Skip to content

Commit

Permalink
Move files around
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaedenn committed Mar 15, 2024
1 parent 2679328 commit ec3c75d
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 27 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ them. Therefore, this mod is compatible with the Fungal Timer mod.

## Prerequisites

This mod depends on the
[https://github.com/dextercd/Noita-Dear-ImGui/releases](Noita-DearImGui) mod.
Note that the Noita-DearImGui mod must appear above Fungal Shift Query in the
mod order.
This mod depends on the Noita-DearImGui mod. Note that the Noita-DearImGui mod
must appear above Fungal Shift Query in the mod order.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion aplc.lua → files/aplc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
--]]

--[[ Example use:
-- local APLC = dofile("mods/shift_query/aplc.lua")
-- local APLC = dofile("mods/shift_query/files/aplc.lua")
-- function get_aplc_data()
-- local lc_combo, ap_combo, lc_prob, ap_prob = APLC.get_recipe()
-- local ap_str = ("AP: %s, %s, %s (%.02f%%)"):format(
Expand Down
20 changes: 19 additions & 1 deletion common.lua → files/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-- the "(no flask)" designation, as it's redundant.

dofile_once("data/scripts/lib/utilities.lua")
dofile_once("mods/shift_query/constants.lua")
dofile_once("mods/shift_query/files/constants.lua")

MOD_ID = "shift_query"
K_CONFIG_LOG_ENABLE = MOD_ID .. "." .. "q_logging"
Expand Down Expand Up @@ -123,6 +123,24 @@ function q_disable_gui()
q_setting_set(SETTING_ENABLE, false)
end

-- Clear the logging global if set
function logger_clear()
local value = GlobalsGetValue("shift_query.logging") or ""
if value ~= "" then
GlobalsSetValue("shift_query.logging", "")
end
end

-- Add a component to the logging global
function logger_add(piece)
local old_log = GlobalsGetValue("shift_query.logging") or ""
local new_log = tostring(piece)
if old_log ~= "" then
new_log = old_log .. "\n" .. new_log
end
GlobalsSetValue("shift_query.logging", new_log)
end

-- Localize a material, either "name" or "$mat_name".
function localize_material(material)
local matid = CellFactory_GetType(material)
Expand Down
2 changes: 2 additions & 0 deletions constants.lua → files/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
MIN_SHIFTS = -1 -- values < 0 mean "all"
MAX_SHIFTS = 20 -- the game implicitly supports only 20 shifts

ALL_SHIFTS = -1 -- values < 0 mean "all"

FLAG_ON = "1"
FLAG_OFF = "0"

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions query.lua → files/query.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

-- luacheck: globals pick_random_from_table_weighted random_nexti random_create

dofile("mods/shift_query/common.lua")
matinfo = dofile("mods/shift_query/materials.lua")
dofile("mods/shift_query/files/common.lua")
matinfo = dofile("mods/shift_query/files/materials.lua")

MAX_SHIFTS = 20 -- maximum number of shifts according to fungal_shift.lua
COOLDOWN = 60*60*5 -- post shift cooldown; five minutes
Expand Down
36 changes: 31 additions & 5 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
--
-- Add "fungal_shift_ui_icon" to the ImGui window.

dofile_once("mods/shift_query/common.lua")
dofile_once("mods/shift_query/materials.lua")
dofile_once("mods/shift_query/query.lua")
dofile_once("mods/shift_query/files/common.lua")
dofile_once("mods/shift_query/files/materials.lua")
dofile_once("mods/shift_query/files/query.lua")
dofile_once("mods/shift_query/lib/feedback.lua")
dofile_once("mods/shift_query/constants.lua")
APLC = dofile_once("mods/shift_query/aplc.lua")
dofile_once("mods/shift_query/files/constants.lua")
APLC = dofile_once("mods/shift_query/files/aplc.lua")

MAT_AP = "midas_precursor"
MAT_LC = "magic_liquid_hp_regeneration_unstable"
Expand Down Expand Up @@ -207,6 +207,32 @@ SQ = {
end
self._imgui.EndMenu()
end

if self._imgui.BeginMenu("Display") then
if self._imgui.BeginMenu("Prior Shifts") then
if self._imgui.MenuItem("Show All") then
q_setting_set(SETTING_PREVIOUS, tostring(ALL_SHIFTS))
self._force_update = true
end
if self._imgui.MenuItem("Show One") then
q_setting_set(SETTING_PREVIOUS, tostring(1))
self._force_update = true
end
self._imgui.EndMenu()
end
if self._imgui.BeginMenu("Pending Shifts") then
if self._imgui.MenuItem("Show All") then
q_setting_set(SETTING_NEXT, tostring(ALL_SHIFTS))
self._force_update = true
end
if self._imgui.MenuItem("Show Next") then
q_setting_set(SETTING_NEXT, tostring(1))
self._force_update = true
end
self._imgui.EndMenu()
end
self._imgui.EndMenu()
end
self._imgui.EndMenuBar()
end
end,
Expand Down
36 changes: 23 additions & 13 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
-- one-at-a-time and in bulk)
-- ** Ability to override MAX_SHIFTS

--[[
-- FIXME: previous_count and next_count display -2 .. 20
-- FIXME: previous_count and next_count are not integers
--]]

dofile("data/scripts/lib/utilities.lua")
dofile("data/scripts/lib/mod_settings.lua")
dofile_once("mods/shift_query/constants.lua")
dofile_once("data/scripts/lib/utilities.lua")
dofile_once("data/scripts/lib/mod_settings.lua")
dofile_once("mods/shift_query/files/common.lua")

-- luacheck: globals MOD_SETTING_SCOPE_RUNTIME

Expand All @@ -21,11 +25,24 @@ dofile_once("mods/shift_query/constants.lua")
-- ModSettingSet(setting_id, new_value)

function mod_setting_changed_callback(mod_id, gui, in_main_menu, setting, old_value, new_value)
if setting == "previous_count" or setting == "next_count" then
if new_value < MIN_SHIFTS then
GamePrint(("setting %s %s outside range"):format(setting, tostring(new_value)))
--[[ TODO: enforce integer values
logger_add(("Setting %s changed from %s to %s"):format(
setting.id, tostring(old_value), tostring(new_value)))
if setting.id == "previous_count" or setting.id == "next_count" then
local final_value = math.floor(new_value)
if final_value < MIN_SHIFTS then
logger_add(("Setting %s %d below %d"):format(setting.id, new_value, final_value))
final_value = MIN_SHIFTS
elseif final_value > MAX_SHIFTS then
logger_add(("Setting %s %d above %d"):format(setting.id, new_value, final_value))
final_value = MAX_SHIFTS
end
if new_value ~= final_value then
ModSettingSet(MOD_ID .. "." .. setting.id, final_value)
end
return final_value
end
]]
end

mod_settings_version = 3
Expand Down Expand Up @@ -71,13 +88,6 @@ mod_settings = {
value_default = true,
scope = MOD_SETTING_SCOPE_RUNTIME,
},
--[[{
id = "override_ui",
ui_name = "Enable Override UI",
ui_description = "Enable use of the manual shifting UI",
value_default = false,
scope = MOD_SETTING_SCOPE_RUNTIME,
},]]
{
id = "include_aplc",
ui_name = "Include AP / LC recipes",
Expand Down
2 changes: 1 addition & 1 deletion workshop_id.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3132525756
3132525756

0 comments on commit ec3c75d

Please sign in to comment.