Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
15 kB · 534 lines
C++
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535#include "stdafx.h"#include "UI.h"#include "UIComponent_Tooltips.h"
UIComponent_Tooltips::UIComponent_Tooltips(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer){ for(int i=0;i<XUSER_MAX_COUNT;i++) { for(int j=0;j<ACTION_MAX_MENU;j++) { m_overrideSFX[i][j]=false; } } // Setup all the Iggy references we need for this scene initialiseMovie();
#ifdef __PSVITA__ // initialise vita touch controls with ids for(unsigned int i = 0; i < ETouchInput_Count; ++i) { m_TouchController[i].init(i); }#endif
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) if(InputManager.IsCircleCrossSwapped()) { IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_boolean; value[0].boolval = true; IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetABSwap , 1 , value ); }#endif}
wstring UIComponent_Tooltips::getMoviePath(){ switch( m_parentLayer->getViewport() ) { case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: m_bSplitscreen = true; return L"ToolTipsSplit"; break; case C4JRender::VIEWPORT_TYPE_FULLSCREEN: default: m_bSplitscreen = false; return L"ToolTips"; break; }}
F64 UIComponent_Tooltips::getSafeZoneHalfWidth(){ float width = ui.getScreenWidth();
float safeWidth = 0.0f;
#ifndef __PSVITA__ // 85% safezone for tooltips in either SD mode if( !RenderManager.IsHiDef() ) { // 85% safezone safeWidth = m_movieWidth * (0.15f / 2); } else { // 90% safezone safeWidth = width * (0.1f / 2); }#endif return safeWidth;}
void UIComponent_Tooltips::updateSafeZone(){ // Distance from edge F64 safeTop = 0.0; F64 safeBottom = 0.0; F64 safeLeft = 0.0; F64 safeRight = 0.0;
switch( m_parentLayer->getViewport() ) { case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: safeTop = getSafeZoneHalfHeight(); safeLeft = getSafeZoneHalfWidth(); break; case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: safeBottom = getSafeZoneHalfHeight(); safeLeft = getSafeZoneHalfWidth(); break; case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: safeLeft = getSafeZoneHalfWidth(); safeBottom = getSafeZoneHalfHeight(); break; case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: safeRight = getSafeZoneHalfWidth(); safeBottom = getSafeZoneHalfHeight(); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: safeTop = getSafeZoneHalfHeight(); safeLeft = getSafeZoneHalfWidth(); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: safeTop = getSafeZoneHalfHeight(); safeRight = getSafeZoneHalfWidth(); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: safeBottom = getSafeZoneHalfHeight(); safeLeft = getSafeZoneHalfWidth(); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: safeBottom = getSafeZoneHalfHeight(); safeRight = getSafeZoneHalfWidth(); break; case C4JRender::VIEWPORT_TYPE_FULLSCREEN: default: safeTop = getSafeZoneHalfHeight(); safeBottom = getSafeZoneHalfHeight(); safeLeft = getSafeZoneHalfWidth(); safeRight = getSafeZoneHalfWidth(); break; } setSafeZone(safeTop, safeBottom, safeLeft, safeRight);}
void UIComponent_Tooltips::tick(){ UIScene::tick();
// set the opacity of the tooltip items unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity); float fVal;
if(ucAlpha<80) { // if we are in a menu, set the minimum opacity for tooltips to 15% if(ui.GetMenuDisplayed(m_iPad) && (ucAlpha<15)) { ucAlpha=15; }
// check if we have the timer running for the opacity unsigned int uiOpacityTimer=app.GetOpacityTimer(m_iPad); if(uiOpacityTimer!=0) { if(uiOpacityTimer<10) { float fStep=(80.0f-(float)ucAlpha)/10.0f; fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); } else { fVal=0.01f*80.0f; } } else { fVal=0.01f*(float)ucAlpha; } } else { // if we are in a menu, set the minimum opacity for tooltips to 15% if(ui.GetMenuDisplayed(m_iPad) && (ucAlpha<15)) { ucAlpha=15; } fVal=0.01f*(float)ucAlpha; } setOpacity(fVal);
bool layoutChanges = false; for (int i = 0; i < eToolTipNumButtons; i++) { if ( !ui.IsReloadingSkin() && m_tooltipValues[i].show && m_tooltipValues[i].label.needsUpdating() ) { layoutChanges = true; _SetTooltip(i, m_tooltipValues[i].label, m_tooltipValues[i].show, true); m_tooltipValues[i].label.setUpdated(); } } if (layoutChanges) _Relayout();}
void UIComponent_Tooltips::render(S32 width, S32 height, C4JRender::eViewportType viewport){ if((ProfileManager.GetLockedProfile()!=-1) && !ui.GetMenuDisplayed(m_iPad) && (app.GetGameSettings(m_iPad,eGameSetting_Tooltips)==0 || app.GetGameSettings(m_iPad,eGameSetting_DisplayHUD)==0)) { return; }
if(m_bSplitscreen) { S32 xPos = 0; S32 yPos = 0; switch( viewport ) { case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: yPos = (S32)(ui.getScreenHeight() / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: xPos = (S32)(ui.getScreenWidth() / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: xPos = (S32)(ui.getScreenWidth() / 2); yPos = (S32)(ui.getScreenHeight() / 2); break; } ui.setupRenderPosition(xPos, yPos);
S32 tileXStart = 0; S32 tileYStart = 0; S32 tileWidth = width; S32 tileHeight = height;
switch( viewport ) { case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: tileHeight = (S32)(ui.getScreenHeight()); break; case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: tileWidth = (S32)(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: tileWidth = (S32)(ui.getScreenWidth()); tileYStart = (S32)(m_movieHeight / 2); break; case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: tileYStart = (S32)(m_movieHeight / 2); break; }
IggyPlayerSetDisplaySize( getMovie(), m_movieWidth, m_movieHeight );
IggyPlayerDrawTilesStart ( getMovie() ); m_renderWidth = tileWidth; m_renderHeight = tileHeight; IggyPlayerDrawTile ( getMovie() , tileXStart , tileYStart , tileXStart + tileWidth , tileYStart + tileHeight , 0 ); IggyPlayerDrawTilesEnd ( getMovie() ); } else { UIScene::render(width, height, viewport); }}
void UIComponent_Tooltips::SetTooltipText( unsigned int tooltip, int iTextID ){ if( _SetTooltip(tooltip, iTextID) ) _Relayout();}
void UIComponent_Tooltips::SetEnableTooltips( bool bVal ){}
void UIComponent_Tooltips::ShowTooltip( unsigned int tooltip, bool show ){ if(show != m_tooltipValues[tooltip].show) { _SetTooltip(tooltip, L"", show); _Relayout(); }}
void UIComponent_Tooltips::SetTooltips( int iA, int iB, int iX, int iY , int iLT, int iRT, int iLB, int iRB, int iLS, int iRS, int iBack, bool forceUpdate){ bool needsRelayout = false; needsRelayout = _SetTooltip( eToolTipButtonA, iA ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonB, iB ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonX, iX ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonY, iY ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonLT, iLT ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonRT, iRT ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonLB, iLB ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonRB, iRB ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonLS, iLS ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonRS, iRS ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonRS, iRS ) || needsRelayout; needsRelayout = _SetTooltip( eToolTipButtonBack, iBack ) || needsRelayout; if (needsRelayout) _Relayout();}
void UIComponent_Tooltips::EnableTooltip( unsigned int tooltip, bool enable ){}
bool UIComponent_Tooltips::_SetTooltip(unsigned int iToolTip, int iTextID){ bool changed = false; if(iTextID != m_tooltipValues[iToolTip].iString || (iTextID > -1 && !m_tooltipValues[iToolTip].show)) { m_tooltipValues[iToolTip].iString = iTextID; changed = true; if(iTextID > -1) _SetTooltip(iToolTip, iTextID, true); else if(iTextID == -2) _SetTooltip(iToolTip, L"", true); else _SetTooltip(iToolTip, L"", false); } return changed;}
void UIComponent_Tooltips::_SetTooltip(unsigned int iToolTipId, UIString label, bool show, bool force){ if(!force && !show && !m_tooltipValues[iToolTipId].show) { return; } m_tooltipValues[iToolTipId].show = show; m_tooltipValues[iToolTipId].label = label;
IggyDataValue result; IggyDataValue value[3]; value[0].type = IGGY_DATATYPE_number; value[0].number = iToolTipId;
value[1].type = IGGY_DATATYPE_string_UTF16; IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str(); stringVal.length = label.length(); value[1].string16 = stringVal;
value[2].type = IGGY_DATATYPE_boolean; value[2].boolval = show; IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetTooltip , 3 , value );
//app.DebugPrintf("Actual tooltip update!\n");}
void UIComponent_Tooltips::_Relayout(){ IggyDataValue result; IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcUpdateLayout, 0 , NULL );
#ifdef __PSVITA__ // rebuild touchboxes ui.TouchBoxRebuild(this);#endif}
#ifdef __PSVITA__void UIComponent_Tooltips::handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased){ //app.DebugPrintf("ToolTip Touch ID = %i\n", iId); bool handled = false;
// 4J - TomK no tooltips no touch! if((!ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad())) && (app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_Tooltips) == 0)) return;
// perform action on release if(bReleased) { switch(iId) { case ETouchInput_Touch_A: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_X\n", iId); if(InputManager.IsCircleCrossSwapped()) InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_O); else InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_X); break; case ETouchInput_Touch_B: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_O\n", iId); if(InputManager.IsCircleCrossSwapped()) InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_X); else InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_O); break; case ETouchInput_Touch_X: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_SQUARE\n", iId); InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_SQUARE); break; case ETouchInput_Touch_Y: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_TRIANGLE\n", iId); InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_TRIANGLE); break; case ETouchInput_Touch_LT: /* not in use on vita */ app.DebugPrintf("ToolTip no action\n", iId); break; case ETouchInput_Touch_RightTrigger: app.DebugPrintf("ToolTip no action\n", iId); /* no action */ break; case ETouchInput_Touch_LeftBumper: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_L1\n", iId); InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_L1); break; case ETouchInput_Touch_RightBumper: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_R1\n", iId); InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_R1); break; case ETouchInput_Touch_LeftStick: app.DebugPrintf("ToolTip no action\n", iId); /* no action */ break; case ETouchInput_Touch_RightStick: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_DPAD_DOWN\n", iId); InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_DPAD_DOWN); break; case ETouchInput_Touch_Select: app.DebugPrintf("ToolTip Map Touch to _PSV_JOY_BUTTON_SELECT\n", iId); InputManager.MapTouchInput(iPad, _PSV_JOY_BUTTON_SELECT); break; } }}#endif
void UIComponent_Tooltips::handleReload(){ app.DebugPrintf("UIComponent_Tooltips::handleReload\n");
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) if(InputManager.IsCircleCrossSwapped()) { IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_boolean; value[0].boolval = true; IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetABSwap , 1 , value ); }#endif
for(unsigned int i = 0; i < eToolTipNumButtons; ++i) { _SetTooltip(i, m_tooltipValues[i].iString, m_tooltipValues[i].show, true); } _Relayout();}
void UIComponent_Tooltips::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled){ if( (0 <= iPad) && (iPad <= 3) && m_overrideSFX[iPad][key] ) { // don't play a sound for this action switch(key) { case ACTION_MENU_A: case ACTION_MENU_OK: case ACTION_MENU_PAGEUP: case ACTION_MENU_PAGEDOWN: case ACTION_MENU_X: case ACTION_MENU_Y: case ACTION_MENU_B: case ACTION_MENU_CANCEL: case ACTION_MENU_LEFT_SCROLL: case ACTION_MENU_RIGHT_SCROLL: case ACTION_MENU_LEFT: case ACTION_MENU_RIGHT: case ACTION_MENU_UP: case ACTION_MENU_DOWN: sendInputToMovie(key, repeat, pressed, released); break; } } else { switch(key) { case ACTION_MENU_OK: case ACTION_MENU_CANCEL: // 4J-PB - We get both A and OK, and B and Cancel, so only play a sound on one of them. sendInputToMovie(key, repeat, pressed, released); break; case ACTION_MENU_A: case ACTION_MENU_X: case ACTION_MENU_Y: // 4J-PB - play a Press sound //CD - Removed, causes a sound on all presses /*if(pressed) { ui.PlayUISFX(eSFX_Press); }*/ sendInputToMovie(key, repeat, pressed, released); break;
case ACTION_MENU_B: // 4J-PB - play a Press sound //CD - Removed, causes a sound on all presses /*if(pressed) { ui.PlayUISFX(eSFX_Back); }*/ sendInputToMovie(key, repeat, pressed, released); break;
case ACTION_MENU_LEFT_SCROLL: case ACTION_MENU_RIGHT_SCROLL: //CD - Removed, causes a sound on all presses /*if(pressed) { ui.PlayUISFX(eSFX_Scroll); }*/ sendInputToMovie(key, repeat, pressed, released); break; case ACTION_MENU_PAGEUP: case ACTION_MENU_PAGEDOWN: case ACTION_MENU_LEFT: case ACTION_MENU_RIGHT: case ACTION_MENU_UP: case ACTION_MENU_DOWN: sendInputToMovie(key, repeat, pressed, released); break; } }}
void UIComponent_Tooltips::overrideSFX(int iPad, int key, bool bVal){ m_overrideSFX[iPad][key]=bVal;}