the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 108 lines 3.0 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "UIControl.h" 4#include "..\..\..\Minecraft.World\StringHelpers.h" 5#include "..\..\..\Minecraft.World\JavaMath.h" 6 7UIControl_Base::UIControl_Base() 8{ 9 m_bLabelChanged = false; 10 m_label; 11 m_id = 0; 12} 13 14bool UIControl_Base::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName) 15{ 16 bool success = UIControl::setupControl(scene,parent,controlName); 17 18 m_setLabelFunc = registerFastName(L"SetLabel"); 19 m_initFunc = registerFastName(L"Init"); 20 m_funcGetLabel = registerFastName(L"GetLabel"); 21 m_funcCheckLabelWidths = registerFastName(L"CheckLabelWidths"); 22 23 return success; 24} 25 26void UIControl_Base::tick() 27{ 28 UIControl::tick(); 29 30 if ( m_label.needsUpdating() || m_bLabelChanged ) 31 { 32 //app.DebugPrintf("Calling SetLabel - '%ls'\n", m_label.c_str()); 33 m_bLabelChanged = false; 34 35 IggyDataValue result; 36 IggyDataValue value[1]; 37 value[0].type = IGGY_DATATYPE_string_UTF16; 38 IggyStringUTF16 stringVal; 39 40 stringVal.string = (IggyUTF16*) m_label.c_str(); 41 stringVal.length = m_label.length(); 42 value[0].string16 = stringVal; 43 44 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setLabelFunc , 1 , value ); 45 46 m_label.setUpdated(); 47 } 48} 49 50void UIControl_Base::setLabel(UIString label, bool instant, bool force) 51{ 52 if( force || ((!m_label.empty() || !label.empty()) && m_label.compare(label) != 0) ) m_bLabelChanged = true; 53 m_label = label; 54 55 if(m_bLabelChanged && instant) 56 { 57 m_bLabelChanged = false; 58 59 IggyDataValue result; 60 IggyDataValue value[1]; 61 value[0].type = IGGY_DATATYPE_string_UTF16; 62 IggyStringUTF16 stringVal; 63 64 stringVal.string = (IggyUTF16*)m_label.c_str(); 65 stringVal.length = m_label.length(); 66 value[0].string16 = stringVal; 67 68 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setLabelFunc , 1 , value ); 69 } 70} 71 72const wchar_t* UIControl_Base::getLabel() 73{ 74 IggyDataValue result; 75 IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcGetLabel, 0, NULL); 76 77 if(result.type == IGGY_DATATYPE_string_UTF16) 78 { 79 m_label = wstring((wchar_t *)result.string16.string, result.string16.length); 80 } 81 82 return m_label.c_str(); 83} 84 85void UIControl_Base::setAllPossibleLabels(int labelCount, wchar_t labels[][256]) 86{ 87 IggyDataValue result; 88 IggyDataValue *value = new IggyDataValue[labelCount]; 89 IggyStringUTF16 * stringVal = new IggyStringUTF16[labelCount]; 90 91 for(unsigned int i = 0; i < labelCount; ++i) 92 { 93 stringVal[i].string = (IggyUTF16 *)labels[i]; 94 stringVal[i].length = wcslen(labels[i]); 95 value[i].type = IGGY_DATATYPE_string_UTF16; 96 value[i].string16 = stringVal[i]; 97 } 98 99 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcCheckLabelWidths , labelCount , value ); 100 101 delete [] value; 102 delete [] stringVal; 103} 104 105bool UIControl_Base::hasFocus() 106{ 107 return m_parentScene->controlHasFocus( this ); 108}