restructure codebase according to vcproj filters

This commit is contained in:
Tropical
2026-03-30 09:50:58 -05:00
parent d5cf90c713
commit 451682693e
3015 changed files with 46858 additions and 54635 deletions

View File

@@ -0,0 +1,156 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl.h"
#include "../../../../../Minecraft.World/ConsoleHelpers/StringHelpers.h"
#include "../../../../../Minecraft.World/ConsoleJavaLibs/JavaMath.h"
UIControl::UIControl() {
m_parentScene = nullptr;
m_lastOpacity = 1.0f;
m_controlName = "";
m_isVisible = true;
m_bHidden = false;
m_isValid = false;
m_eControlType = eNoControl;
m_x = 0;
m_y = 0;
m_width = 0;
m_height = 0;
}
bool UIControl::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
m_parentScene = scene;
m_controlName = controlName;
rrbool res =
IggyValuePathMakeNameRef(&m_iggyPath, parent, controlName.c_str());
m_isValid = res ? true : false;
m_nameXPos = registerFastName(L"x");
m_nameYPos = registerFastName(L"y");
m_nameWidth = registerFastName(L"width");
m_nameHeight = registerFastName(L"height");
m_funcSetAlpha = registerFastName(L"SetControlAlpha");
m_nameVisible = registerFastName(L"visible");
if (m_isValid) {
IggyDatatype controlType = IGGY_DATATYPE__invalid_request;
IggyResult typeResult =
IggyValueGetTypeRS(getIggyValuePath(), 0, nullptr, &controlType);
m_isValid = typeResult == IGGY_RESULT_SUCCESS &&
controlType != IGGY_DATATYPE__invalid_request &&
controlType != IGGY_DATATYPE_undefined;
}
if (m_isValid) {
F64 fx, fy, fwidth, fheight;
IggyValueGetF64RS(getIggyValuePath(), m_nameXPos, nullptr, &fx);
IggyValueGetF64RS(getIggyValuePath(), m_nameYPos, nullptr, &fy);
IggyValueGetF64RS(getIggyValuePath(), m_nameWidth, nullptr, &fwidth);
IggyValueGetF64RS(getIggyValuePath(), m_nameHeight, nullptr, &fheight);
m_x = (S32)fx;
m_y = (S32)fy;
m_width = (S32)Math::round(fwidth);
m_height = (S32)Math::round(fheight);
} else {
m_x = 0;
m_y = 0;
m_width = 0;
m_height = 0;
}
return res;
}
void UIControl::ReInit() {
if (!m_isValid) return;
if (m_lastOpacity != 1.0f) {
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF8 stringVal;
stringVal.string = (char*)m_controlName.c_str();
stringVal.length = m_controlName.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_lastOpacity;
IggyResult out = IggyPlayerCallMethodRS(
m_parentScene->getMovie(), &result, m_parentScene->m_rootPath,
m_funcSetAlpha, 2, value);
}
IggyValueSetBooleanRS(getIggyValuePath(), m_nameVisible, nullptr,
m_isVisible);
}
IggyValuePath* UIControl::getIggyValuePath() { return &m_iggyPath; }
S32 UIControl::getXPos() { return m_x; }
S32 UIControl::getYPos() { return m_y; }
S32 UIControl::getWidth() { return m_width; }
S32 UIControl::getHeight() { return m_height; }
void UIControl::setOpacity(float percent) {
if (percent != m_lastOpacity) {
m_lastOpacity = percent;
if (!m_isValid) return;
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF8 stringVal;
stringVal.string = (char*)m_controlName.c_str();
stringVal.length = m_controlName.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_lastOpacity;
IggyResult out = IggyPlayerCallMethodRS(
m_parentScene->getMovie(), &result, m_parentScene->m_rootPath,
m_funcSetAlpha, 2, value);
}
}
void UIControl::setVisible(bool visible) {
if (visible != m_isVisible) {
if (!m_isValid) {
m_isVisible = visible;
return;
}
rrbool succ = IggyValueSetBooleanRS(getIggyValuePath(), m_nameVisible,
nullptr, visible);
if (succ)
m_isVisible = visible;
else
app.DebugPrintf("Failed to set visibility for control\n");
}
}
bool UIControl::getVisible() {
if (!m_isValid) return m_isVisible;
rrbool bVisible = false;
IggyResult result = IggyValueGetBooleanRS(getIggyValuePath(), m_nameVisible,
nullptr, &bVisible);
m_isVisible = bVisible;
return bVisible;
}
IggyName UIControl::registerFastName(const std::wstring& name) {
return m_parentScene->registerFastName(name);
}

View File

@@ -0,0 +1,88 @@
#pragma once
// This class for any name object in the flash scene
class UIControl {
public:
enum eUIControlType {
eNoControl,
eButton,
eButtonList,
eCheckBox,
eCursor,
eDLCList,
eDynamicLabel,
eEnchantmentBook,
eEnchantmentButton,
eHTMLLabel,
eLabel,
eLeaderboardList,
eMinecraftPlayer,
eMinecraftHorse,
ePlayerList,
ePlayerSkinPreview,
eProgress,
eSaveList,
eSlider,
eSlotList,
eTextInput,
eTexturePackList,
eBitmapIcon,
eTouchControl,
};
protected:
eUIControlType m_eControlType;
int m_id;
bool m_bHidden; // set by the Remove call
bool m_isValid;
public:
void setControlType(eUIControlType eType) { m_eControlType = eType; }
eUIControlType getControlType() { return m_eControlType; }
void setId(int iID) { m_id = iID; }
int getId() { return m_id; }
UIScene* getParentScene() { return m_parentScene; }
protected:
IggyValuePath m_iggyPath;
UIScene* m_parentScene;
std::string m_controlName;
IggyName m_nameXPos, m_nameYPos, m_nameWidth, m_nameHeight;
IggyName m_funcSetAlpha, m_nameVisible;
S32 m_x, m_y, m_width, m_height;
float m_lastOpacity;
bool m_isVisible;
public:
UIControl();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
IggyValuePath* getIggyValuePath();
std::string getControlName() { return m_controlName; }
virtual void tick() {}
virtual void ReInit();
virtual void setFocus(bool focus) {}
S32 getXPos();
S32 getYPos();
S32 getWidth();
S32 getHeight();
void setOpacity(float percent);
void setVisible(bool visible);
bool getVisible();
bool isVisible() { return m_isVisible; }
bool isValid() { return m_isValid; }
virtual bool hasFocus() { return false; }
protected:
IggyName registerFastName(const std::wstring& name);
};

View File

@@ -0,0 +1,116 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl.h"
#include "../../../../../Minecraft.World/ConsoleHelpers/StringHelpers.h"
#include "../../../../../Minecraft.World/ConsoleJavaLibs/JavaMath.h"
UIControl_Base::UIControl_Base() {
m_bLabelChanged = false;
m_id = 0;
}
bool UIControl_Base::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
bool success = UIControl::setupControl(scene, parent, controlName);
m_setLabelFunc = registerFastName(L"SetLabel");
m_initFunc = registerFastName(L"Init");
m_funcGetLabel = registerFastName(L"GetLabel");
m_funcCheckLabelWidths = registerFastName(L"CheckLabelWidths");
return success;
}
void UIControl_Base::tick() {
UIControl::tick();
if (m_label.needsUpdating() || m_bLabelChanged) {
// app.DebugPrintf("Calling SetLabel - '%ls'\n", m_label.c_str());
m_bLabelChanged = false;
const std::u16string convLabel =
wstring_to_u16string(m_label.getString());
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(),
&result, getIggyValuePath(),
m_setLabelFunc, 1, value);
m_label.setUpdated();
}
}
void UIControl_Base::setLabel(UIString label, bool instant, bool force) {
if (force ||
((!m_label.empty() || !label.empty()) && m_label.compare(label) != 0))
m_bLabelChanged = true;
m_label = label;
if (m_bLabelChanged && instant) {
m_bLabelChanged = false;
const std::u16string convLabel =
wstring_to_u16string(m_label.getString());
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(),
&result, getIggyValuePath(),
m_setLabelFunc, 1, value);
}
}
const wchar_t* UIControl_Base::getLabel() {
IggyDataValue result;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcGetLabel, 0, nullptr);
if (result.type == IGGY_DATATYPE_string_UTF16) {
m_label = u16string_to_wstring(result.string16.string);
}
return m_label.c_str();
}
void UIControl_Base::setAllPossibleLabels(int labelCount,
wchar_t labels[][256]) {
IggyDataValue result;
IggyDataValue* value = new IggyDataValue[labelCount];
IggyStringUTF16* stringVal = new IggyStringUTF16[labelCount];
std::vector<std::u16string> conv;
conv.reserve(labelCount);
for (int i = 0; i < labelCount; ++i) {
conv.push_back(wstring_to_u16string(labels[i]));
stringVal[i].string = conv[i].c_str();
stringVal[i].length = (S32)conv[i].length();
value[i].type = IGGY_DATATYPE_string_UTF16;
value[i].string16 = stringVal[i];
}
IggyResult out = IggyPlayerCallMethodRS(
m_parentScene->getMovie(), &result, getIggyValuePath(),
m_funcCheckLabelWidths, labelCount, value);
delete[] value;
delete[] stringVal;
}
bool UIControl_Base::hasFocus() { return m_parentScene->controlHasFocus(this); }

View File

@@ -0,0 +1,36 @@
#pragma once
#include "UIControl.h"
#include "../UIString.h"
// This class maps to the FJ_Base class in actionscript
class UIControl_Base : public UIControl {
protected:
IggyName m_initFunc;
IggyName m_setLabelFunc;
IggyName m_funcGetLabel;
IggyName m_funcCheckLabelWidths;
bool m_bLabelChanged;
UIString m_label;
public:
UIControl_Base();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
virtual void tick();
virtual void setLabel(UIString label, bool instant = false,
bool force = false);
// virtual void setLabel(std::wstring label, bool instant = false, bool
// force = false) { this->setLabel(UIString::CONSTANT(label), instant,
// force); }
const wchar_t* getLabel();
virtual void setAllPossibleLabels(int labelCount, wchar_t labels[][256]);
int getId() { return m_id; }
virtual bool hasFocus();
};

View File

@@ -0,0 +1,101 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_BeaconEffectButton.h"
UIControl_BeaconEffectButton::UIControl_BeaconEffectButton() {
m_data = 0;
m_icon = 0;
m_selected = false;
m_active = false;
m_focus = false;
}
bool UIControl_BeaconEffectButton::setupControl(
UIScene* scene, IggyValuePath* parent, const std::string& controlName) {
bool success = UIControl::setupControl(scene, parent, controlName);
m_funcChangeState = registerFastName(L"ChangeState");
m_funcSetIcon = registerFastName(L"SetIcon");
return success;
}
void UIControl_BeaconEffectButton::SetData(int data, int icon, bool active,
bool selected) {
m_data = data;
m_active = active;
m_selected = selected;
SetIcon(icon);
UpdateButtonState();
}
int UIControl_BeaconEffectButton::GetData() { return m_data; }
void UIControl_BeaconEffectButton::SetButtonSelected(bool selected) {
if (selected != m_selected) {
m_selected = selected;
UpdateButtonState();
}
}
bool UIControl_BeaconEffectButton::IsButtonSelected() { return m_selected; }
void UIControl_BeaconEffectButton::SetButtonActive(bool active) {
if (m_active != active) {
m_active = active;
UpdateButtonState();
}
}
void UIControl_BeaconEffectButton::setFocus(bool focus) {
if (m_focus != focus) {
m_focus = focus;
UpdateButtonState();
}
}
void UIControl_BeaconEffectButton::SetIcon(int icon) {
if (icon != m_icon) {
m_icon = icon;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = m_icon;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetIcon, 1, value);
}
}
void UIControl_BeaconEffectButton::UpdateButtonState() {
EState state = eState_Disabled;
if (!m_active) {
state = eState_Disabled;
} else if (m_selected) {
state = eState_Pressed;
} else if (m_focus) {
state = eState_Enabled_Selected;
} else {
state = eState_Enabled_Unselected;
}
if (state != m_lastState) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = state;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(),
&result, getIggyValuePath(),
m_funcChangeState, 1, value);
if (out == IGGY_RESULT_SUCCESS) m_lastState = state;
}
}

