mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-05-24 03:34:48 +00:00
LaunchMoreOptionsMenu and SettingsGraphicsMenu works now. Change seed dont work. Label update for sliders dont work. InGameHostOptionsMenu is disabled for now.
225 lines
5.5 KiB
C++
225 lines
5.5 KiB
C++
#include "UI.h"
|
|
#include "UIControl_List.h"
|
|
|
|
UIControl_List::UIControl_List() : UIControl_Base()
|
|
{
|
|
//elementCount = 0;
|
|
}
|
|
|
|
UIControl_List::~UIControl_List()
|
|
{
|
|
}
|
|
|
|
bool UIControl_List::setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName)
|
|
{
|
|
//UIControl::setControlType(UIControl::eButtonList);
|
|
|
|
bool success = UIControl_Base::setupControl(scene, parent, controlName);
|
|
|
|
m_removeAllItemsFunc = registerFastName(L"removeAllItems");
|
|
m_funcHighlightItem = registerFastName(L"HighlightItem");
|
|
m_funcRemoveItem = registerFastName(L"RemoveItem");
|
|
m_funcSetTouchFocus = registerFastName(L"SetTouchFocus");
|
|
m_funcCanTouchFocus = registerFastName(L"CanTouchFocus");
|
|
m_funcCanTouchTrigger = registerFastName(L"CanTouchTrigger");
|
|
m_funcEnableItem = registerFastName(L"EnableItem");
|
|
m_funcSetItemLabel = registerFastName(L"SetItemLabel");
|
|
m_funcGetItemLabel = registerFastName(L"GetItemLabel");
|
|
|
|
return success;
|
|
}
|
|
|
|
void UIControl_List::init(int id)
|
|
{
|
|
m_id = id;
|
|
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = id;
|
|
|
|
auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_initFunc, 1, value);
|
|
}
|
|
|
|
void UIControl_List::ReInit()
|
|
{
|
|
UIControl_Base::ReInit();
|
|
init(m_id);
|
|
|
|
m_itemCount = 0;
|
|
m_iCurrentSelection = 0;
|
|
}
|
|
|
|
void UIControl_List::tick()
|
|
{
|
|
UIControl_Base::tick();
|
|
}
|
|
|
|
void UIControl_List::clearList()
|
|
{
|
|
IggyDataValue result;
|
|
|
|
auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_removeAllItemsFunc, 0, nullptr);
|
|
|
|
m_itemCount = 0;
|
|
}
|
|
|
|
void UIControl_List::removeItem(int index)
|
|
{
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = index;
|
|
|
|
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcRemoveItem, 1, value);
|
|
|
|
--m_itemCount;
|
|
}
|
|
|
|
void UIControl_List::SetItemLabel(int index, UIString label, bool applyImmediately)
|
|
{
|
|
/*
|
|
if (applyImmediately)
|
|
{
|
|
*/
|
|
int listIndex = getListIndex(index);
|
|
|
|
IggyDataValue result;
|
|
IggyDataValue value[2];
|
|
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = listIndex;
|
|
|
|
value[1].type = IGGY_DATATYPE_string_UTF16;
|
|
IggyStringUTF16 stringVal;
|
|
|
|
stringVal.string = (IggyUTF16*)label.c_str();
|
|
stringVal.length = label.length();
|
|
value[1].string16 = stringVal;
|
|
|
|
auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetItemLabel, 2, value);
|
|
/*
|
|
}
|
|
else
|
|
{
|
|
UIControl_List::GenericPendingUpdate* update = new UIControl_List::GenericPendingUpdate();
|
|
|
|
update->itemIndex = index;
|
|
update->control = this;
|
|
update->value2 = value2;
|
|
|
|
m_pendingUpdates.push_back(update);
|
|
}
|
|
*/
|
|
}
|
|
|
|
const wchar_t* UIControl_List::GetItemLabel(int index)
|
|
{
|
|
int listIndex = getListIndex(index);
|
|
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = listIndex;
|
|
|
|
auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcGetItemLabel, 1, value);
|
|
|
|
if (result.type == IGGY_DATATYPE_string_UTF16)
|
|
m_label = wstring((wchar_t *)result.string16.string, result.string16.length);
|
|
|
|
return m_label.c_str();
|
|
}
|
|
|
|
int UIControl_List::getItemCount()
|
|
{
|
|
return m_itemCount;
|
|
}
|
|
|
|
void UIControl_List::setCurrentSelection(int iSelection)
|
|
{
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = iSelection;
|
|
|
|
auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcHighlightItem, 1, value);
|
|
}
|
|
|
|
int UIControl_List::getCurrentSelection()
|
|
{
|
|
return m_iCurrentSelection;
|
|
}
|
|
|
|
void UIControl_List::updateChildFocus(int iChild)
|
|
{
|
|
m_iCurrentSelection = iChild;
|
|
}
|
|
|
|
void UIControl_List::SetTouchFocus(S32 iX, S32 iY, bool bRepeat)
|
|
{
|
|
IggyDataValue result;
|
|
IggyDataValue value[3];
|
|
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = iX;
|
|
value[1].type = IGGY_DATATYPE_number;
|
|
value[1].number = iY;
|
|
value[2].type = IGGY_DATATYPE_boolean;
|
|
value[2].boolval = bRepeat;
|
|
|
|
auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetTouchFocus, 3, value);
|
|
}
|
|
|
|
bool UIControl_List::CanTouchTrigger(S32 iX, S32 iY)
|
|
{
|
|
IggyDataValue result;
|
|
IggyDataValue value[2];
|
|
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = iX;
|
|
value[1].type = IGGY_DATATYPE_number;
|
|
value[1].number = iY;
|
|
|
|
auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcCanTouchTrigger, 2, value);
|
|
|
|
S32 bCanTouchTrigger = false;
|
|
|
|
if (result.type == IGGY_DATATYPE_boolean)
|
|
bCanTouchTrigger = (bool)result.boolval;
|
|
|
|
return bCanTouchTrigger;
|
|
}
|
|
|
|
void UIControl_List::addElement(eUIControlType type, int index)
|
|
{
|
|
/*
|
|
if (index < 0) index = m_elementCount;
|
|
|
|
m_elementCount++;
|
|
|
|
m_elementTypes[index] = type;
|
|
m_elementActiveStates[index] = true;
|
|
m_elementIds.push_back(index);
|
|
|
|
return index;
|
|
*/
|
|
}
|
|
|
|
int UIControl_List::getListIndex(int id)
|
|
{
|
|
/*
|
|
for (auto it = m_list.begin(); it != m_list.end(); ++it)
|
|
{
|
|
if (*it == id)
|
|
return std::distance(m_list.begin(), it);
|
|
}
|
|
|
|
return -1;
|
|
*/
|
|
// Temp Fix
|
|
return id;
|
|
} |