nurpax / petmate

PETSCII editor with Electron/React/Redux
MIT License
183 stars 14 forks source link

Add single chargen file support #173

Closed manuelvio closed 4 years ago

manuelvio commented 4 years ago

I've added very basic support for single chargen files to simplify a bit the use of custom charsets. The code tries to load a file called "chargen" in the asset folder and, if not present, falls back to normal behaviour and loads the usual couple of charsets files that get shipped with petmate.

This is an example of petmate with an unsettling charset found in the deepest abyss of internet: PETZXSCII

The chargen file should contain the two charsets (upper and lower case) summing to a total of 4096 bytes, but it can be loaded even if it carries partial character sets, like this example: Schermata del 2019-11-14 22-23-18 In the image above the font is "Action wave", and it has been downloaded from here. Here a trick has been used to get the font correctly loaded: its original size is oddly 514 bytes and it has been converted to 512 bytes using the (linux) shell command tail -c 512 action_wave.64c > chargen getting rid of the first two bytes.

Esshahn commented 4 years ago

Love it! Thanks!

nurpax commented 4 years ago

@manuelvio I like the feature and think it's something Petmate needs. However, I kinda have a different plan for plumbing this into Petmate. See, I'd like there to be a file dialog where a font file can be selected from the filesystem (as opposed to hardcoding to assets/chargen under Petmate install dir). Requiring the user to stick any files into the Petmate installation doesn't feel very discoverable, and in fact may not work at all on some platforms due to application bundles and app permissions.

Furthermore, I'd like any fonts loaded into Petmate and used in a screen to also be saved into a .petmate file.. so that if I share a .petmate file to someone else and use a special font in it, I'd like the font to be included in the workspace file.. so that that someone else will see the same thing I saw when I saved the file.

Alas, implementing what I said above is sort of complicated.. and so I think I'll just have to roll up my sleeves and implement it myself.

I guess UI-wise it'd look like there's a button "Custom.." below the charset ABC|abc selector. If you click it, a settings type of dialog with an option to load a file pops up. If you load a font this way, it'll be included in the current .petmate workspace, and saved along with any other content.

nurpax commented 4 years ago

@manuelvio big thanks for sending this PR! This motivated me to put some work into this. I started on the redux plumbing part and it's not really easy to navigate all that code (even for me). Let's move comments over to #174. I'm closing this PR but worry not, this feature is going to be included in Petmate soon.

manuelvio commented 4 years ago

Thank you @nurpax, I'm glad that my contribution (which, I admit it, was pretty much a hack) was helpful to start this refactoring process. Keep up the good work!