EasyRPG / liblcf

Library to handle RPG Maker 2000/2003 and EasyRPG projects
https://easyrpg.org
MIT License
115 stars 55 forks source link

Read/write RPG Maker editor's clipboard data. #402

Open elsemieni opened 3 years ago

elsemieni commented 3 years ago

I don't know if it belongs here or to the editor. However, since it have similarities to LCF data, I will post here.

RPG Maker editor uses a particular binary format when you copy event data. It seems these had some similarities to LCF files. (but obviously, with different headers, data layout and so on). It will be useful that liblcf handles these data in some sort of way (well, there's not files particulary but clipboard data, that can complicate the things, since each OS handle clipboard data in a different way). Maybe it can be abstracted in liblcf by just read/write data (leaving read/write to clipboard to the program that uses liblcf, for not saying Editor).

For analysis, I used CLCL (https://www.nakka.com/soft/clcl/index_eng.html ) for dumping/writing binary data to the clipboard. I'll attach some examples of the obtained clipboard data, from 2k3e:

2k3e_clipboard_data_sample.zip

Map and events:

Database (all of these have normal and multicopy feature, when available).

One special comment about Event Commands: In english releases, event commands copies more than just binary data, it also put the following in the clipboard, considering 2 Message event commands:

Then most programs will recognize EventCommand data and will paste it as text (perhaps it's a feature to allow share events in communities?).

I tried to see some of these commands (in a very vague way) and it have some similarities and differences between LCF files. Let me put an example with a Map copied to the clipboard, in conjuntion with it's lmu file: image

Also, as closing words; there's a tool made by Cherry called RMEventFactory (http://cherrytree.at/cms/lang/en/download/?did=11) that already handles clipboard event data, allowing batch replacing values, intended for making engines or override default values to make out-of-range commands. However, it is not "compatible" with 2k3e beacuse it recognizes as text instead a maker data (however, if you remove the text by using tools or by pasting it in a older editor and then copying it again, the program can recgonize it without trouble).

Ghabry commented 3 years ago

see also https://github.com/EasyRPG/Editor/issues/120

CherryDT commented 3 years ago

However, it is not "compatible" with 2k3e beacuse it recognizes as text instead a maker data (however, if you remove the text by using tools or by pasting it in a older editor and then copying it again, the program can recgonize it without trouble).

Thanks for pointing that out. Replace eventfactory.dll with this version to fix it: https://cherryshare.at/f/8d7Bbn/eventfactory.dll

(Yeah, I wasn't able to get my old code to compile properly with my current environment so I instead just binary-patched my own tool to fix this.)

Then most programs will recognize EventCommand data and will paste it as text (perhaps it's a feature to allow share events in communities?).

Yes it is, I also wrote that in the helpfile and the changelog for v1.10:

When event script lines are copied to the clipboard, they are now additionally stored in text format.

  • This will allow event scripts to be copied to text editors, web forums, etc.
  • Please note that this does not work the other way round!
fdelapena commented 3 years ago

This excellent HSP module by @fermiumbay allows to script event commands using HSP language for convenience. It allows converting from event commands to HSP script and vice-versa. It is useful for game developers, also helps to set values above/below limits with ease and without patching binaries. The module script source code self-documents how to parse the clipboard for all event commands. More information and download:

https://fermiumbay16.jimdofree.com/%E6%8A%80%E8%A1%93/rpg%E3%83%84%E3%82%AF%E3%83%BC%E3%83%AB%E7%94%A8%E8%87%AA%E8%A3%BD%E3%83%84%E3%83%BC%E3%83%AB/rpg%E3%83%84%E3%82%AF%E3%83%BC%E3%83%AB200x-%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E5%91%BD%E4%BB%A4%E3%81%AE%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E5%8C%96%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB/

It requires HSP3 to run. Please note some command parsing could fail on non-Japanese (English translation) event editors because some values are directly parsed from the event command human-readable output.

To learn more about HSP: Documentation: https://www.onionsoft.net/hsp/v36en/ Prebuilt binaries for Windows: https://github.com/onitama/OpenHSP/releases (it could trigger some false positives on some antivirus like Windows Defender)