the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "UI.h"
3#include "UIControl_SlotList.h"
4
5UIControl_SlotList::UIControl_SlotList()
6{
7 m_lastHighlighted = -1;
8}
9
10bool UIControl_SlotList::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
11{
12 UIControl::setControlType(UIControl::eSlotList);
13 bool success = UIControl_Base::setupControl(scene,parent,controlName);
14
15 //SlotList specific initialisers
16 m_addSlotFunc = registerFastName(L"addSlot");
17 m_setRedBoxFunc = registerFastName(L"SetSlotRedBox");
18 m_setHighlightFunc = registerFastName(L"SetSlotHighlight");
19
20 m_lastHighlighted = 0;
21
22 return success;
23}
24
25void UIControl_SlotList::ReInit()
26{
27 UIControl_Base::ReInit();
28
29 m_lastHighlighted = -1;
30}
31
32void UIControl_SlotList::addSlot(int id)
33{
34 IggyDataValue result;
35 IggyDataValue value[3];
36 value[0].type = IGGY_DATATYPE_number;
37 value[0].number = id;
38
39 value[1].type = IGGY_DATATYPE_boolean;
40 value[1].boolval = false;
41 value[2].type = IGGY_DATATYPE_boolean;
42 value[2].boolval = false;
43 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addSlotFunc ,3 , value );
44}
45
46void UIControl_SlotList::addSlots(int iStartValue, int iCount)
47{
48 for(unsigned int i = iStartValue; i < iStartValue + iCount; ++i)
49 {
50 addSlot(i);
51 }
52}
53
54
55void UIControl_SlotList::setHighlightSlot(int index)
56{
57 if(index != m_lastHighlighted)
58 {
59 if(m_lastHighlighted != -1)
60 {
61 setSlotHighlighted(m_lastHighlighted, false);
62 }
63 setSlotHighlighted(index, true);
64 m_lastHighlighted = index;
65 }
66}
67
68void UIControl_SlotList::setSlotHighlighted(int index, bool highlight)
69{
70 IggyDataValue result;
71 IggyDataValue value[2];
72 value[0].type = IGGY_DATATYPE_number;
73 value[0].number = index;
74
75 value[1].type = IGGY_DATATYPE_boolean;
76 value[1].boolval = highlight;
77 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_setHighlightFunc , 2 , value );
78}
79
80void UIControl_SlotList::showSlotRedBox(int index, bool show)
81{
82 //app.DebugPrintf("Setting red box at index %d to %s\n", index, show?"on":"off");
83 IggyDataValue result;
84 IggyDataValue value[2];
85 value[0].type = IGGY_DATATYPE_number;
86 value[0].number = index;
87
88 value[1].type = IGGY_DATATYPE_boolean;
89 value[1].boolval = show;
90 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_setRedBoxFunc , 2, value );
91}
92
93void UIControl_SlotList::setFocus(bool focus)
94{
95 if(m_lastHighlighted != -1)
96 {
97 if(focus) setSlotHighlighted(m_lastHighlighted, true);
98 else setSlotHighlighted(m_lastHighlighted, false);
99 }
100}