the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 161 lines 4.4 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "UIScene_MessageBox.h" 4 5UIScene_MessageBox::UIScene_MessageBox(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) 6{ 7 // Setup all the Iggy references we need for this scene 8 initialiseMovie(); 9 10 MessageBoxInfo *param = (MessageBoxInfo *)initData; 11 12 m_buttonCount = param->uiOptionC; 13 14 IggyDataValue result; 15 IggyDataValue value[2]; 16 value[0].type = IGGY_DATATYPE_number; 17 value[0].number = param->uiOptionC; 18 19 value[1].type = IGGY_DATATYPE_number; 20 value[1].number = param->dwFocusButton; 21 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcInit , 2 , value ); 22 23 int buttonIndex = 0; 24 if(param->uiOptionC > 3) 25 { 26 m_buttonButtons[eControl_Button0].init(app.GetString(param->uiOptionA[buttonIndex]),buttonIndex); 27 ++buttonIndex; 28 } 29 if(param->uiOptionC > 2) 30 { 31 m_buttonButtons[eControl_Button1].init(app.GetString(param->uiOptionA[buttonIndex]),buttonIndex); 32 ++buttonIndex; 33 } 34 if(param->uiOptionC > 1) 35 { 36 m_buttonButtons[eControl_Button2].init(app.GetString(param->uiOptionA[buttonIndex]),buttonIndex); 37 ++buttonIndex; 38 } 39 m_buttonButtons[eControl_Button3].init(app.GetString(param->uiOptionA[buttonIndex]),buttonIndex); 40 41 m_labelTitle.init(app.GetString(param->uiTitle)); 42 m_labelContent.init(app.GetString(param->uiText)); 43 44 out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , NULL ); 45 46 m_Func = param->Func; 47 m_lpParam = param->lpParam; 48 49 parentLayer->addComponent(iPad,eUIComponent_MenuBackground); 50 51 // 4J-TomK - rebuild touch after auto resize 52#ifdef __PSVITA__ 53 ui.TouchBoxRebuild(this); 54#endif 55} 56 57UIScene_MessageBox::~UIScene_MessageBox() 58{ 59 m_parentLayer->removeComponent(eUIComponent_MenuBackground); 60} 61 62wstring UIScene_MessageBox::getMoviePath() 63{ 64 if(app.GetLocalPlayerCount() > 1 && !m_parentLayer->IsFullscreenGroup()) 65 { 66 return L"MessageBoxSplit"; 67 } 68 else 69 { 70 return L"MessageBox"; 71 } 72} 73 74void UIScene_MessageBox::updateTooltips() 75{ 76 ui.SetTooltips( m_parentLayer->IsFullscreenGroup()?XUSER_INDEX_ANY:m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_CANCEL); 77} 78 79void UIScene_MessageBox::handleReload() 80{ 81 IggyDataValue result; 82 IggyDataValue value[2]; 83 value[0].type = IGGY_DATATYPE_number; 84 value[0].number = m_buttonCount; 85 86 value[1].type = IGGY_DATATYPE_number; 87 value[1].number = (F64)getControlFocus(); 88 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcInit , 2 , value ); 89 90 out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAutoResize , 0 , NULL ); 91} 92 93void UIScene_MessageBox::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) 94{ 95 //app.DebugPrintf("UIScene_DebugOverlay handling input for pad %d, key %d, down- %s, pressed- %s, released- %s\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE"); 96 ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released); 97 switch(key) 98 { 99 case ACTION_MENU_CANCEL: 100 if(pressed) 101 { 102 navigateBack(); 103 if(m_Func) m_Func(m_lpParam, iPad, C4JStorage::EMessage_Cancelled); 104 } 105 break; 106 case ACTION_MENU_OK: 107#ifdef __ORBIS__ 108 case ACTION_MENU_TOUCHPAD_PRESS: 109#endif 110 sendInputToMovie(key, repeat, pressed, released); 111 break; 112 case ACTION_MENU_UP: 113 case ACTION_MENU_DOWN: 114 sendInputToMovie(key, repeat, pressed, released); 115 break; 116 } 117 handled = true; 118} 119 120void UIScene_MessageBox::handlePress(F64 controlId, F64 childId) 121{ 122 C4JStorage::EMessageResult result = C4JStorage::EMessage_Cancelled; 123 switch((int)controlId) 124 { 125 case 0: 126 result = C4JStorage::EMessage_ResultAccept; 127 break; 128 case 1: 129 result = C4JStorage::EMessage_ResultDecline; 130 break; 131 case 2: 132 result = C4JStorage::EMessage_ResultThirdOption; 133 break; 134 case 3: 135 result = C4JStorage::EMessage_ResultFourthOption; 136 break; 137 } 138 139 navigateBack(); 140 if(m_Func) m_Func(m_lpParam, m_iPad, result); 141} 142 143bool UIScene_MessageBox::hasFocus(int iPad) 144{ 145 // 4J-JEV: Fix for PS4 #5204 - [TRC][R4033] The application can be locked up by second user logging out of the system. 146 if (m_iPad == 255) 147 { 148 // Message box is for everyone 149 return bHasFocus; 150 } 151 else if (ProfileManager.IsSignedIn(m_iPad)) 152 { 153 // Owner is still present 154 return bHasFocus && (iPad == m_iPad); 155 } 156 else 157 { 158 // Original owner has left so let everyone interact 159 return bHasFocus; 160 } 161}