View File

@@ -0,0 +1,48 @@
#pragma once
#include "UIControl.h"
class UIControl_BeaconEffectButton : public UIControl {
private:
static const int BUTTON_DISABLED = 0;
static const int BUTTON_ENABLED_UNSELECTED = 1;
static const int BUTTON_ENABLED_SELECTED = 2;
static const int BUTTON_PRESSED = 3;
enum EState {
eState_Disabled,
eState_Enabled_Unselected,
eState_Enabled_Selected,
eState_Pressed
};
EState m_lastState;
int m_data;
int m_icon;
bool m_selected;
bool m_active;
bool m_focus;
IggyName m_funcChangeState, m_funcSetIcon;
public:
UIControl_BeaconEffectButton();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void SetData(int data, int icon, bool active, bool selected);
int GetData();
void SetButtonSelected(bool selected);
bool IsButtonSelected();
void SetButtonActive(bool active);
virtual void setFocus(bool focus);
void SetIcon(int icon);
private:
void UpdateButtonState();
};

View File

@@ -0,0 +1,30 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_BitmapIcon.h"
bool UIControl_BitmapIcon::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eBitmapIcon);
bool success = UIControl::setupControl(scene, parent, controlName);
// SlotList specific initialisers
m_funcSetTextureName = registerFastName(L"SetTextureName");
return success;
}
void UIControl_BitmapIcon::setTextureName(const std::wstring& iconName) {
IggyDataValue result;
IggyDataValue value[1];
const std::u16string convName = wstring_to_u16string(iconName);
IggyStringUTF16 stringVal;
stringVal.string = convName.c_str();
stringVal.length = convName.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcSetTextureName, 1, value);
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "UIControl.h"
class UIControl_BitmapIcon : public UIControl {
private:
IggyName m_funcSetTextureName;
public:
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void setTextureName(const std::wstring& iconName);
};

View File

@@ -0,0 +1,55 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_Button.h"
UIControl_Button::UIControl_Button() {}
bool UIControl_Button::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eButton);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// Button specific initialisers
m_funcEnableButton = registerFastName(L"EnableButton");
return success;
}
void UIControl_Button::init(UIString label, int id) {
m_label = label;
m_id = id;
const std::u16string convLabel = wstring_to_u16string(label.getString());
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = id;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 2, value);
}
void UIControl_Button::ReInit() {
UIControl_Base::ReInit();
init(m_label, m_id);
}
void UIControl_Button::setEnable(bool enable) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = enable;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcEnableButton, 1, value);
}

View File

@@ -0,0 +1,22 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Button : public UIControl_Base {
private:
IggyName m_funcEnableButton;
public:
UIControl_Button();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(UIString label, int id);
// void init(const std::wstring &label, int id) {
// init(UIString::CONSTANT(label), id); }
virtual void ReInit();
void setEnable(bool enable);
};

View File

@@ -0,0 +1,185 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_ButtonList.h"
UIControl_ButtonList::UIControl_ButtonList() {
m_itemCount = 0;
m_iCurrentSelection = 0;
}
bool UIControl_ButtonList::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eButtonList);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// SlotList specific initialisers
m_addNewItemFunc = registerFastName(L"addNewItem");
m_removeAllItemsFunc = registerFastName(L"removeAllItems");
m_funcHighlightItem = registerFastName(L"HighlightItem");
m_funcRemoveItem = registerFastName(L"RemoveItem");
m_funcSetButtonLabel = registerFastName(L"SetButtonLabel");
m_funcSetTouchFocus = registerFastName(L"SetTouchFocus");
m_funcCanTouchTrigger = registerFastName(L"CanTouchTrigger");
return success;
}
void UIControl_ButtonList::init(int id) {
m_id = id;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = id;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 1, value);
}
void UIControl_ButtonList::ReInit() {
UIControl_Base::ReInit();
init(m_id);
m_itemCount = 0;
m_iCurrentSelection = 0;
}
void UIControl_ButtonList::clearList() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_removeAllItemsFunc, 0, nullptr);
m_itemCount = 0;
}
void UIControl_ButtonList::addItem(const std::string& label) {
addItem(label, m_itemCount);
}
void UIControl_ButtonList::addItem(const std::wstring& label) {
addItem(label, m_itemCount);
}
void UIControl_ButtonList::addItem(const std::string& label, int data) {
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF8 stringVal;
stringVal.string = (char*)label.c_str();
stringVal.length = (S32)label.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = data;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addNewItemFunc, 2, value);
++m_itemCount;
}
void UIControl_ButtonList::addItem(const std::wstring& label, int data) {
IggyDataValue result;
IggyDataValue value[2];
const std::u16string convLabel = wstring_to_u16string(label);
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = data;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addNewItemFunc, 2, value);
++m_itemCount;
}
void UIControl_ButtonList::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_ButtonList::setCurrentSelection(int iSelection) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iSelection;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcHighlightItem, 1, value);
}
int UIControl_ButtonList::getCurrentSelection() { return m_iCurrentSelection; }
void UIControl_ButtonList::updateChildFocus(int iChild) {
m_iCurrentSelection = iChild;
}
void UIControl_ButtonList::setButtonLabel(int iButtonId,
const std::wstring& label) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iButtonId;
const std::u16string convLabel = wstring_to_u16string(label);
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcSetButtonLabel, 2, value);
}
void UIControl_DynamicButtonList::tick() {
UIControl_ButtonList::tick();
int buttonIndex = 0;
std::vector<UIString>::iterator itr;
for (itr = m_labels.begin(); itr != m_labels.end(); itr++) {
if (itr->needsUpdating()) {
setButtonLabel(buttonIndex, itr->getString());
itr->setUpdated();
}
buttonIndex++;
}
}
void UIControl_DynamicButtonList::addItem(UIString label, int data) {
if (data < 0) data = m_itemCount;
if (data < m_labels.size()) {
m_labels[data] = label;
} else {
while (data > m_labels.size()) {
m_labels.push_back(UIString());
}
m_labels.push_back(label);
}
UIControl_ButtonList::addItem(label.getString(), data);
}
void UIControl_DynamicButtonList::removeItem(int index) {
m_labels.erase(m_labels.begin() + index);
UIControl_ButtonList::removeItem(index);
}

View File

@@ -0,0 +1,53 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_ButtonList : public UIControl_Base {
protected:
IggyName m_addNewItemFunc, m_removeAllItemsFunc, m_funcHighlightItem,
m_funcRemoveItem, m_funcSetButtonLabel, m_funcSetTouchFocus,
m_funcCanTouchTrigger;
int m_itemCount;
int m_iCurrentSelection;
public:
UIControl_ButtonList();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(int id);
virtual void ReInit();
void clearList();
void addItem(const std::wstring& label);
void addItem(const std::string& label);
void addItem(const std::wstring& label, int data);
void addItem(const std::string& label, int data);
void removeItem(int index);
int getItemCount() { return m_itemCount; }
void setCurrentSelection(int iSelection);
int getCurrentSelection();
void updateChildFocus(int iChild);
void setButtonLabel(int iButtonId, const std::wstring& label);
};
class UIControl_DynamicButtonList : public UIControl_ButtonList {
protected:
std::vector<UIString> m_labels;
public:
virtual void tick();
virtual void addItem(UIString label, int data = -1);
virtual void removeItem(int index);
};

View File

@@ -0,0 +1,98 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_CheckBox.h"
UIControl_CheckBox::UIControl_CheckBox() {}
bool UIControl_CheckBox::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eCheckBox);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// CheckBox specific initialisers
m_checkedProp = registerFastName(L"Checked");
m_funcEnable = registerFastName(L"EnableCheckBox");
m_funcSetCheckBox = registerFastName(L"SetCheckBox");
m_bEnabled = true;
return success;
}
void UIControl_CheckBox::init(UIString label, int id, bool checked) {
m_label = label;
m_id = id;
m_bChecked = checked;
const std::u16string convLabel = wstring_to_u16string(label.getString());
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (int)id;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = checked;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 3, value);
}
bool UIControl_CheckBox::IsChecked() {
rrbool checked = false;
IggyResult result =
IggyValueGetBooleanRS(&m_iggyPath, m_checkedProp, nullptr, &checked);
m_bChecked = checked;
return checked;
}
bool UIControl_CheckBox::IsEnabled() { return m_bEnabled; }
void UIControl_CheckBox::SetEnable(bool enable) {
m_bEnabled = enable;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = enable;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcEnable, 1, value);
}
// 4J HEG - this is only ever used when required, most of this should happen in
// the flash
void UIControl_CheckBox::setChecked(bool checked) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = checked;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetCheckBox, 1, value);
}
// 4J-TomK we need to trigger this one via function instead of key down event
// because of how it works
void UIControl_CheckBox::TouchSetCheckbox(bool checked) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = checked;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetCheckBox, 1, value);
}
void UIControl_CheckBox::ReInit() {
UIControl_Base::ReInit();
init(m_label, m_id, m_bChecked);
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_CheckBox : public UIControl_Base {
private:
IggyName m_checkedProp, m_funcEnable, m_funcSetCheckBox;
bool m_bChecked, m_bEnabled;
public:
UIControl_CheckBox();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(UIString label, int id, bool checked);
bool IsChecked();
bool IsEnabled();
void SetEnable(bool enable);
void setChecked(bool checked);
void TouchSetCheckbox(bool checked);
virtual void ReInit();
};

View File

@@ -0,0 +1,15 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_Cursor.h"
UIControl_Cursor::UIControl_Cursor() {}
bool UIControl_Cursor::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eCursor);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// Label specific initialisers
return success;
}

View File

@@ -0,0 +1,11 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Cursor : public UIControl_Base {
public:
UIControl_Cursor();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
};

View File

@@ -0,0 +1,77 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_DLCList.h"
bool UIControl_DLCList::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eDLCList);
bool success =
UIControl_ButtonList::setupControl(scene, parent, controlName);
// SlotList specific initialisers
m_funcShowTick = registerFastName(L"ShowTick");
return success;
}
void UIControl_DLCList::addItem(const std::string& label, bool showTick,
int iId) {
IggyDataValue result;
IggyDataValue value[3];
IggyStringUTF8 stringVal;
stringVal.string = (char*)label.c_str();
stringVal.length = (S32)label.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iId;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = showTick;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addNewItemFunc, 3, value);
++m_itemCount;
}
void UIControl_DLCList::addItem(const std::wstring& label, bool showTick,
int iId) {
IggyDataValue result;
IggyDataValue value[3];
const std::u16string convLabel = wstring_to_u16string(label);
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = (S32)convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iId;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = showTick;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addNewItemFunc, 3, value);
++m_itemCount;
}
void UIControl_DLCList::showTick(int iId, bool showTick) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = showTick;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcShowTick, 2, value);
}

View File

@@ -0,0 +1,17 @@
#pragma once
#include "UIControl_ButtonList.h"
class UIControl_DLCList : public UIControl_ButtonList {
private:
IggyName m_funcShowTick;
public:
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
using UIControl_ButtonList::addItem;
void addItem(const std::string& label, bool showTick, int iId);
void addItem(const std::wstring& label, bool showTick, int iId);
void showTick(int iId, bool showTick);
};

View File

