From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp | 2243 ++++++++++++++++++++++++ 1 file changed, 2243 insertions(+) create mode 100644 Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp (limited to 'Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp') diff --git a/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp b/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp new file mode 100644 index 00000000..03782c79 --- /dev/null +++ b/Minecraft.Client/Common/XUI/XUI_Scene_Base.cpp @@ -0,0 +1,2243 @@ +#include "stdafx.h" + +#include +#include "..\..\MultiplayerLevel.h" +#include "..\..\MultiplayerLocalPlayer.h" +#include "..\..\StatsCounter.h" +#include "..\..\..\Minecraft.World\StringHelpers.h" +#include "..\..\..\Minecraft.World\net.minecraft.stats.h" +#include "..\..\Minecraft.h" + +#include "..\..\..\Minecraft.World\net.minecraft.world.level.h" +#include "..\..\..\Minecraft.World\LevelData.h" +#include "XUI_CustomMessages.h" +#include "..\..\..\Minecraft.World\Dimension.h" +#include "..\..\..\Minecraft.World\SharedConstants.h" +#include "..\..\GameMode.h" +#include "..\..\EnderDragonRenderer.h" +#include "..\..\..\Minecraft.World\net.minecraft.world.entity.boss.enderdragon.h" +#include "..\..\TexturePackRepository.h" +#include "..\..\TexturePack.h" +#include "..\..\DLCTexturePack.h" + +#define PRESS_START_TIMER 0 + +CXuiSceneBase *CXuiSceneBase::Instance = NULL; +DWORD CXuiSceneBase::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; +//---------------------------------------------------------------------------------- +// Performs initialization tasks - retrieves controls. +//---------------------------------------------------------------------------------- +HRESULT CXuiSceneBase::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) +{ + ASSERT( CXuiSceneBase::Instance == NULL ); + CXuiSceneBase::Instance = this; + + m_iWrongTexturePackTickC=20*5; // default 5 seconds before bringing up the upsell for not having the texture pack + MapChildControls(); + + // Display the tooltips + HRESULT hr = S_OK; + CXuiElement xuiElement = m_hObj; + HXUIOBJ hTemp; + + + m_hEmptyQuadrantLogo=NULL; + XuiElementGetChildById(m_hObj,L"EmptyQuadrantLogo",&m_hEmptyQuadrantLogo); + + D3DXVECTOR3 lastPos; + for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) + { + for( unsigned int i = 0; i < BUTTONS_TOOLTIP_MAX; ++i ) + { + m_visible[idx][ i ] = FALSE; + m_iCurrentTooltipTextID[idx][i]=-1; + hTooltipText[idx][i]=NULL; + hTooltipTextSmall[idx][i]=NULL; + // set all tooltips to shown FALSE by default + m_Buttons[idx][i].SetShow( FALSE ); + m_ButtonsSmall[idx][i].SetShow( FALSE ); + } + + XuiElementGetPosition( m_bottomLeftAnchorPoint[idx].m_hObj, &lastPos); + lastPos.y-=110; + + m_bCrouching[idx]=false; + m_uiSelectedItemOpacityCountDown[idx] =0; + m_bossHealthVisible[idx] = FALSE; + + switch(idx) + { + case 0: + XuiElementGetChildById(m_hObj,L"BasePlayer0",&hTemp); + XuiElementGetChildById(hTemp,L"XuiGamertag",&m_hGamerTagA[0]); + break; + case 1: + XuiElementGetChildById(m_hObj,L"BasePlayer1",&hTemp); + XuiElementGetChildById(hTemp,L"XuiGamertag",&m_hGamerTagA[1]); + break; + case 2: + XuiElementGetChildById(m_hObj,L"BasePlayer2",&hTemp); + XuiElementGetChildById(hTemp,L"XuiGamertag",&m_hGamerTagA[2]); + break; + case 3: + XuiElementGetChildById(m_hObj,L"BasePlayer3",&hTemp); + XuiElementGetChildById(hTemp,L"XuiGamertag",&m_hGamerTagA[3]); + break; + } + } + + m_ticksWithNoBoss = 0; + + UpdatePlayerBasePositions(); + + m_iQuadrantsMask=0; + + return S_OK; +} + +HRESULT CXuiSceneBase::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled) +{ + if(pData->nId==PRESS_START_TIMER) + { + XuiKillTimer(m_hObj,PRESS_START_TIMER); + XuiElementStopTimeline(m_hObj,TRUE); + m_PressStart.SetShow(FALSE); + + // clear the quadrants + m_iQuadrantsMask=0; + + HXUIOBJ hObj=NULL,hQuadrant; + + HRESULT hr=XuiControlGetVisual(m_PressStart.m_hObj,&hObj); + + for(int i=0;iskins->getSelected(); + + if(tPack->getId()!=app.GetRequiredTexturePackID()) + { + // we're not using the texture pack we need + + //Is it available? + TexturePack * pRequiredTPack=pMinecraft->skins->getTexturePackById(app.GetRequiredTexturePackID()); + if(pRequiredTPack!=NULL) + { + // we can switch to the required pack + // reset the timer + m_iWrongTexturePackTickC=20*60*5; // reset to 5 minutes + + pMinecraft->skins->selectTexturePackById(app.GetRequiredTexturePackID()); + + // probably had background downloads enabled, so turn them off + XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO); + } + else + { + // decrement the counter + m_iWrongTexturePackTickC--; + + if(m_iWrongTexturePackTickC==0) + { + // action + app.SetAction(ProfileManager.GetPrimaryPad(),eAppAction_TexturePackRequired); + + // reset the timer + m_iWrongTexturePackTickC=20*60*5; // reset to 5 minutes + } + } + } + } + + if (EnderDragonRenderer::bossInstance == NULL) + { + if(m_ticksWithNoBoss<=20) + { + ++m_ticksWithNoBoss; + } + } + else + { + shared_ptr boss = EnderDragonRenderer::bossInstance; + EnderDragonRenderer::bossInstance = nullptr; + m_ticksWithNoBoss = 0; + + for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) + { + if(pMinecraft->localplayers[i] != NULL && pMinecraft->localplayers[i]->dimension == 1 && !ui.GetMenuDisplayed(i) && app.GetGameSettings(i,eGameSetting_DisplayHUD)) + { + int iGuiScale; + + if(pMinecraft->localplayers[i]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN) + { + iGuiScale=app.GetGameSettings(i,eGameSetting_UISize); + } + else + { + iGuiScale=app.GetGameSettings(i,eGameSetting_UISizeSplitscreen); + } + m_BossHealthGroup[i].SetShow(TRUE); + m_BossHealthText[i].SetText( app.GetString( IDS_BOSS_ENDERDRAGON_HEALTH ) ); + + if(pMinecraft->localplayers[i]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN) + { + switch(iGuiScale) + { + case 0: + m_pBossHealthProgress = m_BossHealthProgress1; + m_BossHealthProgress1[i].SetShow(TRUE); + m_BossHealthProgress2[i].SetShow(FALSE); + m_BossHealthProgress3[i].SetShow(FALSE); + if(m_BossHealthProgress1_small[i]!=NULL) + { + m_BossHealthProgress1_small[i].SetShow(FALSE); + m_BossHealthProgress2_small[i].SetShow(FALSE); + m_BossHealthProgress3_small[i].SetShow(FALSE); + } + + + break; + case 1: + m_pBossHealthProgress = m_BossHealthProgress2; + m_BossHealthProgress1[i].SetShow(FALSE); + m_BossHealthProgress2[i].SetShow(TRUE); + m_BossHealthProgress3[i].SetShow(FALSE); + if(m_BossHealthProgress1_small[i]!=NULL) + { + m_BossHealthProgress1_small[i].SetShow(FALSE); + m_BossHealthProgress2_small[i].SetShow(FALSE); + m_BossHealthProgress3_small[i].SetShow(FALSE); + } + + break; + case 2: + m_pBossHealthProgress = m_BossHealthProgress3; + m_BossHealthProgress1[i].SetShow(FALSE); + m_BossHealthProgress2[i].SetShow(FALSE); + m_BossHealthProgress3[i].SetShow(TRUE); + if(m_BossHealthProgress1_small[i]!=NULL) + { + m_BossHealthProgress1_small[i].SetShow(FALSE); + m_BossHealthProgress2_small[i].SetShow(FALSE); + m_BossHealthProgress3_small[i].SetShow(FALSE); + } + + break; + } + } + else + { + // if we have 2 player top & bottom, we can use the fullscreen bar + if((pMinecraft->localplayers[i]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_SPLIT_TOP) || + (pMinecraft->localplayers[i]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM)) + { + switch(iGuiScale) + { + case 0: + m_pBossHealthProgress = m_BossHealthProgress1; + m_BossHealthProgress1[i].SetShow(TRUE); + m_BossHealthProgress2[i].SetShow(FALSE); + m_BossHealthProgress3[i].SetShow(FALSE); + if(m_BossHealthProgress1_small[i]!=NULL) + { + m_BossHealthProgress1_small[i].SetShow(FALSE); + m_BossHealthProgress2_small[i].SetShow(FALSE); + m_BossHealthProgress3_small[i].SetShow(FALSE); + } + + break; + case 1: + m_pBossHealthProgress = m_BossHealthProgress2; + m_BossHealthProgress1[i].SetShow(FALSE); + m_BossHealthProgress2[i].SetShow(TRUE); + m_BossHealthProgress3[i].SetShow(FALSE); + if(m_BossHealthProgress1_small[i]!=NULL) + { + m_BossHealthProgress1_small[i].SetShow(FALSE); + m_BossHealthProgress2_small[i].SetShow(FALSE); + m_BossHealthProgress3_small[i].SetShow(FALSE); + } + break; + case 2: + m_pBossHealthProgress = m_BossHealthProgress3; + m_BossHealthProgress1[i].SetShow(FALSE); + m_BossHealthProgress2[i].SetShow(FALSE); + m_BossHealthProgress3[i].SetShow(TRUE); + if(m_BossHealthProgress1_small[i]!=NULL) + { + m_BossHealthProgress1_small[i].SetShow(FALSE); + m_BossHealthProgress2_small[i].SetShow(FALSE); + m_BossHealthProgress3_small[i].SetShow(FALSE); + } + break; + } + } + else + { + // use the small versions + switch(iGuiScale) + { + case 0: + m_pBossHealthProgress = m_BossHealthProgress1_small; + m_BossHealthProgress1_small[i].SetShow(TRUE); + m_BossHealthProgress2_small[i].SetShow(FALSE); + m_BossHealthProgress3_small[i].SetShow(FALSE); + m_BossHealthProgress1[i].SetShow(FALSE); + m_BossHealthProgress2[i].SetShow(FALSE); + m_BossHealthProgress3[i].SetShow(FALSE); + + break; + case 1: + m_pBossHealthProgress = m_BossHealthProgress2_small; + m_BossHealthProgress1_small[i].SetShow(FALSE); + m_BossHealthProgress2_small[i].SetShow(TRUE); + m_BossHealthProgress3_small[i].SetShow(FALSE); + m_BossHealthProgress1[i].SetShow(FALSE); + m_BossHealthProgress2[i].SetShow(FALSE); + m_BossHealthProgress3[i].SetShow(FALSE); + break; + case 2: + m_pBossHealthProgress = m_BossHealthProgress3_small; + m_BossHealthProgress1_small[i].SetShow(FALSE); + m_BossHealthProgress2_small[i].SetShow(FALSE); + m_BossHealthProgress3_small[i].SetShow(TRUE); + m_BossHealthProgress1[i].SetShow(FALSE); + m_BossHealthProgress2[i].SetShow(FALSE); + m_BossHealthProgress3[i].SetShow(FALSE); + break; + } + } + } + + m_pBossHealthProgress[i].SetRange(0, boss->getMaxHealth() ); + m_pBossHealthProgress[i].SetValue( boss->getSynchedHealth() ); + m_bossHealthVisible[i] = TRUE; + + _UpdateSelectedItemPos(i); + } + else if( m_bossHealthVisible[i] == TRUE) + { + m_BossHealthGroup[i].SetShow(FALSE); + m_bossHealthVisible[i] = FALSE; + + _UpdateSelectedItemPos(i); + } + } + } + + for(int i=0;i 0) --m_uiSelectedItemOpacityCountDown[i]; + if( m_ticksWithNoBoss > 20 ) + { + m_BossHealthGroup[i].SetShow(FALSE); + m_bossHealthVisible[i] = FALSE; + + _UpdateSelectedItemPos(i); + } + + // check if we have the timer running for the opacity + unsigned int uiOpacityTimer=m_uiSelectedItemOpacityCountDown[i]; + + if(uiOpacityTimer>0 && !ui.GetMenuDisplayed(i) && app.GetGameStarted()) + { + if(uiOpacityTimer < (SharedConstants::TICKS_PER_SECOND * 1) ) + { + float fStep=(80.0f)/10.0f; + float fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); + + XuiElementSetOpacity(m_selectedItemA[i],fVal); + XuiElementSetOpacity(m_selectedItemSmallA[i],fVal); + } + + if( m_playerBaseScenePosition[i] == e_BaseScene_Fullscreen ) + { + m_selectedItemA[i].SetShow(TRUE); + m_selectedItemSmallA[i].SetShow(FALSE); + } + else + { + m_selectedItemA[i].SetShow(FALSE); + m_selectedItemSmallA[i].SetShow(TRUE); + } + } + else + { + m_selectedItemA[i].SetShow(FALSE); + m_selectedItemSmallA[i].SetShow(FALSE); + } + + 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(i) && (ucAlpha<15)) + { + ucAlpha=15; + } + + // check if we have the timer running for the opacity + unsigned int uiOpacityTimer=app.GetOpacityTimer(i); + 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(i) && (ucAlpha<15)) + { + ucAlpha=15; + } + fVal=0.01f*(float)ucAlpha; + } + XuiElementSetOpacity(app.GetCurrentHUDScene(i),fVal); + + XUIMessage xuiMsg; + CustomMessage_TickScene( &xuiMsg ); + XuiSendMessage( app.GetCurrentHUDScene(i), &xuiMsg ); + + bool bDisplayGui=app.GetGameStarted() && !ui.GetMenuDisplayed(i) && !(app.GetXuiAction(i)==eAppAction_AutosaveSaveGameCapturedThumbnail) && app.GetGameSettings(i,eGameSetting_DisplayHUD)!=0; + if(bDisplayGui && pMinecraft->localplayers[i] != NULL) + { + XuiElementSetShow(app.GetCurrentHUDScene(i),TRUE); + } + else + { + XuiElementSetShow(app.GetCurrentHUDScene(i),FALSE); + } + } +} + +HRESULT CXuiSceneBase::_SetEnableTooltips( unsigned int iPad, BOOL bVal ) +{ + for(int i=0;i=0) + { + pString=app.GetString(iTextID); + } + + if(hTooltipText[iPad][uiTooltip]==NULL) + { + HXUIOBJ hObj=NULL; + hr=XuiControlGetVisual(m_Buttons[iPad][uiTooltip].m_hObj,&hObj); + hr=XuiElementGetChildById(hObj,L"text_ButtonText",&hTooltipText[iPad][uiTooltip]); + hr=XuiElementGetPosition(hTooltipText[iPad][uiTooltip],&m_vPosTextInTooltip[uiTooltip]); + } + + if(hTooltipTextSmall[iPad][uiTooltip]==NULL) + { + HXUIOBJ hObj=NULL; + hr=XuiControlGetVisual(m_ButtonsSmall[iPad][uiTooltip].m_hObj,&hObj); + hr=XuiElementGetChildById(hObj,L"text_ButtonText",&hTooltipTextSmall[iPad][uiTooltip]); + hr=XuiElementGetPosition(hTooltipTextSmall[iPad][uiTooltip],&m_vPosTextInTooltipSmall[uiTooltip]); + } + + if(iTextID>=0) + { + hr=XuiTextPresenterMeasureText(hTooltipText[iPad][uiTooltip], pString, &xuiRect); + + // Change the size of the whole button to be the width of the measured text, plus the position the text element starts in the visual (which is the offset by the size of the button graphic) + XuiElementGetBounds(m_Buttons[iPad][uiTooltip].m_hObj,&fWidth, &fHeight); + XuiElementSetBounds(m_Buttons[iPad][uiTooltip].m_hObj,xuiRect.right+1+m_vPosTextInTooltip[uiTooltip].x,fHeight); + + // Change the width of the text element to be the width of the measured text + XuiElementGetBounds(hTooltipText[iPad][uiTooltip],&fWidth, &fHeight); + XuiElementSetBounds(hTooltipText[iPad][uiTooltip],xuiRect.right,fHeight); + + + hr=XuiTextPresenterMeasureText(hTooltipTextSmall[iPad][uiTooltip], pString, &xuiRectSmall); + + // Change the size of the whole button to be the width of the measured text, plus the position the text element starts in the visual (which is the offset by the size of the button graphic) + XuiElementGetBounds(m_ButtonsSmall[iPad][uiTooltip].m_hObj,&fWidth, &fHeight); + XuiElementSetBounds(m_ButtonsSmall[iPad][uiTooltip].m_hObj,xuiRectSmall.right+1+m_vPosTextInTooltipSmall[uiTooltip].x,fHeight); + + // Change the width of the text element to be the width of the measured text + XuiElementGetBounds(hTooltipTextSmall[iPad][uiTooltip],&fWidth, &fHeight); + XuiElementSetBounds(hTooltipTextSmall[iPad][uiTooltip],xuiRectSmall.right,fHeight); + + m_Buttons[iPad][uiTooltip].SetText(pString); + m_ButtonsSmall[iPad][uiTooltip].SetText(pString); + } + else + { + m_Buttons[iPad][uiTooltip].SetText(L""); + XuiElementGetBounds(m_Buttons[iPad][uiTooltip].m_hObj,&fWidth, &fHeight); + XuiElementSetBounds(m_Buttons[iPad][uiTooltip].m_hObj,m_vPosTextInTooltip[uiTooltip].x,fHeight); + + m_ButtonsSmall[iPad][uiTooltip].SetText(L""); + XuiElementGetBounds(m_ButtonsSmall[iPad][uiTooltip].m_hObj,&fWidth, &fHeight); + XuiElementSetBounds(m_ButtonsSmall[iPad][uiTooltip].m_hObj,m_vPosTextInTooltipSmall[uiTooltip].x,fHeight); + } + + m_iCurrentTooltipTextID[iPad][uiTooltip]=iTextID; + + ReLayout(iPad); + + return hr; +} + +HRESULT CXuiSceneBase::_RefreshTooltips( unsigned int iPad) +{ + // if the tooltip is showing, refresh it to update the opacity + for(int tooltip=0;tooltiplevel!=NULL) + { + __int64 i64TimeOfDay =0; + // are we in the Nether? - Leave the time as 0 if we are, so we show daylight + if(pMinecraft->level->dimension->id==0) + { + i64TimeOfDay = pMinecraft->level->getLevelData()->getTime() % 24000; + } + + if(i64TimeOfDay>14000) + { + hr=XuiElementSetShow(hNight,TRUE); + hr=XuiElementSetShow(hDay,FALSE); + } + else + { + hr=XuiElementSetShow(hNight,FALSE); + hr=XuiElementSetShow(hDay,TRUE); + } + } + else + { + hr=XuiElementSetShow(hNight,FALSE); + hr=XuiElementSetShow(hDay,TRUE); + } + } + hr=XuiElementSetShow(m_Background[iPad],bShow); + + return hr; +} + +HRESULT CXuiSceneBase::_ShowDarkOverlay( unsigned int iPad, BOOL bShow ) +{ + return XuiElementSetShow(m_DarkOverlay[iPad],bShow); +} + +HRESULT CXuiSceneBase::_ShowLogo( unsigned int iPad, BOOL bShow ) +{ + return XuiElementSetShow(m_Logo[iPad],bShow); +} + +HRESULT CXuiSceneBase::_ShowPressStart(unsigned int iPad) +{ + XUIRect xuiRect; + LPCWSTR pString=app.GetString(IDS_PRESS_START_TO_JOIN);; + float fWidth,fHeight,fWidthChange; + + XuiSetTimer( m_hObj,PRESS_START_TIMER,3000); + m_iQuadrantsMask|=1<m_dwTrialTimerLimitSecs) + { + dwTimeTicks=m_dwTrialTimerLimitSecs; + } + + dwTimeTicks=m_dwTrialTimerLimitSecs-dwTimeTicks; + +#ifndef _CONTENT_PACKAGE + if(true) +#else + // display the time - only if there's less than 3 minutes + if(dwTimeTicks<180) +#endif + { + int iMins=dwTimeTicks/60; + int iSeconds=dwTimeTicks%60; + swprintf( wcTime, 20, L"%d:%02d",iMins,iSeconds); + m_TrialTimer.SetText(wcTime); + } + else + { + m_TrialTimer.SetText(L""); + } + + // are we out of time? + if(dwTimeTicks==0) + { + // Trial over + app.SetAction(iPad,eAppAction_TrialOver); + } + + return S_OK; +} + +void CXuiSceneBase::_ReduceTrialTimerValue() +{ + DWORD dwTimeTicks=(int)app.getTrialTimer(); + + if(dwTimeTicks>m_dwTrialTimerLimitSecs) + { + dwTimeTicks=m_dwTrialTimerLimitSecs; + } + + m_dwTrialTimerLimitSecs-=dwTimeTicks; +} + +HRESULT CXuiSceneBase::_ShowTrialTimer(BOOL bVal) +{ + m_TrialTimer.SetShow(bVal); + return S_OK; +} + +bool CXuiSceneBase::_PressStartPlaying(unsigned int iPad) +{ + return m_iQuadrantsMask&(1<1280x720 + scale.x = 2.0f; scale.y = 1.5f; scale.z = 1.0f; + XuiElementSetScale(m_hObj, &scale); + + return S_OK; + } + + + if( position != e_BaseScene_Fullscreen ) + { + // Scale up the tooltips so we can read them + /* + scale.x = 0.75f; scale.y = 0.75f; scale.z = 1.0f; + XuiElementSetScale(m_TooltipGroup[iPad], &scale); + fTooltipHeight*=scale.y; + */ + fTooltipHeight = fTooltipHeightSmall; + + scale.x = 0.5f; scale.y = 0.5f; scale.z = 1.0f; + XuiElementSetScale(m_CrouchIcon[iPad], &scale); + XuiElementSetScale(m_Logo[iPad].m_hObj, &scale); + } + else + { + // if we are not in high def mode, then we need to scale the m_BasePlayerScene scene by 2 (we're using the 640x360 scenes) + scale.x = 1.0f; scale.y = 1.0f; scale.z = 1.0f; + XuiElementSetScale(m_BasePlayerScene[iPad], &scale ); + XuiElementSetScale(m_TooltipGroup[iPad], &scale); + XuiElementSetScale(m_CrouchIcon[iPad], &scale); + XuiElementSetScale(m_Logo[iPad].m_hObj, &scale); + } + + + // The move applies to the whole scene, so we'll need to move tooltips back in some cases + switch( position ) + { + // No position adjustment + case e_BaseScene_Fullscreen: + tooltipsPos.x=SAFEZONE_HALF_WIDTH; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT-SAFEZONE_HALF_HEIGHT-fTooltipHeight; + crouchIconPos.x=SAFEZONE_HALF_WIDTH; + crouchIconPos.y=SAFEZONE_HALF_HEIGHT; + fBackWidth=XUI_BASE_SCENE_WIDTH; + fBackHeight=XUI_BASE_SCENE_HEIGHT; + + XuiElementGetPosition(m_selectedItemA[iPad], &vBossHealthPos); + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_HALF-(fBossHealthWidth/2); + vBossHealthPos.y = SAFEZONE_HALF_HEIGHT; + break; + case e_BaseScene_Top_Left: + tooltipsPos.x=SAFEZONE_HALF_WIDTH; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT_HALF-fTooltipHeight; + crouchIconPos.x=SAFEZONE_HALF_WIDTH; + crouchIconPos.y=SAFEZONE_HALF_HEIGHT; + fBackWidth=XUI_BASE_SCENE_WIDTH_HALF; + fBackHeight=XUI_BASE_SCENE_HEIGHT_HALF; + vGamertagPos.x=XUI_BASE_SCENE_WIDTH_HALF-fGamertagWidth - 10.0f; + vGamertagPos.y=SAFEZONE_HALF_HEIGHT; + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_QUARTER-(fBossHealthWidth/2); + vBossHealthPos.y = SAFEZONE_HALF_HEIGHT; + break; + case e_BaseScene_Top: // Top & Bottom - indent by a quarter screen + pos.x += XUI_BASE_SCENE_WIDTH_QUARTER; + tooltipsPos.x=SAFEZONE_HALF_WIDTH - XUI_BASE_SCENE_WIDTH_QUARTER; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT_HALF-fTooltipHeight; + crouchIconPos.x=SAFEZONE_HALF_WIDTH-XUI_BASE_SCENE_WIDTH_QUARTER; + crouchIconPos.y=SAFEZONE_HALF_HEIGHT; + fBackHeight=XUI_BASE_SCENE_HEIGHT_HALF; + fBackWidth=XUI_BASE_SCENE_WIDTH; + vBackPos.x=-XUI_BASE_SCENE_WIDTH_QUARTER; + vBackPos.y=0.0f; + vGamertagPos.x=XUI_BASE_SCENE_WIDTH - XUI_BASE_SCENE_WIDTH_QUARTER - fGamertagWidth - SAFEZONE_HALF_WIDTH; + vGamertagPos.y=SAFEZONE_HALF_HEIGHT; + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_QUARTER-(fBossHealthWidth/2); + vBossHealthPos.y = SAFEZONE_HALF_HEIGHT; + break; + case e_BaseScene_Bottom: + pos.x += XUI_BASE_SCENE_WIDTH_QUARTER; + pos.y += XUI_BASE_SCENE_HEIGHT_HALF; + tooltipsPos.x=SAFEZONE_HALF_WIDTH - XUI_BASE_SCENE_WIDTH_QUARTER; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT_HALF-SAFEZONE_HALF_HEIGHT-fTooltipHeight; + crouchIconPos.x=SAFEZONE_HALF_WIDTH-XUI_BASE_SCENE_WIDTH_QUARTER; + crouchIconPos.y=0.0f; + fBackHeight=XUI_BASE_SCENE_HEIGHT_HALF; + fBackWidth=XUI_BASE_SCENE_WIDTH; + vBackPos.x=-XUI_BASE_SCENE_WIDTH_QUARTER; + vBackPos.y=0.0f; + vGamertagPos.x=XUI_BASE_SCENE_WIDTH - XUI_BASE_SCENE_WIDTH_QUARTER - fGamertagWidth - SAFEZONE_HALF_WIDTH; + vGamertagPos.y=0.0f; + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_QUARTER-(fBossHealthWidth/2); + vBossHealthPos.y = 0.0f; + break; + case e_BaseScene_Bottom_Left: + pos.y += XUI_BASE_SCENE_HEIGHT_HALF; + tooltipsPos.x=SAFEZONE_HALF_WIDTH; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT_HALF-SAFEZONE_HALF_HEIGHT-fTooltipHeight; + crouchIconPos.x=SAFEZONE_HALF_WIDTH; + crouchIconPos.y=0.0f; + fBackWidth=XUI_BASE_SCENE_WIDTH_HALF; + fBackHeight=XUI_BASE_SCENE_HEIGHT_HALF; + vGamertagPos.x=XUI_BASE_SCENE_WIDTH_HALF-fGamertagWidth- 10.0f; + vGamertagPos.y=0.0f; + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_QUARTER-(fBossHealthWidth/2); + vBossHealthPos.y = 0.0f; + break; + case e_BaseScene_Bottom_Right: + pos.x += XUI_BASE_SCENE_WIDTH_HALF; + pos.y += XUI_BASE_SCENE_HEIGHT_HALF; + tooltipsPos.x=0.0f; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT_HALF-SAFEZONE_HALF_HEIGHT-fTooltipHeight; + crouchIconPos.x=0.0f; + crouchIconPos.y=0.0f; + fBackWidth=XUI_BASE_SCENE_WIDTH_HALF; + fBackHeight=XUI_BASE_SCENE_HEIGHT_HALF; + vGamertagPos.x=XUI_BASE_SCENE_WIDTH_HALF-fGamertagWidth-SAFEZONE_HALF_WIDTH; + vGamertagPos.y=0.0f; + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_QUARTER-(fBossHealthWidth/2); + vBossHealthPos.y = 0.0f; + break; + case e_BaseScene_Left: + pos.y += XUI_BASE_SCENE_HEIGHT_QUARTER; + tooltipsPos.x=SAFEZONE_HALF_WIDTH; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT_HALF+XUI_BASE_SCENE_HEIGHT_QUARTER-SAFEZONE_HALF_HEIGHT-fTooltipHeight; + crouchIconPos.x=SAFEZONE_HALF_WIDTH; + crouchIconPos.y=SAFEZONE_HALF_HEIGHT; + fBackWidth=XUI_BASE_SCENE_WIDTH_HALF; + fBackHeight=XUI_BASE_SCENE_HEIGHT; + vBackPos.x=0.0f; + vBackPos.y=-XUI_BASE_SCENE_HEIGHT_QUARTER; + vGamertagPos.x=XUI_BASE_SCENE_WIDTH_HALF-fGamertagWidth- 10.0f; + vGamertagPos.y=SAFEZONE_HALF_HEIGHT - XUI_BASE_SCENE_HEIGHT_QUARTER; + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_QUARTER-(fBossHealthWidth/2); + vBossHealthPos.y = SAFEZONE_HALF_HEIGHT-XUI_BASE_SCENE_HEIGHT_QUARTER; + break; + case e_BaseScene_Right: + pos.x += XUI_BASE_SCENE_WIDTH_HALF; + pos.y += XUI_BASE_SCENE_HEIGHT_QUARTER; + tooltipsPos.x=0.0f; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT_HALF+XUI_BASE_SCENE_HEIGHT_QUARTER-SAFEZONE_HALF_HEIGHT-fTooltipHeight; + crouchIconPos.x=0.0f; + crouchIconPos.y=SAFEZONE_HALF_HEIGHT; + fBackWidth=XUI_BASE_SCENE_WIDTH_HALF; + fBackHeight=XUI_BASE_SCENE_HEIGHT; + vBackPos.x=0.0f; + vBackPos.y=-XUI_BASE_SCENE_HEIGHT_QUARTER; + vGamertagPos.x=XUI_BASE_SCENE_WIDTH_HALF-fGamertagWidth-SAFEZONE_HALF_WIDTH; + vGamertagPos.y=SAFEZONE_HALF_HEIGHT - XUI_BASE_SCENE_HEIGHT_QUARTER; + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_QUARTER-(fBossHealthWidth/2); + vBossHealthPos.y = SAFEZONE_HALF_HEIGHT-XUI_BASE_SCENE_HEIGHT_QUARTER; + break; + case e_BaseScene_Top_Right: + pos.x += XUI_BASE_SCENE_WIDTH_HALF; + tooltipsPos.x=0.0f; + tooltipsPos.y=XUI_BASE_SCENE_HEIGHT_HALF-fTooltipHeight; + crouchIconPos.x=0.0f; + crouchIconPos.y=SAFEZONE_HALF_HEIGHT; + fBackWidth=XUI_BASE_SCENE_WIDTH_HALF; + fBackHeight=XUI_BASE_SCENE_HEIGHT_HALF; + vGamertagPos.x=XUI_BASE_SCENE_WIDTH_HALF-fGamertagWidth-SAFEZONE_HALF_WIDTH; + vGamertagPos.y=SAFEZONE_HALF_HEIGHT; + vBossHealthPos.x = XUI_BASE_SCENE_WIDTH_QUARTER-(fBossHealthWidth/2); + vBossHealthPos.y = SAFEZONE_HALF_HEIGHT; + break; + } + + XuiElementSetPosition(m_BasePlayerScene[iPad], &pos ); + XuiElementSetPosition( m_TooltipGroup[iPad].m_hObj, &tooltipsPos); + XuiElementSetPosition( m_TooltipGroupSmall[iPad].m_hObj, &tooltipsPos); + XuiElementSetPosition( m_CrouchIcon[iPad].m_hObj, &crouchIconPos); + XuiElementSetPosition( m_DarkOverlay[iPad].m_hObj, &vBackPos ); + XuiElementSetBounds( m_DarkOverlay[iPad].m_hObj, fBackWidth, fBackHeight); + XuiElementSetPosition( m_Background[iPad].m_hObj, &vBackPos ); + XuiElementSetBounds( m_Background[iPad].m_hObj, fBackWidth, fBackHeight ); + vGamertagPos.z=0.0f; + XuiElementSetPosition( m_hGamerTagA[iPad], &vGamertagPos ); + XuiElementSetPosition( m_BossHealthGroup[iPad], &vBossHealthPos ); + + + // 4J Stu - If we already have some scenes open, then call this to update their positions + // Fix for #10960 - All Lang: UI: Split-screen: Changing split screen mode (vertical/horizontal) make window layout strange + if(Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->localplayers[iPad]!=NULL) + { + // 4J-PB - Can only do this once we know what the player's UI settings are, so we need to have the player game settings read + _UpdateSelectedItemPos(iPad); + XUIMessage xuiMsg; + CustomMessage_Splitscreenplayer_Struct myMsgData; + CustomMessage_Splitscreenplayer( &xuiMsg, &myMsgData, false); + XuiBroadcastMessage( GetPlayerBaseScene(iPad), &xuiMsg ); + } + // tell the xui scenes that the base position has changed + XUIMessage xuiMsg; + CustomMessage_BasePositionChanged( &xuiMsg ); + XuiBroadcastMessage( GetPlayerBaseScene(iPad), &xuiMsg ); + + return S_OK; +} + +// The function uses the game mode to decide the offsets for the select item. It needs to be called after the game has loaded. +void CXuiSceneBase::_UpdateSelectedItemPos(unsigned int iPad) +{ + D3DXVECTOR3 selectedItemPos; + selectedItemPos.x = selectedItemPos.y = selectedItemPos.z = 0.0f; + float fSelectedItemWidth, fSelectedItemHeight; + XuiElementGetBounds(m_selectedItemSmallA[iPad],&fSelectedItemWidth, &fSelectedItemHeight); + + float yOffset = 0.0f; + + if( m_bossHealthVisible[iPad] == TRUE ) + { + float tempWidth; + XuiElementGetBounds(m_BossHealthGroup[iPad],&tempWidth, &yOffset); + } + + + // Only adjust if fullscreen for now, leaving code to move others if required, but it's too far up the screen when on the bottom quadrants + if( (m_playerBaseScenePosition[iPad] == e_BaseScene_Fullscreen) && + (RenderManager.IsHiDef() || RenderManager.IsWidescreen()) ) + { + D3DXVECTOR3 selectedItemPos; + selectedItemPos.z=0.0f; + float scale, fTempWidth, fTooltipHeight, fTooltipHeightSmall, fSelectedItemWidth, fSelectedItemHeight, fSelectedItemSmallWidth, fSelectedItemSmallHeight; + XuiElementGetBounds(m_TooltipGroup[iPad].m_hObj,&fTempWidth, &fTooltipHeight); + XuiElementGetBounds(m_TooltipGroupSmall[iPad].m_hObj,&fTempWidth, &fTooltipHeightSmall); + XuiElementGetBounds(m_selectedItemA[iPad],&fSelectedItemWidth, &fSelectedItemHeight); + XuiElementGetBounds(m_selectedItemSmallA[iPad],&fSelectedItemSmallWidth, &fSelectedItemSmallHeight); + if( m_playerBaseScenePosition[iPad] != e_BaseScene_Fullscreen ) + { + fTooltipHeight = fTooltipHeightSmall; + fSelectedItemHeight = fSelectedItemSmallHeight; + + scale = 0.5f; + } + else + { + // if we are not in high def mode, then we need to scale the m_BasePlayerScene scene by 2 (we're using the 640x360 scenes) + scale = 1.0f; + } + + // The move applies to the whole scene, so we'll need to move tooltips back in some cases + + selectedItemPos.y=XUI_BASE_SCENE_HEIGHT-SAFEZONE_HALF_HEIGHT-fTooltipHeight - fSelectedItemHeight; + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_HALF - (fSelectedItemWidth/2.0f); + + // Adjust selectedItemPos based on what gui is displayed + + + // 4J-PB - selected the gui scale based on the slider settings, and on whether we're in Creative or Survival + float fYOffset=0.0f; + + unsigned char ucGuiScale=app.GetGameSettings(iPad,eGameSetting_UISize) + 2; + + if(Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->localgameModes[iPad] != NULL && Minecraft::GetInstance()->localgameModes[iPad]->canHurtPlayer()) + { + // SURVIVAL MODE - Move up further because of hearts, shield and xp + switch(ucGuiScale) + { + case 3: + fYOffset = -130.0f; + break; + case 4: + fYOffset = -168.0f; + break; + default: // 2 + fYOffset = -94.0f; + break; + } + } + else + { + switch(ucGuiScale) + { + case 3: + fYOffset = -83.0f; + break; + case 4: + fYOffset = -114.0f; + break; + default: // 2 + fYOffset = -58.0f; + break; + } + } + + + selectedItemPos.y+=fYOffset - 40.0f; // 40 for the XP display + + XuiElementSetPosition( m_selectedItemA[iPad].m_hObj, &selectedItemPos ); + + //XuiElementSetPosition( m_selectedItemSmallA[iPad].m_hObj, &selectedItemPos ); + } + else + { + // The move applies to the whole scene, so we'll need to move tooltips back in some cases + switch( m_playerBaseScenePosition[iPad] ) + { + case e_BaseScene_Fullscreen: + // 480 non-widescreen + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = SAFEZONE_HALF_HEIGHT + yOffset; + break; + case e_BaseScene_Top_Left: + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = SAFEZONE_HALF_HEIGHT + yOffset; + break; + case e_BaseScene_Top: // Top & Bottom - indent by a quarter screen + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = SAFEZONE_HALF_HEIGHT + yOffset; + break; + case e_BaseScene_Bottom: + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = 0.0f + yOffset; + break; + case e_BaseScene_Bottom_Left: + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = 0.0f + yOffset; + break; + case e_BaseScene_Bottom_Right: + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = 0.0f + yOffset; + break; + case e_BaseScene_Left: + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = XUI_BASE_SCENE_HEIGHT_HALF;// + yOffset; - don't need the offset for the boss health since we're displaying the item at the bottom of the screen, not the top + break; + case e_BaseScene_Right: + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = XUI_BASE_SCENE_HEIGHT_HALF;// + yOffset; - don't need the offset for the boss health since we're displaying the item at the bottom of the screen, not the top + break; + case e_BaseScene_Top_Right: + selectedItemPos.x = XUI_BASE_SCENE_WIDTH_QUARTER - (fSelectedItemWidth/2.0f); + selectedItemPos.y = SAFEZONE_HALF_HEIGHT + yOffset; + break; + } + + // 4J-PB - If it's in split screen vertical, adjust the position + // Adjust selectedItemPos based on what gui is displayed + if((m_playerBaseScenePosition[iPad]==e_BaseScene_Left) || (m_playerBaseScenePosition[iPad]==e_BaseScene_Right)) + { + float scale=0.5f; + selectedItemPos.y -= (scale * 88.0f); + if(Minecraft::GetInstance() != NULL && Minecraft::GetInstance()->localgameModes[iPad] != NULL && Minecraft::GetInstance()->localgameModes[iPad]->canHurtPlayer()) + { + selectedItemPos.y -= (scale * 80.0f); + } + + // 4J-PB - selected the gui scale based on the slider settings + unsigned char ucGuiScale; + float fYOffset=0.0f; + if(m_playerBaseScenePosition[iPad]==e_BaseScene_Fullscreen) + { + ucGuiScale=app.GetGameSettings(iPad,eGameSetting_UISize) + 2; + } + else + { + ucGuiScale=app.GetGameSettings(iPad,eGameSetting_UISizeSplitscreen) + 2; + } + switch(ucGuiScale) + { + case 3: + fYOffset = 55.0f; + break; + case 4: + fYOffset = 45.0f; + break; + default: // 2 + fYOffset = 85.0f; + break; + } + selectedItemPos.y+=fYOffset; + } + + XuiElementSetPosition( m_selectedItemSmallA[iPad].m_hObj, &selectedItemPos ); + XuiElementSetPosition( m_selectedItemA[iPad].m_hObj, &selectedItemPos ); + } +} + +CXuiSceneBase::EBaseScenePosition CXuiSceneBase::_GetPlayerBasePosition(int iPad) +{ + return m_playerBaseScenePosition[iPad]; +} + +void CXuiSceneBase::_SetEmptyQuadrantLogo(int iPad,EBaseScenePosition ePos) +{ + if(m_hEmptyQuadrantLogo!=NULL) + { + for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) + { + if(m_playerBaseScenePosition[i] == e_BaseScene_Fullscreen) + { + // Someone is fullscreen, so don't show this + XuiElementSetShow(m_hEmptyQuadrantLogo,FALSE); + return; + } + } + + D3DXVECTOR3 pos; + + // get the bounds of the logo + + pos.z=0.0f; + switch( ePos ) + { + case e_BaseScene_Top_Left: + pos.x=64.0f; + pos.y=36.0f; + break; + case e_BaseScene_Top_Right: + pos.x=640.0+64.0f; + pos.y=36.0f; + break; + case e_BaseScene_Bottom_Left: + pos.x=64.0f; + pos.y=360.0f+36.0f; + break; + case e_BaseScene_Bottom_Right: + pos.x=640.0+64.0f; + pos.y=360.0f+36.0f; + break; + } + + // set the opacity of the logo + if(ProfileManager.GetLockedProfile()!=-1) + { + unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity); + XuiElementSetOpacity(m_hEmptyQuadrantLogo,0.01f*(float)ucAlpha); + } + + XuiElementSetPosition(m_hEmptyQuadrantLogo, &pos ); + XuiElementSetShow(m_hEmptyQuadrantLogo,TRUE); + } +} + + +HRESULT CXuiSceneBase::_PlayUISFX(ESoundEffect eSound) +{ + HRESULT hr; + bool bUsingTexturepackWithAudio=false; + + // are we using a mash-up pack? + if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) + { + TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected(); + if(tPack->hasAudio()) + { + bUsingTexturepackWithAudio=true; + } + } + + /*if(bUsingTexturepackWithAudio) + { + switch(eSound) + { + case eSFX_Back: + hr=XuiSoundPlay(m_SFXA[eSFX_Craft]); + break; + case eSFX_Craft: + hr=XuiSoundPlay(m_SFXA[eSFX_Craft]); + break; + case eSFX_CraftFail: + hr=XuiSoundPlay(m_SFXA[eSFX_Craft]); + break; + case eSFX_Focus: + hr=XuiSoundPlay(m_SFXA[eSFX_Craft]); + break; + case eSFX_Press: + hr=XuiSoundPlay(m_SFXA[eSFX_Craft]); + break; + case eSFX_Scroll: + hr=XuiSoundPlay(m_SFXA[eSFX_Craft]); + break; + default: + hr=S_OK; + break; + } + } + else*/ + { + + switch(eSound) + { + case eSFX_Back: + hr=XuiSoundPlay(m_SFXA[eSFX_Back]); + break; + case eSFX_Craft: + hr=XuiSoundPlay(m_SFXA[eSFX_Craft]); + break; + case eSFX_CraftFail: + hr=XuiSoundPlay(m_SFXA[eSFX_CraftFail]); + break; + case eSFX_Focus: + hr=XuiSoundPlay(m_SFXA[eSFX_Focus]); + break; + case eSFX_Press: + hr=XuiSoundPlay(m_SFXA[eSFX_Press]); + break; + case eSFX_Scroll: + hr=XuiSoundPlay(m_SFXA[eSFX_Scroll]); + break; + default: + hr=S_OK; + break; + } + } + return hr; +} + + +HRESULT CXuiSceneBase::_DisplayGamertag( unsigned int iPad, BOOL bDisplay ) +{ + + if(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask()&(1L<localplayers[iPad]!=NULL) + { + wstring wsGamertag = convStringToWstring( ProfileManager.GetGamertag(iPad)); + XuiControlSetText(m_hGamerTagA[iPad],wsGamertag.c_str()); + + } + else + { + XuiControlSetText(m_hGamerTagA[iPad],L""); + } + } + } + // The host decides whether these are on or off + if(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags)!=0) + { + XuiElementSetShow(m_hGamerTagA[iPad],bDisplay); + + // set the opacity of the gamertag + if((bDisplay==TRUE) &&(ProfileManager.GetLockedProfile()!=-1)) + { + unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity); + float fVal; + + if(ucAlpha<80) + { + // check if we have the timer running for the opacity + unsigned int uiOpacityTimer=app.GetOpacityTimer(ProfileManager.GetPrimaryPad()); + 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 + { + fVal=0.01f*(float)ucAlpha; + } + XuiElementSetOpacity(m_hGamerTagA[iPad],0.01f*fVal); + } + } + else + { + XuiElementSetShow(m_hGamerTagA[iPad],FALSE); + } + + return S_OK; +} + +void CXuiSceneBase::_SetSelectedItem( unsigned int iPad, const wstring& name) +{ + if(app.GetGameSettings(eGameSetting_Hints) == 0 || name.empty()) + { + m_selectedItemA[iPad].SetShow(FALSE); + m_selectedItemSmallA[iPad].SetShow(FALSE); + } + else + { + m_uiSelectedItemOpacityCountDown[iPad] = SharedConstants::TICKS_PER_SECOND * 3; + if(m_playerBaseScenePosition[iPad] == e_BaseScene_Fullscreen) + { + m_selectedItemSmallA[iPad].SetShow(FALSE); + m_selectedItemA[iPad].SetShow(TRUE); + m_selectedItemA[iPad].SetText(name.c_str()); + +// D3DXVECTOR3 vPos; +// XuiElementGetPosition( m_selectedItemA[iPad].m_hObj, &vPos ); +// XuiElementSetPosition( m_selectedItemA[iPad].m_hObj, &vPos ); + + float fVal=0.8f;//0.01f*(float)80; + XuiElementSetOpacity(m_selectedItemA[iPad].m_hObj,fVal); + } + else + { + m_selectedItemA[iPad].SetShow(FALSE); + m_selectedItemSmallA[iPad].SetShow(TRUE); + m_selectedItemSmallA[iPad].SetText(name.c_str()); + +// D3DXVECTOR3 vPos; +// XuiElementGetPosition( m_selectedItemSmallA[iPad].m_hObj, &vPos ); +// XuiElementSetPosition( m_selectedItemSmallA[iPad].m_hObj, &vPos ); + + float fVal=0.8f;//0.01f*(float)80; + XuiElementSetOpacity(m_selectedItemSmallA[iPad].m_hObj,fVal); + } + } +} + +void CXuiSceneBase::_HideAllGameUIElements() +{ + for(int i=0;i0 && lastVisible!=-1 ) + { + float width, height; + XuiElementGetBounds(m_Buttons[iPad][lastVisible].m_hObj, &width, &height); + + // 4J Stu - This is for horizontal layout, will need changed if we do vertical layout + lastPos.x += width + m_iTooltipSpacingGap; + + XuiElementGetBounds(m_ButtonsSmall[iPad][lastVisible].m_hObj, &width, &height); + // 4J Stu - This is for horizontal layout, will need changed if we do vertical layout + lastPosSmall.x += width + m_iTooltipSpacingGapSmall; + } + XuiElementSetPosition( m_Buttons[iPad][i].m_hObj, &lastPos); + XuiElementSetPosition( m_ButtonsSmall[iPad][i].m_hObj, &lastPosSmall); + + lastVisible = i; + } + } +} + +void CXuiSceneBase::TickAllBaseScenes() +{ + if( CXuiSceneBase::Instance != NULL ) + { + CXuiSceneBase::Instance->_TickAllBaseScenes(); + } +} + +HRESULT CXuiSceneBase::SetEnableTooltips( unsigned int iPad, BOOL bVal ) +{ + if( CXuiSceneBase::Instance != NULL ) + { + return CXuiSceneBase::Instance->_SetEnableTooltips(iPad, bVal ); + } + return S_OK; +} + +HRESULT CXuiSceneBase::SetTooltipText( unsigned int iPad, unsigned int tooltip, int iTextID ) +{ + if( CXuiSceneBase::Instance != NULL ) + { + return CXuiSceneBase::Instance->_SetTooltipText(iPad, tooltip, iTextID ); + } + return S_OK; +} + +HRESULT CXuiSceneBase::RefreshTooltips( unsigned int iPad) +{ + if( CXuiSceneBase::Instance != NULL ) + { + return CXuiSceneBase::Instance->_RefreshTooltips(iPad); + } + return S_OK; +} + +HRESULT CXuiSceneBase::ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ) +{ + if( CXuiSceneBase::Instance != NULL ) + { + return CXuiSceneBase::Instance->_ShowTooltip(iPad, tooltip, show ); + } + return S_OK; +} + +HRESULT CXuiSceneBase::ShowSafeArea( BOOL bShow ) +{ + if( CXuiSceneBase::Instance != NULL ) + { + return CXuiSceneBase::Instance->_ShowSafeArea(bShow ); + } + return S_OK; +} + +HRESULT CXuiSceneBase::SetTooltips( unsigned int iPad, int iA, int iB, int iX, int iY , int iLT, int iRT, int iRB, int iLB, int iLS, bool forceUpdate /*= false*/ ) +{ + if( CXuiSceneBase::Instance != NULL ) + { + // Enable all the tooltips. We should disable them in the scenes as required + CXuiSceneBase::Instance->_SetTooltipsEnabled( iPad ); + + int iTooptipsA[BUTTONS_TOOLTIP_MAX]; + iTooptipsA[BUTTON_TOOLTIP_A]=iA; + iTooptipsA[BUTTON_TOOLTIP_B]=iB; + iTooptipsA[BUTTON_TOOLTIP_X]=iX; + iTooptipsA[BUTTON_TOOLTIP_Y]=iY; + iTooptipsA[BUTTON_TOOLTIP_LT]=iLT; + iTooptipsA[BUTTON_TOOLTIP_RT]=iRT; + iTooptipsA[BUTTON_TOOLTIP_LB]=iRB; + iTooptipsA[BUTTON_TOOLTIP_RB]=iLB; + iTooptipsA[BUTTON_TOOLTIP_LS]=iLS; + + for(int i=0;iSetTooltipText(iPad, i, -1 ); + CXuiSceneBase::Instance->_ShowTooltip(iPad, i, false ); + //CXuiSceneBase::Instance->m_iCurrentTooltipTextID[iPad][i]=-1; + } + else if(iTooptipsA[i]==-2) + { + CXuiSceneBase::Instance->_ShowTooltip(iPad, i, true ); + CXuiSceneBase::Instance->SetTooltipText(iPad, i, -2 ); + } + else + { + // does the tooltip need to change? + if(CXuiSceneBase::Instance->m_iCurrentTooltipTextID[iPad][i]!=iTooptipsA[i] || forceUpdate) + { + CXuiSceneBase::Instance->SetTooltipText(iPad, i, iTooptipsA[i] ); + } + CXuiSceneBase::Instance->_ShowTooltip(iPad, i, true ); + } + } + + } + return S_OK; +} + +HRESULT CXuiSceneBase::SetTooltipsEnabled( unsigned int iPad, bool bA, bool bB, bool bX, bool bY,bool bLT, bool bRT, bool bLB, bool bRB, bool bLS) +{ + return CXuiSceneBase::Instance->_SetTooltipsEnabled(iPad, bA, bB, bX, bY, bLT, bRT, bLB, bRB, bLS ); +} + +HRESULT CXuiSceneBase::EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable ) +{ + return CXuiSceneBase::Instance->_EnableTooltip(iPad, tooltip, enable); +} + +HRESULT CXuiSceneBase::AnimateKeyPress(DWORD userIndex, DWORD dwKeyCode) +{ + return CXuiSceneBase::Instance->_AnimateKeyPress(userIndex, dwKeyCode ); +} + +HRESULT CXuiSceneBase::ShowSavingMessage( unsigned int iPad, C4JStorage::ESavingMessage eVal ) +{ + if( CXuiSceneBase::Instance != NULL ) + { + return CXuiSceneBase::Instance->_ShowSavingMessage(iPad, eVal); + } + + return S_OK; +} + +HRESULT CXuiSceneBase::ShowBackground( unsigned int iPad, BOOL bShow ) +{ + return CXuiSceneBase::Instance->_ShowBackground(iPad, bShow ); +} + +HRESULT CXuiSceneBase::ShowDarkOverlay( unsigned int iPad, BOOL bShow ) +{ + return CXuiSceneBase::Instance->_ShowDarkOverlay(iPad, bShow ); +} + +HRESULT CXuiSceneBase::ShowLogo( unsigned int iPad, BOOL bShow ) +{ + return CXuiSceneBase::Instance->_ShowLogo(iPad, bShow ); +} + +HRESULT CXuiSceneBase::ShowPressStart(unsigned int iPad) +{ + CXuiSceneBase::Instance->_ShowPressStart(iPad); + return S_OK; +} + +HRESULT CXuiSceneBase::ShowOtherPlayersBaseScene(int iPad, bool show) +{ + CXuiSceneBase::Instance->_ShowOtherPlayersBaseScene(iPad, show); + return S_OK; +} + +HRESULT CXuiSceneBase::UpdateAutosaveCountdownTimer(unsigned int uiSeconds) +{ + CXuiSceneBase::Instance->_UpdateAutosaveCountdownTimer(uiSeconds); + return S_OK; +} + +HRESULT CXuiSceneBase::ShowAutosaveCountdownTimer(BOOL bVal) +{ + CXuiSceneBase::Instance->_ShowAutosaveCountdownTimer(bVal); + return S_OK; +} + +HRESULT CXuiSceneBase::UpdateTrialTimer(unsigned int iPad) +{ + CXuiSceneBase::Instance->_UpdateTrialTimer(iPad); + return S_OK; +} +HRESULT CXuiSceneBase::ShowTrialTimer(BOOL bVal) +{ + CXuiSceneBase::Instance->_ShowTrialTimer(bVal); + return S_OK; +} + +void CXuiSceneBase::ReduceTrialTimerValue() +{ + CXuiSceneBase::Instance->_ReduceTrialTimerValue(); +} + +bool CXuiSceneBase::PressStartPlaying(unsigned int iPad) +{ + return CXuiSceneBase::Instance->_PressStartPlaying(iPad); +} + +HRESULT CXuiSceneBase::HidePressStart() +{ + return CXuiSceneBase::Instance->_HidePressStart(); +} + +HRESULT CXuiSceneBase::SetPlayerBaseScenePosition( unsigned int iPad, EBaseScenePosition position ) +{ + return CXuiSceneBase::Instance->_SetPlayerBaseScenePosition(iPad, position ); +} + +HRESULT CXuiSceneBase::SetPlayerBasePositions(EBaseScenePosition pad0, EBaseScenePosition pad1, EBaseScenePosition pad2, EBaseScenePosition pad3) +{ + SetPlayerBaseScenePosition( 0, pad0 ); + SetPlayerBaseScenePosition( 1, pad1 ); + SetPlayerBaseScenePosition( 2, pad2 ); + SetPlayerBaseScenePosition( 3, pad3 ); + + return S_OK; +} + +HRESULT CXuiSceneBase::UpdatePlayerBasePositions() +{ + EBaseScenePosition padPositions[XUSER_MAX_COUNT]; + + for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) + { + padPositions[idx] = e_BaseScene_NotSet; + } + + Minecraft *pMinecraft = Minecraft::GetInstance(); + + // If the game is not started (or is being held paused for a bit) then display all scenes fullscreen + if( pMinecraft == NULL ) + { + for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) + { + padPositions[idx] = e_BaseScene_Fullscreen; + } + } + + // If the game is not in split-screen, then display the primary pad at fullscreen + else if(app.GetLocalPlayerCount()<2) + { + int primaryPad = ProfileManager.GetPrimaryPad(); + padPositions[primaryPad] = e_BaseScene_Fullscreen; + + // May need to turn off the player who just left + for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) + { + DisplayGamertag(idx,FALSE); + } + } + + // We are in splitscreen so work out where each player should be + else + { + + for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) + { + if(pMinecraft->localplayers[idx] != NULL) + { + if(pMinecraft->localplayers[idx]->m_iScreenSection==C4JRender::VIEWPORT_TYPE_FULLSCREEN) + { + DisplayGamertag(idx,FALSE); + } + else + { + DisplayGamertag(idx,TRUE); + } + + switch( pMinecraft->localplayers[idx]->m_iScreenSection) + { + case C4JRender::VIEWPORT_TYPE_FULLSCREEN: + padPositions[idx] = e_BaseScene_Fullscreen; + break; + case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: + padPositions[idx] = e_BaseScene_Top; + break; + case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: + padPositions[idx] = e_BaseScene_Bottom; + break; + case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: + padPositions[idx] = e_BaseScene_Left; + break; + case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: + padPositions[idx] = e_BaseScene_Right; + break; + case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: + padPositions[idx] = e_BaseScene_Top_Left; + break; + case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: + padPositions[idx] = e_BaseScene_Top_Right; + break; + case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: + padPositions[idx] = e_BaseScene_Bottom_Left; + break; + case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: + padPositions[idx] = e_BaseScene_Bottom_Right; + break; + } + } + else + { + padPositions[idx] = e_BaseScene_NotSet; + DisplayGamertag(idx,FALSE); + } + } + } + + return SetPlayerBasePositions(padPositions[0], padPositions[1], padPositions[2], padPositions[3]); +} + +CXuiSceneBase::EBaseScenePosition CXuiSceneBase::GetPlayerBasePosition(int iPad) +{ + return CXuiSceneBase::Instance->_GetPlayerBasePosition(iPad); +} + +void CXuiSceneBase::UpdateSelectedItemPos(int iPad) +{ + CXuiSceneBase::Instance->_UpdateSelectedItemPos(iPad); +} + +HXUIOBJ CXuiSceneBase::GetPlayerBaseScene(int iPad) +{ + return CXuiSceneBase::Instance->_GetPlayerBaseScene(iPad); +} + +HRESULT CXuiSceneBase::PlayUISFX(ESoundEffect eSound) +{ + return CXuiSceneBase::Instance->_PlayUISFX(eSound); +} + +void CXuiSceneBase::SetEmptyQuadrantLogo(int iScreenSection) +{ + Minecraft *pMinecraft = Minecraft::GetInstance(); + EBaseScenePosition ePos=e_BaseScene_Top_Left; + int iPad; + // find the empty player + for( iPad = 0; iPad < XUSER_MAX_COUNT; ++iPad) + { + if(pMinecraft->localplayers[iPad] == NULL) + { + switch( iScreenSection) + { + case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: + ePos = e_BaseScene_Top_Left; + break; + case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: + ePos = e_BaseScene_Top_Right; + break; + case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: + ePos = e_BaseScene_Bottom_Left; + break; + case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: + ePos = e_BaseScene_Bottom_Right; + break; + } + break; + } + } + + CXuiSceneBase::Instance->_SetEmptyQuadrantLogo(iPad,ePos); +} + +HRESULT CXuiSceneBase::DisplayGamertag( unsigned int iPad, BOOL bDisplay ) +{ + + CXuiSceneBase::Instance->_DisplayGamertag(iPad,bDisplay); + return S_OK; +} + +void CXuiSceneBase::SetSelectedItem( unsigned int iPad, const wstring &name) +{ + CXuiSceneBase::Instance->_SetSelectedItem(iPad,name); +} + +void CXuiSceneBase::HideAllGameUIElements() +{ + CXuiSceneBase::Instance->_HideAllGameUIElements(); +} + +bool CXuiSceneBase::GetBaseSceneSafeZone( unsigned int iPad, D3DXVECTOR2 &origin, float &width, float &height ) +{ + return CXuiSceneBase::Instance->_GetBaseSceneSafeZone(iPad,origin,width,height); +} + + +#ifndef _XBOX +void CXuiSceneBase::CreateBaseSceneInstance() +{ + CXuiSceneBase *sceneBase = new CXuiSceneBase(); + BOOL handled; + sceneBase->OnInit(NULL,handled); +} +#endif \ No newline at end of file -- cgit v1.2.3