<Index> - >DevDiary< - <Characters> - <Lore>
This week, I worked on the key binds and the file system.
I have figured out how to process arbitrary inputs in Godot and how to isolate key presses and their properties. Before this point, SDR used Godot's built-in input maps. Now I have introduced a code-side input map of my own, and a menu that allows the player to change the key binds.
The controls menu with the default key binds.
Each control in SDR now has three properties: the system name of the control (for example, "ARROW_UP" or "SWORD_LEFT"), the menu name of the key the control is bound to (as seen in the screenshot above), and the scancode of the key the control is bound to.
The scancode system is using Godot's built-in scancode catcher, which seems to differ from typical scancodes, as Godot thinks my Escape key has a scancode of 4194305, whereas online scancode detectors say that it's 27. I am slightly worried that this will introduce control issues on other machines. The alphanumeric keys seem to have "normal" scancodes, at least.
A downside of using scancodes, I'm afraid, is the distancing of SDR from the ability to play it on anything that isn't a keyboard, including controllers, mice, joysticks, wheels etc. On one hand, I am aware that a lot of people prefer playing games on a controller, and it is on me for making SDR incompatible with it. On the other hand, the rapid repeating key presses that are prevalent in Sunrise Doll gameplay would most likely render it unplayable on a controller anyway.
An alternate set of key binds, more similar to a typical controller.
The menu names of the keys are taken from the names that Godot assigns to scancodes on its own. Theoretically it may pick up and display nearly any keyboard key. The only keys on my keyboard that were not picked up were Printscreen, Function and Menu. Godot does not differentiate between left and right Shifts, Alts and Controls, but does differentiate between numpad keys pressed with NumLock enabled and disabled.
Key binds with the longest names I could find on my keyboard.
The key binds get properly saved into a local file. If the game cannot detect the key binds file upon starting up, it automatically creates one with the default key binds. Godot suggests saving files into specific app data directories, which I do not like, as I want all files of an application to be stored within its executable directory. Thankfully, there is an option to do precisely that, although I am warned that it may cause problems if the project's file system is in read-only mode.
The appdata locations according to Godot 4.0 documentation.
If the problems do arise, I will have to submit and use the appdata directories, and fortunately the transfer boils down to changing a single string in the code.
Now when I have a reliable way to save and load files, I can start moving the stage setup logic there. This is an important step that will make it easier to build stages both for me and the player.