@@ -0,0 +1,84 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_DynamicLabel.h"
UIControl_DynamicLabel::UIControl_DynamicLabel() {}
bool UIControl_DynamicLabel::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eDynamicLabel);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// Label specific initialisers
m_funcAddText = registerFastName(L"AddText");
m_funcTouchScroll = registerFastName(L"TouchScroll");
m_funcGetRealWidth = registerFastName(L"GetRealWidth");
m_funcGetRealHeight = registerFastName(L"GetRealHeight");
return success;
}
void UIControl_DynamicLabel::addText(const std::wstring& text,
bool bLastEntry) {
const std::u16string convText = wstring_to_u16string(text);
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF16 stringVal;
stringVal.string = convText.c_str();
stringVal.length = convText.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = bLastEntry;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcAddText, 2, value);
}
void UIControl_DynamicLabel::ReInit() { UIControl_Base::ReInit(); }
void UIControl_DynamicLabel::SetupTouch() {}
void UIControl_DynamicLabel::TouchScroll(S32 iY, bool bActive) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iY;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = bActive;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcTouchScroll, 2, value);
}
S32 UIControl_DynamicLabel::GetRealWidth() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcGetRealWidth, 0, nullptr);
S32 iRealWidth = m_width;
if (result.type == IGGY_DATATYPE_number) {
iRealWidth = (S32)result.number;
}
return iRealWidth;
}
S32 UIControl_DynamicLabel::GetRealHeight() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcGetRealHeight, 0, nullptr);
S32 iRealHeight = m_height;
if (result.type == IGGY_DATATYPE_number) {
iRealHeight = (S32)result.number;
}
return iRealHeight;
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_DynamicLabel : public UIControl_Label {
private:
IggyName m_funcAddText, m_funcTouchScroll, m_funcGetRealWidth,
m_funcGetRealHeight;
public:
UIControl_DynamicLabel();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
virtual void addText(const std::wstring& text, bool bLastEntry);
virtual void ReInit();
virtual void SetupTouch();
virtual void TouchScroll(S32 iY, bool bActive);
S32 GetRealWidth();
S32 GetRealHeight();
};

View File

@@ -0,0 +1,132 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_EnchantmentBook.h"
#include "../../../../net/minecraft/client/Minecraft.h"
#include "../../../../net/minecraft/client/renderer/tileentity/TileEntityRenderDispatcher.h"
#include "../../../../net/minecraft/client/renderer/tileentity/EnchantTableRenderer.h"
#include "../../../../net/minecraft/client/Lighting.h"
#include "../../../../net/minecraft/client/model/BookModel.h"
#include "../../../../../Minecraft.World/net/minecraft/world/level/tile/entity/net.minecraft.world.level.tile.entity.h"
#include "../../../../../Minecraft.World/net/minecraft/world/inventory/net.minecraft.world.inventory.h"
UIControl_EnchantmentBook::UIControl_EnchantmentBook() {
UIControl::setControlType(UIControl::eEnchantmentBook);
model = nullptr;
last = nullptr;
time = 0;
flip = oFlip = flipT = flipA = 0.0f;
open = oOpen = 0.0f;
}
void UIControl_EnchantmentBook::render(IggyCustomDrawCallbackRegion* region) {
glPushMatrix();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
// Revert the scale from the setup
float ssX = width / m_width;
float ssY = height / m_height;
glScalef(ssX, ssY, 1.0f);
glTranslatef(m_width / 2, m_height / 2, 50.0f);
// Add a uniform scale
glScalef(-57 / ssX, 57 / ssX, 360.0f);
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
// float sss = 4;
// glTranslatef(0, 3.3f, -16);
// glScalef(sss, sss, sss);
Minecraft* pMinecraft = Minecraft::GetInstance();
int tex = pMinecraft->textures->loadTexture(
TN_ITEM_BOOK); // 4J was L"/1_2_2/item/book.png"
pMinecraft->textures->bind(tex);
glRotatef(20, 1, 0, 0);
float a = 1;
float o = oOpen + (open - oOpen) * a;
glTranslatef((1 - o) * 0.2f, (1 - o) * 0.1f, (1 - o) * 0.25f);
glRotatef(-(1 - o) * 90 - 90, 0, 1, 0);
glRotatef(180, 1, 0, 0);
float ff1 = oFlip + (flip - oFlip) * a + 0.25f;
float ff2 = oFlip + (flip - oFlip) * a + 0.75f;
ff1 = (ff1 - floor(ff1)) * 1.6f - 0.3f;
ff2 = (ff2 - floor(ff2)) * 1.6f - 0.3f;
if (ff1 < 0) ff1 = 0;
if (ff2 < 0) ff2 = 0;
if (ff1 > 1) ff1 = 1;
if (ff2 > 1) ff2 = 1;
glEnable(GL_CULL_FACE);
if (model == nullptr) {
// Share the model the the EnchantTableRenderer
EnchantTableRenderer* etr =
(EnchantTableRenderer*)TileEntityRenderDispatcher::instance
->getRenderer(eTYPE_ENCHANTMENTTABLEENTITY);
if (etr != nullptr) {
model = etr->bookModel;
} else {
model = new BookModel();
}
}
model->render(nullptr, 0, ff1, ff2, o, 0, 1 / 16.0f, true);
glDisable(GL_CULL_FACE);
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
tickBook();
}
void UIControl_EnchantmentBook::tickBook() {
UIScene_EnchantingMenu* m_containerScene =
(UIScene_EnchantingMenu*)m_parentScene;
EnchantmentMenu* menu = m_containerScene->getMenu();
std::shared_ptr<ItemInstance> current = menu->getSlot(0)->getItem();
if (!ItemInstance::matches(current, last)) {
last = current;
do {
flipT += random.nextInt(4) - random.nextInt(4);
} while (flip <= flipT + 1 && flip >= flipT - 1);
}
time++;
oFlip = flip;
oOpen = open;
bool shouldBeOpen = false;
for (int i = 0; i < 3; i++) {
if (menu->costs[i] != 0) {
shouldBeOpen = true;
}
}
if (shouldBeOpen)
open += 0.2f;
else
open -= 0.2f;
if (open < 0) open = 0;
if (open > 1) open = 1;
float diff = (flipT - flip) * 0.4f;
float max = 0.2f;
if (diff < -max) diff = -max;
if (diff > +max) diff = +max;
flipA += (diff - flipA) * 0.9f;
flip = flip + flipA;
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include "UIControl.h"
class UIScene_EnchantingMenu;
class BookModel;
class UIControl_EnchantmentBook : public UIControl {
private:
BookModel* model;
Random random;
// 4J JEV: Book animation variables.
int time;
float flip, oFlip, flipT, flipA;
float open, oOpen;
// bool m_bDirty;
// float m_fScale,m_fAlpha;
// int m_iPad;
std::shared_ptr<ItemInstance> last;
// float m_fScreenWidth,m_fScreenHeight;
// float m_fRawWidth,m_fRawHeight;
void tickBook();
public:
UIControl_EnchantmentBook();
void render(IggyCustomDrawCallbackRegion* region);
};

View File

@@ -0,0 +1,214 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include <iterator>
#include <sstream>
#include "../UI.h"
#include "UIControl_EnchantmentButton.h"
#include "../../../../../Minecraft.World/net/minecraft/world/inventory/net.minecraft.world.inventory.h"
#include "../../../../net/minecraft/client/Minecraft.h"
#include "../../../../net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "../../../../../Minecraft.World/ConsoleHelpers/StringHelpers.h"
#include <iterator>
UIControl_EnchantmentButton::UIControl_EnchantmentButton() {
m_index = 0;
m_lastState = eState_Inactive;
m_lastCost = 0;
m_enchantmentString = L"";
m_bHasFocus = false;
m_textColour = app.GetHTMLColour(eTextColor_Enchant);
m_textFocusColour = app.GetHTMLColour(eTextColor_EnchantFocus);
m_textDisabledColour = app.GetHTMLColour(eTextColor_EnchantDisabled);
}
bool UIControl_EnchantmentButton::setupControl(UIScene* scene,
IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eEnchantmentButton);
bool success = UIControl_Button::setupControl(scene, parent, controlName);
// Button specific initialisers
m_funcChangeState = registerFastName(L"ChangeState");
return success;
}
void UIControl_EnchantmentButton::init(int index) { m_index = index; }
void UIControl_EnchantmentButton::ReInit() {
UIControl_Button::ReInit();
m_lastState = eState_Inactive;
m_lastCost = 0;
m_bHasFocus = false;
updateState();
}
void UIControl_EnchantmentButton::tick() {
updateState();
UIControl_Button::tick();
}
void UIControl_EnchantmentButton::render(IggyCustomDrawCallbackRegion* region) {
UIScene_EnchantingMenu* enchantingScene =
(UIScene_EnchantingMenu*)m_parentScene;
EnchantmentMenu* menu = enchantingScene->getMenu();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width / 2;
float yo = height;
// glTranslatef(xo, yo, 50.0f);
// Revert the scale from the setup
float ssX = width / m_width;
float ssY = height / m_height;
glScalef(ssX, ssY, 1.0f);
float ss = 1.0f;
#if TO_BE_IMPLEMENTED
if (!enchantingScene->m_bSplitscreen)
#endif
{
switch (enchantingScene->getSceneResolution()) {
case UIScene::eSceneResolution_1080:
ss = 3.0f;
break;
default:
ss = 2.0f;
break;
}
}
glScalef(ss, ss, ss);
int cost = menu->costs[m_index];
// if(cost != m_lastCost)
//{
// updateState();
// }
glColor4f(1, 1, 1, 1);
if (cost != 0) {
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);
Minecraft* pMinecraft = Minecraft::GetInstance();
std::wstring line = _toString<int>(cost);
Font* font = pMinecraft->altFont;
// int col = 0x685E4A;
unsigned int col = m_textColour;
if (pMinecraft->localplayers[enchantingScene->getPad()]
->experienceLevel < cost &&
!pMinecraft->localplayers[enchantingScene->getPad()]
->abilities.instabuild) {
col = m_textDisabledColour;
font->drawWordWrap(m_enchantmentString, 0, 0, (float)m_width / ss,
col, (float)m_height / ss);
font = pMinecraft->font;
// col = (0x80ff20 & 0xfefefe) >> 1;
// font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col);
} else {
if (m_bHasFocus) {
// col = 0xffff80;
col = m_textFocusColour;
}
font->drawWordWrap(m_enchantmentString, 0, 0, (float)m_width / ss,
col, (float)m_height / ss);
font = pMinecraft->font;
// col = 0x80ff20;
// font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col);
}
glDisable(GL_ALPHA_TEST);
} else {
}
// Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
}
void UIControl_EnchantmentButton::updateState() {
UIScene_EnchantingMenu* enchantingScene =
(UIScene_EnchantingMenu*)m_parentScene;
EnchantmentMenu* menu = enchantingScene->getMenu();
EState state = eState_Inactive;
int cost = menu->costs[m_index];
Minecraft* pMinecraft = Minecraft::GetInstance();
if (cost > pMinecraft->localplayers[enchantingScene->getPad()]
->experienceLevel &&
!pMinecraft->localplayers[enchantingScene->getPad()]
->abilities.instabuild) {
// Dark background
state = eState_Inactive;
} else {
// Light background and focus background
if (m_bHasFocus) {
state = eState_Selected;
} else {
state = eState_Active;
}
}
if (cost != m_lastCost) {
setLabel(_toString<int>(cost));
m_lastCost = cost;
m_enchantmentString = EnchantmentNames::instance.getRandomName();
}
if (cost == 0) {
// Dark background
state = eState_Inactive;
setLabel(L"");
}
if (state != m_lastState) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (int)state;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(),
&result, getIggyValuePath(),
m_funcChangeState, 1, value);
if (out == IGGY_RESULT_SUCCESS) m_lastState = state;
}
}
void UIControl_EnchantmentButton::setFocus(bool focus) {
m_bHasFocus = focus;
updateState();
}
UIControl_EnchantmentButton::EnchantmentNames
UIControl_EnchantmentButton::EnchantmentNames::instance;
UIControl_EnchantmentButton::EnchantmentNames::EnchantmentNames() {
std::wstring allWords =
L"the elder scrolls klaatu berata niktu xyzzy bless curse light "
L"darkness fire air earth water hot dry cold wet ignite snuff embiggen "
L"twist shorten stretch fiddle destroy imbue galvanize enchant free "
L"limited range of towards inside sphere cube self other ball mental "
L"physical grow shrink demon elemental spirit animal creature beast "
L"humanoid undead fresh stale ";
std::wistringstream iss(allWords);
std::copy(std::istream_iterator<std::wstring, wchar_t,
std::char_traits<wchar_t> >(iss),
std::istream_iterator<std::wstring, wchar_t,
std::char_traits<wchar_t> >(),
std::back_inserter(words));
}
std::wstring UIControl_EnchantmentButton::EnchantmentNames::getRandomName() {
int wordCount = random.nextInt(2) + 3;
std::wstring word = L"";
for (int i = 0; i < wordCount; i++) {
if (i > 0) word += L" ";
word += words[random.nextInt(words.size())];
}
return word;
}

