Skip to content

Commit

Permalink
expose all of the JournalPageData stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Nov 30, 2024
1 parent 82b3ca3 commit 27f65b8
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 14 deletions.
40 changes: 40 additions & 0 deletions docs/game_data/spel2.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions docs/src/includes/_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -1966,6 +2027,7 @@ float | [sinewave_angle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&

### JournalPopupUI

Used in [SaveRelated](#SaveRelated)

Type | Name | Description
---- | ---- | -----------
Expand Down Expand Up @@ -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

Expand Down
35 changes: 24 additions & 11 deletions src/game_api/game_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
};
Expand All @@ -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<uint8_t, JournalData> places_data;
/// Scale and offset not used in those pages. Can't add more
game_unordered_map<uint8_t, JournalPageData> places_data;
game_unordered_map<ENT_TYPE, JournalBestiaryData> bestiary_data;
game_unordered_map<ENT_TYPE, ENT_TYPE> 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<ENT_TYPE, ENT_TYPE> monster_part_to_main;
game_unordered_map<ENT_TYPE, JournalPeopleData> people_info;
game_unordered_map<ENT_TYPE, ENT_TYPE> people_part_to_main; // used to map shopkeeper clone to shopkeeper only
game_unordered_map<ENT_TYPE, JournalData> item_info;
game_unordered_map<ENT_TYPE, JournalData> trap_info;
game_unordered_map<ENT_TYPE, ENT_TYPE> 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<ENT_TYPE, ENT_TYPE> people_part_to_main;
game_unordered_map<ENT_TYPE, JournalPageData> item_info;
game_unordered_map<ENT_TYPE, JournalPageData> trap_info;
/// used for stuff like upsidedown_spikes -> spikes, skulldrop skulls -> skulldrop trap etc.
game_unordered_map<ENT_TYPE, ENT_TYPE> trap_part_to_main;
game_unordered_map<ENT_TYPE, StickersData> stickers_data;

/// Gets local version of the SaveData
SaveData* get_SaveData()
{
return savedata.decode_local();
}
};

struct BGMUnknown
Expand Down
2 changes: 1 addition & 1 deletion src/game_api/screen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
95 changes: 93 additions & 2 deletions src/game_api/script/usertypes/game_manager_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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>(
"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>(
"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>(
"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<JournalPageData>());

/// Used in SaveRelated
lua.new_usertype<JournalPeopleData>(
"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<JournalPageData>());

/// Used in SaveRelated
lua.new_usertype<JournalTrapData>(
"JournalTrapData",
"texture",
&JournalTrapData::texture,
"background_sprite_id",
&JournalTrapData::background_sprite_id,
sol::base_classes,
sol::bases<JournalPageData>());

/// Used in SaveRelated
lua.new_usertype<StickersData>(
"StickersData",
"sprite_id",
&StickersData::sprite_id,
"texture",
&StickersData::texture);

/// Used in SaveRelated
lua.new_usertype<JournalPopupUI>(
"JournalPopupUI",
"wiggling_page_icon",
Expand All @@ -100,6 +190,7 @@ void register_usertypes(sol::state& lua)
&JournalPopupUI::timer,
"slide_position",
&JournalPopupUI::slide_position);

auto gameprops_type = lua.new_usertype<GameProps>("GameProps");
/// NoDoc
gameprops_type["buttons"] = sol::property([](GameProps& gp) -> uint32_t
Expand Down

0 comments on commit 27f65b8

Please sign in to comment.