Files
neoLegacy/Minecraft.Client/Common/UI/UIControl_MultiList.cpp
T
Tranqlmao 9abd52985e TU53 + Bug Fixes (Many)
Patch Notes:
Blocks
+ Colored shulker boxes
+ Concrete powder
+ Concrete
+ Glazed terracotta
Items
+ Shulker shell
+ Iron nugget
UI Changes
+ Added Custom Controls to Keyboard & Mouse, as well as Controller
+ Added Custom SuperFlat
+ Added Edit Server Menu
+ Added Firework Crafting
Feature Changes
+ Host Options
+ Added Pick Block
+ Added off-hand slot for maps and arrows.
Bug Fixes & changes
+ TU47: Banner hitbox wrong (and inventory model fixed)
+ TU47/48: Ice not melting properly
+ TU48: Dead bushes not dropping sticks
+ TU48: Guardians and polar bears not dropping cooked fish when on fire
+ TU48: Bonus chest missing saplings and seeds
+ TU48: Frosted ice obtainable
+ TU48: Hoppers not collecting items
+ TU48: Wither skeletons spawning in 2-high gaps
+ TU48: End crystals exploding with “TNT Explodes” off
+ TU48: Tamed ocelots staying hostile
+ TU48: Signs not placing on tall grass
+ TU51: Skeleton hitbox wrong
+ TU53: Fall damage in shallow water
+ TU53: Squids not spawning in man-made pools
+ Elytra has been improved to be more accurate to the source material
+ Removed Spectral Arrow from crafting
+ Fixed several broken item descriptions
+ You can no longer cook Pufferfish or Clownfish
+ Fixed scaling issue with paperdoll and chat
+ Iron and gold armor can now be smelted into nuggets.
+ More items can now be used as fuel in a furnace.
+ Using a firework rocket while gliding with elytra will now give the player a boost.
+ Changed the color of dyes, wool, carpets, and banners.
+ Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items.
+ Fishing rods can now hook on entities without causing knockback or pseudo-damage.
+ Fixed banner crafting
+ Fixed Map colors for certain blocks
+ Fixed Path block height
+ Fixed String block issues
+ Fixed Item frame culling.
+ Fixed Tutorial world NBT/Block State issues
+ Fixed World Slider
+ Fixed Enderman AI
+ Fixed Player animation bug
+ HUD Flash text changes
+ Generation accuracy changes
+ Many other small accuracy changes and fixes
2026-11-24 13:44:06 -05:00

526 lines
15 KiB
C++