View File

@@ -0,0 +1,53 @@
#pragma once
#include "UIControl_Button.h"
class UIControl_EnchantmentButton : public UIControl_Button {
private:
// Maps to values in AS
enum EState {
eState_Inactive = 0,
eState_Active = 1,
eState_Selected = 2,
};
EState m_lastState;
int m_lastCost;
int m_index;
std::wstring m_enchantmentString;
bool m_bHasFocus;
IggyName m_funcChangeState;
unsigned int m_textColour, m_textFocusColour, m_textDisabledColour;
class EnchantmentNames {
public:
static EnchantmentNames instance;
private:
Random random;
std::vector<std::wstring> words;
EnchantmentNames();
public:
std::wstring getRandomName();
};
public:
UIControl_EnchantmentButton();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
virtual void tick();
void init(int index);
virtual void ReInit();
void render(IggyCustomDrawCallbackRegion* region);
void updateState();
virtual void setFocus(bool focus);
};

View File

@@ -0,0 +1,90 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_HTMLLabel.h"
UIControl_HTMLLabel::UIControl_HTMLLabel() {}
bool UIControl_HTMLLabel::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eHTMLLabel);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// Label specific initialisers
m_funcStartAutoScroll = registerFastName(L"StartAutoScroll");
m_funcTouchScroll = registerFastName(L"TouchScroll");
m_funcGetRealWidth = registerFastName(L"GetRealWidth");
m_funcGetRealHeight = registerFastName(L"GetRealHeight");
return success;
}
void UIControl_HTMLLabel::startAutoScroll() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcStartAutoScroll, 0, nullptr);
}
void UIControl_HTMLLabel::ReInit() {
UIControl_Base::ReInit();
// Don't set the label, HTML sizes will have changed. Let the scene update
// us.
init(L"");
}
void UIControl_HTMLLabel::setLabel(const std::string& label) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF8;
IggyStringUTF8 stringVal;
stringVal.string = (char*)label.c_str();
stringVal.length = label.length();
value[0].string8 = stringVal;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_setLabelFunc, 1, value);
}
void UIControl_HTMLLabel::SetupTouch() {}
void UIControl_HTMLLabel::TouchScroll(S32 iY, bool bActive) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iY;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = bActive;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcTouchScroll, 2, value);
}
S32 UIControl_HTMLLabel::GetRealWidth() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcGetRealWidth, 0, nullptr);
S32 iRealWidth = m_width;
if (result.type == IGGY_DATATYPE_number) {
iRealWidth = (S32)result.number;
}
return iRealWidth;
}
S32 UIControl_HTMLLabel::GetRealHeight() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcGetRealHeight, 0, nullptr);
S32 iRealHeight = m_height;
if (result.type == IGGY_DATATYPE_number) {
iRealHeight = (S32)result.number;
}
return iRealHeight;
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_HTMLLabel : public UIControl_Label {
private:
IggyName m_funcStartAutoScroll, m_funcTouchScroll, m_funcGetRealWidth,
m_funcGetRealHeight;
public:
UIControl_HTMLLabel();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void startAutoScroll();
virtual void ReInit();
using UIControl_Base::setLabel;
void setLabel(const std::string& label);
virtual void SetupTouch();
virtual void TouchScroll(S32 iY, bool bActive);
S32 GetRealWidth();
S32 GetRealHeight();
};

View File

@@ -0,0 +1,43 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_Label.h"
#include "../../../../../Minecraft.World/ConsoleHelpers/StringHelpers.h"
UIControl_Label::UIControl_Label() {}
bool UIControl_Label::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eLabel);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// Label specific initialisers
return success;
}
void UIControl_Label::init(UIString label) {
m_label = label;
const std::u16string convLabel = wstring_to_u16string(label.getString());
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 1, value);
}
void UIControl_Label::ReInit() {
UIControl_Base::ReInit();
// 4J-JEV: This can't be reinitialised.
if (m_reinitEnabled) {
init(m_label);
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Label : public UIControl_Base {
private:
bool m_reinitEnabled;
public:
UIControl_Label();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(UIString label);
virtual void ReInit();
void disableReinitialisation() { m_reinitEnabled = false; }
};

View File

@@ -0,0 +1,216 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_LeaderboardList.h"
UIControl_LeaderboardList::UIControl_LeaderboardList() {}
bool UIControl_LeaderboardList::setupControl(UIScene* scene,
IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eLeaderboardList);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// UIControl_LeaderboardList specific initialisers
m_funcInitLeaderboard = registerFastName(L"InitLeaderboard");
m_funcAddDataSet = registerFastName(L"AddDataSet");
m_funcResetLeaderboard = registerFastName(L"ResetLeaderboard");
m_funcSetupTitles = registerFastName(L"SetupTitles");
m_funcSetColumnIcon = registerFastName(L"SetColumnIcon");
return success;
}
void UIControl_LeaderboardList::init(int id) {
m_id = id;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = id;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 1, value);
}
void UIControl_LeaderboardList::ReInit() {
UIControl_Base::ReInit();
init(m_id);
}
void UIControl_LeaderboardList::clearList() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcResetLeaderboard, 0, nullptr);
}
void UIControl_LeaderboardList::setupTitles(const std::wstring& rank,
const std::wstring& gamertag) {
IggyDataValue result;
IggyDataValue value[2];
const std::u16string convRank = wstring_to_u16string(rank);
IggyStringUTF16 stringVal0;
stringVal0.string = convRank.c_str();
stringVal0.length = convRank.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal0;
const std::u16string convGamertag = wstring_to_u16string(gamertag);
IggyStringUTF16 stringVal1;
stringVal1.string = convGamertag.c_str();
stringVal1.length = convGamertag.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal1;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetupTitles, 2, value);
}
void UIControl_LeaderboardList::initLeaderboard(int iFirstFocus,
int iTotalEntries,
int iNumColumns) {
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iFirstFocus;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iTotalEntries;
value[2].type = IGGY_DATATYPE_number;
value[2].number = iNumColumns;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcInitLeaderboard, 3, value);
}
void UIControl_LeaderboardList::setColumnIcon(int iColumn, int iType) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iColumn;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (iType <= 32000) ? 0 : (iType - 32000);
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcSetColumnIcon, 2, value);
}
void UIControl_LeaderboardList::addDataSet(
bool bLast, int iId, int iRank, const std::wstring& gamertag,
bool bDisplayMessage, const std::wstring& col0, const std::wstring& col1,
const std::wstring& col2, const std::wstring& col3,
const std::wstring& col4, const std::wstring& col5,
const std::wstring& col6) {
IggyDataValue result;
IggyDataValue value[12];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = bLast;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iId;
value[2].type = IGGY_DATATYPE_number;
value[2].number = iRank;
const std::u16string convGamertag = wstring_to_u16string(gamertag);
IggyStringUTF16 stringVal0;
stringVal0.string = convGamertag.c_str();
stringVal0.length = convGamertag.length();
value[3].type = IGGY_DATATYPE_string_UTF16;
value[3].string16 = stringVal0;
value[4].type = IGGY_DATATYPE_boolean;
value[4].boolval = bDisplayMessage;
const std::u16string convCol0 = wstring_to_u16string(col0);
IggyStringUTF16 stringVal1;
stringVal1.string = convCol0.c_str();
stringVal1.length = convCol0.length();
value[5].type = IGGY_DATATYPE_string_UTF16;
value[5].string16 = stringVal1;
if (col1.empty()) {
value[6].type = IGGY_DATATYPE_null;
} else {
const std::u16string convCol1 = wstring_to_u16string(col1);
IggyStringUTF16 stringVal2;
stringVal2.string = convCol1.c_str();
stringVal2.length = convCol1.length();
value[6].type = IGGY_DATATYPE_string_UTF16;
value[6].string16 = stringVal2;
}
if (col2.empty()) {
value[7].type = IGGY_DATATYPE_null;
} else {
const std::u16string convCol2 = wstring_to_u16string(col2);
IggyStringUTF16 stringVal3;
stringVal3.string = convCol2.c_str();
stringVal3.length = convCol2.length();
value[7].type = IGGY_DATATYPE_string_UTF16;
value[7].string16 = stringVal3;
}
if (col3.empty()) {
value[8].type = IGGY_DATATYPE_null;
} else {
const std::u16string convCol3 = wstring_to_u16string(col3);
IggyStringUTF16 stringVal4;
stringVal4.string = convCol3.c_str();
stringVal4.length = convCol3.length();
value[8].type = IGGY_DATATYPE_string_UTF16;
value[8].string16 = stringVal4;
}
if (col4.empty()) {
value[9].type = IGGY_DATATYPE_null;
} else {
const std::u16string convCol4 = wstring_to_u16string(col4);
IggyStringUTF16 stringVal5;
stringVal5.string = convCol4.c_str();
stringVal5.length = convCol4.length();
value[9].type = IGGY_DATATYPE_string_UTF16;
value[9].string16 = stringVal5;
}
if (col5.empty()) {
value[10].type = IGGY_DATATYPE_null;
} else {
const std::u16string convCol5 = wstring_to_u16string(col5);
IggyStringUTF16 stringVal6;
stringVal6.string = convCol5.c_str();
stringVal6.length = convCol5.length();
value[10].type = IGGY_DATATYPE_string_UTF16;
value[10].string16 = stringVal6;
}
if (col6.empty()) {
value[11].type = IGGY_DATATYPE_null;
} else {
const std::u16string convCol6 = wstring_to_u16string(col6);
IggyStringUTF16 stringVal7;
stringVal7.string = convCol6.c_str();
stringVal7.length = convCol6.length();
value[11].type = IGGY_DATATYPE_string_UTF16;
value[11].string16 = stringVal7;
}
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcAddDataSet, 12, value);
}

View File

@@ -0,0 +1,47 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_LeaderboardList : public UIControl_Base {
private:
IggyName m_funcInitLeaderboard, m_funcAddDataSet;
IggyName m_funcResetLeaderboard;
IggyName m_funcSetupTitles, m_funcSetColumnIcon;
public:
enum ELeaderboardIcons {
e_ICON_TYPE_IGGY = 0,
e_ICON_TYPE_CLIMBED = 32001,
e_ICON_TYPE_FALLEN = 32002,
e_ICON_TYPE_WALKED = 32003,
e_ICON_TYPE_SWAM = 32004,
e_ICON_TYPE_ZOMBIE = 32005,
e_ICON_TYPE_ZOMBIEPIGMAN = 32006,
e_ICON_TYPE_GHAST = 32007,
e_ICON_TYPE_CREEPER = 32008,
e_ICON_TYPE_SKELETON = 32009,
e_ICON_TYPE_SPIDER = 32010,
e_ICON_TYPE_SPIDERJOKEY = 32011,
e_ICON_TYPE_SLIME = 32012,
e_ICON_TYPE_PORTAL = 32013,
};
UIControl_LeaderboardList();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(int id);
virtual void ReInit();
void clearList();
void setupTitles(const std::wstring& rank, const std::wstring& gamertag);
void initLeaderboard(int iFirstFocus, int iTotalEntries, int iNumColumns);
void setColumnIcon(int iColumn, int iType);
void addDataSet(bool bLast, int iId, int iRank,
const std::wstring& gamertag, bool bDisplayMessage,
const std::wstring& col0, const std::wstring& col1,
const std::wstring& col2, const std::wstring& col3,
const std::wstring& col4, const std::wstring& col5,
const std::wstring& col6);
};

