From 27f65b8e4c59d24a55083254ef792a1ddcd0fb8f Mon Sep 17 00:00:00 2001 From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com> Date: Sat, 30 Nov 2024 18:31:14 +0100 Subject: [PATCH] expose all of the JournalPageData stuff --- docs/game_data/spel2.lua | 40 ++++++++ docs/src/includes/_types.md | 73 ++++++++++++++ src/game_api/game_manager.hpp | 35 ++++--- src/game_api/screen.hpp | 2 +- .../script/usertypes/game_manager_lua.cpp | 95 ++++++++++++++++++- 5 files changed, 231 insertions(+), 14 deletions(-) diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index 915759e34..0724d29f4 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -2356,6 +2356,46 @@ do ---@class SaveRelated ---@field journal_popup_ui JournalPopupUI + ---@field places_data table @Scale and offset not used in those pages. Can't add more + ---@field bestiary_data table + ---@field monster_part_to_main table @used to map stuff like Osiris_Hand -> Osiris_Head, Hundun limbs -> Hundun etc. + ---@field people_info table + ---@field people_part_to_main table @used to map shopkeeper clone to shopkeeper only + ---@field item_info table + ---@field trap_info table + ---@field trap_part_to_main table @used for stuff like upsidedown_spikes -> spikes, skulldrop skulls -> skulldrop trap etc. + ---@field stickers_data table + ---@field get_SaveData fun(self): SaveData @Gets local version of the SaveData + +---@class JournalPageData + ---@field page_nr integer + ---@field sprite_id integer + ---@field name STRINGID + ---@field description STRINGID + ---@field scale number + ---@field offset_x number + ---@field offset_y number + +---@class JournalBestiaryData : JournalPageData + ---@field texture TEXTURE + ---@field background_sprite_id integer + ---@field killed_by_NA boolean + ---@field defeated_NA boolean + +---@class JournalPeopleData : JournalPageData + ---@field texture TEXTURE + ---@field background_sprite_id integer + ---@field killed_by_NA boolean + ---@field defeated_NA boolean + ---@field portret_texture TEXTURE + +---@class JournalTrapData : JournalPageData + ---@field texture TEXTURE + ---@field background_sprite_id integer + +---@class StickersData + ---@field sprite_id integer + ---@field texture TEXTURE ---@class JournalPopupUI ---@field wiggling_page_icon TextureRenderingInfo diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index 30a4ae45e..6d2d8d18f 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -779,6 +779,20 @@ Type | Name | Description [ENT_TYPE](#ENT_TYPE) | [owner_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_type) | int | [owner_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_uid) | +### JournalPageData + +Used in [SaveRelated](#SaveRelated) + +Type | Name | Description +---- | ---- | ----------- +int | [page_nr](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=page_nr) | +int | [sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sprite_id) | +[STRINGID](#Aliases) | [name](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=name) | +[STRINGID](#Aliases) | [description](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=description) | +float | [scale](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=scale) | +float | [offset_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset_x) | +float | [offset_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset_y) | + ### KeyboardKey @@ -1028,6 +1042,15 @@ Type | Name | Description int | [column](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=column) | int | [row](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=row) | +### StickersData + +Used in [SaveRelated](#SaveRelated) + +Type | Name | Description +---- | ---- | ----------- +int | [sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sprite_id) | +[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | + ### Triangle @@ -1188,6 +1211,19 @@ array<[ControllerInput](#ControllerInput), 12> | [controller](https://gith ## Journal types +### JournalBestiaryData + +Used in [SaveRelated](#SaveRelated) +Derived from [JournalPageData](#JournalPageData) + + +Type | Name | Description +---- | ---- | ----------- +[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | +int | [background_sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=background_sprite_id) | +bool | [killed_by_NA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=killed_by_NA) | +bool | [defeated_NA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=defeated_NA) | + ### JournalPage Used in [set_callback](#set_callback) with [ON](#ON).RENDER_POST_JOURNAL_PAGE @@ -1368,6 +1404,31 @@ Type | Name | Description [TextureRenderingInfo](#TextureRenderingInfo) | [trap_icon](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=trap_icon) | [TextureRenderingInfo](#TextureRenderingInfo) | [trap_background](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=trap_background) | +### JournalPeopleData + +Used in [SaveRelated](#SaveRelated) +Derived from [JournalPageData](#JournalPageData) + + +Type | Name | Description +---- | ---- | ----------- +[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | +int | [background_sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=background_sprite_id) | +bool | [killed_by_NA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=killed_by_NA) | +bool | [defeated_NA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=defeated_NA) | +[TEXTURE](#TEXTURE) | [portret_texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=portret_texture) | + +### JournalTrapData + +Used in [SaveRelated](#SaveRelated) +Derived from [JournalPageData](#JournalPageData) + + +Type | Name | Description +---- | ---- | ----------- +[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | +int | [background_sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=background_sprite_id) | + ## Levelgen types @@ -1966,6 +2027,7 @@ float | [sinewave_angle](https://github.com/spelunky-fyi/overlunky/search?l=Lua& ### JournalPopupUI +Used in [SaveRelated](#SaveRelated) Type | Name | Description ---- | ---- | ----------- @@ -2052,10 +2114,21 @@ int | [visibility](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=visi ### SaveRelated +Used in [GameManager](#GameManager) Type | Name | Description ---- | ---- | ----------- [JournalPopupUI](#JournalPopupUI) | [journal_popup_ui](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_popup_ui) | +map<int, [JournalPageData](#JournalPageData)> | [places_data](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=places_data) | Scale and offset not used in those pages. Can't add more +map<[ENT_TYPE](#ENT_TYPE), [JournalBestiaryData](#JournalBestiaryData)> | [bestiary_data](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=bestiary_data) | +map<[ENT_TYPE](#ENT_TYPE), [ENT_TYPE](#ENT_TYPE)> | [monster_part_to_main](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=monster_part_to_main) | used to map stuff like Osiris_Hand -> Osiris_Head, [Hundun](#Hundun) limbs -> [Hundun](#Hundun) etc. +map<[ENT_TYPE](#ENT_TYPE), [JournalPeopleData](#JournalPeopleData)> | [people_info](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=people_info) | +map<[ENT_TYPE](#ENT_TYPE), [ENT_TYPE](#ENT_TYPE)> | [people_part_to_main](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=people_part_to_main) | used to map shopkeeper clone to shopkeeper only +map<[ENT_TYPE](#ENT_TYPE), [JournalPageData](#JournalPageData)> | [item_info](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=item_info) | +map<[ENT_TYPE](#ENT_TYPE), [JournalPageData](#JournalPageData)> | [trap_info](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=trap_info) | +map<[ENT_TYPE](#ENT_TYPE), [ENT_TYPE](#ENT_TYPE)> | [trap_part_to_main](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=trap_part_to_main) | used for stuff like upsidedown_spikes -> spikes, skulldrop skulls -> skulldrop trap etc. +map<[ENT_TYPE](#ENT_TYPE), [StickersData](#StickersData)> | [stickers_data](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=stickers_data) | +[SaveData](#SaveData) | [get_SaveData()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_SaveData) | Gets local version of the [SaveData](#SaveData) ### Screen diff --git a/src/game_api/game_manager.hpp b/src/game_api/game_manager.hpp index 704d31068..f4f582940 100644 --- a/src/game_api/game_manager.hpp +++ b/src/game_api/game_manager.hpp @@ -39,8 +39,9 @@ struct JournalPopupUI // uint8_t padding[3]; // probably? }; -class JournalData +class JournalPageData { + public: uint32_t page_nr; uint32_t sprite_id; STRINGID name; @@ -50,16 +51,18 @@ class JournalData float offset_y; }; -class JournalBestiaryData : public JournalData +class JournalBestiaryData : public JournalPageData { + public: TEXTURE texture; uint32_t background_sprite_id; bool killed_by_NA; bool defeated_NA; }; -class JournalPeopleData : public JournalData +class JournalPeopleData : public JournalPageData { + public: TEXTURE texture; uint32_t background_sprite_id; bool killed_by_NA; @@ -68,8 +71,9 @@ class JournalPeopleData : public JournalData TEXTURE portret_texture; }; -class JournalTrapData : public JournalData +class JournalTrapData : public JournalPageData { + public: TEXTURE texture; uint32_t background_sprite_id; }; @@ -88,16 +92,25 @@ struct SaveRelated ENT_TYPE player_entity; // for the journal stuff, probably the leader? ENT_TYPE progress_stickers_powerups[29]; // pre-journal progress setup, maybe gathering from all players or something? - /// Scale and offset not used - game_unordered_map places_data; + /// Scale and offset not used in those pages. Can't add more + game_unordered_map places_data; game_unordered_map bestiary_data; - game_unordered_map monster_part_to_main; // used to map stuff like Osiris_Hand -> Osiris_Head, Hundun limbs -> Hundun etc. + /// used to map stuff like Osiris_Hand -> Osiris_Head, Hundun limbs -> Hundun etc. + game_unordered_map monster_part_to_main; game_unordered_map people_info; - game_unordered_map people_part_to_main; // used to map shopkeeper clone to shopkeeper only - game_unordered_map item_info; - game_unordered_map trap_info; - game_unordered_map trap_part_to_main; // used for stuff like upsidedown_spikes -> spikes, skulldrop skulls -> skulldrop trap etc. + /// used to map shopkeeper clone to shopkeeper only + game_unordered_map people_part_to_main; + game_unordered_map item_info; + game_unordered_map trap_info; + /// used for stuff like upsidedown_spikes -> spikes, skulldrop skulls -> skulldrop trap etc. + game_unordered_map trap_part_to_main; game_unordered_map stickers_data; + + /// Gets local version of the SaveData + SaveData* get_SaveData() + { + return savedata.decode_local(); + } }; struct BGMUnknown diff --git a/src/game_api/screen.hpp b/src/game_api/screen.hpp index 6307b76b6..5bb626e31 100644 --- a/src/game_api/screen.hpp +++ b/src/game_api/screen.hpp @@ -506,7 +506,7 @@ class ScreenCharacterSelect : public Screen // ID: 9 float start_panel_slidein; float action_buttons_keycap_size; bool screen_loading; // locks the inputs? - bool unknown64b; // sets the state.ingame + bool unknown64b; // sets the state.ingame bool seeded_run; bool daily_challenge; uint32_t next_screen_to_load; diff --git a/src/game_api/script/usertypes/game_manager_lua.cpp b/src/game_api/script/usertypes/game_manager_lua.cpp index ebfd36923..2d1ec85e3 100644 --- a/src/game_api/script/usertypes/game_manager_lua.cpp +++ b/src/game_api/script/usertypes/game_manager_lua.cpp @@ -10,8 +10,9 @@ #include "game_manager.hpp" // for GameManager, JournalPopupUI, GameProps #include "memory.hpp" // for memory_read TODO:temp +#include "savedata.hpp" // for SaveData #include "screen.hpp" // IWYU pragma: keep -#include "script/sol_helper.hpp" // +#include "script/sol_helper.hpp" // for ZeroIndexArray namespace NGM { @@ -78,10 +79,99 @@ void register_usertypes(sol::state& lua) gamemanager_type["buttons_controls"] = &GameManager::buttons_controls; gamemanager_type["buttons_movement"] = &GameManager::buttons_movement; + /// Used in GameManager lua.new_usertype( "SaveRelated", "journal_popup_ui", - &SaveRelated::journal_popup_ui); + &SaveRelated::journal_popup_ui, + "places_data", + &SaveRelated::places_data, + "bestiary_data", + &SaveRelated::bestiary_data, + "monster_part_to_main", + &SaveRelated::monster_part_to_main, + "people_info", + &SaveRelated::people_info, + "people_part_to_main", + &SaveRelated::people_part_to_main, + "item_info", + &SaveRelated::item_info, + "trap_info", + &SaveRelated::trap_info, + "trap_part_to_main", + &SaveRelated::trap_part_to_main, + "stickers_data", + &SaveRelated::stickers_data, + "get_SaveData", + &SaveRelated::get_SaveData); + + /// Used in SaveRelated + lua.new_usertype( + "JournalPageData", + "page_nr", + &JournalPageData::page_nr, + "sprite_id", + &JournalPageData::sprite_id, + "name", + &JournalPageData::name, + "description", + &JournalPageData::description, + "scale", + &JournalPageData::scale, + "offset_x", + &JournalPageData::offset_x, + "offset_y", + &JournalPageData::offset_y); + + /// Used in SaveRelated + lua.new_usertype( + "JournalBestiaryData", + "texture", + &JournalBestiaryData::texture, + "background_sprite_id", + &JournalBestiaryData::background_sprite_id, + "killed_by_NA", + &JournalBestiaryData::killed_by_NA, + "defeated_NA", + &JournalBestiaryData::defeated_NA, + sol::base_classes, + sol::bases()); + + /// Used in SaveRelated + lua.new_usertype( + "JournalPeopleData", + "texture", + &JournalPeopleData::texture, + "background_sprite_id", + &JournalPeopleData::background_sprite_id, + "killed_by_NA", + &JournalPeopleData::killed_by_NA, + "defeated_NA", + &JournalPeopleData::defeated_NA, + "portret_texture", + &JournalPeopleData::portret_texture, + sol::base_classes, + sol::bases()); + + /// Used in SaveRelated + lua.new_usertype( + "JournalTrapData", + "texture", + &JournalTrapData::texture, + "background_sprite_id", + &JournalTrapData::background_sprite_id, + sol::base_classes, + sol::bases()); + + /// Used in SaveRelated + lua.new_usertype( + "StickersData", + "sprite_id", + &StickersData::sprite_id, + "texture", + &StickersData::texture); + + /// Used in SaveRelated lua.new_usertype( "JournalPopupUI", "wiggling_page_icon", @@ -100,6 +190,7 @@ void register_usertypes(sol::state& lua) &JournalPopupUI::timer, "slide_position", &JournalPopupUI::slide_position); + auto gameprops_type = lua.new_usertype("GameProps"); /// NoDoc gameprops_type["buttons"] = sol::property([](GameProps& gp) -> uint32_t