Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend/StarCraftingInterface.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
commit6352e8e3196f78388b6c771073f9e03eaa612673 (patch)
treee23772f79a7fbc41bc9108951e9e136857484bf4 /source/frontend/StarCraftingInterface.hpp
parent6741a057e5639280d85d0f88ba26f000baa58f61 (diff)
everything everywhere
all at once
Diffstat (limited to 'source/frontend/StarCraftingInterface.hpp')
-rw-r--r--source/frontend/StarCraftingInterface.hpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/source/frontend/StarCraftingInterface.hpp b/source/frontend/StarCraftingInterface.hpp
new file mode 100644
index 0000000..282729a
--- /dev/null
+++ b/source/frontend/StarCraftingInterface.hpp
@@ -0,0 +1,85 @@
+#ifndef STAR_CRAFTING_INTERFACE_HPP
+#define STAR_CRAFTING_INTERFACE_HPP
+
+#include "StarWorldPainter.hpp"
+#include "StarWorldClient.hpp"
+#include "StarItemRecipe.hpp"
+#include "StarPane.hpp"
+
+namespace Star {
+
+STAR_CLASS(WorldClient);
+STAR_CLASS(PlayerBlueprints);
+STAR_CLASS(ListWidget);
+STAR_CLASS(TextBoxWidget);
+STAR_CLASS(ButtonWidget);
+STAR_CLASS(LabelWidget);
+STAR_CLASS(AudioInstance);
+
+STAR_CLASS(CraftingPane);
+
+class CraftingPane : public Pane {
+public:
+ CraftingPane(
+ WorldClientPtr worldClient, PlayerPtr player, Json const& settings, EntityId sourceEntityId = NullEntityId);
+
+ void displayed() override;
+ void dismissed() override;
+ PanePtr createTooltip(Vec2I const& screenPosition) override;
+
+ EntityId sourceEntityId() const;
+
+private:
+ void upgradeTable();
+
+ List<ItemRecipe> determineRecipes();
+
+ virtual void update() override;
+ void updateCraftButtons();
+ void updateAvailableRecipes();
+ bool consumeIngredients(ItemRecipe& recipe, int count);
+ void stopCrafting();
+ void toggleCraft();
+ void craft(int count);
+ void countChanged();
+ void countTextChanged();
+ int maxCraft();
+ void setupList(WidgetPtr widget, ItemRecipe const& recipe);
+ ItemRecipe recipeFromSelectedWidget() const;
+ void setupWidget(WidgetPtr const& widget, ItemRecipe const& recipe, HashMap<ItemDescriptor, uint64_t> const& normalizedBag);
+
+ PanePtr setupTooltip(ItemRecipe const& recipe);
+
+ size_t itemCount(List<ItemPtr> const& store, ItemDescriptor const& item);
+
+ WorldClientPtr m_worldClient;
+ PlayerPtr m_player;
+ PlayerBlueprintsPtr m_blueprints;
+
+ bool m_crafting;
+ GameTimer m_craftTimer;
+ AudioInstancePtr m_craftingSound;
+ int m_count;
+ List<ItemRecipe> m_recipes;
+ BiHashMap<ItemRecipe, WidgetPtr> m_recipesWidgetMap; // maps ItemRecipe to guiList WidgetPtrs
+
+ ListWidgetPtr m_guiList;
+ TextBoxWidgetPtr m_textBox;
+ ButtonWidgetPtr m_filterHaveMaterials;
+ size_t m_displayedRecipe;
+
+ StringSet m_filter;
+
+ int m_recipeAutorefreshCooldown;
+
+ HashMap<ItemDescriptor, ItemPtr> m_itemCache;
+
+ EntityId m_sourceEntityId;
+ Json m_settings;
+
+ Maybe<ItemRecipe> m_upgradeRecipe;
+};
+
+}
+
+#endif