View File

@@ -0,0 +1,110 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../../../../net/minecraft/client/Minecraft.h"
#include "../../../../net/minecraft/client/gui/ScreenSizeCalculator.h"
#include "../../../../net/minecraft/client/renderer/entity/EntityRenderDispatcher.h"
#include "../../../../net/minecraft/client/renderer/entity/PlayerRenderer.h"
#include "../../../../net/minecraft/client/renderer/entity/HorseRenderer.h"
#include "../../../../net/minecraft/client/model/HumanoidModel.h"
#include "../../../../net/minecraft/client/model/ModelHorse.h"
#include "../../../../net/minecraft/client/Lighting.h"
#include "../../../../net/minecraft/client/model/geom/ModelPart.h"
#include "../../../../net/minecraft/client/Options.h"
#include "../../../../../Minecraft.World/net/minecraft/world/entity/player/net.minecraft.world.entity.player.h"
// #include
// "../../../Minecraft.World/net.minecraft.world.entity.animal.EntityHorse.h"
#include "../../../../net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "../UI.h"
#include "UIControl_MinecraftHorse.h"
UIControl_MinecraftHorse::UIControl_MinecraftHorse() {
UIControl::setControlType(UIControl::eMinecraftHorse);
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
}
void UIControl_MinecraftHorse::render(IggyCustomDrawCallbackRegion* region) {
Minecraft* pMinecraft = Minecraft::GetInstance();
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width / 2;
float yo = height;
// dynamic y offset according to region height
glTranslatef(xo, yo - (height / 7.5f), 50.0f);
// UIScene_InventoryMenu *containerMenu = (UIScene_InventoryMenu
// *)m_parentScene;
UIScene_HorseInventoryMenu* containerMenu =
(UIScene_HorseInventoryMenu*)m_parentScene;
std::shared_ptr<LivingEntity> entityHorse = containerMenu->m_horse;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
float ss = width / (m_fScreenWidth / m_fScreenHeight) * 0.71f;
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
float oybr = entityHorse->yBodyRot;
float oyr = entityHorse->yRot;
float oxr = entityHorse->xRot;
float oyhr = entityHorse->yHeadRot;
// float xd = ( matrix._41 + ( (bwidth*matrix._11)/2) ) - m_pointerPos.x;
float xd = (m_x + m_width / 2) - containerMenu->m_pointerPos.x;
// Need to base Y on head position, not centre of mass
// float yd = ( matrix._42 + ( (bheight*matrix._22) / 2) - 40 ) -
// m_pointerPos.y;
float yd = (m_y + m_height / 2 - 40) - containerMenu->m_pointerPos.y;
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float)atan(yd / 40.0f) * 20, 1, 0, 0);
entityHorse->yBodyRot = (float)atan(xd / 40.0f) * 20;
entityHorse->yRot = (float)atan(xd / 40.0f) * 40;
entityHorse->xRot = -(float)atan(yd / 40.0f) * 20;
entityHorse->yHeadRot = entityHorse->yRot;
// entityHorse->glow = 1;
glTranslatef(0, entityHorse->heightOffset, 0);
EntityRenderDispatcher::instance->playerRotY = 180;
// 4J Stu - Turning on hideGui while we do this stops the name rendering in
// split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
EntityRenderDispatcher::instance->render(entityHorse, 0, 0, 0, 0, 1, false,
false);
pMinecraft->options->hideGui = wasHidingGui;
// entityHorse->glow = 0;
entityHorse->yBodyRot = oybr;
entityHorse->yRot = oyr;
entityHorse->xRot = oxr;
entityHorse->yHeadRot = oyhr;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "UIControl.h"
class UIControl_MinecraftHorse : public UIControl {
private:
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
public:
UIControl_MinecraftHorse();
void render(IggyCustomDrawCallbackRegion* region);
};

View File

@@ -0,0 +1,103 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../../../../net/minecraft/client/Minecraft.h"
#include "../../../../net/minecraft/client/gui/ScreenSizeCalculator.h"
#include "../../../../net/minecraft/client/renderer/entity/EntityRenderDispatcher.h"
#include "../../../../net/minecraft/client/renderer/entity/PlayerRenderer.h"
#include "../../../../net/minecraft/client/model/HumanoidModel.h"
#include "../../../../net/minecraft/client/Lighting.h"
#include "../../../../net/minecraft/client/model/geom/ModelPart.h"
#include "../../../../net/minecraft/client/Options.h"
#include "../../../../../Minecraft.World/net/minecraft/world/entity/player/net.minecraft.world.entity.player.h"
#include "../../../../net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "../UI.h"
#include "UIControl_MinecraftPlayer.h"
UIControl_MinecraftPlayer::UIControl_MinecraftPlayer() {
UIControl::setControlType(UIControl::eMinecraftPlayer);
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
}
void UIControl_MinecraftPlayer::render(IggyCustomDrawCallbackRegion* region) {
Minecraft* pMinecraft = Minecraft::GetInstance();
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width / 2;
float yo = height;
// dynamic y offset according to region height
glTranslatef(xo, yo - (height / 9.0f), 50.0f);
float ss;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
ss = width / (m_fScreenWidth / m_fScreenHeight);
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
UIScene_InventoryMenu* containerMenu =
(UIScene_InventoryMenu*)m_parentScene;
float oybr = pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot;
float oyr = pMinecraft->localplayers[containerMenu->getPad()]->yRot;
float oxr = pMinecraft->localplayers[containerMenu->getPad()]->xRot;
float oyhr = pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot;
// float xd = ( matrix._41 + ( (bwidth*matrix._11)/2) ) - m_pointerPos.x;
float xd = (m_x + m_width / 2) - containerMenu->m_pointerPos.x;
// Need to base Y on head position, not centre of mass
// float yd = ( matrix._42 + ( (bheight*matrix._22) / 2) - 40 ) -
// m_pointerPos.y;
float yd = (m_y + m_height / 2 - 40) - containerMenu->m_pointerPos.y;
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float)atan(yd / 40.0f) * 20, 1, 0, 0);
pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot =
(float)atan(xd / 40.0f) * 20;
pMinecraft->localplayers[containerMenu->getPad()]->yRot =
(float)atan(xd / 40.0f) * 40;
pMinecraft->localplayers[containerMenu->getPad()]->xRot =
-(float)atan(yd / 40.0f) * 20;
pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot =
pMinecraft->localplayers[containerMenu->getPad()]->yRot;
// pMinecraft->localplayers[m_iPad]->glow = 1;
glTranslatef(
0, pMinecraft->localplayers[containerMenu->getPad()]->heightOffset, 0);
EntityRenderDispatcher::instance->playerRotY = 180;
// 4J Stu - Turning on hideGui while we do this stops the name rendering in
// split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
EntityRenderDispatcher::instance->render(
pMinecraft->localplayers[containerMenu->getPad()], 0, 0, 0, 0, 1, false,
false);
pMinecraft->options->hideGui = wasHidingGui;
// pMinecraft->localplayers[m_iPad]->glow = 0;
pMinecraft->localplayers[containerMenu->getPad()]->yBodyRot = oybr;
pMinecraft->localplayers[containerMenu->getPad()]->yRot = oyr;
pMinecraft->localplayers[containerMenu->getPad()]->xRot = oxr;
pMinecraft->localplayers[containerMenu->getPad()]->yHeadRot = oyhr;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "UIControl.h"
class UIControl_MinecraftPlayer : public UIControl {
private:
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
public:
UIControl_MinecraftPlayer();
void render(IggyCustomDrawCallbackRegion* region);
};

View File

@@ -0,0 +1,72 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_PlayerList.h"
bool UIControl_PlayerList::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::ePlayerList);
bool success =
UIControl_ButtonList::setupControl(scene, parent, controlName);
// SlotList specific initialisers
m_funcSetPlayerIcon = registerFastName(L"SetPlayerIcon");
m_funcSetVOIPIcon = registerFastName(L"SetVOIPIcon");
return success;
}
void UIControl_PlayerList::addItem(const std::wstring& label, int iPlayerIcon,
int iVOIPIcon) {
IggyDataValue result;
IggyDataValue value[4];
const std::u16string convLabel = wstring_to_u16string(label);
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = (S32)convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_itemCount;
value[2].type = IGGY_DATATYPE_number;
value[2].number = iPlayerIcon + 1;
value[3].type = IGGY_DATATYPE_number;
value[3].number = iVOIPIcon + 1;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addNewItemFunc, 4, value);
++m_itemCount;
}
void UIControl_PlayerList::setPlayerIcon(int iId, int iPlayerIcon) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iPlayerIcon + 1;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcSetPlayerIcon, 2, value);
}
void UIControl_PlayerList::setVOIPIcon(int iId, int iVOIPIcon) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
value[1].type = IGGY_DATATYPE_number;
value[1].number = iVOIPIcon + 1;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSetVOIPIcon, 2, value);
}

View File

@@ -0,0 +1,17 @@
#pragma once
#include "UIControl_ButtonList.h"
class UIControl_PlayerList : public UIControl_ButtonList {
private:
IggyName m_funcSetPlayerIcon, m_funcSetVOIPIcon;
public:
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
using UIControl_ButtonList::addItem;
void addItem(const std::wstring& label, int iPlayerIcon, int iVOIPIcon);
void setPlayerIcon(int iId, int iPlayerIcon);
void setVOIPIcon(int iId, int iVOIPIcon);
};

View File

