diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index c45efe048..70a994926 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -2067,7 +2067,7 @@ do ---@class SelectPlayerSlot ---@field activated boolean ---@field character ENT_TYPE - ---@field texture integer + ---@field texture TEXTURE ---@class Items ---@field player_count integer @@ -2444,7 +2444,7 @@ function PRNG:random(min, max) end ---@field life integer ---@field sacrifice_value integer @Favor for sacrificing alive. Halved when dead (health == 0). ---@field blood_content integer - ---@field texture integer + ---@field texture TEXTURE ---@field animations table ---@field properties_flags integer ---@field default_flags integer @@ -4540,8 +4540,8 @@ function MovableBehavior:get_state_id() end ---@field blue integer ---@field permanent boolean ---@field invisible boolean - ---@field get_texture fun(self): integer - ---@field set_texture fun(self, texture_id: integer): boolean + ---@field get_texture fun(self): TEXTURE + ---@field set_texture fun(self, texture_id: TEXTURE): boolean ---@class ParticleEmitterInfo ---@field particle_type ParticleDB @@ -4603,14 +4603,14 @@ function MovableBehavior:get_state_id() end ---@field get_level_file fun(self): string @Returns: The .lvl file to load (e.g. dwelling = dwellingarea.lvl except when level == 4 (cavebossarea.lvl)) ---@field get_theme_id fun(self): integer @Returns: THEME, or subtheme in CO ---@field get_base_id fun(self): integer @Returns: THEME, or logical base THEME for special levels (Abzu->Tide Pool etc) - ---@field get_floor_spreading_type fun(self): integer @Returns: ENT_TYPE used for floor spreading (generic or one of the styled floors) - ---@field get_floor_spreading_type2 fun(self): integer @Returns: ENT_TYPE used for floor spreading (stone or one of the styled floors) + ---@field get_floor_spreading_type fun(self): ENT_TYPE @Returns: ENT_TYPE used for floor spreading (generic or one of the styled floors) + ---@field get_floor_spreading_type2 fun(self): ENT_TYPE @Returns: ENT_TYPE used for floor spreading (stone or one of the styled floors) ---@field get_transition_styled_floor fun(self): boolean @Returns: true if transition should use styled floor ---@field get_transition_floor_modifier fun(self): integer @Determines the types of FLOOR_TUNNEL_NEXT/CURRENT (depending on where you are transitioning from/to)
Returns: 85 by default, except for: olmec: 15, cog: 23 - ---@field get_transition_styled_floor_type fun(self): integer @Returns: ENT_TYPE used for the transition floor - ---@field get_backwall_type fun(self): integer @Returns: ENT_TYPE used for the backwall (BG_LEVEL_BACKWALL by default) - ---@field get_border_type fun(self): integer @Returns: ENT_TYPE to use for the border tiles - ---@field get_critter_type fun(self): integer @Returns: ENT_TYPE for theme specific critter + ---@field get_transition_styled_floor_type fun(self): ENT_TYPE @Returns: ENT_TYPE used for the transition floor + ---@field get_backwall_type fun(self): ENT_TYPE @Returns: ENT_TYPE used for the backwall (BG_LEVEL_BACKWALL by default) + ---@field get_border_type fun(self): ENT_TYPE @Returns: ENT_TYPE to use for the border tiles + ---@field get_critter_type fun(self): ENT_TYPE @Returns: ENT_TYPE for theme specific critter ---@field get_liquid_gravity fun(self): number @Returns: gravity used to initialize liquid pools (-1..1) ---@field get_player_damage fun(self): boolean @Returns: false to disable most player damage and the usage of bombs and ropes. Enabled in parts of base camp. ---@field get_explosion_soot fun(self): boolean @Returns: true if explosions should spawn background soot @@ -4619,7 +4619,7 @@ function MovableBehavior:get_state_id() end ---@field get_loop fun(self): boolean @Returns: true if the loop rendering should be enabled (Combine with the right get_border_type) ---@field get_vault_level fun(self): integer @Returns: highest y-level a vault can spawn ---@field get_theme_flag fun(self, index: integer): boolean @Returns: allow_beehive or allow_leprechaun flag
Params: index: 0 or 1 - ---@field get_dynamic_texture fun(self, texture_id: integer): integer @Returns: TEXTURE based on texture_id
Params: DYNAMIC_TEXTURE texture_id + ---@field get_dynamic_texture fun(self, texture_id: DYNAMIC_TEXTURE): TEXTURE @Returns: TEXTURE based on texture_id
Params: DYNAMIC_TEXTURE texture_id ---@field pre_transition fun(self): nil @Sets state.level_next, world_next and theme_next (or state.win_state) based on level number. Runs when exiting a level. ---@field get_exit_room_y_level fun(self): integer @Returns: usually state.height - 1. For special levels fixed heights are returned. ---@field get_shop_chance fun(self): integer @Returns: inverse shop chance @@ -4737,7 +4737,7 @@ function MovableBehavior:get_state_id() end ---@field level_file string @Level file to load. Probably doesn't do much in custom themes, especially if you're forcing them in PRE_LOAD_LEVEL_FILES. ---@field theme integer @Theme index. Probably shouldn't collide with the vanilla ones. Purpose unknown. ---@field base_theme integer @Base THEME to load enabled functions from, when no other theme is specified. - ---@field textures table @Add TEXTUREs here to override different dynamic textures. + ---@field textures table @Add TEXTUREs here to override different dynamic textures. ---@field override any @theme_override ---@field pre fun(self, index: THEME_OVERRIDE, func_: function): nil @Set a callback to be called before this theme function. ---@field post fun(self, index: THEME_OVERRIDE, func_: function): nil @Set a callback to be called after this theme function, to fix some changes it did for example. @@ -4784,7 +4784,7 @@ function MovableBehavior:get_state_id() end ---@field get_loop fun(self): boolean ---@field get_vault_level fun(self): integer ---@field get_theme_flag fun(self, index: integer): boolean - ---@field get_dynamic_texture fun(self, texture_id: integer): integer @Add TEXTUREs to `textures` to override different dynamic textures easily. + ---@field get_dynamic_texture fun(self, texture_id: DYNAMIC_TEXTURE): TEXTURE @Add TEXTURE s to `textures` map of the CustomTheme to override different dynamic textures easily. ---@field pre_transition fun(self): nil ---@field get_exit_room_y_level fun(self): integer ---@field get_shop_chance fun(self): integer @@ -5426,7 +5426,7 @@ function VanillaRenderContext:draw_world_poly_filled(points, color) end ---@field text_length integer @You can also just use `#` operator on the whole TextRenderingInfo to get the text lenght ---@field width number ---@field height number - ---@field special_texture_id integer @Used to draw buttons and stuff, default is -1 wich uses the buttons texture + ---@field special_texture_id TEXTURE @Used to draw buttons and stuff, default is -1 wich uses the buttons texture ---@field get_dest fun(self): Letter[] @Returns refrence to the letter coordinates relative to the x,y position ---@field get_source fun(self): Letter[] @Returns refrence to the letter coordinates in the texture ---@field text_size fun(self): number, number @{width, height}, is only updated when you set/change the text. This is equivalent to draw_text_size diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index ccfd1e7e3..5e79677c8 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -475,7 +475,7 @@ int | [damage](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=damage) int | [life](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=life) | int | [sacrifice_value](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sacrifice_value) | Favor for sacrificing alive. Halved when dead (health == 0). int | [blood_content](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=blood_content) | -int | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | +[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | map<int, [Animation](#Animation)> | [animations](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=animations) | int | [properties_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=properties_flags) | int | [default_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_flags) | @@ -1807,8 +1807,8 @@ int | [green](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=green) | int | [blue](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=blue) | bool | [permanent](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=permanent) | bool | [invisible](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=invisible) | -int | [get_texture()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_texture) | -bool | [set_texture(int texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_texture) | +[TEXTURE](#TEXTURE) | [get_texture()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_texture) | +bool | [set_texture(TEXTURE texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_texture) | ### ParticleEmitterInfo @@ -2966,7 +2966,7 @@ Type | Name | Description ---- | ---- | ----------- bool | [activated](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=activated) | [ENT_TYPE](#ENT_TYPE) | [character](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=character) | -int | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | +[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | ### StateMemory @@ -3101,7 +3101,7 @@ float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) | int | [text_length](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=text_length) | You can also just use `#` operator on the whole TextRenderingInfo to get the text lenght float | [width](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=width) | float | [height](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=height) | -int | [special_texture_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=special_texture_id) | Used to draw buttons and stuff, default is -1 wich uses the buttons texture +[TEXTURE](#TEXTURE) | [special_texture_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=special_texture_id) | Used to draw buttons and stuff, default is -1 wich uses the buttons texture span<[Letter](#Letter)> | [get_dest()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_dest) | Returns refrence to the letter coordinates relative to the x,y position span<[Letter](#Letter)> | [get_source()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_source) | Returns refrence to the letter coordinates in the texture tuple<float, float> | [text_size()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=text_size) | {width, height}, is only updated when you set/change the text. This is equivalent to draw_text_size @@ -3212,7 +3212,7 @@ Type | Name | Description string | [level_file](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=level_file) | Level file to load. Probably doesn't do much in custom themes, especially if you're forcing them in PRE_LOAD_LEVEL_FILES. int | [theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme) | Theme index. Probably shouldn't collide with the vanilla ones. Purpose unknown. int | [base_theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=base_theme) | Base [THEME](#THEME) to load enabled functions from, when no other theme is specified. -map<[DYNAMIC_TEXTURE](#DYNAMIC_TEXTURE), int> | [textures](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=textures) | Add TEXTUREs here to override different dynamic textures. +map<[DYNAMIC_TEXTURE](#DYNAMIC_TEXTURE), [TEXTURE](#TEXTURE)> | [textures](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=textures) | Add TEXTUREs here to override different dynamic textures. | [override](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=override) | `override(THEME_OVERRIDE override, bool enabled)` To disable or enable theme functions using the base_theme.
`override(THEME_OVERRIDE override, THEME theme)` To override a theme function with another theme.
`override(THEME_OVERRIDE override, function func)` To override a theme function with a lua function.
nil | [pre(THEME_OVERRIDE index, function func_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pre) | Set a callback to be called before this theme function. nil | [post(THEME_OVERRIDE index, function func_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=post) | Set a callback to be called after this theme function, to fix some changes it did for example. @@ -3259,7 +3259,7 @@ float | [get_backlayer_light_level()](https://github.com/spelunky-fyi/overlunky/ bool | [get_loop()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_loop) | int | [get_vault_level()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_vault_level) | bool | [get_theme_flag(int index)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_theme_flag) | -int | [get_dynamic_texture(int texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_dynamic_texture) | Add TEXTUREs to `textures` to override different dynamic textures easily. +[TEXTURE](#TEXTURE) | [get_dynamic_texture(DYNAMIC_TEXTURE texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_dynamic_texture) | Add [TEXTURE](#TEXTURE) s to `textures` map of the CustomTheme to override different dynamic textures easily. nil | [pre_transition()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pre_transition) | int | [get_exit_room_y_level()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_exit_room_y_level) | int | [get_shop_chance()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_shop_chance) | @@ -3342,14 +3342,14 @@ nil | [spawn_effects()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q string | [get_level_file()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_level_file) | Returns: The .lvl file to load (e.g. dwelling = dwellingarea.lvl except when level == 4 (cavebossarea.lvl)) int | [get_theme_id()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_theme_id) | Returns: [THEME](#THEME), or subtheme in CO int | [get_base_id()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_base_id) | Returns: [THEME](#THEME), or logical base [THEME](#THEME) for special levels (Abzu->Tide Pool etc) -int | [get_floor_spreading_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_floor_spreading_type) | Returns: [ENT_TYPE](#ENT_TYPE) used for floor spreading (generic or one of the styled floors) -int | [get_floor_spreading_type2()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_floor_spreading_type2) | Returns: [ENT_TYPE](#ENT_TYPE) used for floor spreading (stone or one of the styled floors) +[ENT_TYPE](#ENT_TYPE) | [get_floor_spreading_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_floor_spreading_type) | Returns: [ENT_TYPE](#ENT_TYPE) used for floor spreading (generic or one of the styled floors) +[ENT_TYPE](#ENT_TYPE) | [get_floor_spreading_type2()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_floor_spreading_type2) | Returns: [ENT_TYPE](#ENT_TYPE) used for floor spreading (stone or one of the styled floors) bool | [get_transition_styled_floor()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_transition_styled_floor) | Returns: true if transition should use styled floor int | [get_transition_floor_modifier()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_transition_floor_modifier) | Determines the types of FLOOR_TUNNEL_NEXT/CURRENT (depending on where you are transitioning from/to)
Returns: 85 by default, except for: olmec: 15, cog: 23 -int | [get_transition_styled_floor_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_transition_styled_floor_type) | Returns: [ENT_TYPE](#ENT_TYPE) used for the transition floor -int | [get_backwall_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_backwall_type) | Returns: [ENT_TYPE](#ENT_TYPE) used for the backwall (BG_LEVEL_BACKWALL by default) -int | [get_border_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_border_type) | Returns: [ENT_TYPE](#ENT_TYPE) to use for the border tiles -int | [get_critter_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_critter_type) | Returns: [ENT_TYPE](#ENT_TYPE) for theme specific critter +[ENT_TYPE](#ENT_TYPE) | [get_transition_styled_floor_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_transition_styled_floor_type) | Returns: [ENT_TYPE](#ENT_TYPE) used for the transition floor +[ENT_TYPE](#ENT_TYPE) | [get_backwall_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_backwall_type) | Returns: [ENT_TYPE](#ENT_TYPE) used for the backwall (BG_LEVEL_BACKWALL by default) +[ENT_TYPE](#ENT_TYPE) | [get_border_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_border_type) | Returns: [ENT_TYPE](#ENT_TYPE) to use for the border tiles +[ENT_TYPE](#ENT_TYPE) | [get_critter_type()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_critter_type) | Returns: [ENT_TYPE](#ENT_TYPE) for theme specific critter float | [get_liquid_gravity()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_liquid_gravity) | Returns: gravity used to initialize liquid pools (-1..1) bool | [get_player_damage()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_player_damage) | Returns: false to disable most player damage and the usage of bombs and ropes. Enabled in parts of base camp. bool | [get_explosion_soot()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_explosion_soot) | Returns: true if explosions should spawn background soot @@ -3358,7 +3358,7 @@ float | [get_backlayer_light_level()](https://github.com/spelunky-fyi/overlunky/ bool | [get_loop()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_loop) | Returns: true if the loop rendering should be enabled (Combine with the right get_border_type) int | [get_vault_level()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_vault_level) | Returns: highest y-level a vault can spawn bool | [get_theme_flag(int index)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_theme_flag) | Returns: allow_beehive or allow_leprechaun flag
Params: index: 0 or 1 -int | [get_dynamic_texture(int texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_dynamic_texture) | Returns: [TEXTURE](#TEXTURE) based on texture_id
Params: [DYNAMIC_TEXTURE](#DYNAMIC_TEXTURE) texture_id +[TEXTURE](#TEXTURE) | [get_dynamic_texture(DYNAMIC_TEXTURE texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_dynamic_texture) | Returns: [TEXTURE](#TEXTURE) based on texture_id
Params: [DYNAMIC_TEXTURE](#DYNAMIC_TEXTURE) texture_id nil | [pre_transition()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pre_transition) | Sets state.level_next, world_next and theme_next (or state.win_state) based on level number. Runs when exiting a level. int | [get_exit_room_y_level()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_exit_room_y_level) | Returns: usually state.height - 1. For special levels fixed heights are returned. int | [get_shop_chance()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_shop_chance) | Returns: inverse shop chance diff --git a/src/game_api/aliases.hpp b/src/game_api/aliases.hpp index 9d22aeac0..0d84cd23d 100644 --- a/src/game_api/aliases.hpp +++ b/src/game_api/aliases.hpp @@ -52,7 +52,7 @@ using uColor = uint32_t; using SPAWN_TYPE = uint32_t; // NoAlias using VANILLA_SOUND_PARAM = uint32_t; // NoAlias using VANILLA_SOUND_CALLBACK_TYPE = uint32_t; // NoAlias -using TEXTURE = int64_t; // NoAlias +using TEXTURE = int32_t; // NoAlias using INPUTS = uint16_t; // NoAlias using MENU_INPUT = uint16_t; // NoAlias using BUTTON = uint8_t; // NoAlias diff --git a/src/game_api/entity_db.hpp b/src/game_api/entity_db.hpp index efad9038a..68d334cd5 100644 --- a/src/game_api/entity_db.hpp +++ b/src/game_api/entity_db.hpp @@ -87,7 +87,7 @@ struct EntityDB float glow_alpha; }; }; - int32_t texture_id; + TEXTURE texture_id; int32_t technique; int32_t tile_x; int32_t tile_y; diff --git a/src/game_api/items.hpp b/src/game_api/items.hpp index b53f30c5b..1464d2981 100644 --- a/src/game_api/items.hpp +++ b/src/game_api/items.hpp @@ -101,8 +101,8 @@ struct SelectPlayerSlot uint8_t padding1; uint8_t padding2; uint8_t padding3; - ENT_TYPE character; // Entity DB ID - uint32_t texture_id; // Texture DB ID + ENT_TYPE character; // Entity DB ID + TEXTURE texture_id; // Texture DB ID }; struct Items diff --git a/src/game_api/level_api.hpp b/src/game_api/level_api.hpp index b3b727649..7e54ab872 100644 --- a/src/game_api/level_api.hpp +++ b/src/game_api/level_api.hpp @@ -230,6 +230,18 @@ struct SpawnInfo float y; }; +enum class DYNAMIC_TEXTURE : int32_t +{ + INVISIBLE = -2, + BACKGROUND = -4, + FLOOR = -5, + DOOR = -6, + DOOR_LAYER = -7, + BACKGROUND_DECORATION = -8, + KALI_STATUE = -9, + COFFIN = -10 +}; + class ThemeInfo { public: @@ -341,11 +353,11 @@ class ThemeInfo // duat: 112 (ENT_TYPE_FLOORSTYLED_DUAT) // hundun: 107 (ENT_TYPE_FLOORSTYLED_SUNKEN) /// Returns: ENT_TYPE used for floor spreading (generic or one of the styled floors) - virtual uint32_t get_floor_spreading_type() = 0; + virtual ENT_TYPE get_floor_spreading_type() = 0; // similar to get_floor_spreading_type(), except now the default = 103 (ENT_TYPE_FLOORSTYLED_STONE) /// Returns: ENT_TYPE used for floor spreading (stone or one of the styled floors) - virtual uint32_t get_floor_spreading_type2() = 0; + virtual ENT_TYPE get_floor_spreading_type2() = 0; /// Returns: true if transition should use styled floor virtual bool get_transition_styled_floor() = 0; @@ -355,16 +367,16 @@ class ThemeInfo virtual uint32_t get_transition_floor_modifier() = 0; /// Returns: ENT_TYPE used for the transition floor - virtual uint32_t get_transition_styled_floor_type() = 0; + virtual ENT_TYPE get_transition_styled_floor_type() = 0; /// Returns: ENT_TYPE used for the backwall (BG_LEVEL_BACKWALL by default) - virtual uint32_t get_backwall_type() = 0; + virtual ENT_TYPE get_backwall_type() = 0; /// Returns: ENT_TYPE to use for the border tiles - virtual uint32_t get_border_type() = 0; + virtual ENT_TYPE get_border_type() = 0; /// Returns: ENT_TYPE for theme specific critter - virtual uint32_t get_critter_type() = 0; + virtual ENT_TYPE get_critter_type() = 0; /// Returns: gravity used to initialize liquid pools (-1..1) virtual float get_liquid_gravity() = 0; @@ -393,7 +405,7 @@ class ThemeInfo /// Returns: TEXTURE based on texture_id /// Params: DYNAMIC_TEXTURE texture_id - virtual uint32_t get_dynamic_texture(int32_t texture_id) = 0; + virtual TEXTURE get_dynamic_texture(DYNAMIC_TEXTURE texture_id) = 0; /// Sets state.level_next, world_next and theme_next (or state.win_state) based on level number. Runs when exiting a level. virtual void pre_transition() = 0; @@ -624,18 +636,6 @@ bool grow_chain_and_blocks(uint32_t x, uint32_t y); void do_load_screen(); -enum class DYNAMIC_TEXTURE : int32_t -{ - INVISIBLE = -2, - BACKGROUND = -4, - FLOOR = -5, - DOOR = -6, - DOOR_LAYER = -7, - BACKGROUND_DECORATION = -8, - KALI_STATUE = -9, - COFFIN = -10 -}; - enum class THEME_OVERRIDE : uint8_t { BASE, diff --git a/src/game_api/particles.cpp b/src/game_api/particles.cpp index 5b967c71d..2a4d0e3e9 100644 --- a/src/game_api/particles.cpp +++ b/src/game_api/particles.cpp @@ -19,11 +19,11 @@ ParticleDB* particle_db_ptr() return addr; } -std::uint64_t ParticleDB::get_texture() const +TEXTURE ParticleDB::get_texture() const { return texture->id; } -bool ParticleDB::set_texture(std::uint32_t texture_id) +bool ParticleDB::set_texture(TEXTURE texture_id) { if (auto* new_texture = ::get_texture(texture_id)) { diff --git a/src/game_api/particles.hpp b/src/game_api/particles.hpp index e12ec6ec6..a3b4d8ded 100644 --- a/src/game_api/particles.hpp +++ b/src/game_api/particles.hpp @@ -71,8 +71,8 @@ struct ParticleDB ParticleDB(const ParticleDB& other) = default; ParticleDB(const PARTICLEEMITTER particle_id); - std::uint64_t get_texture() const; - bool set_texture(std::uint32_t texture_id); + TEXTURE get_texture() const; + bool set_texture(TEXTURE texture_id); }; struct ParticleEmitter diff --git a/src/game_api/render_api.cpp b/src/game_api/render_api.cpp index 3a09653b4..2c22c2466 100644 --- a/src/game_api/render_api.cpp +++ b/src/game_api/render_api.cpp @@ -519,7 +519,7 @@ void fetch_texture(Entity* entity, int32_t texture_id) { if (texture_id < -3) { - texture_id = State::get().ptr_local()->current_theme->get_dynamic_texture(texture_id); + texture_id = State::get().ptr_local()->current_theme->get_dynamic_texture((DYNAMIC_TEXTURE)texture_id); } entity->texture = get_textures()->texture_map[texture_id]; } diff --git a/src/game_api/render_api.hpp b/src/game_api/render_api.hpp index bfc71dd79..fd9534f58 100644 --- a/src/game_api/render_api.hpp +++ b/src/game_api/render_api.hpp @@ -182,7 +182,7 @@ struct TextRenderingInfo uint16_t unknown8; // padding probably /// Used to draw buttons and stuff, default is -1 wich uses the buttons texture - int32_t special_texture_id; + TEXTURE special_texture_id; uint8_t shader; // ? changing it can change the text color, or make the text all rectangles? uint8_t padding1[3]; diff --git a/src/game_api/script/usertypes/level_lua.cpp b/src/game_api/script/usertypes/level_lua.cpp index 1fe885fef..903a74457 100644 --- a/src/game_api/script/usertypes/level_lua.cpp +++ b/src/game_api/script/usertypes/level_lua.cpp @@ -242,7 +242,7 @@ class CustomTheme : public ThemeInfo std::map> overrides; /// Add TEXTUREs here to override different dynamic textures. - std::map textures; + std::map textures; void override(THEME_OVERRIDE index, bool enabled_) { @@ -892,15 +892,15 @@ class CustomTheme : public ThemeInfo return allow_leprechaun; } - /// Add TEXTUREs to `textures` to override different dynamic textures easily. - uint32_t get_dynamic_texture(int32_t texture_id) + /// Add TEXTURE s to `textures` map of the CustomTheme to override different dynamic textures easily. + TEXTURE get_dynamic_texture(DYNAMIC_TEXTURE texture_id) { auto index = THEME_OVERRIDE::TEXTURE_DYNAMIC; - uint32_t ret = 0; + TEXTURE ret = 0; run_pre_func(index, texture_id); - if (textures.find((DYNAMIC_TEXTURE)texture_id) != textures.end()) + if (auto it = textures.find(texture_id); it != textures.end()) { - ret = textures[(DYNAMIC_TEXTURE)texture_id]; + ret = it->second; } else if (get_override_func_enabled(index)) ret = run_override_func(index, texture_id).value_or(ret); diff --git a/src/game_api/texture.cpp b/src/game_api/texture.cpp index 3cbd0a5b1..8b2681eb6 100644 --- a/src/game_api/texture.cpp +++ b/src/game_api/texture.cpp @@ -77,7 +77,8 @@ TEXTURE define_texture(TextureDefinition data) auto* textures = get_textures(); Texture new_texture{ - static_cast(textures->texture_map.size() + render.custom_textures.size() + 1), + static_cast(textures->texture_map.size() + render.custom_textures.size() + 1), + 0, nullptr, data.width, data.height, @@ -145,7 +146,8 @@ std::optional get_texture(TextureDefinition data) auto* textures = get_textures(); Texture new_texture{ - static_cast(textures->texture_map.size() + render.custom_textures.size() + 1), + static_cast(textures->texture_map.size() + render.custom_textures.size() + 1), + 0, nullptr, data.width, data.height, diff --git a/src/game_api/texture.hpp b/src/game_api/texture.hpp index 903f40eae..a75c0830c 100644 --- a/src/game_api/texture.hpp +++ b/src/game_api/texture.hpp @@ -11,6 +11,7 @@ struct Texture { TEXTURE id; + uint32_t padding{0}; const char** name; std::uint32_t width; std::uint32_t height; diff --git a/src/injected/ui.cpp b/src/injected/ui.cpp index b65b94cdd..0128e9604 100644 --- a/src/injected/ui.cpp +++ b/src/injected/ui.cpp @@ -8125,7 +8125,7 @@ void render_hotbar_textures() if (type->texture_id < 0) { const auto theme = g_state->current_theme ? g_state->current_theme : g_state->level_gen->themes[0]; - texture = get_texture(theme->get_dynamic_texture(type->texture_id)); + texture = get_texture(theme->get_dynamic_texture((DYNAMIC_TEXTURE)type->texture_id)); } if (!texture) continue; diff --git a/src/spel2_dll/spel2.cpp b/src/spel2_dll/spel2.cpp index ee704a630..d653e9d3f 100644 --- a/src/spel2_dll/spel2.cpp +++ b/src/spel2_dll/spel2.cpp @@ -423,7 +423,7 @@ int64_t SpelunkyEntity_GetTexture(Entity* entity) } void SpelunkyEntity_SetTexture(Entity* entity, int64_t texture) { - entity->set_texture(texture); + entity->set_texture(static_cast(texture)); } uint16_t SpelunkyEntity_GetTextureTile(Entity* entity) {