Skip to content

Commit

Permalink
Add beta config support
Browse files Browse the repository at this point in the history
  • Loading branch information
dextercd committed Jan 5, 2024
1 parent b6d4ce2 commit e1311a3
Show file tree
Hide file tree
Showing 7 changed files with 2,670 additions and 637 deletions.
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,27 @@ foreach(FILE_VERSION main beta)
${CMAKE_CURRENT_SOURCE_DIR}/data/component_${FILE_VERSION}_documentation.json@component_documentation
${CMAKE_CURRENT_SOURCE_DIR}/data/field_infos.json
)
add_custom_target(components_${FILE_VERSION}_lua ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/components_${FILE_VERSION}.lua)

render_jinja_template(OUTPUT serialise_component_${FILE_VERSION}.lua
TEMPLATE serialise_component.lua
JSON ${CMAKE_CURRENT_SOURCE_DIR}/data/component_${FILE_VERSION}_documentation.json@component_documentation
)

render_jinja_template(OUTPUT configs_${FILE_VERSION}.lua
TEMPLATE configs.lua
JSON
${CMAKE_CURRENT_SOURCE_DIR}/data/configs_${FILE_VERSION}.json@configs
)

add_custom_target(components_${FILE_VERSION}_lua ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/components_${FILE_VERSION}.lua)
add_custom_target(serialise_component_${FILE_VERSION}_lua ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/serialise_component_${FILE_VERSION}.lua)
add_custom_target(configs_${FILE_VERSION}_lua ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/configs_${FILE_VERSION}.lua)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/serialise_component_${FILE_VERSION}.lua
${CMAKE_CURRENT_BINARY_DIR}/components_${FILE_VERSION}.lua
${CMAKE_CURRENT_BINARY_DIR}/configs_${FILE_VERSION}.lua
DESTINATION "component-explorer"
COMPONENT ComponentExplorer
)
Expand All @@ -121,13 +130,6 @@ render_jinja_template(OUTPUT version.lua
)
add_custom_target(version_lua ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.lua)

render_jinja_template(OUTPUT configs.lua
TEMPLATE configs.lua
JSON
${CMAKE_CURRENT_SOURCE_DIR}/data/configs.json
)
add_custom_target(configs_lua ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/configs.lua)


configure_file(mod.xml.in mod.xml @ONLY)

Expand All @@ -137,7 +139,6 @@ install(DIRECTORY component-explorer DESTINATION "." COMPONENT ComponentExplorer
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/version.lua
${CMAKE_CURRENT_BINARY_DIR}/configs.lua
${CMAKE_CURRENT_BINARY_DIR}/mod.xml
DESTINATION "component-explorer"
COMPONENT ComponentExplorer
Expand Down
8 changes: 4 additions & 4 deletions component-explorer/components.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
beta_version = dofile("mods/component-explorer/utils/beta_version.lua")
local beta_version = dofile("mods/component-explorer/utils/beta_version.lua")

if beta_version.august_beta then
dofile("mods/component-explorer/components_beta.lua")
if beta_version.dec31_beta then
return dofile("mods/component-explorer/components_beta.lua")
else
dofile("mods/component-explorer/components_main.lua")
return dofile("mods/component-explorer/components_main.lua")
end
8 changes: 8 additions & 0 deletions component-explorer/configs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local beta_version = dofile("mods/component-explorer/utils/beta_version.lua")

if beta_version.dec31_beta then
return dofile("mods/component-explorer/configs_beta.lua")
else
return dofile("mods/component-explorer/configs_main.lua")
end

8 changes: 4 additions & 4 deletions component-explorer/serialise_component.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
beta_version = dofile("mods/component-explorer/utils/beta_version.lua")
local beta_version = dofile("mods/component-explorer/utils/beta_version.lua")

if beta_version.august_beta then
dofile("mods/component-explorer/serialise_component_beta.lua")
if beta_version.dec31_beta then
return dofile("mods/component-explorer/serialise_component_beta.lua")
else
dofile("mods/component-explorer/serialise_component_main.lua")
return dofile("mods/component-explorer/serialise_component_main.lua")
end
2 changes: 1 addition & 1 deletion component-explorer/utils/beta_version.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ local beta_version = {}
-- Table just indicates compatibility with certain betas.
-- Used to gate certain features/options that only work on later versions of Noita.

beta_version.august_beta = PhysicsBodyIDGetBodyAABB ~= nil
beta_version.dec31_beta = ModDoesFileExist and ModDoesFileExist("data/entities/items/pickup/give_all_perks.xml")

return beta_version
Loading

0 comments on commit e1311a3

Please sign in to comment.