@@ -0,0 +1,505 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../../../../net/minecraft/client/Minecraft.h"
#include "../../../../net/minecraft/client/gui/ScreenSizeCalculator.h"
#include "../../../../net/minecraft/client/renderer/entity/EntityRenderDispatcher.h"
#include "../../../../net/minecraft/client/renderer/entity/PlayerRenderer.h"
#include "../../../../net/minecraft/client/model/HumanoidModel.h"
#include "../../../../net/minecraft/client/Lighting.h"
#include "../../../../net/minecraft/client/model/geom/ModelPart.h"
#include "../../../../net/minecraft/client/Options.h"
#include "../../../../../Minecraft.World/net/minecraft/world/entity/player/net.minecraft.world.entity.player.h"
#include "UIControl_PlayerSkinPreview.h"
// #define SKIN_PREVIEW_BOB_ANIM
#define SKIN_PREVIEW_WALKING_ANIM
UIControl_PlayerSkinPreview::UIControl_PlayerSkinPreview() {
UIControl::setControlType(UIControl::ePlayerSkinPreview);
m_bDirty = false;
m_fScale = 1.0f;
m_fAlpha = 1.0f;
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
m_customTextureUrl = L"default";
m_backupTexture = TN_MOB_CHAR;
m_capeTextureUrl = L"";
m_yRot = 0;
m_xRot = 0;
m_swingTime = 0.0f;
m_bobTick = 0.0f;
m_walkAnimSpeedO = 0.0f;
m_walkAnimSpeed = 0.0f;
m_walkAnimPos = 0.0f;
m_bAutoRotate = false;
m_bRotatingLeft = false;
m_incXRot = false;
m_decXRot = false;
m_incYRot = false;
m_decYRot = false;
m_currentAnimation = e_SkinPreviewAnimation_Walking;
m_fTargetRotation = 0.0f;
m_fOriginalRotation = 0.0f;
m_framesAnimatingRotation = 0;
m_bAnimatingToFacing = false;
m_pvAdditionalModelParts = nullptr;
m_uiAnimOverrideBitmask = 0L;
}
void UIControl_PlayerSkinPreview::tick() {
UIControl::tick();
if (m_bAnimatingToFacing) {
++m_framesAnimatingRotation;
m_yRot = m_fOriginalRotation +
m_framesAnimatingRotation *
((m_fTargetRotation - m_fOriginalRotation) /
CHANGING_SKIN_FRAMES);
// if(m_framesAnimatingRotation == CHANGING_SKIN_FRAMES)
// m_bAnimatingToFacing = false;
} else {
if (m_incXRot) IncrementXRotation();
if (m_decXRot) DecrementXRotation();
if (m_incYRot) IncrementYRotation();
if (m_decYRot) DecrementYRotation();
if (m_bAutoRotate) {
++m_rotateTick;
if (m_rotateTick % 4 == 0) {
if (m_yRot >= LOOK_LEFT_EXTENT) {
m_bRotatingLeft = false;
} else if (m_yRot <= LOOK_RIGHT_EXTENT) {
m_bRotatingLeft = true;
}
if (m_bRotatingLeft) {
IncrementYRotation();
} else {
DecrementYRotation();
}
}
}
}
}
void UIControl_PlayerSkinPreview::SetTexture(const std::wstring& url,
TEXTURE_NAME backupTexture) {
m_customTextureUrl = url;
m_backupTexture = backupTexture;
unsigned int uiAnimOverrideBitmask = Player::getSkinAnimOverrideBitmask(
app.getSkinIdFromPath(m_customTextureUrl));
if (app.GetGameSettings(eGameSetting_CustomSkinAnim) == 0) {
// We have a force animation for some skins (claptrap)
// 4J-PB - treat all the eAnim_Disable flags as a force anim
if ((uiAnimOverrideBitmask &
HumanoidModel::m_staticBitmaskIgnorePlayerCustomAnimSetting) !=
0) {
m_uiAnimOverrideBitmask = uiAnimOverrideBitmask;
} else {
m_uiAnimOverrideBitmask = 0;
}
} else {
m_uiAnimOverrideBitmask = uiAnimOverrideBitmask;
}
m_pvAdditionalModelParts =
app.GetAdditionalModelParts(app.getSkinIdFromPath(m_customTextureUrl));
}
void UIControl_PlayerSkinPreview::SetFacing(ESkinPreviewFacing facing,
bool bAnimate /*= false*/) {
switch (facing) {
case e_SkinPreviewFacing_Forward:
m_fTargetRotation = 0;
m_bRotatingLeft = true;
break;
case e_SkinPreviewFacing_Left:
m_fTargetRotation = LOOK_LEFT_EXTENT;
m_bRotatingLeft = false;
break;
case e_SkinPreviewFacing_Right:
m_fTargetRotation = LOOK_RIGHT_EXTENT;
m_bRotatingLeft = true;
break;
}
if (!bAnimate) {
m_yRot = m_fTargetRotation;
m_bAnimatingToFacing = false;
} else {
m_fOriginalRotation = m_yRot;
m_bAnimatingToFacing = true;
m_framesAnimatingRotation = 0;
}
}
void UIControl_PlayerSkinPreview::CycleNextAnimation() {
m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation + 1);
if (m_currentAnimation >= e_SkinPreviewAnimation_Count)
m_currentAnimation = e_SkinPreviewAnimation_Walking;
m_swingTime = 0.0f;
}
void UIControl_PlayerSkinPreview::CyclePreviousAnimation() {
m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation - 1);
if (m_currentAnimation < e_SkinPreviewAnimation_Walking)
m_currentAnimation =
(ESkinPreviewAnimations)(e_SkinPreviewAnimation_Count - 1);
m_swingTime = 0.0f;
}
void UIControl_PlayerSkinPreview::render(IggyCustomDrawCallbackRegion* region) {
Minecraft* pMinecraft = Minecraft::GetInstance();
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width / 2;
float yo = height;
glTranslatef(xo, yo - 3.5f, 50.0f);
// glTranslatef(120.0f, 294, 0.0f);
float ss;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
ss = width / (m_fScreenWidth / m_fScreenHeight);
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
// glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
// glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float)m_xRot, 1, 0, 0);
// 4J Stu - Turning on hideGui while we do this stops the name rendering in
// split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
// EntityRenderDispatcher::instance->render(pMinecraft->localplayers[0], 0,
// 0, 0, 0, 1);
EntityRenderer* renderer =
EntityRenderDispatcher::instance->getRenderer(eTYPE_LOCALPLAYER);
if (renderer != nullptr) {
// 4J-PB - any additional parts to turn on for this player (skin
// dependent)
// std::vector<ModelPart *>
// *pAdditionalModelParts=mob->GetAdditionalModelParts();
if (m_pvAdditionalModelParts && m_pvAdditionalModelParts->size() != 0) {
for (auto it = m_pvAdditionalModelParts->begin();
it != m_pvAdditionalModelParts->end(); ++it) {
ModelPart* pModelPart = *it;
pModelPart->visible = true;
}
}
render(renderer, 0, 0, 0, 0, 1);
// renderer->postRender(entity, x, y, z, rot, a);
// hide the additional parts
if (m_pvAdditionalModelParts && m_pvAdditionalModelParts->size() != 0) {
for (auto it = m_pvAdditionalModelParts->begin();
it != m_pvAdditionalModelParts->end(); ++it) {
ModelPart* pModelPart = *it;
pModelPart->visible = false;
}
}
}
pMinecraft->options->hideGui = wasHidingGui;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
}
// 4J Stu - Modified version of MobRenderer::render that does not require an
// actual entity
void UIControl_PlayerSkinPreview::render(EntityRenderer* renderer, double x,
double y, double z, float rot,
float a) {
glPushMatrix();
glDisable(GL_CULL_FACE);
HumanoidModel* model = (HumanoidModel*)renderer->getModel();
// getAttackAnim(mob, a);
// if (armor != nullptr) armor->attackTime = model->attackTime;
// model->riding = mob->isRiding();
// if (armor != nullptr) armor->riding = model->riding;
// 4J Stu - Remember to reset these values once the rendering is done if you
// add another one
model->attackTime = 0;
model->sneaking = false;
model->holdingRightHand = false;
model->holdingLeftHand = false;
model->idle = false;
model->eating = false;
model->eating_swing = 0;
model->eating_t = 0;
model->young = false;
model->riding = false;
model->m_uiAnimOverrideBitmask = m_uiAnimOverrideBitmask;
if (!m_bAnimatingToFacing) {
switch (m_currentAnimation) {
case e_SkinPreviewAnimation_Sneaking:
model->sneaking = true;
break;
case e_SkinPreviewAnimation_Attacking:
model->holdingRightHand = true;
m_swingTime++;
if (m_swingTime >= (Player::SWING_DURATION * 3)) {
m_swingTime = 0;
}
model->attackTime =
m_swingTime / (float)(Player::SWING_DURATION * 3);
break;
default:
break;
};
}
float bodyRot =
m_yRot; //(mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a);
float headRot = m_yRot; //(mob->yRotO + (mob->yRot - mob->yRotO) * a);
float headRotx = 0; //(mob->xRotO + (mob->xRot - mob->xRotO) * a);
// setupPosition(mob, x, y, z);
// is equivalent to
glTranslatef((float)x, (float)y, (float)z);
// float bob = getBob(mob, a);
#if defined(SKIN_PREVIEW_BOB_ANIM)
float bob = (m_bobTick + a) / 2;
++m_bobTick;
if (m_bobTick >= 360 * 2) m_bobTick = 0;
#else
float bob = 0.0f;
#endif
// setupRotations(mob, bob, bodyRot, a);
// is equivalent to
glRotatef(180 - bodyRot, 0, 1, 0);
float _scale = 1 / 16.0f;
glEnable(GL_RESCALE_NORMAL);
glScalef(-1, -1, 1);
// scale(mob, a);
// is equivalent to
float s = 15 / 16.0f;
glScalef(s, s, s);
// 4J - TomK - pull up character a bit more to make sure extra geo around
// feet doesn't cause rendering problems on PSVita
glTranslatef(0, -24 * _scale - 0.125f / 16.0f, 0);
#if defined(SKIN_PREVIEW_WALKING_ANIM)
m_walkAnimSpeedO = m_walkAnimSpeed;
m_walkAnimSpeed += (0.1f - m_walkAnimSpeed) * 0.4f;
m_walkAnimPos += m_walkAnimSpeed;
float ws = m_walkAnimSpeedO + (m_walkAnimSpeed - m_walkAnimSpeedO) * a;
float wp = m_walkAnimPos - m_walkAnimSpeed * (1 - a);
#else
float ws = 0;
float wp = 0;
#endif
if (ws > 1) ws = 1;
MemSect(31);
bindTexture(m_customTextureUrl, m_backupTexture);
MemSect(0);
glEnable(GL_ALPHA_TEST);
// model->prepareMobModel(mob, wp, ws, a);
model->render(nullptr, wp, ws, bob, headRot - bodyRot, headRotx, _scale,
true);
/*for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmor(mob, i, a))
{
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, true);
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
}
}*/
// additionalRendering(mob, a);
if (bindTexture(m_capeTextureUrl, L"")) {
glPushMatrix();
glTranslatef(0, 0, 2 / 16.0f);
double xd = 0; //(mob->xCloakO + (mob->xCloak - mob->xCloakO) * a) -
//(mob->xo + (mob->x - mob->xo) * a);
double yd = 0; //(mob->yCloakO + (mob->yCloak - mob->yCloakO) * a) -
//(mob->yo + (mob->y - mob->yo) * a);
double zd = 0; //(mob->zCloakO + (mob->zCloak - mob->zCloakO) * a) -
//(mob->zo + (mob->z - mob->zo) * a);
float yr = 1; // mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a;
double xa = sin(yr * PI / 180);
double za = -cos(yr * PI / 180);
float flap = (float)yd * 10;
if (flap < -6) flap = -6;
if (flap > 32) flap = 32;
float lean = (float)(xd * xa + zd * za) * 100;
float lean2 = (float)(xd * za - zd * xa) * 100;
if (lean < 0) lean = 0;
// float pow = 1;//mob->oBob + (bob - mob->oBob) * a;
flap += 1; // sin((mob->walkDistO + (mob->walkDist - mob->walkDistO) *
// a) * 6) * 32 * pow;
if (model->sneaking) {
flap += 25;
}
glRotatef(6.0f + lean / 2 + flap, 1, 0, 0);
glRotatef(lean2 / 2, 0, 0, 1);
glRotatef(-lean2 / 2, 0, 1, 0);
glRotatef(180, 0, 1, 0);
model->renderCloak(1 / 16.0f, true);
glPopMatrix();
}
/*
float br = mob->getBrightness(a);
int overlayColor = getOverlayColor(mob, br, a);
if (((overlayColor >> 24) & 0xff) > 0 || mob->hurtTime > 0 || mob->deathTime
> 0)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthFunc(GL_EQUAL);
// 4J - changed these renders to not use the compiled version of their
models, because otherwise the render states set
// about (in particular the depth & alpha test) don't work with our command
buffer versions if (mob->hurtTime > 0 || mob->deathTime > 0)
{
glColor4f(br, 0, 0, 0.4f);
model->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmorOverlay(mob, i, a))
{
glColor4f(br, 0, 0, 0.4f);
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
}
}
}
if (((overlayColor >> 24) & 0xff) > 0)
{
float r = ((overlayColor >> 16) & 0xff) / 255.0f;
float g = ((overlayColor >> 8) & 0xff) / 255.0f;
float b = ((overlayColor) & 0xff) / 255.0f;
float aa = ((overlayColor >> 24) & 0xff) / 255.0f;
glColor4f(r, g, b, aa);
model->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmorOverlay(mob, i, a))
{
glColor4f(r, g, b, aa);
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
}
}
}
glDepthFunc(GL_LEQUAL);
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glEnable(GL_TEXTURE_2D);
}
*/
glDisable(GL_RESCALE_NORMAL);
glEnable(GL_CULL_FACE);
glPopMatrix();
MemSect(31);
// renderName(mob, x, y, z);
MemSect(0);
// Reset the model values to stop the changes we made here affecting
// anything in game (like the player hand render)
model->attackTime = 0;
model->sneaking = false;
model->holdingRightHand = false;
model->holdingLeftHand = false;
}
bool UIControl_PlayerSkinPreview::bindTexture(const std::wstring& urlTexture,
int backupTexture) {
Textures* t = Minecraft::GetInstance()->textures;
// 4J-PB - no http textures on the xbox, mem textures instead
// int id = t->loadHttpTexture(urlTexture, backupTexture);
int id = t->loadMemTexture(urlTexture, backupTexture);
if (id >= 0) {
t->bind(id);
return true;
} else {
return false;
}
}
bool UIControl_PlayerSkinPreview::bindTexture(
const std::wstring& urlTexture, const std::wstring& backupTexture) {
Textures* t = Minecraft::GetInstance()->textures;
// 4J-PB - no http textures on the xbox, mem textures instead
// int id = t->loadHttpTexture(urlTexture, backupTexture);
int id = t->loadMemTexture(urlTexture, backupTexture);
if (id >= 0) {
t->bind(id);
return true;
} else {
return false;
}
}