#include "stdafx.h"
#include "UI.h"
#include "UIControl_MultiList.h"
// Multilist By aRockefeler Or aRockefort
UIControl_MultiList::UIControl_MultiList()
{
m_itemCount = 0;
m_iCurrentSelection = 0;
}
bool UIControl_MultiList::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eButtonList); // reuses eButtonList, same as original
bool success = UIControl_Base::setupControl(scene, parent, controlName);
m_funcSetPossibleLabels = registerFastName(L"SetPossibleLabels");
m_funcAddNewItem_Label = registerFastName(L"addNewItem_Label");
m_funcAddNewItem_Button = registerFastName(L"addNewItem_Button");
m_funcAddNewItem_MenuButton = registerFastName(L"addNewItem_MenuButton");
m_funcAddNewItem_CheckBox = registerFastName(L"addNewItem_CheckBox");
m_funcAddNewItem_Slider = registerFastName(L"addNewItem_Slider");
m_funcAddNewItem_TextInput = registerFastName(L"addNewItem_TextInput");
m_funcSetCheckBox = registerFastName(L"SetCheckBox");
m_funcGetCheckBox = registerFastName(L"GetCheckBox");
m_funcSetSliderValue = registerFastName(L"SetSliderValue");
m_funcGetSliderValue = registerFastName(L"GetSliderValue");
m_funcSetItemLabel = registerFastName(L"SetItemLabel");
m_funcSetItemIcons = registerFastName(L"SetItemIcons");
m_funcSetItemLabelLeft = registerFastName(L"SetItemLabelLeft");
m_funcSetItemEnabled = registerFastName(L"SetItemEnabled");
m_funcSetItemFlat = registerFastName(L"SetItemFlat");
m_funcSetItemFlatLabel = registerFastName(L"SetItemFlatLabel");
// these use the same pattern as UIControl_ButtonList
m_funcHighlightItem = registerFastName(L"HighlightItem");
m_funcEnableItem = registerFastName(L"EnableItem");
m_funcCheckElementExists = registerFastName(L"CheckElementExists");
m_funcSetTouchFocus = registerFastName(L"SetTouchFocus");
m_funcCanTouchTrigger = registerFastName(L"CanTouchTrigger");
m_removeAllItemsFunc = registerFastName(L"removeAllItems");
return success;
}
void UIControl_MultiList::init(int id)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (F64)id;
IggyResult out = IggyPlayerCallMethodRS(
m_parentScene->getMovie(),
&result,
getIggyValuePath(),
m_initFunc,
1,
value);
}
// the internal element array
// Items are stored in insertion order so
// we walk m_itemIds to find the 0-based position of the given id
int UIControl_MultiList::getListIndex(int id) const
{
for (size_t i = 0; i < m_itemIds.size(); ++i)
{
if (m_itemIds[i] == id)
return (int)i;
}
return -1;
}
// returns the item id stored at the given position in m_itemIds or -1 if out of range
int UIControl_MultiList::getIdFromIndex(int index) const
{
if (index >= 0 && index < (int)m_itemIds.size())
return m_itemIds[index];
return -1;
}
void UIControl_MultiList::AddNewLabel(const wstring &label, int id)
{
IggyDataValue result;
IggyDataValue value[1];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcAddNewItem_Label, 1, value);
m_itemIds.push_back(id);
++m_itemCount;
}
void UIControl_MultiList::SetItemFlatLabel(int id, int referenceId, const wstring &label)
{
int listIndex = getListIndex(id);
int referenceIndex = getListIndex(referenceId);
if (listIndex < 0 || referenceIndex < 0)
return;
IggyDataValue result;
IggyDataValue args[3];
args[0].type = IGGY_DATATYPE_number;
args[0].number = (double)listIndex;
args[1].type = IGGY_DATATYPE_number;
args[1].number = (double)referenceIndex;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
args[2].type = IGGY_DATATYPE_string_UTF16;
args[2].string16 = stringVal;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemFlatLabel, 3, args);
}
void UIControl_MultiList::AddNewButton(const wstring &label, int id)
{
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (double)id;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcAddNewItem_Button, 2, value);
m_itemIds.push_back(id);
++m_itemCount;
}
void UIControl_MultiList::AddNewMenuButton(const wstring &label, int id)
{
AddNewButton(label, id);
}
void UIControl_MultiList::AddNewCheckbox(const wstring &label, int id, bool checked)
{
IggyDataValue result;
IggyDataValue value[3];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (double)id;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = checked ? 1 : 0;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcAddNewItem_CheckBox, 3, value);
m_itemIds.push_back(id);
++m_itemCount;
}
void UIControl_MultiList::AddNewSlider(const wstring &label, int id, int minVal, int maxVal, int step, int initialVal)
{
app.DebugPrintf("[MULTILIST] AddNewSlider: label=%ls id=%d min=%d max=%d step=%d init=%d\n",
label.c_str(), id, minVal, maxVal, step, initialVal);
IggyDataValue result;
IggyDataValue value[5];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (double)id;
value[2].type = IGGY_DATATYPE_number;
value[2].number = (double)minVal;
value[3].type = IGGY_DATATYPE_number;
value[3].number = (double)maxVal;
value[4].type = IGGY_DATATYPE_number;
value[4].number = (double)initialVal;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcAddNewItem_Slider, 5, value);
m_sliderValues.emplace(id, initialVal);
m_itemIds.push_back(id);
++m_itemCount;
}
void UIControl_MultiList::handleSliderMove(int id, int newValue) {
auto it = m_sliderValues.find(id);
if (it == m_sliderValues.end()) return;
if (newValue != it->second) {
int valueCount = 1;
if (g_KBMInput.IsKBMActive() && g_KBMInput.HasAnyInput()) {
if (newValue % 10 == 0) {
ui.PlayUISFX(eSFX_Scroll);
it->second = newValue;
} else if (valueCount <= 20) {
ui.PlayUISFX(eSFX_Scroll);
it->second = newValue;
}
} else {
ui.PlayUISFX(eSFX_Scroll);
it->second = newValue;
}
}
}
void UIControl_MultiList::AddNewTextInput(const wstring &label, int id)
{
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (double)id;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcAddNewItem_TextInput, 2, value);
m_itemIds.push_back(id);
++m_itemCount;
}
bool UIControl_MultiList::GetCheckboxValue(int id)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (double)getListIndex(id);
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcGetCheckBox, 1, value);
if (result.type == IGGY_DATATYPE_boolean)
return result.boolval != 0;
if (result.type == IGGY_DATATYPE_number)
return (int)result.number == 1;
return false;
}
void UIControl_MultiList::SetCheckboxValue(int id, bool checked, bool bImmediate)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (double)getListIndex(id);
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = checked ? 1 : 0;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetCheckBox, 2, value);
}
int UIControl_MultiList::GetSliderValue(int id)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (double)getListIndex(id);
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcGetSliderValue, 1, value);
if (result.type == IGGY_DATATYPE_number)
return (int)result.number;
return 0;
}
void UIControl_MultiList::SetSliderValue(int id, int value, bool bImmediate)
{
IggyDataValue result;
IggyDataValue args[2];
args[0].type = IGGY_DATATYPE_number;
args[0].number = (double)getListIndex(id);
args[1].type = IGGY_DATATYPE_number;
args[1].number = (double)value;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetSliderValue, 2, args);
}
void UIControl_MultiList::SetSliderLabel(int id, const wstring &label, bool bImmediate)
{
IggyDataValue result;
IggyDataValue args[2];
args[0].type = IGGY_DATATYPE_number;
args[0].number = (double)getListIndex(id);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
args[1].type = IGGY_DATATYPE_string_UTF16;
args[1].string16 = stringVal;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetItemLabel, 2, args);
}
void UIControl_MultiList::SetItemEnabled(int id, bool enabled)
{
int listIndex = getListIndex(id);
if (listIndex < 0)
return;
IggyDataValue result;
IggyDataValue args[2];
args[0].type = IGGY_DATATYPE_number;
args[0].number = (double)listIndex;
args[1].type = IGGY_DATATYPE_boolean;
args[1].boolval = enabled ? 1 : 0;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemEnabled, 2, args);
}
void UIControl_MultiList::SetItemFlat(int id)
{
int listIndex = getListIndex(id);
if (listIndex < 0)
return;
IggyDataValue result;
IggyDataValue args[1];
args[0].type = IGGY_DATATYPE_number;
args[0].number = (double)listIndex;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemFlat, 1, args);
}
void UIControl_MultiList::SetItemLabelLeft(int id, const wstring &label)
{
int listIndex = getListIndex(id);
if (listIndex < 0)
return;
IggyDataValue result;
IggyDataValue args[2];
args[0].type = IGGY_DATATYPE_number;
args[0].number = (double)listIndex;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
args[1].type = IGGY_DATATYPE_string_UTF16;
args[1].string16 = stringVal;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemLabelLeft, 2, args);
}
void UIControl_MultiList::SetItemIcons(int id, const wstring &iconNames, int size)
{
int listIndex = getListIndex(id);
if (listIndex < 0)
return;
IggyDataValue result;
IggyDataValue args[3];
args[0].type = IGGY_DATATYPE_number;
args[0].number = (double)listIndex;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)iconNames.c_str();
stringVal.length = iconNames.length();
args[1].type = IGGY_DATATYPE_string_UTF16;
args[1].string16 = stringVal;
args[2].type = IGGY_DATATYPE_number;
args[2].number = (double)size;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
IggyPlayerRootPath(m_parentScene->getMovie()), m_funcSetItemIcons, 3, args);
}
void UIControl_MultiList::HighlightItem(int id, bool animate)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (double)getListIndex(id);
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = animate ? 1 : 0;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcHighlightItem, 2, value);
m_iCurrentSelection = id;
}
void UIControl_MultiList::EnableItem(int id, bool bEnable, bool bImmediate)
{
if (!bImmediate)
return; // deferred mode not implemented
int listIndex = getListIndex(id);
if (listIndex < 0)
return;
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (double)listIndex;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = bEnable ? 1 : 0;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcEnableItem, 2, value);
}
void UIControl_MultiList::clearList()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_removeAllItemsFunc, 0, nullptr);
m_itemIds.clear();
m_sliderValues.clear();
m_itemCount = 0;
m_iCurrentSelection = 0;
}
bool UIControl_MultiList::CheckElementExists(int id)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (double)id;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcCheckElementExists, 1, value);
if (result.type == IGGY_DATATYPE_boolean)
return result.boolval != 0;
if (result.type == IGGY_DATATYPE_number)
return (int)result.number != 0;
return false;
}
void UIControl_MultiList::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;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetTouchFocus, 3, value);
}
int UIControl_MultiList::GetActiveItemIndex()
{
S32 index = -1;
if (IggyValueGetS32RS(getIggyValuePath(), 0, "iActiveItem", &index) == IGGY_RESULT_SUCCESS) return index;
F64 fIndex = -1;
if (IggyValueGetF64RS(getIggyValuePath(), 0, "iActiveItem", &fIndex) == IGGY_RESULT_SUCCESS) return static_cast<int>(fIndex);
if (IggyValueGetS32RS(getIggyValuePath(), 0, "m_iActiveItem", &index) == IGGY_RESULT_SUCCESS) return index;
return -1;
}
bool UIControl_MultiList::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;
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcCanTouchTrigger, 2, value);
return result.type == IGGY_DATATYPE_boolean && result.boolval;
}