the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 84 lines 2.2 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "UIControl_Progress.h" 4 5UIControl_Progress::UIControl_Progress() 6{ 7 m_min = 0; 8 m_max = 100; 9 m_current = 0; 10 m_lastPercent = 0.0f; 11 m_showingBar = true; 12} 13 14bool UIControl_Progress::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName) 15{ 16 UIControl::setControlType(UIControl::eProgress); 17 bool success = UIControl_Base::setupControl(scene,parent,controlName); 18 19 //Progress specific initialisers 20 m_setProgressFunc = registerFastName(L"setProgress"); 21 m_showBarFunc = registerFastName(L"ShowBar"); 22 23 return success; 24} 25 26void UIControl_Progress::init(UIString label, int id, int min, int max, int current) 27{ 28 m_label = label; 29 m_id = id; 30 m_min = min; 31 m_max = max; 32 m_current = current; 33 34 IggyDataValue result; 35 IggyDataValue value[1]; 36 value[0].type = IGGY_DATATYPE_string_UTF16; 37 IggyStringUTF16 stringVal; 38 39 stringVal.string = (IggyUTF16*)label.c_str(); 40 stringVal.length = label.length(); 41 value[0].string16 = stringVal; 42 43 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 1 , value ); 44} 45 46void UIControl_Progress::ReInit() 47{ 48 UIControl_Base::ReInit(); 49 init(m_label, m_id, m_min, m_max, m_current); 50} 51 52void UIControl_Progress::setProgress(int current) 53{ 54 m_current = current; 55 56 float percent = (float)((m_current-m_min))/(m_max-m_min); 57 58 if(percent != m_lastPercent) 59 { 60 m_lastPercent = percent; 61 //app.DebugPrintf("Setting progress value to %d/%f\n", m_current, percent); 62 63 IggyDataValue result; 64 IggyDataValue value[1]; 65 value[0].type = IGGY_DATATYPE_number; 66 value[0].number = percent; 67 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setProgressFunc , 1 , value ); 68 } 69} 70 71void UIControl_Progress::showBar(bool show) 72{ 73 if(show != m_showingBar) 74 { 75 m_showingBar = show; 76 //app.DebugPrintf("Setting progress value to %d/%f\n", m_current, percent); 77 78 IggyDataValue result; 79 IggyDataValue value[1]; 80 value[0].type = IGGY_DATATYPE_boolean; 81 value[0].boolval = show; 82 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_showBarFunc , 1 , value ); 83 } 84}