View File

@@ -0,0 +1,108 @@
#pragma once
#include <cstdint>
#include "UIControl.h"
#include "../../../../net/minecraft/client/renderer/Textures.h"
class ModelPart;
class EntityRenderer;
class UIControl_PlayerSkinPreview : public UIControl {
private:
static const int LOOK_LEFT_EXTENT = 45;
static const int LOOK_RIGHT_EXTENT = -45;
static const int CHANGING_SKIN_FRAMES = 15;
enum ESkinPreviewAnimations {
e_SkinPreviewAnimation_Walking,
e_SkinPreviewAnimation_Sneaking,
e_SkinPreviewAnimation_Attacking,
e_SkinPreviewAnimation_Count,
};
bool m_bDirty;
float m_fScale, m_fAlpha;
std::wstring m_customTextureUrl;
TEXTURE_NAME m_backupTexture;
std::wstring m_capeTextureUrl;
unsigned int m_uiAnimOverrideBitmask;
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
int m_yRot, m_xRot;
float m_bobTick;
float m_walkAnimSpeedO;
float m_walkAnimSpeed;
float m_walkAnimPos;
bool m_bAutoRotate, m_bRotatingLeft;
std::uint8_t m_rotateTick;
float m_fTargetRotation, m_fOriginalRotation;
int m_framesAnimatingRotation;
bool m_bAnimatingToFacing;
float m_swingTime;
ESkinPreviewAnimations m_currentAnimation;
// std::vector<Model::SKIN_BOX *> *m_pvAdditionalBoxes;
std::vector<ModelPart*>* m_pvAdditionalModelParts;
public:
enum ESkinPreviewFacing {
e_SkinPreviewFacing_Forward,
e_SkinPreviewFacing_Left,
e_SkinPreviewFacing_Right,
};
UIControl_PlayerSkinPreview();
virtual void tick();
void render(IggyCustomDrawCallbackRegion* region);
void SetTexture(const std::wstring& url,
TEXTURE_NAME backupTexture = TN_MOB_CHAR);
void SetCapeTexture(const std::wstring& url) { m_capeTextureUrl = url; }
void ResetRotation() {
m_xRot = 0;
m_yRot = 0;
}
void IncrementYRotation() {
m_yRot = (m_yRot + 4);
if (m_yRot >= 180) m_yRot = -180;
}
void DecrementYRotation() {
m_yRot = (m_yRot - 4);
if (m_yRot <= -180) m_yRot = 180;
}
void IncrementXRotation() {
m_xRot = (m_xRot + 2);
if (m_xRot > 22) m_xRot = 22;
}
void DecrementXRotation() {
m_xRot = (m_xRot - 2);
if (m_xRot < -22) m_xRot = -22;
}
void SetAutoRotate(bool autoRotate) { m_bAutoRotate = autoRotate; }
void SetFacing(ESkinPreviewFacing facing, bool bAnimate = false);
void CycleNextAnimation();
void CyclePreviousAnimation();
bool m_incXRot, m_decXRot;
bool m_incYRot, m_decYRot;
private:
void render(EntityRenderer* renderer, double x, double y, double z,
float rot, float a);
bool bindTexture(const std::wstring& urlTexture, int backupTexture);
bool bindTexture(const std::wstring& urlTexture,
const std::wstring& backupTexture);
};

View File

@@ -0,0 +1,88 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_Progress.h"
UIControl_Progress::UIControl_Progress() {
m_min = 0;
m_max = 100;
m_current = 0;
m_lastPercent = 0.0f;
m_showingBar = true;
}
bool UIControl_Progress::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eProgress);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// Progress specific initialisers
m_setProgressFunc = registerFastName(L"setProgress");
m_showBarFunc = registerFastName(L"ShowBar");
return success;
}
void UIControl_Progress::init(UIString label, int id, int min, int max,
int current) {
m_label = label;
m_id = id;
m_min = min;
m_max = max;
m_current = current;
const std::u16string convLabel = wstring_to_u16string(label.getString());
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 1, value);
}
void UIControl_Progress::ReInit() {
UIControl_Base::ReInit();
init(m_label, m_id, m_min, m_max, m_current);
}
void UIControl_Progress::setProgress(int current) {
m_current = current;
float percent = (float)((m_current - m_min)) / (m_max - m_min);
if (percent != m_lastPercent) {
m_lastPercent = percent;
// app.DebugPrintf("Setting progress value to %d/%f\n", m_current,
// percent);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = percent;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(),
&result, getIggyValuePath(),
m_setProgressFunc, 1, value);
}
}
void UIControl_Progress::showBar(bool show) {
if (show != m_showingBar) {
m_showingBar = show;
// app.DebugPrintf("Setting progress value to %d/%f\n", m_current,
// percent);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].boolval = show;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_showBarFunc, 1, value);
}
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Progress : public UIControl_Base {
private:
IggyName m_setProgressFunc, m_showBarFunc;
int m_min;
int m_max;
int m_current;
float m_lastPercent;
bool m_showingBar;
public:
UIControl_Progress();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(UIString label, int id, int min, int max, int current);
virtual void ReInit();
void setProgress(int current);
void showBar(bool show);
};

View File

@@ -0,0 +1,116 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_SaveList.h"
bool UIControl_SaveList::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eSaveList);
bool success =
UIControl_ButtonList::setupControl(scene, parent, controlName);
// SlotList specific initialisers
m_funcSetTextureName = registerFastName(L"SetTextureName");
return success;
}
void UIControl_SaveList::addItem(const std::wstring& label) {
addItem(label, L"");
}
void UIControl_SaveList::addItem(const std::string& label) {
addItem(label, L"");
}
void UIControl_SaveList::addItem(const std::wstring& label, int data) {
addItem(label, L"", data);
}
void UIControl_SaveList::addItem(const std::string& label, int data) {
addItem(label, L"", data);
}
void UIControl_SaveList::addItem(const std::string& label,
const std::wstring& iconName) {
addItem(label, iconName, m_itemCount);
++m_itemCount;
}
void UIControl_SaveList::addItem(const std::wstring& label,
const std::wstring& iconName) {
addItem(label, iconName, m_itemCount);
++m_itemCount;
}
void UIControl_SaveList::addItem(const std::string& label,
const std::wstring& iconName, int data) {
IggyDataValue result;
IggyDataValue value[3];
IggyStringUTF8 stringVal;
stringVal.string = (char*)label.c_str();
stringVal.length = (S32)label.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_itemCount;
const std::u16string convName = wstring_to_u16string(iconName);
IggyStringUTF16 stringVal2;
stringVal2.string = convName.c_str();
stringVal2.length = convName.length();
value[2].type = IGGY_DATATYPE_string_UTF16;
value[2].string16 = stringVal2;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addNewItemFunc, 3, value);
}
void UIControl_SaveList::addItem(const std::wstring& label,
const std::wstring& iconName, int data) {
IggyDataValue result;
IggyDataValue value[3];
const std::u16string convLabel = wstring_to_u16string(label);
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = (S32)convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_itemCount;
const std::u16string convName = wstring_to_u16string(iconName);
IggyStringUTF16 stringVal2;
stringVal2.string = convName.c_str();
stringVal2.length = convName.length();
value[2].type = IGGY_DATATYPE_string_UTF16;
value[2].string16 = stringVal2;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addNewItemFunc, 3, value);
}
void UIControl_SaveList::setTextureName(int iId, const std::wstring& iconName) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
const std::u16string convName = wstring_to_u16string(iconName);
IggyStringUTF16 stringVal;
stringVal.string = convName.c_str();
stringVal.length = convName.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcSetTextureName, 2, value);
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include "UIControl_ButtonList.h"
class UIControl_SaveList : public UIControl_ButtonList {
private:
IggyName m_funcSetTextureName;
public:
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
using UIControl_ButtonList::addItem;
void addItem(const std::wstring& label);
void addItem(const std::string& label);
void addItem(const std::wstring& label, int data);
void addItem(const std::string& label, int data);
void addItem(const std::string& label, const std::wstring& iconName);
void addItem(const std::wstring& label, const std::wstring& iconName);
void setTextureName(int iId, const std::wstring& iconName);
private:
void addItem(const std::string& label, const std::wstring& iconName,
int data);
void addItem(const std::wstring& label, const std::wstring& iconName,
int data);
};

View File

@@ -0,0 +1,106 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_Slider.h"
UIControl_Slider::UIControl_Slider() {
m_id = 0;
m_min = 0;
m_max = 100;
m_current = 0;
}
bool UIControl_Slider::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eSlider);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// Slider specific initialisers
m_funcSetRelativeSliderPos = registerFastName(L"SetRelativeSliderPos");
m_funcGetRealWidth = registerFastName(L"GetRealWidth");
return success;
}
void UIControl_Slider::init(UIString label, int id, int min, int max,
int current) {
m_label = label;
m_id = id;
m_min = min;
m_max = max;
m_current = current;
const std::u16string convLabel = wstring_to_u16string(label.getString());
IggyDataValue result;
IggyDataValue value[5];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (int)id;
value[2].type = IGGY_DATATYPE_number;
value[2].number = (int)min;
value[3].type = IGGY_DATATYPE_number;
value[3].number = (int)max;
value[4].type = IGGY_DATATYPE_number;
value[4].number = (int)current;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 5, value);
}
void UIControl_Slider::handleSliderMove(int newValue) {
if (m_current != newValue) {
ui.PlayUISFX(eSFX_Scroll);
m_current = newValue;
if (newValue < m_allPossibleLabels.size()) {
setLabel(m_allPossibleLabels[newValue]);
}
}
}
void UIControl_Slider::SetSliderTouchPos(float fTouchPos) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = fTouchPos;
IggyResult out = IggyPlayerCallMethodRS(
m_parentScene->getMovie(), &result, getIggyValuePath(),
m_funcSetRelativeSliderPos, 1, value);
}
S32 UIControl_Slider::GetRealWidth() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcGetRealWidth, 0, nullptr);
S32 iRealWidth = m_width;
if (result.type == IGGY_DATATYPE_number) {
iRealWidth = (S32)result.number;
}
return iRealWidth;
}
void UIControl_Slider::setAllPossibleLabels(int labelCount,
wchar_t labels[][256]) {
m_allPossibleLabels.clear();
for (unsigned int i = 0; i < labelCount; ++i) {
m_allPossibleLabels.push_back(labels[i]);
}
UIControl_Base::setAllPossibleLabels(labelCount, labels);
}
void UIControl_Slider::ReInit() {
UIControl_Base::ReInit();
init(m_label, m_id, m_min, m_max, m_current);
}

