the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2
3#include "UIScene.h"
4#include "UIControl_SlotList.h"
5#include "UIControl_Label.h"
6#include "IUIScene_CraftingMenu.h"
7
8#define CRAFTING_INVENTORY_SLOT_START 0
9#define CRAFTING_INVENTORY_SLOT_END (CRAFTING_INVENTORY_SLOT_START + 27)
10
11#define CRAFTING_HOTBAR_SLOT_START CRAFTING_INVENTORY_SLOT_END
12#define CRAFTING_HOTBAR_SLOT_END (CRAFTING_HOTBAR_SLOT_START + 9)
13
14// Ingredients etc should go here
15#define CRAFTING_INGREDIENTS_DESCRIPTION_START CRAFTING_HOTBAR_SLOT_END
16#define CRAFTING_INGREDEINTS_DESCRIPTION_END (CRAFTING_INGREDIENTS_DESCRIPTION_START + 4)
17
18#define CRAFTING_OUTPUT_SLOT_START CRAFTING_INGREDEINTS_DESCRIPTION_END
19#define CRAFTING_OUTPUT_SLOT_END (CRAFTING_OUTPUT_SLOT_START + 1)
20
21#define CRAFTING_INGREDIENTS_LAYOUT_START CRAFTING_OUTPUT_SLOT_END
22#define CRAFTING_INGREDIENTS_LAYOUT_END (CRAFTING_INGREDIENTS_LAYOUT_START+9)
23
24#define CRAFTING_V_SLOT_START CRAFTING_INGREDIENTS_LAYOUT_END
25#define CRAFTING_V_SLOT_END (CRAFTING_V_SLOT_START+3)
26
27// H slots should go last in the count as it's dependent on which size of crafting panel we have
28#define CRAFTING_H_SLOT_START CRAFTING_V_SLOT_END
29
30class UIScene_CraftingMenu : public UIScene, public IUIScene_CraftingMenu
31{
32private:
33 typedef struct _SlotInfo
34 {
35 shared_ptr<ItemInstance> item;
36 unsigned int alpha;
37 bool show;
38
39 _SlotInfo()
40 {
41 item = nullptr;
42 alpha = 31;
43 show = true;
44 }
45 } SlotInfo;
46
47 SlotInfo m_hSlotsInfo[m_iMaxHSlotC];
48 SlotInfo m_vSlotsInfo[m_iMaxDisplayedVSlotC];
49 SlotInfo m_ingredientsSlotsInfo[m_iIngredients3x3SlotC];
50 SlotInfo m_craftingOutputSlotInfo;
51 SlotInfo m_ingredientsInfo[4];
52
53 AbstractContainerMenu *m_menu;
54
55 int m_iMenuInventoryStart;
56 int m_iMenuHotBarStart;
57
58public:
59 UIScene_CraftingMenu(int iPad, void *initData, UILayer *parentLayer);
60
61 virtual void handleDestroy();
62
63 virtual EUIScene getSceneType();
64
65 virtual void customDraw(IggyCustomDrawCallbackRegion *region);
66
67#ifdef __PSVITA__
68 virtual void handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased);
69 virtual UIControl* GetMainPanel();
70 virtual void handleTouchBoxRebuild();
71 virtual void handleTimerComplete(int id);
72#endif
73
74protected:
75 UIControl m_controlMainPanel;
76 UIControl m_control1Selector, m_control2Selector, m_control3Selector;
77 UIControl_SlotList m_slotListCraftingHSlots;
78 UIControl_SlotList m_slotListCrafting1VSlots, m_slotListCrafting2VSlots[2], m_slotListCrafting3VSlots[3];
79 UIControl_SlotList m_slotListIngredientsLayout, m_slotListCraftingOutput;
80 UIControl_SlotList m_slotListIngredients[4];
81 UIControl_SlotList m_slotListInventory, m_slotListHotBar;
82 UIControl_Label m_labelIngredientsDesc[4];
83 UIControl_HTMLLabel m_labelDescription;
84 UIControl_Label m_labelGroupName, m_labelItemName, m_labelInventory, m_labelIngredients;
85
86 IggyName m_funcMoveSelector, m_funcSelectVerticalItem, m_funcSetActiveTab;
87 IggyName m_funcShowPanelDisplay, m_funcShowIngredientSlot;
88
89#ifdef __PSVITA__
90 enum ETouchInput
91 {
92 ETouchInput_TouchPanel_0,
93 ETouchInput_TouchPanel_1,
94 ETouchInput_TouchPanel_2,
95 ETouchInput_TouchPanel_3,
96 ETouchInput_TouchPanel_4,
97 ETouchInput_TouchPanel_5,
98 ETouchInput_TouchPanel_6,
99 ETouchInput_CraftingHSlots,
100
101 ETouchInput_Count,
102 };
103 UIControl_Touch m_TouchInput[ETouchInput_Count];
104 S32 m_iCraftingSlotTouchStartY;
105#endif
106
107 UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
108 UI_MAP_ELEMENT( m_controlMainPanel, "MainPanel" )
109 UI_BEGIN_MAP_CHILD_ELEMENTS( m_controlMainPanel )
110 UI_MAP_ELEMENT( m_slotListCraftingHSlots, "CraftingHSlots")
111
112 UI_MAP_ELEMENT( m_control3Selector, "SlotSelector3" )
113 UI_BEGIN_MAP_CHILD_ELEMENTS( m_control3Selector)
114 UI_MAP_ELEMENT( m_slotListCrafting3VSlots[0], "Crafting3VSlot1")
115 UI_MAP_ELEMENT( m_slotListCrafting3VSlots[1], "Crafting3VSlot2")
116 UI_MAP_ELEMENT( m_slotListCrafting3VSlots[2], "Crafting3VSlot3")
117 UI_END_MAP_CHILD_ELEMENTS()
118
119 UI_MAP_ELEMENT( m_control2Selector, "SlotSelector2" )
120 UI_BEGIN_MAP_CHILD_ELEMENTS( m_control2Selector)
121 UI_MAP_ELEMENT( m_slotListCrafting2VSlots[0], "Crafting2VSlot1")
122 UI_MAP_ELEMENT( m_slotListCrafting2VSlots[1], "Crafting2VSlot2")
123 UI_END_MAP_CHILD_ELEMENTS()
124
125 UI_MAP_ELEMENT( m_control1Selector, "CraftingSelector" )
126 UI_BEGIN_MAP_CHILD_ELEMENTS( m_control1Selector)
127 UI_MAP_ELEMENT( m_slotListCrafting1VSlots, "Crafting1VSlot1")
128 UI_END_MAP_CHILD_ELEMENTS()
129
130 UI_MAP_ELEMENT( m_slotListIngredientsLayout, "IngredientsLayout")
131 UI_MAP_ELEMENT( m_slotListCraftingOutput, "CraftingOutput")
132
133 UI_MAP_ELEMENT( m_slotListIngredients[0], "Ingredient1")
134 UI_MAP_ELEMENT( m_slotListIngredients[1], "Ingredient2")
135 UI_MAP_ELEMENT( m_slotListIngredients[2], "Ingredient3")
136 UI_MAP_ELEMENT( m_slotListIngredients[3], "Ingredient4")
137
138 UI_MAP_ELEMENT( m_labelIngredientsDesc[0], "Ingredient1Desc")
139 UI_MAP_ELEMENT( m_labelIngredientsDesc[1], "Ingredient2Desc")
140 UI_MAP_ELEMENT( m_labelIngredientsDesc[2], "Ingredient3Desc")
141 UI_MAP_ELEMENT( m_labelIngredientsDesc[3], "Ingredient4Desc")
142
143 UI_MAP_ELEMENT( m_labelIngredients, "IngredientsLabel")
144
145 UI_MAP_ELEMENT( m_labelDescription, "DescriptionText")
146
147 UI_MAP_ELEMENT( m_slotListInventory, "Inventory")
148 UI_MAP_ELEMENT( m_slotListHotBar, "HotBar")
149
150 UI_MAP_ELEMENT( m_labelGroupName, "GroupName")
151 UI_MAP_ELEMENT( m_labelItemName, "ItemName")
152 UI_MAP_ELEMENT( m_labelInventory, "InventoryLabel")
153
154 UI_MAP_NAME( m_funcMoveSelector, L"MoveSelector")
155 UI_MAP_NAME( m_funcSelectVerticalItem, L"SelectVerticalItem")
156 UI_MAP_NAME( m_funcSetActiveTab, L"SetActiveTab")
157 UI_MAP_NAME( m_funcShowPanelDisplay, L"showPanelDisplay")
158 UI_MAP_NAME( m_funcShowIngredientSlot, L"ShowIngredient")
159
160#ifdef __PSVITA__
161 UI_MAP_ELEMENT( m_TouchInput[ETouchInput_TouchPanel_0], "TouchPanel_0" )
162 UI_MAP_ELEMENT( m_TouchInput[ETouchInput_TouchPanel_1], "TouchPanel_1" )
163 UI_MAP_ELEMENT( m_TouchInput[ETouchInput_TouchPanel_2], "TouchPanel_2" )
164 UI_MAP_ELEMENT( m_TouchInput[ETouchInput_TouchPanel_3], "TouchPanel_3" )
165 UI_MAP_ELEMENT( m_TouchInput[ETouchInput_TouchPanel_4], "TouchPanel_4" )
166 UI_MAP_ELEMENT( m_TouchInput[ETouchInput_TouchPanel_5], "TouchPanel_5" )
167 UI_MAP_ELEMENT( m_TouchInput[ETouchInput_TouchPanel_6], "TouchPanel_6" )
168 UI_MAP_ELEMENT( m_TouchInput[ETouchInput_CraftingHSlots], "TouchPanel_CraftingHSlots" )
169#endif
170
171 UI_END_MAP_CHILD_ELEMENTS()
172 UI_END_MAP_ELEMENTS_AND_NAMES()
173
174 virtual wstring getMoviePath();
175 virtual void handleReload();
176
177 virtual bool allowRepeat(int key);
178 void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);
179
180protected:
181 virtual int getPad();
182 virtual void hideAllHSlots();
183 virtual void hideAllVSlots();
184 virtual void hideAllIngredientsSlots();
185 virtual void setCraftHSlotItem(int iPad, int iIndex, shared_ptr<ItemInstance> item, unsigned int uiAlpha);
186 virtual void setCraftVSlotItem(int iPad, int iIndex, shared_ptr<ItemInstance> item, unsigned int uiAlpha);
187 virtual void setCraftingOutputSlotItem(int iPad, shared_ptr<ItemInstance> item);
188 virtual void setCraftingOutputSlotRedBox(bool show);
189 virtual void setIngredientSlotItem(int iPad, int index, shared_ptr<ItemInstance> item);
190 virtual void setIngredientSlotRedBox(int index, bool show);
191 virtual void setIngredientDescriptionItem(int iPad, int index, shared_ptr<ItemInstance> item);
192 virtual void setIngredientDescriptionRedBox(int index, bool show);
193 virtual void setIngredientDescriptionText(int index, LPCWSTR text);
194 virtual void setShowCraftHSlot(int iIndex, bool show);
195 virtual void showTabHighlight(int iIndex, bool show);
196 virtual void setGroupText(LPCWSTR text);
197 virtual void setDescriptionText(LPCWSTR text);
198 virtual void setItemText(LPCWSTR text);
199 virtual void scrollDescriptionUp();
200 virtual void scrollDescriptionDown();
201 virtual void updateHighlightAndScrollPositions();
202 virtual void updateVSlotPositions(int iSlots, int i);
203
204 virtual void UpdateMultiPanel();
205
206 virtual void HandleMessage(EUIMessage message, void *data);
207 void handleInventoryUpdated(LPVOID data);
208
209 // 4J - TomK If update tooltips is called then make sure the correct parent is invoked! (both UIScene AND IUIScene_CraftingMenu have an instance of said function!)
210 virtual void updateTooltips() { IUIScene_CraftingMenu::UpdateTooltips(); }
211};