Loading bitmap files outside Data folder #193

Open
opened 2018-03-28 19:01:54 +00:00 by JoaoFelipe · 5 comments
JoaoFelipe commented 2018-03-28 19:01:54 +00:00 (Migrated from github.com)

Hi, I'm developing a translation system for Rakuen that replaces game images by translated images in a distinct directory (outside Data): f999882557/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?

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 commented 2018-03-28 19:34:13 +00:00 (Migrated from github.com)

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.

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.
Ancurio commented 2018-03-28 19:54:30 +00:00 (Migrated from github.com)

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

Can you isolate a test case where mkxp doesn't load a Bitmap correctly?
JoaoFelipe commented 2018-03-28 20:38:49 +00:00 (Migrated from github.com)

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.

Here it is: https://github.com/JoaoFelipe/mkxp-issue193 In the Override_Bitmap script I have: ```ruby 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.
ReinUsesLisp commented 2018-03-29 03:47:15 +00:00 (Migrated from github.com)

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.

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`: ```ruby # 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.
Ancurio commented 2018-03-29 05:25:31 +00:00 (Migrated from github.com)

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.

> 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.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: MapleShrine/mkxp#193
No description provided.