mkxp icon indicating copy to clipboard operation
mkxp copied to clipboard

Loading bitmap files outside Data folder

Open JoaoFelipe opened this issue 6 years ago • 5 comments

Hi, I'm developing a translation system for Rakuen that replaces game images by translated images in a distinct directory (outside Data): https://github.com/JoaoFelipe/rakuen-translation/blob/f999882557bf085f2456fe6ca22c4f77f300fc40/mods/translation/languages.rb#L315

It works on rpg maker engine, but when I try to execute it with mkxp, it doesn't find the file, but states the right path. Is this a mkxp limitation? Any suggestions on a workaround?

JoaoFelipe avatar Mar 28 '18 19:03 JoaoFelipe

I managed to load the external images by moving the mods directory to Data, but it is still an inconsistency between the engines. So I will leave the issue open.

JoaoFelipe avatar Mar 28 '18 19:03 JoaoFelipe

Can you isolate a test case where mkxp doesn't load a Bitmap correctly?

Ancurio avatar Mar 28 '18 19:03 Ancurio

Here it is: https://github.com/JoaoFelipe/mkxp-issue193 In the Override_Bitmap script I have:

class Bitmap
  alias_method :old_initialize, :initialize
  
  def initialize(*args)
    if args.size == 1
      result = args[0]
      if args[0] == "Graphics/Titles/TitleBG"
        result = "#{Dir.getwd}/TitleBG.png"
      end
      args[0] = result
    end
    old_initialize(*args)
    
  end
end

It basically overrides the Graphics/Titles/TitleBG (that is configured as the game title image) by TitleBG.png in the project root.

The Game.exe from rpg maker xp works, but neither mkxp.exe nor mkxp.amd64 are able to load the file in the project root.

JoaoFelipe avatar Mar 28 '18 20:03 JoaoFelipe

I can reproduce it. It seems to be a bug (since you say it doesn't fail on Game.exe).

For now, just remove Dir.getwd:

# replace
result = "#{Dir.getwd}/TitleBG.png"
# with
result = "TitleBG.png"

I think this is because PhysFS (or Filesystem object) is not searching in absolute paths.

ReinUsesLisp avatar Mar 29 '18 03:03 ReinUsesLisp

I think this is because PhysFS (or Filesystem object) is not searching in absolute paths.

I haven't tested yet, but this is a strong contender for the issue. @JoaoFelipe Is there a reason you need to prefix the path with the absolute current directory? mkxp always resolves paths to assets (bitmaps, music) relative to the game directory, so it should work even if you're outside the Data or Graphics folder; being outside the game folder however would be a bit problematic.

Ancurio avatar Mar 29 '18 05:03 Ancurio