View File

@@ -0,0 +1,33 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Slider : public UIControl_Base {
private:
// int m_id; // 4J-TomK this is part of class UIControl and doesn't need to
// be here!
int m_min;
int m_max;
int m_current;
std::vector<std::wstring> m_allPossibleLabels;
// 4J-TomK - function for setting slider position on touch
IggyName m_funcSetRelativeSliderPos;
IggyName m_funcGetRealWidth;
public:
UIControl_Slider();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(UIString label, int id, int min, int max, int current);
void handleSliderMove(int newValue);
void SetSliderTouchPos(float fTouchPos);
virtual void setAllPossibleLabels(int labelCount, wchar_t labels[][256]);
S32 GetRealWidth();
virtual void ReInit();
};

View File

@@ -0,0 +1,94 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_SlotList.h"
UIControl_SlotList::UIControl_SlotList() { m_lastHighlighted = -1; }
bool UIControl_SlotList::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eSlotList);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// SlotList specific initialisers
m_addSlotFunc = registerFastName(L"addSlot");
m_setRedBoxFunc = registerFastName(L"SetSlotRedBox");
m_setHighlightFunc = registerFastName(L"SetSlotHighlight");
m_lastHighlighted = 0;
return success;
}
void UIControl_SlotList::ReInit() {
UIControl_Base::ReInit();
m_lastHighlighted = -1;
}
void UIControl_SlotList::addSlot(int id) {
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_number;
value[0].number = id;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = false;
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = false;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addSlotFunc, 3, value);
}
void UIControl_SlotList::addSlots(int iStartValue, int iCount) {
for (unsigned int i = iStartValue; i < iStartValue + iCount; ++i) {
addSlot(i);
}
}
void UIControl_SlotList::setHighlightSlot(int index) {
if (index != m_lastHighlighted) {
if (m_lastHighlighted != -1) {
setSlotHighlighted(m_lastHighlighted, false);
}
setSlotHighlighted(index, true);
m_lastHighlighted = index;
}
}
void UIControl_SlotList::setSlotHighlighted(int index, bool highlight) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = index;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = highlight;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_setHighlightFunc, 2, value);
}
void UIControl_SlotList::showSlotRedBox(int index, bool show) {
// app.DebugPrintf("Setting red box at index %d to %s\n", index,
// show?"on":"off");
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = index;
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = show;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_setRedBoxFunc, 2, value);
}
void UIControl_SlotList::setFocus(bool focus) {
if (m_lastHighlighted != -1) {
if (focus)
setSlotHighlighted(m_lastHighlighted, true);
else
setSlotHighlighted(m_lastHighlighted, false);
}
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_SlotList : public UIControl_Base {
private:
// IggyName m_addSlotFunc, m_getSlotFunc, m_setRedBoxFunc,
// m_setHighlightFunc;
IggyName m_addSlotFunc, m_setRedBoxFunc, m_setHighlightFunc;
int m_lastHighlighted;
public:
UIControl_SlotList();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
virtual void ReInit();
void addSlot(int id);
void addSlots(int iStartValue, int iCount);
void setHighlightSlot(int index);
void showSlotRedBox(int index, bool show);
virtual void setFocus(bool focus);
private:
void setSlotHighlighted(int index, bool highlight);
};

View File

@@ -0,0 +1,122 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_SpaceIndicatorBar.h"
UIControl_SpaceIndicatorBar::UIControl_SpaceIndicatorBar() {
m_min = 0;
m_max = 100;
m_currentSave = 0;
m_currentTotal = 0;
m_currentOffset = 0.0f;
}
bool UIControl_SpaceIndicatorBar::setupControl(UIScene* scene,
IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eProgress);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// Progress specific initialisers
m_setSaveSizeFunc = registerFastName(L"setSaveGameSize");
m_setTotalSizeFunc = registerFastName(L"setTotalSize");
m_setSaveGameOffsetFunc = registerFastName(L"setSaveGameOffset");
return success;
}
void UIControl_SpaceIndicatorBar::init(UIString label, int id, int64_t min,
int64_t max) {
m_label = label;
m_id = id;
m_min = min;
m_max = max;
const std::u16string convLabel = wstring_to_u16string(label.getString());
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 1, value);
}
void UIControl_SpaceIndicatorBar::ReInit() {
UIControl_Base::ReInit();
init(m_label, m_id, m_min, m_max);
setSaveSize(m_currentSave);
setTotalSize(m_currentTotal);
setSaveGameOffset(m_currentOffset);
}
void UIControl_SpaceIndicatorBar::reset() {
m_sizeAndOffsets.clear();
m_currentTotal = 0;
setTotalSize(0);
setSaveSize(0);
setSaveGameOffset(0.0f);
}
void UIControl_SpaceIndicatorBar::addSave(int64_t size) {
float startPercent = (float)((m_currentTotal - m_min)) / (m_max - m_min);
m_sizeAndOffsets.push_back(std::pair<int64_t, float>(size, startPercent));
m_currentTotal += size;
setTotalSize(m_currentTotal);
}
void UIControl_SpaceIndicatorBar::selectSave(int index) {
if (index >= 0 && index < m_sizeAndOffsets.size()) {
std::pair<int64_t, float> values = m_sizeAndOffsets[index];
setSaveSize(values.first);
setSaveGameOffset(values.second);
} else {
setSaveSize(0);
setSaveGameOffset(0);
}
}
void UIControl_SpaceIndicatorBar::setSaveSize(int64_t size) {
m_currentSave = size;
float percent = (float)((m_currentSave - m_min)) / (m_max - m_min);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = percent;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_setSaveSizeFunc, 1, value);
}
void UIControl_SpaceIndicatorBar::setTotalSize(int64_t size) {
float percent = (float)((m_currentTotal - m_min)) / (m_max - m_min);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = percent;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_setTotalSizeFunc, 1, value);
}
void UIControl_SpaceIndicatorBar::setSaveGameOffset(float offset) {
m_currentOffset = offset;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = m_currentOffset;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_setSaveGameOffsetFunc, 1, value);
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_SpaceIndicatorBar : public UIControl_Base {
private:
IggyName m_setSaveSizeFunc, m_setTotalSizeFunc, m_setSaveGameOffsetFunc;
int64_t m_min;
int64_t m_max;
int64_t m_currentSave, m_currentTotal;
float m_currentOffset;
std::vector<std::pair<int64_t, float> > m_sizeAndOffsets;
public:
UIControl_SpaceIndicatorBar();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(UIString label, int id, int64_t min, int64_t max);
virtual void ReInit();
void reset();
void addSave(int64_t size);
void selectSave(int index);
private:
void setSaveSize(int64_t size);
void setTotalSize(int64_t totalSize);
void setSaveGameOffset(float offset);
};

View File

@@ -0,0 +1,71 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_TextInput.h"
#include "../../../../../Minecraft.World/ConsoleHelpers/StringHelpers.h"
UIControl_TextInput::UIControl_TextInput() { m_bHasFocus = false; }
bool UIControl_TextInput::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eTextInput);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// TextInput specific initialisers
m_textName = registerFastName(L"text");
m_funcChangeState = registerFastName(L"ChangeState");
m_funcSetCharLimit = registerFastName(L"SetCharLimit");
return success;
}
void UIControl_TextInput::init(UIString label, int id) {
m_label = label;
m_id = id;
const std::u16string convLabel = wstring_to_u16string(label.getString());
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = id;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 2, value);
}
void UIControl_TextInput::ReInit() {
UIControl_Base::ReInit();
init(m_label, m_id);
}
void UIControl_TextInput::setFocus(bool focus) {
if (m_bHasFocus != focus) {
m_bHasFocus = focus;
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = focus ? 0 : 1;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(),
&result, getIggyValuePath(),
m_funcChangeState, 1, value);
}
}
void UIControl_TextInput::SetCharLimit(int iLimit) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iLimit;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcSetCharLimit, 1, value);
}

View File

@@ -0,0 +1,22 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_TextInput : public UIControl_Base {
private:
IggyName m_textName, m_funcChangeState, m_funcSetCharLimit;
bool m_bHasFocus;
public:
UIControl_TextInput();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(UIString label, int id);
void ReInit();
virtual void setFocus(bool focus);
void SetCharLimit(int iLimit);
};

View File

@@ -0,0 +1,141 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_TexturePackList.h"
UIControl_TexturePackList::UIControl_TexturePackList() {}
bool UIControl_TexturePackList::setupControl(UIScene* scene,
IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eTexturePackList);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
// SlotList specific initialisers
m_addPackFunc = registerFastName(L"addPack");
m_clearSlotsFunc = registerFastName(L"removeAllItems");
m_funcSelectSlot = registerFastName(L"SelectSlot");
m_funcEnableSelector = registerFastName(L"EnableSelector");
m_funcSetTouchFocus = registerFastName(L"SetTouchFocus");
m_funcCanTouchTrigger = registerFastName(L"CanTouchTrigger");
m_funcGetRealHeight = registerFastName(L"GetRealHeight");
return success;
}
void UIControl_TexturePackList::init(const std::wstring& label, int id) {
m_label = label;
m_id = id;
const std::u16string convLabel = wstring_to_u16string(label);
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = id;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 2, value);
}
void UIControl_TexturePackList::addPack(int id,
const std::wstring& textureName) {
const std::u16string convName = wstring_to_u16string(textureName);
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = id;
value[1].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = convName.c_str();
stringVal.length = convName.length();
value[1].string16 = stringVal;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addPackFunc, 2, value);
}
void UIControl_TexturePackList::selectSlot(int id) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = id;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_funcSelectSlot, 1, value);
}
void UIControl_TexturePackList::clearSlots() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_clearSlotsFunc, 0, nullptr);
}
void UIControl_TexturePackList::setEnabled(bool enable) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_boolean;
value[0].number = enable;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcEnableSelector, 1, value);
}
void UIControl_TexturePackList::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;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcSetTouchFocus, 3, value);
}
bool UIControl_TexturePackList::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;
IggyResult 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;
}
S32 UIControl_TexturePackList::GetRealHeight() {
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcGetRealHeight, 0, nullptr);
S32 iRealHeight = m_height;
if (result.type == IGGY_DATATYPE_number) {
iRealHeight = (S32)result.number;
}
return iRealHeight;
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_TexturePackList : public UIControl_Base {
private:
IggyName m_addPackFunc, m_funcSelectSlot, m_funcSetTouchFocus,
m_funcCanTouchTrigger, m_funcGetRealHeight, m_clearSlotsFunc;
IggyName m_funcEnableSelector;
public:
UIControl_TexturePackList();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(const std::wstring& label, int id);
void addPack(int id, const std::wstring& textureName);
void selectSlot(int id);
void clearSlots();
virtual void setEnabled(bool enable);
void SetTouchFocus(S32 iX, S32 iY, bool bRepeat);
bool CanTouchTrigger(S32 iX, S32 iY);
S32 GetRealHeight();
};

View File

@@ -0,0 +1,34 @@
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
#include "../UI.h"
#include "UIControl_Touch.h"
UIControl_Touch::UIControl_Touch() {}
bool UIControl_Touch::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eTouchControl);
bool success = UIControl_Base::setupControl(scene, parent, controlName);
return success;
}
void UIControl_Touch::init(int iId) {
m_id = iId;
#if !defined(__linux__)
switch (m_parentScene->GetParentLayer()->m_iLayer) {
case eUILayer_Error:
case eUILayer_Fullscreen:
case eUILayer_Scene:
case eUILayer_HUD:
ui.TouchBoxAdd(this, m_parentScene);
break;
}
#endif
}
void UIControl_Touch::ReInit() {
UIControl_Base::ReInit();
init(m_id);
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "UIControl_Base.h"
class UIControl_Touch : public UIControl_Base {
private:
public:
UIControl_Touch();
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName);
void init(int id);
virtual void ReInit();
};