From 4c636e911ce86bcd6d501fc2f6f3ce2c3dd9c71c Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 24 Jul 2023 22:11:45 +1000 Subject: [PATCH] Add default crafting config values --- .../interface/windowconfig/crafting.config.patch | 10 ++++++++++ source/frontend/StarCraftingInterface.cpp | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 assets/opensb/interface/windowconfig/crafting.config.patch diff --git a/assets/opensb/interface/windowconfig/crafting.config.patch b/assets/opensb/interface/windowconfig/crafting.config.patch new file mode 100644 index 0000000..0728507 --- /dev/null +++ b/assets/opensb/interface/windowconfig/crafting.config.patch @@ -0,0 +1,10 @@ +// Default config for all crafting interfaces, vanilla and modded. + +{ "default" : { + // Disables the crafting timer if true. + "disableTimer" : false, + + // This is only used if the crafting timer is enabled. + // This is how many crafts are ran when the crafting timer wraps. + "craftCount" : 1 +} } \ No newline at end of file diff --git a/source/frontend/StarCraftingInterface.cpp b/source/frontend/StarCraftingInterface.cpp index 3156a78..b363b92 100644 --- a/source/frontend/StarCraftingInterface.cpp +++ b/source/frontend/StarCraftingInterface.cpp @@ -38,7 +38,9 @@ CraftingPane::CraftingPane(WorldClientPtr worldClient, PlayerPtr player, Json co auto assets = Root::singleton().assets(); // get the config data for this crafting pane, default to "bare hands" crafting auto baseConfig = settings.get("config", "/interface/windowconfig/crafting.config"); - m_settings = jsonMerge(assets->fetchJson(baseConfig), settings); + m_settings = jsonMerge(assets->json("/interface/windowconfig/crafting.config:default"), + jsonMerge(assets->fetchJson(baseConfig), settings)); + m_filter = StringSet::from(jsonToStringList(m_settings.get("filter", JsonArray()))); GuiReader reader; @@ -266,7 +268,7 @@ void CraftingPane::update(float dt) { // crafters gonna craft while (m_crafting && m_craftTimer.wrapTick()) { - craft(1); + craft(min(m_count, (int)m_settings.getInt("craftCount", 1))); } // update crafting icon, progress and buttons