Module Patch: http://pastebin.com/u5gYFWkx
-
Unfortunately, I had to write this for B34 because the SVN version doesn't print out log files for me. I could apply the patch to the B35 scripts, but I don't trust my compile of B35 so I'm not sure that I'd be able to properly test it.
-
With this patch, a player's hotbar preferences are saved between games. The player's preferences are stored in two tables: One is the "Player: Global" table where the most recent position of a hotkey is constantly updated. The other is the "Player: Specific" table where hotkeys are stored according to both the player's race/subrace and class/subclass. Additionally, new tables are created and saved for any creature that has the "save_hotkeys" flag set to true (currently, any summons and the alchemist golem). Any inventory items with the "save_hotkey" flag set to true are also saved to the tables (at the moment, this only includes the Orb of Knowledge and the Orb of Scrying).
Here are some practical examples of how this functionality works:
The player's first post-patch character is a Cornac Rogue. He puts the Infusion: Regeneration hotkey in Page 1, Slot 6 (P1S6) and he puts the Orb of Scrying hotkey in P3S12. These hotkeys are immediately updated in the "Player: Global" table in addition to the Cornac-Rogue table, but the changes won't be persist until the game is saved.
He then creates a Dwarf Archmage. The code automatically assigns the Infusion: Regeneration hotkey to P1S6 and the Orb of Knowledge hotkey to P3S12. The player remembers the fourth hotbar is now working, so he moves his Orb of Knowledge hotkey to P4S12. The "Player: Global" and Dwarf-Archmage tables are immediately updated with that change. That character dies, so he decides to play a Skeleton Rogue. The Orb of Knowledge hotkey is auto-sorted to P4S12.
That Skeleton Rogue meets an early end. The player creates another Cornac Rogue. His regeneration infusion is sorted to P1S6, but his Orb of Knowledge is sorted to P3S12. This is because specific preferences (race+class) always override global (whichever slot the hotkey was most recently assigned to) preferences.
If two hotkeys are set to be auto-assigned to the same key (P1S0, for example), one will be assigned to P1S0 and the other will instead be assigned to the earliest available slot (P1S1, if no hotkey exists there).
The tables are loaded from the save/quick_hotkeys file every time a previously-created game is loaded or a new game is created, allowing the player to always keep his preferences up-to-date.
- Bug Fixes -
- Hotkeys are now properly displayed on the fourth hotbar
- Hotkeys will no longer disappear when dragged into a section of the hotbar that does not have a proper page defined for it
- Hotkeys will no longer be duplicated on the hotbar for creatures that call engine.interface.PlayerHotkeys:hotkeyAutoTalents
- The attack hotkey will no longer appear on the hotbar for creatures that call engine.interface.PlayerHotkeys:hotkeyAutoTalents
- engine.Savefile.hotkeys_file - Path of the quick hotkeys file (currently statically set to "/save/quick_hotkeys").
- engine.interface.PlayerHotkeys.quickhotkeys - Static table containing all of the hotkey preferences tables.
- engine.interface.PlayerHotkeys.quickhotkeys_specifics - Static array containing any appropriate functions for keying how the module would like to distinguish between "Player: Global" and "Player: Specific" hotkeys. In the ToME4 module, these functions return a string containing the player's race/subrace (or npc type) and class/subclass (or npc subtype). The functions should always be inserted into the array in the appropriate order.
- [item].save_hotkey - Tells the engine to save the item's most recent hotkey slot in the appropriate tables.
- [actor].save_hotkeys - Tells the engine to dump all of the actor's hotkey slots to the appropriate tables. This does not need to be assigned to the main player.
- [talent].ignored_by_hotkeyautotalents - Prevent engine.interface.PlayerHotkeys:hotkeyAutoTalents from creating a hotkey for any talents with this flag set to true. Currently, T_ATTACK is the only talent with this flag enabled.