format XUI

This commit is contained in:
Tropical
2026-03-22 12:40:22 -05:00
parent a403bf5a4a
commit 4b2f614326
175 changed files with 31285 additions and 30912 deletions

View File

@@ -6,83 +6,72 @@
#include "SlotItemControlBase.h"
#include "SlotProgressControl.h"
int SlotProgressControl::GetValue()
{
int value = 0;
int SlotProgressControl::GetValue() {
int value = 0;
HXUIOBJ hVisual, hParent;
this->GetParent( &hVisual );
XuiElementGetParent( hVisual, &hParent);
HXUIOBJ hVisual, hParent;
this->GetParent(&hVisual);
XuiElementGetParent(hVisual, &hParent);
void* pvUserData;
XuiElementGetUserData( hParent, &pvUserData );
void* pvUserData;
XuiElementGetUserData(hParent, &pvUserData);
if( pvUserData != NULL )
{
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
std::shared_ptr<ItemInstance> item = std::shared_ptr<ItemInstance>();
if (pvUserData != NULL) {
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
if( pUserDataContainer->slot != NULL )
{
item = pUserDataContainer->slot->getItem();
}
else
{
item = pUserDataContainer->item;
}
std::shared_ptr<ItemInstance> item = std::shared_ptr<ItemInstance>();
if( item != NULL )
{
// TODO Should use getDamage instead even though it returns the same value
if( item->isDamaged() )
value = item->getDamageValue();
else
value = 0;
}
}
else
{
LPCWSTR name;
XuiElementGetId( hParent, &name );
if (pUserDataContainer->slot != NULL) {
item = pUserDataContainer->slot->getItem();
} else {
item = pUserDataContainer->item;
}
OutputDebugStringW( name );
OutputDebugString( "\n" );
}
if (item != NULL) {
// TODO Should use getDamage instead even though it returns the same
// value
if (item->isDamaged())
value = item->getDamageValue();
else
value = 0;
}
} else {
LPCWSTR name;
XuiElementGetId(hParent, &name);
return value;
OutputDebugStringW(name);
OutputDebugString("\n");
}
return value;
}
void SlotProgressControl::GetRange(int *pnRangeMin, int *pnRangeMax)
{
*pnRangeMin = 0;
*pnRangeMax = 0;
void SlotProgressControl::GetRange(int* pnRangeMin, int* pnRangeMax) {
*pnRangeMin = 0;
*pnRangeMax = 0;
HXUIOBJ hVisual, hParent;
this->GetParent( &hVisual );
XuiElementGetParent( hVisual, &hParent);
HXUIOBJ hVisual, hParent;
this->GetParent(&hVisual);
XuiElementGetParent(hVisual, &hParent);
void* pvUserData;
XuiElementGetUserData( hParent, &pvUserData );
void* pvUserData;
XuiElementGetUserData(hParent, &pvUserData);
if( pvUserData != NULL )
{
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
std::shared_ptr<ItemInstance> item = std::shared_ptr<ItemInstance>();
if (pvUserData != NULL) {
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
if( pUserDataContainer->slot != NULL )
{
item = pUserDataContainer->slot->getItem();
}
else
{
item = pUserDataContainer->item;
}
std::shared_ptr<ItemInstance> item = std::shared_ptr<ItemInstance>();
if( item != NULL )
{
*pnRangeMax = item->getMaxDamage();
}
}
if (pUserDataContainer->slot != NULL) {
item = pUserDataContainer->slot->getItem();
} else {
item = pUserDataContainer->item;
}
if (item != NULL) {
*pnRangeMax = item->getMaxDamage();
}
}
}

View File

@@ -2,17 +2,17 @@
#include "ProgressControlBase.h"
class SlotProgressControl : public ProgressControlBase
{
class SlotProgressControl : public ProgressControlBase {
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( SlotProgressControl, L"SlotProgressControl", XUI_CLASS_PROGRESSBAR )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(SlotProgressControl, L"SlotProgressControl",
XUI_CLASS_PROGRESSBAR)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
virtual int GetValue();
virtual void GetRange(int *pnRangeMin, int *pnRangeMax);
virtual int GetValue();
virtual void GetRange(int* pnRangeMin, int* pnRangeMax);
};

View File

@@ -2,8 +2,6 @@
#include <assert.h>
#include "XUI_BasePlayer.h"
HRESULT CXuiSceneBasePlayer::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
return S_OK;
HRESULT CXuiSceneBasePlayer::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
return S_OK;
}

View File

@@ -1,13 +1,12 @@
#pragma once
class CXuiSceneBasePlayer : public CXuiSceneImpl
{
class CXuiSceneBasePlayer : public CXuiSceneImpl {
protected:
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiSceneBasePlayer, L"CXuiSceneBasePlayer", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiSceneBasePlayer, L"CXuiSceneBasePlayer",
XUI_CLASS_SCENE)
};

View File

@@ -3,69 +3,63 @@
#include "../../Minecraft.Client/Minecraft.h"
#include "../../Minecraft.Client/UI/Gui.h"
HRESULT CScene_Chat::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *(int *)pInitData->pvInitData;
HRESULT CScene_Chat::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
m_iPad = *(int*)pInitData->pvInitData;
MapChildControls();
MapChildControls();
this->SetTimer(0,100);
this->SetTimer(0, 100);
XuiElementGetPosition(m_hObj,&m_OriginalPosition);
XuiElementGetPosition(m_hObj, &m_OriginalPosition);
return S_OK;
return S_OK;
}
HRESULT CScene_Chat::OnTimer( XUIMessageTimer *pXUIMessageTimer, BOOL &bHandled)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
Gui *pGui = pMinecraft->gui;
HRESULT CScene_Chat::OnTimer(XUIMessageTimer* pXUIMessageTimer,
BOOL& bHandled) {
Minecraft* pMinecraft = Minecraft::GetInstance();
Gui* pGui = pMinecraft->gui;
//DWORD messagesToDisplay = std::min( CHAT_LINES_COUNT, pGui->getMessagesCount(m_iPad) );
for( unsigned int i = 0; i < CHAT_LINES_COUNT; ++i )
{
float opacity = pGui->getOpacity(m_iPad, i);
if( opacity > 0 )
{
m_Backgrounds[i].SetOpacity(opacity);
m_Labels[i].SetOpacity(opacity);
m_Labels[i].SetText( pGui->getMessage(m_iPad,i).c_str() );
}
else
{
m_Backgrounds[i].SetOpacity(0);
m_Labels[i].SetOpacity(0);
}
}
if(pMinecraft->localplayers[m_iPad]!= NULL)
{
m_Jukebox.SetText( pGui->getJukeboxMessage(m_iPad).c_str() );
m_Jukebox.SetOpacity( pGui->getJukeboxOpacity(m_iPad) );
}
return S_OK;
// DWORD messagesToDisplay = std::min( CHAT_LINES_COUNT,
// pGui->getMessagesCount(m_iPad) );
for (unsigned int i = 0; i < CHAT_LINES_COUNT; ++i) {
float opacity = pGui->getOpacity(m_iPad, i);
if (opacity > 0) {
m_Backgrounds[i].SetOpacity(opacity);
m_Labels[i].SetOpacity(opacity);
m_Labels[i].SetText(pGui->getMessage(m_iPad, i).c_str());
} else {
m_Backgrounds[i].SetOpacity(0);
m_Labels[i].SetOpacity(0);
}
}
if (pMinecraft->localplayers[m_iPad] != NULL) {
m_Jukebox.SetText(pGui->getJukeboxMessage(m_iPad).c_str());
m_Jukebox.SetOpacity(pGui->getJukeboxOpacity(m_iPad));
}
return S_OK;
}
HRESULT CScene_Chat::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
app.ReloadChatScene(m_iPad, bJoining);
HRESULT CScene_Chat::OnCustomMessage_Splitscreenplayer(bool bJoining,
BOOL& bHandled) {
bHandled = true;
return S_OK;
app.ReloadChatScene(m_iPad, bJoining);
return S_OK;
}
HRESULT CScene_Chat::OffsetTextPosition( float xOffset, float yOffset /*= 0.0f*/ )
{
D3DXVECTOR3 vPos;
float fWidth, fHeight;
XuiElementGetBounds( m_Backgrounds[0], &fWidth, &fHeight );
for(unsigned int i = 0; i < CHAT_LINES_COUNT; ++i)
{
XuiElementGetPosition( m_Labels[i], &vPos );
vPos.x = xOffset;
vPos.y += yOffset;
XuiElementSetPosition( m_Labels[i], &vPos );
XuiElementSetBounds( m_Labels[i], fWidth - xOffset, fHeight );
}
return S_OK;
HRESULT CScene_Chat::OffsetTextPosition(float xOffset,
float yOffset /*= 0.0f*/) {
D3DXVECTOR3 vPos;
float fWidth, fHeight;
XuiElementGetBounds(m_Backgrounds[0], &fWidth, &fHeight);
for (unsigned int i = 0; i < CHAT_LINES_COUNT; ++i) {
XuiElementGetPosition(m_Labels[i], &vPos);
vPos.x = xOffset;
vPos.y += yOffset;
XuiElementSetPosition(m_Labels[i], &vPos);
XuiElementSetBounds(m_Labels[i], fWidth - xOffset, fHeight);
}
return S_OK;
}

View File

@@ -4,56 +4,54 @@
#define CHAT_LINES_COUNT 10
class CScene_Chat : public CXuiSceneImpl
{
class CScene_Chat : public CXuiSceneImpl {
protected:
CXuiControl m_Labels[CHAT_LINES_COUNT];
CXuiControl m_Backgrounds[CHAT_LINES_COUNT];
CXuiControl m_Jukebox;
D3DXVECTOR3 m_OriginalPosition;
int m_iPad;
CXuiControl m_Labels[CHAT_LINES_COUNT];
CXuiControl m_Backgrounds[CHAT_LINES_COUNT];
CXuiControl m_Jukebox;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_TIMER( OnTimer )
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_END_MSG_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiLabel1, m_Labels[0])
MAP_CONTROL(IDC_XuiLabel2, m_Labels[1])
MAP_CONTROL(IDC_XuiLabel3, m_Labels[2])
MAP_CONTROL(IDC_XuiLabel4, m_Labels[3])
MAP_CONTROL(IDC_XuiLabel5, m_Labels[4])
MAP_CONTROL(IDC_XuiLabel6, m_Labels[5])
MAP_CONTROL(IDC_XuiLabel7, m_Labels[6])
MAP_CONTROL(IDC_XuiLabel8, m_Labels[7])
MAP_CONTROL(IDC_XuiLabel9, m_Labels[8])
MAP_CONTROL(IDC_XuiLabel10, m_Labels[9])
MAP_CONTROL(IDC_XuiBack1, m_Backgrounds[0])
MAP_CONTROL(IDC_XuiBack2, m_Backgrounds[1])
MAP_CONTROL(IDC_XuiBack3, m_Backgrounds[2])
MAP_CONTROL(IDC_XuiBack4, m_Backgrounds[3])
MAP_CONTROL(IDC_XuiBack5, m_Backgrounds[4])
MAP_CONTROL(IDC_XuiBack6, m_Backgrounds[5])
MAP_CONTROL(IDC_XuiBack7, m_Backgrounds[6])
MAP_CONTROL(IDC_XuiBack8, m_Backgrounds[7])
MAP_CONTROL(IDC_XuiBack9, m_Backgrounds[8])
MAP_CONTROL(IDC_XuiBack10, m_Backgrounds[9])
MAP_CONTROL(IDC_XuiLabelJukebox, m_Jukebox)
END_CONTROL_MAP()
D3DXVECTOR3 m_OriginalPosition;
int m_iPad;
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnTimer( XUIMessageTimer *pXUIMessageTimer, BOOL &bHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_TIMER(OnTimer)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_END_MSG_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiLabel1, m_Labels[0])
MAP_CONTROL(IDC_XuiLabel2, m_Labels[1])
MAP_CONTROL(IDC_XuiLabel3, m_Labels[2])
MAP_CONTROL(IDC_XuiLabel4, m_Labels[3])
MAP_CONTROL(IDC_XuiLabel5, m_Labels[4])
MAP_CONTROL(IDC_XuiLabel6, m_Labels[5])
MAP_CONTROL(IDC_XuiLabel7, m_Labels[6])
MAP_CONTROL(IDC_XuiLabel8, m_Labels[7])
MAP_CONTROL(IDC_XuiLabel9, m_Labels[8])
MAP_CONTROL(IDC_XuiLabel10, m_Labels[9])
MAP_CONTROL(IDC_XuiBack1, m_Backgrounds[0])
MAP_CONTROL(IDC_XuiBack2, m_Backgrounds[1])
MAP_CONTROL(IDC_XuiBack3, m_Backgrounds[2])
MAP_CONTROL(IDC_XuiBack4, m_Backgrounds[3])
MAP_CONTROL(IDC_XuiBack5, m_Backgrounds[4])
MAP_CONTROL(IDC_XuiBack6, m_Backgrounds[5])
MAP_CONTROL(IDC_XuiBack7, m_Backgrounds[6])
MAP_CONTROL(IDC_XuiBack8, m_Backgrounds[7])
MAP_CONTROL(IDC_XuiBack9, m_Backgrounds[8])
MAP_CONTROL(IDC_XuiBack10, m_Backgrounds[9])
MAP_CONTROL(IDC_XuiLabelJukebox, m_Jukebox)
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnTimer(XUIMessageTimer* pXUIMessageTimer, BOOL& bHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_Chat, L"CScene_Chat", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_Chat, L"CScene_Chat", XUI_CLASS_SCENE)
HRESULT OffsetTextPosition( float xOffset, float yOffset = 0.0f );
HRESULT OffsetTextPosition(float xOffset, float yOffset = 0.0f);
};

View File

@@ -10,207 +10,199 @@
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_ConnectingProgress::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
ConnectionProgressParams *param = (ConnectionProgressParams *)pInitData->pvInitData;
m_iPad = param->iPad;
MapChildControls();
HRESULT CScene_ConnectingProgress::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
ConnectionProgressParams* param =
(ConnectionProgressParams*)pInitData->pvInitData;
m_iPad = param->iPad;
MapChildControls();
if( param->stringId >= 0 )
{
m_title.SetText( app.GetString( param->stringId ) );
}
else
{
m_title.SetText( L"" );
}
if (param->stringId >= 0) {
m_title.SetText(app.GetString(param->stringId));
} else {
m_title.SetText(L"");
}
m_buttonConfirm.SetText( app.GetString( IDS_CONFIRM_OK ) );
m_buttonConfirm.SetText(app.GetString(IDS_CONFIRM_OK));
if(app.GetLocalPlayerCount()>1)
{
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
}
if (app.GetLocalPlayerCount() > 1) {
app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad, false);
}
CXuiSceneBase::ShowBackground( m_iPad, TRUE );
CXuiSceneBase::ShowLogo( m_iPad, TRUE );
CXuiSceneBase::ShowBackground(m_iPad, TRUE);
CXuiSceneBase::ShowLogo(m_iPad, TRUE);
m_showTooltips = param->showTooltips;
if( param->showTooltips )
ui.SetTooltips( m_iPad, -1, IDS_TOOLTIPS_CANCEL_JOIN, -1, -1 );
else
ui.SetTooltips( m_iPad, -1 );
m_showTooltips = param->showTooltips;
if (param->showTooltips)
ui.SetTooltips(m_iPad, -1, IDS_TOOLTIPS_CANCEL_JOIN, -1, -1);
else
ui.SetTooltips(m_iPad, -1);
m_runFailTimer = param->setFailTimer;
m_timerTime = param->timerTime;
m_runFailTimer = param->setFailTimer;
m_timerTime = param->timerTime;
return S_OK;
return S_OK;
}
// The framework calls this handler when the object is to be destroyed.
HRESULT CScene_ConnectingProgress::OnDestroy()
{
return S_OK;
}
// The framework calls this handler when the object is to be destroyed.
HRESULT CScene_ConnectingProgress::OnDestroy() { return S_OK; }
//----------------------------------------------------------------------------------
// Updates the UI when the list selection changes.
//----------------------------------------------------------------------------------
HRESULT CScene_ConnectingProgress::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled )
{
return S_OK;
HRESULT CScene_ConnectingProgress::OnNotifySelChanged(
HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled) {
return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_ConnectingProgress::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_ConnectingProgress::OnNotifyPressEx(
HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if(hObjPressed == m_buttonConfirm)
{
if( m_iPad != ProfileManager.GetPrimaryPad() && g_NetworkManager.IsInSession() )
{
// The connection failed if we see the button, so the temp player should be removed and the viewports updated again
Minecraft *pMinecraft = Minecraft::GetInstance();
pMinecraft->removeLocalPlayerIdx(m_iPad);
}
else
{
app.NavigateToHomeMenu();
//app.NavigateBack( ProfileManager.GetPrimaryPad() );
}
}
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
if( m_showTooltips )
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
// Explicitly handle B button presses
if (pInputData->dwKeyCode == VK_PAD_B)
{
// Cancel the join
Minecraft *pMinecraft = Minecraft::GetInstance();
pMinecraft->removeLocalPlayerIdx(m_iPad);
rfHandled = TRUE;
}
}
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled)
{
// This gets called every frame, so use it to update our two text boxes
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled )
{
//if(m_runFailTimer) XuiSetTimer(m_hObj,0,m_timerTime);
if( pTransition->dwTransType == XUI_TRANSITION_FROM )
{
XuiKillTimer(m_hObj,0);
}
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnTransitionEnd( XUIMessageTransition *pTransition, BOOL& bHandled )
{
// are we being destroyed? If so, don't do anything
if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY )
{
return S_OK;
}
if( pTransition->dwTransType == XUI_TRANSITION_TO )
{
if(m_runFailTimer) XuiSetTimer(m_hObj,0,m_timerTime);
}
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
{
// Check if the connection failed
Minecraft *pMinecraft = Minecraft::GetInstance();
if( pMinecraft->m_connectionFailed[m_iPad] || !g_NetworkManager.IsInSession() )
{
app.RemoveBackScene(m_iPad);
// 4J-PB - timers auto repeat, so kill it
XuiKillTimer(m_hObj,0);
int exitReasonStringId;
switch(pMinecraft->m_connectionFailedReason[m_iPad])
{
case DisconnectPacket::eDisconnect_LoginTooLong:
exitReasonStringId = IDS_DISCONNECTED_LOGIN_TOO_LONG;
break;
case DisconnectPacket::eDisconnect_ServerFull:
exitReasonStringId = IDS_DISCONNECTED_SERVER_FULL;
break;
case DisconnectPacket::eDisconnect_Kicked:
exitReasonStringId = IDS_DISCONNECTED_KICKED;
break;
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
break;
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
break;
case DisconnectPacket::eDisconnect_NoUGC_Remote:
exitReasonStringId = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE;
break;
case DisconnectPacket::eDisconnect_NoFlying:
exitReasonStringId = IDS_DISCONNECTED_FLYING;
break;
case DisconnectPacket::eDisconnect_Quitting:
exitReasonStringId = IDS_DISCONNECTED_SERVER_QUIT;
break;
case DisconnectPacket::eDisconnect_OutdatedServer:
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
break;
case DisconnectPacket::eDisconnect_OutdatedClient:
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
break;
default:
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
break;
}
if( m_iPad != ProfileManager.GetPrimaryPad() && g_NetworkManager.IsInSession() )
{
m_buttonConfirm.SetShow(TRUE);
m_buttonConfirm.SetFocus(m_iPad);
// Set text
m_title.SetText( app.GetString( IDS_CONNECTION_FAILED ) );
m_status.SetText( app.GetString( exitReasonStringId ) );
}
else
{
unsigned int uiIDA[1];
uiIDA[0]=IDS_CONFIRM_OK;
#ifdef _XBOX
StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable());
#endif
exitReasonStringId = -1;
//app.NavigateToHomeMenu();
app.SetAction(ProfileManager.GetPrimaryPad(),eAppAction_ExitWorld,(void *)TRUE);
}
}
if (hObjPressed == m_buttonConfirm) {
if (m_iPad != ProfileManager.GetPrimaryPad() &&
g_NetworkManager.IsInSession()) {
// The connection failed if we see the button, so the temp player
// should be removed and the viewports updated again
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->removeLocalPlayerIdx(m_iPad);
} else {
app.NavigateToHomeMenu();
// app.NavigateBack( ProfileManager.GetPrimaryPad() );
}
}
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
if (m_showTooltips) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
// Explicitly handle B button presses
if (pInputData->dwKeyCode == VK_PAD_B) {
// Cancel the join
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->removeLocalPlayerIdx(m_iPad);
rfHandled = TRUE;
}
}
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
// This gets called every frame, so use it to update our two text boxes
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnTransitionStart(
XUIMessageTransition* pTransition, BOOL& bHandled) {
// if(m_runFailTimer) XuiSetTimer(m_hObj,0,m_timerTime);
if (pTransition->dwTransType == XUI_TRANSITION_FROM) {
XuiKillTimer(m_hObj, 0);
}
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnTransitionEnd(
XUIMessageTransition* pTransition, BOOL& bHandled) {
// are we being destroyed? If so, don't do anything
if (pTransition->dwTransAction == XUI_TRANSITION_ACTION_DESTROY) {
return S_OK;
}
if (pTransition->dwTransType == XUI_TRANSITION_TO) {
if (m_runFailTimer) XuiSetTimer(m_hObj, 0, m_timerTime);
}
return S_OK;
}
HRESULT CScene_ConnectingProgress::OnTimer(XUIMessageTimer* pTimer,
BOOL& bHandled) {
// Check if the connection failed
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft->m_connectionFailed[m_iPad] ||
!g_NetworkManager.IsInSession()) {
app.RemoveBackScene(m_iPad);
// 4J-PB - timers auto repeat, so kill it
XuiKillTimer(m_hObj, 0);
int exitReasonStringId;
switch (pMinecraft->m_connectionFailedReason[m_iPad]) {
case DisconnectPacket::eDisconnect_LoginTooLong:
exitReasonStringId = IDS_DISCONNECTED_LOGIN_TOO_LONG;
break;
case DisconnectPacket::eDisconnect_ServerFull:
exitReasonStringId = IDS_DISCONNECTED_SERVER_FULL;
break;
case DisconnectPacket::eDisconnect_Kicked:
exitReasonStringId = IDS_DISCONNECTED_KICKED;
break;
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
exitReasonStringId =
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
break;
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
exitReasonStringId =
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
break;
case DisconnectPacket::eDisconnect_NoUGC_Remote:
exitReasonStringId =
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_REMOTE;
break;
case DisconnectPacket::eDisconnect_NoFlying:
exitReasonStringId = IDS_DISCONNECTED_FLYING;
break;
case DisconnectPacket::eDisconnect_Quitting:
exitReasonStringId = IDS_DISCONNECTED_SERVER_QUIT;
break;
case DisconnectPacket::eDisconnect_OutdatedServer:
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
break;
case DisconnectPacket::eDisconnect_OutdatedClient:
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
break;
default:
exitReasonStringId = IDS_CONNECTION_LOST_SERVER;
break;
}
if (m_iPad != ProfileManager.GetPrimaryPad() &&
g_NetworkManager.IsInSession()) {
m_buttonConfirm.SetShow(TRUE);
m_buttonConfirm.SetFocus(m_iPad);
// Set text
m_title.SetText(app.GetString(IDS_CONNECTION_FAILED));
m_status.SetText(app.GetString(exitReasonStringId));
} else {
unsigned int uiIDA[1];
uiIDA[0] = IDS_CONFIRM_OK;
#ifdef _XBOX
StorageManager.RequestMessageBox(IDS_CONNECTION_FAILED,
exitReasonStringId, uiIDA, 1,
ProfileManager.GetPrimaryPad(),
NULL, NULL, app.GetStringTable());
#endif
exitReasonStringId = -1;
// app.NavigateToHomeMenu();
app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_ExitWorld,
(void*)TRUE);
}
}
return S_OK;
}

View File

@@ -1,55 +1,59 @@
#pragma once
#pragma once
#include "../media/xuiscene_connectingprogress.h"
class CScene_ConnectingProgress : public CXuiSceneImpl
{
class CScene_ConnectingProgress : public CXuiSceneImpl {
private:
int m_iPad;
bool m_runFailTimer;
int m_timerTime;
bool m_showTooltips;
int m_iPad;
bool m_runFailTimer;
int m_timerTime;
bool m_showTooltips;
protected:
// Control and Element wrapper objects.
CXuiControl m_title, m_status, m_buttonConfirm;
// Control and Element wrapper objects.
CXuiControl m_title, m_status, m_buttonConfirm;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY( OnDestroy )
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_TRANSITION_START( OnTransitionStart )
XUI_ON_XM_TRANSITION_END( OnTransitionEnd )
XUI_ON_XM_TIMER( OnTimer )
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_ON_XM_TRANSITION_END(OnTransitionEnd)
XUI_ON_XM_TIMER(OnTimer)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Title, m_title)
MAP_CONTROL(IDC_Status, m_status)
MAP_CONTROL(IDC_ButtonConfirm, m_buttonConfirm)
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Title, m_title)
MAP_CONTROL(IDC_Status, m_status)
MAP_CONTROL(IDC_ButtonConfirm, m_buttonConfirm)
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnTransitionStart(XUIMessageTransition* pTransition,
BOOL& bHandled);
HRESULT OnTransitionEnd(XUIMessageTransition* pTransition, BOOL& bHandled);
HRESULT OnTimer(XUIMessageTimer* pTimer, BOOL& bHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnDestroy();
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnTransitionEnd( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled );
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_ConnectingProgress, L"CScene_ConnectingProgress", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_ConnectingProgress, L"CScene_ConnectingProgress",
XUI_CLASS_SCENE)
private:
bool m_threadCompleted;
D3DXVECTOR3 m_OriginalPosition;
bool m_threadCompleted;
D3DXVECTOR3 m_OriginalPosition;
};

View File

@@ -2,97 +2,94 @@
#include "XUI_Control_ComboBox.h"
#include "../../Minecraft.Client/Platform/Xbox/Xbox_App.h"
HRESULT CXuiControl4JComboBox::OnInit(XUIMessageInit *pInitData, BOOL& bHandled)
{
m_ListData.nItems=0;
m_ListData.pItems=NULL;
HRESULT CXuiControl4JComboBox::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
m_ListData.nItems = 0;
m_ListData.pItems = NULL;
return S_OK;
return S_OK;
}
void CXuiControl4JComboBox::SetData(LIST_ITEM_INFO *pItems,int iCount)
{
CXuiControl4JComboBox *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
void CXuiControl4JComboBox::SetData(LIST_ITEM_INFO* pItems, int iCount) {
CXuiControl4JComboBox* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
// copy the data in
pThis->m_ListData.pItems= new LIST_ITEM_INFO [iCount] ;
memcpy(pThis->m_ListData.pItems,pItems,sizeof(LIST_ITEM_INFO)*iCount);
pThis->m_ListData.nItems=iCount;
// copy the data in
pThis->m_ListData.pItems = new LIST_ITEM_INFO[iCount];
memcpy(pThis->m_ListData.pItems, pItems, sizeof(LIST_ITEM_INFO) * iCount);
pThis->m_ListData.nItems = iCount;
//InsertItems( 0, iCount );
// InsertItems( 0, iCount );
}
int CXuiControl4JComboBox::GetSelectedIndex()
{
return XuiListGetCurSel(GetListObject(),NULL);
int CXuiControl4JComboBox::GetSelectedIndex() {
return XuiListGetCurSel(GetListObject(), NULL);
}
// Gets called every frame
HRESULT CXuiControl4JComboBox::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData,BOOL& bHandled)
{
if( ( 0 == pGetSourceTextData->iData ) && ( ( pGetSourceTextData->bItemData ) ) )
{
pGetSourceTextData->szText =
m_ListData.pItems[pGetSourceTextData->iItem].pwszText;
bHandled = TRUE;
}
return S_OK;
HRESULT CXuiControl4JComboBox::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
if ((0 == pGetSourceTextData->iData) && ((pGetSourceTextData->bItemData))) {
pGetSourceTextData->szText =
m_ListData.pItems[pGetSourceTextData->iItem].pwszText;
bHandled = TRUE;
}
return S_OK;
}
HRESULT CXuiControl4JComboBox::OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData,BOOL& bHandled)
{
pGetItemCountData->cItems = m_ListData.nItems;
bHandled = TRUE;
return S_OK;
HRESULT CXuiControl4JComboBox::OnGetItemCountAll(
XUIMessageGetItemCount* pGetItemCountData, BOOL& bHandled) {
pGetItemCountData->cItems = m_ListData.nItems;
bHandled = TRUE;
return S_OK;
}
HRESULT CXuiControl4JComboBox::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled)
{
return S_OK;
HRESULT CXuiControl4JComboBox::OnGetSourceDataImage(
XUIMessageGetSourceImage* pGetSourceImageData, BOOL& bHandled) {
return S_OK;
//if( ( 0 == pGetSourceImageData->iData ) && ( pGetSourceImageData->bItemData ) )
//{
// // Check for a brush
// if( ( 0 == pGetSourceImageData->iData ) && (
// pGetSourceImageData->bItemData ) )
//{
// // Check for a brush
// if(m_ListData.pItems[pGetSourceImageData->iItem].hXuiBrush!=NULL)
// {
// pGetSourceImageData->hBrush=m_ListData.pItems[pGetSourceImageData->iItem].hXuiBrush;
// }
// else
// {
// pGetSourceImageData->szPath =
// m_ListData.pItems[pGetSourceImageData->iItem].pwszImage;
// }
// bHandled = TRUE;
//}
//return S_OK;
// if(m_ListData.pItems[pGetSourceImageData->iItem].hXuiBrush!=NULL)
// {
// pGetSourceImageData->hBrush=m_ListData.pItems[pGetSourceImageData->iItem].hXuiBrush;
// }
// else
// {
// pGetSourceImageData->szPath =
// m_ListData.pItems[pGetSourceImageData->iItem].pwszImage;
// }
// bHandled = TRUE;
//}
// return S_OK;
}
HRESULT CXuiControl4JComboBox::OnGetItemEnable(XUIMessageGetItemEnable *pGetItemEnableData,BOOL& bHandled)
{
if(m_ListData.pItems!=NULL && m_ListData.nItems!=0)
{
pGetItemEnableData->bEnabled =
m_ListData.pItems[pGetItemEnableData->iItem].fEnabled;
}
bHandled = TRUE;
return S_OK;
HRESULT CXuiControl4JComboBox::OnGetItemEnable(
XUIMessageGetItemEnable* pGetItemEnableData, BOOL& bHandled) {
if (m_ListData.pItems != NULL && m_ListData.nItems != 0) {
pGetItemEnableData->bEnabled =
m_ListData.pItems[pGetItemEnableData->iItem].fEnabled;
}
bHandled = TRUE;
return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CXuiControl4JComboBox::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
CScene_Base::HandleKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if(hObjPressed==GetValueObject())
{
XuiElementSetShow(GetListObject(),TRUE);
XuiElementSetFocus(GetListObject());
rfHandled = TRUE;
}
return S_OK;
HRESULT CXuiControl4JComboBox::OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData,
BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
CScene_Base::HandleKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if (hObjPressed == GetValueObject()) {
XuiElementSetShow(GetListObject(), TRUE);
XuiElementSetFocus(GetListObject());
rfHandled = TRUE;
}
return S_OK;
}

View File

@@ -1,53 +1,49 @@
#pragma once
class CXuiControl4JComboBox : public CXuiComboBoxImpl
{
class CXuiControl4JComboBox : public CXuiComboBoxImpl {
public:
// Information for one list item.
typedef struct _LIST_ITEM_INFO {
LPCWSTR pwszText;
LPCWSTR pwszImage;
HXUIBRUSH hXuiBrush;
BOOL fChecked;
BOOL fEnabled;
} LIST_ITEM_INFO;
// Information for one list item.
typedef struct _LIST_ITEM_INFO
{
LPCWSTR pwszText;
LPCWSTR pwszImage;
HXUIBRUSH hXuiBrush;
BOOL fChecked;
BOOL fEnabled;
}
LIST_ITEM_INFO;
// List data.
typedef struct _tagListData {
int nItems;
LIST_ITEM_INFO* pItems;
} LIST_DATA;
// List data.
typedef struct _tagListData
{
int nItems;
LIST_ITEM_INFO *pItems;
}
LIST_DATA;
LIST_DATA m_ListData;
XUI_IMPLEMENT_CLASS(CXuiControl4JComboBox, L"CXuiControl4JComboBox",
XUI_CLASS_COMBOBOX);
LIST_DATA m_ListData;
XUI_IMPLEMENT_CLASS(CXuiControl4JComboBox, L"CXuiControl4JComboBox", XUI_CLASS_COMBOBOX);
void SetData(_LIST_ITEM_INFO *pItems,int iCount);
int GetSelectedIndex();
void SetData(_LIST_ITEM_INFO* pItems, int iCount);
int GetSelectedIndex();
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_GET_ITEMENABLE(OnGetItemEnable)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_GET_ITEMENABLE(OnGetItemEnable)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_END_MSG_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled);
HRESULT OnGetItemEnable(XUIMessageGetItemEnable *pGetItemEnableData,BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetSourceImageData,
BOOL& bHandled);
HRESULT OnGetItemEnable(XUIMessageGetItemEnable* pGetItemEnableData,
BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
};

View File

@@ -1,200 +1,191 @@
#include "../../Minecraft.World/Platform/stdafx.h"
#include "../../Minecraft.World/Platform/stdafx.h"
#include "XUI_Ctrl_4JEdit.h"
HRESULT CXuiCtrl4JEdit::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled) {
HRESULT hr = S_OK;
// set a limit for the text box
m_uTextLimit = XUI_4JEDIT_MAX_CHARS - 1;
XuiEditSetTextLimit(m_hObj, m_uTextLimit);
// Find the text limit. (Add one for NULL terminator)
// m_uTextLimit = std::min( XuiEditGetTextLimit(m_hObj) + 1,
// XUI_4JEDIT_MAX_CHARS);
HRESULT CXuiCtrl4JEdit::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
HRESULT hr=S_OK;
ZeroMemory(wchText, sizeof(WCHAR) * (m_uTextLimit + 1));
// set a limit for the text box
m_uTextLimit=XUI_4JEDIT_MAX_CHARS-1;
XuiEditSetTextLimit(m_hObj,m_uTextLimit);
// Find the text limit. (Add one for NULL terminator)
//m_uTextLimit = std::min( XuiEditGetTextLimit(m_hObj) + 1, XUI_4JEDIT_MAX_CHARS);
ZeroMemory( wchText , sizeof(WCHAR)*(m_uTextLimit+1) );
m_bReadOnly = false;
m_uiTitle = 0;
m_uiText =0;
m_eKeyboardMode=C_4JInput::EKeyboardMode_Default;
return hr;
m_bReadOnly = false;
m_uiTitle = 0;
m_uiText = 0;
m_eKeyboardMode = C_4JInput::EKeyboardMode_Default;
return hr;
}
HRESULT CXuiCtrl4JEdit::SetTextLimit(int iLimit)
{
CXuiCtrl4JEdit *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
if(iLimit<XUI_4JEDIT_MAX_CHARS)
{
pThis->m_uTextLimit=iLimit;
XuiEditSetTextLimit(pThis->m_hObj,iLimit);
ZeroMemory( pThis->wchText , sizeof(WCHAR)*XUI_4JEDIT_MAX_CHARS );
}
return S_OK;
HRESULT CXuiCtrl4JEdit::SetTextLimit(int iLimit) {
CXuiCtrl4JEdit* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
if (iLimit < XUI_4JEDIT_MAX_CHARS) {
pThis->m_uTextLimit = iLimit;
XuiEditSetTextLimit(pThis->m_hObj, iLimit);
ZeroMemory(pThis->wchText, sizeof(WCHAR) * XUI_4JEDIT_MAX_CHARS);
}
return S_OK;
}
HRESULT CXuiCtrl4JEdit::SetCaretPosition(int iPos)
{
CXuiCtrl4JEdit *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
XuiEditSetCaretPosition(pThis->m_hObj,iPos);
return S_OK;
HRESULT CXuiCtrl4JEdit::SetCaretPosition(int iPos) {
CXuiCtrl4JEdit* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
XuiEditSetCaretPosition(pThis->m_hObj, iPos);
return S_OK;
}
HRESULT CXuiCtrl4JEdit::SetTitleAndText(unsigned int uiTitle, unsigned int uiText)
{
CXuiCtrl4JEdit *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
pThis->m_uiTitle=uiTitle;
pThis->m_uiText=uiText;
HRESULT CXuiCtrl4JEdit::SetTitleAndText(unsigned int uiTitle,
unsigned int uiText) {
CXuiCtrl4JEdit* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
pThis->m_uiTitle = uiTitle;
pThis->m_uiText = uiText;
return S_OK;
return S_OK;
}
HRESULT CXuiCtrl4JEdit::SetReadOnly(bool bReadOnly)
{
// Attempt to make the change on the actual original version of this object that XUI made itself, rather
// than the copy we make ourselves and then map to it, which shares the same handle
CXuiCtrl4JEdit *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
pThis->m_bReadOnly = bReadOnly;
HRESULT CXuiCtrl4JEdit::SetReadOnly(bool bReadOnly) {
// Attempt to make the change on the actual original version of this object
// that XUI made itself, rather than the copy we make ourselves and then map
// to it, which shares the same handle
CXuiCtrl4JEdit* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
pThis->m_bReadOnly = bReadOnly;
return S_OK;
return S_OK;
}
HRESULT CXuiCtrl4JEdit::SetKeyboardType(C_4JInput::EKeyboardMode eKeyboardMode)
{
CXuiCtrl4JEdit *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
pThis->m_eKeyboardMode= eKeyboardMode;
return S_OK;
HRESULT CXuiCtrl4JEdit::SetKeyboardType(
C_4JInput::EKeyboardMode eKeyboardMode) {
CXuiCtrl4JEdit* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
pThis->m_eKeyboardMode = eKeyboardMode;
return S_OK;
}
// HRESULT CXuiCtrl4JEdit::SetIPMode(bool bIPMode)
// {
// // Attempt to make the change on the actual original version of this object that XUI made itself, rather
// // than the copy we make ourselves and then map to it, which shares the same handle
// CXuiCtrl4JEdit *pThis;
// {
// // Attempt to make the change on the actual original version of this
// object that XUI made itself, rather
// // than the copy we make ourselves and then map to it, which shares the
// same handle CXuiCtrl4JEdit *pThis;
// HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
// if (FAILED(hr))
// return hr;
// pThis->m_bIPMode= bIPMode;
//
//
// return S_OK;
// }
// HRESULT CXuiCtrl4JEdit::SetExtendedMode(bool bExtendedMode)
// {
// // Attempt to make the change on the actual original version of this object that XUI made itself, rather
// // than the copy we make ourselves and then map to it, which shares the same handle
// CXuiCtrl4JEdit *pThis;
// {
// // Attempt to make the change on the actual original version of this
// object that XUI made itself, rather
// // than the copy we make ourselves and then map to it, which shares the
// same handle CXuiCtrl4JEdit *pThis;
// HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
// if (FAILED(hr))
// return hr;
// pThis->m_bExtendedMode= bExtendedMode;
//
//
// return S_OK;
// }
HRESULT CXuiCtrl4JEdit::OnChar(XUIMessageChar* pInputData, BOOL& rfHandled)
{
CXuiCtrl4JEdit *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
HRESULT CXuiCtrl4JEdit::OnChar(XUIMessageChar* pInputData, BOOL& rfHandled) {
CXuiCtrl4JEdit* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
HXUIOBJ hBaseObj;
HXUIOBJ hBaseObj;
// need to send the key down to the base object, so that when we notify the parent, the edit control has been updated with the right text
hr=XuiGetBaseObject(pThis->m_hObj,&hBaseObj);
// need to send the key down to the base object, so that when we notify the
// parent, the edit control has been updated with the right text
hr = XuiGetBaseObject(pThis->m_hObj, &hBaseObj);
XUIMessage xuiMsg;
XUIMessageChar xuiMsgChar;
XuiMessageChar( &xuiMsg, &xuiMsgChar, pInputData->wch, pInputData->dwFlags, pInputData->UserIndex );
// Send the XM_CHAR message.
XuiSendMessage( hBaseObj, &xuiMsg );
XUIMessage xuiMsg;
XUIMessageChar xuiMsgChar;
XuiMessageChar(&xuiMsg, &xuiMsgChar, pInputData->wch, pInputData->dwFlags,
pInputData->UserIndex);
// Send the XM_CHAR message.
XuiSendMessage(hBaseObj, &xuiMsg);
rfHandled = TRUE;
SendNotifyValueChanged((int)pInputData->wch);
rfHandled = TRUE;
SendNotifyValueChanged((int)pInputData->wch);
return hr;
}
HRESULT CXuiCtrl4JEdit::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
CXuiCtrl4JEdit *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
//HRESULT hr = S_OK;
if( pThis->m_bReadOnly ) return hr;
// Find the text limit. (Add one for NULL terminator)
//m_uTextLimit = std::min( XuiEditGetTextLimit(m_hObj) + 1, XUI_4JEDIT_MAX_CHARS);
if((((pInputData->dwKeyCode == VK_PAD_A) && (pInputData->wch == 0)) || (pInputData->dwKeyCode == VK_PAD_START)) && !(pInputData->dwFlags & XUI_INPUT_FLAG_REPEAT))
{
pThis->RequestKeyboard(pInputData->UserIndex);
rfHandled = TRUE;
}
return hr;
return hr;
}
void CXuiCtrl4JEdit::RequestKeyboard(int iPad)
{
InputManager.RequestKeyboard(m_uiTitle,GetText(),m_uiText,iPad,wchText,m_uTextLimit+1,&CXuiCtrl4JEdit::KeyboardReturned,this,m_eKeyboardMode,app.GetStringTable());
HRESULT CXuiCtrl4JEdit::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
CXuiCtrl4JEdit* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
// HRESULT hr = S_OK;
if (pThis->m_bReadOnly) return hr;
// Find the text limit. (Add one for NULL terminator)
// m_uTextLimit = std::min( XuiEditGetTextLimit(m_hObj) + 1,
// XUI_4JEDIT_MAX_CHARS);
if ((((pInputData->dwKeyCode == VK_PAD_A) && (pInputData->wch == 0)) ||
(pInputData->dwKeyCode == VK_PAD_START)) &&
!(pInputData->dwFlags & XUI_INPUT_FLAG_REPEAT)) {
pThis->RequestKeyboard(pInputData->UserIndex);
rfHandled = TRUE;
}
return hr;
}
void CXuiCtrl4JEdit::RequestKeyboard(int iPad) {
InputManager.RequestKeyboard(m_uiTitle, GetText(), m_uiText, iPad, wchText,
m_uTextLimit + 1,
&CXuiCtrl4JEdit::KeyboardReturned, this,
m_eKeyboardMode, app.GetStringTable());
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrl4JEdit::SendNotifyValueChanged(int iValue)
{
CXuiCtrl4JEdit *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
HXUIOBJ hParent;
//HRESULT hr=S_OK;
XUIMessage msg;
XUINotify msgNotify;
XUINotifyValueChanged msgNotifyValueChanged;
HRESULT CXuiCtrl4JEdit::SendNotifyValueChanged(int iValue) {
CXuiCtrl4JEdit* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
HXUIOBJ hParent;
// HRESULT hr=S_OK;
XUIMessage msg;
XUINotify msgNotify;
XUINotifyValueChanged msgNotifyValueChanged;
XuiElementGetParent(pThis->m_hObj, &hParent);
XuiNotifyValueChanged(&msg, &msgNotify, &msgNotifyValueChanged, XuiGetOuter(pThis->m_hObj), iValue);
XuiBubbleMessage(XuiGetOuter(hParent), &msg);
XuiElementGetParent(pThis->m_hObj, &hParent);
XuiNotifyValueChanged(&msg, &msgNotify, &msgNotifyValueChanged,
XuiGetOuter(pThis->m_hObj), iValue);
XuiBubbleMessage(XuiGetOuter(hParent), &msg);
return hr;
}
int CXuiCtrl4JEdit::KeyboardReturned(void *pParam,bool bSet)
{
CXuiCtrl4JEdit* pClass = (CXuiCtrl4JEdit*)pParam;
HRESULT hr = S_OK;
if(bSet)
{
pClass->SetText(pClass->wchText);
// need to move the caret to the end of the newly set text
XuiEditSetCaretPosition(pClass->m_hObj, (int)wcsnlen(pClass->wchText, 50));
pClass->SendNotifyValueChanged(10); // 10 for a return
}
return hr;
return hr;
}
int CXuiCtrl4JEdit::KeyboardReturned(void* pParam, bool bSet) {
CXuiCtrl4JEdit* pClass = (CXuiCtrl4JEdit*)pParam;
HRESULT hr = S_OK;
if (bSet) {
pClass->SetText(pClass->wchText);
// need to move the caret to the end of the newly set text
XuiEditSetCaretPosition(pClass->m_hObj,
(int)wcsnlen(pClass->wchText, 50));
pClass->SendNotifyValueChanged(10); // 10 for a return
}
return hr;
}

View File

@@ -4,41 +4,40 @@
#define XUI_4JEDIT_MAX_CHARS 61
class CXuiCtrl4JEdit : public CXuiControlImpl
{
class CXuiCtrl4JEdit : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrl4JEdit, L"CXuiCtrl4JEdit", XUI_CLASS_EDIT)
XUI_IMPLEMENT_CLASS(CXuiCtrl4JEdit, L"CXuiCtrl4JEdit", XUI_CLASS_EDIT)
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_CHAR(OnChar)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnChar(XUIMessageChar* pInputData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_CHAR(OnChar)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnChar(XUIMessageChar* pInputData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
public:
HRESULT SetReadOnly(bool bReadOnly);
// HRESULT SetIPMode(bool bIPMode);
// HRESULT SetExtendedMode(bool bExtendedMode);
HRESULT SetKeyboardType(C_4JInput::EKeyboardMode eKeyboardMode);
HRESULT SetTextLimit(int iLimit);
HRESULT SetCaretPosition(int iPos);
HRESULT SetTitleAndText(unsigned int uiTitle, unsigned int uiText);
HRESULT SetReadOnly(bool bReadOnly);
// HRESULT SetIPMode(bool bIPMode);
// HRESULT SetExtendedMode(bool bExtendedMode);
HRESULT SetKeyboardType(C_4JInput::EKeyboardMode eKeyboardMode);
HRESULT SetTextLimit(int iLimit);
HRESULT SetCaretPosition(int iPos);
HRESULT SetTitleAndText(unsigned int uiTitle, unsigned int uiText);
void RequestKeyboard(int iPad);
void RequestKeyboard(int iPad);
protected:
bool m_bReadOnly;
C_4JInput::EKeyboardMode m_eKeyboardMode;
unsigned int m_uiTitle,m_uiText;
bool m_bReadOnly;
C_4JInput::EKeyboardMode m_eKeyboardMode;
unsigned int m_uiTitle, m_uiText;
private:
static int KeyboardReturned(void *pParam,bool bSet);
HRESULT SendNotifyValueChanged(int);
WCHAR wchText[XUI_4JEDIT_MAX_CHARS];
unsigned int m_uTextLimit;
private:
static int KeyboardReturned(void* pParam, bool bSet);
HRESULT SendNotifyValueChanged(int);
WCHAR wchText[XUI_4JEDIT_MAX_CHARS];
unsigned int m_uTextLimit;
};

View File

@@ -1,61 +1,52 @@
#include "../../Minecraft.World/Platform/stdafx.h"
#include "XUI_Ctrl_4JIcon.h"
HRESULT CXuiCtrl4JIcon::OnInit(XUIMessageInit *pInitData, BOOL& bHandled)
{
m_hBrush=NULL;
return S_OK;
HRESULT CXuiCtrl4JIcon::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
m_hBrush = NULL;
return S_OK;
}
HRESULT CXuiCtrl4JIcon::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled)
{
XUIMessage Message;
XUIMessageGetSourceImage MsgGetImage;
HRESULT hr;
HXUIOBJ hObj;
HRESULT CXuiCtrl4JIcon::OnGetSourceDataImage(
XUIMessageGetSourceImage* pGetSourceImageData, BOOL& bHandled) {
XUIMessage Message;
XUIMessageGetSourceImage MsgGetImage;
HRESULT hr;
HXUIOBJ hObj;
if(m_hBrush)
{
pGetSourceImageData->hBrush = m_hBrush;
bHandled = TRUE;
}
else
{
XuiMessageGetSourceImage(&Message, &MsgGetImage, pGetSourceImageData->iItem, pGetSourceImageData->iData, TRUE);
if (m_hBrush) {
pGetSourceImageData->hBrush = m_hBrush;
bHandled = TRUE;
} else {
XuiMessageGetSourceImage(&Message, &MsgGetImage,
pGetSourceImageData->iItem,
pGetSourceImageData->iData, TRUE);
hr = GetParent(&hObj);
hr = GetParent(&hObj);
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(hObj, &Message);
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(hObj, &Message);
if (Message.bHandled)
{
pGetSourceImageData->hBrush = MsgGetImage.hBrush;
bHandled = TRUE;
}
}
}
return S_OK;
if (Message.bHandled) {
pGetSourceImageData->hBrush = MsgGetImage.hBrush;
bHandled = TRUE;
}
}
}
return S_OK;
}
HRESULT CXuiCtrl4JIcon::UseBrush(HXUIBRUSH hBrush)
{
if( m_hBrush )
{
XuiDestroyBrush( m_hBrush );
}
m_hBrush = hBrush;
return XuiControlSetImageBrush(m_hObj,hBrush);
HRESULT CXuiCtrl4JIcon::UseBrush(HXUIBRUSH hBrush) {
if (m_hBrush) {
XuiDestroyBrush(m_hBrush);
}
m_hBrush = hBrush;
return XuiControlSetImageBrush(m_hObj, hBrush);
}
HRESULT CXuiCtrl4JIcon::OnDestroy()
{
HRESULT CXuiCtrl4JIcon::OnDestroy() {
if (m_hBrush) {
XuiDestroyBrush(m_hBrush);
}
if( m_hBrush )
{
XuiDestroyBrush( m_hBrush );
}
return S_OK;
return S_OK;
}

View File

@@ -1,25 +1,21 @@
#pragma once
class CXuiCtrl4JIcon : public CXuiControlImpl
{
class CXuiCtrl4JIcon : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrl4JIcon, L"CXuiCtrl4JIcon", XUI_CLASS_LABEL);
HRESULT UseBrush(HXUIBRUSH hBrush);
XUI_IMPLEMENT_CLASS(CXuiCtrl4JIcon, L"CXuiCtrl4JIcon", XUI_CLASS_LABEL);
HRESULT UseBrush(HXUIBRUSH hBrush);
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_DESTROY( OnDestroy )
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetSourceImageData,
BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled);
HRESULT OnDestroy();
HXUIBRUSH m_hBrush;
HXUIBRUSH m_hBrush;
};

View File

@@ -1,405 +1,361 @@
#include "../../Minecraft.World/Platform/stdafx.h"
#include "XUI_Ctrl_4JList.h"
static bool TimeSortFn(const void *a, const void *b);
static bool TimeSortFn(const void* a, const void* b);
HRESULT CXuiCtrl4JList::OnInit(XUIMessageInit *pInitData, BOOL& bHandled)
{
InitializeCriticalSection(&m_AccessListData);
HRESULT CXuiCtrl4JList::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
InitializeCriticalSection(&m_AccessListData);
m_hSelectionChangedHandlerObj = NULL;
m_hSelectionChangedHandlerObj = NULL;
return S_OK;
return S_OK;
}
void CXuiCtrl4JList::AddData( const LIST_ITEM_INFO& ItemInfo , int iSortListFromIndex, int iSortFunction)
{
// need to allocate memory for the structure and its strings
// and remap the string pointers
std::size_t totalBytes = 0;
std::size_t textBytes = 0;
std::size_t imageBytes = 0;
void CXuiCtrl4JList::AddData(const LIST_ITEM_INFO& ItemInfo,
int iSortListFromIndex, int iSortFunction) {
// need to allocate memory for the structure and its strings
// and remap the string pointers
std::size_t totalBytes = 0;
std::size_t textBytes = 0;
std::size_t imageBytes = 0;
if(ItemInfo.pwszText)
{
textBytes = wcslen(ItemInfo.pwszText) * sizeof(WCHAR);
totalBytes += textBytes + sizeof(WCHAR);
}
if (ItemInfo.pwszText) {
textBytes = wcslen(ItemInfo.pwszText) * sizeof(WCHAR);
totalBytes += textBytes + sizeof(WCHAR);
}
if(ItemInfo.pwszImage)
{
imageBytes = wcslen(ItemInfo.pwszImage) * sizeof(WCHAR);
totalBytes += imageBytes + sizeof(WCHAR);
}
if (ItemInfo.pwszImage) {
imageBytes = wcslen(ItemInfo.pwszImage) * sizeof(WCHAR);
totalBytes += imageBytes + sizeof(WCHAR);
}
totalBytes += sizeof(LIST_ITEM_INFO);
LIST_ITEM_INFO *pItemInfo = reinterpret_cast<LIST_ITEM_INFO *>(new unsigned char[totalBytes]);
ZeroMemory(pItemInfo, totalBytes);
totalBytes += sizeof(LIST_ITEM_INFO);
LIST_ITEM_INFO* pItemInfo =
reinterpret_cast<LIST_ITEM_INFO*>(new unsigned char[totalBytes]);
ZeroMemory(pItemInfo, totalBytes);
XMemCpy( pItemInfo, &ItemInfo, sizeof( LIST_ITEM_INFO ) );
if(textBytes != 0)
{
XMemCpy( &pItemInfo[1], ItemInfo.pwszText, textBytes );
pItemInfo->pwszText=(LPCWSTR)&pItemInfo[1];
if(imageBytes != 0)
{
unsigned char *imageText = reinterpret_cast<unsigned char *>(&pItemInfo[1]) + textBytes + sizeof(WCHAR);
XMemCpy( imageText, ItemInfo.pwszImage, imageBytes );
pItemInfo->pwszImage = reinterpret_cast<LPCWSTR>(imageText);
}
}
else if(imageBytes != 0)
{
XMemCpy( &pItemInfo[1], ItemInfo.pwszImage, imageBytes );
pItemInfo->pwszImage=(LPCWSTR)&pItemInfo[1];
}
XMemCpy(pItemInfo, &ItemInfo, sizeof(LIST_ITEM_INFO));
if (textBytes != 0) {
XMemCpy(&pItemInfo[1], ItemInfo.pwszText, textBytes);
pItemInfo->pwszText = (LPCWSTR)&pItemInfo[1];
if (imageBytes != 0) {
unsigned char* imageText =
reinterpret_cast<unsigned char*>(&pItemInfo[1]) + textBytes +
sizeof(WCHAR);
XMemCpy(imageText, ItemInfo.pwszImage, imageBytes);
pItemInfo->pwszImage = reinterpret_cast<LPCWSTR>(imageText);
}
} else if (imageBytes != 0) {
XMemCpy(&pItemInfo[1], ItemInfo.pwszImage, imageBytes);
pItemInfo->pwszImage = (LPCWSTR)&pItemInfo[1];
}
EnterCriticalSection(&m_AccessListData);
EnterCriticalSection(&m_AccessListData);
// need to remember the original index of this addition before it gets sorted - this will get used to load the game
if(iSortListFromIndex!=-1)
{
pItemInfo->iIndex=(int)m_vListData.size()-iSortListFromIndex;
}
else
{
pItemInfo->iIndex=(int)m_vListData.size();
}
// need to remember the original index of this addition before it gets
// sorted - this will get used to load the game
if (iSortListFromIndex != -1) {
pItemInfo->iIndex = (int)m_vListData.size() - iSortListFromIndex;
} else {
pItemInfo->iIndex = (int)m_vListData.size();
}
// added to force a sort order for DLC
//pItemInfo->iSortIndex=iSortIndex;
m_vListData.push_back(pItemInfo);
// added to force a sort order for DLC
// pItemInfo->iSortIndex=iSortIndex;
m_vListData.push_back(pItemInfo);
#ifdef _DEBUG
int iCount=0;
for (AUTO_VAR(it, m_vListData.begin()); it != m_vListData.end(); it++)
{
PLIST_ITEM_INFO pInfo=(PLIST_ITEM_INFO)*it;
app.DebugPrintf("%d. ",iCount++);
OutputDebugStringW(pInfo->pwszText);
app.DebugPrintf(" - %d\n",pInfo->iSortIndex);
}
int iCount = 0;
for (AUTO_VAR(it, m_vListData.begin()); it != m_vListData.end(); it++) {
PLIST_ITEM_INFO pInfo = (PLIST_ITEM_INFO)*it;
app.DebugPrintf("%d. ", iCount++);
OutputDebugStringW(pInfo->pwszText);
app.DebugPrintf(" - %d\n", pInfo->iSortIndex);
}
#endif
if(iSortListFromIndex!=-1)
{
switch(iSortFunction)
{
case eSortList_Date:
// sort from the index passed (to leave create world and tutorial in the saves list)
sort(m_vListData.begin()+iSortListFromIndex, m_vListData.end(),CXuiCtrl4JList::TimeSortFn);
break;
case eSortList_Alphabetical:
// alphabetical sort
sort(m_vListData.begin()+iSortListFromIndex, m_vListData.end(),CXuiCtrl4JList::AlphabeticSortFn);
break;
case eSortList_Index:
sort(m_vListData.begin()+iSortListFromIndex, m_vListData.end(),CXuiCtrl4JList::IndexSortFn);
break;
}
}
LeaveCriticalSection(&m_AccessListData);
// #ifdef _DEBUG
//
// iCount=0;
// for (AUTO_VAR(it, m_vListData.begin()); it != m_vListData.end(); it++)
// {
// PLIST_ITEM_INFO pInfo=(PLIST_ITEM_INFO)*it;
// app.DebugPrintf("After Sort - %d. ",iCount++);
// OutputDebugStringW(pInfo->pwszText);
// app.DebugPrintf(" - %d\n",pInfo->iSortIndex);
//
// }
// #endif
InsertItems( 0, 1 );
if (iSortListFromIndex != -1) {
switch (iSortFunction) {
case eSortList_Date:
// sort from the index passed (to leave create world and
// tutorial in the saves list)
sort(m_vListData.begin() + iSortListFromIndex,
m_vListData.end(), CXuiCtrl4JList::TimeSortFn);
break;
case eSortList_Alphabetical:
// alphabetical sort
sort(m_vListData.begin() + iSortListFromIndex,
m_vListData.end(), CXuiCtrl4JList::AlphabeticSortFn);
break;
case eSortList_Index:
sort(m_vListData.begin() + iSortListFromIndex,
m_vListData.end(), CXuiCtrl4JList::IndexSortFn);
break;
}
}
LeaveCriticalSection(&m_AccessListData);
// #ifdef _DEBUG
//
// iCount=0;
// for (AUTO_VAR(it, m_vListData.begin()); it != m_vListData.end(); it++)
// {
// PLIST_ITEM_INFO pInfo=(PLIST_ITEM_INFO)*it;
// app.DebugPrintf("After Sort - %d. ",iCount++);
// OutputDebugStringW(pInfo->pwszText);
// app.DebugPrintf(" - %d\n",pInfo->iSortIndex);
//
// }
// #endif
InsertItems(0, 1);
}
void CXuiCtrl4JList::RemoveAllData( )
{
EnterCriticalSection(&m_AccessListData);
void CXuiCtrl4JList::RemoveAllData() {
EnterCriticalSection(&m_AccessListData);
int iSize=(int)m_vListData.size();
for(int i=0;i<iSize;i++)
{
LIST_ITEM_INFO *pBack = m_vListData.back();
if( pBack->hXuiBrush )
{
XuiDestroyBrush(pBack->hXuiBrush);
}
m_vListData.pop_back();
DeleteItems( 0, 1 );
}
int iSize = (int)m_vListData.size();
for (int i = 0; i < iSize; i++) {
LIST_ITEM_INFO* pBack = m_vListData.back();
if (pBack->hXuiBrush) {
XuiDestroyBrush(pBack->hXuiBrush);
}
m_vListData.pop_back();
DeleteItems(0, 1);
}
LeaveCriticalSection(&m_AccessListData);
LeaveCriticalSection(&m_AccessListData);
}
void CXuiCtrl4JList::SelectByUserData(int iData)
{
for(unsigned int i = 0; i < m_vListData.size(); ++i)
{
if(m_vListData.at(i)->iData == iData)
{
SetCurSel(i);
SetTopItem(i); // scroll the item into view if it's not visible
break;
}
}
void CXuiCtrl4JList::SelectByUserData(int iData) {
for (unsigned int i = 0; i < m_vListData.size(); ++i) {
if (m_vListData.at(i)->iData == iData) {
SetCurSel(i);
SetTopItem(i); // scroll the item into view if it's not visible
break;
}
}
}
int CXuiCtrl4JList::GetIndexByUserData(int iData)
{
for(unsigned int i = 0; i < m_vListData.size(); ++i)
{
if(m_vListData.at(i)->iData == iData)
{
return i;
}
}
return 0;
int CXuiCtrl4JList::GetIndexByUserData(int iData) {
for (unsigned int i = 0; i < m_vListData.size(); ++i) {
if (m_vListData.at(i)->iData == iData) {
return i;
}
}
return 0;
}
CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetData(int index)
{
return *m_vListData[index];
CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetData(int index) {
return *m_vListData[index];
}
CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetDataiData(int iData)
{
LIST_ITEM_INFO info;
CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetDataiData(int iData) {
LIST_ITEM_INFO info;
for(unsigned int i=0;i<m_vListData.size();i++)
{
info=*m_vListData[i];
if(info.iData==iData)
{
return *m_vListData[i];
}
}
for (unsigned int i = 0; i < m_vListData.size(); i++) {
info = *m_vListData[i];
if (info.iData == iData) {
return *m_vListData[i];
}
}
return *m_vListData[0];
return *m_vListData[0];
}
CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetData(FILETIME *pFileTime)
{
LIST_ITEM_INFO info;
CXuiCtrl4JList::LIST_ITEM_INFO& CXuiCtrl4JList::GetData(FILETIME* pFileTime) {
LIST_ITEM_INFO info;
for(unsigned int i=0;i<m_vListData.size();i++)
{
info=*m_vListData[i];
if((info.fTime.dwHighDateTime==pFileTime->dwHighDateTime)&&(info.fTime.dwLowDateTime==pFileTime->dwLowDateTime))
{
return *m_vListData[i];
}
}
for (unsigned int i = 0; i < m_vListData.size(); i++) {
info = *m_vListData[i];
if ((info.fTime.dwHighDateTime == pFileTime->dwHighDateTime) &&
(info.fTime.dwLowDateTime == pFileTime->dwLowDateTime)) {
return *m_vListData[i];
}
}
return *m_vListData[0];
return *m_vListData[0];
}
bool CXuiCtrl4JList::TimeSortFn(const void *a, const void *b)
{
CXuiCtrl4JList::LIST_ITEM_INFO *SaveDetailsA=(CXuiCtrl4JList::LIST_ITEM_INFO *)a;
CXuiCtrl4JList::LIST_ITEM_INFO *SaveDetailsB=(CXuiCtrl4JList::LIST_ITEM_INFO *)b;
if(SaveDetailsA->fTime.dwHighDateTime > SaveDetailsB->fTime.dwHighDateTime)
{
return true;
}
else if(SaveDetailsA->fTime.dwHighDateTime == SaveDetailsB->fTime.dwHighDateTime)
{
if(SaveDetailsA->fTime.dwLowDateTime > SaveDetailsB->fTime.dwLowDateTime)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
bool CXuiCtrl4JList::TimeSortFn(const void* a, const void* b) {
CXuiCtrl4JList::LIST_ITEM_INFO* SaveDetailsA =
(CXuiCtrl4JList::LIST_ITEM_INFO*)a;
CXuiCtrl4JList::LIST_ITEM_INFO* SaveDetailsB =
(CXuiCtrl4JList::LIST_ITEM_INFO*)b;
if (SaveDetailsA->fTime.dwHighDateTime >
SaveDetailsB->fTime.dwHighDateTime) {
return true;
} else if (SaveDetailsA->fTime.dwHighDateTime ==
SaveDetailsB->fTime.dwHighDateTime) {
if (SaveDetailsA->fTime.dwLowDateTime >
SaveDetailsB->fTime.dwLowDateTime) {
return true;
} else {
return false;
}
} else {
return false;
}
}
bool CXuiCtrl4JList::AlphabeticSortFn(const void *a, const void *b)
{
CXuiCtrl4JList::LIST_ITEM_INFO *SaveDetailsA=(CXuiCtrl4JList::LIST_ITEM_INFO *)a;
CXuiCtrl4JList::LIST_ITEM_INFO *SaveDetailsB=(CXuiCtrl4JList::LIST_ITEM_INFO *)b;
bool CXuiCtrl4JList::AlphabeticSortFn(const void* a, const void* b) {
CXuiCtrl4JList::LIST_ITEM_INFO* SaveDetailsA =
(CXuiCtrl4JList::LIST_ITEM_INFO*)a;
CXuiCtrl4JList::LIST_ITEM_INFO* SaveDetailsB =
(CXuiCtrl4JList::LIST_ITEM_INFO*)b;
std::wstring wstr1=SaveDetailsA->pwszText;
std::wstring wstr2=SaveDetailsB->pwszText;
if(wstr1.compare(wstr2)<0)
{
return true;
}
std::wstring wstr1 = SaveDetailsA->pwszText;
std::wstring wstr2 = SaveDetailsB->pwszText;
if (wstr1.compare(wstr2) < 0) {
return true;
}
return false;
return false;
}
bool CXuiCtrl4JList::IndexSortFn(const void *a, const void *b)
{
CXuiCtrl4JList::LIST_ITEM_INFO *SaveDetailsA=(CXuiCtrl4JList::LIST_ITEM_INFO *)a;
CXuiCtrl4JList::LIST_ITEM_INFO *SaveDetailsB=(CXuiCtrl4JList::LIST_ITEM_INFO *)b;
bool CXuiCtrl4JList::IndexSortFn(const void* a, const void* b) {
CXuiCtrl4JList::LIST_ITEM_INFO* SaveDetailsA =
(CXuiCtrl4JList::LIST_ITEM_INFO*)a;
CXuiCtrl4JList::LIST_ITEM_INFO* SaveDetailsB =
(CXuiCtrl4JList::LIST_ITEM_INFO*)b;
int iA=SaveDetailsA->iSortIndex;
int iB=SaveDetailsB->iSortIndex;
if(iA>iB)
{
return true;
}
int iA = SaveDetailsA->iSortIndex;
int iB = SaveDetailsB->iSortIndex;
if (iA > iB) {
return true;
}
return false;
return false;
}
void CXuiCtrl4JList::UpdateGraphic(int iItem,HXUIBRUSH hXuiBrush )
{
// need to update the one with the matching filetime
EnterCriticalSection(&m_AccessListData);
if( GetData(iItem).hXuiBrush )
{
XuiDestroyBrush( GetData(iItem).hXuiBrush );
}
GetData(iItem).hXuiBrush=hXuiBrush;
LeaveCriticalSection(&m_AccessListData);
void CXuiCtrl4JList::UpdateGraphic(int iItem, HXUIBRUSH hXuiBrush) {
// need to update the one with the matching filetime
EnterCriticalSection(&m_AccessListData);
if (GetData(iItem).hXuiBrush) {
XuiDestroyBrush(GetData(iItem).hXuiBrush);
}
GetData(iItem).hXuiBrush = hXuiBrush;
LeaveCriticalSection(&m_AccessListData);
}
void CXuiCtrl4JList::UpdateText(int iItem,LPCWSTR pwszText )
{
// need to update the one with the matching filetime
EnterCriticalSection(&m_AccessListData);
GetData(iItem).pwszText=pwszText;
LeaveCriticalSection(&m_AccessListData);
void CXuiCtrl4JList::UpdateText(int iItem, LPCWSTR pwszText) {
// need to update the one with the matching filetime
EnterCriticalSection(&m_AccessListData);
GetData(iItem).pwszText = pwszText;
LeaveCriticalSection(&m_AccessListData);
}
void CXuiCtrl4JList::UpdateGraphicFromiData(int iData,HXUIBRUSH hXuiBrush )
{
// need to update the one with the matching iData
EnterCriticalSection(&m_AccessListData);
if( GetDataiData(iData).hXuiBrush )
{
XuiDestroyBrush( GetDataiData(iData).hXuiBrush );
}
GetDataiData(iData).hXuiBrush=hXuiBrush;
LeaveCriticalSection(&m_AccessListData);
void CXuiCtrl4JList::UpdateGraphicFromiData(int iData, HXUIBRUSH hXuiBrush) {
// need to update the one with the matching iData
EnterCriticalSection(&m_AccessListData);
if (GetDataiData(iData).hXuiBrush) {
XuiDestroyBrush(GetDataiData(iData).hXuiBrush);
}
GetDataiData(iData).hXuiBrush = hXuiBrush;
LeaveCriticalSection(&m_AccessListData);
}
void CXuiCtrl4JList::UpdateGraphic(FILETIME *pfTime,HXUIBRUSH hXuiBrush )
{
// need to update the one with the matching filetime
EnterCriticalSection(&m_AccessListData);
if( GetData(pfTime).hXuiBrush )
{
XuiDestroyBrush( GetData(pfTime).hXuiBrush );
}
GetData(pfTime).hXuiBrush=hXuiBrush;
LeaveCriticalSection(&m_AccessListData);
void CXuiCtrl4JList::UpdateGraphic(FILETIME* pfTime, HXUIBRUSH hXuiBrush) {
// need to update the one with the matching filetime
EnterCriticalSection(&m_AccessListData);
if (GetData(pfTime).hXuiBrush) {
XuiDestroyBrush(GetData(pfTime).hXuiBrush);
}
GetData(pfTime).hXuiBrush = hXuiBrush;
LeaveCriticalSection(&m_AccessListData);
}
// Gets called every frame
HRESULT CXuiCtrl4JList::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData,BOOL& bHandled)
{
if( ( 0 == pGetSourceTextData->iData ) && ( ( pGetSourceTextData->bItemData ) ) )
{
EnterCriticalSection(&m_AccessListData);
pGetSourceTextData->szText =
GetData(pGetSourceTextData->iItem).pwszText;
LeaveCriticalSection(&m_AccessListData);
bHandled = TRUE;
}
return S_OK;
HRESULT CXuiCtrl4JList::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
if ((0 == pGetSourceTextData->iData) && ((pGetSourceTextData->bItemData))) {
EnterCriticalSection(&m_AccessListData);
pGetSourceTextData->szText =
GetData(pGetSourceTextData->iItem).pwszText;
LeaveCriticalSection(&m_AccessListData);
bHandled = TRUE;
}
return S_OK;
}
HRESULT CXuiCtrl4JList::OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData,BOOL& bHandled)
{
pGetItemCountData->cItems = (int)m_vListData.size();
bHandled = TRUE;
return S_OK;
HRESULT CXuiCtrl4JList::OnGetItemCountAll(
XUIMessageGetItemCount* pGetItemCountData, BOOL& bHandled) {
pGetItemCountData->cItems = (int)m_vListData.size();
bHandled = TRUE;
return S_OK;
}
HRESULT CXuiCtrl4JList::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled)
{
if( ( 0 == pGetSourceImageData->iData ) && ( pGetSourceImageData->bItemData ) )
{
// Check for a brush
EnterCriticalSection(&m_AccessListData);
if(GetData(pGetSourceImageData->iItem).hXuiBrush!=NULL)
{
pGetSourceImageData->hBrush=GetData(pGetSourceImageData->iItem).hXuiBrush;
}
else
{
pGetSourceImageData->szPath =
GetData(pGetSourceImageData->iItem).pwszImage;
}
LeaveCriticalSection(&m_AccessListData);
bHandled = TRUE;
}
return S_OK;
HRESULT CXuiCtrl4JList::OnGetSourceDataImage(
XUIMessageGetSourceImage* pGetSourceImageData, BOOL& bHandled) {
if ((0 == pGetSourceImageData->iData) && (pGetSourceImageData->bItemData)) {
// Check for a brush
EnterCriticalSection(&m_AccessListData);
if (GetData(pGetSourceImageData->iItem).hXuiBrush != NULL) {
pGetSourceImageData->hBrush =
GetData(pGetSourceImageData->iItem).hXuiBrush;
} else {
pGetSourceImageData->szPath =
GetData(pGetSourceImageData->iItem).pwszImage;
}
LeaveCriticalSection(&m_AccessListData);
bHandled = TRUE;
}
return S_OK;
}
HRESULT CXuiCtrl4JList::OnGetItemEnable(XUIMessageGetItemEnable *pGetItemEnableData,BOOL& bHandled)
{
if(m_vListData.size()!=0)
{
EnterCriticalSection(&m_AccessListData);
pGetItemEnableData->bEnabled =
GetData(pGetItemEnableData->iItem).fEnabled;
LeaveCriticalSection(&m_AccessListData);
}
bHandled = TRUE;
return S_OK;
HRESULT CXuiCtrl4JList::OnGetItemEnable(
XUIMessageGetItemEnable* pGetItemEnableData, BOOL& bHandled) {
if (m_vListData.size() != 0) {
EnterCriticalSection(&m_AccessListData);
pGetItemEnableData->bEnabled =
GetData(pGetItemEnableData->iItem).fEnabled;
LeaveCriticalSection(&m_AccessListData);
}
bHandled = TRUE;
return S_OK;
}
HRESULT CXuiCtrl4JList::SetBorder(int index, bool show)
{
CXuiControl Control;
HXUIOBJ hVisual,hBorder;
GetItemControl(index,&Control);
Control.GetVisual(&hVisual);
XuiElementGetChildById(hVisual,L"Border",&hBorder);
return XuiElementSetShow(hBorder,show);
HRESULT CXuiCtrl4JList::SetBorder(int index, bool show) {
CXuiControl Control;
HXUIOBJ hVisual, hBorder;
GetItemControl(index, &Control);
Control.GetVisual(&hVisual);
XuiElementGetChildById(hVisual, L"Border", &hBorder);
return XuiElementSetShow(hBorder, show);
}
void CXuiCtrl4JList::SetSelectionChangedHandle(HXUIOBJ hObj)
{
m_hSelectionChangedHandlerObj = hObj;
void CXuiCtrl4JList::SetSelectionChangedHandle(HXUIOBJ hObj) {
m_hSelectionChangedHandlerObj = hObj;
}
HRESULT CXuiCtrl4JList::OnDestroy()
{
DeleteCriticalSection(&m_AccessListData);
HRESULT CXuiCtrl4JList::OnDestroy() {
DeleteCriticalSection(&m_AccessListData);
if(m_vListData.size()!=0)
{
for (unsigned i = 0; i < m_vListData.size(); ++i)
{
if( m_vListData[i]->hXuiBrush )
{
XuiDestroyBrush( m_vListData[i]->hXuiBrush );
}
delete [] reinterpret_cast<unsigned char *>(m_vListData[i]);
}
}
return S_OK;
if (m_vListData.size() != 0) {
for (unsigned i = 0; i < m_vListData.size(); ++i) {
if (m_vListData[i]->hXuiBrush) {
XuiDestroyBrush(m_vListData[i]->hXuiBrush);
}
delete[] reinterpret_cast<unsigned char*>(m_vListData[i]);
}
}
return S_OK;
}
HRESULT CXuiCtrl4JList::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled )
{
if(m_hSelectionChangedHandlerObj)
{
XUIMessage xuiMsg;
XUINotify xuiNotify;
XUINotifySelChanged xuiNotifySel;
XuiNotifySelChanged( &xuiMsg, &xuiNotify, &xuiNotifySel, hObjSource, pNotifySelChangedData->iItem, pNotifySelChangedData->iOldItem );
XuiSendMessage( m_hSelectionChangedHandlerObj, &xuiMsg );
HRESULT CXuiCtrl4JList::OnNotifySelChanged(
HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled) {
if (m_hSelectionChangedHandlerObj) {
XUIMessage xuiMsg;
XUINotify xuiNotify;
XUINotifySelChanged xuiNotifySel;
XuiNotifySelChanged(&xuiMsg, &xuiNotify, &xuiNotifySel, hObjSource,
pNotifySelChangedData->iItem,
pNotifySelChangedData->iOldItem);
XuiSendMessage(m_hSelectionChangedHandlerObj, &xuiMsg);
bHandled = xuiMsg.bHandled;
}
return S_OK;
bHandled = xuiMsg.bHandled;
}
return S_OK;
}

View File

@@ -1,78 +1,81 @@
#pragma once
class CXuiCtrl4JList : public CXuiListImpl
{
class CXuiCtrl4JList : public CXuiListImpl {
public:
enum
{
eSortList_Date = 0,
eSortList_Alphabetical,
eSortList_Index,
};
enum {
eSortList_Date = 0,
eSortList_Alphabetical,
eSortList_Index,
};
// Information for one list item.
typedef struct _LIST_ITEM_INFO
{
LPCWSTR pwszText;
LPCWSTR pwszImage;
HXUIBRUSH hXuiBrush;
bool fChecked;
bool fEnabled;
bool bIsDamaged; // damaged save
FILETIME fTime;
int iData; // user data
int iIndex; // used for internal list sorting
int iSortIndex; // used to force an order for DLC
}
LIST_ITEM_INFO,*PLIST_ITEM_INFO;
// Information for one list item.
typedef struct _LIST_ITEM_INFO {
LPCWSTR pwszText;
LPCWSTR pwszImage;
HXUIBRUSH hXuiBrush;
bool fChecked;
bool fEnabled;
bool bIsDamaged; // damaged save
FILETIME fTime;
int iData; // user data
int iIndex; // used for internal list sorting
int iSortIndex; // used to force an order for DLC
} LIST_ITEM_INFO, *PLIST_ITEM_INFO;
typedef std::vector <PLIST_ITEM_INFO> LISTITEMINFOARRAY;
typedef std::vector<PLIST_ITEM_INFO> LISTITEMINFOARRAY;
XUI_IMPLEMENT_CLASS(CXuiCtrl4JList, L"CXuiCtrl4JList", XUI_CLASS_LIST);
XUI_IMPLEMENT_CLASS(CXuiCtrl4JList, L"CXuiCtrl4JList", XUI_CLASS_LIST);
void AddData( const LIST_ITEM_INFO& ItemInfo , int iSortListFromIndex=-1, int iSortFunction=CXuiCtrl4JList::eSortList_Date);
void RemoveAllData( );
void UpdateText(int iItem,LPCWSTR pwszText );
void SelectByUserData(int iData);
int GetIndexByUserData(int iData);
void AddData(const LIST_ITEM_INFO& ItemInfo, int iSortListFromIndex = -1,
int iSortFunction = CXuiCtrl4JList::eSortList_Date);
void RemoveAllData();
void UpdateText(int iItem, LPCWSTR pwszText);
void SelectByUserData(int iData);
int GetIndexByUserData(int iData);
void UpdateGraphic(int iItem, HXUIBRUSH hXuiBrush);
void UpdateGraphic(FILETIME* pfTime, HXUIBRUSH hXuiBrush);
void UpdateGraphicFromiData(int iData, HXUIBRUSH hXuiBrush);
LIST_ITEM_INFO& GetData(int index);
LIST_ITEM_INFO& GetData(FILETIME* pFileTime);
LIST_ITEM_INFO& GetDataiData(int iData);
HRESULT SetBorder(int index,
bool show); // for a highlight around the current
// selected item in the controls layout
void SetSelectionChangedHandle(HXUIOBJ hObj);
void UpdateGraphic(int iItem,HXUIBRUSH hXuiBrush );
void UpdateGraphic(FILETIME *pfTime,HXUIBRUSH hXuiBrush );
void UpdateGraphicFromiData(int iData,HXUIBRUSH hXuiBrush );
LIST_ITEM_INFO& GetData(int index);
LIST_ITEM_INFO& GetData(FILETIME *pFileTime);
LIST_ITEM_INFO& GetDataiData(int iData);
HRESULT SetBorder(int index, bool show); // for a highlight around the current selected item in the controls layout
void SetSelectionChangedHandle(HXUIOBJ hObj);
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_GET_ITEMENABLE(OnGetItemEnable)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_GET_ITEMENABLE(OnGetItemEnable)
XUI_ON_XM_DESTROY( OnDestroy )
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetSourceImageData,
BOOL& bHandled);
HRESULT OnGetItemEnable(XUIMessageGetItemEnable* pGetItemEnableData,
BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled);
HRESULT OnGetItemEnable(XUIMessageGetItemEnable *pGetItemEnableData,BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
LISTITEMINFOARRAY m_vListData;
CRITICAL_SECTION m_AccessListData;
LISTITEMINFOARRAY m_vListData;
CRITICAL_SECTION m_AccessListData;
private:
static bool AlphabeticSortFn(const void *a, const void *b);
static bool TimeSortFn(const void *a, const void *b);
static bool IndexSortFn(const void *a, const void *b);
static bool AlphabeticSortFn(const void* a, const void* b);
static bool TimeSortFn(const void* a, const void* b);
static bool IndexSortFn(const void* a, const void* b);
HXUIOBJ m_hSelectionChangedHandlerObj;
HXUIOBJ m_hSelectionChangedHandlerObj;
};

View File

@@ -5,23 +5,22 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.item.alchemy.h"
#include "XUI_Ctrl_BrewProgress.h"
int CXuiCtrlBrewProgress::GetValue()
{
void* pvUserData;
this->GetUserData( &pvUserData );
int CXuiCtrlBrewProgress::GetValue() {
void* pvUserData;
this->GetUserData(&pvUserData);
if( pvUserData != NULL )
{
BrewingStandTileEntity *pBrewingStandTileEntity = (BrewingStandTileEntity *)pvUserData;
if (pvUserData != NULL) {
BrewingStandTileEntity* pBrewingStandTileEntity =
(BrewingStandTileEntity*)pvUserData;
return pBrewingStandTileEntity->getBrewTime();
}
return pBrewingStandTileEntity->getBrewTime();
}
return 0;
return 0;
}
void CXuiCtrlBrewProgress::GetRange(int *pnRangeMin, int *pnRangeMax)
{
*pnRangeMin = 0;
*pnRangeMax = PotionBrewing::BREWING_TIME_SECONDS * SharedConstants::TICKS_PER_SECOND;
void CXuiCtrlBrewProgress::GetRange(int* pnRangeMin, int* pnRangeMax) {
*pnRangeMin = 0;
*pnRangeMax =
PotionBrewing::BREWING_TIME_SECONDS * SharedConstants::TICKS_PER_SECOND;
}

View File

@@ -1,19 +1,19 @@
#pragma once
//using namespace std;
// using namespace std;
#include "XUI_Ctrl_ProgressCtrlBase.h"
class CXuiCtrlBrewProgress : public CXuiCtrlProgressCtrlBase
{
class CXuiCtrlBrewProgress : public CXuiCtrlProgressCtrlBase {
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlBrewProgress, L"CXuiCtrlBrewProgress", XUI_CLASS_PROGRESSBAR )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiCtrlBrewProgress, L"CXuiCtrlBrewProgress",
XUI_CLASS_PROGRESSBAR)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
virtual int GetValue();
virtual void GetRange(int *pnRangeMin, int *pnRangeMax);
virtual int GetValue();
virtual void GetRange(int* pnRangeMin, int* pnRangeMax);
};

View File

@@ -3,50 +3,47 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h"
#include "XUI_Ctrl_BubblesProgress.h"
int CXuiCtrlBubblesProgress::GetValue()
{
void* pvUserData;
this->GetUserData( &pvUserData );
int CXuiCtrlBubblesProgress::GetValue() {
void* pvUserData;
this->GetUserData(&pvUserData);
if( pvUserData != NULL )
{
BrewingStandTileEntity *pBrewingStandTileEntity = (BrewingStandTileEntity *)pvUserData;
if (pvUserData != NULL) {
BrewingStandTileEntity* pBrewingStandTileEntity =
(BrewingStandTileEntity*)pvUserData;
int value = 0;
int bubbleStep = (pBrewingStandTileEntity->getBrewTime() / 2) % 7;
switch (bubbleStep)
{
case 0:
value = 0;
break;
case 6:
value = 5;
break;
case 5:
value = 10;
break;
case 4:
value = 15;
break;
case 3:
value = 20;
break;
case 2:
value = 25;
break;
case 1:
value = 30;
break;
}
int value = 0;
int bubbleStep = (pBrewingStandTileEntity->getBrewTime() / 2) % 7;
switch (bubbleStep) {
case 0:
value = 0;
break;
case 6:
value = 5;
break;
case 5:
value = 10;
break;
case 4:
value = 15;
break;
case 3:
value = 20;
break;
case 2:
value = 25;
break;
case 1:
value = 30;
break;
}
return value;
}
return value;
}
return 0;
return 0;
}
void CXuiCtrlBubblesProgress::GetRange(int *pnRangeMin, int *pnRangeMax)
{
*pnRangeMin = 0;
*pnRangeMax = 30;
void CXuiCtrlBubblesProgress::GetRange(int* pnRangeMin, int* pnRangeMax) {
*pnRangeMin = 0;
*pnRangeMax = 30;
}

View File

@@ -1,19 +1,19 @@
#pragma once
//using namespace std;
// using namespace std;
#include "XUI_Ctrl_ProgressCtrlBase.h"
class CXuiCtrlBubblesProgress : public CXuiCtrlProgressCtrlBase
{
class CXuiCtrlBubblesProgress : public CXuiCtrlProgressCtrlBase {
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlBubblesProgress, L"CXuiCtrlBubblesProgress", XUI_CLASS_PROGRESSBAR )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiCtrlBubblesProgress, L"CXuiCtrlBubblesProgress",
XUI_CLASS_PROGRESSBAR)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
virtual int GetValue();
virtual void GetRange(int *pnRangeMin, int *pnRangeMax);
virtual int GetValue();
virtual void GetRange(int* pnRangeMin, int* pnRangeMax);
};

View File

@@ -5,25 +5,23 @@
#include "XUI_Scene_Furnace.h"
#include "XUI_Ctrl_BurnProgress.h"
int CXuiCtrlBurnProgress::GetValue()
{
void* pvUserData;
this->GetUserData( &pvUserData );
int CXuiCtrlBurnProgress::GetValue() {
void* pvUserData;
this->GetUserData(&pvUserData);
if( pvUserData != NULL )
{
FurnaceTileEntity *pFurnaceTileEntity = (FurnaceTileEntity *)pvUserData;
if (pvUserData != NULL) {
FurnaceTileEntity* pFurnaceTileEntity = (FurnaceTileEntity*)pvUserData;
// TODO This param is a magic number in Java but we should really define it somewhere with a name
// I think it is the number of states of the progress display (ie the max value)
return pFurnaceTileEntity->getBurnProgress( 24 );
}
// TODO This param is a magic number in Java but we should really define
// it somewhere with a name I think it is the number of states of the
// progress display (ie the max value)
return pFurnaceTileEntity->getBurnProgress(24);
}
return 0;
return 0;
}
void CXuiCtrlBurnProgress::GetRange(int *pnRangeMin, int *pnRangeMax)
{
*pnRangeMin = 0;
*pnRangeMax = 24;
void CXuiCtrlBurnProgress::GetRange(int* pnRangeMin, int* pnRangeMax) {
*pnRangeMin = 0;
*pnRangeMax = 24;
}

View File

@@ -1,19 +1,19 @@
#pragma once
//using namespace std;
// using namespace std;
#include "XUI_Ctrl_ProgressCtrlBase.h"
class CXuiCtrlBurnProgress : public CXuiCtrlProgressCtrlBase
{
class CXuiCtrlBurnProgress : public CXuiCtrlProgressCtrlBase {
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlBurnProgress, L"CXuiCtrlBurnProgress", XUI_CLASS_PROGRESSBAR )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiCtrlBurnProgress, L"CXuiCtrlBurnProgress",
XUI_CLASS_PROGRESSBAR)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
virtual int GetValue();
virtual void GetRange(int *pnRangeMin, int *pnRangeMax);
virtual int GetValue();
virtual void GetRange(int* pnRangeMin, int* pnRangeMax);
};

View File

@@ -8,116 +8,119 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
CXuiCtrlCraftIngredientSlot::CXuiCtrlCraftIngredientSlot()
{
m_iID=0;
m_Desc=NULL;
m_isFoil = false;
m_isDirty = false;
m_item = nullptr;
CXuiCtrlCraftIngredientSlot::CXuiCtrlCraftIngredientSlot() {
m_iID = 0;
m_Desc = NULL;
m_isFoil = false;
m_isDirty = false;
m_item = nullptr;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlCraftIngredientSlot::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
HRESULT hr=S_OK;
return hr;
HRESULT CXuiCtrlCraftIngredientSlot::OnInit(XUIMessageInit* pInitData,
BOOL& rfHandled) {
HRESULT hr = S_OK;
return hr;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlCraftIngredientSlot::OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled)
{
if( m_iID != 0 || m_item != NULL )
{
pData->item = m_item;
pData->iItemBitField = MAKE_SLOTDISPLAY_ITEM_BITMASK(m_iID,m_iAuxVal,m_isFoil);
pData->iDataBitField = MAKE_SLOTDISPLAY_DATA_BITMASK(m_iPad, m_uiAlpha,m_bDecorations,m_iCount,m_iScale,0);
}
else
{
pData->iDataBitField = 0;
pData->szPath = L"";
}
pData->bDirty = m_isDirty ? TRUE : FALSE;
m_isDirty = false;
HRESULT CXuiCtrlCraftIngredientSlot::OnCustomMessage_GetSlotItem(
CustomMessage_GetSlotItem_Struct* pData, BOOL& bHandled) {
if (m_iID != 0 || m_item != NULL) {
pData->item = m_item;
pData->iItemBitField =
MAKE_SLOTDISPLAY_ITEM_BITMASK(m_iID, m_iAuxVal, m_isFoil);
pData->iDataBitField = MAKE_SLOTDISPLAY_DATA_BITMASK(
m_iPad, m_uiAlpha, m_bDecorations, m_iCount, m_iScale, 0);
} else {
pData->iDataBitField = 0;
pData->szPath = L"";
}
pData->bDirty = m_isDirty ? TRUE : FALSE;
m_isDirty = false;
bHandled = TRUE;
return S_OK;
bHandled = TRUE;
return S_OK;
}
HRESULT CXuiCtrlCraftIngredientSlot::OnGetSourceText(XUIMessageGetSourceText *pGetSourceTextData,BOOL& bHandled)
{
pGetSourceTextData->szText=m_Desc;
bHandled = TRUE;
return S_OK;
HRESULT CXuiCtrlCraftIngredientSlot::OnGetSourceText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
pGetSourceTextData->szText = m_Desc;
bHandled = TRUE;
return S_OK;
}
void CXuiCtrlCraftIngredientSlot::SetRedBox(bool show)
{
HRESULT hr=S_OK;
void CXuiCtrlCraftIngredientSlot::SetRedBox(bool show) {
HRESULT hr = S_OK;
HXUIOBJ hObj,hObjChild;
hr=GetVisual(&hObj);
XuiElementGetChildById(hObj,L"BoxRed",&hObjChild);
XuiElementSetShow(hObjChild,show);
XuiElementGetChildById(hObj,L"Exclaim",&hObjChild);
XuiElementSetShow(hObjChild,show);
HXUIOBJ hObj, hObjChild;
hr = GetVisual(&hObj);
XuiElementGetChildById(hObj, L"BoxRed", &hObjChild);
XuiElementSetShow(hObjChild, show);
XuiElementGetChildById(hObj, L"Exclaim", &hObjChild);
XuiElementSetShow(hObjChild, show);
}
void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool isFoil, bool bShow)
{
m_item = nullptr;
m_iID=iId;
m_iAuxVal=iAuxVal;
// 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture
// rather than the dynamic one for the player
// not right... auxvals for diggables are damage values, can be a lot higher
if( (m_iAuxVal & 0xFF) == 0xFF && !( iId == Item::clock_Id || iId == Item::compass_Id ) ) // 4J Stu - If the aux value is set to match any
m_iAuxVal = 0;
void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, int iId, int iAuxVal,
int iCount, int iScale,
unsigned int uiAlpha,
bool bDecorations, bool isFoil,
bool bShow) {
m_item = nullptr;
m_iID = iId;
m_iAuxVal = iAuxVal;
// if the count comes in as 0, make it 1
m_iCount=iCount==0?1:iCount;
m_iScale=iScale;
m_uiAlpha=uiAlpha;
m_bDecorations=bDecorations;
m_isFoil = isFoil;
// 4J Stu - For clocks and compasses we set the aux value to a special one
// that signals we should use a default texture rather than the dynamic one
// for the player not right... auxvals for diggables are damage values, can
// be a lot higher
if ((m_iAuxVal & 0xFF) == 0xFF &&
!(iId == Item::clock_Id ||
iId == Item::compass_Id)) // 4J Stu - If the aux value is set to
// match any
m_iAuxVal = 0;
m_iPad = iPad;
m_isDirty = true;
// if the count comes in as 0, make it 1
m_iCount = iCount == 0 ? 1 : iCount;
m_iScale = iScale;
m_uiAlpha = uiAlpha;
m_bDecorations = bDecorations;
m_isFoil = isFoil;
XuiElementSetShow(m_hObj,bShow);
m_iPad = iPad;
m_isDirty = true;
XuiElementSetShow(m_hObj, bShow);
}
void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, std::shared_ptr<ItemInstance> item, int iScale, unsigned int uiAlpha,bool bDecorations, bool bShow)
{
if(item == NULL) SetIcon(iPad, 0,0,0,0,0,false,false,bShow);
else
{
m_item = item;
m_iID = item->id;
m_iScale = iScale;
m_uiAlpha = uiAlpha;
m_bDecorations = bDecorations;
void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad,
std::shared_ptr<ItemInstance> item,
int iScale, unsigned int uiAlpha,
bool bDecorations, bool bShow) {
if (item == NULL)
SetIcon(iPad, 0, 0, 0, 0, 0, false, false, bShow);
else {
m_item = item;
m_iID = item->id;
m_iScale = iScale;
m_uiAlpha = uiAlpha;
m_bDecorations = bDecorations;
m_iPad = iPad;
m_isDirty = true;
m_iPad = iPad;
m_isDirty = true;
XuiElementSetShow(m_hObj,bShow);
}
XuiElementSetShow(m_hObj, bShow);
}
}
void CXuiCtrlCraftIngredientSlot::SetDescription(LPCWSTR Desc)
{
HRESULT hr=S_OK;
void CXuiCtrlCraftIngredientSlot::SetDescription(LPCWSTR Desc) {
HRESULT hr = S_OK;
HXUIOBJ hObj,hObjChild;
hr=GetVisual(&hObj);
XuiElementGetChildById(hObj,L"text_name",&hObjChild);
XuiControlSetText(hObjChild,Desc);
XuiElementSetShow(hObjChild,Desc==NULL?FALSE:TRUE);
m_Desc=Desc;
HXUIOBJ hObj, hObjChild;
hr = GetVisual(&hObj);
XuiElementGetChildById(hObj, L"text_name", &hObjChild);
XuiControlSetText(hObjChild, Desc);
XuiElementSetShow(hObjChild, Desc == NULL ? FALSE : TRUE);
m_Desc = Desc;
}

View File

@@ -3,43 +3,47 @@
#include <string>
#include <XuiApp.h>
//-----------------------------------------------------------------------------
// CXuiCtrlMinecraftSlot class
//-----------------------------------------------------------------------------
class CXuiCtrlCraftIngredientSlot : public CXuiControlImpl
{
class CXuiCtrlCraftIngredientSlot : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlCraftIngredientSlot, L"CXuiCtrlCraftIngredientSlot", XUI_CLASS_LABEL)
XUI_IMPLEMENT_CLASS(CXuiCtrlCraftIngredientSlot,
L"CXuiCtrlCraftIngredientSlot", XUI_CLASS_LABEL)
CXuiCtrlCraftIngredientSlot();
virtual ~CXuiCtrlCraftIngredientSlot() {};
void SetRedBox(bool show);
void SetIcon(int iPad, int iId, int iAuxVal, int iCount, int iScale,
unsigned int uiAlpha, bool bDecorations, bool isFoil = false,
bool bShow = true);
void SetIcon(int iPad, std::shared_ptr<ItemInstance> item, int iScale,
unsigned int uiAlpha, bool bDecorations, bool bShow = true);
void SetDescription(LPCWSTR Desc);
CXuiCtrlCraftIngredientSlot();
virtual ~CXuiCtrlCraftIngredientSlot() { };
void SetRedBox(bool show);
void SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha, bool bDecorations, bool isFoil = false, bool bShow=true);
void SetIcon(int iPad, std::shared_ptr<ItemInstance> item, int iScale, unsigned int uiAlpha,bool bDecorations, bool bShow=true);
void SetDescription(LPCWSTR Desc);
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GETSLOTITEM_MESSAGE(OnCustomMessage_GetSlotItem)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GETSLOTITEM_MESSAGE(OnCustomMessage_GetSlotItem)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceText)
XUI_END_MSG_MAP()
HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled);
HRESULT OnGetSourceText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct* pData,
BOOL& bHandled);
HRESULT OnGetSourceText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
private:
std::shared_ptr<ItemInstance> m_item;
int m_iID;
int m_iAuxVal;
int m_iCount;
int m_iScale;
unsigned int m_uiAlpha;
int m_iPad;
bool m_bDecorations;
bool m_isFoil;
LPCWSTR m_Desc;
bool m_isDirty;
std::shared_ptr<ItemInstance> m_item;
int m_iID;
int m_iAuxVal;
int m_iCount;
int m_iScale;
unsigned int m_uiAlpha;
int m_iPad;
bool m_bDecorations;
bool m_isFoil;
LPCWSTR m_Desc;
bool m_isDirty;
};

View File

@@ -8,83 +8,77 @@
#include "XUI_Ctrl_EnchantButton.h"
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlEnchantmentButton::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
HRESULT hr=S_OK;
HRESULT CXuiCtrlEnchantmentButton::OnInit(XUIMessageInit* pInitData,
BOOL& rfHandled) {
HRESULT hr = S_OK;
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
HXUIOBJ parent = m_hObj;
HXUICLASS hcInventoryClass = XuiFindClass( L"CXuiSceneEnchant" );
HXUICLASS currentClass;
HXUIOBJ parent = m_hObj;
HXUICLASS hcInventoryClass = XuiFindClass(L"CXuiSceneEnchant");
HXUICLASS currentClass;
do
{
XuiElementGetParent(parent,&parent);
currentClass = XuiGetObjectClass( parent );
} while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) );
do {
XuiElementGetParent(parent, &parent);
currentClass = XuiGetObjectClass(parent);
} while (parent != NULL &&
!XuiClassDerivesFrom(currentClass, hcInventoryClass));
assert( parent != NULL );
assert(parent != NULL);
void *pObj;
XuiObjectFromHandle( parent, &pObj );
m_containerScene = (CXuiSceneEnchant *)pObj;
void* pObj;
XuiObjectFromHandle(parent, &pObj);
m_containerScene = (CXuiSceneEnchant*)pObj;
m_index = 0;
m_lastCost = 0;
m_iPad = 0;
m_costString = L"";
m_index = 0;
m_lastCost = 0;
m_iPad = 0;
m_costString = L"";
return hr;
return hr;
}
void CXuiCtrlEnchantmentButton::SetData(int iPad, int index)
{
m_iPad = iPad;
m_index = index;
void CXuiCtrlEnchantmentButton::SetData(int iPad, int index) {
m_iPad = iPad;
m_index = index;
}
HRESULT CXuiCtrlEnchantmentButton::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled)
{
EnchantmentMenu *menu = m_containerScene->getMenu();
HRESULT CXuiCtrlEnchantmentButton::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
EnchantmentMenu* menu = m_containerScene->getMenu();
int cost = menu->costs[m_index];
int cost = menu->costs[m_index];
if(cost != m_lastCost)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
if(cost > pMinecraft->localplayers[m_iPad]->experienceLevel && !pMinecraft->localplayers[m_iPad]->abilities.instabuild)
{
// Dark background
SetEnable(FALSE);
}
else
{
// Light background and focus background
SetEnable(TRUE);
}
m_costString = _toString<int>(cost);
m_lastCost = cost;
}
if(cost == 0)
{
// Dark background
SetEnable(FALSE);
pGetSourceTextData->bDisplay = FALSE;
}
else
{
pGetSourceTextData->szText = m_costString.c_str();
pGetSourceTextData->bDisplay = TRUE;
}
if (cost != m_lastCost) {
Minecraft* pMinecraft = Minecraft::GetInstance();
if (cost > pMinecraft->localplayers[m_iPad]->experienceLevel &&
!pMinecraft->localplayers[m_iPad]->abilities.instabuild) {
// Dark background
SetEnable(FALSE);
} else {
// Light background and focus background
SetEnable(TRUE);
}
m_costString = _toString<int>(cost);
m_lastCost = cost;
}
if (cost == 0) {
// Dark background
SetEnable(FALSE);
pGetSourceTextData->bDisplay = FALSE;
} else {
pGetSourceTextData->szText = m_costString.c_str();
pGetSourceTextData->bDisplay = TRUE;
}
bHandled = TRUE;
bHandled = TRUE;
return S_OK;
return S_OK;
}

View File

@@ -2,32 +2,33 @@
class CXuiSceneEnchant;
class CXuiCtrlEnchantmentButton : public CXuiControlImpl
{
friend class CXuiCtrlEnchantmentButtonText;
class CXuiCtrlEnchantmentButton : public CXuiControlImpl {
friend class CXuiCtrlEnchantmentButtonText;
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlEnchantmentButton, L"CXuiCtrlEnchantmentButton", XUI_CLASS_CONTROL)
XUI_IMPLEMENT_CLASS(CXuiCtrlEnchantmentButton, L"CXuiCtrlEnchantmentButton",
XUI_CLASS_CONTROL)
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
public:
void SetData(int iPad, int index);
void SetData(int iPad, int index);
private:
int m_iPad;
int m_index;
int m_lastCost;
std::wstring m_costString;
CXuiSceneEnchant *m_containerScene;
int m_iPad;
int m_index;
int m_lastCost;
std::wstring m_costString;
CXuiSceneEnchant* m_containerScene;
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
};

View File

@@ -22,133 +22,133 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
CXuiCtrlEnchantmentBook::CXuiCtrlEnchantmentBook() :
m_bDirty(false),
m_fScale(1.0f),
m_fAlpha(1.0f)
{
Minecraft *pMinecraft=Minecraft::GetInstance();
CXuiCtrlEnchantmentBook::CXuiCtrlEnchantmentBook()
: m_bDirty(false), m_fScale(1.0f), m_fAlpha(1.0f) {
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
model = NULL;
model = NULL;
time = 0;
flip = oFlip = flipT = flipA = 0.0f;
open = oOpen = 0.0f;
time = 0;
flip = oFlip = flipT = flipA = 0.0f;
open = oOpen = 0.0f;
}
CXuiCtrlEnchantmentBook::~CXuiCtrlEnchantmentBook()
{
//if(model != NULL) delete model;
CXuiCtrlEnchantmentBook::~CXuiCtrlEnchantmentBook() {
// if(model != NULL) delete model;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlEnchantmentBook::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
HRESULT hr=S_OK;
HRESULT CXuiCtrlEnchantmentBook::OnInit(XUIMessageInit* pInitData,
BOOL& rfHandled) {
HRESULT hr = S_OK;
HXUIOBJ parent = m_hObj;
HXUICLASS hcInventoryClass = XuiFindClass( L"CXuiSceneEnchant" );
HXUICLASS currentClass;
HXUIOBJ parent = m_hObj;
HXUICLASS hcInventoryClass = XuiFindClass(L"CXuiSceneEnchant");
HXUICLASS currentClass;
do
{
XuiElementGetParent(parent,&parent);
currentClass = XuiGetObjectClass( parent );
} while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) );
do {
XuiElementGetParent(parent, &parent);
currentClass = XuiGetObjectClass(parent);
} while (parent != NULL &&
!XuiClassDerivesFrom(currentClass, hcInventoryClass));
assert( parent != NULL );
assert(parent != NULL);
void *pObj;
XuiObjectFromHandle( parent, &pObj );
m_containerScene = (CXuiSceneEnchant *)pObj;
void* pObj;
XuiObjectFromHandle(parent, &pObj);
m_containerScene = (CXuiSceneEnchant*)pObj;
last = nullptr;
last = nullptr;
m_iPad = m_containerScene->getPad();
m_iPad = m_containerScene->getPad();
return hr;
return hr;
}
HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL &bHandled )
{
HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender* pRenderData,
BOOL& bHandled) {
#ifdef _XBOX
HXUIDC hDC = pRenderData->hDC;
HXUIDC hDC = pRenderData->hDC;
// build and render with the game call
// build and render with the game call
RenderManager.Set_matrixDirty();
RenderManager.Set_matrixDirty();
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
float alpha = 1.0f;
//GetOpacity( &alpha );
float alpha = 1.0f;
// GetOpacity( &alpha );
D3DXMATRIX matrix;
GetFullXForm(&matrix);
D3DXMATRIX matrix;
GetFullXForm(&matrix);
float bwidth, bheight;
GetBounds(&bwidth, &bheight);
float bwidth,bheight;
GetBounds(&bwidth,&bheight);
glColor4f(1, 1, 1, alpha);
glColor4f(1, 1, 1, alpha);
// Annoyingly, XUI renders everything to a z of 0 so if we want to render
// anything that needs the z-buffer on top of it, then we need to clear it.
// Clear just the region required for this control.
D3DRECT clearRect;
clearRect.x1 = (int)(matrix._41) - 2;
clearRect.y1 = (int)(matrix._42) - 2;
clearRect.x2 = (int)(matrix._41 + (bwidth * matrix._11)) + 2;
clearRect.y2 = (int)(matrix._42 + (bheight * matrix._22)) + 2;
// Annoyingly, XUI renders everything to a z of 0 so if we want to render anything that needs the z-buffer on top of it, then we need to clear it.
// Clear just the region required for this control.
D3DRECT clearRect;
clearRect.x1 = (int)(matrix._41) - 2;
clearRect.y1 = (int)(matrix._42) - 2;
clearRect.x2 = (int)(matrix._41 + ( bwidth * matrix._11 )) + 2;
clearRect.y2 = (int)(matrix._42 + ( bheight * matrix._22 )) + 2;
RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &clearRect);
RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &clearRect);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fRawWidth, m_fRawHeight, 0, 1000, 3000);
// gluPerspective(90, (float) (320 / 240.0f), 0.5f, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fRawWidth, m_fRawHeight, 0, 1000, 3000);
//gluPerspective(90, (float) (320 / 240.0f), 0.5f, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
float xo = ((matrix._41 + ((bwidth * matrix._11) / 2)) / m_fScreenWidth) *
m_fRawWidth;
float yo = ((matrix._42 + ((bheight * matrix._22) / 2)) / m_fScreenHeight) *
m_fRawHeight;
float xo = ( (matrix._41 + ( (bwidth*matrix._11)/2) ) / m_fScreenWidth ) * m_fRawWidth;
float yo = ( (matrix._42 + ((bheight*matrix._22)/2) ) / m_fScreenHeight ) * m_fRawHeight;
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
glTranslatef(xo, yo, 50.0f);
float ss;
glPushMatrix();
glTranslatef(xo, yo, 50.0f);
float ss;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
ss = (((bheight * matrix._22) / m_fScreenHeight) * m_fRawHeight) * 1.5f;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
ss = ( ( (bheight*matrix._22) / m_fScreenHeight ) * m_fRawHeight ) * 1.5f;
glScalef(-ss, ss, ss);
// glRotatef(180, 0, 0, 1);
glScalef(-ss, ss, ss);
//glRotatef(180, 0, 0, 1);
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
// float sss = 4;
//float sss = 4;
// glTranslatef(0, 3.3f, -16);
// glScalef(sss, sss, sss);
//glTranslatef(0, 3.3f, -16);
//glScalef(sss, sss, sss);
int tex = pMinecraft->textures->loadTexture(TN_ITEM_BOOK); // 4J was L"/1_2_2/item/book.png"
int tex = pMinecraft->textures->loadTexture(
TN_ITEM_BOOK); // 4J was L"/1_2_2/item/book.png"
pMinecraft->textures->bind(tex);
glRotatef(20, 1, 0, 0);
float a = 1;
float a = 1;
float o = oOpen + (open - oOpen) * a;
glTranslatef((1 - o) * 0.2f, (1 - o) * 0.1f, (1 - o) * 0.25f);
glRotatef(-(1 - o) * 90 - 90, 0, 1, 0);
@@ -164,44 +164,43 @@ HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL &b
if (ff1 > 1) ff1 = 1;
if (ff2 > 1) ff2 = 1;
glEnable(GL_CULL_FACE);
glEnable(GL_CULL_FACE);
if(model == NULL)
{
// Share the model the the EnchantTableRenderer
if (model == NULL) {
// Share the model the the EnchantTableRenderer
EnchantTableRenderer *etr = (EnchantTableRenderer*)TileEntityRenderDispatcher::instance->getRenderer(eTYPE_ENCHANTMENTTABLEENTITY);
if(etr != NULL)
{
model = etr->bookModel;
}
else
{
model = new BookModel();
}
}
EnchantTableRenderer* etr =
(EnchantTableRenderer*)TileEntityRenderDispatcher::instance
->getRenderer(eTYPE_ENCHANTMENTTABLEENTITY);
if (etr != NULL) {
model = etr->bookModel;
} else {
model = new BookModel();
}
}
model->render(NULL, 0, ff1, ff2, o, 0, 1 / 16.0f,true);
glDisable(GL_CULL_FACE);
model->render(NULL, 0, ff1, ff2, o, 0, 1 / 16.0f, true);
glDisable(GL_CULL_FACE);
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
XuiRenderRestoreState(hDC);
XuiRenderRestoreState(hDC);
tickBook();
tickBook();
bHandled = TRUE;
bHandled = TRUE;
#endif
return S_OK;
return S_OK;
}
//HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL &bHandled )
// HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL
// &bHandled )
//{
// HXUIDC hDC = pRenderData->hDC;
//
//
// RenderManager.Set_matrixDirty();
//
// Minecraft *minecraft = Minecraft::GetInstance();
@@ -224,75 +223,80 @@ HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL &b
// parent.GetParent(&scene);
// scene.GetPosition(&vecPP);
//
// float xo = ( (matrix._41 + ( (bwidth*matrix._11)/2) ) / m_fScreenWidth ) * m_fRawWidth;
// float yo = ( (matrix._42 + (bheight*matrix._22) ) / m_fScreenHeight ) * m_fRawHeight;
// float xo = ( (matrix._41 + ( (bwidth*matrix._11)/2) ) / m_fScreenWidth )
//* m_fRawWidth; float yo = ( (matrix._42 + (bheight*matrix._22) ) /
//m_fScreenHeight ) * m_fRawHeight;
//
// glColor4f(1, 1, 1, 1);
// glColor4f(1, 1, 1, 1);
//
// glPushMatrix();
// glMatrixMode(GL_PROJECTION);
// glPushMatrix();
// glLoadIdentity();
// glPushMatrix();
// glMatrixMode(GL_PROJECTION);
// glPushMatrix();
// glLoadIdentity();
//
// ScreenSizeCalculator ssc = ScreenSizeCalculator(minecraft->options, minecraft->width, minecraft->height);
// ScreenSizeCalculator ssc = ScreenSizeCalculator(minecraft->options,
// minecraft->width, minecraft->height);
//
// //glViewport((int) (ssc.getWidth() - 320) / 2 * ssc.scale, (int) (ssc.getHeight() - 240) / 2 * ssc.scale, (int) (320 * ssc.scale), (int) (240 * ssc.scale));
// //glViewport((int) (ssc.getWidth() - 320) / 2 * ssc.scale, (int)
// (ssc.getHeight() - 240) / 2 * ssc.scale, (int) (320 * ssc.scale), (int)
// (240 * ssc.scale));
//
// // 4J JEV: Trying to position it within the XUI element
// float xPos, yPos;
// xPos = (vec.x + vecP.x + vecPP.x) / (minecraft->width/2); xPos = xPos - 1; xPos = 2*xPos/3;
// yPos = (vec.y + vecP.y + vecPP.y) / (minecraft->height/2); yPos = 1 - yPos; yPos = 2*yPos/3;
// glTranslatef(xPos, yPos, 0);
// xPos = (vec.x + vecP.x + vecPP.x) / (minecraft->width/2); xPos = xPos -
//1; xPos = 2*xPos/3; yPos = (vec.y + vecP.y + vecPP.y) / (minecraft->height/2);
//yPos = 1 - yPos; yPos = 2*yPos/3; glTranslatef(xPos, yPos, 0);
//
// gluPerspective(90, (float) (320 / 240.0f), 9, 80);
// gluPerspective(90, (float) (320 / 240.0f), 9, 80);
//
// float sss = 1;
// glMatrixMode(GL_MODELVIEW);
// glLoadIdentity();
// Lighting::turnOn();
// float sss = 1;
// glMatrixMode(GL_MODELVIEW);
// glLoadIdentity();
// Lighting::turnOn();
//
// glTranslatef(0, 3.3f, -16);
// glScalef(sss, sss, sss);
// glTranslatef(0, 3.3f, -16);
// glScalef(sss, sss, sss);
//
// float ss = 5;
// float ss = 5;
//
// glScalef(ss, ss, ss);
// glRotatef(180, 0, 0, 1);
// glScalef(ss, ss, ss);
// glRotatef(180, 0, 0, 1);
//
// int tex = minecraft->textures->loadTexture(TN_ITEM_BOOK); // 4J was L"/1_2_2/item/book.png"
// minecraft->textures->bind(tex);
// int tex = minecraft->textures->loadTexture(TN_ITEM_BOOK); // 4J was
//L"/1_2_2/item/book.png"
// minecraft->textures->bind(tex);
//
// glRotatef(20, 1, 0, 0);
// glRotatef(20, 1, 0, 0);
//
// float o = oOpen + (open - oOpen) * a;
// glTranslatef((1 - o) * 0.2f, (1 - o) * 0.1f, (1 - o) * 0.25f);
// glRotatef(-(1 - o) * 90 - 90, 0, 1, 0);
// glRotatef(180, 1, 0, 0);
// float o = oOpen + (open - oOpen) * a;
// glTranslatef((1 - o) * 0.2f, (1 - o) * 0.1f, (1 - o) * 0.25f);
// glRotatef(-(1 - o) * 90 - 90, 0, 1, 0);
// glRotatef(180, 1, 0, 0);
//
// float ff1 = oFlip + (flip - oFlip) * a + 0.25f;
// float ff2 = oFlip + (flip - oFlip) * a + 0.75f;
// ff1 = (ff1 - floor(ff1)) * 1.6f - 0.3f;
// ff2 = (ff2 - floor(ff2)) * 1.6f - 0.3f;
// float ff1 = oFlip + (flip - oFlip) * a + 0.25f;
// float ff2 = oFlip + (flip - oFlip) * a + 0.75f;
// ff1 = (ff1 - floor(ff1)) * 1.6f - 0.3f;
// ff2 = (ff2 - floor(ff2)) * 1.6f - 0.3f;
//
// if (ff1 < 0) ff1 = 0;
// if (ff2 < 0) ff2 = 0;
// if (ff1 > 1) ff1 = 1;
// if (ff2 > 1) ff2 = 1;
// if (ff1 < 0) ff1 = 0;
// if (ff2 < 0) ff2 = 0;
// if (ff1 > 1) ff1 = 1;
// if (ff2 > 1) ff2 = 1;
//
// glEnable(GL_RESCALE_NORMAL);
// glEnable(GL_RESCALE_NORMAL);
//
// model.render(NULL, 0, ff1, ff2, o, 0, 1 / 16.0f,true);
// model.render(NULL, 0, ff1, ff2, o, 0, 1 / 16.0f,true);
//
// glDisable(GL_RESCALE_NORMAL);
// Lighting::turnOff();
// glMatrixMode(GL_PROJECTION);
// //glViewport(0, 0, minecraft->width, minecraft->height);
// glPopMatrix();
// glMatrixMode(GL_MODELVIEW);
// glPopMatrix();
// glDisable(GL_RESCALE_NORMAL);
// Lighting::turnOff();
// glMatrixMode(GL_PROJECTION);
// //glViewport(0, 0, minecraft->width, minecraft->height);
// glPopMatrix();
// glMatrixMode(GL_MODELVIEW);
// glPopMatrix();
//
// Lighting::turnOff();
// glColor4f(1, 1, 1, 1);
// Lighting::turnOff();
// glColor4f(1, 1, 1, 1);
//
// XuiRenderRestoreState(hDC);
//
@@ -301,41 +305,37 @@ HRESULT CXuiCtrlEnchantmentBook::OnRender(XUIMessageRender *pRenderData, BOOL &b
// bHandled = TRUE;
//
// return S_OK;
//}
// }
void CXuiCtrlEnchantmentBook::tickBook()
{
EnchantmentMenu *menu = m_containerScene->getMenu();
std::shared_ptr<ItemInstance> current = menu->getSlot(0)->getItem();
if (!ItemInstance::matches(current, last))
{
void CXuiCtrlEnchantmentBook::tickBook() {
EnchantmentMenu* menu = m_containerScene->getMenu();
std::shared_ptr<ItemInstance> current = menu->getSlot(0)->getItem();
if (!ItemInstance::matches(current, last)) {
last = current;
do
{
flipT += random.nextInt(4) - random.nextInt(4);
} while (flip <= flipT + 1 && flip >= flipT - 1);
do {
flipT += random.nextInt(4) - random.nextInt(4);
} while (flip <= flipT + 1 && flip >= flipT - 1);
}
time++;
oFlip = flip;
oOpen = open;
bool shouldBeOpen = false;
for (int i = 0; i < 3; i++)
{
if (menu->costs[i] != 0)
{
bool shouldBeOpen = false;
for (int i = 0; i < 3; i++) {
if (menu->costs[i] != 0) {
shouldBeOpen = true;
}
}
}
if (shouldBeOpen) open += 0.2f;
else open -= 0.2f;
if (shouldBeOpen)
open += 0.2f;
else
open -= 0.2f;
if (open < 0) open = 0;
if (open > 1) open = 1;
float diff = (flipT - flip) * 0.4f;
float max = 0.2f;
if (diff < -max) diff = -max;

View File

@@ -1,7 +1,7 @@
#pragma once
#include "../../Minecraft.World/Util/Random.h"
//using namespace std;
// using namespace std;
class CXuiSceneEnchant;
class BookModel;
@@ -9,43 +9,43 @@ class BookModel;
//-----------------------------------------------------------------------------
// CXuiCtrlEnchantPanel class
//-----------------------------------------------------------------------------
class CXuiCtrlEnchantmentBook : public CXuiControlImpl
{
class CXuiCtrlEnchantmentBook : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlEnchantmentBook, L"CXuiCtrlEnchantmentBook", XUI_CLASS_LABEL)
XUI_IMPLEMENT_CLASS(CXuiCtrlEnchantmentBook, L"CXuiCtrlEnchantmentBook",
XUI_CLASS_LABEL)
CXuiCtrlEnchantmentBook();
virtual ~CXuiCtrlEnchantmentBook();
CXuiCtrlEnchantmentBook();
virtual ~CXuiCtrlEnchantmentBook();
void setChanged();
void setOpen(bool);
void setChanged();
void setOpen(bool);
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender *pRenderData, BOOL &rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender* pRenderData, BOOL& rfHandled);
private:
BookModel *model;
Random random;
BookModel* model;
Random random;
// 4J JEV: Book animation variables.
int time;
// 4J JEV: Book animation variables.
int time;
float flip, oFlip, flipT, flipA;
float open, oOpen;
bool m_bDirty;
float m_fScale,m_fAlpha;
int m_iPad;
CXuiSceneEnchant *m_containerScene;
std::shared_ptr<ItemInstance> last;
bool m_bDirty;
float m_fScale, m_fAlpha;
int m_iPad;
CXuiSceneEnchant* m_containerScene;
std::shared_ptr<ItemInstance> last;
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
void tickBook();
void tickBook();
};

View File

@@ -18,168 +18,171 @@
#include <iterator>
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlEnchantmentButtonText::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
HRESULT hr=S_OK;
HRESULT CXuiCtrlEnchantmentButtonText::OnInit(XUIMessageInit* pInitData,
BOOL& rfHandled) {
HRESULT hr = S_OK;
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
HXUIOBJ parent = m_hObj;
HXUICLASS hcInventoryClass = XuiFindClass( L"CXuiCtrlEnchantmentButton" );
HXUICLASS currentClass;
HXUIOBJ parent = m_hObj;
HXUICLASS hcInventoryClass = XuiFindClass(L"CXuiCtrlEnchantmentButton");
HXUICLASS currentClass;
do
{
XuiElementGetParent(parent,&parent);
currentClass = XuiGetObjectClass( parent );
} while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) );
do {
XuiElementGetParent(parent, &parent);
currentClass = XuiGetObjectClass(parent);
} while (parent != NULL &&
!XuiClassDerivesFrom(currentClass, hcInventoryClass));
assert( parent != NULL );
assert(parent != NULL);
void *pObj;
XuiObjectFromHandle( parent, &pObj );
m_parentControl = (CXuiCtrlEnchantmentButton *)pObj;
void* pObj;
XuiObjectFromHandle(parent, &pObj);
m_parentControl = (CXuiCtrlEnchantmentButton*)pObj;
m_lastCost = 0;
m_enchantmentString = L"";
m_lastCost = 0;
m_enchantmentString = L"";
m_textColour = app.GetHTMLColour(eTextColor_Enchant);
m_textFocusColour = app.GetHTMLColour(eTextColor_EnchantFocus);
m_textDisabledColour = app.GetHTMLColour(eTextColor_EnchantDisabled);
m_textColour = app.GetHTMLColour(eTextColor_Enchant);
m_textFocusColour = app.GetHTMLColour(eTextColor_EnchantFocus);
m_textDisabledColour = app.GetHTMLColour(eTextColor_EnchantDisabled);
return hr;
return hr;
}
HRESULT CXuiCtrlEnchantmentButtonText::OnRender(XUIMessageRender *pRenderData, BOOL &bHandled )
{
HXUIDC hDC = pRenderData->hDC;
CXuiControl xuiControl(m_hObj);
HRESULT CXuiCtrlEnchantmentButtonText::OnRender(XUIMessageRender* pRenderData,
BOOL& bHandled) {
HXUIDC hDC = pRenderData->hDC;
CXuiControl xuiControl(m_hObj);
// build and render with the game call
// build and render with the game call
RenderManager.Set_matrixDirty();
RenderManager.Set_matrixDirty();
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
D3DXMATRIX matrix;
xuiControl.GetFullXForm(&matrix);
float bwidth,bheight;
xuiControl.GetBounds(&bwidth,&bheight);
D3DXMATRIX matrix;
xuiControl.GetFullXForm(&matrix);
float bwidth, bheight;
xuiControl.GetBounds(&bwidth, &bheight);
// Annoyingly, XUI renders everything to a z of 0 so if we want to render anything that needs the z-buffer on top of it, then we need to clear it.
// Clear just the region required for this control.
D3DRECT clearRect;
clearRect.x1 = (int)(matrix._41) - 2;
clearRect.y1 = (int)(matrix._42) - 2;
clearRect.x2 = (int)(matrix._41 + ( bwidth * matrix._11 )) + 2;
clearRect.y2 = (int)(matrix._42 + ( bheight * matrix._22 )) + 2;
// Annoyingly, XUI renders everything to a z of 0 so if we want to render
// anything that needs the z-buffer on top of it, then we need to clear it.
// Clear just the region required for this control.
D3DRECT clearRect;
clearRect.x1 = (int)(matrix._41) - 2;
clearRect.y1 = (int)(matrix._42) - 2;
clearRect.x2 = (int)(matrix._41 + (bwidth * matrix._11)) + 2;
clearRect.y2 = (int)(matrix._42 + (bheight * matrix._22)) + 2;
RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &clearRect);
// glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fScreenWidth, m_fScreenHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &clearRect);
// glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fScreenWidth, m_fScreenHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
glEnable(GL_RESCALE_NORMAL);
glPushMatrix();
glRotatef(120, 1, 0, 0);
// Lighting::turnOnGui();
glPopMatrix();
glEnable(GL_RESCALE_NORMAL);
glPushMatrix();
glRotatef(120, 1, 0, 0);
//Lighting::turnOnGui();
glPopMatrix();
EnchantmentMenu* menu = m_parentControl->m_containerScene->getMenu();
float xo = matrix._41;
float yo = matrix._42;
glTranslatef(xo, yo, 50.0f);
float ss = 1;
EnchantmentMenu *menu = m_parentControl->m_containerScene->getMenu();
if (!m_parentControl->m_containerScene->m_bSplitscreen) {
ss = 2;
}
float xo = matrix._41;
float yo = matrix._42;
glTranslatef(xo, yo, 50.0f);
glScalef(ss, ss, ss);
float ss = 1;
int cost = menu->costs[m_parentControl->m_index];
if(!m_parentControl->m_containerScene->m_bSplitscreen)
{
ss = 2;
}
if (cost != m_lastCost) {
m_lastCost = cost;
m_enchantmentString = EnchantmentNames::instance.getRandomName();
}
glScalef(ss, ss, ss);
glColor4f(1, 1, 1, 1);
if (cost != 0) {
std::wstring line = _toString<int>(cost);
Font* font = pMinecraft->altFont;
// int col = 0x685E4A;
unsigned int col = m_textColour;
if (pMinecraft->localplayers[m_parentControl->m_iPad]->experienceLevel <
cost &&
!pMinecraft->localplayers[m_parentControl->m_iPad]
->abilities.instabuild) {
col = m_textDisabledColour;
font->drawWordWrap(m_enchantmentString, 0, 0, bwidth / ss, col,
bheight / ss);
font = pMinecraft->font;
// col = (0x80ff20 & 0xfefefe) >> 1;
// font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col);
} else {
if (m_parentControl->HasFocus()) {
// col = 0xffff80;
col = m_textFocusColour;
}
font->drawWordWrap(m_enchantmentString, 0, 0, bwidth / ss, col,
bheight / ss);
font = pMinecraft->font;
// col = 0x80ff20;
// font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col);
}
} else {
}
int cost = menu->costs[m_parentControl->m_index];
// Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
if(cost != m_lastCost)
{
m_lastCost = cost;
m_enchantmentString = EnchantmentNames::instance.getRandomName();
}
XuiRenderRestoreState(hDC);
glColor4f(1, 1, 1, 1);
if (cost != 0)
{
std::wstring line = _toString<int>(cost);
Font *font = pMinecraft->altFont;
//int col = 0x685E4A;
unsigned int col = m_textColour;
if (pMinecraft->localplayers[m_parentControl->m_iPad]->experienceLevel < cost && !pMinecraft->localplayers[m_parentControl->m_iPad]->abilities.instabuild)
{
col = m_textDisabledColour;
font->drawWordWrap(m_enchantmentString, 0, 0, bwidth/ss, col, bheight/ss);
font = pMinecraft->font;
//col = (0x80ff20 & 0xfefefe) >> 1;
//font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col);
}
else
{
if (m_parentControl->HasFocus())
{
//col = 0xffff80;
col = m_textFocusColour;
}
font->drawWordWrap(m_enchantmentString, 0, 0, bwidth/ss, col, bheight/ss);
font = pMinecraft->font;
//col = 0x80ff20;
//font->drawShadow(line, (bwidth - font->width(line))/ss, 7, col);
}
}
else
{
}
bHandled = TRUE;
//Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
XuiRenderRestoreState(hDC);
bHandled = TRUE;
return S_OK;
return S_OK;
}
CXuiCtrlEnchantmentButtonText::EnchantmentNames CXuiCtrlEnchantmentButtonText::EnchantmentNames::instance;
CXuiCtrlEnchantmentButtonText::EnchantmentNames
CXuiCtrlEnchantmentButtonText::EnchantmentNames::instance;
CXuiCtrlEnchantmentButtonText::EnchantmentNames::EnchantmentNames()
{
std::wstring allWords = L"the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale ";
std::wistringstream iss(allWords);
std::copy(std::istream_iterator< std::wstring, wchar_t, std::char_traits<wchar_t> >(iss), std::istream_iterator< std::wstring, wchar_t, std::char_traits<wchar_t> >(),std::back_inserter(words));
CXuiCtrlEnchantmentButtonText::EnchantmentNames::EnchantmentNames() {
std::wstring allWords =
L"the elder scrolls klaatu berata niktu xyzzy bless curse light "
L"darkness fire air earth water hot dry cold wet ignite snuff embiggen "
L"twist shorten stretch fiddle destroy imbue galvanize enchant free "
L"limited range of towards inside sphere cube self other ball mental "
L"physical grow shrink demon elemental spirit animal creature beast "
L"humanoid undead fresh stale ";
std::wistringstream iss(allWords);
std::copy(std::istream_iterator<std::wstring, wchar_t,
std::char_traits<wchar_t> >(iss),
std::istream_iterator<std::wstring, wchar_t,
std::char_traits<wchar_t> >(),
std::back_inserter(words));
}
std::wstring CXuiCtrlEnchantmentButtonText::EnchantmentNames::getRandomName()
{
int wordCount = random.nextInt(2) + 3;
std::wstring word = L"";
for (int i = 0; i < wordCount; i++)
{
if (i > 0) word += L" ";
word += words[random.nextInt(words.size())];
}
return word;
std::wstring CXuiCtrlEnchantmentButtonText::EnchantmentNames::getRandomName() {
int wordCount = random.nextInt(2) + 3;
std::wstring word = L"";
for (int i = 0; i < wordCount; i++) {
if (i > 0) word += L" ";
word += words[random.nextInt(words.size())];
}
return word;
}

View File

@@ -2,44 +2,42 @@
class CXuiSceneEnchant;
class CXuiCtrlEnchantmentButtonText : public CXuiControlImpl
{
class CXuiCtrlEnchantmentButtonText : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlEnchantmentButtonText, L"CXuiCtrlEnchantmentButtonText", XUI_CLASS_CONTROL)
XUI_IMPLEMENT_CLASS(CXuiCtrlEnchantmentButtonText,
L"CXuiCtrlEnchantmentButtonText", XUI_CLASS_CONTROL)
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender *pRenderData, BOOL &rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender* pRenderData, BOOL& rfHandled);
private:
CXuiCtrlEnchantmentButton *m_parentControl;
CXuiCtrlEnchantmentButton* m_parentControl;
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
int m_lastCost;
std::wstring m_enchantmentString;
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
unsigned int m_textColour, m_textFocusColour, m_textDisabledColour;
int m_lastCost;
std::wstring m_enchantmentString;
class EnchantmentNames
{
public:
static EnchantmentNames instance;
unsigned int m_textColour, m_textFocusColour, m_textDisabledColour;
private:
Random random;
std::vector<std::wstring> words;
class EnchantmentNames {
public:
static EnchantmentNames instance;
EnchantmentNames();
private:
Random random;
std::vector<std::wstring> words;
public:
std::wstring getRandomName();
};
EnchantmentNames();
public:
std::wstring getRandomName();
};
};

View File

@@ -5,25 +5,23 @@
#include "XUI_Scene_Furnace.h"
#include "XUI_Ctrl_FireProgress.h"
int CXuiCtrlFireProgress::GetValue()
{
void* pvUserData;
this->GetUserData( &pvUserData );
int CXuiCtrlFireProgress::GetValue() {
void* pvUserData;
this->GetUserData(&pvUserData);
if( pvUserData != NULL )
{
FurnaceTileEntity *pFurnaceTileEntity = (FurnaceTileEntity *)pvUserData;
if (pvUserData != NULL) {
FurnaceTileEntity* pFurnaceTileEntity = (FurnaceTileEntity*)pvUserData;
// TODO This param is a magic number in Java but we should really define it somewhere with a name
// I think it is the number of states of the progress display (ie the max value)
return pFurnaceTileEntity->getLitProgress( 12 );
}
// TODO This param is a magic number in Java but we should really define
// it somewhere with a name I think it is the number of states of the
// progress display (ie the max value)
return pFurnaceTileEntity->getLitProgress(12);
}
return 0;
return 0;
}
void CXuiCtrlFireProgress::GetRange(int *pnRangeMin, int *pnRangeMax)
{
*pnRangeMin = 0;
*pnRangeMax = 12;
void CXuiCtrlFireProgress::GetRange(int* pnRangeMin, int* pnRangeMax) {
*pnRangeMin = 0;
*pnRangeMax = 12;
}

View File

@@ -1,19 +1,19 @@
#pragma once
//using namespace std;
// using namespace std;
#include "XUI_Ctrl_ProgressCtrlBase.h"
class CXuiCtrlFireProgress : public CXuiCtrlProgressCtrlBase
{
class CXuiCtrlFireProgress : public CXuiCtrlProgressCtrlBase {
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlFireProgress, L"CXuiCtrlFireProgress", XUI_CLASS_PROGRESSBAR )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiCtrlFireProgress, L"CXuiCtrlFireProgress",
XUI_CLASS_PROGRESSBAR)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
virtual int GetValue();
virtual void GetRange(int *pnRangeMin, int *pnRangeMax);
virtual int GetValue();
virtual void GetRange(int* pnRangeMin, int* pnRangeMax);
};

View File

@@ -4,18 +4,16 @@
#include "../../Minecraft.Client/Minecraft.h"
#include "../../Minecraft.Client/Rendering/EntityRenderers/ProgressRenderer.h"
int CXuiCtrlLoadingProgress::GetValue()
{
int currentValue = 0;
int CXuiCtrlLoadingProgress::GetValue() {
int currentValue = 0;
Minecraft *pMinecraft=Minecraft::GetInstance();
currentValue = pMinecraft->progressRenderer->getCurrentPercent();
//printf("About to render progress of %d\n", currentValue);
return currentValue;
Minecraft* pMinecraft = Minecraft::GetInstance();
currentValue = pMinecraft->progressRenderer->getCurrentPercent();
// printf("About to render progress of %d\n", currentValue);
return currentValue;
}
void CXuiCtrlLoadingProgress::GetRange(int *pnRangeMin, int *pnRangeMax)
{
*pnRangeMin = 0;
*pnRangeMax = 100;
void CXuiCtrlLoadingProgress::GetRange(int* pnRangeMin, int* pnRangeMax) {
*pnRangeMin = 0;
*pnRangeMax = 100;
}

View File

@@ -2,17 +2,17 @@
#include "XUI_Ctrl_ProgressCtrlBase.h"
class CXuiCtrlLoadingProgress : public CXuiCtrlProgressCtrlBase
{
class CXuiCtrlLoadingProgress : public CXuiCtrlProgressCtrlBase {
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlLoadingProgress, L"CXuiCtrlLoadingProgress", XUI_CLASS_PROGRESSBAR )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiCtrlLoadingProgress, L"CXuiCtrlLoadingProgress",
XUI_CLASS_PROGRESSBAR)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
virtual int GetValue();
virtual void GetRange(int *pnRangeMin, int *pnRangeMax);
virtual int GetValue();
virtual void GetRange(int* pnRangeMin, int* pnRangeMax);
};

View File

@@ -14,176 +14,172 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
CXuiCtrlMinecraftPlayer::CXuiCtrlMinecraftPlayer() :
m_bDirty(false),
m_fScale(1.0f),
m_fAlpha(1.0f)
{
Minecraft *pMinecraft=Minecraft::GetInstance();
CXuiCtrlMinecraftPlayer::CXuiCtrlMinecraftPlayer()
: m_bDirty(false), m_fScale(1.0f), m_fAlpha(1.0f) {
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlMinecraftPlayer::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
HRESULT hr=S_OK;
HRESULT CXuiCtrlMinecraftPlayer::OnInit(XUIMessageInit* pInitData,
BOOL& rfHandled) {
HRESULT hr = S_OK;
HXUIOBJ parent = m_hObj;
HXUICLASS hcInventoryClass = XuiFindClass( L"CXuiSceneInventory" );
HXUICLASS currentClass;
HXUIOBJ parent = m_hObj;
HXUICLASS hcInventoryClass = XuiFindClass(L"CXuiSceneInventory");
HXUICLASS currentClass;
do
{
XuiElementGetParent(parent,&parent);
currentClass = XuiGetObjectClass( parent );
} while (parent != NULL && !XuiClassDerivesFrom( currentClass, hcInventoryClass ) );
do {
XuiElementGetParent(parent, &parent);
currentClass = XuiGetObjectClass(parent);
} while (parent != NULL &&
!XuiClassDerivesFrom(currentClass, hcInventoryClass));
assert( parent != NULL );
assert(parent != NULL);
void *pObj;
XuiObjectFromHandle( parent, &pObj );
m_containerScene = (CXuiSceneInventory *)pObj;
void* pObj;
XuiObjectFromHandle(parent, &pObj);
m_containerScene = (CXuiSceneInventory*)pObj;
m_iPad = m_containerScene->getPad();
m_iPad = m_containerScene->getPad();
return hr;
return hr;
}
HRESULT CXuiCtrlMinecraftPlayer::OnRender(XUIMessageRender *pRenderData, BOOL &bHandled )
{
HRESULT CXuiCtrlMinecraftPlayer::OnRender(XUIMessageRender* pRenderData,
BOOL& bHandled) {
#ifdef _XBOX
HXUIDC hDC = pRenderData->hDC;
HXUIDC hDC = pRenderData->hDC;
// build and render with the game call
// build and render with the game call
RenderManager.Set_matrixDirty();
RenderManager.Set_matrixDirty();
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
glColor4f(1, 1, 1, 1);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fRawWidth, m_fRawHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
glColor4f(1, 1, 1, 1);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fRawWidth, m_fRawHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
D3DXMATRIX matrix;
CXuiControl xuiControl(m_hObj);
xuiControl.GetFullXForm(&matrix);
float bwidth, bheight;
xuiControl.GetBounds(&bwidth, &bheight);
D3DXMATRIX matrix;
CXuiControl xuiControl(m_hObj);
xuiControl.GetFullXForm(&matrix);
float bwidth,bheight;
xuiControl.GetBounds(&bwidth,&bheight);
float xo = ((matrix._41 + ((bwidth * matrix._11) / 2)) / m_fScreenWidth) *
m_fRawWidth;
float yo = ((matrix._42 + (bheight * matrix._22)) / m_fScreenHeight) *
m_fRawHeight;
float xo = ( (matrix._41 + ( (bwidth*matrix._11)/2) ) / m_fScreenWidth ) * m_fRawWidth;
float yo = ( (matrix._42 + (bheight*matrix._22) ) / m_fScreenHeight ) * m_fRawHeight;
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
glTranslatef(xo, yo - 3.5f, 50.0f);
float ss; // = 26;
glPushMatrix();
glTranslatef(xo, yo - 3.5f, 50.0f);
float ss;// = 26;
if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())
{
ss = 24;
}
else
{
if(app.GetLocalPlayerCount()>1)
{
ss = 13;
}
else
{
ss = 26;
}
}
// Base scale on height of this control
// Potentially we might want separate x & y scales here
//ss = ( ( bheight / m_fScreenHeight ) * m_fRawHeight );
// For testing split screen - this scale is correct for 4 player split screen
if (!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) {
ss = 24;
} else {
if (app.GetLocalPlayerCount() > 1) {
ss = 13;
} else {
ss = 26;
}
}
// Base scale on height of this control
// Potentially we might want separate x & y scales here
// ss = ( ( bheight / m_fScreenHeight ) * m_fRawHeight );
// For testing split screen - this scale is correct for 4 player split
// screen
// how many local players do we have?
// int iPlayerC=0;
//
// for(int i=0;i<XUSER_MAX_COUNT;i++)
// {
// if(pMinecraft->localplayers[i] != NULL)
// {
// iPlayerC++;
// }
// }
//
// switch(iPlayerC)
// {
// case 1:
// break;
// case 2:
// case 3:
// case 4:
// ss *= 0.5f;
// break;
// }
// how many local players do we have?
// int iPlayerC=0;
//
// for(int i=0;i<XUSER_MAX_COUNT;i++)
// {
// if(pMinecraft->localplayers[i] != NULL)
// {
// iPlayerC++;
// }
// }
//
// switch(iPlayerC)
// {
// case 1:
// break;
// case 2:
// case 3:
// case 4:
// ss *= 0.5f;
// break;
// }
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
float oybr = pMinecraft->localplayers[m_iPad]->yBodyRot;
float oyr = pMinecraft->localplayers[m_iPad]->yRot;
float oxr = pMinecraft->localplayers[m_iPad]->xRot;
float oyhr = pMinecraft->localplayers[m_iPad]->yHeadRot;
float oybr = pMinecraft->localplayers[m_iPad]->yBodyRot;
float oyr = pMinecraft->localplayers[m_iPad]->yRot;
float oxr = pMinecraft->localplayers[m_iPad]->xRot;
float oyhr = pMinecraft->localplayers[m_iPad]->yHeadRot;
D3DXVECTOR3 pointerPosition = m_containerScene->GetCursorScreenPosition();
//printf("Pointer screen position is x:%f, y:%f, z:%f\n",pointerPosition.x, pointerPosition.y, pointerPosition.z);
D3DXVECTOR3 pointerPosition = m_containerScene->GetCursorScreenPosition();
// printf("Pointer screen position is x:%f, y:%f, z:%f\n",pointerPosition.x,
// pointerPosition.y, pointerPosition.z);
float xd = ( matrix._41 + ( (bwidth*matrix._11)/2) ) - pointerPosition.x;
float xd = (matrix._41 + ((bwidth * matrix._11) / 2)) - pointerPosition.x;
// Need to base Y on head position, not centre of mass
float yd = ( matrix._42 + ( (bheight*matrix._22) / 2) - 40 ) - pointerPosition.y;
// Need to base Y on head position, not centre of mass
float yd =
(matrix._42 + ((bheight * matrix._22) / 2) - 40) - pointerPosition.y;
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float) atan(yd / 40.0f) * 20, 1, 0, 0);
glRotatef(-(float)atan(yd / 40.0f) * 20, 1, 0, 0);
pMinecraft->localplayers[m_iPad]->yBodyRot = (float) atan(xd / 40.0f) * 20;
pMinecraft->localplayers[m_iPad]->yRot = (float) atan(xd / 40.0f) * 40;
pMinecraft->localplayers[m_iPad]->xRot = -(float) atan(yd / 40.0f) * 20;
pMinecraft->localplayers[m_iPad]->yHeadRot = pMinecraft->localplayers[m_iPad]->yRot;
//pMinecraft->localplayers[m_iPad]->glow = 1;
glTranslatef(0, pMinecraft->localplayers[m_iPad]->heightOffset, 0);
EntityRenderDispatcher::instance->playerRotY = 180;
pMinecraft->localplayers[m_iPad]->yBodyRot = (float)atan(xd / 40.0f) * 20;
pMinecraft->localplayers[m_iPad]->yRot = (float)atan(xd / 40.0f) * 40;
pMinecraft->localplayers[m_iPad]->xRot = -(float)atan(yd / 40.0f) * 20;
pMinecraft->localplayers[m_iPad]->yHeadRot =
pMinecraft->localplayers[m_iPad]->yRot;
// pMinecraft->localplayers[m_iPad]->glow = 1;
glTranslatef(0, pMinecraft->localplayers[m_iPad]->heightOffset, 0);
EntityRenderDispatcher::instance->playerRotY = 180;
// 4J Stu - Turning on hideGui while we do this stops the name rendering in split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
EntityRenderDispatcher::instance->render(pMinecraft->localplayers[m_iPad], 0, 0, 0, 0, 1,false,false);
pMinecraft->options->hideGui = wasHidingGui;
//pMinecraft->localplayers[m_iPad]->glow = 0;
// 4J Stu - Turning on hideGui while we do this stops the name rendering in
// split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
EntityRenderDispatcher::instance->render(pMinecraft->localplayers[m_iPad],
0, 0, 0, 0, 1, false, false);
pMinecraft->options->hideGui = wasHidingGui;
// pMinecraft->localplayers[m_iPad]->glow = 0;
pMinecraft->localplayers[m_iPad]->yBodyRot = oybr;
pMinecraft->localplayers[m_iPad]->yRot = oyr;
pMinecraft->localplayers[m_iPad]->xRot = oxr;
pMinecraft->localplayers[m_iPad]->yHeadRot = oyhr;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
pMinecraft->localplayers[m_iPad]->yBodyRot = oybr;
pMinecraft->localplayers[m_iPad]->yRot = oyr;
pMinecraft->localplayers[m_iPad]->xRot = oxr;
pMinecraft->localplayers[m_iPad]->yHeadRot = oyhr;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
XuiRenderRestoreState(hDC);
XuiRenderRestoreState(hDC);
bHandled = TRUE;
bHandled = TRUE;
#endif
return S_OK;
return S_OK;
}

View File

@@ -3,7 +3,7 @@
#include <string>
#include <XuiApp.h>
//using namespace std;
// using namespace std;
class TileRenderer;
class ItemRenderer;
@@ -12,31 +12,29 @@ class CXuiSceneInventory;
//-----------------------------------------------------------------------------
// CXuiCtrlMinecraftPlayer class
//-----------------------------------------------------------------------------
class CXuiCtrlMinecraftPlayer : public CXuiControlImpl
{
class CXuiCtrlMinecraftPlayer : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlMinecraftPlayer, L"CXuiCtrlMinecraftPlayer", XUI_CLASS_LABEL)
XUI_IMPLEMENT_CLASS(CXuiCtrlMinecraftPlayer, L"CXuiCtrlMinecraftPlayer",
XUI_CLASS_LABEL)
CXuiCtrlMinecraftPlayer();
virtual ~CXuiCtrlMinecraftPlayer() { };
CXuiCtrlMinecraftPlayer();
virtual ~CXuiCtrlMinecraftPlayer() {};
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender *pRenderData, BOOL &rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender* pRenderData, BOOL& rfHandled);
private:
bool m_bDirty;
float m_fScale,m_fAlpha;
int m_iPad;
CXuiSceneInventory *m_containerScene;
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
bool m_bDirty;
float m_fScale, m_fAlpha;
int m_iPad;
CXuiSceneInventory* m_containerScene;
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
};

View File

@@ -14,7 +14,7 @@
#include "../../Minecraft.Client/Build/stubs.h"
#include "../../Minecraft.Client/Rendering/Models/ModelPart.h"
//#define SKIN_PREVIEW_BOB_ANIM
// #define SKIN_PREVIEW_BOB_ANIM
#define SKIN_PREVIEW_WALKING_ANIM
//-----------------------------------------------------------------------------
@@ -22,362 +22,354 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
CXuiCtrlMinecraftSkinPreview::CXuiCtrlMinecraftSkinPreview() :
m_bDirty(FALSE),
m_fScale(1.0f),
m_fAlpha(1.0f)
{
Minecraft *pMinecraft=Minecraft::GetInstance();
CXuiCtrlMinecraftSkinPreview::CXuiCtrlMinecraftSkinPreview()
: m_bDirty(FALSE), m_fScale(1.0f), m_fAlpha(1.0f) {
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
m_customTextureUrl = L"default";
m_backupTexture = TN_MOB_CHAR;
m_capeTextureUrl = L"";
m_customTextureUrl = L"default";
m_backupTexture = TN_MOB_CHAR;
m_capeTextureUrl = L"";
m_yRot = 0;
m_xRot = 0;
m_yRot = 0;
m_xRot = 0;
m_swingTime = 0.0f;
m_bobTick = 0.0f;
m_walkAnimSpeedO = 0.0f;
m_walkAnimSpeed = 0.0f;
m_walkAnimPos = 0.0f;
m_swingTime = 0.0f;
m_bobTick = 0.0f;
m_walkAnimSpeedO = 0.0f;
m_walkAnimSpeed = 0.0f;
m_walkAnimPos = 0.0f;
m_bAutoRotate = false;
m_bRotatingLeft = false;
m_bAutoRotate = false;
m_bRotatingLeft = false;
m_incXRot = false;
m_decXRot = false;
m_incYRot = false;
m_decYRot = false;
m_incXRot = false;
m_decXRot = false;
m_incYRot = false;
m_decYRot = false;
m_currentAnimation = e_SkinPreviewAnimation_Walking;
m_currentAnimation = e_SkinPreviewAnimation_Walking;
m_fTargetRotation = 0.0f;
m_fOriginalRotation = 0.0f;
m_framesAnimatingRotation = 0;
m_bAnimatingToFacing = false;
m_pvAdditionalModelParts=NULL;
m_uiAnimOverrideBitmask=0L;
m_fTargetRotation = 0.0f;
m_fOriginalRotation = 0.0f;
m_framesAnimatingRotation = 0;
m_bAnimatingToFacing = false;
m_pvAdditionalModelParts = NULL;
m_uiAnimOverrideBitmask = 0L;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlMinecraftSkinPreview::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
HRESULT hr=S_OK;
HRESULT CXuiCtrlMinecraftSkinPreview::OnInit(XUIMessageInit* pInitData,
BOOL& rfHandled) {
HRESULT hr = S_OK;
return hr;
return hr;
}
void CXuiCtrlMinecraftSkinPreview::SetTexture(const std::wstring &url, TEXTURE_NAME backupTexture)
{
m_customTextureUrl = url;
m_backupTexture = backupTexture;
void CXuiCtrlMinecraftSkinPreview::SetTexture(const std::wstring& url,
TEXTURE_NAME backupTexture) {
m_customTextureUrl = url;
m_backupTexture = backupTexture;
unsigned int uiAnimOverrideBitmask = Player::getSkinAnimOverrideBitmask( app.getSkinIdFromPath(m_customTextureUrl) );
unsigned int uiAnimOverrideBitmask = Player::getSkinAnimOverrideBitmask(
app.getSkinIdFromPath(m_customTextureUrl));
if(app.GetGameSettings(eGameSetting_CustomSkinAnim)==0 )
{
// We have a force animation for some skins (claptrap)
// 4J-PB - treat all the eAnim_Disable flags as a force anim
if (app.GetGameSettings(eGameSetting_CustomSkinAnim) == 0) {
// We have a force animation for some skins (claptrap)
// 4J-PB - treat all the eAnim_Disable flags as a force anim
if((uiAnimOverrideBitmask & HumanoidModel::m_staticBitmaskIgnorePlayerCustomAnimSetting)!=0)
{
m_uiAnimOverrideBitmask=uiAnimOverrideBitmask;
}
else
{
m_uiAnimOverrideBitmask=0;
}
}
else
{
m_uiAnimOverrideBitmask = uiAnimOverrideBitmask;
}
app.DebugPrintf("+++ SetTexture - %d, %8x\n",app.getSkinIdFromPath(m_customTextureUrl)&0xFFFFFFF,m_uiAnimOverrideBitmask);
m_pvAdditionalModelParts=app.GetAdditionalModelParts(app.getSkinIdFromPath(m_customTextureUrl));
}
void CXuiCtrlMinecraftSkinPreview::SetFacing(ESkinPreviewFacing facing, bool bAnimate /*= false*/)
{
switch(facing)
{
case e_SkinPreviewFacing_Forward:
m_fTargetRotation = 0;
m_bRotatingLeft = true;
break;
case e_SkinPreviewFacing_Left:
m_fTargetRotation = LOOK_LEFT_EXTENT;
m_bRotatingLeft = false;
break;
case e_SkinPreviewFacing_Right:
m_fTargetRotation = LOOK_RIGHT_EXTENT;
m_bRotatingLeft = true;
break;
}
if(!bAnimate)
{
m_yRot = m_fTargetRotation;
m_bAnimatingToFacing = false;
}
else
{
m_fOriginalRotation = m_yRot;
m_bAnimatingToFacing = true;
m_framesAnimatingRotation = 0;
}
}
void CXuiCtrlMinecraftSkinPreview::CycleNextAnimation()
{
m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation + 1);
if(m_currentAnimation >= e_SkinPreviewAnimation_Count) m_currentAnimation = e_SkinPreviewAnimation_Walking;
m_swingTime = 0.0f;
}
void CXuiCtrlMinecraftSkinPreview::CyclePreviousAnimation()
{
m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation - 1);
if(m_currentAnimation < e_SkinPreviewAnimation_Walking) m_currentAnimation = (ESkinPreviewAnimations)(e_SkinPreviewAnimation_Count - 1);
m_swingTime = 0.0f;
}
HRESULT CXuiCtrlMinecraftSkinPreview::OnRender(XUIMessageRender *pRenderData, BOOL &bHandled )
{
if( m_bAnimatingToFacing )
{
++m_framesAnimatingRotation;
m_yRot = m_fOriginalRotation + m_framesAnimatingRotation * ( (m_fTargetRotation - m_fOriginalRotation) / CHANGING_SKIN_FRAMES );
//if(m_framesAnimatingRotation == CHANGING_SKIN_FRAMES) m_bAnimatingToFacing = false;
}
else
{
if( m_incXRot ) IncrementXRotation();
if( m_decXRot ) DecrementXRotation();
if( m_incYRot ) IncrementYRotation();
if( m_decYRot ) DecrementYRotation();
if(m_bAutoRotate)
{
++m_rotateTick;
if(m_rotateTick%4==0)
{
if(m_yRot >= LOOK_LEFT_EXTENT)
{
m_bRotatingLeft = false;
}
else if(m_yRot <= LOOK_RIGHT_EXTENT)
{
m_bRotatingLeft = true;
}
if(m_bRotatingLeft)
{
IncrementYRotation();
}
else
{
DecrementYRotation();
}
}
}
}
HXUIDC hDC = pRenderData->hDC;
// build and render with the game call
RenderManager.Set_matrixDirty();
Minecraft *pMinecraft=Minecraft::GetInstance();
float alpha = 1.0f;
//GetOpacity( &alpha );
glColor4f(1, 1, 1, alpha);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fRawWidth, m_fRawHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
D3DXMATRIX matrix;
GetFullXForm(&matrix);
float bwidth,bheight;
GetBounds(&bwidth,&bheight);
float xo = ( (matrix._41 + ( (bwidth*matrix._11)/2) ) / m_fScreenWidth ) * m_fRawWidth;
float yo = ( (matrix._42 + (bheight*matrix._22) ) / m_fScreenHeight ) * m_fRawHeight;
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
glTranslatef(xo, yo - 3.5f, 50.0f);
float ss;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
ss = ( ( (bheight*matrix._22) / m_fScreenHeight ) * m_fRawHeight )/2;
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
//glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
//glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float)m_xRot, 1, 0, 0);
// 4J Stu - Turning on hideGui while we do this stops the name rendering in split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
//EntityRenderDispatcher::instance->render(pMinecraft->localplayers[0], 0, 0, 0, 0, 1);
EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER);
if (renderer != NULL)
{
// 4J-PB - any additional parts to turn on for this player (skin dependent)
//std::vector<ModelPart *> *pAdditionalModelParts=mob->GetAdditionalModelParts();
if(m_pvAdditionalModelParts && m_pvAdditionalModelParts->size()!=0)
{
for(AUTO_VAR(it, m_pvAdditionalModelParts->begin()); it != m_pvAdditionalModelParts->end(); ++it)
{
ModelPart *pModelPart=*it;
pModelPart->visible=true;
}
}
render(renderer,0,0,0,0,1);
//renderer->postRender(entity, x, y, z, rot, a);
// hide the additional parts
if(m_pvAdditionalModelParts && m_pvAdditionalModelParts->size()!=0)
{
for(AUTO_VAR(it, m_pvAdditionalModelParts->begin()); it != m_pvAdditionalModelParts->end(); ++it)
{
ModelPart *pModelPart=*it;
pModelPart->visible=false;
}
}
if ((uiAnimOverrideBitmask &
HumanoidModel::m_staticBitmaskIgnorePlayerCustomAnimSetting) !=
0) {
m_uiAnimOverrideBitmask = uiAnimOverrideBitmask;
} else {
m_uiAnimOverrideBitmask = 0;
}
} else {
m_uiAnimOverrideBitmask = uiAnimOverrideBitmask;
}
pMinecraft->options->hideGui = wasHidingGui;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
XuiRenderRestoreState(hDC);
bHandled = TRUE;
return S_OK;
app.DebugPrintf("+++ SetTexture - %d, %8x\n",
app.getSkinIdFromPath(m_customTextureUrl) & 0xFFFFFFF,
m_uiAnimOverrideBitmask);
m_pvAdditionalModelParts =
app.GetAdditionalModelParts(app.getSkinIdFromPath(m_customTextureUrl));
}
// 4J Stu - Modified version of MobRenderer::render that does not require an actual entity
void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, double y, double z, float rot, float a)
{
void CXuiCtrlMinecraftSkinPreview::SetFacing(ESkinPreviewFacing facing,
bool bAnimate /*= false*/) {
switch (facing) {
case e_SkinPreviewFacing_Forward:
m_fTargetRotation = 0;
m_bRotatingLeft = true;
break;
case e_SkinPreviewFacing_Left:
m_fTargetRotation = LOOK_LEFT_EXTENT;
m_bRotatingLeft = false;
break;
case e_SkinPreviewFacing_Right:
m_fTargetRotation = LOOK_RIGHT_EXTENT;
m_bRotatingLeft = true;
break;
}
if (!bAnimate) {
m_yRot = m_fTargetRotation;
m_bAnimatingToFacing = false;
} else {
m_fOriginalRotation = m_yRot;
m_bAnimatingToFacing = true;
m_framesAnimatingRotation = 0;
}
}
void CXuiCtrlMinecraftSkinPreview::CycleNextAnimation() {
m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation + 1);
if (m_currentAnimation >= e_SkinPreviewAnimation_Count)
m_currentAnimation = e_SkinPreviewAnimation_Walking;
m_swingTime = 0.0f;
}
void CXuiCtrlMinecraftSkinPreview::CyclePreviousAnimation() {
m_currentAnimation = (ESkinPreviewAnimations)(m_currentAnimation - 1);
if (m_currentAnimation < e_SkinPreviewAnimation_Walking)
m_currentAnimation =
(ESkinPreviewAnimations)(e_SkinPreviewAnimation_Count - 1);
m_swingTime = 0.0f;
}
HRESULT CXuiCtrlMinecraftSkinPreview::OnRender(XUIMessageRender* pRenderData,
BOOL& bHandled) {
if (m_bAnimatingToFacing) {
++m_framesAnimatingRotation;
m_yRot = m_fOriginalRotation +
m_framesAnimatingRotation *
((m_fTargetRotation - m_fOriginalRotation) /
CHANGING_SKIN_FRAMES);
// if(m_framesAnimatingRotation == CHANGING_SKIN_FRAMES)
// m_bAnimatingToFacing = false;
} else {
if (m_incXRot) IncrementXRotation();
if (m_decXRot) DecrementXRotation();
if (m_incYRot) IncrementYRotation();
if (m_decYRot) DecrementYRotation();
if (m_bAutoRotate) {
++m_rotateTick;
if (m_rotateTick % 4 == 0) {
if (m_yRot >= LOOK_LEFT_EXTENT) {
m_bRotatingLeft = false;
} else if (m_yRot <= LOOK_RIGHT_EXTENT) {
m_bRotatingLeft = true;
}
if (m_bRotatingLeft) {
IncrementYRotation();
} else {
DecrementYRotation();
}
}
}
}
HXUIDC hDC = pRenderData->hDC;
// build and render with the game call
RenderManager.Set_matrixDirty();
Minecraft* pMinecraft = Minecraft::GetInstance();
float alpha = 1.0f;
// GetOpacity( &alpha );
glColor4f(1, 1, 1, alpha);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fRawWidth, m_fRawHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
D3DXMATRIX matrix;
GetFullXForm(&matrix);
float bwidth, bheight;
GetBounds(&bwidth, &bheight);
float xo = ((matrix._41 + ((bwidth * matrix._11) / 2)) / m_fScreenWidth) *
m_fRawWidth;
float yo = ((matrix._42 + (bheight * matrix._22)) / m_fScreenHeight) *
m_fRawHeight;
glEnable(GL_RESCALE_NORMAL);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
glTranslatef(xo, yo - 3.5f, 50.0f);
float ss;
// Base scale on height of this control
// Potentially we might want separate x & y scales here
ss = (((bheight * matrix._22) / m_fScreenHeight) * m_fRawHeight) / 2;
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
// glRotatef(45 + 90, 0, 1, 0);
Lighting::turnOn();
// glRotatef(-45 - 90, 0, 1, 0);
glRotatef(-(float)m_xRot, 1, 0, 0);
// 4J Stu - Turning on hideGui while we do this stops the name rendering in
// split-screen
bool wasHidingGui = pMinecraft->options->hideGui;
pMinecraft->options->hideGui = true;
// EntityRenderDispatcher::instance->render(pMinecraft->localplayers[0], 0,
// 0, 0, 0, 1);
EntityRenderer* renderer =
EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER);
if (renderer != NULL) {
// 4J-PB - any additional parts to turn on for this player (skin
// dependent)
// std::vector<ModelPart *>
// *pAdditionalModelParts=mob->GetAdditionalModelParts();
if (m_pvAdditionalModelParts && m_pvAdditionalModelParts->size() != 0) {
for (AUTO_VAR(it, m_pvAdditionalModelParts->begin());
it != m_pvAdditionalModelParts->end(); ++it) {
ModelPart* pModelPart = *it;
pModelPart->visible = true;
}
}
render(renderer, 0, 0, 0, 0, 1);
// renderer->postRender(entity, x, y, z, rot, a);
// hide the additional parts
if (m_pvAdditionalModelParts && m_pvAdditionalModelParts->size() != 0) {
for (AUTO_VAR(it, m_pvAdditionalModelParts->begin());
it != m_pvAdditionalModelParts->end(); ++it) {
ModelPart* pModelPart = *it;
pModelPart->visible = false;
}
}
}
pMinecraft->options->hideGui = wasHidingGui;
glPopMatrix();
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
XuiRenderRestoreState(hDC);
bHandled = TRUE;
return S_OK;
}
// 4J Stu - Modified version of MobRenderer::render that does not require an
// actual entity
void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer* renderer, double x,
double y, double z, float rot,
float a) {
glPushMatrix();
glDisable(GL_CULL_FACE);
HumanoidModel *model = (HumanoidModel *)renderer->getModel();
HumanoidModel* model = (HumanoidModel*)renderer->getModel();
//getAttackAnim(mob, a);
//if (armor != NULL) armor->attackTime = model->attackTime;
//model->riding = mob->isRiding();
//if (armor != NULL) armor->riding = model->riding;
// getAttackAnim(mob, a);
// if (armor != NULL) armor->attackTime = model->attackTime;
// model->riding = mob->isRiding();
// if (armor != NULL) armor->riding = model->riding;
// 4J Stu - Remember to reset these values once the rendering is done if you add another one
model->attackTime = 0;
model->sneaking = false;
model->holdingRightHand = false;
model->holdingLeftHand = false;
model->idle = false;
model->eating = false;
model->eating_swing = 0;
model->eating_t = 0;
model->young = false;
model->riding = false;
// 4J Stu - Remember to reset these values once the rendering is done if you
// add another one
model->attackTime = 0;
model->sneaking = false;
model->holdingRightHand = false;
model->holdingLeftHand = false;
model->idle = false;
model->eating = false;
model->eating_swing = 0;
model->eating_t = 0;
model->young = false;
model->riding = false;
model->m_uiAnimOverrideBitmask = m_uiAnimOverrideBitmask;
model->m_uiAnimOverrideBitmask = m_uiAnimOverrideBitmask;
if( !m_bAnimatingToFacing )
{
switch( m_currentAnimation )
{
case e_SkinPreviewAnimation_Sneaking:
model->sneaking = true;
break;
case e_SkinPreviewAnimation_Attacking:
model->holdingRightHand = true;
m_swingTime++;
if (m_swingTime >= (Player::SWING_DURATION * 3) )
{
m_swingTime = 0;
}
model->attackTime = m_swingTime / (float) (Player::SWING_DURATION * 3);
break;
default:
break;
};
}
if (!m_bAnimatingToFacing) {
switch (m_currentAnimation) {
case e_SkinPreviewAnimation_Sneaking:
model->sneaking = true;
break;
case e_SkinPreviewAnimation_Attacking:
model->holdingRightHand = true;
m_swingTime++;
if (m_swingTime >= (Player::SWING_DURATION * 3)) {
m_swingTime = 0;
}
model->attackTime =
m_swingTime / (float)(Player::SWING_DURATION * 3);
break;
default:
break;
};
}
float bodyRot =
m_yRot; //(mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a);
float headRot = m_yRot; //(mob->yRotO + (mob->yRot - mob->yRotO) * a);
float headRotx = 0; //(mob->xRotO + (mob->xRot - mob->xRotO) * a);
float bodyRot = m_yRot; //(mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a);
float headRot = m_yRot; //(mob->yRotO + (mob->yRot - mob->yRotO) * a);
float headRotx = 0; //(mob->xRotO + (mob->xRot - mob->xRotO) * a);
//setupPosition(mob, x, y, z);
// is equivalent to
glTranslatef((float) x, (float) y, (float) z);
// setupPosition(mob, x, y, z);
// is equivalent to
glTranslatef((float)x, (float)y, (float)z);
//float bob = getBob(mob, a);
// float bob = getBob(mob, a);
#ifdef SKIN_PREVIEW_BOB_ANIM
float bob = (m_bobTick + a)/2;
float bob = (m_bobTick + a) / 2;
++m_bobTick;
if(m_bobTick>=360*2) m_bobTick = 0;
++m_bobTick;
if (m_bobTick >= 360 * 2) m_bobTick = 0;
#else
float bob = 0.0f;
float bob = 0.0f;
#endif
//setupRotations(mob, bob, bodyRot, a);
// is equivalent to
glRotatef(180 - bodyRot, 0, 1, 0);
// setupRotations(mob, bob, bodyRot, a);
// is equivalent to
glRotatef(180 - bodyRot, 0, 1, 0);
float _scale = 1 / 16.0f;
glEnable(GL_RESCALE_NORMAL);
glScalef(-1, -1, 1);
//scale(mob, a);
// is equivalent to
float s = 15 / 16.0f;
glScalef(s, s, s);
// scale(mob, a);
// is equivalent to
float s = 15 / 16.0f;
glScalef(s, s, s);
glTranslatef(0, -24 * _scale - 0.125f / 16.0f, 0);
#ifdef SKIN_PREVIEW_WALKING_ANIM
m_walkAnimSpeedO = m_walkAnimSpeed;
m_walkAnimSpeed += (0.1f - m_walkAnimSpeed) * 0.4f;
m_walkAnimPos += m_walkAnimSpeed;
m_walkAnimSpeedO = m_walkAnimSpeed;
m_walkAnimSpeed += (0.1f - m_walkAnimSpeed) * 0.4f;
m_walkAnimPos += m_walkAnimSpeed;
float ws = m_walkAnimSpeedO + (m_walkAnimSpeed - m_walkAnimSpeedO) * a;
float wp = m_walkAnimPos - m_walkAnimSpeed * (1 - a);
#else
@@ -387,50 +379,52 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do
if (ws > 1) ws = 1;
MemSect(31);
MemSect(31);
bindTexture(m_customTextureUrl, m_backupTexture);
MemSect(0);
MemSect(0);
glEnable(GL_ALPHA_TEST);
//model->prepareMobModel(mob, wp, ws, a);
model->render(nullptr, wp, ws, bob, headRot - bodyRot, headRotx, _scale, true);
// model->prepareMobModel(mob, wp, ws, a);
model->render(nullptr, wp, ws, bob, headRot - bodyRot, headRotx, _scale,
true);
/*for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
{
if (prepareArmor(mob, i, a))
{
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, true);
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
{
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale,
true); glDisable(GL_BLEND); glEnable(GL_ALPHA_TEST);
}
}*/
//additionalRendering(mob, a);
if (bindTexture(m_capeTextureUrl, L"" ))
{
// additionalRendering(mob, a);
if (bindTexture(m_capeTextureUrl, L"")) {
glPushMatrix();
glTranslatef(0, 0, 2 / 16.0f);
double xd = 0;//(mob->xCloakO + (mob->xCloak - mob->xCloakO) * a) - (mob->xo + (mob->x - mob->xo) * a);
double yd = 0;//(mob->yCloakO + (mob->yCloak - mob->yCloakO) * a) - (mob->yo + (mob->y - mob->yo) * a);
double zd = 0;//(mob->zCloakO + (mob->zCloak - mob->zCloakO) * a) - (mob->zo + (mob->z - mob->zo) * a);
double xd = 0; //(mob->xCloakO + (mob->xCloak - mob->xCloakO) * a) -
//(mob->xo + (mob->x - mob->xo) * a);
double yd = 0; //(mob->yCloakO + (mob->yCloak - mob->yCloakO) * a) -
//(mob->yo + (mob->y - mob->yo) * a);
double zd = 0; //(mob->zCloakO + (mob->zCloak - mob->zCloakO) * a) -
//(mob->zo + (mob->z - mob->zo) * a);
float yr = 1;//mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a;
float yr = 1; // mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a;
double xa = sin(yr * PI / 180);
double za = -cos(yr * PI / 180);
float flap = (float) yd * 10;
float flap = (float)yd * 10;
if (flap < -6) flap = -6;
if (flap > 32) flap = 32;
float lean = (float) (xd * xa + zd * za) * 100;
float lean2 = (float) (xd * za - zd * xa) * 100;
float lean = (float)(xd * xa + zd * za) * 100;
float lean2 = (float)(xd * za - zd * xa) * 100;
if (lean < 0) lean = 0;
//float pow = 1;//mob->oBob + (bob - mob->oBob) * a;
// float pow = 1;//mob->oBob + (bob - mob->oBob) * a;
flap += 1;//sin((mob->walkDistO + (mob->walkDist - mob->walkDistO) * a) * 6) * 32 * pow;
if (model->sneaking)
{
flap += 1; // sin((mob->walkDistO + (mob->walkDist - mob->walkDistO) *
// a) * 6) * 32 * pow;
if (model->sneaking) {
flap += 25;
}
@@ -438,114 +432,113 @@ void CXuiCtrlMinecraftSkinPreview::render(EntityRenderer *renderer, double x, do
glRotatef(lean2 / 2, 0, 0, 1);
glRotatef(-lean2 / 2, 0, 1, 0);
glRotatef(180, 0, 1, 0);
model->renderCloak(1 / 16.0f,true);
model->renderCloak(1 / 16.0f, true);
glPopMatrix();
}
/*
float br = mob->getBrightness(a);
int overlayColor = getOverlayColor(mob, br, a);
/*
float br = mob->getBrightness(a);
int overlayColor = getOverlayColor(mob, br, a);
if (((overlayColor >> 24) & 0xff) > 0 || mob->hurtTime > 0 || mob->deathTime > 0)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthFunc(GL_EQUAL);
if (((overlayColor >> 24) & 0xff) > 0 || mob->hurtTime > 0 || mob->deathTime >
0)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthFunc(GL_EQUAL);
// 4J - changed these renders to not use the compiled version of their models, because otherwise the render states set
// about (in particular the depth & alpha test) don't work with our command buffer versions
if (mob->hurtTime > 0 || mob->deathTime > 0)
{
glColor4f(br, 0, 0, 0.4f);
model->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmorOverlay(mob, i, a))
{
glColor4f(br, 0, 0, 0.4f);
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
}
// 4J - changed these renders to not use the compiled version of
their models, because otherwise the render states set
// about (in particular the depth & alpha test) don't work with our
command buffer versions if (mob->hurtTime > 0 || mob->deathTime > 0)
{
glColor4f(br, 0, 0, 0.4f);
model->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmorOverlay(mob, i, a))
{
glColor4f(br, 0, 0, 0.4f);
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale,
false);
}
}
if (((overlayColor >> 24) & 0xff) > 0)
{
float r = ((overlayColor >> 16) & 0xff) / 255.0f;
float g = ((overlayColor >> 8) & 0xff) / 255.0f;
float b = ((overlayColor) & 0xff) / 255.0f;
float aa = ((overlayColor >> 24) & 0xff) / 255.0f;
glColor4f(r, g, b, aa);
model->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmorOverlay(mob, i, a))
{
glColor4f(r, g, b, aa);
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
}
}
}
glDepthFunc(GL_LEQUAL);
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glEnable(GL_TEXTURE_2D);
}
*/
if (((overlayColor >> 24) & 0xff) > 0)
{
float r = ((overlayColor >> 16) & 0xff) / 255.0f;
float g = ((overlayColor >> 8) & 0xff) / 255.0f;
float b = ((overlayColor) & 0xff) / 255.0f;
float aa = ((overlayColor >> 24) & 0xff) / 255.0f;
glColor4f(r, g, b, aa);
model->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale, false);
for (int i = 0; i < MAX_ARMOR_LAYERS; i++)
{
if (prepareArmorOverlay(mob, i, a))
{
glColor4f(r, g, b, aa);
armor->render(wp, ws, bob, headRot - bodyRot, headRotx, _scale,
false);
}
}
}
glDepthFunc(GL_LEQUAL);
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glEnable(GL_TEXTURE_2D);
}
*/
glDisable(GL_RESCALE_NORMAL);
glEnable(GL_CULL_FACE);
glPopMatrix();
MemSect(31);
//renderName(mob, x, y, z);
MemSect(0);
MemSect(31);
// renderName(mob, x, y, z);
MemSect(0);
// Reset the model values to stop the changes we made here affecting anything in game (like the player hand render)
model->attackTime = 0;
model->sneaking = false;
model->holdingRightHand = false;
model->holdingLeftHand = false;
// Reset the model values to stop the changes we made here affecting
// anything in game (like the player hand render)
model->attackTime = 0;
model->sneaking = false;
model->holdingRightHand = false;
model->holdingLeftHand = false;
}
bool CXuiCtrlMinecraftSkinPreview::bindTexture(const std::wstring& urlTexture, int backupTexture)
{
Textures *t = Minecraft::GetInstance()->textures;
bool CXuiCtrlMinecraftSkinPreview::bindTexture(const std::wstring& urlTexture,
int backupTexture) {
Textures* t = Minecraft::GetInstance()->textures;
// 4J-PB - no http textures on the xbox, mem textures instead
//int id = t->loadHttpTexture(urlTexture, backupTexture);
int id = t->loadMemTexture(urlTexture, backupTexture);
// 4J-PB - no http textures on the xbox, mem textures instead
if (id >= 0)
{
// int id = t->loadHttpTexture(urlTexture, backupTexture);
int id = t->loadMemTexture(urlTexture, backupTexture);
if (id >= 0) {
t->bind(id);
return true;
}
else
{
} else {
return false;
}
}
bool CXuiCtrlMinecraftSkinPreview::bindTexture(const std::wstring& urlTexture, const std::wstring& backupTexture)
{
Textures *t = Minecraft::GetInstance()->textures;
bool CXuiCtrlMinecraftSkinPreview::bindTexture(
const std::wstring& urlTexture, const std::wstring& backupTexture) {
Textures* t = Minecraft::GetInstance()->textures;
// 4J-PB - no http textures on the xbox, mem textures instead
//int id = t->loadHttpTexture(urlTexture, backupTexture);
int id = t->loadMemTexture(urlTexture, backupTexture);
// 4J-PB - no http textures on the xbox, mem textures instead
if (id >= 0)
{
// int id = t->loadHttpTexture(urlTexture, backupTexture);
int id = t->loadMemTexture(urlTexture, backupTexture);
if (id >= 0) {
t->bind(id);
return true;
}
else
{
} else {
return false;
}
}

View File

@@ -3,104 +3,121 @@
#include <string>
#include <XuiApp.h>
#include "../../Minecraft.Client/Textures/Textures.h"
//#include "../../Xbox/DLC/DLCSkinFile.h"
// #include "../../Xbox/DLC/DLCSkinFile.h"
#include "../../Minecraft.Client/Rendering/Models/Model.h"
//using namespace std;
// using namespace std;
class EntityRenderer;
//-----------------------------------------------------------------------------
// CXuiCtrlMinecraftSkinPreview class
//-----------------------------------------------------------------------------
class CXuiCtrlMinecraftSkinPreview : public CXuiControlImpl
{
class CXuiCtrlMinecraftSkinPreview : public CXuiControlImpl {
private:
static const int LOOK_LEFT_EXTENT = 45;
static const int LOOK_RIGHT_EXTENT = -45;
static const int LOOK_LEFT_EXTENT = 45;
static const int LOOK_RIGHT_EXTENT = -45;
static const int CHANGING_SKIN_FRAMES = 15;
static const int CHANGING_SKIN_FRAMES = 15;
enum ESkinPreviewAnimations
{
e_SkinPreviewAnimation_Walking,
e_SkinPreviewAnimation_Sneaking,
e_SkinPreviewAnimation_Attacking,
enum ESkinPreviewAnimations {
e_SkinPreviewAnimation_Walking,
e_SkinPreviewAnimation_Sneaking,
e_SkinPreviewAnimation_Attacking,
e_SkinPreviewAnimation_Count,
};
e_SkinPreviewAnimation_Count,
};
public:
enum ESkinPreviewFacing
{
e_SkinPreviewFacing_Forward,
e_SkinPreviewFacing_Left,
e_SkinPreviewFacing_Right,
};
enum ESkinPreviewFacing {
e_SkinPreviewFacing_Forward,
e_SkinPreviewFacing_Left,
e_SkinPreviewFacing_Right,
};
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlMinecraftSkinPreview, L"CXuiCtrlMinecraftSkinPreview", XUI_CLASS_LABEL)
XUI_IMPLEMENT_CLASS(CXuiCtrlMinecraftSkinPreview,
L"CXuiCtrlMinecraftSkinPreview", XUI_CLASS_LABEL)
CXuiCtrlMinecraftSkinPreview();
virtual ~CXuiCtrlMinecraftSkinPreview() { };
CXuiCtrlMinecraftSkinPreview();
virtual ~CXuiCtrlMinecraftSkinPreview() {};
void SetTexture(const std::wstring &url, TEXTURE_NAME backupTexture = TN_MOB_CHAR);
void SetCapeTexture(const std::wstring &url) { m_capeTextureUrl = url; }
void ResetRotation() { m_xRot = 0; m_yRot = 0; }
void IncrementYRotation() { m_yRot = (m_yRot+4); if(m_yRot >= 180) m_yRot = -180; }
void DecrementYRotation() { m_yRot = (m_yRot-4); if(m_yRot <= -180) m_yRot = 180; }
void IncrementXRotation() { m_xRot = (m_xRot+2); if(m_xRot > 22) m_xRot = 22; }
void DecrementXRotation() { m_xRot = (m_xRot-2); if(m_xRot < -22) m_xRot = -22; }
void SetAutoRotate(bool autoRotate) { m_bAutoRotate = autoRotate; }
void SetFacing(ESkinPreviewFacing facing, bool bAnimate = false);
void SetTexture(const std::wstring& url,
TEXTURE_NAME backupTexture = TN_MOB_CHAR);
void SetCapeTexture(const std::wstring& url) { m_capeTextureUrl = url; }
void ResetRotation() {
m_xRot = 0;
m_yRot = 0;
}
void IncrementYRotation() {
m_yRot = (m_yRot + 4);
if (m_yRot >= 180) m_yRot = -180;
}
void DecrementYRotation() {
m_yRot = (m_yRot - 4);
if (m_yRot <= -180) m_yRot = 180;
}
void IncrementXRotation() {
m_xRot = (m_xRot + 2);
if (m_xRot > 22) m_xRot = 22;
}
void DecrementXRotation() {
m_xRot = (m_xRot - 2);
if (m_xRot < -22) m_xRot = -22;
}
void SetAutoRotate(bool autoRotate) { m_bAutoRotate = autoRotate; }
void SetFacing(ESkinPreviewFacing facing, bool bAnimate = false);
void CycleNextAnimation();
void CyclePreviousAnimation();
void CycleNextAnimation();
void CyclePreviousAnimation();
bool m_incXRot, m_decXRot;
bool m_incYRot, m_decYRot;
bool m_incXRot, m_decXRot;
bool m_incYRot, m_decYRot;
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender *pRenderData, BOOL &rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender* pRenderData, BOOL& rfHandled);
private:
void render(EntityRenderer *renderer, double x, double y, double z, float rot, float a);
bool bindTexture(const std::wstring& urlTexture, int backupTexture);
bool bindTexture(const std::wstring& urlTexture, const std::wstring& backupTexture);
void render(EntityRenderer* renderer, double x, double y, double z,
float rot, float a);
bool bindTexture(const std::wstring& urlTexture, int backupTexture);
bool bindTexture(const std::wstring& urlTexture,
const std::wstring& backupTexture);
bool m_bDirty;
float m_fScale,m_fAlpha;
bool m_bDirty;
float m_fScale, m_fAlpha;
std::wstring m_customTextureUrl;
TEXTURE_NAME m_backupTexture;
std::wstring m_capeTextureUrl;
unsigned int m_uiAnimOverrideBitmask;
std::wstring m_customTextureUrl;
TEXTURE_NAME m_backupTexture;
std::wstring m_capeTextureUrl;
unsigned int m_uiAnimOverrideBitmask;
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
int m_yRot,m_xRot;
float m_bobTick;
int m_yRot, m_xRot;
float m_walkAnimSpeedO;
float m_walkAnimSpeed;
float m_walkAnimPos;
float m_bobTick;
bool m_bAutoRotate, m_bRotatingLeft;
std::uint8_t m_rotateTick;
float m_fTargetRotation, m_fOriginalRotation;
int m_framesAnimatingRotation;
bool m_bAnimatingToFacing;
float m_walkAnimSpeedO;
float m_walkAnimSpeed;
float m_walkAnimPos;
float m_swingTime;
bool m_bAutoRotate, m_bRotatingLeft;
std::uint8_t m_rotateTick;
float m_fTargetRotation, m_fOriginalRotation;
int m_framesAnimatingRotation;
bool m_bAnimatingToFacing;
ESkinPreviewAnimations m_currentAnimation;
//std::vector<Model::SKIN_BOX *> *m_pvAdditionalBoxes;
std::vector<ModelPart *> *m_pvAdditionalModelParts;
float m_swingTime;
ESkinPreviewAnimations m_currentAnimation;
// std::vector<Model::SKIN_BOX *> *m_pvAdditionalBoxes;
std::vector<ModelPart*>* m_pvAdditionalModelParts;
};

View File

@@ -17,340 +17,350 @@
// The xzp path icons for the leaderboard
LPCWSTR CXuiCtrlMinecraftSlot::xzpIcons[15]=
{
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Skeleton.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Creeper.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_SpiderJockey.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Spider.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Zombie.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_ZombiePigman.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Swam.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Walked.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Fallen.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Portal.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Climbed.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Ghast.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Slime.png",
L"Graphics\\CraftIcons\\icon_structures.png",
L"Graphics\\CraftIcons\\icon_tools.png",
LPCWSTR CXuiCtrlMinecraftSlot::xzpIcons[15] = {
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Skeleton.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Creeper.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_SpiderJockey.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Spider.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Zombie.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_ZombiePigman.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Swam.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Walked.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Fallen.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Portal.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Climbed.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Ghast.png",
L"Graphics\\Leaderboard\\LeaderBoard_Icon_Slime.png",
L"Graphics\\CraftIcons\\icon_structures.png",
L"Graphics\\CraftIcons\\icon_tools.png",
};
//-----------------------------------------------------------------------------
CXuiCtrlMinecraftSlot::CXuiCtrlMinecraftSlot() :
//m_hBrush(NULL),
m_bDirty(FALSE),
m_iPassThroughDataAssociation(0),
m_iPassThroughIdAssociation(0),
m_fScale(1.0f),
m_fAlpha(1.0f),
m_iID(0),
m_iCount(0),
m_iAuxVal(0),
m_bDecorations(false),
m_isFoil(false),
m_popTime(0)
{
m_pItemRenderer = new ItemRenderer();
m_item = nullptr;
CXuiCtrlMinecraftSlot::CXuiCtrlMinecraftSlot()
: // m_hBrush(NULL),
m_bDirty(FALSE),
m_iPassThroughDataAssociation(0),
m_iPassThroughIdAssociation(0),
m_fScale(1.0f),
m_fAlpha(1.0f),
m_iID(0),
m_iCount(0),
m_iAuxVal(0),
m_bDecorations(false),
m_isFoil(false),
m_popTime(0) {
m_pItemRenderer = new ItemRenderer();
m_item = nullptr;
m_bScreenWidthSetup = false;
m_bScreenWidthSetup = false;
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
if(pMinecraft != NULL)
{
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_bScreenWidthSetup = true;
}
if (pMinecraft != NULL) {
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_bScreenWidthSetup = true;
}
}
CXuiCtrlMinecraftSlot::~CXuiCtrlMinecraftSlot()
{
delete m_pItemRenderer;
}
CXuiCtrlMinecraftSlot::~CXuiCtrlMinecraftSlot() { delete m_pItemRenderer; }
void CXuiCtrlMinecraftSlot::SetPassThroughDataAssociation(unsigned int iID, unsigned int iData)
{
m_item = nullptr;
m_iPassThroughIdAssociation = iID;
m_iPassThroughDataAssociation = iData;
void CXuiCtrlMinecraftSlot::SetPassThroughDataAssociation(unsigned int iID,
unsigned int iData) {
m_item = nullptr;
m_iPassThroughIdAssociation = iID;
m_iPassThroughDataAssociation = iData;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlMinecraftSlot::OnGetSourceImage(XUIMessageGetSourceImage* pData, BOOL& rfHandled)
{
XUIMessage Message;
CustomMessage_GetSlotItem_Struct MsgGetSlotItem;
HRESULT hr;
HXUIOBJ hObj;
HRESULT CXuiCtrlMinecraftSlot::OnGetSourceImage(XUIMessageGetSourceImage* pData,
BOOL& rfHandled) {
XUIMessage Message;
CustomMessage_GetSlotItem_Struct MsgGetSlotItem;
HRESULT hr;
HXUIOBJ hObj;
CustomMessage_GetSlotItem(&Message, &MsgGetSlotItem, m_iPassThroughIdAssociation, m_iPassThroughDataAssociation);
CustomMessage_GetSlotItem(&Message, &MsgGetSlotItem,
m_iPassThroughIdAssociation,
m_iPassThroughDataAssociation);
hr = GetParent(&hObj);
hr = GetParent(&hObj);
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(hObj, &Message);
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(hObj, &Message);
if(hr == XUI_ERR_SOURCEDATA_ITEM)
{
// Go up the parent chain one more
HXUIOBJ hParent;
hr = XuiElementGetParent(hObj,&hParent);
hr = XuiBubbleMessage(hParent, &Message);
}
if (hr == XUI_ERR_SOURCEDATA_ITEM) {
// Go up the parent chain one more
HXUIOBJ hParent;
hr = XuiElementGetParent(hObj, &hParent);
hr = XuiBubbleMessage(hParent, &Message);
}
if (Message.bHandled)
{
pData->szPath = MsgGetSlotItem.szPath;
pData->bDirty = MsgGetSlotItem.bDirty;
if (Message.bHandled) {
pData->szPath = MsgGetSlotItem.szPath;
pData->bDirty = MsgGetSlotItem.bDirty;
if(MsgGetSlotItem.item != NULL)
{
m_item = MsgGetSlotItem.item;
m_iID = m_item->id;
m_iPad = GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField);
m_fAlpha = ((float)GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/31.0f;
m_bDecorations = GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField);
m_fScale = ((float)GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/10.0f;
}
else
{
m_iID = GET_SLOTDISPLAY_ID_FROM_ITEM_BITMASK(MsgGetSlotItem.iItemBitField);
if (MsgGetSlotItem.item != NULL) {
m_item = MsgGetSlotItem.item;
m_iID = m_item->id;
m_iPad = GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField);
m_fAlpha = ((float)GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField)) /
31.0f;
m_bDecorations = GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField);
m_fScale = ((float)GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField)) /
10.0f;
} else {
m_iID = GET_SLOTDISPLAY_ID_FROM_ITEM_BITMASK(
MsgGetSlotItem.iItemBitField);
// if the id is greater than or equal to 32000, then it's an xzp icon, not a game icon
if(m_iID<32000)
{
// 4J Stu - Some parent controls may overide this, others will leave it as what we passed in
// if the id is greater than or equal to 32000, then it's an xzp
// icon, not a game icon
if (m_iID < 32000) {
// 4J Stu - Some parent controls may overide this, others
// will leave it as what we passed in
m_iPad = GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField);
m_fAlpha = ((float)GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/31.0f;
m_bDecorations = GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField);
m_iCount = GET_SLOTDISPLAY_COUNT_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField);
m_fScale = ((float)GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField))/10.0f;
m_popTime = GET_SLOTDISPLAY_POPTIME_FROM_DATA_BITMASK(MsgGetSlotItem.iDataBitField);
m_iPad = GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField);
m_fAlpha = ((float)GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField)) /
31.0f;
m_bDecorations =
GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField);
m_iCount = GET_SLOTDISPLAY_COUNT_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField);
m_fScale = ((float)GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField)) /
10.0f;
m_popTime = GET_SLOTDISPLAY_POPTIME_FROM_DATA_BITMASK(
MsgGetSlotItem.iDataBitField);
m_iAuxVal = GET_SLOTDISPLAY_AUXVAL_FROM_ITEM_BITMASK(MsgGetSlotItem.iItemBitField);
m_iAuxVal = GET_SLOTDISPLAY_AUXVAL_FROM_ITEM_BITMASK(
MsgGetSlotItem.iItemBitField);
//m_iID = iID;
// m_iID = iID;
m_isFoil = GET_SLOTDISPLAY_FOIL_FROM_ITEM_BITMASK(MsgGetSlotItem.iItemBitField);
}
else
{
pData->szPath = xzpIcons[m_iID-32000];
}
m_isFoil = GET_SLOTDISPLAY_FOIL_FROM_ITEM_BITMASK(
MsgGetSlotItem.iItemBitField);
} else {
pData->szPath = xzpIcons[m_iID - 32000];
}
if(m_item != NULL && (m_item->id != m_iID || m_item->getAuxValue() != m_iAuxVal || m_item->GetCount() != m_iCount) ) m_item = nullptr;
}
if (m_item != NULL && (m_item->id != m_iID ||
m_item->getAuxValue() != m_iAuxVal ||
m_item->GetCount() != m_iCount))
m_item = nullptr;
}
rfHandled = TRUE;
return hr;
} else {
pData->szPath = L"";
}
}
rfHandled = TRUE;
return hr;
}
else
{
pData->szPath = L"";
}
}
pData->bDirty = m_bDirty;
m_bDirty = FALSE;
rfHandled = TRUE;
return S_OK;
pData->bDirty = m_bDirty;
m_bDirty = FALSE;
rfHandled = TRUE;
return S_OK;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlMinecraftSlot::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
//DWORD dwPropId;
HRESULT hr=S_OK;
return hr;
HRESULT CXuiCtrlMinecraftSlot::OnInit(XUIMessageInit* pInitData,
BOOL& rfHandled) {
// DWORD dwPropId;
HRESULT hr = S_OK;
return hr;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender *pRenderData, BOOL &bHandled )
{
// Force an update of the id
XUIMessage Message;
XUIMessageGetSourceImage MsgGetImage;
HRESULT hr;
XuiMessageGetSourceImage(&Message, &MsgGetImage, m_iPassThroughIdAssociation, m_iPassThroughDataAssociation, FALSE);
hr = XuiSendMessage(m_hObj, &Message);
HRESULT CXuiCtrlMinecraftSlot::OnRender(XUIMessageRender* pRenderData,
BOOL& bHandled) {
// Force an update of the id
XUIMessage Message;
XUIMessageGetSourceImage MsgGetImage;
HRESULT hr;
XuiMessageGetSourceImage(&Message, &MsgGetImage,
m_iPassThroughIdAssociation,
m_iPassThroughDataAssociation, FALSE);
hr = XuiSendMessage(m_hObj, &Message);
// We cannot have an Item with id 0
if(m_item != NULL || (m_iID > 0 && m_iID<32000) )
{
HXUIDC hDC = pRenderData->hDC;
CXuiControl xuiControl(m_hObj);
if(m_item == NULL) m_item = std::shared_ptr<ItemInstance>( new ItemInstance(m_iID, m_iCount, m_iAuxVal) );
// We cannot have an Item with id 0
if (m_item != NULL || (m_iID > 0 && m_iID < 32000)) {
HXUIDC hDC = pRenderData->hDC;
CXuiControl xuiControl(m_hObj);
if (m_item == NULL)
m_item = std::shared_ptr<ItemInstance>(
new ItemInstance(m_iID, m_iCount, m_iAuxVal));
// build and render with the game call
// build and render with the game call
RenderManager.Set_matrixDirty();
RenderManager.Set_matrixDirty();
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
D3DXMATRIX matrix;
xuiControl.GetFullXForm(&matrix);
float bwidth,bheight;
xuiControl.GetBounds(&bwidth,&bheight);
D3DXMATRIX matrix;
xuiControl.GetFullXForm(&matrix);
float bwidth, bheight;
xuiControl.GetBounds(&bwidth, &bheight);
float x = matrix._41;
float y = matrix._42;
float x = matrix._41;
float y = matrix._42;
// Base scale on height of this control, compared to height of what the item renderer normally renders (16 pixels high). Potentially
// we might want separate x & y scales here
// Base scale on height of this control, compared to height of what the
// item renderer normally renders (16 pixels high). Potentially we might
// want separate x & y scales here
float scaleX = bwidth / 16.0f;
float scaleY = bheight / 16.0f;
float scaleX = bwidth / 16.0f;
float scaleY = bheight / 16.0f;
// apply any scale in the matrix too
scaleX *= matrix._11;
scaleY *= matrix._22;
// apply any scale in the matrix too
scaleX *= matrix._11;
scaleY *= matrix._22;
// Annoyingly, XUI renders everything to a z of 0 so if we want to render anything that needs the z-buffer on top of it, then we need to clear it.
// Clear just the region required for this control.
D3DRECT clearRect;
clearRect.x1 = (int)(matrix._41) - 2;
clearRect.y1 = (int)(matrix._42) - 2;
clearRect.x2 = (int)(matrix._41 + ( bwidth * matrix._11 )) + 2;
clearRect.y2 = (int)(matrix._42 + ( bheight * matrix._22 )) + 2;
// Annoyingly, XUI renders everything to a z of 0 so if we want to
// render anything that needs the z-buffer on top of it, then we need to
// clear it. Clear just the region required for this control.
D3DRECT clearRect;
clearRect.x1 = (int)(matrix._41) - 2;
clearRect.y1 = (int)(matrix._42) - 2;
clearRect.x2 = (int)(matrix._41 + (bwidth * matrix._11)) + 2;
clearRect.y2 = (int)(matrix._42 + (bheight * matrix._22)) + 2;
if(!m_bScreenWidthSetup)
{
Minecraft *pMinecraft=Minecraft::GetInstance();
if(pMinecraft != NULL)
{
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_bScreenWidthSetup = true;
}
}
if (!m_bScreenWidthSetup) {
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft != NULL) {
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_bScreenWidthSetup = true;
}
}
RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &clearRect);
// glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fScreenWidth, m_fScreenHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &clearRect);
// glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, m_fScreenWidth, m_fScreenHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
glEnable(GL_RESCALE_NORMAL);
glPushMatrix();
glRotatef(120, 1, 0, 0);
Lighting::turnOn();
glPopMatrix();
glEnable(GL_RESCALE_NORMAL);
glPushMatrix();
glRotatef(120, 1, 0, 0);
Lighting::turnOn();
glPopMatrix();
// Make sure that pMinecraft->player is the correct player so that
// player specific rendering
// eg clock and compass, are rendered correctly
std::shared_ptr<MultiplayerLocalPlayer> oldPlayer = pMinecraft->player;
if (m_iPad >= 0 && m_iPad < XUSER_MAX_COUNT)
pMinecraft->player = pMinecraft->localplayers[m_iPad];
float pop = m_popTime;
if (pop > 0) {
glPushMatrix();
float squeeze = 1 + pop / (float)Inventory::POP_TIME_DURATION;
float sx = x;
float sy = y;
float sxoffs = 8 * scaleX;
float syoffs = 12 * scaleY;
glTranslatef((float)(sx + sxoffs), (float)(sy + syoffs), 0);
glScalef(1 / squeeze, (squeeze + 1) / 2, 1);
glTranslatef((float)-(sx + sxoffs), (float)-(sy + syoffs), 0);
}
//Make sure that pMinecraft->player is the correct player so that player specific rendering
// eg clock and compass, are rendered correctly
std::shared_ptr<MultiplayerLocalPlayer> oldPlayer = pMinecraft->player;
m_pItemRenderer->renderAndDecorateItem(
pMinecraft->font, pMinecraft->textures, m_item, x, y, scaleX,
scaleY, m_fAlpha, m_isFoil, false);
if( m_iPad >= 0 && m_iPad < XUSER_MAX_COUNT ) pMinecraft->player = pMinecraft->localplayers[m_iPad];
if (pop > 0) {
glPopMatrix();
}
float pop = m_popTime;
if (pop > 0)
{
glPushMatrix();
float squeeze = 1 + pop / (float) Inventory::POP_TIME_DURATION;
float sx = x;
float sy = y;
float sxoffs = 8 * scaleX;
float syoffs = 12 * scaleY;
glTranslatef((float)(sx + sxoffs), (float)(sy + syoffs), 0);
glScalef(1 / squeeze, (squeeze + 1) / 2, 1);
glTranslatef((float)-(sx + sxoffs), (float)-(sy + syoffs), 0);
}
if (m_bDecorations) {
if ((scaleX != 1.0f) || (scaleY != 1.0f)) {
glPushMatrix();
glScalef(scaleX, scaleY, 1.0f);
int iX = (int)(0.5f + ((float)x) / scaleX);
int iY = (int)(0.5f + ((float)y) / scaleY);
m_pItemRenderer->renderAndDecorateItem(pMinecraft->font, pMinecraft->textures, m_item, x, y,scaleX,scaleY,m_fAlpha,m_isFoil,false);
m_pItemRenderer->renderGuiItemDecorations(
pMinecraft->font, pMinecraft->textures, m_item, iX, iY,
m_fAlpha);
glPopMatrix();
} else {
m_pItemRenderer->renderGuiItemDecorations(
pMinecraft->font, pMinecraft->textures, m_item, (int)x,
(int)y, m_fAlpha);
}
}
if (pop > 0)
{
glPopMatrix();
}
pMinecraft->player = oldPlayer;
if(m_bDecorations)
{
if((scaleX!=1.0f) ||(scaleY!=1.0f))
{
glPushMatrix();
glScalef(scaleX, scaleY, 1.0f);
int iX= (int)(0.5f+((float)x)/scaleX);
int iY= (int)(0.5f+((float)y)/scaleY);
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, m_item, iX, iY, m_fAlpha);
glPopMatrix();
}
else
{
m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, m_item, (int)x, (int)y, m_fAlpha);
}
}
XuiRenderRestoreState(hDC);
pMinecraft->player = oldPlayer;
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
XuiRenderRestoreState(hDC);
bHandled = TRUE;
}
return S_OK;
bHandled = TRUE;
}
return S_OK;
}
void CXuiCtrlMinecraftSlot::SetIcon(int iPad, int iId, int iAuxVal, int iCount,
int iScale, unsigned int uiAlpha,
bool bDecorations, bool bShow,
bool isFoil) {
m_item = nullptr;
m_iID = iId;
m_iAuxVal = iAuxVal;
void CXuiCtrlMinecraftSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool bShow, bool isFoil)
{
m_item = nullptr;
m_iID=iId;
m_iAuxVal=iAuxVal;
// aux value for diggers can go as high as 1561
// const _Tier *_Tier::DIAMOND = new _Tier(3, 1561, 8, 3); //
// setMaxDamage(tier->getUses());
// aux value for diggers can go as high as 1561
//const _Tier *_Tier::DIAMOND = new _Tier(3, 1561, 8, 3); //
// setMaxDamage(tier->getUses());
// int ItemInstance::getDamageValue()
// {
// return auxValue;
// }
// int ItemInstance::getDamageValue()
// {
// return auxValue;
// }
if ((m_iAuxVal & 0xFF) ==
0xFF) // 4J Stu - If the aux value is set to match any
m_iAuxVal = 0;
m_iCount = iCount;
m_fScale = (float)(iScale) / 10.0f;
// m_uiAlpha=uiAlpha;
m_fAlpha = ((float)(uiAlpha)) / 255.0f;
m_bDecorations = bDecorations;
// mif(bDecorations) m_iDecorations=1;
// else m_iDecorations=0;
if( (m_iAuxVal & 0xFF) == 0xFF) // 4J Stu - If the aux value is set to match any
m_iAuxVal = 0;
m_iPad = iPad;
m_iCount=iCount;
m_fScale = (float)(iScale)/10.0f;
//m_uiAlpha=uiAlpha;
m_fAlpha =((float)(uiAlpha)) / 255.0f;
m_bDecorations = bDecorations;
// mif(bDecorations) m_iDecorations=1;
// else m_iDecorations=0;
m_isFoil = isFoil;
m_iPad = iPad;
m_isFoil = isFoil;
XuiElementSetShow(m_hObj,bShow);
XuiElementSetShow(m_hObj, bShow);
}
void CXuiCtrlMinecraftSlot::SetIcon(int iPad, std::shared_ptr<ItemInstance> item, int iScale, unsigned int uiAlpha,bool bDecorations, bool bShow)
{
m_item = item;
m_isFoil = item->isFoil();
m_iPad = iPad;
m_fScale = (float)(iScale)/10.0f;
m_fAlpha =((float)(uiAlpha)) / 31;
m_bDecorations = bDecorations;
m_bDirty = TRUE;
XuiElementSetShow(m_hObj,bShow);
void CXuiCtrlMinecraftSlot::SetIcon(int iPad,
std::shared_ptr<ItemInstance> item,
int iScale, unsigned int uiAlpha,
bool bDecorations, bool bShow) {
m_item = item;
m_isFoil = item->isFoil();
m_iPad = iPad;
m_fScale = (float)(iScale) / 10.0f;
m_fAlpha = ((float)(uiAlpha)) / 31;
m_bDecorations = bDecorations;
m_bDirty = TRUE;
XuiElementSetShow(m_hObj, bShow);
}

View File

@@ -3,7 +3,7 @@
#include <string>
#include <XuiApp.h>
//using namespace std;
// using namespace std;
class TileRenderer;
class ItemRenderer;
@@ -11,49 +11,52 @@ class ItemRenderer;
//-----------------------------------------------------------------------------
// CXuiCtrlMinecraftSlot class
//-----------------------------------------------------------------------------
class CXuiCtrlMinecraftSlot : public CXuiControlImpl
{
class CXuiCtrlMinecraftSlot : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlMinecraftSlot, L"CXuiCtrlMinecraftSlot", XUI_CLASS_LABEL)
XUI_IMPLEMENT_CLASS(CXuiCtrlMinecraftSlot, L"CXuiCtrlMinecraftSlot",
XUI_CLASS_LABEL)
void SetPassThroughDataAssociation(unsigned int iID, unsigned int iData);
CXuiCtrlMinecraftSlot();
virtual ~CXuiCtrlMinecraftSlot();
void SetPassThroughDataAssociation(unsigned int iID, unsigned int iData);
CXuiCtrlMinecraftSlot();
virtual ~CXuiCtrlMinecraftSlot();
void renderGuiItem(Font *font, Textures *textures,ItemInstance *item, int x, int y);
void RenderItem();
void SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool bShow, bool isFoil);
void SetIcon(int iPad, std::shared_ptr<ItemInstance> item, int iScale, unsigned int uiAlpha,bool bDecorations, bool bShow=true);
void renderGuiItem(Font* font, Textures* textures, ItemInstance* item,
int x, int y);
void RenderItem();
void SetIcon(int iPad, int iId, int iAuxVal, int iCount, int iScale,
unsigned int uiAlpha, bool bDecorations, bool bShow,
bool isFoil);
void SetIcon(int iPad, std::shared_ptr<ItemInstance> item, int iScale,
unsigned int uiAlpha, bool bDecorations, bool bShow = true);
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceImage)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceImage)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
HRESULT OnGetSourceImage(XUIMessageGetSourceImage* pData, BOOL& rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender *pRenderData, BOOL &rfHandled);
HRESULT OnGetSourceImage(XUIMessageGetSourceImage* pData, BOOL& rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender* pRenderData, BOOL& rfHandled);
private:
std::shared_ptr<ItemInstance> m_item;
bool m_bDirty;
int m_iPassThroughDataAssociation;
int m_iPassThroughIdAssociation;
float m_fScale,m_fAlpha;
int m_iPad;
int m_iID;
int m_iCount;
int m_iAuxVal;
bool m_bDecorations;
bool m_isFoil;
int m_popTime;
std::shared_ptr<ItemInstance> m_item;
bool m_bDirty;
int m_iPassThroughDataAssociation;
int m_iPassThroughIdAssociation;
float m_fScale, m_fAlpha;
int m_iPad;
int m_iID;
int m_iCount;
int m_iAuxVal;
bool m_bDecorations;
bool m_isFoil;
int m_popTime;
bool m_bScreenWidthSetup;
float m_fScreenWidth,m_fScreenHeight;
ItemRenderer *m_pItemRenderer;
bool m_bScreenWidthSetup;
float m_fScreenWidth, m_fScreenHeight;
ItemRenderer* m_pItemRenderer;
static LPCWSTR xzpIcons[15];
static LPCWSTR xzpIcons[15];
};

View File

@@ -1,71 +1,48 @@
#include "../../Minecraft.World/Platform/stdafx.h"
#include "XUI_Ctrl_MobEffect.h"
LPCWSTR CXuiCtrlMobEffect::iconFrameNames[MobEffect::e_MobEffectIcon_COUNT]=
{
L"Normal",
L"Blindness",
L"Fire_Resistance",
L"Haste",
L"Hunger",
L"Invisibility",
L"Jump_Boost",
L"Mining_Fatigue",
L"Nausea",
L"Night_Vision",
L"Poison",
L"Regeneration",
L"Resistance",
L"Slowness",
L"Speed",
L"Strength",
L"Water_Breathing",
L"Weakness",
LPCWSTR CXuiCtrlMobEffect::iconFrameNames[MobEffect::e_MobEffectIcon_COUNT] = {
L"Normal", L"Blindness", L"Fire_Resistance", L"Haste",
L"Hunger", L"Invisibility", L"Jump_Boost", L"Mining_Fatigue",
L"Nausea", L"Night_Vision", L"Poison", L"Regeneration",
L"Resistance", L"Slowness", L"Speed", L"Strength",
L"Water_Breathing", L"Weakness",
};
HRESULT CXuiCtrlMobEffect::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
m_icon = MobEffect::e_MobEffectIcon_None;
m_name = L"";
m_duration = L"";
return S_OK;
HRESULT CXuiCtrlMobEffect::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled) {
m_icon = MobEffect::e_MobEffectIcon_None;
m_name = L"";
m_duration = L"";
return S_OK;
}
HRESULT CXuiCtrlMobEffect::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled)
{
if( pGetSourceTextData->iData == 1 )
{
pGetSourceTextData->szText = m_name.c_str();
pGetSourceTextData->bDisplay = TRUE;
HRESULT CXuiCtrlMobEffect::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
if (pGetSourceTextData->iData == 1) {
pGetSourceTextData->szText = m_name.c_str();
pGetSourceTextData->bDisplay = TRUE;
if(FAILED(PlayVisualRange(iconFrameNames[m_icon],NULL,iconFrameNames[m_icon])))
{
PlayVisualRange(L"Normal",NULL,L"Normal");
}
if (FAILED(PlayVisualRange(iconFrameNames[m_icon], NULL,
iconFrameNames[m_icon]))) {
PlayVisualRange(L"Normal", NULL, L"Normal");
}
bHandled = TRUE;
}
else if( pGetSourceTextData->iData == 2 )
{
pGetSourceTextData->szText = m_duration.c_str();
pGetSourceTextData->bDisplay = TRUE;
bHandled = TRUE;
} else if (pGetSourceTextData->iData == 2) {
pGetSourceTextData->szText = m_duration.c_str();
pGetSourceTextData->bDisplay = TRUE;
bHandled = TRUE;
}
return S_OK;
bHandled = TRUE;
}
return S_OK;
}
void CXuiCtrlMobEffect::setIcon(MobEffect::EMobEffectIcon icon)
{
m_icon = icon;
void CXuiCtrlMobEffect::setIcon(MobEffect::EMobEffectIcon icon) {
m_icon = icon;
}
void CXuiCtrlMobEffect::setName(const std::wstring &name)
{
m_name = name;
}
void CXuiCtrlMobEffect::setName(const std::wstring& name) { m_name = name; }
void CXuiCtrlMobEffect::setDuration(const std::wstring &duration)
{
m_duration = duration;
void CXuiCtrlMobEffect::setDuration(const std::wstring& duration) {
m_duration = duration;
}

View File

@@ -1,31 +1,32 @@
#pragma once
//using namespace std;
// using namespace std;
#include "../../Minecraft.World/Entities/MobEffect.h"
class CXuiCtrlMobEffect : public CXuiControlImpl
{
class CXuiCtrlMobEffect : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlMobEffect, L"CXuiCtrlMobEffect", XUI_CLASS_CONTROL)
XUI_IMPLEMENT_CLASS(CXuiCtrlMobEffect, L"CXuiCtrlMobEffect",
XUI_CLASS_CONTROL)
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
public:
void setIcon(MobEffect::EMobEffectIcon icon);
void setName(const std::wstring &name);
void setDuration(const std::wstring &duration);
void setIcon(MobEffect::EMobEffectIcon icon);
void setName(const std::wstring& name);
void setDuration(const std::wstring& duration);
private:
MobEffect::EMobEffectIcon m_icon;
std::wstring m_name;
std::wstring m_duration;
MobEffect::EMobEffectIcon m_icon;
std::wstring m_name;
std::wstring m_duration;
static LPCWSTR iconFrameNames[MobEffect::e_MobEffectIcon_COUNT];
static LPCWSTR iconFrameNames[MobEffect::e_MobEffectIcon_COUNT];
};

View File

@@ -1,109 +1,104 @@
#include "../../Minecraft.World/Platform/stdafx.h"
#include "XUI_Ctrl_PassThroughList.h"
HRESULT CXuiCtrlPassThroughList::OnInit(XUIMessageInit *pInitData, BOOL& bHandled)
{
return S_OK;
HRESULT CXuiCtrlPassThroughList::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
return S_OK;
}
HRESULT CXuiCtrlPassThroughList::OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled)
{
XUIMessage message;
XUIMessageInput messageInput;
HRESULT hr;
HXUIOBJ hObj;
XuiMessageInput( &message, &messageInput, XUI_KEYDOWN, pInputData->dwKeyCode, pInputData->wch, pInputData->dwFlags, pInputData->UserIndex );
HRESULT CXuiCtrlPassThroughList::OnKeyDown(XUIMessageInput* pInputData,
BOOL& bHandled) {
XUIMessage message;
XUIMessageInput messageInput;
HRESULT hr;
HXUIOBJ hObj;
hr = GetParent(&hObj);
XuiMessageInput(&message, &messageInput, XUI_KEYDOWN, pInputData->dwKeyCode,
pInputData->wch, pInputData->dwFlags,
pInputData->UserIndex);
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(hObj, &message);
hr = GetParent(&hObj);
if (message.bHandled)
{
bHandled = TRUE;
}
}
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(hObj, &message);
return S_OK;
if (message.bHandled) {
bHandled = TRUE;
}
}
return S_OK;
}
// Gets called every frame
HRESULT CXuiCtrlPassThroughList::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData,BOOL& bHandled)
{
XUIMessage Message;
XUIMessageGetSourceText MsgGetText;
HRESULT hr;
HXUIOBJ hObj;
HRESULT CXuiCtrlPassThroughList::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
XUIMessage Message;
XUIMessageGetSourceText MsgGetText;
HRESULT hr;
HXUIOBJ hObj;
XuiMessageGetSourceText(&Message, &MsgGetText, pGetSourceTextData->iItem, pGetSourceTextData->iData, pGetSourceTextData->bItemData);
XuiMessageGetSourceText(&Message, &MsgGetText, pGetSourceTextData->iItem,
pGetSourceTextData->iData,
pGetSourceTextData->bItemData);
hr = GetParent(&hObj);
hr = GetParent(&hObj);
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(hObj, &Message);
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(hObj, &Message);
if (Message.bHandled)
{
pGetSourceTextData->szText = MsgGetText.szText;
bHandled = TRUE;
}
}
return S_OK;
if (Message.bHandled) {
pGetSourceTextData->szText = MsgGetText.szText;
bHandled = TRUE;
}
}
return S_OK;
}
// Gets called every frame
HRESULT CXuiCtrlPassThroughList::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled)
{
XUIMessage Message;
XUIMessageGetSourceImage MsgGetImage;
HRESULT hr;
HXUIOBJ hObj;
HRESULT CXuiCtrlPassThroughList::OnGetSourceDataImage(
XUIMessageGetSourceImage* pGetSourceImageData, BOOL& bHandled) {
XUIMessage Message;
XUIMessageGetSourceImage MsgGetImage;
HRESULT hr;
HXUIOBJ hObj;
XuiMessageGetSourceImage(&Message, &MsgGetImage, pGetSourceImageData->iItem, pGetSourceImageData->iData, pGetSourceImageData->bItemData);
XuiMessageGetSourceImage(&Message, &MsgGetImage, pGetSourceImageData->iItem,
pGetSourceImageData->iData,
pGetSourceImageData->bItemData);
hr = GetParent(&hObj);
hr = GetParent(&hObj);
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(hObj, &Message);
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(hObj, &Message);
if (Message.bHandled)
{
pGetSourceImageData->szPath = MsgGetImage.szPath;
bHandled = TRUE;
}
}
return S_OK;
if (Message.bHandled) {
pGetSourceImageData->szPath = MsgGetImage.szPath;
bHandled = TRUE;
}
}
return S_OK;
}
HRESULT CXuiCtrlPassThroughList::OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData,BOOL& bHandled)
{
XUIMessage Message;
XUIMessageGetItemCount MsgGetItemCountAll;
HRESULT hr;
HXUIOBJ hObj;
HRESULT CXuiCtrlPassThroughList::OnGetItemCountAll(
XUIMessageGetItemCount* pGetItemCountData, BOOL& bHandled) {
XUIMessage Message;
XUIMessageGetItemCount MsgGetItemCountAll;
HRESULT hr;
HXUIOBJ hObj;
XuiMessageGetItemCount(&Message, &MsgGetItemCountAll, XUI_ITEMCOUNT_ALL);
XuiMessageGetItemCount(&Message, &MsgGetItemCountAll, XUI_ITEMCOUNT_ALL);
hr = GetParent(&hObj);
hr = GetParent(&hObj);
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(hObj, &Message);
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(hObj, &Message);
if (Message.bHandled)
{
pGetItemCountData->cItems = MsgGetItemCountAll.cItems;
bHandled = TRUE;
}
}
bHandled = TRUE;
return S_OK;
if (Message.bHandled) {
pGetItemCountData->cItems = MsgGetItemCountAll.cItems;
bHandled = TRUE;
}
}
bHandled = TRUE;
return S_OK;
}

View File

@@ -1,28 +1,28 @@
#pragma once
// 4J Stu - A list control that responds by sending the message to it's parent and
// returning what the parent returns
// 4J Stu - A list control that responds by sending the message to it's parent
// and returning what the parent returns
class CXuiCtrlPassThroughList : public CXuiListImpl
{
class CXuiCtrlPassThroughList : public CXuiListImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlPassThroughList, L"CXuiCtrlPassThroughList", XUI_CLASS_LIST);
XUI_IMPLEMENT_CLASS(CXuiCtrlPassThroughList, L"CXuiCtrlPassThroughList",
XUI_CLASS_LIST);
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_END_MSG_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetSourceImageData,
BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
};

View File

@@ -2,21 +2,22 @@
#include "XUI_Ctrl_ProgressCtrlBase.h"
HRESULT CXuiCtrlProgressCtrlBase::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled)
{
// The Xui backend calls GetSourceDataText every frame to get the text for the indexed label
// We don't want to change the label, but take this opportunity to send out a message to ourself
// to update the value of the progress bar
this->SetValue( GetValue() );
HRESULT CXuiCtrlProgressCtrlBase::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
// The Xui backend calls GetSourceDataText every frame to get the text for
// the indexed label We don't want to change the label, but take this
// opportunity to send out a message to ourself to update the value of the
// progress bar
this->SetValue(GetValue());
int min, max;
this->GetRange( &min, &max );
this->SetRange( min, max );
int min, max;
this->GetRange(&min, &max);
this->SetRange(min, max);
pGetSourceTextData->szText = L"";
pGetSourceTextData->bDisplay = FALSE;
pGetSourceTextData->szText = L"";
pGetSourceTextData->bDisplay = FALSE;
bHandled = TRUE;
bHandled = TRUE;
return S_OK;
return S_OK;
}

View File

@@ -1,11 +1,13 @@
#pragma once
class CXuiCtrlProgressCtrlBase : public CXuiProgressBar, public CXuiElementImplBase
{
class CXuiCtrlProgressCtrlBase : public CXuiProgressBar,
public CXuiElementImplBase {
public:
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
// Override these in the derived classes to return the values to be displayed on the control
virtual int GetValue() = 0;
virtual void GetRange(int *pnRangeMin, int *pnRangeMax) = 0;
// Override these in the derived classes to return the values to be
// displayed on the control
virtual int GetValue() = 0;
virtual void GetRange(int* pnRangeMin, int* pnRangeMax) = 0;
};

View File

@@ -3,172 +3,156 @@
#define NO_SOUND_TIMER 0
HRESULT CXuiCtrlSliderWrapper::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
void *pObj;
HXUIOBJ hObjChild;
HRESULT CXuiCtrlSliderWrapper::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
void* pObj;
HXUIOBJ hObjChild;
XuiElementGetChildById(m_hObj,L"FocusSink",&hObjChild);
XuiObjectFromHandle( hObjChild, &pObj );
m_pFocusSink = (CXuiControl *)pObj;
XuiElementGetChildById(m_hObj, L"FocusSink", &hObjChild);
XuiObjectFromHandle(hObjChild, &pObj);
m_pFocusSink = (CXuiControl*)pObj;
XuiElementGetChildById(m_hObj,L"XuiSlider",&hObjChild);
XuiObjectFromHandle( hObjChild, &pObj );
m_pSlider = (CXuiSlider *)pObj;
XuiElementGetChildById(m_hObj, L"XuiSlider", &hObjChild);
XuiObjectFromHandle(hObjChild, &pObj);
m_pSlider = (CXuiSlider*)pObj;
m_sliderActive = false;
m_bDisplayVal = true;
m_bPlaySound = false; // make this false to avoid a sound being played in the first setting of the slider value in a scene
XuiSetTimer( m_hObj,NO_SOUND_TIMER,50);
bHandled = TRUE;
return S_OK;
m_sliderActive = false;
m_bDisplayVal = true;
m_bPlaySound = false; // make this false to avoid a sound being played in
// the first setting of the slider value in a scene
XuiSetTimer(m_hObj, NO_SOUND_TIMER, 50);
bHandled = TRUE;
return S_OK;
}
HRESULT CXuiCtrlSliderWrapper::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CXuiCtrlSliderWrapper::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
// switch(pInputData->dwKeyCode)
// {
// switch(pInputData->dwKeyCode)
// {
// case VK_PAD_A:
// // 4J-PB - IGNORE !
// if(m_sliderActive)
// {
// m_pFocusSink->SetFocus(pInputData->UserIndex);
// m_sliderActive = false;
// }
// else
// {
// m_pSlider->SetFocus(pInputData->UserIndex);
// m_sliderActive = true;
// }
// rfHandled = TRUE;
//
// break;
// default:
// m_pSlider->SetFocus(pInputData->UserIndex);
// m_sliderActive = false;
// break;
//
// }
//
return S_OK;
// case VK_PAD_A:
// // 4J-PB - IGNORE !
// if(m_sliderActive)
// {
// m_pFocusSink->SetFocus(pInputData->UserIndex);
// m_sliderActive = false;
// }
// else
// {
// m_pSlider->SetFocus(pInputData->UserIndex);
// m_sliderActive = true;
// }
// rfHandled = TRUE;
//
// break;
// default:
// m_pSlider->SetFocus(pInputData->UserIndex);
// m_sliderActive = false;
// break;
//
// }
//
return S_OK;
}
HRESULT CXuiCtrlSliderWrapper::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValueChanged* pValueChangedData, BOOL& rfHandled)
{
XUIMessage Message;
XUINotify Notify;
XUINotifyValueChanged MsgValueChanged;
HRESULT hr;
HXUIOBJ hObj;
if(m_bPlaySound)
{
m_bPlaySound = false;
CXuiSceneBase::PlayUISFX(eSFX_Scroll);
XuiSetTimer( m_hObj,NO_SOUND_TIMER,150);
}
HRESULT CXuiCtrlSliderWrapper::OnNotifyValueChanged(
HXUIOBJ hObjSource, XUINotifyValueChanged* pValueChangedData,
BOOL& rfHandled) {
XUIMessage Message;
XUINotify Notify;
XUINotifyValueChanged MsgValueChanged;
HRESULT hr;
HXUIOBJ hObj;
//app.DebugPrintf("Slider val changed - %d\n",pValueChangedData->nValue);
if (m_bPlaySound) {
m_bPlaySound = false;
CXuiSceneBase::PlayUISFX(eSFX_Scroll);
XuiSetTimer(m_hObj, NO_SOUND_TIMER, 150);
}
XuiNotifyValueChanged(&Message,&Notify,&MsgValueChanged,hObjSource,pValueChangedData->nValue);
// app.DebugPrintf("Slider val changed - %d\n",pValueChangedData->nValue);
hr = GetParent(&hObj);
XuiNotifyValueChanged(&Message, &Notify, &MsgValueChanged, hObjSource,
pValueChangedData->nValue);
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(hObj, &Message);
rfHandled = TRUE;
}
return S_OK;
hr = GetParent(&hObj);
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(hObj, &Message);
rfHandled = TRUE;
}
return S_OK;
}
HRESULT CXuiCtrlSliderWrapper::OnTimer(XUIMessageTimer* pData,
BOOL& rfHandled) {
if (pData->nId == NO_SOUND_TIMER) {
XuiKillTimer(m_hObj, NO_SOUND_TIMER);
m_bPlaySound = true;
}
HRESULT CXuiCtrlSliderWrapper::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled)
{
if(pData->nId==NO_SOUND_TIMER)
{
XuiKillTimer(m_hObj,NO_SOUND_TIMER);
m_bPlaySound=true;
}
return S_OK;
return S_OK;
}
HRESULT CXuiCtrlSliderWrapper::SetValue( int nValue )
{
CXuiCtrlSliderWrapper *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
HRESULT CXuiCtrlSliderWrapper::SetValue(int nValue) {
CXuiCtrlSliderWrapper* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
pThis->m_pSlider->SetValue(nValue);
return S_OK;
pThis->m_pSlider->SetValue(nValue);
return S_OK;
}
HRESULT CXuiCtrlSliderWrapper::SetValueDisplay(bool show)
{
CXuiCtrlSliderWrapper *pThis;
HXUIOBJ hVisual,hText;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
HRESULT CXuiCtrlSliderWrapper::SetValueDisplay(bool show) {
CXuiCtrlSliderWrapper* pThis;
HXUIOBJ hVisual, hText;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
hr=XuiControlGetVisual(pThis->m_pSlider->m_hObj,&hVisual);
hr=XuiElementGetChildById(hVisual,L"Text_Value",&hText);
hr = XuiControlGetVisual(pThis->m_pSlider->m_hObj, &hVisual);
hr = XuiElementGetChildById(hVisual, L"Text_Value", &hText);
if(hText!=NULL)
{
XuiElementSetShow(hText,show);
}
if (hText != NULL) {
XuiElementSetShow(hText, show);
}
return S_OK;
return S_OK;
}
LPCWSTR CXuiCtrlSliderWrapper::GetText( )
{
CXuiCtrlSliderWrapper *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return NULL;
return pThis->m_pSlider->GetText();
//return S_OK;
LPCWSTR CXuiCtrlSliderWrapper::GetText() {
CXuiCtrlSliderWrapper* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return NULL;
return pThis->m_pSlider->GetText();
// return S_OK;
}
HRESULT CXuiCtrlSliderWrapper::SetText(LPCWSTR text , int iDataAssoc)
{
CXuiCtrlSliderWrapper *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
HRESULT CXuiCtrlSliderWrapper::SetText(LPCWSTR text, int iDataAssoc) {
CXuiCtrlSliderWrapper* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
// if there's a data assoc value, find the right control for it
if(iDataAssoc!=0)
{
// if there's a data assoc value, find the right control for it
if (iDataAssoc != 0) {
}
}
pThis->m_pSlider->SetText(text);
return hr;
pThis->m_pSlider->SetText(text);
return hr;
}
HXUIOBJ CXuiCtrlSliderWrapper::GetSlider()
{
CXuiCtrlSliderWrapper *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return NULL;
return pThis->m_pSlider->m_hObj;
HXUIOBJ CXuiCtrlSliderWrapper::GetSlider() {
CXuiCtrlSliderWrapper* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return NULL;
return pThis->m_pSlider->m_hObj;
}
HRESULT CXuiCtrlSliderWrapper::SetRange( int nRangeMin, int nRangeMax)
{
CXuiCtrlSliderWrapper *pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
if (FAILED(hr))
return hr;
pThis->m_pSlider->SetRange(nRangeMin, nRangeMax);
return S_OK;
HRESULT CXuiCtrlSliderWrapper::SetRange(int nRangeMin, int nRangeMax) {
CXuiCtrlSliderWrapper* pThis;
HRESULT hr = XuiObjectFromHandle(m_hObj, (void**)&pThis);
if (FAILED(hr)) return hr;
pThis->m_pSlider->SetRange(nRangeMin, nRangeMax);
return S_OK;
}

View File

@@ -1,38 +1,39 @@
#pragma once
class CXuiCtrlSliderWrapper : public CXuiSceneImpl
{
class CXuiCtrlSliderWrapper : public CXuiSceneImpl {
private:
CXuiSlider *m_pSlider;
CXuiControl *m_pFocusSink;
bool m_sliderActive;
bool m_bDisplayVal;
bool m_bPlaySound;
CXuiSlider* m_pSlider;
CXuiControl* m_pFocusSink;
bool m_sliderActive;
bool m_bDisplayVal;
bool m_bPlaySound;
protected:
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_TIMER( OnTimer )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_TIMER(OnTimer)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged(HXUIOBJ hObjSource,
XUINotifyValueChanged* pValueChangedData,
BOOL& rfHandled);
HRESULT OnTimer(XUIMessageTimer* pData, BOOL& rfHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValueChanged* pValueChangedData, BOOL& rfHandled);
HRESULT OnTimer(XUIMessageTimer *pData,BOOL& rfHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiCtrlSliderWrapper, L"CXuiCtrlSliderWrapper",
XUI_CLASS_SCENE)
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlSliderWrapper, L"CXuiCtrlSliderWrapper", XUI_CLASS_SCENE )
HRESULT SetValue( int nValue );
HXUIOBJ GetSlider();
HRESULT SetRange( int nRangeMin, int nRangeMax);
LPCWSTR GetText( );
HRESULT SetText(LPCWSTR text, int iDataAssoc=0 );
HRESULT SetValueDisplay( bool show );
HRESULT SetValue(int nValue);
HXUIOBJ GetSlider();
HRESULT SetRange(int nRangeMin, int nRangeMax);
LPCWSTR GetText();
HRESULT SetText(LPCWSTR text, int iDataAssoc = 0);
HRESULT SetValueDisplay(bool show);
};

View File

@@ -1,37 +1,48 @@
#pragma once
#include "XUI_Ctrl_SlotItemCtrlBase.h"
class CXuiCtrlSlotItem : public CXuiControlImpl, public CXuiCtrlSlotItemCtrlBase
{
class CXuiCtrlSlotItem : public CXuiControlImpl,
public CXuiCtrlSlotItemCtrlBase {
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlSlotItem, L"CXuiCtrlSlotItem", XUI_CLASS_CONTROL )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiCtrlSlotItem, L"CXuiCtrlSlotItem",
XUI_CLASS_CONTROL)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_GETSLOTITEM_MESSAGE(OnCustomMessage_GetSlotItem)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_GETSLOTITEM_MESSAGE(OnCustomMessage_GetSlotItem)
// 4J WESTY : Pointer Prototype : Added to support prototype only.
XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate )
// 4J WESTY : Pointer Prototype : Added to support prototype only.
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_ON_XM_KEYDOWN( OnKeyDown )
XUI_END_MSG_MAP()
using CXuiCtrlSlotItemCtrlBase::OnInit;
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled) { return this->OnInit( m_hObj, pInitData, bHandled ); };
using CXuiCtrlSlotItemCtrlBase::OnDestroy;
HRESULT OnDestroy() { return this->OnDestroy( m_hObj ); };
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_END_MSG_MAP()
using CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem;
HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled) { return this->OnCustomMessage_GetSlotItem( m_hObj, pData, bHandled ); };
using CXuiCtrlSlotItemCtrlBase::OnInit;
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
return this->OnInit(m_hObj, pInitData, bHandled);
};
// 4J WESTY : Pointer Prototype : Added to support prototype only.
using CXuiCtrlSlotItemCtrlBase::OnControlNavigate;
HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) { return this->OnControlNavigate( m_hObj, pControlNavigateData, bHandled ); };
using CXuiCtrlSlotItemCtrlBase::OnDestroy;
HRESULT OnDestroy() { return this->OnDestroy(m_hObj); };
using CXuiCtrlSlotItemCtrlBase::OnKeyDown;
HRESULT OnKeyDown(XUIMessageInput *pInputData, BOOL& bHandled) { return this->OnKeyDown( m_hObj, pInputData, bHandled ); };
using CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem;
HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct* pData,
BOOL& bHandled) {
return this->OnCustomMessage_GetSlotItem(m_hObj, pData, bHandled);
};
// 4J WESTY : Pointer Prototype : Added to support prototype only.
using CXuiCtrlSlotItemCtrlBase::OnControlNavigate;
HRESULT OnControlNavigate(XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled) {
return this->OnControlNavigate(m_hObj, pControlNavigateData, bHandled);
};
using CXuiCtrlSlotItemCtrlBase::OnKeyDown;
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled) {
return this->OnKeyDown(m_hObj, pInputData, bHandled);
};
};

View File

@@ -8,385 +8,373 @@
#include "XUI_Ctrl_SlotItemCtrlBase.h"
HRESULT CXuiCtrlSlotItemCtrlBase::OnInit( HXUIOBJ hObj, XUIMessageInit* pInitData, BOOL& bHandled )
{
HRESULT hr = S_OK;
SlotControlUserDataContainer* pvUserData = new SlotControlUserDataContainer();
hr = XuiElementSetUserData(hObj, (void *)pvUserData );
HRESULT CXuiCtrlSlotItemCtrlBase::OnInit(HXUIOBJ hObj,
XUIMessageInit* pInitData,
BOOL& bHandled) {
HRESULT hr = S_OK;
SlotControlUserDataContainer* pvUserData =
new SlotControlUserDataContainer();
hr = XuiElementSetUserData(hObj, (void*)pvUserData);
// 4J WESTY : Pointer Prototype : Added to support prototype only.
m_bSkipDefaultNavigation = false;
// 4J WESTY : Pointer Prototype : Added to support prototype only.
m_bSkipDefaultNavigation = false;
return hr;
return hr;
}
HRESULT CXuiCtrlSlotItemCtrlBase::OnDestroy( HXUIOBJ hObj )
{
HRESULT hr = S_OK;
void* pvUserData;
hr = XuiElementGetUserData( hObj, &pvUserData );
HRESULT CXuiCtrlSlotItemCtrlBase::OnDestroy(HXUIOBJ hObj) {
HRESULT hr = S_OK;
void* pvUserData;
hr = XuiElementGetUserData(hObj, &pvUserData);
if( pvUserData != NULL )
{
delete pvUserData;
}
if (pvUserData != NULL) {
delete pvUserData;
}
return hr;
return hr;
}
HRESULT CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem(HXUIOBJ hObj, CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled)
{
std::shared_ptr<ItemInstance> item = std::shared_ptr<ItemInstance>();
HRESULT CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem(
HXUIOBJ hObj, CustomMessage_GetSlotItem_Struct* pData, BOOL& bHandled) {
std::shared_ptr<ItemInstance> item = std::shared_ptr<ItemInstance>();
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
if( pUserDataContainer->slot != NULL )
{
item = pUserDataContainer->slot->getItem();
}
else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT)
{
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] );
if(player != NULL) item = player->inventory->getCarried();
}
if (pUserDataContainer->slot != NULL) {
item = pUserDataContainer->slot->getItem();
} else if (pUserDataContainer->m_iPad >= 0 &&
pUserDataContainer->m_iPad < XUSER_MAX_COUNT) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad]);
if (player != NULL) item = player->inventory->getCarried();
}
if( item != NULL )
{
pData->item = item;
pData->iItemBitField = MAKE_SLOTDISPLAY_ITEM_BITMASK(item->id,item->getAuxValue(),item->isFoil());
//int iAuxVal=item->getAuxValue();
//int iCount = item->GetCount();
// 8 bits - alpha
// 1 bit - decorations on
// 11 bits - auxval
// 6 bits - count
// 6 bits - scale
pData->iDataBitField = MAKE_SLOTDISPLAY_DATA_BITMASK(pUserDataContainer->m_iPad, (int)(31*pUserDataContainer->m_fAlpha),true,item->GetCount(),7,item->popTime);
}
else
{
//pGetSourceImageData->iData = 0;
pData->szPath = L"";
}
if (item != NULL) {
pData->item = item;
pData->iItemBitField = MAKE_SLOTDISPLAY_ITEM_BITMASK(
item->id, item->getAuxValue(), item->isFoil());
// int iAuxVal=item->getAuxValue();
// int iCount = item->GetCount();
// 8 bits - alpha
// 1 bit - decorations on
// 11 bits - auxval
// 6 bits - count
// 6 bits - scale
pData->iDataBitField = MAKE_SLOTDISPLAY_DATA_BITMASK(
pUserDataContainer->m_iPad,
(int)(31 * pUserDataContainer->m_fAlpha), true, item->GetCount(), 7,
item->popTime);
} else {
// pGetSourceImageData->iData = 0;
pData->szPath = L"";
}
bHandled = TRUE;
bHandled = TRUE;
return S_OK;
return S_OK;
}
void CXuiCtrlSlotItemCtrlBase::SetSlot( HXUIOBJ hObj, Slot* slot )
{
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
void CXuiCtrlSlotItemCtrlBase::SetSlot(HXUIOBJ hObj, Slot* slot) {
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
pUserDataContainer->slot = slot;
pUserDataContainer->slot = slot;
}
void CXuiCtrlSlotItemCtrlBase::SetUserIndex( HXUIOBJ hObj, int iPad )
{
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
void CXuiCtrlSlotItemCtrlBase::SetUserIndex(HXUIOBJ hObj, int iPad) {
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
pUserDataContainer->m_iPad = iPad;
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
pUserDataContainer->m_iPad = iPad;
}
void CXuiCtrlSlotItemCtrlBase::SetAlpha( HXUIOBJ hObj, float fAlpha )
{
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
void CXuiCtrlSlotItemCtrlBase::SetAlpha(HXUIOBJ hObj, float fAlpha) {
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
pUserDataContainer->m_fAlpha = fAlpha;
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
pUserDataContainer->m_fAlpha = fAlpha;
}
bool CXuiCtrlSlotItemCtrlBase::isEmpty( HXUIOBJ hObj )
{
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
bool CXuiCtrlSlotItemCtrlBase::isEmpty(HXUIOBJ hObj) {
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
if(pUserDataContainer->slot != NULL)
{
return !pUserDataContainer->slot->hasItem();
}
else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT)
{
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] );
if(player != NULL) return player->inventory->getCarried() == NULL;
}
return true;
if (pUserDataContainer->slot != NULL) {
return !pUserDataContainer->slot->hasItem();
} else if (pUserDataContainer->m_iPad >= 0 &&
pUserDataContainer->m_iPad < XUSER_MAX_COUNT) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad]);
if (player != NULL) return player->inventory->getCarried() == NULL;
}
return true;
}
std::wstring CXuiCtrlSlotItemCtrlBase::GetItemDescription( HXUIOBJ hObj, std::vector<std::wstring> &unformattedStrings )
{
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
std::wstring CXuiCtrlSlotItemCtrlBase::GetItemDescription(
HXUIOBJ hObj, std::vector<std::wstring>& unformattedStrings) {
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
if(pUserDataContainer->slot != NULL)
{
std::wstring desc = L"";
std::vector<std::wstring> *strings = pUserDataContainer->slot->getItem()->getHoverText(Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad], false, unformattedStrings);
bool firstLine = true;
for(AUTO_VAR(it, strings->begin()); it != strings->end(); ++it)
{
std::wstring thisString = *it;
if(!firstLine)
{
desc.append( L"<br />" );
}
else
{
firstLine = false;
wchar_t formatted[256];
eMinecraftColour rarityColour = pUserDataContainer->slot->getItem()->getRarity()->color;
int colour = app.GetHTMLColour(rarityColour);
if (pUserDataContainer->slot != NULL) {
std::wstring desc = L"";
std::vector<std::wstring>* strings =
pUserDataContainer->slot->getItem()->getHoverText(
Minecraft::GetInstance()
->localplayers[pUserDataContainer->m_iPad],
false, unformattedStrings);
bool firstLine = true;
for (AUTO_VAR(it, strings->begin()); it != strings->end(); ++it) {
std::wstring thisString = *it;
if (!firstLine) {
desc.append(L"<br />");
} else {
firstLine = false;
wchar_t formatted[256];
eMinecraftColour rarityColour =
pUserDataContainer->slot->getItem()->getRarity()->color;
int colour = app.GetHTMLColour(rarityColour);
if(pUserDataContainer->slot->getItem()->hasCustomHoverName())
{
colour = app.GetHTMLColour(eTextColor_RenamedItemTitle);
}
if (pUserDataContainer->slot->getItem()->hasCustomHoverName()) {
colour = app.GetHTMLColour(eTextColor_RenamedItemTitle);
}
swprintf(formatted, 256, L"<font color=\"#%08x\">%s</font>",colour,thisString.c_str());
thisString = formatted;
}
desc.append( thisString );
}
strings->clear();
delete strings;
return desc;//app.GetString( pUserDataContainer->slot->getItem()->getDescriptionId() );
}
else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT)
{
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] );
if(player != NULL)
{
std::shared_ptr<ItemInstance> item = player->inventory->getCarried();
if(item != NULL) return app.GetString( item->getDescriptionId() );
}
}
return L"";
swprintf(formatted, 256, L"<font color=\"#%08x\">%s</font>",
colour, thisString.c_str());
thisString = formatted;
}
desc.append(thisString);
}
strings->clear();
delete strings;
return desc; // app.GetString(
// pUserDataContainer->slot->getItem()->getDescriptionId()
// );
} else if (pUserDataContainer->m_iPad >= 0 &&
pUserDataContainer->m_iPad < XUSER_MAX_COUNT) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad]);
if (player != NULL) {
std::shared_ptr<ItemInstance> item =
player->inventory->getCarried();
if (item != NULL) return app.GetString(item->getDescriptionId());
}
}
return L"";
}
std::shared_ptr<ItemInstance> CXuiCtrlSlotItemCtrlBase::getItemInstance( HXUIOBJ hObj )
{
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
std::shared_ptr<ItemInstance> CXuiCtrlSlotItemCtrlBase::getItemInstance(
HXUIOBJ hObj) {
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
if(pUserDataContainer->slot != NULL)
{
return pUserDataContainer->slot->getItem();
}
else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT)
{
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] );
if(player != NULL) return player->inventory->getCarried();
}
return nullptr;
if (pUserDataContainer->slot != NULL) {
return pUserDataContainer->slot->getItem();
} else if (pUserDataContainer->m_iPad >= 0 &&
pUserDataContainer->m_iPad < XUSER_MAX_COUNT) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad]);
if (player != NULL) return player->inventory->getCarried();
}
return nullptr;
}
Slot *CXuiCtrlSlotItemCtrlBase::getSlot( HXUIOBJ hObj )
{
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
Slot* CXuiCtrlSlotItemCtrlBase::getSlot(HXUIOBJ hObj) {
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
return pUserDataContainer->slot;
return pUserDataContainer->slot;
}
HRESULT CXuiCtrlSlotItemCtrlBase::OnKeyDown(HXUIOBJ hObj, XUIMessageInput *pInputData, BOOL& bHandled)
{
if( pInputData->dwKeyCode == VK_PAD_DPAD_LEFT ||
pInputData->dwKeyCode == VK_PAD_DPAD_RIGHT ||
pInputData->dwKeyCode == VK_PAD_DPAD_UP ||
pInputData->dwKeyCode == VK_PAD_DPAD_DOWN ||
pInputData->dwKeyCode == VK_PAD_LTRIGGER ||
pInputData->dwKeyCode == VK_PAD_RTRIGGER)
{
HXUIOBJ parent;
HRESULT hr;
hr = XuiElementGetParent( hObj, &parent );
HRESULT CXuiCtrlSlotItemCtrlBase::OnKeyDown(HXUIOBJ hObj,
XUIMessageInput* pInputData,
BOOL& bHandled) {
if (pInputData->dwKeyCode == VK_PAD_DPAD_LEFT ||
pInputData->dwKeyCode == VK_PAD_DPAD_RIGHT ||
pInputData->dwKeyCode == VK_PAD_DPAD_UP ||
pInputData->dwKeyCode == VK_PAD_DPAD_DOWN ||
pInputData->dwKeyCode == VK_PAD_LTRIGGER ||
pInputData->dwKeyCode == VK_PAD_RTRIGGER) {
HXUIOBJ parent;
HRESULT hr;
hr = XuiElementGetParent(hObj, &parent);
XUIMessage message;
XUIMessageInput messageInput;
XuiMessageInput( &message, &messageInput, XUI_KEYDOWN, pInputData->dwKeyCode, pInputData->wch, pInputData->dwFlags, pInputData->UserIndex );
XUIMessage message;
XUIMessageInput messageInput;
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(parent, &message);
XuiMessageInput(&message, &messageInput, XUI_KEYDOWN,
pInputData->dwKeyCode, pInputData->wch,
pInputData->dwFlags, pInputData->UserIndex);
if (message.bHandled)
{
bHandled = TRUE;
}
}
}
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(parent, &message);
return S_OK;
if (message.bHandled) {
bHandled = TRUE;
}
}
}
return S_OK;
}
// 4J WESTY : Pointer Prototype : Added to support prototype only.
HRESULT CXuiCtrlSlotItemCtrlBase::OnControlNavigate( HXUIOBJ hObj, XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled)
{
// Skip default navigation behaviour when navigation is by pointer.
if ( m_bSkipDefaultNavigation )
{
pControlNavigateData->bSkipNavigate = TRUE;
bHandled = TRUE;
}
return S_OK;
HRESULT CXuiCtrlSlotItemCtrlBase::OnControlNavigate(
HXUIOBJ hObj, XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled) {
// Skip default navigation behaviour when navigation is by pointer.
if (m_bSkipDefaultNavigation) {
pControlNavigateData->bSkipNavigate = TRUE;
bHandled = TRUE;
}
return S_OK;
}
// 4J WESTY : Pointer Prototype : Added to support prototype only.
int CXuiCtrlSlotItemCtrlBase::GetObjectCount( HXUIOBJ hObj )
{
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
int CXuiCtrlSlotItemCtrlBase::GetObjectCount(HXUIOBJ hObj) {
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
int iCount = 0;
int iCount = 0;
if(pUserDataContainer->slot != NULL)
{
if ( pUserDataContainer->slot->hasItem() )
{
iCount = pUserDataContainer->slot->getItem()->GetCount();
}
}
else if(pUserDataContainer->m_iPad >= 0 && pUserDataContainer->m_iPad < XUSER_MAX_COUNT)
{
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>( Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad] );
if(player != NULL && player->inventory->getCarried() != NULL)
{
iCount = player->inventory->getCarried()->count;
}
}
return iCount;
if (pUserDataContainer->slot != NULL) {
if (pUserDataContainer->slot->hasItem()) {
iCount = pUserDataContainer->slot->getItem()->GetCount();
}
} else if (pUserDataContainer->m_iPad >= 0 &&
pUserDataContainer->m_iPad < XUSER_MAX_COUNT) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()->localplayers[pUserDataContainer->m_iPad]);
if (player != NULL && player->inventory->getCarried() != NULL) {
iCount = player->inventory->getCarried()->count;
}
}
return iCount;
}
// 4J WESTY : Pointer Prototype : Added to support prototype only.
bool CXuiCtrlSlotItemCtrlBase::IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj )
{
bool bThisItemExists = false;
int iThisID = 0;
int iThisAux = 0;
bool CXuiCtrlSlotItemCtrlBase::IsSameItemAs(HXUIOBJ hThisObj,
HXUIOBJ hOtherObj) {
bool bThisItemExists = false;
int iThisID = 0;
int iThisAux = 0;
bool bOtherItemExists = false;
int iOtherID = 0;
int iOtherAux = 0;
bool bOtherItemExists = false;
int iOtherID = 0;
int iOtherAux = 0;
bool bStackedByData = false;
bool bStackedByData = false;
// Get the info on this item.
void* pvThisUserData;
XuiElementGetUserData( hThisObj, &pvThisUserData );
SlotControlUserDataContainer* pThisUserDataContainer = (SlotControlUserDataContainer*)pvThisUserData;
// Get the info on this item.
void* pvThisUserData;
XuiElementGetUserData(hThisObj, &pvThisUserData);
SlotControlUserDataContainer* pThisUserDataContainer =
(SlotControlUserDataContainer*)pvThisUserData;
if(pThisUserDataContainer->slot != NULL)
{
if ( pThisUserDataContainer->slot->hasItem() )
{
iThisID = pThisUserDataContainer->slot->getItem()->id;
iThisAux = pThisUserDataContainer->slot->getItem()->getAuxValue();
bThisItemExists = true;
bStackedByData = pThisUserDataContainer->slot->getItem()->isStackedByData();
}
}
else if(pThisUserDataContainer->m_iPad >= 0 && pThisUserDataContainer->m_iPad < XUSER_MAX_COUNT)
{
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>( Minecraft::GetInstance()->localplayers[pThisUserDataContainer->m_iPad] );
if(player != NULL && player->inventory->getCarried() != NULL)
{
iThisID = player->inventory->getCarried()->id;
iThisAux = player->inventory->getCarried()->getAuxValue();
bThisItemExists = true;
bStackedByData = player->inventory->getCarried()->isStackedByData();
}
if (pThisUserDataContainer->slot != NULL) {
if (pThisUserDataContainer->slot->hasItem()) {
iThisID = pThisUserDataContainer->slot->getItem()->id;
iThisAux = pThisUserDataContainer->slot->getItem()->getAuxValue();
bThisItemExists = true;
bStackedByData =
pThisUserDataContainer->slot->getItem()->isStackedByData();
}
} else if (pThisUserDataContainer->m_iPad >= 0 &&
pThisUserDataContainer->m_iPad < XUSER_MAX_COUNT) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()
->localplayers[pThisUserDataContainer->m_iPad]);
if (player != NULL && player->inventory->getCarried() != NULL) {
iThisID = player->inventory->getCarried()->id;
iThisAux = player->inventory->getCarried()->getAuxValue();
bThisItemExists = true;
bStackedByData = player->inventory->getCarried()->isStackedByData();
}
}
}
// Get the info on other item.
void* pvOtherUserData;
XuiElementGetUserData(hOtherObj, &pvOtherUserData);
SlotControlUserDataContainer* pOtherUserDataContainer =
(SlotControlUserDataContainer*)pvOtherUserData;
// Get the info on other item.
void* pvOtherUserData;
XuiElementGetUserData( hOtherObj, &pvOtherUserData );
SlotControlUserDataContainer* pOtherUserDataContainer = (SlotControlUserDataContainer*)pvOtherUserData;
if (pOtherUserDataContainer->slot != NULL) {
if (pOtherUserDataContainer->slot->hasItem()) {
iOtherID = pOtherUserDataContainer->slot->getItem()->id;
iOtherAux = pOtherUserDataContainer->slot->getItem()->getAuxValue();
bOtherItemExists = true;
}
} else if (pOtherUserDataContainer->m_iPad >= 0 &&
pOtherUserDataContainer->m_iPad < XUSER_MAX_COUNT) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()
->localplayers[pOtherUserDataContainer->m_iPad]);
if (player != NULL && player->inventory->getCarried() != NULL) {
iOtherID = player->inventory->getCarried()->id;
iOtherAux = player->inventory->getCarried()->getAuxValue();
bOtherItemExists = true;
}
}
if(pOtherUserDataContainer->slot != NULL)
{
if ( pOtherUserDataContainer->slot->hasItem() )
{
iOtherID = pOtherUserDataContainer->slot->getItem()->id;
iOtherAux = pOtherUserDataContainer->slot->getItem()->getAuxValue();
bOtherItemExists = true;
}
}
else if(pOtherUserDataContainer->m_iPad >= 0 && pOtherUserDataContainer->m_iPad < XUSER_MAX_COUNT)
{
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>( Minecraft::GetInstance()->localplayers[pOtherUserDataContainer->m_iPad] );
if(player != NULL && player->inventory->getCarried() != NULL)
{
iOtherID = player->inventory->getCarried()->id;
iOtherAux = player->inventory->getCarried()->getAuxValue();
bOtherItemExists = true;
}
}
if ( bThisItemExists && bOtherItemExists )
{
return ( ( iThisID == iOtherID ) && ( (bStackedByData && iThisAux == iOtherAux) || !bStackedByData ) );
}
else
{
return false;
}
if (bThisItemExists && bOtherItemExists) {
return ((iThisID == iOtherID) &&
((bStackedByData && iThisAux == iOtherAux) || !bStackedByData));
} else {
return false;
}
}
// 4J WESTY : Pointer Prototype : Added to support prototype only.
// Returns number of items that can still be stacked into this slot.
int CXuiCtrlSlotItemCtrlBase::GetEmptyStackSpace( HXUIOBJ hObj )
{
int iResult = 0;
int CXuiCtrlSlotItemCtrlBase::GetEmptyStackSpace(HXUIOBJ hObj) {
int iResult = 0;
void* pvUserData;
XuiElementGetUserData( hObj, &pvUserData );
SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
void* pvUserData;
XuiElementGetUserData(hObj, &pvUserData);
SlotControlUserDataContainer* pUserDataContainer =
(SlotControlUserDataContainer*)pvUserData;
int iCount = 0;
int iMaxStackSize = 0;
bool bStackable = false;
int iCount = 0;
int iMaxStackSize = 0;
bool bStackable = false;
if(pUserDataContainer->slot != NULL)
{
if ( pUserDataContainer->slot->hasItem() )
{
bStackable = pUserDataContainer->slot->getItem()->isStackable();
if ( bStackable )
{
iCount = pUserDataContainer->slot->getItem()->GetCount();
iMaxStackSize = std::min(pUserDataContainer->slot->getItem()->getMaxStackSize(), pUserDataContainer->slot->getMaxStackSize() );
if (pUserDataContainer->slot != NULL) {
if (pUserDataContainer->slot->hasItem()) {
bStackable = pUserDataContainer->slot->getItem()->isStackable();
if (bStackable) {
iCount = pUserDataContainer->slot->getItem()->GetCount();
iMaxStackSize = std::min(
pUserDataContainer->slot->getItem()->getMaxStackSize(),
pUserDataContainer->slot->getMaxStackSize());
iResult = iMaxStackSize - iCount;
iResult = iMaxStackSize - iCount;
if(iResult < 0 ) iResult = 0;
}
}
}
if (iResult < 0) iResult = 0;
}
}
}
return iResult;
return iResult;
}

View File

@@ -1,78 +1,89 @@
#pragma once
//using namespace std;
// using namespace std;
class Slot;
class ItemInstance;
#include "XUI_CustomMessages.h"
class SlotControlUserDataContainer
{
class SlotControlUserDataContainer {
public:
SlotControlUserDataContainer() : slot( NULL ), hProgressBar( NULL ), m_iPad( -1 ), m_fAlpha(1.0f) {};
Slot* slot;
HXUIOBJ hProgressBar;
float m_fAlpha;
int m_iPad;
SlotControlUserDataContainer()
: slot(NULL), hProgressBar(NULL), m_iPad(-1), m_fAlpha(1.0f) {};
Slot* slot;
HXUIOBJ hProgressBar;
float m_fAlpha;
int m_iPad;
};
// The base class for all controls with the "ItemButton" visual
// This could be a list item or just a button.
// We need this class to be able to easily access all the parts of the visual
class CXuiCtrlSlotItemCtrlBase
{
class CXuiCtrlSlotItemCtrlBase {
private:
// 4J WESTY : Pointer Prototype : Added to support prototype only.
bool m_bSkipDefaultNavigation;
// 4J WESTY : Pointer Prototype : Added to support prototype only.
bool m_bSkipDefaultNavigation;
public:
// We define a lot of functions as virtual. These should be implemented to call the protected version by
// passing in the HXUIOBJ of the control as the first parameter. We do not have access to that normally
// due to the inheritance structure
virtual HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) = 0;
virtual HRESULT OnDestroy() = 0;
// We define a lot of functions as virtual. These should be implemented to
// call the protected version by passing in the HXUIOBJ of the control as
// the first parameter. We do not have access to that normally due to the
// inheritance structure
virtual HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled) = 0;
virtual HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled) = 0;
virtual HRESULT OnDestroy() = 0;
// 4J WESTY : Pointer Prototype : Added to support prototype only.
virtual HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) = 0;
virtual HRESULT OnCustomMessage_GetSlotItem(
CustomMessage_GetSlotItem_Struct* pData, BOOL& bHandled) = 0;
virtual HRESULT OnKeyDown(XUIMessageInput *pInputData, BOOL& bHandled) = 0;
// 4J WESTY : Pointer Prototype : Added to support prototype only.
virtual HRESULT OnControlNavigate(
XUIMessageControlNavigate* pControlNavigateData, BOOL& bHandled) = 0;
void SetSlot( HXUIOBJ hObj, Slot* slot );
void SetAlpha( HXUIOBJ hObj, float fAlpha );
void SetUserIndex( HXUIOBJ hObj, int iPad );
virtual HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled) = 0;
bool isEmpty( HXUIOBJ hObj );
void SetSlot(HXUIOBJ hObj, Slot* slot);
void SetAlpha(HXUIOBJ hObj, float fAlpha);
void SetUserIndex(HXUIOBJ hObj, int iPad);
std::wstring GetItemDescription( HXUIOBJ hObj, std::vector<std::wstring> &unformattedStrings );
bool isEmpty(HXUIOBJ hObj);
std::shared_ptr<ItemInstance> getItemInstance( HXUIOBJ hObj );
Slot *getSlot( HXUIOBJ hObj );
std::wstring GetItemDescription(
HXUIOBJ hObj, std::vector<std::wstring>& unformattedStrings);
// 4J WESTY : Pointer Prototype : Added to support prototype only.
int GetObjectCount( HXUIOBJ hObj );
std::shared_ptr<ItemInstance> getItemInstance(HXUIOBJ hObj);
Slot* getSlot(HXUIOBJ hObj);
// 4J WESTY : Pointer Prototype : Added to support prototype only.
void SetSkipsDefaultNavigation( bool bSkipDefaultNavigation ) { m_bSkipDefaultNavigation = bSkipDefaultNavigation; }
// 4J WESTY : Pointer Prototype : Added to support prototype only.
int GetObjectCount(HXUIOBJ hObj);
// 4J WESTY : Pointer Prototype : Added to support prototype only.
int GetEmptyStackSpace( HXUIOBJ hObj ); // Returns number of items that can still be stacked into this slot.
// 4J WESTY : Pointer Prototype : Added to support prototype only.
void SetSkipsDefaultNavigation(bool bSkipDefaultNavigation) {
m_bSkipDefaultNavigation = bSkipDefaultNavigation;
}
// 4J WESTY : Pointer Prototype : Added to support prototype only.
bool IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj );
// 4J WESTY : Pointer Prototype : Added to support prototype only.
int GetEmptyStackSpace(HXUIOBJ hObj); // Returns number of items that can
// still be stacked into this slot.
protected:
HRESULT OnInit( HXUIOBJ hObj, XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnDestroy( HXUIOBJ hObj );
// 4J WESTY : Pointer Prototype : Added to support prototype only.
bool IsSameItemAs(HXUIOBJ hThisObj, HXUIOBJ hOtherObj);
HRESULT OnCustomMessage_GetSlotItem(HXUIOBJ hObj, CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled);
protected:
HRESULT OnInit(HXUIOBJ hObj, XUIMessageInit* pInitData, BOOL& bHandled);
// 4J WESTY : Pointer Prototype : Added to support prototype only.
HRESULT OnControlNavigate(HXUIOBJ hObj, XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled);
HRESULT OnDestroy(HXUIOBJ hObj);
HRESULT OnKeyDown(HXUIOBJ hObj, XUIMessageInput *pInputData, BOOL& bHandled);
HRESULT OnCustomMessage_GetSlotItem(HXUIOBJ hObj,
CustomMessage_GetSlotItem_Struct* pData,
BOOL& bHandled);
// 4J WESTY : Pointer Prototype : Added to support prototype only.
HRESULT OnControlNavigate(HXUIOBJ hObj,
XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled);
HRESULT OnKeyDown(HXUIOBJ hObj, XUIMessageInput* pInputData,
BOOL& bHandled);
};

View File

@@ -2,37 +2,48 @@
#include "XUI_Ctrl_SlotItemCtrlBase.h"
class CXuiCtrlSlotItemListItem : public CXuiListItemImpl, public CXuiCtrlSlotItemCtrlBase
{
class CXuiCtrlSlotItemListItem : public CXuiListItemImpl,
public CXuiCtrlSlotItemCtrlBase {
public:
// Define the class. The class name must match the ClassOverride property
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlSlotItemListItem, L"CXuiCtrlSlotItemListItem", XUI_CLASS_LISTITEM )
XUI_IMPLEMENT_CLASS(CXuiCtrlSlotItemListItem, L"CXuiCtrlSlotItemListItem",
XUI_CLASS_LISTITEM)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_GETSLOTITEM_MESSAGE(OnCustomMessage_GetSlotItem)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_GETSLOTITEM_MESSAGE(OnCustomMessage_GetSlotItem)
// 4J WESTY : Pointer Prototype : Added to support prototype only.
XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate )
// 4J WESTY : Pointer Prototype : Added to support prototype only.
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_ON_XM_KEYDOWN( OnKeyDown )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_END_MSG_MAP()
using CXuiCtrlSlotItemCtrlBase::OnInit;
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled) { return this->OnInit( m_hObj, pInitData, bHandled ); };
using CXuiCtrlSlotItemCtrlBase::OnDestroy;
HRESULT OnDestroy() { return this->OnDestroy( m_hObj ); };
using CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem;
HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled) { return this->OnCustomMessage_GetSlotItem( m_hObj, pData, bHandled ); };
using CXuiCtrlSlotItemCtrlBase::OnInit;
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
return this->OnInit(m_hObj, pInitData, bHandled);
};
// 4J WESTY : Pointer Prototype : Added to support prototype only.
using CXuiCtrlSlotItemCtrlBase::OnControlNavigate;
HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) { return this->OnControlNavigate( m_hObj, pControlNavigateData, bHandled ); }
using CXuiCtrlSlotItemCtrlBase::OnDestroy;
HRESULT OnDestroy() { return this->OnDestroy(m_hObj); };
using CXuiCtrlSlotItemCtrlBase::OnKeyDown;
HRESULT OnKeyDown(XUIMessageInput *pInputData, BOOL& bHandled) { return this->OnKeyDown( m_hObj, pInputData, bHandled ); };
using CXuiCtrlSlotItemCtrlBase::OnCustomMessage_GetSlotItem;
HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct* pData,
BOOL& bHandled) {
return this->OnCustomMessage_GetSlotItem(m_hObj, pData, bHandled);
};
// 4J WESTY : Pointer Prototype : Added to support prototype only.
using CXuiCtrlSlotItemCtrlBase::OnControlNavigate;
HRESULT OnControlNavigate(XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled) {
return this->OnControlNavigate(m_hObj, pControlNavigateData, bHandled);
}
using CXuiCtrlSlotItemCtrlBase::OnKeyDown;
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled) {
return this->OnKeyDown(m_hObj, pInputData, bHandled);
};
};

View File

@@ -5,226 +5,200 @@
#include "XUI_Ctrl_SlotItemListItem.h"
#include "XUI_Ctrl_SlotList.h"
//--------------------------------------------------------------------------------------
// Name: CXuiCtrlSlotList::OnInit
// Desc: Message handler for XM_INIT
//--------------------------------------------------------------------------------------
HRESULT CXuiCtrlSlotList::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
slotCount = 0;
HRESULT CXuiCtrlSlotList::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
slotCount = 0;
return S_OK;
return S_OK;
}
HRESULT CXuiCtrlSlotList::OnDestroy()
{
return S_OK;
HRESULT CXuiCtrlSlotList::OnDestroy() { return S_OK; }
HRESULT CXuiCtrlSlotList::OnKeyDown(XUIMessageInput* pInputData,
BOOL& bHandled) {
if (pInputData->dwKeyCode == VK_PAD_DPAD_LEFT ||
pInputData->dwKeyCode == VK_PAD_DPAD_RIGHT ||
pInputData->dwKeyCode == VK_PAD_DPAD_UP ||
pInputData->dwKeyCode == VK_PAD_DPAD_DOWN ||
pInputData->dwKeyCode == VK_PAD_LTRIGGER ||
pInputData->dwKeyCode == VK_PAD_RTRIGGER) {
HXUIOBJ parent;
HRESULT hr;
hr = XuiElementGetParent(m_hObj, &parent);
XUIMessage message;
XUIMessageInput messageInput;
XuiMessageInput(&message, &messageInput, XUI_KEYDOWN,
pInputData->dwKeyCode, pInputData->wch,
pInputData->dwFlags, pInputData->UserIndex);
if (HRESULT_SUCCEEDED(hr)) {
hr = XuiBubbleMessage(parent, &message);
if (message.bHandled) {
bHandled = TRUE;
}
}
}
return S_OK;
}
HRESULT CXuiCtrlSlotList::OnKeyDown(XUIMessageInput *pInputData, BOOL& bHandled)
{
if( pInputData->dwKeyCode == VK_PAD_DPAD_LEFT ||
pInputData->dwKeyCode == VK_PAD_DPAD_RIGHT ||
pInputData->dwKeyCode == VK_PAD_DPAD_UP ||
pInputData->dwKeyCode == VK_PAD_DPAD_DOWN ||
pInputData->dwKeyCode == VK_PAD_LTRIGGER ||
pInputData->dwKeyCode == VK_PAD_RTRIGGER)
{
HXUIOBJ parent;
HRESULT hr;
hr = XuiElementGetParent( m_hObj, &parent );
void CXuiCtrlSlotList::SetData(int m_iPad, AbstractContainerMenu* menu,
int rows, int columns, int startIndex /*= 0*/,
int endIndex /*= 0*/) {
assert(startIndex >= 0 && startIndex < menu->getSize());
assert(endIndex <= menu->getSize());
XUIMessage message;
XUIMessageInput messageInput;
XuiMessageInput( &message, &messageInput, XUI_KEYDOWN, pInputData->dwKeyCode, pInputData->wch, pInputData->dwFlags, pInputData->UserIndex );
if (startIndex < 0) {
startIndex = 0;
} else if (startIndex > menu->getSize()) {
startIndex = menu->getSize();
}
if (HRESULT_SUCCEEDED(hr))
{
hr = XuiBubbleMessage(parent, &message);
if (endIndex == 0) {
endIndex = startIndex + (rows * columns);
}
if (message.bHandled)
{
bHandled = TRUE;
}
}
}
if (endIndex > menu->getSize()) {
endIndex = menu->getSize();
}
return S_OK;
if (startIndex > endIndex) {
endIndex = startIndex;
}
assert((rows * columns) == (endIndex - startIndex));
this->rows = rows;
this->columns = columns;
this->startIndex = startIndex;
this->slotCount = rows * columns;
InsertItems(0, slotCount);
for (int i = 0; i < slotCount; i++) {
CXuiCtrlSlotItemListItem* slotControl;
GetCXuiCtrlSlotItem(i, &slotControl);
slotControl->SetSlot(slotControl->m_hObj,
menu->getSlot(i + startIndex));
slotControl->SetUserIndex(slotControl->m_hObj, m_iPad);
slotControl = NULL;
}
}
void CXuiCtrlSlotList::SetData(int m_iPad, AbstractContainerMenu* menu, int rows, int columns, int startIndex /*= 0*/, int endIndex /*= 0*/)
{
assert( startIndex >= 0 && startIndex < menu->getSize() );
assert( endIndex <= menu->getSize() );
HRESULT CXuiCtrlSlotList::OnGetItemCountAll(
XUIMessageGetItemCount* pGetItemCountData, BOOL& bHandled) {
// We don't need to look at the type of request. The message map
// has already filtered out a request to retrieve all items.
pGetItemCountData->cItems = slotCount;
bHandled = TRUE;
if( startIndex < 0 )
{
startIndex = 0;
}
else if( startIndex > menu->getSize() )
{
startIndex = menu->getSize();
}
if( endIndex == 0 )
{
endIndex = startIndex + (rows * columns);
}
if( endIndex > menu->getSize() )
{
endIndex = menu->getSize();
}
if( startIndex > endIndex )
{
endIndex = startIndex;
}
assert( (rows * columns) == (endIndex - startIndex) );
this->rows = rows;
this->columns = columns;
this->startIndex = startIndex;
this->slotCount = rows * columns;
InsertItems( 0, slotCount );
for(int i = 0; i < slotCount; i++)
{
CXuiCtrlSlotItemListItem* slotControl;
GetCXuiCtrlSlotItem(i, &slotControl);
slotControl->SetSlot( slotControl->m_hObj, menu->getSlot( i + startIndex ) );
slotControl->SetUserIndex( slotControl->m_hObj, m_iPad );
slotControl = NULL;
}
return (S_OK);
}
HRESULT CXuiCtrlSlotList::OnGetItemCountAll( XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled )
{
// We don't need to look at the type of request. The message map
// has already filtered out a request to retrieve all items.
pGetItemCountData->cItems = slotCount;
bHandled = TRUE;
HRESULT CXuiCtrlSlotList::OnGetItemCountMaxLines(
XUIMessageGetItemCount* pGetItemCountData, BOOL& bHandled) {
// We don't need to look at the type of request. The message map
// has already filtered out a request to retrieve max lines.
pGetItemCountData->cItems = rows;
bHandled = TRUE;
return( S_OK );
return (S_OK);
}
HRESULT CXuiCtrlSlotList::OnGetItemCountMaxLines( XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled )
{
// We don't need to look at the type of request. The message map
// has already filtered out a request to retrieve max lines.
pGetItemCountData->cItems = rows;
bHandled = TRUE;
HRESULT CXuiCtrlSlotList::OnGetItemCountMaxPerLine(
XUIMessageGetItemCount* pGetItemCountData, BOOL& bHandled) {
// We don't need to look at the type of request. The message map
// has already filtered out a request to retrieve max per line.
pGetItemCountData->cItems = columns;
bHandled = TRUE;
return( S_OK );
return (S_OK);
}
HRESULT CXuiCtrlSlotList::OnGetItemCountMaxPerLine( XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled )
{
// We don't need to look at the type of request. The message map
// has already filtered out a request to retrieve max per line.
pGetItemCountData->cItems = columns;
bHandled = TRUE;
int CXuiCtrlSlotList::GetCurrentColumn() {
int currentItemIndex = GetCurSel();
return( S_OK );
return currentItemIndex % columns;
}
int CXuiCtrlSlotList::GetCurrentColumn()
{
int currentItemIndex = GetCurSel();
int CXuiCtrlSlotList::GetCurrentRow() {
int currentItemIndex = GetCurSel();
return currentItemIndex % columns;
}
int CXuiCtrlSlotList::GetCurrentRow()
{
int currentItemIndex = GetCurSel();
return (currentItemIndex/columns) % rows;
return (currentItemIndex / columns) % rows;
}
// Return the index in the menu object
int CXuiCtrlSlotList::GetCurrentIndex()
{
int currentSelected = GetCurSel();
return currentSelected + this->startIndex;
int CXuiCtrlSlotList::GetCurrentIndex() {
int currentSelected = GetCurSel();
return currentSelected + this->startIndex;
}
void CXuiCtrlSlotList::SetCurrentSlot(int row, int column)
{
if( row >= rows )
{
row = rows - 1;
}
else if ( row < 0 )
{
row = 0;
}
if( column >= columns )
{
column = columns - 1;
}
else if ( column < 0 )
{
column = 0;
}
int newSlot = ( row * columns ) + column;
SetCurSel( newSlot );
void CXuiCtrlSlotList::SetCurrentSlot(int row, int column) {
if (row >= rows) {
row = rows - 1;
} else if (row < 0) {
row = 0;
}
if (column >= columns) {
column = columns - 1;
} else if (column < 0) {
column = 0;
}
int newSlot = (row * columns) + column;
SetCurSel(newSlot);
}
void CXuiCtrlSlotList::SetEntrySlot(int row, int column, XUI_CONTROL_NAVIGATE direction)
{
// The direction is the direction in which we are leaving the previous control to get to here
// So a Navigate up means we want to start at the bottom of ourself
switch( direction )
{
case XUI_CONTROL_NAVIGATE_UP:
{
row = rows - 1;
break;
}
case XUI_CONTROL_NAVIGATE_DOWN:
{
row = 0;
break;
}
case XUI_CONTROL_NAVIGATE_LEFT:
case XUI_CONTROL_NAVIGATE_TABBACKWARD:
{
column = columns - 1;
break;
}
case XUI_CONTROL_NAVIGATE_RIGHT:
case XUI_CONTROL_NAVIGATE_TABFORWARD:
{
column = 0;
break;
}
}
SetCurrentSlot( row, column );
void CXuiCtrlSlotList::SetEntrySlot(int row, int column,
XUI_CONTROL_NAVIGATE direction) {
// The direction is the direction in which we are leaving the previous
// control to get to here So a Navigate up means we want to start at the
// bottom of ourself
switch (direction) {
case XUI_CONTROL_NAVIGATE_UP: {
row = rows - 1;
break;
}
case XUI_CONTROL_NAVIGATE_DOWN: {
row = 0;
break;
}
case XUI_CONTROL_NAVIGATE_LEFT:
case XUI_CONTROL_NAVIGATE_TABBACKWARD: {
column = columns - 1;
break;
}
case XUI_CONTROL_NAVIGATE_RIGHT:
case XUI_CONTROL_NAVIGATE_TABFORWARD: {
column = 0;
break;
}
}
SetCurrentSlot(row, column);
}
void CXuiCtrlSlotList::Clicked()
{
CXuiCtrlSlotItemListItem* slot;
GetCXuiCtrlSlotItem( GetCurSel() , &slot);
void CXuiCtrlSlotList::Clicked() {
CXuiCtrlSlotItemListItem* slot;
GetCXuiCtrlSlotItem(GetCurSel(), &slot);
// To get the press animation
slot->Press();
// To get the press animation
slot->Press();
}
void CXuiCtrlSlotList::GetCXuiCtrlSlotItem(int itemIndex, CXuiCtrlSlotItemListItem** CXuiCtrlSlotItem)
{
HXUIOBJ itemControl = this->GetItemControl(itemIndex);
void *pObj;
XuiObjectFromHandle( itemControl, &pObj );
*CXuiCtrlSlotItem = (CXuiCtrlSlotItemListItem *)pObj;
void CXuiCtrlSlotList::GetCXuiCtrlSlotItem(
int itemIndex, CXuiCtrlSlotItemListItem** CXuiCtrlSlotItem) {
HXUIOBJ itemControl = this->GetItemControl(itemIndex);
void* pObj;
XuiObjectFromHandle(itemControl, &pObj);
*CXuiCtrlSlotItem = (CXuiCtrlSlotItemListItem*)pObj;
}

View File

@@ -1,73 +1,84 @@
#pragma once
// Sig: HRESULT OnGetItemCountMaxLines(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled)
#define XUI_ON_XM_GET_ITEMCOUNT_MAX_LINES(MemberFunc)\
if (pMessage->dwMessage == XM_GET_ITEMCOUNT && ((XUIMessageGetItemCount *) pMessage->pvData)->nType == XUI_ITEMCOUNT_MAX_LINES)\
{\
XUIMessageGetItemCount *pData = (XUIMessageGetItemCount *) pMessage->pvData;\
return MemberFunc(pData, pMessage->bHandled);\
}
// Sig: HRESULT OnGetItemCountMaxLines(XUIMessageGetItemCount
// *pGetItemCountData, BOOL& bHandled)
#define XUI_ON_XM_GET_ITEMCOUNT_MAX_LINES(MemberFunc) \
if (pMessage->dwMessage == XM_GET_ITEMCOUNT && \
((XUIMessageGetItemCount*)pMessage->pvData)->nType == \
XUI_ITEMCOUNT_MAX_LINES) { \
XUIMessageGetItemCount* pData = \
(XUIMessageGetItemCount*)pMessage->pvData; \
return MemberFunc(pData, pMessage->bHandled); \
}
// Sig: HRESULT OnGetItemCountMaxPerLine(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled)
#define XUI_ON_XM_GET_ITEMCOUNT_MAX_PER_LINE(MemberFunc)\
if (pMessage->dwMessage == XM_GET_ITEMCOUNT && ((XUIMessageGetItemCount *) pMessage->pvData)->nType == XUI_ITEMCOUNT_MAX_PER_LINE)\
{\
XUIMessageGetItemCount *pData = (XUIMessageGetItemCount *) pMessage->pvData;\
return MemberFunc(pData, pMessage->bHandled);\
}
// Sig: HRESULT OnGetItemCountMaxPerLine(XUIMessageGetItemCount
// *pGetItemCountData, BOOL& bHandled)
#define XUI_ON_XM_GET_ITEMCOUNT_MAX_PER_LINE(MemberFunc) \
if (pMessage->dwMessage == XM_GET_ITEMCOUNT && \
((XUIMessageGetItemCount*)pMessage->pvData)->nType == \
XUI_ITEMCOUNT_MAX_PER_LINE) { \
XUIMessageGetItemCount* pData = \
(XUIMessageGetItemCount*)pMessage->pvData; \
return MemberFunc(pData, pMessage->bHandled); \
}
class AbstractContainerMenu;
class SlotListItemControl;
class CXuiCtrlSlotItemListItem;
class CXuiCtrlSlotList : public CXuiListImpl
{
class CXuiCtrlSlotList : public CXuiListImpl {
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiCtrlSlotList, L"CXuiCtrlSlotList", XUI_CLASS_LIST )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiCtrlSlotList, L"CXuiCtrlSlotList", XUI_CLASS_LIST)
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_KEYDOWN( OnKeyDown )
XUI_ON_XM_GET_ITEMCOUNT_ALL( OnGetItemCountAll )
XUI_ON_XM_GET_ITEMCOUNT_MAX_LINES(OnGetItemCountMaxLines)
XUI_ON_XM_GET_ITEMCOUNT_MAX_PER_LINE(OnGetItemCountMaxPerLine)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_GET_ITEMCOUNT_MAX_LINES(OnGetItemCountMaxLines)
XUI_ON_XM_GET_ITEMCOUNT_MAX_PER_LINE(OnGetItemCountMaxPerLine)
XUI_END_MSG_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput *pInputData, BOOL& bHandled);
HRESULT OnGetItemCountAll( XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled );
HRESULT OnGetItemCountMaxLines(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
HRESULT OnGetItemCountMaxPerLine(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
HRESULT OnRender(XUIMessageRender *pRenderData, BOOL &rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
HRESULT OnGetItemCountMaxLines(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
HRESULT OnGetItemCountMaxPerLine(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
HRESULT OnRender(XUIMessageRender* pRenderData, BOOL& rfHandled);
public:
void SetData(int m_iPad, AbstractContainerMenu* menu, int rows, int columns, int startIndex = 0, int endIndex = 0);
int GetRows() { return rows; };
int GetColumns() { return columns; };
int GetCurrentColumn();
int GetCurrentRow();
void SetData(int m_iPad, AbstractContainerMenu* menu, int rows, int columns,
int startIndex = 0, int endIndex = 0);
int GetCurrentIndex();
int GetRows() { return rows; };
int GetColumns() { return columns; };
int GetCurrentColumn();
int GetCurrentRow();
void SetCurrentSlot(int row, int column);
void SetEntrySlot(int row, int column, XUI_CONTROL_NAVIGATE direction);
int GetCurrentIndex();
void Clicked();
void SetCurrentSlot(int row, int column);
void SetEntrySlot(int row, int column, XUI_CONTROL_NAVIGATE direction);
// 4J WESTY : Pointer Prototype : Made public.
void GetCXuiCtrlSlotItem(int itemIndex, CXuiCtrlSlotItemListItem** CXuiCtrlSlotItem);
void Clicked();
// 4J WESTY : Pointer Prototype : Made public.
void GetCXuiCtrlSlotItem(int itemIndex,
CXuiCtrlSlotItemListItem** CXuiCtrlSlotItem);
private:
int slotCount;
int rows;
int columns;
int startIndex;
int slotCount;
int rows;
int columns;
int startIndex;
// 4J WESTY : Pointer Prototype : Made public.
//void GetCXuiCtrlSlotItem(int itemIndex, CXuiCtrlSlotItemListItem** CXuiCtrlSlotItem);
// 4J WESTY : Pointer Prototype : Made public.
// void GetCXuiCtrlSlotItem(int itemIndex, CXuiCtrlSlotItemListItem**
// CXuiCtrlSlotItem);
};

View File

@@ -12,83 +12,80 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
CXuiCtrlSplashPulser::CXuiCtrlSplashPulser() :
m_bDirty(FALSE),
m_fScale(1.0f),
m_fAlpha(1.0f)
{
Minecraft *pMinecraft=Minecraft::GetInstance();
CXuiCtrlSplashPulser::CXuiCtrlSplashPulser()
: m_bDirty(FALSE), m_fScale(1.0f), m_fAlpha(1.0f) {
Minecraft* pMinecraft = Minecraft::GetInstance();
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, pMinecraft->height_phys);
m_fScreenWidth=(float)pMinecraft->width_phys;
m_fRawWidth=(float)ssc.rawWidth;
m_fScreenHeight=(float)pMinecraft->height_phys;
m_fRawHeight=(float)ssc.rawHeight;
ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys,
pMinecraft->height_phys);
m_fScreenWidth = (float)pMinecraft->width_phys;
m_fRawWidth = (float)ssc.rawWidth;
m_fScreenHeight = (float)pMinecraft->height_phys;
m_fRawHeight = (float)ssc.rawHeight;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlSplashPulser::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
HRESULT hr=S_OK;
return hr;
HRESULT CXuiCtrlSplashPulser::OnInit(XUIMessageInit* pInitData,
BOOL& rfHandled) {
HRESULT hr = S_OK;
return hr;
}
HRESULT CXuiCtrlSplashPulser::OnRender(XUIMessageRender *pRenderData, BOOL &bHandled )
{
HRESULT CXuiCtrlSplashPulser::OnRender(XUIMessageRender* pRenderData,
BOOL& bHandled) {
#ifdef _XBOX
HXUIDC hDC = pRenderData->hDC;
Minecraft *pMinecraft=Minecraft::GetInstance();
Font *font = pMinecraft->font;
HXUIDC hDC = pRenderData->hDC;
std::wstring splash( GetText() );
Minecraft* pMinecraft = Minecraft::GetInstance();
Font* font = pMinecraft->font;
// build and render with the game call
std::wstring splash(GetText());
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
// build and render with the game call
RenderManager.Set_matrixDirty();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1280.0f, 720.0f, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
glColor4f(1.0f,1.0f,1.0f,1.0f);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glPushMatrix();
RenderManager.Set_matrixDirty();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1280.0f, 720.0f, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
D3DXMATRIX matrix;
CXuiControl xuiControl(m_hObj);
xuiControl.GetFullXForm(&matrix);
float bwidth,bheight;
xuiControl.GetBounds(&bwidth,&bheight);
glPushMatrix();
float xo = (matrix._41 + (bwidth*matrix._11)/2 );
float yo = (matrix._42 + (bheight*matrix._22) );
D3DXMATRIX matrix;
CXuiControl xuiControl(m_hObj);
xuiControl.GetFullXForm(&matrix);
float bwidth, bheight;
xuiControl.GetBounds(&bwidth, &bheight);
float xo = (matrix._41 + (bwidth * matrix._11) / 2);
float yo = (matrix._42 + (bheight * matrix._22));
glTranslatef(xo, yo, 0);
glRotatef(-17, 0, 0, 1);
float sss = 1.8f - Mth::abs(Mth::sin(System::currentTimeMillis() % 1000 / 1000.0f * PI * 2) * 0.1f);
sss*=(m_fScreenWidth/m_fRawWidth);
float sss = 1.8f - Mth::abs(Mth::sin(System::currentTimeMillis() % 1000 /
1000.0f * PI * 2) *
0.1f);
sss *= (m_fScreenWidth / m_fRawWidth);
sss = sss * 100 / (font->width(splash) + 8 * 4);
glScalef(sss, sss, sss);
//drawCenteredString(font, splash, 0, -8, 0xffff00);
font->drawShadow(splash, 0 - (font->width(splash)) / 2, -8, 0xffff00);
// drawCenteredString(font, splash, 0, -8, 0xffff00);
font->drawShadow(splash, 0 - (font->width(splash)) / 2, -8, 0xffff00);
glPopMatrix();
glDisable(GL_RESCALE_NORMAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_RESCALE_NORMAL);
XuiRenderRestoreState(hDC);
glEnable(GL_DEPTH_TEST);
bHandled = TRUE;
XuiRenderRestoreState(hDC);
bHandled = TRUE;
#endif
return S_OK;
return S_OK;
}

View File

@@ -3,34 +3,32 @@
#include <string>
#include <XuiApp.h>
//using namespace std;
// using namespace std;
//-----------------------------------------------------------------------------
// CXuiCtrlSplashPulser class
//-----------------------------------------------------------------------------
class CXuiCtrlSplashPulser : public CXuiControlImpl
{
class CXuiCtrlSplashPulser : public CXuiControlImpl {
public:
XUI_IMPLEMENT_CLASS(CXuiCtrlSplashPulser, L"CXuiCtrlSplashPulser", XUI_CLASS_LABEL)
XUI_IMPLEMENT_CLASS(CXuiCtrlSplashPulser, L"CXuiCtrlSplashPulser",
XUI_CLASS_LABEL)
CXuiCtrlSplashPulser();
virtual ~CXuiCtrlSplashPulser() { };
CXuiCtrlSplashPulser();
virtual ~CXuiCtrlSplashPulser() {};
protected:
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_RENDER(OnRender)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender *pRenderData, BOOL &rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
HRESULT OnRender(XUIMessageRender* pRenderData, BOOL& rfHandled);
private:
bool m_bDirty;
float m_fScale,m_fAlpha;
float m_fScreenWidth,m_fScreenHeight;
float m_fRawWidth,m_fRawHeight;
bool m_bDirty;
float m_fScale, m_fAlpha;
float m_fScreenWidth, m_fScreenHeight;
float m_fRawWidth, m_fRawHeight;
};

View File

@@ -1,193 +1,180 @@
#pragma once
#define XM_SPLITSCREENPLAYER_MESSAGE XM_USER
#define XM_FONTRENDERERCHANGE_MESSAGE XM_USER + 1
#define XM_DLCMOUNTED_MESSAGE XM_USER + 2
#define XM_BASE_POSITION_CHANGED_MESSAGE XM_USER + 3
#define XM_DLCSINSTALLED_MESSAGE XM_USER + 4
#define XM_INVENTORYUPDATED_MESSAGE XM_USER + 5
#define XM_TMS_DLCFILE_RETRIEVED_MESSAGE XM_USER + 6
#define XM_TMS_BANFILE_RETRIEVED_MESSAGE XM_USER + 7
#define XM_TMS_ALLFILES_RETRIEVED_MESSAGE XM_USER + 8
#define XM_CUSTOMTICKSCENE_MESSAGE XM_USER + 9
#define XM_GETSLOTITEM_MESSAGE XM_USER + 10
#define XM_SPLITSCREENPLAYER_MESSAGE XM_USER
#define XM_FONTRENDERERCHANGE_MESSAGE XM_USER + 1
#define XM_DLCMOUNTED_MESSAGE XM_USER + 2
#define XM_BASE_POSITION_CHANGED_MESSAGE XM_USER + 3
#define XM_DLCSINSTALLED_MESSAGE XM_USER + 4
#define XM_INVENTORYUPDATED_MESSAGE XM_USER + 5
#define XM_TMS_DLCFILE_RETRIEVED_MESSAGE XM_USER + 6
#define XM_TMS_BANFILE_RETRIEVED_MESSAGE XM_USER + 7
#define XM_TMS_ALLFILES_RETRIEVED_MESSAGE XM_USER + 8
#define XM_CUSTOMTICKSCENE_MESSAGE XM_USER + 9
#define XM_GETSLOTITEM_MESSAGE XM_USER + 10
typedef struct
{
std::shared_ptr<ItemInstance> item;
// Legacy values for compatibility
int iDataBitField;
int iItemBitField;
LPCWSTR szPath;
bool bDirty;
}
CustomMessage_GetSlotItem_Struct;
typedef struct {
std::shared_ptr<ItemInstance> item;
// Legacy values for compatibility
int iDataBitField;
int iItemBitField;
LPCWSTR szPath;
bool bDirty;
} CustomMessage_GetSlotItem_Struct;
// Define the prototype for your handler function
// Sig: HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled)
// Sig: HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct
// *pData, BOOL& bHandled)
// Define the message map macro
#define XUI_ON_XM_GETSLOTITEM_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_GETSLOTITEM_MESSAGE)\
{\
CustomMessage_GetSlotItem_Struct *pData = (CustomMessage_GetSlotItem_Struct *) pMessage->pvData;\
return MemberFunc(pData, pMessage->bHandled);\
#define XUI_ON_XM_GETSLOTITEM_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_GETSLOTITEM_MESSAGE) { \
CustomMessage_GetSlotItem_Struct* pData = \
(CustomMessage_GetSlotItem_Struct*)pMessage->pvData; \
return MemberFunc(pData, pMessage->bHandled); \
}
static __declspec(noinline) void CustomMessage_GetSlotItem(
XUIMessage* pMsg, CustomMessage_GetSlotItem_Struct* pData,
int iDataBitField, int iItemBitField) {
XuiMessage(pMsg, XM_GETSLOTITEM_MESSAGE);
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
pData->item = nullptr;
pData->iDataBitField = iDataBitField;
pData->iItemBitField = iItemBitField;
pData->szPath = NULL;
pData->bDirty = false;
}
static __declspec(noinline) void CustomMessage_GetSlotItem(XUIMessage *pMsg, CustomMessage_GetSlotItem_Struct* pData, int iDataBitField, int iItemBitField)
{
XuiMessage(pMsg,XM_GETSLOTITEM_MESSAGE);
_XuiMessageExtra(pMsg,(XUIMessageData*) pData, sizeof(*pData));
pData->item = nullptr;
pData->iDataBitField = iDataBitField;
pData->iItemBitField = iItemBitField;
pData->szPath = NULL;
pData->bDirty = false;
}
typedef struct
{
bool bJoining; // if you're not joining, your leaving
}
CustomMessage_Splitscreenplayer_Struct;
typedef struct {
bool bJoining; // if you're not joining, your leaving
} CustomMessage_Splitscreenplayer_Struct;
// Define the prototype for your handler function
// Sig: HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
// Define the message map macro
#define XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_SPLITSCREENPLAYER_MESSAGE)\
{\
CustomMessage_Splitscreenplayer_Struct *pData = (CustomMessage_Splitscreenplayer_Struct *) pMessage->pvData;\
return MemberFunc(pData->bJoining, pMessage->bHandled);\
}
#define XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_SPLITSCREENPLAYER_MESSAGE) { \
CustomMessage_Splitscreenplayer_Struct* pData = \
(CustomMessage_Splitscreenplayer_Struct*)pMessage->pvData; \
return MemberFunc(pData->bJoining, pMessage->bHandled); \
}
static __declspec(noinline) void CustomMessage_Splitscreenplayer(XUIMessage *pMsg, CustomMessage_Splitscreenplayer_Struct* pData, bool bJoining)
{
XuiMessage(pMsg,XM_SPLITSCREENPLAYER_MESSAGE);
_XuiMessageExtra(pMsg,(XUIMessageData*) pData, sizeof(*pData));
pData->bJoining = bJoining;
static __declspec(noinline) void CustomMessage_Splitscreenplayer(
XUIMessage* pMsg, CustomMessage_Splitscreenplayer_Struct* pData,
bool bJoining) {
XuiMessage(pMsg, XM_SPLITSCREENPLAYER_MESSAGE);
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
pData->bJoining = bJoining;
}
// Define the prototype for your handler function
// Sig: HRESULT OnFontRendererChange()
// Define the message map macro
#define XUI_ON_XM_FONTRENDERERCHANGE_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_FONTRENDERERCHANGE_MESSAGE)\
{\
return MemberFunc();\
}
#define XUI_ON_XM_FONTRENDERERCHANGE_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_FONTRENDERERCHANGE_MESSAGE) { \
return MemberFunc(); \
}
static __declspec(noinline) void CustomMessage_FontRendererChange(XUIMessage *pMsg)
{
XuiMessage(pMsg,XM_FONTRENDERERCHANGE_MESSAGE);
static __declspec(noinline) void CustomMessage_FontRendererChange(
XUIMessage* pMsg) {
XuiMessage(pMsg, XM_FONTRENDERERCHANGE_MESSAGE);
}
// Define the prototype for your handler function
// Sig: HRESULT OnDLCMounted()
// Define the message map macro
#define XUI_ON_XM_DLCLOADED_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_DLCMOUNTED_MESSAGE)\
{\
return MemberFunc();\
}
#define XUI_ON_XM_DLCLOADED_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_DLCMOUNTED_MESSAGE) { \
return MemberFunc(); \
}
static __declspec(noinline) void CustomMessage_DLCMountingComplete(XUIMessage *pMsg)
{
XuiMessage(pMsg,XM_DLCMOUNTED_MESSAGE);
static __declspec(noinline) void CustomMessage_DLCMountingComplete(
XUIMessage* pMsg) {
XuiMessage(pMsg, XM_DLCMOUNTED_MESSAGE);
}
// Define the prototype for your handler function
// Sig: HRESULT OnBasePositionChanged()
// Define the message map macro
#define XUI_ON_XM_BASE_POSITION_CHANGED_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_BASE_POSITION_CHANGED_MESSAGE)\
{\
return MemberFunc();\
}
#define XUI_ON_XM_BASE_POSITION_CHANGED_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_BASE_POSITION_CHANGED_MESSAGE) { \
return MemberFunc(); \
}
static __declspec(noinline) void CustomMessage_BasePositionChanged(XUIMessage *pMsg)
{
XuiMessage(pMsg,XM_BASE_POSITION_CHANGED_MESSAGE);
static __declspec(noinline) void CustomMessage_BasePositionChanged(
XUIMessage* pMsg) {
XuiMessage(pMsg, XM_BASE_POSITION_CHANGED_MESSAGE);
}
// the prototype for your handler function
// Sig: HRESULT OnDLCInstalled()
// Define the message map macro
#define XUI_ON_XM_DLCINSTALLED_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_DLCSINSTALLED_MESSAGE)\
{\
return MemberFunc();\
}
#define XUI_ON_XM_DLCINSTALLED_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_DLCSINSTALLED_MESSAGE) { \
return MemberFunc(); \
}
static __declspec(noinline) void CustomMessage_DLCInstalled(XUIMessage *pMsg)
{
XuiMessage(pMsg,XM_DLCSINSTALLED_MESSAGE);
static __declspec(noinline) void CustomMessage_DLCInstalled(XUIMessage* pMsg) {
XuiMessage(pMsg, XM_DLCSINSTALLED_MESSAGE);
}
// the prototype for your handler function
// Sig: HRESULT OnCustomMessage_InventoryUpdated()
// Define the message map macro
#define XUI_ON_XM_INVENTORYUPDATED_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_INVENTORYUPDATED_MESSAGE)\
{\
return MemberFunc();\
}
#define XUI_ON_XM_INVENTORYUPDATED_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_INVENTORYUPDATED_MESSAGE) { \
return MemberFunc(); \
}
static __declspec(noinline) void CustomMessage_InventoryUpdated(XUIMessage *pMsg)
{
XuiMessage(pMsg,XM_INVENTORYUPDATED_MESSAGE);
static
__declspec(noinline) void CustomMessage_InventoryUpdated(XUIMessage* pMsg) {
XuiMessage(pMsg, XM_INVENTORYUPDATED_MESSAGE);
}
// the prototype for your handler function
// Sig: HRESULT OnCustomMessage_()
// Define the message map macro
#define XUI_ON_XM_TMS_DLCFILE_RETRIEVED_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_TMS_DLCFILE_RETRIEVED_MESSAGE)\
{\
return MemberFunc();\
}
#define XUI_ON_XM_TMS_DLCFILE_RETRIEVED_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_TMS_DLCFILE_RETRIEVED_MESSAGE) { \
return MemberFunc(); \
}
static __declspec(noinline) void CustomMessage_TMS_DLCFileRetrieved(XUIMessage *pMsg)
{
XuiMessage(pMsg,XM_TMS_DLCFILE_RETRIEVED_MESSAGE);
static __declspec(noinline) void CustomMessage_TMS_DLCFileRetrieved(
XUIMessage* pMsg) {
XuiMessage(pMsg, XM_TMS_DLCFILE_RETRIEVED_MESSAGE);
}
// the prototype for your handler function
// Sig: HRESULT OnCustomMessage_()
// Define the message map macro
#define XUI_ON_XM_TMS_BANFILE_RETRIEVED_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_TMS_BANFILE_RETRIEVED_MESSAGE)\
{\
return MemberFunc();\
}
#define XUI_ON_XM_TMS_BANFILE_RETRIEVED_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_TMS_BANFILE_RETRIEVED_MESSAGE) { \
return MemberFunc(); \
}
static __declspec(noinline) void CustomMessage_TMS_BanFileRetrieved(XUIMessage *pMsg)
{
XuiMessage(pMsg,XM_TMS_BANFILE_RETRIEVED_MESSAGE);
static __declspec(noinline) void CustomMessage_TMS_BanFileRetrieved(
XUIMessage* pMsg) {
XuiMessage(pMsg, XM_TMS_BANFILE_RETRIEVED_MESSAGE);
}
// Define the prototype for your handler function
// Sig: HRESULT OnCustomMessage_TickScene()
// Define the message map macro
#define XUI_ON_XM_CUSTOMTICKSCENE_MESSAGE(MemberFunc)\
if (pMessage->dwMessage == XM_CUSTOMTICKSCENE_MESSAGE)\
{\
return MemberFunc();\
}
#define XUI_ON_XM_CUSTOMTICKSCENE_MESSAGE(MemberFunc) \
if (pMessage->dwMessage == XM_CUSTOMTICKSCENE_MESSAGE) { \
return MemberFunc(); \
}
static __declspec(noinline) void CustomMessage_TickScene(XUIMessage *pMsg)
{
XuiMessage(pMsg,XM_CUSTOMTICKSCENE_MESSAGE);
static __declspec(noinline) void CustomMessage_TickScene(XUIMessage* pMsg) {
XuiMessage(pMsg, XM_CUSTOMTICKSCENE_MESSAGE);
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,134 +3,135 @@
#include "../media/xuiscene_DLCOffers.h"
#include "../media/xuiscene_DLCMain.h"
#include "XUI_CustomMessages.h"
#include "XUI_Ctrl_4JList.h"
#include "XUI_Ctrl_4JIcon.h"
//#include "XUI_Ctrl_DLCPrice.h"
// #include "XUI_Ctrl_DLCPrice.h"
class CXuiCtrl4JList;
class CScene_DLCOffers;
class CXuiCtrlDLCPrice;
class CScene_DLCMain : public CXuiSceneImpl
{
// Xui Elements
CXuiList xList;
CXuiCtrl4JList *list;
CXuiControl m_Timer;
class CScene_DLCMain : public CXuiSceneImpl {
// Xui Elements
CXuiList xList;
CXuiCtrl4JList* list;
CXuiControl m_Timer;
// Misc
int iPad, iOfferC;
// Misc
int iPad, iOfferC;
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_KEYDOWN( OnKeyDown )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_ON_XM_TIMER( OnTimer )
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_ON_XM_TIMER(OnTimer)
XUI_END_MSG_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiOffersList, xList)
MAP_CONTROL(IDC_Timer, m_Timer)
END_CONTROL_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiOffersList, xList)
MAP_CONTROL(IDC_Timer, m_Timer)
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled);
HRESULT OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled );
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnNavReturn(HXUIOBJ hObj, BOOL& rfHandled);
HRESULT OnTimer(XUIMessageTimer* pTimer, BOOL& bHandled);
public:
XUI_IMPLEMENT_CLASS( CScene_DLCMain, L"CScene_DLCMain", XUI_CLASS_SCENE )
XUI_IMPLEMENT_CLASS(CScene_DLCMain, L"CScene_DLCMain", XUI_CLASS_SCENE)
private:
bool m_bAllDLCContentRetrieved;
bool m_bIgnoreInput;
bool m_bAllDLCContentRetrieved;
bool m_bIgnoreInput;
};
class CScene_DLCOffers : public CXuiSceneImpl
{
class CScene_DLCOffers : public CXuiSceneImpl {
protected:
//static const std::wstring DEFAULT_BANNER;
// static const std::wstring DEFAULT_BANNER;
// Control and Element wrapper objects.
CXuiList m_List;
CXuiCtrl4JList *m_pOffersList;
CXuiImageElement m_Banner;
CXuiCtrl4JIcon m_TMSImage;
CXuiHtmlControl m_SellText;
CXuiControl m_PriceTag;
CXuiControl m_Timer;
HXUIBRUSH m_hXuiBrush;
// Control and Element wrapper objects.
CXuiList m_List;
CXuiCtrl4JList* m_pOffersList;
CXuiImageElement m_Banner;
CXuiCtrl4JIcon m_TMSImage;
CXuiHtmlControl m_SellText;
CXuiControl m_PriceTag;
CXuiControl m_Timer;
HXUIBRUSH m_hXuiBrush;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_ON_XM_TIMER( OnTimer )
XUI_ON_XM_DLCINSTALLED_MESSAGE(OnCustomMessage_DLCInstalled)
XUI_ON_XM_GET_SOURCE_IMAGE( OnGetSourceDataImage )
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_ON_XM_TIMER(OnTimer)
XUI_ON_XM_DLCINSTALLED_MESSAGE(OnCustomMessage_DLCInstalled)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiOffersList, m_List)
MAP_CONTROL(IDC_XuiHTMLSellText, m_SellText)
MAP_CONTROL(IDC_XuiDLCPriceTag, m_PriceTag)
MAP_CONTROL(IDC_XuiDLCBanner, m_TMSImage)
MAP_CONTROL(IDC_Timer, m_Timer)
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiOffersList, m_List)
MAP_CONTROL(IDC_XuiHTMLSellText, m_SellText)
MAP_CONTROL(IDC_XuiDLCPriceTag, m_PriceTag)
MAP_CONTROL(IDC_XuiDLCBanner, m_TMSImage)
MAP_CONTROL(IDC_Timer, m_Timer)
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnDestroy();
HRESULT OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled);
HRESULT OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled );
HRESULT OnCustomMessage_DLCInstalled();
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnDestroy();
HRESULT OnNavReturn(HXUIOBJ hObj, BOOL& rfHandled);
HRESULT OnTimer(XUIMessageTimer* pTimer, BOOL& bHandled);
HRESULT OnCustomMessage_DLCInstalled();
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetSourceImageData,
BOOL& bHandled);
HRESULT GetDLCInfo( int iOfferC, bool bUpdateOnly=false );
HRESULT GetDLCInfo(int iOfferC, bool bUpdateOnly = false);
//static int EthernetDisconnectReturned(void *pParam,int iPad,const C4JStorage::EMessageResult);
static int TMSReadCallback(void *pParam,int iPad,bool bResult);
// static int EthernetDisconnectReturned(void *pParam,int iPad,const
// C4JStorage::EMessageResult);
static int TMSReadCallback(void* pParam, int iPad, bool bResult);
// void UpdateTooltips(XMARKETPLACE_CONTENTOFFER_INFO& xOffer);
void UpdateTooltips(XMARKETPLACE_CURRENCY_CONTENTOFFER_INFO& xOffer);
//void UpdateTooltips(XMARKETPLACE_CONTENTOFFER_INFO& xOffer);
void UpdateTooltips(XMARKETPLACE_CURRENCY_CONTENTOFFER_INFO& xOffer);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_DLCOffers, L"CScene_DLCOffers", XUI_CLASS_SCENE)
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_DLCOffers, L"CScene_DLCOffers", XUI_CLASS_SCENE )
typedef struct _DLCOffer
{
int iOfferC;
}
DLCOffer;
typedef struct _DLCOffer {
int iOfferC;
} DLCOffer;
private:
//std::vector<int> offerIndexes;
CScene_DLCMain *pMain;
bool m_bIgnorePress;
int m_iPad;
int m_iOfferC;
int m_iType;
bool m_bIsSD;
bool m_bAllDLCContentRetrieved;
bool m_bDLCRequiredIsRetrieved;
bool m_bIsFemale; // to only show the correct gender type offers for avatars
DLC_INFO *m_pNoImageFor_DLC;
bool bNoDLCToDisplay; // to display a default "No DLC available at this time"
// std::vector<int> offerIndexes;
CScene_DLCMain* pMain;
bool m_bIgnorePress;
int m_iPad;
int m_iOfferC;
int m_iType;
bool m_bIsSD;
bool m_bAllDLCContentRetrieved;
bool m_bDLCRequiredIsRetrieved;
bool
m_bIsFemale; // to only show the correct gender type offers for avatars
DLC_INFO* m_pNoImageFor_DLC;
bool bNoDLCToDisplay; // to display a default "No DLC available at this
// time"
};

View File

@@ -24,219 +24,226 @@
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_Death::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *(int *)pInitData->pvInitData;
HRESULT CScene_Death::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
m_iPad = *(int*)pInitData->pvInitData;
m_bIgnoreInput = false;
m_bIgnoreInput = false;
MapChildControls();
if(app.GetLocalPlayerCount()>1)
{
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad);
}
XuiControlSetText(m_Title,app.GetString(IDS_YOU_DIED));
XuiControlSetText(m_Buttons[BUTTON_DEATH_RESPAWN],app.GetString(IDS_RESPAWN));
XuiControlSetText(m_Buttons[BUTTON_DEATH_EXITGAME],app.GetString(IDS_EXIT_GAME));
MapChildControls();
if (app.GetLocalPlayerCount() > 1) {
app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad);
}
// Display the tooltips
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT);
XuiControlSetText(m_Title, app.GetString(IDS_YOU_DIED));
XuiControlSetText(m_Buttons[BUTTON_DEATH_RESPAWN],
app.GetString(IDS_RESPAWN));
XuiControlSetText(m_Buttons[BUTTON_DEATH_EXITGAME],
app.GetString(IDS_EXIT_GAME));
return S_OK;
// Display the tooltips
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT);
return S_OK;
}
//----------------------------------------------------------------------------------
// Updates the UI when the list selection changes.
//----------------------------------------------------------------------------------
HRESULT CScene_Death::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled )
{
if( hObjSource == m_Scene )
{
/*int curSel = m_List.GetCurSel();
HRESULT CScene_Death::OnNotifySelChanged(
HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled) {
if (hObjSource == m_Scene) {
/*int curSel = m_List.GetCurSel();
// Set the locale with the current language.
XuiSetLocale( Languages[curSel].pszLanguagePath );
// Set the locale with the current language.
XuiSetLocale( Languages[curSel].pszLanguagePath );
// Apply the locale to the main scene.
XuiApplyLocale( m_hObj, NULL );
// Apply the locale to the main scene.
XuiApplyLocale( m_hObj, NULL );
// Update the text for the current value.
m_Value.SetText( m_List.GetText( curSel ) );*/
// Update the text for the current value.
m_Value.SetText( m_List.GetText( curSel ) );*/
bHandled = TRUE;
}
bHandled = TRUE;
}
return S_OK;
return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_Death::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
if(m_bIgnoreInput) return S_OK;
HRESULT CScene_Death::OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData,
BOOL& rfHandled) {
if (m_bIgnoreInput) return S_OK;
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
unsigned int uiButtonCounter=0;
unsigned int uiButtonCounter = 0;
while((uiButtonCounter<BUTTONS_DEATH_MAX) && (m_Buttons[uiButtonCounter]!=hObjPressed)) uiButtonCounter++;
while ((uiButtonCounter < BUTTONS_DEATH_MAX) &&
(m_Buttons[uiButtonCounter] != hObjPressed))
uiButtonCounter++;
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
// Determine which button was pressed,
// and call the appropriate function.
switch(uiButtonCounter)
{
case BUTTON_DEATH_EXITGAME:
{
// 4J-PB - fix for #8333 - BLOCKER: If player decides to exit game, then cancels the exit player becomes stuck at game over screen
//m_bIgnoreInput = true;
// Check if it's the trial version
if(ProfileManager.IsFullVersion())
{
unsigned int uiIDA[3];
// is it the primary player exiting?
if(pNotifyPressData->UserIndex==ProfileManager.GetPrimaryPad())
{
int playTime = -1;
if( pMinecraft->localplayers[pNotifyPressData->UserIndex] != NULL )
{
playTime = (int)pMinecraft->localplayers[pNotifyPressData->UserIndex]->getSessionTimer();
}
TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed);
if(StorageManager.GetSaveDisabled())
{
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, pNotifyPressData->UserIndex,&UIScene_PauseMenu::ExitGameDialogReturned,this, app.GetStringTable());
}
else
{
if( g_NetworkManager.IsHost() )
{
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_EXIT_GAME_SAVE;
uiIDA[2]=IDS_EXIT_GAME_NO_SAVE;
// Determine which button was pressed,
// and call the appropriate function.
switch (uiButtonCounter) {
case BUTTON_DEATH_EXITGAME: {
// 4J-PB - fix for #8333 - BLOCKER: If player decides to exit game,
// then cancels the exit player becomes stuck at game over screen
// m_bIgnoreInput = true;
// Check if it's the trial version
if (ProfileManager.IsFullVersion()) {
unsigned int uiIDA[3];
StorageManager.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, pNotifyPressData->UserIndex,&UIScene_PauseMenu::ExitGameSaveDialogReturned,this, app.GetStringTable());
}
else
{
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
// is it the primary player exiting?
if (pNotifyPressData->UserIndex ==
ProfileManager.GetPrimaryPad()) {
int playTime = -1;
if (pMinecraft->localplayers[pNotifyPressData->UserIndex] !=
NULL) {
playTime =
(int)pMinecraft
->localplayers[pNotifyPressData->UserIndex]
->getSessionTimer();
}
TelemetryManager->RecordLevelExit(
pNotifyPressData->UserIndex,
eSen_LevelExitStatus_Failed);
StorageManager.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, pNotifyPressData->UserIndex,&UIScene_PauseMenu::ExitGameDialogReturned,this, app.GetStringTable());
}
}
}
else
{
TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed);
// just exit the player
app.SetAction(pNotifyPressData->UserIndex,eAppAction_ExitPlayer);
}
}
else
{
// is it the primary player exiting?
if(pNotifyPressData->UserIndex==ProfileManager.GetPrimaryPad())
{
TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed);
// adjust the trial time played
CXuiSceneBase::ReduceTrialTimerValue();
if (StorageManager.GetSaveDisabled()) {
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST,
uiIDA, 2, pNotifyPressData->UserIndex,
&UIScene_PauseMenu::ExitGameDialogReturned, this,
app.GetStringTable());
} else {
if (g_NetworkManager.IsHost()) {
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_EXIT_GAME_SAVE;
uiIDA[2] = IDS_EXIT_GAME_NO_SAVE;
// exit the level
unsigned int uiIDA[2];
uiIDA[0]=IDS_CONFIRM_CANCEL;
uiIDA[1]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST, uiIDA, 2, pNotifyPressData->UserIndex,&UIScene_PauseMenu::ExitGameDialogReturned,this, app.GetStringTable());
}
else
{
TelemetryManager->RecordLevelExit(pNotifyPressData->UserIndex, eSen_LevelExitStatus_Failed);
StorageManager.RequestMessageBox(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3,
pNotifyPressData->UserIndex,
&UIScene_PauseMenu::ExitGameSaveDialogReturned,
this, app.GetStringTable());
} else {
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
// just exit the player
app.SetAction(pNotifyPressData->UserIndex,eAppAction_ExitPlayer);
}
}
}
break;
case BUTTON_DEATH_RESPAWN:
{
m_bIgnoreInput = true;
app.SetAction(pNotifyPressData->UserIndex,eAppAction_Respawn);
}
StorageManager.RequestMessageBox(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2,
pNotifyPressData->UserIndex,
&UIScene_PauseMenu::ExitGameDialogReturned,
this, app.GetStringTable());
}
}
} else {
TelemetryManager->RecordLevelExit(
pNotifyPressData->UserIndex,
eSen_LevelExitStatus_Failed);
break;
default:
break;
}
// just exit the player
app.SetAction(pNotifyPressData->UserIndex,
eAppAction_ExitPlayer);
}
} else {
// is it the primary player exiting?
if (pNotifyPressData->UserIndex ==
ProfileManager.GetPrimaryPad()) {
TelemetryManager->RecordLevelExit(
pNotifyPressData->UserIndex,
eSen_LevelExitStatus_Failed);
// adjust the trial time played
CXuiSceneBase::ReduceTrialTimerValue();
// exit the level
unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST,
uiIDA, 2, pNotifyPressData->UserIndex,
&UIScene_PauseMenu::ExitGameDialogReturned, this,
app.GetStringTable());
} else {
TelemetryManager->RecordLevelExit(
pNotifyPressData->UserIndex,
eSen_LevelExitStatus_Failed);
return S_OK;
// just exit the player
app.SetAction(pNotifyPressData->UserIndex,
eAppAction_ExitPlayer);
}
}
} break;
case BUTTON_DEATH_RESPAWN: {
m_bIgnoreInput = true;
app.SetAction(pNotifyPressData->UserIndex, eAppAction_Respawn);
}
break;
default:
break;
}
return S_OK;
}
HRESULT CScene_Death::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_Death::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_PAD_START:
case VK_ESCAPE:
switch(pInputData->dwKeyCode)
{
// kill the crafting xui
// 4J Stu - No back out, must choose
// app.CloseXuiScenes();
case VK_PAD_B:
case VK_PAD_START:
case VK_ESCAPE:
rfHandled = TRUE;
// kill the crafting xui
// 4J Stu - No back out, must choose
//app.CloseXuiScenes();
break;
}
rfHandled = TRUE;
break;
}
return S_OK;
return S_OK;
}
int CScene_Death::RespawnThreadProc( void* lpParameter )
{
AABB::UseDefaultThreadStorage();
Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
size_t iPad=(size_t)lpParameter;
int CScene_Death::RespawnThreadProc(void* lpParameter) {
AABB::UseDefaultThreadStorage();
Vec3::UseDefaultThreadStorage();
Compression::UseDefaultThreadStorage();
size_t iPad = (size_t)lpParameter;
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->localplayers[iPad]->respawn();
pMinecraft->localplayers[iPad]->respawn();
app.SetGameStarted(true);
pMinecraft->gameRenderer->EnableUpdateThread();
// If we are online, then we should wait here until the respawn is done
// If we are offline, this should release straight away
//WaitForSingleObject( pMinecraft->m_hPlayerRespawned, INFINITE );
while(pMinecraft->localplayers[iPad]->GetPlayerRespawned()==false)
{
Sleep(50);
}
app.SetGameStarted(true);
pMinecraft->gameRenderer->EnableUpdateThread();
return S_OK;
// If we are online, then we should wait here until the respawn is done
// If we are offline, this should release straight away
// WaitForSingleObject( pMinecraft->m_hPlayerRespawned, INFINITE );
while (pMinecraft->localplayers[iPad]->GetPlayerRespawned() == false) {
Sleep(50);
}
return S_OK;
}
HRESULT CScene_Death::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining);
HRESULT CScene_Death::OnCustomMessage_Splitscreenplayer(bool bJoining,
BOOL& bHandled) {
bHandled = true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj, &m_OriginalPosition,
m_iPad, bJoining);
}

View File

@@ -3,50 +3,50 @@
#include "../media/xuiscene_Death.h"
#include "XUI_CustomMessages.h"
#define BUTTON_DEATH_RESPAWN 0
#define BUTTON_DEATH_EXITGAME 1
#define BUTTONS_DEATH_MAX BUTTON_DEATH_EXITGAME + 1
#define BUTTON_DEATH_RESPAWN 0
#define BUTTON_DEATH_EXITGAME 1
#define BUTTONS_DEATH_MAX BUTTON_DEATH_EXITGAME + 1
class CScene_Death : public CXuiSceneImpl {
protected:
// Control and Element wrapper objects.
CXuiScene m_Scene;
CXuiControl m_Buttons[BUTTONS_DEATH_MAX];
CXuiControl m_Title;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Respawn, m_Buttons[BUTTON_DEATH_RESPAWN])
MAP_CONTROL(IDC_ExitGame, m_Buttons[BUTTON_DEATH_EXITGAME])
MAP_CONTROL(IDC_Title, m_Title)
END_CONTROL_MAP()
class CScene_Death : public CXuiSceneImpl
{
protected:
// Control and Element wrapper objects.
CXuiScene m_Scene;
CXuiControl m_Buttons[BUTTONS_DEATH_MAX];
CXuiControl m_Title;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Respawn, m_Buttons[BUTTON_DEATH_RESPAWN])
MAP_CONTROL(IDC_ExitGame, m_Buttons[BUTTON_DEATH_EXITGAME])
MAP_CONTROL(IDC_Title, m_Title)
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_Death, L"CScene_Death", XUI_CLASS_SCENE)
static int RespawnThreadProc(void* lpParameter);
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_Death, L"CScene_Death", XUI_CLASS_SCENE )
static int RespawnThreadProc( void* lpParameter );
private:
bool m_bIgnoreInput;
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
bool m_bIgnoreInput;
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
};

View File

@@ -2,52 +2,50 @@
#include "../media/xuiscene_debug.h"
class CScene_Debug : public CXuiSceneImpl
{
protected:
class CScene_Debug : public CXuiSceneImpl {
protected:
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnNotifyValueChanged(HXUIOBJ hObjSource,
XUINotifyValueChanged* pNotifyValueChanged,
BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnControlNavigate(XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled);
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_ON_XM_NOTIFY_VALUE_CHANGED( OnNotifyValueChanged )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_END_MSG_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
HRESULT OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged* pNotifyValueChanged, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_Debug, L"CScene_Debug", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_Debug, L"CScene_Debug", XUI_CLASS_SCENE)
private:
typedef struct {
HXUIOBJ hXuiObj;
void* pvData;
} DEBUGDATA;
typedef struct
{
HXUIOBJ hXuiObj;
void *pvData;
}
DEBUGDATA;
static LPCWSTR m_DebugCheckboxTextA[eDebugSetting_Max+1];
static LPCWSTR m_DebugButtonTextA[eDebugButton_Max+1];
int m_iTotalCheckboxElements;
int m_iTotalButtonElements;
DEBUGDATA *m_DebugCheckboxDataA;
DEBUGDATA *m_DebugButtonDataA;
int m_iCurrentCheckboxElement;
int m_iCurrentButtonElement;
int m_iPad;
bool m_bOnCheckboxes; // for navigations
static LPCWSTR m_DebugCheckboxTextA[eDebugSetting_Max + 1];
static LPCWSTR m_DebugButtonTextA[eDebugButton_Max + 1];
int m_iTotalCheckboxElements;
int m_iTotalButtonElements;
DEBUGDATA* m_DebugCheckboxDataA;
DEBUGDATA* m_DebugButtonDataA;
int m_iCurrentCheckboxElement;
int m_iCurrentButtonElement;
int m_iPad;
bool m_bOnCheckboxes; // for navigations
};

View File

@@ -9,110 +9,113 @@
#include "../GameRules/ConsoleGameRules.h"
#include "XUI_DebugItemEditor.h"
#ifdef _DEBUG_MENUS_ENABLED
HRESULT CScene_DebugItemEditor::OnInit( XUIMessageInit *pInitData, BOOL &bHandled )
{
MapChildControls();
#ifdef _DEBUG_MENUS_ENABLED
HRESULT CScene_DebugItemEditor::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
MapChildControls();
ItemEditorInput *initData = (ItemEditorInput *)pInitData->pvInitData;
m_iPad = initData->iPad;
m_slot = initData->slot;
m_menu = initData->menu;
if(m_slot != NULL) m_item = m_slot->getItem();
ItemEditorInput* initData = (ItemEditorInput*)pInitData->pvInitData;
m_iPad = initData->iPad;
m_slot = initData->slot;
m_menu = initData->menu;
if (m_slot != NULL) m_item = m_slot->getItem();
if(m_item!=NULL)
{
m_icon->SetIcon(m_iPad, m_item->id,m_item->getAuxValue(),m_item->count,10,31,false,m_item->isFoil());
m_itemName.SetText( app.GetString( Item::items[m_item->id]->getDescriptionId(m_item) ) );
if (m_item != NULL) {
m_icon->SetIcon(m_iPad, m_item->id, m_item->getAuxValue(),
m_item->count, 10, 31, false, m_item->isFoil());
m_itemName.SetText(
app.GetString(Item::items[m_item->id]->getDescriptionId(m_item)));
m_itemId .SetText( _toString<int>(m_item->id).c_str() );
m_itemAuxValue .SetText( _toString<int>(m_item->getAuxValue()).c_str() );
m_itemCount .SetText( _toString<int>(m_item->count).c_str() );
m_item4JData .SetText( _toString<int>(m_item->get4JData()).c_str() );
}
m_itemId.SetText(_toString<int>(m_item->id).c_str());
m_itemAuxValue.SetText(_toString<int>(m_item->getAuxValue()).c_str());
m_itemCount.SetText(_toString<int>(m_item->count).c_str());
m_item4JData.SetText(_toString<int>(m_item->get4JData()).c_str());
}
m_itemId .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_itemAuxValue .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_itemCount .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_item4JData .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_itemId.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_itemAuxValue.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_itemCount.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_item4JData.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_generatedXml.SetText( CollectItemRuleDefinition::generateXml(m_item).c_str() );
m_generatedXml.SetText(
CollectItemRuleDefinition::generateXml(m_item).c_str());
delete initData;
delete initData;
return S_OK;
return S_OK;
}
HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch(pInputData->dwKeyCode)
{
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_PAD_START:
case VK_PAD_BACK:
// We need to send a packet to the server to update it's
// representation of this item
if (m_slot != NULL && m_menu != NULL) {
m_slot->set(m_item);
case VK_PAD_B:
case VK_PAD_START:
case VK_PAD_BACK:
// We need to send a packet to the server to update it's representation of this item
if(m_slot != NULL && m_menu != NULL)
{
m_slot->set(m_item);
Minecraft* pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> player =
pMinecraft->localplayers[m_iPad];
if (player != NULL && player->connection)
player->connection->send(
std::shared_ptr<ContainerSetSlotPacket>(
new ContainerSetSlotPacket(m_menu->containerId,
m_slot->index, m_item)));
}
// kill the crafting xui
app.NavigateBack(m_iPad);
Minecraft *pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> player = pMinecraft->localplayers[m_iPad];
if(player != NULL && player->connection) player->connection->send( std::shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(m_menu->containerId, m_slot->index, m_item) ) );
}
// kill the crafting xui
app.NavigateBack(m_iPad);
rfHandled = TRUE;
rfHandled = TRUE;
break;
}
break;
}
return S_OK;
return S_OK;
}
HRESULT CScene_DebugItemEditor::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled)
{
if(m_item == NULL) m_item = std::shared_ptr<ItemInstance>( new ItemInstance(0,1,0) );
if(hObjSource == m_itemId)
{
int id = 0;
std::wstring value = m_itemId.GetText();
if(!value.empty()) id = _fromString<int>( value );
HRESULT CScene_DebugItemEditor::OnNotifyValueChanged(
HXUIOBJ hObjSource, XUINotifyValueChanged* pNotifyValueChangedData,
BOOL& bHandled) {
if (m_item == NULL)
m_item = std::shared_ptr<ItemInstance>(new ItemInstance(0, 1, 0));
if (hObjSource == m_itemId) {
int id = 0;
std::wstring value = m_itemId.GetText();
if (!value.empty()) id = _fromString<int>(value);
// TODO Proper validation of the valid item ids
if(id > 0 && Item::items[id] != NULL) m_item->id = id;
}
else if(hObjSource == m_itemAuxValue)
{
int auxVal = 0;
std::wstring value = m_itemAuxValue.GetText();
if(!value.empty()) auxVal = _fromString<int>( value );
if(auxVal >= 0) m_item->setAuxValue( auxVal );
}
else if(hObjSource == m_itemCount)
{
int count = 0;
std::wstring value = m_itemCount.GetText();
if(!value.empty()) count = _fromString<int>( value );
if(count > 0 && count <= Item::items[m_item->id]->getMaxStackSize()) m_item->count = count;
}
else if(hObjSource == m_item4JData)
{
int data = 0;
std::wstring value = m_item4JData.GetText();
if(!value.empty()) data = _fromString<int>( value );
m_item->set4JData(data);
}
m_icon->SetIcon(m_iPad, m_item->id,m_item->getAuxValue(),m_item->count,10,31,false,m_item->isFoil());
// TODO Proper validation of the valid item ids
if (id > 0 && Item::items[id] != NULL) m_item->id = id;
} else if (hObjSource == m_itemAuxValue) {
int auxVal = 0;
std::wstring value = m_itemAuxValue.GetText();
if (!value.empty()) auxVal = _fromString<int>(value);
if (auxVal >= 0) m_item->setAuxValue(auxVal);
} else if (hObjSource == m_itemCount) {
int count = 0;
std::wstring value = m_itemCount.GetText();
if (!value.empty()) count = _fromString<int>(value);
if (count > 0 && count <= Item::items[m_item->id]->getMaxStackSize())
m_item->count = count;
} else if (hObjSource == m_item4JData) {
int data = 0;
std::wstring value = m_item4JData.GetText();
if (!value.empty()) data = _fromString<int>(value);
m_item->set4JData(data);
}
m_itemName.SetText( app.GetString( Item::items[m_item->id]->getDescriptionId(m_item) ) );
m_icon->SetIcon(m_iPad, m_item->id, m_item->getAuxValue(), m_item->count,
10, 31, false, m_item->isFoil());
m_generatedXml.SetText( CollectItemRuleDefinition::generateXml(m_item).c_str() );
return S_OK;
m_itemName.SetText(
app.GetString(Item::items[m_item->id]->getDescriptionId(m_item)));
m_generatedXml.SetText(
CollectItemRuleDefinition::generateXml(m_item).c_str());
return S_OK;
}
#endif

View File

@@ -1,57 +1,59 @@
#pragma once
//using namespace std;
// using namespace std;
#include "../media/xuiscene_debug_item_editor.h"
#include "XUI_Ctrl_CraftIngredientSlot.h"
#include "XUI_Ctrl_4JEdit.h"
#include "../../Minecraft.World/Items/ItemInstance.h"
class CScene_DebugItemEditor : public CXuiSceneImpl
{
#ifdef _DEBUG_MENUS_ENABLED
class CScene_DebugItemEditor : public CXuiSceneImpl {
#ifdef _DEBUG_MENUS_ENABLED
public:
typedef struct _ItemEditorInput
{
int iPad;
Slot *slot;
AbstractContainerMenu *menu;
} ItemEditorInput;
private:
int m_iPad;
std::shared_ptr<ItemInstance> m_item;
Slot *m_slot;
AbstractContainerMenu *m_menu;
typedef struct _ItemEditorInput {
int iPad;
Slot* slot;
AbstractContainerMenu* menu;
} ItemEditorInput;
CXuiCtrlCraftIngredientSlot *m_icon;
CXuiControl m_generatedXml, m_itemName;
CXuiCtrl4JEdit m_itemId, m_itemAuxValue, m_itemCount, m_item4JData;
private:
int m_iPad;
std::shared_ptr<ItemInstance> m_item;
Slot* m_slot;
AbstractContainerMenu* m_menu;
CXuiCtrlCraftIngredientSlot* m_icon;
CXuiControl m_generatedXml, m_itemName;
CXuiCtrl4JEdit m_itemId, m_itemAuxValue, m_itemCount, m_item4JData;
protected:
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED( OnNotifyValueChanged )
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_itemId, m_itemId)
MAP_CONTROL(IDC_itemAuxValue, m_itemAuxValue)
MAP_CONTROL(IDC_itemCount, m_itemCount)
MAP_CONTROL(IDC_item4JData, m_item4JData)
MAP_OVERRIDE(IDC_icon, m_icon)
MAP_CONTROL(IDC_ruleXml, m_generatedXml)
MAP_CONTROL(IDC_itemName, m_itemName)
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_itemId, m_itemId)
MAP_CONTROL(IDC_itemAuxValue, m_itemAuxValue)
MAP_CONTROL(IDC_itemCount, m_itemCount)
MAP_CONTROL(IDC_item4JData, m_item4JData)
MAP_OVERRIDE(IDC_icon, m_icon)
MAP_CONTROL(IDC_ruleXml, m_generatedXml)
MAP_CONTROL(IDC_itemName, m_itemName)
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged(HXUIOBJ hObjSource,
XUINotifyValueChanged* pNotifyValueChangedData,
BOOL& bHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_DebugItemEditor, L"CScene_DebugItemEditor", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_DebugItemEditor, L"CScene_DebugItemEditor",
XUI_CLASS_SCENE)
#endif
};

View File

@@ -28,364 +28,372 @@
#include "../../Minecraft.World/Headers/net.minecraft.commands.common.h"
#include "../../Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h"
#ifdef _DEBUG_MENUS_ENABLED
HRESULT CScene_DebugOverlay::OnInit( XUIMessageInit *pInitData, BOOL &bHandled )
{
MapChildControls();
#ifdef _DEBUG_MENUS_ENABLED
HRESULT CScene_DebugOverlay::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
MapChildControls();
m_items.InsertItems( 0, 512 );
m_items.InsertItems(0, 512);
for(unsigned int i = 0; i < Item::items.length; ++i)
{
if(Item::items[i] != NULL)
{
//m_items.InsertItems(m_items.GetItemCount(),1);
m_itemIds.push_back(i);
m_items.SetText( m_itemIds.size() - 1, app.GetString( Item::items[i]->getDescriptionId() ) );
}
}
for (unsigned int i = 0; i < Item::items.length; ++i) {
if (Item::items[i] != NULL) {
// m_items.InsertItems(m_items.GetItemCount(),1);
m_itemIds.push_back(i);
m_items.SetText(m_itemIds.size() - 1,
app.GetString(Item::items[i]->getDescriptionId()));
}
}
m_enchantments.InsertItems( 0, Enchantment::validEnchantments.size() );
for(unsigned int i = 0; i < Enchantment::validEnchantments.size(); ++i )
{
Enchantment *ench = Enchantment::validEnchantments.at(i);
m_enchantments.InsertItems(0, Enchantment::validEnchantments.size());
for (unsigned int i = 0; i < Enchantment::validEnchantments.size(); ++i) {
Enchantment* ench = Enchantment::validEnchantments.at(i);
m_enchantmentIds.push_back(ench->id);
m_enchantments.SetText( i, app.GetString( ench->getDescriptionId() ) );
}
m_mobs.InsertItems( 0, 21 );
m_enchantmentIds.push_back(ench->id);
m_enchantments.SetText(i, app.GetString(ench->getDescriptionId()));
}
m_mobs.SetText( m_mobFactories.size(), L"Chicken" );
m_mobFactories.push_back(eTYPE_CHICKEN);
m_mobs.SetText( m_mobFactories.size(), L"Cow" );
m_mobFactories.push_back(eTYPE_COW);
m_mobs.SetText( m_mobFactories.size(), L"Pig" );
m_mobFactories.push_back(eTYPE_PIG);
m_mobs.SetText( m_mobFactories.size(), L"Sheep" );
m_mobFactories.push_back(eTYPE_SHEEP);
m_mobs.SetText( m_mobFactories.size(), L"Squid" );
m_mobFactories.push_back(eTYPE_SQUID);
m_mobs.SetText( m_mobFactories.size(), L"Wolf" );
m_mobFactories.push_back(eTYPE_WOLF);
m_mobs.SetText( m_mobFactories.size(), L"Creeper" );
m_mobFactories.push_back(eTYPE_CREEPER);
m_mobs.SetText( m_mobFactories.size(), L"Ghast" );
m_mobFactories.push_back(eTYPE_GHAST);
m_mobs.SetText( m_mobFactories.size(), L"Pig Zombie" );
m_mobFactories.push_back(eTYPE_PIGZOMBIE);
m_mobs.SetText( m_mobFactories.size(), L"Skeleton" );
m_mobFactories.push_back(eTYPE_SKELETON);
m_mobs.SetText( m_mobFactories.size(), L"Slime" );
m_mobFactories.push_back(eTYPE_SLIME);
m_mobs.SetText( m_mobFactories.size(), L"Spider" );
m_mobFactories.push_back(eTYPE_SPIDER);
m_mobs.SetText( m_mobFactories.size(), L"Zombie" );
m_mobFactories.push_back(eTYPE_ZOMBIE);
m_mobs.SetText( m_mobFactories.size(), L"Enderman" );
m_mobFactories.push_back(eTYPE_ENDERMAN);
m_mobs.SetText( m_mobFactories.size(), L"Silverfish" );
m_mobFactories.push_back(eTYPE_SILVERFISH);
m_mobs.SetText( m_mobFactories.size(), L"Cave Spider" );
m_mobFactories.push_back(eTYPE_CAVESPIDER);
m_mobs.SetText( m_mobFactories.size(), L"Mooshroom" );
m_mobFactories.push_back(eTYPE_MUSHROOMCOW);
m_mobs.SetText( m_mobFactories.size(), L"Snow Golem" );
m_mobFactories.push_back(eTYPE_SNOWMAN);
m_mobs.SetText( m_mobFactories.size(), L"Ender Dragon" );
m_mobFactories.push_back(eTYPE_ENDERDRAGON);
m_mobs.SetText( m_mobFactories.size(), L"Blaze" );
m_mobFactories.push_back(eTYPE_BLAZE);
m_mobs.SetText( m_mobFactories.size(), L"Magma Cube" );
m_mobFactories.push_back(eTYPE_LAVASLIME);
m_mobs.InsertItems(0, 21);
Minecraft *pMinecraft = Minecraft::GetInstance();
m_setTime.SetValue( pMinecraft->level->getLevelData()->getTime() % 24000 );
m_setFov.SetValue( (int)pMinecraft->gameRenderer->GetFovVal());
m_mobs.SetText(m_mobFactories.size(), L"Chicken");
m_mobFactories.push_back(eTYPE_CHICKEN);
m_mobs.SetText(m_mobFactories.size(), L"Cow");
m_mobFactories.push_back(eTYPE_COW);
m_mobs.SetText(m_mobFactories.size(), L"Pig");
m_mobFactories.push_back(eTYPE_PIG);
m_mobs.SetText(m_mobFactories.size(), L"Sheep");
m_mobFactories.push_back(eTYPE_SHEEP);
m_mobs.SetText(m_mobFactories.size(), L"Squid");
m_mobFactories.push_back(eTYPE_SQUID);
m_mobs.SetText(m_mobFactories.size(), L"Wolf");
m_mobFactories.push_back(eTYPE_WOLF);
m_mobs.SetText(m_mobFactories.size(), L"Creeper");
m_mobFactories.push_back(eTYPE_CREEPER);
m_mobs.SetText(m_mobFactories.size(), L"Ghast");
m_mobFactories.push_back(eTYPE_GHAST);
m_mobs.SetText(m_mobFactories.size(), L"Pig Zombie");
m_mobFactories.push_back(eTYPE_PIGZOMBIE);
m_mobs.SetText(m_mobFactories.size(), L"Skeleton");
m_mobFactories.push_back(eTYPE_SKELETON);
m_mobs.SetText(m_mobFactories.size(), L"Slime");
m_mobFactories.push_back(eTYPE_SLIME);
m_mobs.SetText(m_mobFactories.size(), L"Spider");
m_mobFactories.push_back(eTYPE_SPIDER);
m_mobs.SetText(m_mobFactories.size(), L"Zombie");
m_mobFactories.push_back(eTYPE_ZOMBIE);
m_mobs.SetText(m_mobFactories.size(), L"Enderman");
m_mobFactories.push_back(eTYPE_ENDERMAN);
m_mobs.SetText(m_mobFactories.size(), L"Silverfish");
m_mobFactories.push_back(eTYPE_SILVERFISH);
m_mobs.SetText(m_mobFactories.size(), L"Cave Spider");
m_mobFactories.push_back(eTYPE_CAVESPIDER);
m_mobs.SetText(m_mobFactories.size(), L"Mooshroom");
m_mobFactories.push_back(eTYPE_MUSHROOMCOW);
m_mobs.SetText(m_mobFactories.size(), L"Snow Golem");
m_mobFactories.push_back(eTYPE_SNOWMAN);
m_mobs.SetText(m_mobFactories.size(), L"Ender Dragon");
m_mobFactories.push_back(eTYPE_ENDERDRAGON);
m_mobs.SetText(m_mobFactories.size(), L"Blaze");
m_mobFactories.push_back(eTYPE_BLAZE);
m_mobs.SetText(m_mobFactories.size(), L"Magma Cube");
m_mobFactories.push_back(eTYPE_LAVASLIME);
XuiSetTimer(m_hObj,0,DEBUG_OVERLAY_UPDATE_TIME_PERIOD);
Minecraft* pMinecraft = Minecraft::GetInstance();
m_setTime.SetValue(pMinecraft->level->getLevelData()->getTime() % 24000);
m_setFov.SetValue((int)pMinecraft->gameRenderer->GetFovVal());
bHandled = TRUE;
return S_OK;
XuiSetTimer(m_hObj, 0, DEBUG_OVERLAY_UPDATE_TIME_PERIOD);
bHandled = TRUE;
return S_OK;
}
// Handler for the XM_NOTIFY message
HRESULT CScene_DebugOverlay::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_DebugOverlay::OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData,
BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
unsigned int nIndex;
Minecraft *pMinecraft = Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
if ( hObjPressed == m_items )
{
if (hObjPressed == m_items) {
nIndex = m_items.GetCurSel();
if(nIndex<m_itemIds.size())
{
int id = m_itemIds[nIndex];
//app.SetXuiServerAction(pNotifyPressData->UserIndex, eXuiServerAction_DropItem, (void *)id);
ClientConnection *conn = Minecraft::GetInstance()->getConnection(ProfileManager.GetPrimaryPad());
conn->send( GiveItemCommand::preparePacket(std::dynamic_pointer_cast<Player>(Minecraft::GetInstance()->localplayers[ProfileManager.GetPrimaryPad()]), id) );
}
}
else if ( hObjPressed == m_mobs )
{
if (nIndex < m_itemIds.size()) {
int id = m_itemIds[nIndex];
// app.SetXuiServerAction(pNotifyPressData->UserIndex,
// eXuiServerAction_DropItem, (void *)id);
ClientConnection* conn = Minecraft::GetInstance()->getConnection(
ProfileManager.GetPrimaryPad());
conn->send(GiveItemCommand::preparePacket(
std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()
->localplayers[ProfileManager.GetPrimaryPad()]),
id));
}
} else if (hObjPressed == m_mobs) {
nIndex = m_mobs.GetCurSel();
if(nIndex<m_mobFactories.size())
{
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_SpawnMob,(void *)m_mobFactories[nIndex]);
}
}
else if ( hObjPressed == m_enchantments )
{
if (nIndex < m_mobFactories.size()) {
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),
eXuiServerAction_SpawnMob,
(void*)m_mobFactories[nIndex]);
}
} else if (hObjPressed == m_enchantments) {
nIndex = m_enchantments.GetCurSel();
ClientConnection *conn = Minecraft::GetInstance()->getConnection(ProfileManager.GetPrimaryPad());
conn->send( EnchantItemCommand::preparePacket(std::dynamic_pointer_cast<Player>(Minecraft::GetInstance()->localplayers[ProfileManager.GetPrimaryPad()]), m_enchantmentIds[nIndex]) );
ClientConnection* conn = Minecraft::GetInstance()->getConnection(
ProfileManager.GetPrimaryPad());
conn->send(EnchantItemCommand::preparePacket(
std::dynamic_pointer_cast<Player>(
Minecraft::GetInstance()
->localplayers[ProfileManager.GetPrimaryPad()]),
m_enchantmentIds[nIndex]));
}
/*else if( hObjPressed == m_saveToDisc ) // 4J-JEV: Doesn't look like we use this debug option anymore.
{
/*else if( hObjPressed == m_saveToDisc ) // 4J-JEV: Doesn't look like we use
this debug option anymore.
{
#ifndef _CONTENT_PACKAGE
pMinecraft->level->save(true, NULL);
pMinecraft->level->save(true, NULL);
int radius;
m_chunkRadius.GetValue(&radius);
if( radius > 0 )
{
SaveLimitedFile(radius);
}
else
{
pMinecraft->level->getLevelStorage()->getSaveFile()->DebugFlushToFile();
}
int radius;
m_chunkRadius.GetValue(&radius);
if( radius > 0 )
{
SaveLimitedFile(radius);
}
else
{
pMinecraft->level->getLevelStorage()->getSaveFile()->DebugFlushToFile();
}
#endif
}*/
else if( hObjPressed == m_createSchematic )
{
}*/
else if (hObjPressed == m_createSchematic) {
#ifndef _CONTENT_PACKAGE
// load from the .xzp file
const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
// load from the .xzp file
const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
HXUIOBJ hScene;
HRESULT hr;
//const WCHAR XZP_SEPARATOR = L'#';
constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[ LOCATOR_SIZE ];
HXUIOBJ hScene;
HRESULT hr;
// const WCHAR XZP_SEPARATOR = L'#';
constexpr int LOCATOR_SIZE =
256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[LOCATOR_SIZE];
swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/");
hr = XuiSceneCreate(szResourceLocator,app.GetSceneName(eUIScene_DebugCreateSchematic,false, false), NULL, &hScene);
this->NavigateForward(hScene);
//app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic);
swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",
c_ModuleHandle, L"media", L"media/");
hr = XuiSceneCreate(
szResourceLocator,
app.GetSceneName(eUIScene_DebugCreateSchematic, false, false), NULL,
&hScene);
this->NavigateForward(hScene);
// app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic);
#endif
}
else if ( hObjPressed == m_setCamera )
{
} else if (hObjPressed == m_setCamera) {
#ifndef _CONTENT_PACKAGE
// load from the .xzp file
const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
// load from the .xzp file
const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
HXUIOBJ hScene;
HRESULT hr;
//const WCHAR XZP_SEPARATOR = L'#';
constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[ LOCATOR_SIZE ];
HXUIOBJ hScene;
HRESULT hr;
// const WCHAR XZP_SEPARATOR = L'#';
constexpr int LOCATOR_SIZE =
256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[LOCATOR_SIZE];
swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/");
hr = XuiSceneCreate(szResourceLocator,app.GetSceneName(eUIScene_DebugSetCamera, false, false), NULL, &hScene);
this->NavigateForward(hScene);
//app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic);
swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls",
c_ModuleHandle, L"media", L"media/");
hr = XuiSceneCreate(
szResourceLocator,
app.GetSceneName(eUIScene_DebugSetCamera, false, false), NULL,
&hScene);
this->NavigateForward(hScene);
// app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic);
#endif
}
else if( hObjPressed == m_toggleRain )
{
//app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_ToggleRain);
ClientConnection *conn = Minecraft::GetInstance()->getConnection(ProfileManager.GetPrimaryPad());
conn->send( ToggleDownfallCommand::preparePacket() );
}
else if( hObjPressed == m_toggleThunder )
{
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_ToggleThunder);
}
else if( hObjPressed == m_resetTutorial )
{
Tutorial::debugResetPlayerSavedProgress( ProfileManager.GetPrimaryPad() );
}
else if( hObjPressed == m_setDay )
{
ClientConnection *conn = Minecraft::GetInstance()->getConnection(ProfileManager.GetPrimaryPad());
conn->send( TimeCommand::preparePacket(false) );
}
else if( hObjPressed == m_setNight )
{
ClientConnection *conn = Minecraft::GetInstance()->getConnection(ProfileManager.GetPrimaryPad());
conn->send( TimeCommand::preparePacket(true) );
}
} else if (hObjPressed == m_toggleRain) {
// app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_ToggleRain);
ClientConnection* conn = Minecraft::GetInstance()->getConnection(
ProfileManager.GetPrimaryPad());
conn->send(ToggleDownfallCommand::preparePacket());
} else if (hObjPressed == m_toggleThunder) {
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),
eXuiServerAction_ToggleThunder);
} else if (hObjPressed == m_resetTutorial) {
Tutorial::debugResetPlayerSavedProgress(ProfileManager.GetPrimaryPad());
} else if (hObjPressed == m_setDay) {
ClientConnection* conn = Minecraft::GetInstance()->getConnection(
ProfileManager.GetPrimaryPad());
conn->send(TimeCommand::preparePacket(false));
} else if (hObjPressed == m_setNight) {
ClientConnection* conn = Minecraft::GetInstance()->getConnection(
ProfileManager.GetPrimaryPad());
conn->send(TimeCommand::preparePacket(true));
}
rfHandled = TRUE;
return S_OK;
}
HRESULT CScene_DebugOverlay::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_DebugOverlay::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_PAD_START:
case VK_PAD_BACK:
switch(pInputData->dwKeyCode)
{
// kill the crafting xui
app.EnableDebugOverlay(false, pInputData->UserIndex);
case VK_PAD_B:
case VK_PAD_START:
case VK_PAD_BACK:
rfHandled = TRUE;
// kill the crafting xui
app.EnableDebugOverlay(false,pInputData->UserIndex);
break;
}
rfHandled = TRUE;
break;
}
return S_OK;
return S_OK;
}
HRESULT CScene_DebugOverlay::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled)
{
if( hObjSource == m_setTime )
{
Minecraft *pMinecraft = Minecraft::GetInstance();
// Need to set the time on both levels to stop the flickering as the local level
// tries to predict the time
// Only works if we are on the host machine, but shouldn't break if not
MinecraftServer::SetTime(pNotifyValueChangedData->nValue);
pMinecraft->level->getLevelData()->setTime(pNotifyValueChangedData->nValue);
}
if( hObjSource == m_setFov )
{
Minecraft *pMinecraft = Minecraft::GetInstance();
pMinecraft->gameRenderer->SetFovVal((float)pNotifyValueChangedData->nValue);
}
return S_OK;
HRESULT CScene_DebugOverlay::OnNotifyValueChanged(
HXUIOBJ hObjSource, XUINotifyValueChanged* pNotifyValueChangedData,
BOOL& bHandled) {
if (hObjSource == m_setTime) {
Minecraft* pMinecraft = Minecraft::GetInstance();
// Need to set the time on both levels to stop the flickering as the
// local level tries to predict the time Only works if we are on the
// host machine, but shouldn't break if not
MinecraftServer::SetTime(pNotifyValueChangedData->nValue);
pMinecraft->level->getLevelData()->setTime(
pNotifyValueChangedData->nValue);
}
if (hObjSource == m_setFov) {
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->gameRenderer->SetFovVal(
(float)pNotifyValueChangedData->nValue);
}
return S_OK;
}
HRESULT CScene_DebugOverlay::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
{
Minecraft *pMinecraft = Minecraft::GetInstance();
if(pMinecraft->level != NULL)
{
m_setTime.SetValue( pMinecraft->level->getLevelData()->getTime() % 24000 );
m_setFov.SetValue( (int)pMinecraft->gameRenderer->GetFovVal());
}
return S_OK;
HRESULT CScene_DebugOverlay::OnTimer(XUIMessageTimer* pTimer, BOOL& bHandled) {
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft->level != NULL) {
m_setTime.SetValue(pMinecraft->level->getLevelData()->getTime() %
24000);
m_setFov.SetValue((int)pMinecraft->gameRenderer->GetFovVal());
}
return S_OK;
}
void CScene_DebugOverlay::SetSpawnToPlayerPos()
{
Minecraft *pMinecraft = Minecraft::GetInstance();
void CScene_DebugOverlay::SetSpawnToPlayerPos() {
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->level->getLevelData()->setXSpawn((int)pMinecraft->player->x);
pMinecraft->level->getLevelData()->setYSpawn((int)pMinecraft->player->y);
pMinecraft->level->getLevelData()->setZSpawn((int)pMinecraft->player->z);
pMinecraft->level->getLevelData()->setXSpawn((int)pMinecraft->player->x);
pMinecraft->level->getLevelData()->setYSpawn((int)pMinecraft->player->y);
pMinecraft->level->getLevelData()->setZSpawn((int)pMinecraft->player->z);
}
#ifndef _CONTENT_PACKAGE
void CScene_DebugOverlay::SaveLimitedFile(int chunkRadius)
{
std::unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> newFileCache;
void CScene_DebugOverlay::SaveLimitedFile(int chunkRadius) {
std::unordered_map<File, RegionFile*, FileKeyHash, FileKeyEq> newFileCache;
Minecraft *pMinecraft = Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
ConsoleSaveFile *currentSave = pMinecraft->level->getLevelStorage()->getSaveFile();
ConsoleSaveFile* currentSave =
pMinecraft->level->getLevelStorage()->getSaveFile();
// With a size of 0 but a value in the data pointer we should create a new save
ConsoleSaveFileOriginal newSave( currentSave->getFilename(), NULL, 0, true );
// With a size of 0 but a value in the data pointer we should create a new
// save
ConsoleSaveFileOriginal newSave(currentSave->getFilename(), NULL, 0, true);
// TODO Make this only happen for the new save
//SetSpawnToPlayerPos();
FileEntry *origFileEntry = currentSave->createFile( std::wstring( L"level.dat" ) );
byteArray levelData( origFileEntry->getFileSize() );
unsigned int bytesRead;
currentSave->setFilePointer(origFileEntry, 0, SaveFileSeekOrigin::Begin);
currentSave->readFile(
origFileEntry,
levelData.data, // data buffer
origFileEntry->getFileSize(), // number of bytes to read
&bytesRead // number of bytes read
);
// TODO Make this only happen for the new save
// SetSpawnToPlayerPos();
FileEntry* origFileEntry =
currentSave->createFile(std::wstring(L"level.dat"));
byteArray levelData(origFileEntry->getFileSize());
unsigned int bytesRead;
currentSave->setFilePointer(origFileEntry, 0, SaveFileSeekOrigin::Begin);
currentSave->readFile(
origFileEntry,
levelData.data, // data buffer
origFileEntry->getFileSize(), // number of bytes to read
&bytesRead // number of bytes read
);
FileEntry *newFileEntry = newSave.createFile( std::wstring( L"level.dat" ) );
unsigned int bytesWritten;
newSave.writeFile( newFileEntry,
levelData.data, // data buffer
origFileEntry->getFileSize(), // number of bytes to write
&bytesWritten // number of bytes written
);
FileEntry* newFileEntry = newSave.createFile(std::wstring(L"level.dat"));
unsigned int bytesWritten;
newSave.writeFile(newFileEntry,
levelData.data, // data buffer
origFileEntry->getFileSize(), // number of bytes to write
&bytesWritten // number of bytes written
);
int playerChunkX = pMinecraft->player->xChunk;
int playerChunkZ = pMinecraft->player->zChunk;
int playerChunkX = pMinecraft->player->xChunk;
int playerChunkZ = pMinecraft->player->zChunk;
for(int xPos = playerChunkX - chunkRadius; xPos < playerChunkX + chunkRadius; ++xPos)
{
for(int zPos = playerChunkZ - chunkRadius; zPos < playerChunkZ + chunkRadius; ++zPos)
{
CompoundTag *chunkData=NULL;
for (int xPos = playerChunkX - chunkRadius;
xPos < playerChunkX + chunkRadius; ++xPos) {
for (int zPos = playerChunkZ - chunkRadius;
zPos < playerChunkZ + chunkRadius; ++zPos) {
CompoundTag* chunkData = NULL;
DataInputStream *is = RegionFileCache::getChunkDataInputStream(currentSave, L"", xPos, zPos);
if (is != NULL)
{
chunkData = NbtIo::read((DataInput *)is);
is->deleteChildStream();
delete is;
}
app.DebugPrintf("Processing chunk (%d, %d)\n", xPos, zPos);
DataOutputStream *os = getChunkDataOutputStream(newFileCache, &newSave, L"", xPos, zPos);
if(os != NULL)
{
NbtIo::write(chunkData, os);
os->close();
DataInputStream* is = RegionFileCache::getChunkDataInputStream(
currentSave, L"", xPos, zPos);
if (is != NULL) {
chunkData = NbtIo::read((DataInput*)is);
is->deleteChildStream();
delete is;
}
app.DebugPrintf("Processing chunk (%d, %d)\n", xPos, zPos);
DataOutputStream* os = getChunkDataOutputStream(
newFileCache, &newSave, L"", xPos, zPos);
if (os != NULL) {
NbtIo::write(chunkData, os);
os->close();
// 4J Stu - getChunkDataOutputStream makes a new DataOutputStream that points to a new ChunkBuffer( ByteArrayOutputStream )
// We should clean these up when we are done
os->deleteChildStream();
delete os;
}
if(chunkData != NULL)
{
delete chunkData;
}
}
}
// 4J Stu - getChunkDataOutputStream makes a new
// DataOutputStream that points to a new ChunkBuffer(
// ByteArrayOutputStream ) We should clean these up when we are
// done
os->deleteChildStream();
delete os;
}
if (chunkData != NULL) {
delete chunkData;
}
}
}
newSave.DebugFlushToFile();
newSave.DebugFlushToFile();
}
#endif
RegionFile *CScene_DebugOverlay::getRegionFile(std::unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> &newFileCache, ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ) // 4J - TODO was synchronized
RegionFile* CScene_DebugOverlay::getRegionFile(
std::unordered_map<File, RegionFile*, FileKeyHash, FileKeyEq>& newFileCache,
ConsoleSaveFile* saveFile, const std::wstring& prefix, int chunkX,
int chunkZ) // 4J - TODO was synchronized
{
File file( prefix + std::wstring(L"r.") + _toString(chunkX>>5) + L"." + _toString(chunkZ>>5) + L".mcr" );
File file(prefix + std::wstring(L"r.") + _toString(chunkX >> 5) + L"." +
_toString(chunkZ >> 5) + L".mcr");
RegionFile *ref = NULL;
AUTO_VAR(it, newFileCache.find(file));
if( it != newFileCache.end() )
ref = it->second;
RegionFile* ref = NULL;
AUTO_VAR(it, newFileCache.find(file));
if (it != newFileCache.end()) ref = it->second;
// 4J Jev, put back in.
if (ref != NULL)
{
return ref;
// 4J Jev, put back in.
if (ref != NULL) {
return ref;
}
RegionFile *reg = new RegionFile(saveFile, &file);
newFileCache[file] = reg; // 4J - this was originally a softReferenc
RegionFile* reg = new RegionFile(saveFile, &file);
newFileCache[file] = reg; // 4J - this was originally a softReferenc
return reg;
}
DataOutputStream *CScene_DebugOverlay::getChunkDataOutputStream(std::unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> &newFileCache, ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ)
{
RegionFile *r = getRegionFile(newFileCache, saveFile, prefix, chunkX, chunkZ);
DataOutputStream* CScene_DebugOverlay::getChunkDataOutputStream(
std::unordered_map<File, RegionFile*, FileKeyHash, FileKeyEq>& newFileCache,
ConsoleSaveFile* saveFile, const std::wstring& prefix, int chunkX,
int chunkZ) {
RegionFile* r =
getRegionFile(newFileCache, saveFile, prefix, chunkX, chunkZ);
return r->getChunkDataOutputStream(chunkX & 31, chunkZ & 31);
}
#endif

View File

@@ -1,5 +1,5 @@
#pragma once
//using namespace std;
// using namespace std;
#include "../media/xuiscene_debugoverlay.h"
#define DEBUG_OVERLAY_UPDATE_TIME_PERIOD 10000
@@ -10,63 +10,75 @@ class ConsoleSaveFile;
#include "../../Minecraft.World/IO/Files/File.h"
#include "../../Minecraft.World/Entities/Entity.h"
class CScene_DebugOverlay : public CXuiSceneImpl
{
#ifdef _DEBUG_MENUS_ENABLED
class CScene_DebugOverlay : public CXuiSceneImpl {
#ifdef _DEBUG_MENUS_ENABLED
private:
CXuiList m_items, m_mobs, m_enchantments;
CXuiControl m_resetTutorial, m_createSchematic, m_toggleRain, m_toggleThunder, m_setCamera;
CXuiControl m_setDay, m_setNight;
CXuiSlider m_chunkRadius, m_setTime,m_setFov;
std::vector<int> m_itemIds;
std::vector<eINSTANCEOF> m_mobFactories;
std::vector<int> m_enchantmentIds;
CXuiList m_items, m_mobs, m_enchantments;
CXuiControl m_resetTutorial, m_createSchematic, m_toggleRain,
m_toggleThunder, m_setCamera;
CXuiControl m_setDay, m_setNight;
CXuiSlider m_chunkRadius, m_setTime, m_setFov;
std::vector<int> m_itemIds;
std::vector<eINSTANCEOF> m_mobFactories;
std::vector<int> m_enchantmentIds;
protected:
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_NOTIFY_PRESS_EX( OnNotifyPressEx )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED( OnNotifyValueChanged )
XUI_ON_XM_TIMER( OnTimer )
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_ON_XM_TIMER(OnTimer)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_ChunkRadius, m_chunkRadius)
MAP_CONTROL(IDC_ResetTutorial, m_resetTutorial)
MAP_CONTROL(IDC_CreateSchematic, m_createSchematic)
MAP_CONTROL(IDC_ToggleRain, m_toggleRain)
MAP_CONTROL(IDC_ToggleThunder, m_toggleThunder)
MAP_CONTROL(IDC_SetDay, m_setDay)
MAP_CONTROL(IDC_SetNight, m_setNight)
MAP_CONTROL(IDC_SliderTime, m_setTime)
MAP_CONTROL(IDC_SliderFov, m_setFov)
MAP_CONTROL(IDC_MobList, m_mobs)
MAP_CONTROL(IDC_EnchantmentsList, m_enchantments)
MAP_CONTROL(IDC_ItemsList, m_items)
MAP_CONTROL(IDC_SetCamera, m_setCamera)
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_ChunkRadius, m_chunkRadius)
MAP_CONTROL(IDC_ResetTutorial, m_resetTutorial)
MAP_CONTROL(IDC_CreateSchematic, m_createSchematic)
MAP_CONTROL(IDC_ToggleRain, m_toggleRain)
MAP_CONTROL(IDC_ToggleThunder, m_toggleThunder)
MAP_CONTROL(IDC_SetDay, m_setDay)
MAP_CONTROL(IDC_SetNight, m_setNight)
MAP_CONTROL(IDC_SliderTime, m_setTime)
MAP_CONTROL(IDC_SliderFov, m_setFov)
MAP_CONTROL(IDC_MobList, m_mobs)
MAP_CONTROL(IDC_EnchantmentsList, m_enchantments)
MAP_CONTROL(IDC_ItemsList, m_items)
MAP_CONTROL(IDC_SetCamera, m_setCamera)
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged(HXUIOBJ hObjSource,
XUINotifyValueChanged* pNotifyValueChangedData,
BOOL& bHandled);
HRESULT OnTimer(XUIMessageTimer* pTimer, BOOL& bHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled);
HRESULT OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled );
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_DebugOverlay, L"CScene_DebugOverlay", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_DebugOverlay, L"CScene_DebugOverlay",
XUI_CLASS_SCENE)
private:
void SetSpawnToPlayerPos();
void SetSpawnToPlayerPos();
#ifndef _CONTENT_PACKAGE
void SaveLimitedFile(int chunkRadius);
#endif
RegionFile *getRegionFile(std::unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> &newFileCache, ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ);
void SaveLimitedFile(int chunkRadius);
#endif
RegionFile* getRegionFile(std::unordered_map<File, RegionFile*, FileKeyHash,
FileKeyEq>& newFileCache,
ConsoleSaveFile* saveFile,
const std::wstring& prefix, int chunkX,
int chunkZ);
DataOutputStream *getChunkDataOutputStream(std::unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> &newFileCache, ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ);
DataOutputStream* getChunkDataOutputStream(
std::unordered_map<File, RegionFile*, FileKeyHash, FileKeyEq>&
newFileCache,
ConsoleSaveFile* saveFile, const std::wstring& prefix, int chunkX,
int chunkZ);
#endif
};

View File

@@ -5,174 +5,153 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
#ifndef _CONTENT_PACKAGE
HRESULT CScene_DebugSchematicCreator::OnInit( XUIMessageInit *pInitData, BOOL &bHandled )
{
MapChildControls();
HRESULT CScene_DebugSchematicCreator::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
MapChildControls();
m_startX .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_startY .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_startZ .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_endX .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_endY .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_endZ .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_startX.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_startY.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_startZ.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_endX.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_endY.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_endZ.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_data = new ConsoleSchematicFile::XboxSchematicInitParam();
m_data = new ConsoleSchematicFile::XboxSchematicInitParam();
return S_OK;
return S_OK;
}
HRESULT CScene_DebugSchematicCreator::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_DebugSchematicCreator::OnNotifyPressEx(
HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if ( hObjPressed == m_createButton )
{
// We want the start to be even
if(m_data->startX > 0 && m_data->startX%2 != 0)
m_data->startX-=1;
else if(m_data->startX < 0 && m_data->startX%2 !=0)
m_data->startX-=1;
if(m_data->startY < 0) m_data->startY = 0;
else if(m_data->startY > 0 && m_data->startY%2 != 0)
m_data->startY-=1;
if(m_data->startZ > 0 && m_data->startZ%2 != 0)
m_data->startZ-=1;
else if(m_data->startZ < 0 && m_data->startZ%2 !=0)
m_data->startZ-=1;
// We want the end to be odd to have a total size that is even
if(m_data->endX > 0 && m_data->endX%2 == 0)
m_data->endX+=1;
else if(m_data->endX < 0 && m_data->endX%2 ==0)
m_data->endX+=1;
if(m_data->endY > Level::maxBuildHeight)
m_data->endY = Level::maxBuildHeight;
else if(m_data->endY > 0 && m_data->endY%2 == 0)
m_data->endY+=1;
else if(m_data->endY < 0 && m_data->endY%2 ==0)
m_data->endY+=1;
if(m_data->endZ > 0 && m_data->endZ%2 == 0)
m_data->endZ+=1;
else if(m_data->endZ < 0 && m_data->endZ%2 ==0)
m_data->endZ+=1;
if (hObjPressed == m_createButton) {
// We want the start to be even
if (m_data->startX > 0 && m_data->startX % 2 != 0)
m_data->startX -= 1;
else if (m_data->startX < 0 && m_data->startX % 2 != 0)
m_data->startX -= 1;
if (m_data->startY < 0)
m_data->startY = 0;
else if (m_data->startY > 0 && m_data->startY % 2 != 0)
m_data->startY -= 1;
if (m_data->startZ > 0 && m_data->startZ % 2 != 0)
m_data->startZ -= 1;
else if (m_data->startZ < 0 && m_data->startZ % 2 != 0)
m_data->startZ -= 1;
std::wstring value = m_name.GetText();
if(!value.empty())
{
swprintf(m_data->name,64,L"%ls", value.c_str());
}
else
{
swprintf(m_data->name,64,L"schematic");
}
// We want the end to be odd to have a total size that is even
if (m_data->endX > 0 && m_data->endX % 2 == 0)
m_data->endX += 1;
else if (m_data->endX < 0 && m_data->endX % 2 == 0)
m_data->endX += 1;
if (m_data->endY > Level::maxBuildHeight)
m_data->endY = Level::maxBuildHeight;
else if (m_data->endY > 0 && m_data->endY % 2 == 0)
m_data->endY += 1;
else if (m_data->endY < 0 && m_data->endY % 2 == 0)
m_data->endY += 1;
if (m_data->endZ > 0 && m_data->endZ % 2 == 0)
m_data->endZ += 1;
else if (m_data->endZ < 0 && m_data->endZ % 2 == 0)
m_data->endZ += 1;
m_data->bSaveMobs = m_saveMobs.IsChecked();
std::wstring value = m_name.GetText();
if (!value.empty()) {
swprintf(m_data->name, 64, L"%ls", value.c_str());
} else {
swprintf(m_data->name, 64, L"schematic");
}
m_data->bSaveMobs = m_saveMobs.IsChecked();
#ifdef _XBOX
if (m_useXboxCompr.IsChecked())
m_data->compressionType = Compression::eCompressionType_LZXRLE;
else
if (m_useXboxCompr.IsChecked())
m_data->compressionType = Compression::eCompressionType_LZXRLE;
else
#endif
m_data->compressionType = Compression::eCompressionType_RLE;
m_data->compressionType = Compression::eCompressionType_RLE;
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(), eXuiServerAction_ExportSchematic, (void *)m_data);
NavigateBack();
rfHandled = TRUE;
}
return S_OK;
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),
eXuiServerAction_ExportSchematic, (void*)m_data);
NavigateBack();
rfHandled = TRUE;
}
return S_OK;
}
HRESULT CScene_DebugSchematicCreator::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_DebugSchematicCreator::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch(pInputData->dwKeyCode)
{
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_PAD_START:
case VK_PAD_BACK:
NavigateBack();
case VK_PAD_B:
case VK_PAD_START:
case VK_PAD_BACK:
NavigateBack();
rfHandled = TRUE;
rfHandled = TRUE;
break;
}
break;
}
return S_OK;
return S_OK;
}
HRESULT CScene_DebugSchematicCreator::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled)
{
if(hObjSource == m_startX)
{
int iVal = 0;
std::wstring value = m_startX.GetText();
if(!value.empty()) iVal = _fromString<int>( value );
HRESULT CScene_DebugSchematicCreator::OnNotifyValueChanged(
HXUIOBJ hObjSource, XUINotifyValueChanged* pNotifyValueChangedData,
BOOL& bHandled) {
if (hObjSource == m_startX) {
int iVal = 0;
std::wstring value = m_startX.GetText();
if (!value.empty()) iVal = _fromString<int>(value);
if( iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16))
{
m_data->startX = iVal;
}
}
else if(hObjSource == m_startY)
{
int iVal = 0;
std::wstring value = m_startY.GetText();
if(!value.empty()) iVal = _fromString<int>( value );
if (iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) {
m_data->startX = iVal;
}
} else if (hObjSource == m_startY) {
int iVal = 0;
std::wstring value = m_startY.GetText();
if (!value.empty()) iVal = _fromString<int>(value);
if( iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16))
{
m_data->startY = iVal;
}
}
else if(hObjSource == m_startZ)
{
int iVal = 0;
std::wstring value = m_startZ.GetText();
if(!value.empty()) iVal = _fromString<int>( value );
if (iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) {
m_data->startY = iVal;
}
} else if (hObjSource == m_startZ) {
int iVal = 0;
std::wstring value = m_startZ.GetText();
if (!value.empty()) iVal = _fromString<int>(value);
if( iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16))
{
m_data->startZ = iVal;
}
}
else if(hObjSource == m_endX)
{
int iVal = 0;
std::wstring value = m_endX.GetText();
if(!value.empty()) iVal = _fromString<int>( value );
if (iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) {
m_data->startZ = iVal;
}
} else if (hObjSource == m_endX) {
int iVal = 0;
std::wstring value = m_endX.GetText();
if (!value.empty()) iVal = _fromString<int>(value);
if( iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16))
{
m_data->endX = iVal;
}
}
else if(hObjSource == m_endY)
{
int iVal = 0;
std::wstring value = m_endY.GetText();
if(!value.empty()) iVal = _fromString<int>( value );
if (iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) {
m_data->endX = iVal;
}
} else if (hObjSource == m_endY) {
int iVal = 0;
std::wstring value = m_endY.GetText();
if (!value.empty()) iVal = _fromString<int>(value);
if( iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16))
{
m_data->endY = iVal;
}
}
else if(hObjSource == m_endZ)
{
int iVal = 0;
std::wstring value = m_endZ.GetText();
if(!value.empty()) iVal = _fromString<int>( value );
if (iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) {
m_data->endY = iVal;
}
} else if (hObjSource == m_endZ) {
int iVal = 0;
std::wstring value = m_endZ.GetText();
if (!value.empty()) iVal = _fromString<int>(value);
if( iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16))
{
m_data->endZ = iVal;
}
}
return S_OK;
if (iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) {
m_data->endZ = iVal;
}
}
return S_OK;
}
#endif

View File

@@ -3,47 +3,50 @@
#include "XUI_Ctrl_4JEdit.h"
#include "../GameRules/ConsoleSchematicFile.h"
class CScene_DebugSchematicCreator : public CXuiSceneImpl
{
class CScene_DebugSchematicCreator : public CXuiSceneImpl {
#ifndef _CONTENT_PACKAGE
private:
CXuiControl m_createButton;
CXuiCtrl4JEdit m_name, m_startX, m_startY, m_startZ, m_endX, m_endY, m_endZ;
CXuiCheckbox m_saveMobs, m_useXboxCompr;
CXuiControl m_createButton;
CXuiCtrl4JEdit m_name, m_startX, m_startY, m_startZ, m_endX, m_endY, m_endZ;
CXuiCheckbox m_saveMobs, m_useXboxCompr;
ConsoleSchematicFile::XboxSchematicInitParam *m_data;
ConsoleSchematicFile::XboxSchematicInitParam* m_data;
protected:
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_NOTIFY_PRESS_EX( OnNotifyPressEx )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED( OnNotifyValueChanged )
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_CreateButton, m_createButton)
MAP_CONTROL(IDC_Name, m_name)
MAP_CONTROL(IDC_StartX, m_startX)
MAP_CONTROL(IDC_StartY, m_startY)
MAP_CONTROL(IDC_StartZ, m_startZ)
MAP_CONTROL(IDC_EndX, m_endX)
MAP_CONTROL(IDC_EndY, m_endY)
MAP_CONTROL(IDC_EndZ, m_endZ)
MAP_CONTROL(IDC_SaveMobs, m_saveMobs)
MAP_CONTROL(IDC_UseXboxCompression, m_useXboxCompr)
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_CreateButton, m_createButton)
MAP_CONTROL(IDC_Name, m_name)
MAP_CONTROL(IDC_StartX, m_startX)
MAP_CONTROL(IDC_StartY, m_startY)
MAP_CONTROL(IDC_StartZ, m_startZ)
MAP_CONTROL(IDC_EndX, m_endX)
MAP_CONTROL(IDC_EndY, m_endY)
MAP_CONTROL(IDC_EndZ, m_endZ)
MAP_CONTROL(IDC_SaveMobs, m_saveMobs)
MAP_CONTROL(IDC_UseXboxCompression, m_useXboxCompr)
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged(HXUIOBJ hObjSource,
XUINotifyValueChanged* pNotifyValueChangedData,
BOOL& bHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_DebugSchematicCreator, L"CScene_DebugSchematicCreator", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_DebugSchematicCreator,
L"CScene_DebugSchematicCreator", XUI_CLASS_SCENE)
#endif
};

View File

@@ -9,144 +9,139 @@
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
#ifndef _CONTENT_PACKAGE
HRESULT CScene_DebugSetCamera::OnInit( XUIMessageInit *pInitData, BOOL &bHandled )
{
MapChildControls();
HRESULT CScene_DebugSetCamera::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
MapChildControls();
m_camX .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_camY .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_camZ .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_yRot .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_elevation .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_camX.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_camY.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_camZ.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_yRot.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
m_elevation.SetKeyboardType(C_4JInput::EKeyboardMode_Numeric);
int playerNo = 0;
currentPosition = new DebugSetCameraPosition();
int playerNo = 0;
currentPosition = new DebugSetCameraPosition();
currentPosition->player = playerNo;
Minecraft *pMinecraft = Minecraft::GetInstance();
if (pMinecraft != NULL)
{
Vec3 *vec = pMinecraft->localplayers[playerNo]->getPos(1.0);
currentPosition->player = playerNo;
currentPosition->m_camX = vec->x;
currentPosition->m_camY = vec->y - 1.62;// pMinecraft->localplayers[playerNo]->getHeadHeight();
currentPosition->m_camZ = vec->z;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft != NULL) {
Vec3* vec = pMinecraft->localplayers[playerNo]->getPos(1.0);
currentPosition->m_yRot = pMinecraft->localplayers[playerNo]->yRot;
currentPosition->m_elev = pMinecraft->localplayers[playerNo]->xRot;
}
currentPosition->m_camX = vec->x;
currentPosition->m_camY =
vec->y -
1.62; // pMinecraft->localplayers[playerNo]->getHeadHeight();
currentPosition->m_camZ = vec->z;
m_camX.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_camY.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_camZ.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_yRot.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_elevation.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
currentPosition->m_yRot = pMinecraft->localplayers[playerNo]->yRot;
currentPosition->m_elev = pMinecraft->localplayers[playerNo]->xRot;
}
m_camX.SetText((CONST WCHAR *) _toString<double>(currentPosition->m_camX).c_str());
m_camY.SetText((CONST WCHAR *) _toString<double>(currentPosition->m_camY + 1.62).c_str());
m_camZ.SetText((CONST WCHAR *) _toString<double>(currentPosition->m_camZ).c_str());
m_camX.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_camY.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_camZ.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_yRot.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_elevation.SetKeyboardType(C_4JInput::EKeyboardMode_Full);
m_yRot.SetText((CONST WCHAR *) _toString<double>(currentPosition->m_yRot).c_str());
m_elevation.SetText((CONST WCHAR *) _toString<double>(currentPosition->m_elev).c_str());
//fpp = new FreezePlayerParam();
//fpp->player = playerNo;
//fpp->freeze = true;
m_camX.SetText(
(CONST WCHAR*)_toString<double>(currentPosition->m_camX).c_str());
m_camY.SetText(
(CONST WCHAR*)_toString<double>(currentPosition->m_camY + 1.62)
.c_str());
m_camZ.SetText(
(CONST WCHAR*)_toString<double>(currentPosition->m_camZ).c_str());
//m_lockPlayer.SetCheck( !fpp->freeze );
m_yRot.SetText(
(CONST WCHAR*)_toString<double>(currentPosition->m_yRot).c_str());
m_elevation.SetText(
(CONST WCHAR*)_toString<double>(currentPosition->m_elev).c_str());
m_lockPlayer.SetCheck( app.GetFreezePlayers() );
// fpp = new FreezePlayerParam();
// fpp->player = playerNo;
// fpp->freeze = true;
return S_OK;
// m_lockPlayer.SetCheck( !fpp->freeze );
m_lockPlayer.SetCheck(app.GetFreezePlayers());
return S_OK;
}
HRESULT CScene_DebugSetCamera::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_DebugSetCamera::OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData,
BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if (hObjPressed == m_teleport)
{
app.SetXuiServerAction( ProfileManager.GetPrimaryPad(),
eXuiServerAction_SetCameraLocation,
(void *)currentPosition);
rfHandled = TRUE;
}
else if (hObjPressed == m_lockPlayer)
{
app.SetFreezePlayers( m_lockPlayer.IsChecked() );
if (hObjPressed == m_teleport) {
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),
eXuiServerAction_SetCameraLocation,
(void*)currentPosition);
rfHandled = TRUE;
} else if (hObjPressed == m_lockPlayer) {
app.SetFreezePlayers(m_lockPlayer.IsChecked());
rfHandled = TRUE;
}
rfHandled = TRUE;
}
return S_OK;
return S_OK;
}
HRESULT CScene_DebugSetCamera::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch(pInputData->dwKeyCode)
{
case VK_PAD_B:
case VK_PAD_START:
case VK_PAD_BACK:
NavigateBack();
HRESULT CScene_DebugSetCamera::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_PAD_START:
case VK_PAD_BACK:
NavigateBack();
//delete currentPosition;
//currentPosition = NULL;
// delete currentPosition;
// currentPosition = NULL;
rfHandled = TRUE;
break;
}
return S_OK;
rfHandled = TRUE;
break;
}
return S_OK;
}
HRESULT CScene_DebugSetCamera::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled)
{
HRESULT CScene_DebugSetCamera::OnNotifyValueChanged(
HXUIOBJ hObjSource, XUINotifyValueChanged* pNotifyValueChangedData,
BOOL& bHandled) {
// Text Boxes
if (hObjSource == m_camX) {
double iVal = 0;
std::wstring value = m_camX.GetText();
if (!value.empty()) iVal = _fromString<double>(value);
currentPosition->m_camX = iVal;
bHandled = TRUE;
} else if (hObjSource == m_camY) {
double iVal = 0;
std::wstring value = m_camY.GetText();
if (!value.empty()) iVal = _fromString<double>(value);
currentPosition->m_camY = iVal - 1.62;
bHandled = TRUE;
} else if (hObjSource == m_camZ) {
double iVal = 0;
std::wstring value = m_camZ.GetText();
if (!value.empty()) iVal = _fromString<double>(value);
currentPosition->m_camZ = iVal;
bHandled = TRUE;
} else if (hObjSource == m_yRot) {
double iVal = 0;
std::wstring value = m_yRot.GetText();
if (!value.empty()) iVal = _fromString<double>(value);
currentPosition->m_yRot = iVal;
bHandled = TRUE;
} else if (hObjSource == m_elevation) {
double iVal = 0;
std::wstring value = m_elevation.GetText();
if (!value.empty()) iVal = _fromString<double>(value);
currentPosition->m_elev = iVal;
bHandled = TRUE;
}
// Text Boxes
if (hObjSource == m_camX)
{
double iVal = 0;
std::wstring value = m_camX.GetText();
if(!value.empty()) iVal = _fromString<double>( value );
currentPosition->m_camX = iVal;
bHandled = TRUE;
}
else if (hObjSource == m_camY)
{
double iVal = 0;
std::wstring value = m_camY.GetText();
if(!value.empty()) iVal = _fromString<double>( value );
currentPosition->m_camY = iVal - 1.62;
bHandled = TRUE;
}
else if (hObjSource == m_camZ)
{
double iVal = 0;
std::wstring value = m_camZ.GetText();
if(!value.empty()) iVal = _fromString<double>( value );
currentPosition->m_camZ = iVal;
bHandled = TRUE;
}
else if (hObjSource == m_yRot)
{
double iVal = 0;
std::wstring value = m_yRot.GetText();
if(!value.empty()) iVal = _fromString<double>( value );
currentPosition->m_yRot = iVal;
bHandled = TRUE;
}
else if (hObjSource == m_elevation)
{
double iVal = 0;
std::wstring value = m_elevation.GetText();
if(!value.empty()) iVal = _fromString<double>( value );
currentPosition->m_elev = iVal;
bHandled = TRUE;
}
return S_OK;
return S_OK;
}
#endif

View File

@@ -3,52 +3,54 @@
#include "XUI_Ctrl_4JEdit.h"
#include "../GameRules/ConsoleSchematicFile.h"
class CScene_DebugSetCamera : public CXuiSceneImpl
{
class CScene_DebugSetCamera : public CXuiSceneImpl {
public:
typedef struct _FreezePlayerParam
{
int player;
bool freeze;
} FreezePlayerParam;
typedef struct _FreezePlayerParam {
int player;
bool freeze;
} FreezePlayerParam;
#ifndef _CONTENT_PACKAGE
private:
CXuiCtrl4JEdit m_camX, m_camY, m_camZ, m_yRot, m_elevation;
CXuiCheckbox m_lockPlayer;
CXuiControl m_teleport;
CXuiCtrl4JEdit m_camX, m_camY, m_camZ, m_yRot, m_elevation;
CXuiCheckbox m_lockPlayer;
CXuiControl m_teleport;
DebugSetCameraPosition *currentPosition;
FreezePlayerParam *fpp;
DebugSetCameraPosition* currentPosition;
FreezePlayerParam* fpp;
protected:
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_NOTIFY_PRESS_EX( OnNotifyPressEx )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED( OnNotifyValueChanged )
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_CamX, m_camX)
MAP_CONTROL(IDC_CamY, m_camY)
MAP_CONTROL(IDC_CamZ, m_camZ)
MAP_CONTROL(IDC_YRot, m_yRot)
MAP_CONTROL(IDC_Elevation, m_elevation)
MAP_CONTROL(IDC_LockPlayer, m_lockPlayer)
MAP_CONTROL(IDC_Teleport, m_teleport)
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_CamX, m_camX)
MAP_CONTROL(IDC_CamY, m_camY)
MAP_CONTROL(IDC_CamZ, m_camZ)
MAP_CONTROL(IDC_YRot, m_yRot)
MAP_CONTROL(IDC_Elevation, m_elevation)
MAP_CONTROL(IDC_LockPlayer, m_lockPlayer)
MAP_CONTROL(IDC_Teleport, m_teleport)
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged(HXUIOBJ hObjSource,
XUINotifyValueChanged* pNotifyValueChangedData,
BOOL& bHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_DebugSetCamera, L"CScene_DebugSetCamera", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_DebugSetCamera, L"CScene_DebugSetCamera",
XUI_CLASS_SCENE)
#endif
};

View File

@@ -7,67 +7,64 @@
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_DebugTips::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *(int *)pInitData->pvInitData;
HRESULT CScene_DebugTips::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
m_iPad = *(int*)pInitData->pvInitData;
m_bIgnoreInput = false;
m_bIgnoreInput = false;
MapChildControls();
MapChildControls();
// Display the tooltips
//ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT);
// display the next tip
std::wstring wsText=app.FormatHTMLString(m_iPad,app.GetString(app.GetNextTip()));
wchar_t startTags[64];
swprintf(startTags,64,L"<font color=\"#%08x\" size=14><DIV ALIGN=CENTER>",app.GetHTMLColour(eHTMLColor_White));
wsText= startTags + wsText + L"</DIV>";
XuiControlSetText(m_tip,wsText.c_str());
// Display the tooltips
// ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT);
// display the next tip
std::wstring wsText =
app.FormatHTMLString(m_iPad, app.GetString(app.GetNextTip()));
wchar_t startTags[64];
swprintf(startTags, 64, L"<font color=\"#%08x\" size=14><DIV ALIGN=CENTER>",
app.GetHTMLColour(eHTMLColor_White));
wsText = startTags + wsText + L"</DIV>";
XuiControlSetText(m_tip, wsText.c_str());
return S_OK;
return S_OK;
}
HRESULT CScene_DebugTips::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
// ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_DebugTips::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
//ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch (pInputData->dwKeyCode) {
case VK_PAD_A: {
// next tip
// display the next tip
std::wstring wsText =
app.FormatHTMLString(m_iPad, app.GetString(app.GetNextTip()));
wchar_t startTags[64];
swprintf(startTags, 64,
L"<font color=\"#%08x\" size=14><DIV ALIGN=CENTER>",
app.GetHTMLColour(eHTMLColor_White));
wsText = startTags + wsText + L"</DIV>";
XuiControlSetText(m_tip, wsText.c_str());
rfHandled = TRUE;
} break;
switch(pInputData->dwKeyCode)
{
case VK_PAD_A:
{
case VK_PAD_B:
case VK_PAD_START:
case VK_ESCAPE:
// next tip
// display the next tip
std::wstring wsText=app.FormatHTMLString(m_iPad,app.GetString(app.GetNextTip()));
wchar_t startTags[64];
swprintf(startTags,64,L"<font color=\"#%08x\" size=14><DIV ALIGN=CENTER>",app.GetHTMLColour(eHTMLColor_White));
wsText= startTags + wsText + L"</DIV>";
XuiControlSetText(m_tip,wsText.c_str());
app.NavigateBack(m_iPad);
rfHandled = TRUE;
}
break;
rfHandled = TRUE;
case VK_PAD_B:
case VK_PAD_START:
case VK_ESCAPE:
app.NavigateBack(m_iPad);
rfHandled = TRUE;
break;
break;
#ifndef _CONTENT_PACKAGE
case VK_PAD_LTHUMB_PRESS:
case VK_PAD_LTHUMB_PRESS:
#ifdef _XBOX
app.OverrideFontRenderer(true);
app.OverrideFontRenderer(true);
#endif
break;
break;
#endif
}
}
return S_OK;
return S_OK;
}

View File

@@ -2,37 +2,32 @@
#include "../media/xuiscene_DebugTips.h"
class CScene_DebugTips : public CXuiSceneImpl {
protected:
// Control and Element wrapper objects.
CXuiControl m_tip;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Tip, m_tip)
END_CONTROL_MAP()
class CScene_DebugTips : public CXuiSceneImpl
{
protected:
// Control and Element wrapper objects.
CXuiControl m_tip;
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Tip, m_tip)
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_DebugTips, L"CScene_DebugTips", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_DebugTips, L"CScene_DebugTips", XUI_CLASS_SCENE)
private:
bool m_bIgnoreInput;
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
bool m_bIgnoreInput;
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
};

View File

@@ -12,364 +12,385 @@
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_FullscreenProgress::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
MapChildControls();
HRESULT CScene_FullscreenProgress::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
MapChildControls();
m_buttonConfirm.SetText( app.GetString( IDS_CONFIRM_OK ) );
m_buttonConfirm.SetText(app.GetString(IDS_CONFIRM_OK));
LoadingInputParams *params = (LoadingInputParams *)pInitData->pvInitData;
LoadingInputParams* params = (LoadingInputParams*)pInitData->pvInitData;
m_CompletionData = params->completionData;
m_iPad=params->completionData->iPad;
m_cancelFunc = params->cancelFunc;
m_cancelFuncParam = params->m_cancelFuncParam;
m_completeFunc = params->completeFunc;
m_completeFuncParam = params->m_completeFuncParam;
m_bWasCancelled=false;
m_CompletionData = params->completionData;
m_iPad = params->completionData->iPad;
m_cancelFunc = params->cancelFunc;
m_cancelFuncParam = params->m_cancelFuncParam;
m_completeFunc = params->completeFunc;
m_completeFuncParam = params->m_completeFuncParam;
m_bWasCancelled = false;
thread = new C4JThread(params->func, params->lpParam, "FullscreenProgress");
thread->SetProcessor(3); // TODO 4J Stu - Make sure this is a good thread/core to use
thread = new C4JThread(params->func, params->lpParam, "FullscreenProgress");
thread->SetProcessor(
3); // TODO 4J Stu - Make sure this is a good thread/core to use
m_threadCompleted = false;
threadStarted = false;
//ResumeThread( thread );
if( CXuiSceneBase::GetPlayerBasePosition(m_iPad) != CXuiSceneBase::e_BaseScene_Fullscreen && CXuiSceneBase::GetPlayerBasePosition(m_iPad) != CXuiSceneBase::e_BaseScene_NotSet)
{
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
CXuiSceneBase::ShowLogo( m_iPad, FALSE );
}
else
{
CXuiSceneBase::ShowLogo( m_iPad, params->completionData->bShowLogo );
}
m_threadCompleted = false;
threadStarted = false;
// ResumeThread( thread );
if (CXuiSceneBase::GetPlayerBasePosition(m_iPad) !=
CXuiSceneBase::e_BaseScene_Fullscreen &&
CXuiSceneBase::GetPlayerBasePosition(m_iPad) !=
CXuiSceneBase::e_BaseScene_NotSet) {
app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad, false);
CXuiSceneBase::ShowLogo(m_iPad, FALSE);
} else {
CXuiSceneBase::ShowLogo(m_iPad, params->completionData->bShowLogo);
}
CXuiSceneBase::ShowBackground( m_iPad, params->completionData->bShowBackground );
ui.SetTooltips( m_iPad, -1, params->cancelText, -1, -1 );
CXuiSceneBase::ShowBackground(m_iPad,
params->completionData->bShowBackground);
ui.SetTooltips(m_iPad, -1, params->cancelText, -1, -1);
// Clear the progress text
Minecraft *pMinecraft=Minecraft::GetInstance();
pMinecraft->progressRenderer->progressStart(-1);
pMinecraft->progressRenderer->progressStage(-1);
// Clear the progress text
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->progressRenderer->progressStart(-1);
pMinecraft->progressRenderer->progressStage(-1);
// set the tip
std::wstring wsText=app.FormatHTMLString(m_iPad,app.GetString(app.GetNextTip()));
wchar_t startTags[64];
swprintf(startTags,64,L"<font color=\"#%08x\" size=14><DIV ALIGN=CENTER>",app.GetHTMLColour(eHTMLColor_White));
wsText= startTags + wsText + L"</DIV>";
XuiControlSetText(m_tip, wsText.c_str());
// set the tip
std::wstring wsText =
app.FormatHTMLString(m_iPad, app.GetString(app.GetNextTip()));
wchar_t startTags[64];
swprintf(startTags, 64, L"<font color=\"#%08x\" size=14><DIV ALIGN=CENTER>",
app.GetHTMLColour(eHTMLColor_White));
wsText = startTags + wsText + L"</DIV>";
XuiControlSetText(m_tip, wsText.c_str());
m_tip.SetShow( m_CompletionData->bShowTips );
m_tip.SetShow(m_CompletionData->bShowTips);
return S_OK;
return S_OK;
}
// The framework calls this handler when the object is to be destroyed.
HRESULT CScene_FullscreenProgress::OnDestroy()
{
if( thread != NULL && thread != INVALID_HANDLE_VALUE )
delete thread;
// The framework calls this handler when the object is to be destroyed.
HRESULT CScene_FullscreenProgress::OnDestroy() {
if (thread != NULL && thread != INVALID_HANDLE_VALUE) delete thread;
if( m_CompletionData != NULL )
delete m_CompletionData;
if (m_CompletionData != NULL) delete m_CompletionData;
return S_OK;
return S_OK;
}
HRESULT CScene_FullscreenProgress::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_FullscreenProgress::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch(pInputData->dwKeyCode)
{
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_ESCAPE:
// 4J-JEV: Fix for Xbox360 #162749 - TU17: Save Upload: Content: UI:
// Player is presented with non-functional Tooltips after the Upload
// Save For Xbox One is completed.
if (m_cancelFunc != NULL && !m_threadCompleted) {
m_cancelFunc(m_cancelFuncParam);
m_bWasCancelled = true;
}
break;
}
case VK_PAD_B:
case VK_ESCAPE:
// 4J-JEV: Fix for Xbox360 #162749 - TU17: Save Upload: Content: UI: Player is presented with non-functional Tooltips after the Upload Save For Xbox One is completed.
if( m_cancelFunc != NULL && !m_threadCompleted )
{
m_cancelFunc( m_cancelFuncParam );
m_bWasCancelled=true;
}
break;
}
return S_OK;
return S_OK;
}
//----------------------------------------------------------------------------------
// Updates the UI when the list selection changes.
//----------------------------------------------------------------------------------
HRESULT CScene_FullscreenProgress::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled )
{
return S_OK;
HRESULT CScene_FullscreenProgress::OnNotifySelChanged(
HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled) {
return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_FullscreenProgress::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_FullscreenProgress::OnNotifyPressEx(
HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if(m_threadCompleted == true && hObjPressed == m_buttonConfirm)
{
// if there's a complete function, call it
if(m_completeFunc)
{
m_completeFunc(m_completeFuncParam);
}
switch(m_CompletionData->type)
{
case e_ProgressCompletion_NavigateBack:
CXuiSceneBase::ShowBackground( m_CompletionData->iPad, FALSE );
CXuiSceneBase::ShowBackground( m_CompletionData->iPad, TRUE );
app.NavigateBack(m_CompletionData->iPad);
// Show the other players scenes
CXuiSceneBase::ShowOtherPlayersBaseScene(m_CompletionData->iPad, true);
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_NavigateBackToScene:
CXuiSceneBase::ShowBackground( m_CompletionData->iPad, FALSE );
CXuiSceneBase::ShowBackground( m_CompletionData->iPad, TRUE );
CXuiSceneBase::ShowOtherPlayersBaseScene(m_CompletionData->iPad, true);
// If the pause menu is still active, then navigate back
// Otherwise close everything then navigate forwads to the pause menu
if(app.IsSceneInStack(m_CompletionData->iPad, m_CompletionData->scene))
{
app.NavigateBack(m_CompletionData->iPad,false, m_CompletionData->scene);
}
else
{
app.CloseXuiScenesAndNavigateToScene(m_CompletionData->iPad,m_CompletionData->scene);
}
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_CloseUIScenes:
app.CloseXuiScenes(m_CompletionData->iPad);
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_CloseAllPlayersUIScenes:
app.CloseAllPlayersXuiScenes();
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_NavigateToHomeMenu:
app.NavigateToHomeMenu();
ui.UpdatePlayerBasePositions();
break;
}
}
if (m_threadCompleted == true && hObjPressed == m_buttonConfirm) {
// if there's a complete function, call it
if (m_completeFunc) {
m_completeFunc(m_completeFuncParam);
}
switch (m_CompletionData->type) {
case e_ProgressCompletion_NavigateBack:
CXuiSceneBase::ShowBackground(m_CompletionData->iPad, FALSE);
CXuiSceneBase::ShowBackground(m_CompletionData->iPad, TRUE);
app.NavigateBack(m_CompletionData->iPad);
// Show the other players scenes
CXuiSceneBase::ShowOtherPlayersBaseScene(m_CompletionData->iPad,
true);
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_NavigateBackToScene:
CXuiSceneBase::ShowBackground(m_CompletionData->iPad, FALSE);
CXuiSceneBase::ShowBackground(m_CompletionData->iPad, TRUE);
CXuiSceneBase::ShowOtherPlayersBaseScene(m_CompletionData->iPad,
true);
// If the pause menu is still active, then navigate back
// Otherwise close everything then navigate forwads to the pause
// menu
if (app.IsSceneInStack(m_CompletionData->iPad,
m_CompletionData->scene)) {
app.NavigateBack(m_CompletionData->iPad, false,
m_CompletionData->scene);
} else {
app.CloseXuiScenesAndNavigateToScene(
m_CompletionData->iPad, m_CompletionData->scene);
}
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_CloseUIScenes:
app.CloseXuiScenes(m_CompletionData->iPad);
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_CloseAllPlayersUIScenes:
app.CloseAllPlayersXuiScenes();
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_NavigateToHomeMenu:
app.NavigateToHomeMenu();
ui.UpdatePlayerBasePositions();
break;
}
}
return S_OK;
return S_OK;
}
HRESULT CScene_FullscreenProgress::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled)
{
// This gets called every frame, so use it to update our two text boxes
Minecraft *pMinecraft=Minecraft::GetInstance();
HRESULT CScene_FullscreenProgress::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
// This gets called every frame, so use it to update our two text boxes
int title = pMinecraft->progressRenderer->getCurrentTitle();
if(title >= 0)
m_title.SetText( app.GetString( title ) );
else
m_title.SetText( L"" );
Minecraft* pMinecraft = Minecraft::GetInstance();
int status = pMinecraft->progressRenderer->getCurrentStatus();
if(status >= 0)
m_status.SetText( app.GetString( status ) );
else
m_status.SetText( L"" );
int title = pMinecraft->progressRenderer->getCurrentTitle();
if (title >= 0)
m_title.SetText(app.GetString(title));
else
m_title.SetText(L"");
return S_OK;
int status = pMinecraft->progressRenderer->getCurrentStatus();
if (status >= 0)
m_status.SetText(app.GetString(status));
else
m_status.SetText(L"");
return S_OK;
}
HRESULT CScene_FullscreenProgress::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled )
{
if(!threadStarted)
{
thread->Run();
threadStarted = true;
XuiSetTimer(m_hObj,TIMER_FULLSCREEN_PROGRESS,TIMER_FULLSCREEN_PROGRESS_TIME);
XuiSetTimer(m_hObj,TIMER_FULLSCREEN_TIPS,TIMER_FULLSCREEN_TIPS_TIME);
}
return S_OK;
HRESULT CScene_FullscreenProgress::OnTransitionStart(
XUIMessageTransition* pTransition, BOOL& bHandled) {
if (!threadStarted) {
thread->Run();
threadStarted = true;
XuiSetTimer(m_hObj, TIMER_FULLSCREEN_PROGRESS,
TIMER_FULLSCREEN_PROGRESS_TIME);
XuiSetTimer(m_hObj, TIMER_FULLSCREEN_TIPS, TIMER_FULLSCREEN_TIPS_TIME);
}
return S_OK;
}
HRESULT CScene_FullscreenProgress::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
{
int code = thread->GetExitCode();
DWORD exitcode = *((DWORD *)&code);
HRESULT CScene_FullscreenProgress::OnTimer(XUIMessageTimer* pTimer,
BOOL& bHandled) {
int code = thread->GetExitCode();
DWORD exitcode = *((DWORD*)&code);
//app.DebugPrintf("CScene_FullscreenProgress Timer %d\n",pTimer->nId);
// app.DebugPrintf("CScene_FullscreenProgress Timer %d\n",pTimer->nId);
if( exitcode != STILL_ACTIVE )
{
// 4J-PB - need to kill the timers whatever happens
XuiKillTimer(m_hObj,TIMER_FULLSCREEN_PROGRESS);
XuiKillTimer(m_hObj,TIMER_FULLSCREEN_TIPS);
XuiControlSetText(m_tip,L"");
if (exitcode != STILL_ACTIVE) {
// 4J-PB - need to kill the timers whatever happens
XuiKillTimer(m_hObj, TIMER_FULLSCREEN_PROGRESS);
XuiKillTimer(m_hObj, TIMER_FULLSCREEN_TIPS);
XuiControlSetText(m_tip, L"");
// hide the tips bar in cause we're waiting for the user to press ok
m_tip.SetShow( FALSE );
// hide the tips bar in cause we're waiting for the user to press ok
m_tip.SetShow(FALSE);
// If we failed (currently used by network connection thread), navigate back
if( exitcode != S_OK )
{
if( exitcode == ERROR_CANCELLED )
{
// Current thread cancelled for whatever reason
// Currently used only for the CConsoleMinecraftApp::RemoteSaveThreadProc thread
// Assume to just ignore this thread as something else is now running that will
// cause another action
}
else
{
/*m_threadCompleted = true;
m_buttonConfirm.SetShow( TRUE );
m_buttonConfirm.SetFocus( m_CompletionData->iPad );
m_CompletionData->type = e_ProgressCompletion_NavigateToHomeMenu;
// If we failed (currently used by network connection thread), navigate
// back
if (exitcode != S_OK) {
if (exitcode == ERROR_CANCELLED) {
// Current thread cancelled for whatever reason
// Currently used only for the
// CConsoleMinecraftApp::RemoteSaveThreadProc thread Assume to
// just ignore this thread as something else is now running that
// will cause another action
} else {
/*m_threadCompleted = true;
m_buttonConfirm.SetShow( TRUE );
m_buttonConfirm.SetFocus( m_CompletionData->iPad );
m_CompletionData->type =
e_ProgressCompletion_NavigateToHomeMenu;
int exitReasonStringId;
switch( app.GetDisconnectReason() )
{
default:
exitReasonStringId = IDS_CONNECTION_FAILED;
}
Minecraft *pMinecraft=Minecraft::GetInstance();
pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId );*/
//app.NavigateBack(m_CompletionData->iPad);
int exitReasonStringId;
switch( app.GetDisconnectReason() )
{
default:
exitReasonStringId = IDS_CONNECTION_FAILED;
}
Minecraft *pMinecraft=Minecraft::GetInstance();
pMinecraft->progressRenderer->progressStartNoAbort(
exitReasonStringId );*/
// app.NavigateBack(m_CompletionData->iPad);
unsigned int uiIDA[1];
uiIDA[0]=IDS_CONFIRM_OK;
StorageManager.RequestMessageBox( IDS_CONNECTION_FAILED, IDS_CONNECTION_LOST_SERVER, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable());
app.NavigateToHomeMenu();
ui.UpdatePlayerBasePositions();
}
}
else
{
if(( m_CompletionData->bRequiresUserAction == TRUE ) && (!m_bWasCancelled))
{
m_threadCompleted = true;
m_buttonConfirm.SetShow( TRUE );
m_buttonConfirm.SetFocus( ProfileManager.GetPrimaryPad() );
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT, -1, -1, -1 );
}
else
{
if(m_bWasCancelled)
{
m_threadCompleted = true;
}
app.DebugPrintf("FullScreenProgress complete with action: ");
switch(m_CompletionData->type)
{
case e_ProgressCompletion_AutosaveNavigateBack:
app.DebugPrintf("e_ProgressCompletion_AutosaveNavigateBack\n");
{
// store these - they get wiped by the destroy caused by navigateback
int iPad=m_CompletionData->iPad;
//bool bAutosaveWasMenuDisplayed=m_CompletionData->bAutosaveWasMenuDisplayed;
CXuiSceneBase::ShowBackground( iPad, FALSE );
CXuiSceneBase::ShowLogo(iPad, FALSE );
app.NavigateBack(iPad);
unsigned int uiIDA[1];
uiIDA[0] = IDS_CONFIRM_OK;
StorageManager.RequestMessageBox(
IDS_CONNECTION_FAILED, IDS_CONNECTION_LOST_SERVER, uiIDA, 1,
ProfileManager.GetPrimaryPad(), NULL, NULL,
app.GetStringTable());
// 4J Stu - Fix for #65437 - Customer Encountered: Code: Settings: Autosave option doesn't work when the Host goes into idle state during gameplay.
// Autosave obviously cannot occur if an ignore autosave menu is displayed, so even if we navigate back to a scene and not empty
// then we still want to reset this flag which was set true by the navigate to the fullscreen progress
app.SetIgnoreAutosaveMenuDisplayed(iPad, false);
app.NavigateToHomeMenu();
ui.UpdatePlayerBasePositions();
}
} else {
if ((m_CompletionData->bRequiresUserAction == TRUE) &&
(!m_bWasCancelled)) {
m_threadCompleted = true;
m_buttonConfirm.SetShow(TRUE);
m_buttonConfirm.SetFocus(ProfileManager.GetPrimaryPad());
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, -1, -1, -1);
} else {
if (m_bWasCancelled) {
m_threadCompleted = true;
}
app.DebugPrintf("FullScreenProgress complete with action: ");
switch (m_CompletionData->type) {
case e_ProgressCompletion_AutosaveNavigateBack:
app.DebugPrintf(
"e_ProgressCompletion_AutosaveNavigateBack\n");
{
// store these - they get wiped by the destroy
// caused by navigateback
int iPad = m_CompletionData->iPad;
// bool
// bAutosaveWasMenuDisplayed=m_CompletionData->bAutosaveWasMenuDisplayed;
CXuiSceneBase::ShowBackground(iPad, FALSE);
CXuiSceneBase::ShowLogo(iPad, FALSE);
app.NavigateBack(iPad);
// the navigate back leaves SetMenuDisplayed as true, but there may not have been a menu up when autosave was kicked off
// if(bAutosaveWasMenuDisplayed==false)
// {
// app.SetMenuDisplayed(iPad,false);
// }
// Show the other players scenes
CXuiSceneBase::ShowOtherPlayersBaseScene(iPad, true);
// This just allows it to be shown
Minecraft *pMinecraft = Minecraft::GetInstance();
if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(true);
ui.UpdatePlayerBasePositions();
}
break;
// 4J Stu - Fix for #65437 - Customer Encountered:
// Code: Settings: Autosave option doesn't work when
// the Host goes into idle state during gameplay.
// Autosave obviously cannot occur if an ignore
// autosave menu is displayed, so even if we
// navigate back to a scene and not empty then we
// still want to reset this flag which was set true
// by the navigate to the fullscreen progress
app.SetIgnoreAutosaveMenuDisplayed(iPad, false);
// the navigate back leaves SetMenuDisplayed as
// true, but there may not have been a menu up when
// autosave was kicked off
// if(bAutosaveWasMenuDisplayed==false)
// {
// app.SetMenuDisplayed(iPad,false);
// }
// Show the other players scenes
CXuiSceneBase::ShowOtherPlayersBaseScene(iPad,
true);
// This just allows it to be shown
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft->localgameModes
[ProfileManager.GetPrimaryPad()] != NULL)
pMinecraft
->localgameModes[ProfileManager
.GetPrimaryPad()]
->getTutorial()
->showTutorialPopup(true);
ui.UpdatePlayerBasePositions();
}
break;
case e_ProgressCompletion_NavigateBack:
app.DebugPrintf("e_ProgressCompletion_NavigateBack\n");
{
// store these - they get wiped by the destroy
// caused by navigateback
int iPad = m_CompletionData->iPad;
CXuiSceneBase::ShowBackground(iPad, FALSE);
CXuiSceneBase::ShowBackground(iPad, TRUE);
app.NavigateBack(iPad);
// Show the other players scenes
CXuiSceneBase::ShowOtherPlayersBaseScene(iPad,
true);
ui.UpdatePlayerBasePositions();
}
break;
case e_ProgressCompletion_NavigateBackToScene:
app.DebugPrintf(
"e_ProgressCompletion_NavigateBackToScene\n");
CXuiSceneBase::ShowBackground(m_CompletionData->iPad,
FALSE);
CXuiSceneBase::ShowBackground(m_CompletionData->iPad,
TRUE);
CXuiSceneBase::ShowOtherPlayersBaseScene(
m_CompletionData->iPad, true);
// If the pause menu is still active, then navigate back
// Otherwise close everything then navigate forwads to
// the pause menu
if (app.IsSceneInStack(m_CompletionData->iPad,
m_CompletionData->scene)) {
app.NavigateBack(m_CompletionData->iPad, false,
m_CompletionData->scene);
} else {
app.CloseXuiScenesAndNavigateToScene(
m_CompletionData->iPad,
m_CompletionData->scene);
}
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_CloseUIScenes:
app.DebugPrintf("e_ProgressCompletion_CloseUIScenes\n");
app.CloseXuiScenes(m_CompletionData->iPad);
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_CloseAllPlayersUIScenes:
app.DebugPrintf(
"e_ProgressCompletion_CloseAllPlayersUIScenes\n");
app.CloseAllPlayersXuiScenes();
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_NavigateToHomeMenu:
app.DebugPrintf(
"e_ProgressCompletion_NavigateToHomeMenu\n");
app.NavigateToHomeMenu();
// ui.UpdatePlayerBasePositions();
break;
default:
app.DebugPrintf("Default\n");
break;
}
}
}
} else {
switch (pTimer->nId) {
case TIMER_FULLSCREEN_PROGRESS:
break;
case TIMER_FULLSCREEN_TIPS: {
// display the next tip
std::wstring wsText = app.FormatHTMLString(
m_iPad, app.GetString(app.GetNextTip()));
wchar_t startTags[64];
swprintf(startTags, 64,
L"<font color=\"#%08x\" size=14><DIV ALIGN=CENTER>",
app.GetHTMLColour(eHTMLColor_White));
wsText = startTags + wsText + L"</DIV>";
XuiControlSetText(m_tip, wsText.c_str());
} break;
}
}
case e_ProgressCompletion_NavigateBack:
app.DebugPrintf("e_ProgressCompletion_NavigateBack\n");
{
// store these - they get wiped by the destroy caused by navigateback
int iPad=m_CompletionData->iPad;
CXuiSceneBase::ShowBackground( iPad, FALSE );
CXuiSceneBase::ShowBackground( iPad, TRUE );
app.NavigateBack(iPad);
// Show the other players scenes
CXuiSceneBase::ShowOtherPlayersBaseScene(iPad, true);
ui.UpdatePlayerBasePositions();
}
break;
case e_ProgressCompletion_NavigateBackToScene:
app.DebugPrintf("e_ProgressCompletion_NavigateBackToScene\n");
CXuiSceneBase::ShowBackground( m_CompletionData->iPad, FALSE );
CXuiSceneBase::ShowBackground( m_CompletionData->iPad, TRUE );
CXuiSceneBase::ShowOtherPlayersBaseScene(m_CompletionData->iPad, true);
// If the pause menu is still active, then navigate back
// Otherwise close everything then navigate forwads to the pause menu
if(app.IsSceneInStack(m_CompletionData->iPad, m_CompletionData->scene))
{
app.NavigateBack(m_CompletionData->iPad,false, m_CompletionData->scene);
}
else
{
app.CloseXuiScenesAndNavigateToScene(m_CompletionData->iPad,m_CompletionData->scene);
}
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_CloseUIScenes:
app.DebugPrintf("e_ProgressCompletion_CloseUIScenes\n");
app.CloseXuiScenes(m_CompletionData->iPad);
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_CloseAllPlayersUIScenes:
app.DebugPrintf("e_ProgressCompletion_CloseAllPlayersUIScenes\n");
app.CloseAllPlayersXuiScenes();
ui.UpdatePlayerBasePositions();
break;
case e_ProgressCompletion_NavigateToHomeMenu:
app.DebugPrintf("e_ProgressCompletion_NavigateToHomeMenu\n");
app.NavigateToHomeMenu();
//ui.UpdatePlayerBasePositions();
break;
default:
app.DebugPrintf("Default\n");
break;
}
}
}
}
else
{
switch(pTimer->nId)
{
case TIMER_FULLSCREEN_PROGRESS:
break;
case TIMER_FULLSCREEN_TIPS:
{
// display the next tip
std::wstring wsText=app.FormatHTMLString(m_iPad,app.GetString(app.GetNextTip()));
wchar_t startTags[64];
swprintf(startTags,64,L"<font color=\"#%08x\" size=14><DIV ALIGN=CENTER>",app.GetHTMLColour(eHTMLColor_White));
wsText= startTags + wsText + L"</DIV>";
XuiControlSetText(m_tip,wsText.c_str());
}
break;
}
}
bHandled = TRUE;
return( S_OK );
return (S_OK);
}

View File

@@ -1,68 +1,72 @@
#pragma once
#pragma once
#include "../media/xuiscene_fullscreenprogress.h"
#include "../../Minecraft.World/Util/C4JThread.h"
#define ERROR_FULLSCREENPROGRESS_
class CScene_FullscreenProgress : public CXuiSceneImpl
{
class CScene_FullscreenProgress : public CXuiSceneImpl {
private:
C4JThread* thread;
bool threadStarted;
UIFullscreenProgressCompletionData *m_CompletionData;
C4JThread* thread;
bool threadStarted;
UIFullscreenProgressCompletionData* m_CompletionData;
static const int TIMER_FULLSCREEN_PROGRESS = 0;
static const int TIMER_FULLSCREEN_TIPS = 1;
static const int TIMER_FULLSCREEN_PROGRESS = 0;
static const int TIMER_FULLSCREEN_TIPS = 1;
static const int TIMER_FULLSCREEN_PROGRESS_TIME = 500;
static const int TIMER_FULLSCREEN_TIPS_TIME = 7000;
static const int TIMER_FULLSCREEN_PROGRESS_TIME = 500;
static const int TIMER_FULLSCREEN_TIPS_TIME = 7000;
protected:
// Control and Element wrapper objects.
CXuiControl m_title, m_status, m_buttonConfirm, m_tip;
// Control and Element wrapper objects.
CXuiControl m_title, m_status, m_buttonConfirm, m_tip;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY( OnDestroy )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_TRANSITION_START( OnTransitionStart )
XUI_ON_XM_TIMER( OnTimer )
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_ON_XM_TIMER(OnTimer)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Title, m_title)
MAP_CONTROL(IDC_Tip, m_tip)
MAP_CONTROL(IDC_Status, m_status)
MAP_CONTROL(IDC_ButtonConfirm, m_buttonConfirm)
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Title, m_title)
MAP_CONTROL(IDC_Tip, m_tip)
MAP_CONTROL(IDC_Status, m_status)
MAP_CONTROL(IDC_ButtonConfirm, m_buttonConfirm)
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnTransitionStart(XUIMessageTransition* pTransition,
BOOL& bHandled);
HRESULT OnTimer(XUIMessageTimer* pTimer, BOOL& bHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled );
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_FullscreenProgress, L"CScene_FullscreenProgress", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_FullscreenProgress, L"CScene_FullscreenProgress",
XUI_CLASS_SCENE)
private:
bool m_threadCompleted;
int m_iPad;
void (*m_cancelFunc)(LPVOID param);
void (*m_completeFunc)(LPVOID param);
LPVOID m_cancelFuncParam;
LPVOID m_completeFuncParam;
D3DXVECTOR3 m_OriginalPosition;
bool m_bWasCancelled;
bool m_threadCompleted;
int m_iPad;
void (*m_cancelFunc)(LPVOID param);
void (*m_completeFunc)(LPVOID param);
LPVOID m_cancelFuncParam;
LPVOID m_completeFuncParam;
D3DXVECTOR3 m_OriginalPosition;
bool m_bWasCancelled;
};

View File

@@ -8,457 +8,420 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.effect.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.material.h"
HRESULT CXuiSceneHud::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *(int *)pInitData->pvInitData;
HRESULT CXuiSceneHud::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
m_iPad = *(int*)pInitData->pvInitData;
MapChildControls();
MapChildControls();
XuiElementGetPosition(m_hObj,&m_OriginalPosition);
m_tickCount = 0;
XuiElementGetPosition(m_hObj, &m_OriginalPosition);
return S_OK;
m_tickCount = 0;
return S_OK;
}
HRESULT CXuiSceneHud::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
app.ReloadHudScene(m_iPad, bJoining);
HRESULT CXuiSceneHud::OnCustomMessage_Splitscreenplayer(bool bJoining,
BOOL& bHandled) {
bHandled = true;
return S_OK;
app.ReloadHudScene(m_iPad, bJoining);
return S_OK;
}
HRESULT CXuiSceneHud::OnCustomMessage_TickScene()
{
Minecraft *pMinecraft = Minecraft::GetInstance();
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return S_OK;
HRESULT CXuiSceneHud::OnCustomMessage_TickScene() {
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft->localplayers[m_iPad] == NULL ||
pMinecraft->localgameModes[m_iPad] == NULL)
return S_OK;
++m_tickCount;
++m_tickCount;
int iGuiScale;
int iGuiScale;
if(pMinecraft->localplayers[m_iPad]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN)
{
iGuiScale=app.GetGameSettings(m_iPad,eGameSetting_UISize);
}
else
{
iGuiScale=app.GetGameSettings(m_iPad,eGameSetting_UISizeSplitscreen);
}
if (pMinecraft->localplayers[m_iPad]->m_iScreenSection ==
C4JRender::VIEWPORT_TYPE_FULLSCREEN) {
iGuiScale = app.GetGameSettings(m_iPad, eGameSetting_UISize);
} else {
iGuiScale = app.GetGameSettings(m_iPad, eGameSetting_UISizeSplitscreen);
}
int startFrame = 0;
switch(iGuiScale)
{
case 0:
XuiElementFindNamedFrame(m_hObj, L"ScaleSmall", &startFrame);
break;
case 1:
XuiElementFindNamedFrame(m_hObj, L"Normal", &startFrame);
break;
case 2:
XuiElementFindNamedFrame(m_hObj, L"ScaleLarge", &startFrame);
break;
}
if(startFrame >= 0) XuiElementPlayTimeline( m_hObj, startFrame, startFrame, startFrame, FALSE, TRUE);
int startFrame = 0;
switch (iGuiScale) {
case 0:
XuiElementFindNamedFrame(m_hObj, L"ScaleSmall", &startFrame);
break;
case 1:
XuiElementFindNamedFrame(m_hObj, L"Normal", &startFrame);
break;
case 2:
XuiElementFindNamedFrame(m_hObj, L"ScaleLarge", &startFrame);
break;
}
if (startFrame >= 0)
XuiElementPlayTimeline(m_hObj, startFrame, startFrame, startFrame,
FALSE, TRUE);
// Move the whole hud group if we are not in fullscreen
if(pMinecraft->localplayers[m_iPad]->m_iScreenSection != C4JRender::VIEWPORT_TYPE_FULLSCREEN)
{
int iTooltipsYOffset = 0;
// if tooltips are off, set the y offset to zero
if(app.GetGameSettings(m_iPad,eGameSetting_Tooltips)==0)
{
switch(iGuiScale)
{
case 0:
iTooltipsYOffset=28;//screenHeight/10;
break;
case 2:
iTooltipsYOffset=28;//screenHeight/10;
break;
case 1:
default:
iTooltipsYOffset=28;//screenHeight/10;
break;
}
}
// Move the whole hud group if we are not in fullscreen
if (pMinecraft->localplayers[m_iPad]->m_iScreenSection !=
C4JRender::VIEWPORT_TYPE_FULLSCREEN) {
int iTooltipsYOffset = 0;
// if tooltips are off, set the y offset to zero
if (app.GetGameSettings(m_iPad, eGameSetting_Tooltips) == 0) {
switch (iGuiScale) {
case 0:
iTooltipsYOffset = 28; // screenHeight/10;
break;
case 2:
iTooltipsYOffset = 28; // screenHeight/10;
break;
case 1:
default:
iTooltipsYOffset = 28; // screenHeight/10;
break;
}
}
float fHeight, fWidth;
GetBounds(&fWidth, &fHeight);
float fHeight, fWidth;
GetBounds(&fWidth, &fHeight);
int iSafezoneYHalf = 0;
switch(pMinecraft->localplayers[m_iPad]->m_iScreenSection)
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
iSafezoneYHalf = -fHeight/10;// 5% (need to treat the whole screen is 2x this screen)
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
iSafezoneYHalf = (fHeight/2)-(fHeight/10);// 5% (need to treat the whole screen is 2x this screen)
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
iSafezoneYHalf = (fHeight/2)-(fHeight/10);// 5% (need to treat the whole screen is 2x this screen)
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
iSafezoneYHalf = -fHeight/10; // 5% (the whole screen is 2x this screen)
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
iSafezoneYHalf = -fHeight/10; // 5% (the whole screen is 2x this screen)
break;
};
int iSafezoneYHalf = 0;
switch (pMinecraft->localplayers[m_iPad]->m_iScreenSection) {
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
iSafezoneYHalf = -fHeight / 10; // 5% (need to treat the whole
// screen is 2x this screen)
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
iSafezoneYHalf = (fHeight / 2) -
(fHeight / 10); // 5% (need to treat the whole
// screen is 2x this screen)
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
iSafezoneYHalf = (fHeight / 2) -
(fHeight / 10); // 5% (need to treat the whole
// screen is 2x this screen)
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
iSafezoneYHalf =
-fHeight / 10; // 5% (the whole screen is 2x this screen)
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
iSafezoneYHalf =
-fHeight / 10; // 5% (the whole screen is 2x this screen)
break;
};
D3DXVECTOR3 pos;
m_hudGroup.GetPosition(&pos);
pos.y = iTooltipsYOffset + iSafezoneYHalf;
m_hudGroup.SetPosition(&pos);
}
D3DXVECTOR3 pos;
m_hudGroup.GetPosition(&pos);
pos.y = iTooltipsYOffset + iSafezoneYHalf;
m_hudGroup.SetPosition(&pos);
}
// Update inventory
float opacity = 1.0f;
GetOpacity(&opacity);
int selected = pMinecraft->localplayers[m_iPad]->inventory->selected;
for(unsigned int j = 0; j < 9; ++j)
{
m_hotbarIcon[j]->SetSlot(m_hotbarIcon[j]->m_hObj,pMinecraft->localplayers[m_iPad]->inventoryMenu->getSlot(InventoryMenu::USE_ROW_SLOT_START + j));
m_hotbarIcon[j]->SetUserIndex(m_hotbarIcon[j]->m_hObj, m_iPad );
// Update inventory
float opacity = 1.0f;
GetOpacity(&opacity);
int selected = pMinecraft->localplayers[m_iPad]->inventory->selected;
for (unsigned int j = 0; j < 9; ++j) {
m_hotbarIcon[j]->SetSlot(
m_hotbarIcon[j]->m_hObj,
pMinecraft->localplayers[m_iPad]->inventoryMenu->getSlot(
InventoryMenu::USE_ROW_SLOT_START + j));
m_hotbarIcon[j]->SetUserIndex(m_hotbarIcon[j]->m_hObj, m_iPad);
if(j == selected)
{
m_hotbarIcon[j]->SetEnable(FALSE); //Makes the selected overlay display
}
else
{
m_hotbarIcon[j]->SetEnable(TRUE); //Hides the selected overlay display
}
if (j == selected) {
m_hotbarIcon[j]->SetEnable(
FALSE); // Makes the selected overlay display
} else {
m_hotbarIcon[j]->SetEnable(
TRUE); // Hides the selected overlay display
}
m_hotbarIcon[j]->SetAlpha( m_hotbarIcon[j]->m_hObj, opacity );
}
m_hotbarIcon[j]->SetAlpha(m_hotbarIcon[j]->m_hObj, opacity);
}
// Update xp progress
if (pMinecraft->localgameModes[m_iPad]->canHurtPlayer())
{
int xpNeededForNextLevel = pMinecraft->localplayers[m_iPad]->getXpNeededForNextLevel();
int progress = (int)(pMinecraft->localplayers[m_iPad]->experienceProgress *xpNeededForNextLevel);
// Update xp progress
if (pMinecraft->localgameModes[m_iPad]->canHurtPlayer()) {
int xpNeededForNextLevel =
pMinecraft->localplayers[m_iPad]->getXpNeededForNextLevel();
int progress =
(int)(pMinecraft->localplayers[m_iPad]->experienceProgress *
xpNeededForNextLevel);
m_ExperienceProgress.SetShow(TRUE);
m_ExperienceProgress.SetRange(0,xpNeededForNextLevel);
m_ExperienceProgress.SetValue(progress);
}
else
{
m_ExperienceProgress.SetShow(FALSE);
}
m_ExperienceProgress.SetShow(TRUE);
m_ExperienceProgress.SetRange(0, xpNeededForNextLevel);
m_ExperienceProgress.SetValue(progress);
} else {
m_ExperienceProgress.SetShow(FALSE);
}
// Update xp level
if (pMinecraft->localgameModes[m_iPad]->hasExperience() && pMinecraft->localplayers[m_iPad]->experienceLevel > 0)
{
m_xpLevel.SetShow(TRUE);
// Update xp level
if (pMinecraft->localgameModes[m_iPad]->hasExperience() &&
pMinecraft->localplayers[m_iPad]->experienceLevel > 0) {
m_xpLevel.SetShow(TRUE);
wchar_t formatted[10];
swprintf(formatted, 10, L"%d",pMinecraft->localplayers[m_iPad]->experienceLevel);
wchar_t formatted[10];
swprintf(formatted, 10, L"%d",
pMinecraft->localplayers[m_iPad]->experienceLevel);
m_xpLevel.SetText(formatted);
}
else
{
m_xpLevel.SetShow(FALSE);
}
m_xpLevel.SetText(formatted);
} else {
m_xpLevel.SetShow(FALSE);
}
if (pMinecraft->localgameModes[m_iPad]->canHurtPlayer())
{
m_random.setSeed(m_tickCount * 312871);
if (pMinecraft->localgameModes[m_iPad]->canHurtPlayer()) {
m_random.setSeed(m_tickCount * 312871);
// Update health
int heartOffsetIndex = -1;
if (pMinecraft->localplayers[m_iPad]->hasEffect(MobEffect::regeneration))
{
heartOffsetIndex = m_tickCount % 25;
}
// Update health
int heartOffsetIndex = -1;
if (pMinecraft->localplayers[m_iPad]->hasEffect(
MobEffect::regeneration)) {
heartOffsetIndex = m_tickCount % 25;
}
bool blink = pMinecraft->localplayers[m_iPad]->invulnerableTime / 3 % 2 == 1;
if (pMinecraft->localplayers[m_iPad]->invulnerableTime < 10) blink = false;
int iHealth = pMinecraft->localplayers[m_iPad]->getHealth();
int iLastHealth = pMinecraft->localplayers[m_iPad]->lastHealth;
bool bHasPoison = pMinecraft->localplayers[m_iPad]->hasEffect(MobEffect::poison);
for (int icon = 0; icon < Player::MAX_HEALTH / 2; icon++)
{
if(blink)
{
if (icon * 2 + 1 < iLastHealth || icon * 2 + 1 < iHealth)
{
// Full
if(bHasPoison)
{
m_healthIcon[icon].PlayVisualRange(L"FullPoisonFlash",NULL,L"FullPoisonFlash");
}
else
{
m_healthIcon[icon].PlayVisualRange(L"FullFlash",NULL,L"FullFlash");
}
}
else if (icon * 2 + 1 == iLastHealth || icon * 2 + 1 == iHealth)
{
// Half
if(bHasPoison)
{
m_healthIcon[icon].PlayVisualRange(L"HalfPoisonFlash",NULL,L"HalfPoisonFlash");
}
else
{
m_healthIcon[icon].PlayVisualRange(L"HalfFlash",NULL,L"HalfFlash");
}
}
else
{
// Empty
m_healthIcon[icon].PlayVisualRange(L"NormalFlash",NULL,L"NormalFlash");
}
}
else
{
if (icon * 2 + 1 < iHealth)
{
// Full
if(bHasPoison)
{
m_healthIcon[icon].PlayVisualRange(L"FullPoison",NULL,L"FullPoison");
}
else
{
m_healthIcon[icon].PlayVisualRange(L"Full",NULL,L"Full");
}
}
else if (icon * 2 + 1 == iHealth)
{
// Half
if(bHasPoison)
{
m_healthIcon[icon].PlayVisualRange(L"HalfPoison",NULL,L"HalfPoison");
}
else
{
m_healthIcon[icon].PlayVisualRange(L"Half",NULL,L"Half");
}
}
else
{
// Empty
m_healthIcon[icon].PlayVisualRange(L"Normal",NULL,L"Normal");
}
}
bool blink =
pMinecraft->localplayers[m_iPad]->invulnerableTime / 3 % 2 == 1;
if (pMinecraft->localplayers[m_iPad]->invulnerableTime < 10)
blink = false;
int iHealth = pMinecraft->localplayers[m_iPad]->getHealth();
int iLastHealth = pMinecraft->localplayers[m_iPad]->lastHealth;
bool bHasPoison =
pMinecraft->localplayers[m_iPad]->hasEffect(MobEffect::poison);
for (int icon = 0; icon < Player::MAX_HEALTH / 2; icon++) {
if (blink) {
if (icon * 2 + 1 < iLastHealth || icon * 2 + 1 < iHealth) {
// Full
if (bHasPoison) {
m_healthIcon[icon].PlayVisualRange(
L"FullPoisonFlash", NULL, L"FullPoisonFlash");
} else {
m_healthIcon[icon].PlayVisualRange(L"FullFlash", NULL,
L"FullFlash");
}
} else if (icon * 2 + 1 == iLastHealth ||
icon * 2 + 1 == iHealth) {
// Half
if (bHasPoison) {
m_healthIcon[icon].PlayVisualRange(
L"HalfPoisonFlash", NULL, L"HalfPoisonFlash");
} else {
m_healthIcon[icon].PlayVisualRange(L"HalfFlash", NULL,
L"HalfFlash");
}
} else {
// Empty
m_healthIcon[icon].PlayVisualRange(L"NormalFlash", NULL,
L"NormalFlash");
}
} else {
if (icon * 2 + 1 < iHealth) {
// Full
if (bHasPoison) {
m_healthIcon[icon].PlayVisualRange(L"FullPoison", NULL,
L"FullPoison");
} else {
m_healthIcon[icon].PlayVisualRange(L"Full", NULL,
L"Full");
}
} else if (icon * 2 + 1 == iHealth) {
// Half
if (bHasPoison) {
m_healthIcon[icon].PlayVisualRange(L"HalfPoison", NULL,
L"HalfPoison");
} else {
m_healthIcon[icon].PlayVisualRange(L"Half", NULL,
L"Half");
}
} else {
// Empty
m_healthIcon[icon].PlayVisualRange(L"Normal", NULL,
L"Normal");
}
}
float yo = 0;
if (iHealth <= 4)
{
yo = (float)m_random.nextInt(2) * (iGuiScale+1);
}
if (icon == heartOffsetIndex)
{
yo = -2.0f * (iGuiScale+1);
}
float yo = 0;
if (iHealth <= 4) {
yo = (float)m_random.nextInt(2) * (iGuiScale + 1);
}
if (icon == heartOffsetIndex) {
yo = -2.0f * (iGuiScale + 1);
}
D3DXVECTOR3 pos;
m_healthIcon[icon].GetPosition(&pos);
// TODO - 4J Stu - This should be scaled based on gui scale and overall size (ie full, split or 480)
pos.y = yo;
m_healthIcon[icon].SetPosition(&pos);
D3DXVECTOR3 pos;
m_healthIcon[icon].GetPosition(&pos);
// TODO - 4J Stu - This should be scaled based on gui scale and
// overall size (ie full, split or 480)
pos.y = yo;
m_healthIcon[icon].SetPosition(&pos);
}
}
// Update food
bool foodBlink = false;
FoodData* foodData = pMinecraft->localplayers[m_iPad]->getFoodData();
int food = foodData->getFoodLevel();
int oldFood = foodData->getLastFoodLevel();
bool hasHungerEffect =
pMinecraft->localplayers[m_iPad]->hasEffect(MobEffect::hunger);
int saturationLevel = pMinecraft->localplayers[m_iPad]
->getFoodData()
->getSaturationLevel();
for (int icon = 0; icon < 10; icon++) {
if (foodBlink) {
if (icon * 2 + 1 < oldFood || icon * 2 + 1 < food) {
// Full
if (hasHungerEffect) {
m_foodIcon[icon].PlayVisualRange(
L"FullPoisonFlash", NULL, L"FullPoisonFlash");
} else {
m_foodIcon[icon].PlayVisualRange(L"FullFlash", NULL,
L"FullFlash");
}
} else if (icon * 2 + 1 == oldFood || icon * 2 + 1 == food) {
// Half
if (hasHungerEffect) {
m_foodIcon[icon].PlayVisualRange(
L"HalfPoisonFlash", NULL, L"HalfPoisonFlash");
} else {
m_foodIcon[icon].PlayVisualRange(L"HalfFlash", NULL,
L"HalfFlash");
}
} else {
// Empty
m_foodIcon[icon].PlayVisualRange(L"NormalFlash", NULL,
L"NormalFlash");
}
} else {
if (icon * 2 + 1 < food) {
// Full
if (hasHungerEffect) {
m_foodIcon[icon].PlayVisualRange(L"FullPoison", NULL,
L"FullPoison");
} else {
m_foodIcon[icon].PlayVisualRange(L"Full", NULL,
L"Full");
}
} else if (icon * 2 + 1 == food) {
// Half
if (hasHungerEffect) {
m_foodIcon[icon].PlayVisualRange(L"HalfPoison", NULL,
L"HalfPoison");
} else {
m_foodIcon[icon].PlayVisualRange(L"Half", NULL,
L"Half");
}
} else {
// Empty
if (hasHungerEffect) {
m_foodIcon[icon].PlayVisualRange(L"NormalPoison", NULL,
L"NormalPoison");
} else {
m_foodIcon[icon].PlayVisualRange(L"Normal", NULL,
L"Normal");
}
}
}
// Update food
bool foodBlink = false;
FoodData *foodData = pMinecraft->localplayers[m_iPad]->getFoodData();
int food = foodData->getFoodLevel();
int oldFood = foodData->getLastFoodLevel();
bool hasHungerEffect = pMinecraft->localplayers[m_iPad]->hasEffect(MobEffect::hunger);
int saturationLevel = pMinecraft->localplayers[m_iPad]->getFoodData()->getSaturationLevel();
for (int icon = 0; icon < 10; icon++)
{
if(foodBlink)
{
if (icon * 2 + 1 < oldFood || icon * 2 + 1 < food)
{
// Full
if(hasHungerEffect)
{
m_foodIcon[icon].PlayVisualRange(L"FullPoisonFlash",NULL,L"FullPoisonFlash");
}
else
{
m_foodIcon[icon].PlayVisualRange(L"FullFlash",NULL,L"FullFlash");
}
}
else if (icon * 2 + 1 == oldFood || icon * 2 + 1 == food)
{
// Half
if(hasHungerEffect)
{
m_foodIcon[icon].PlayVisualRange(L"HalfPoisonFlash",NULL,L"HalfPoisonFlash");
}
else
{
m_foodIcon[icon].PlayVisualRange(L"HalfFlash",NULL,L"HalfFlash");
}
}
else
{
// Empty
m_foodIcon[icon].PlayVisualRange(L"NormalFlash",NULL,L"NormalFlash");
}
}
else
{
if (icon * 2 + 1 < food)
{
// Full
if(hasHungerEffect)
{
m_foodIcon[icon].PlayVisualRange(L"FullPoison",NULL,L"FullPoison");
}
else
{
m_foodIcon[icon].PlayVisualRange(L"Full",NULL,L"Full");
}
}
else if (icon * 2 + 1 == food)
{
// Half
if(hasHungerEffect)
{
m_foodIcon[icon].PlayVisualRange(L"HalfPoison",NULL,L"HalfPoison");
}
else
{
m_foodIcon[icon].PlayVisualRange(L"Half",NULL,L"Half");
}
}
else
{
// Empty
if(hasHungerEffect)
{
m_foodIcon[icon].PlayVisualRange(L"NormalPoison",NULL,L"NormalPoison");
}
else
{
m_foodIcon[icon].PlayVisualRange(L"Normal",NULL,L"Normal");
}
}
}
float yo = 0;
if (saturationLevel <= 0) {
if ((m_tickCount % (food * 3 + 1)) == 0) {
yo = (float)(m_random.nextInt(3) - 1) * (iGuiScale + 1);
}
}
float yo = 0;
if (saturationLevel <= 0)
{
if ((m_tickCount % (food * 3 + 1)) == 0)
{
yo = (float)(m_random.nextInt(3) - 1) * (iGuiScale+1);
}
}
D3DXVECTOR3 pos;
m_foodIcon[icon].GetPosition(&pos);
// TODO - 4J Stu - This should be scaled based on gui scale and
// overall size (ie full, split or 480)
pos.y = yo;
m_foodIcon[icon].SetPosition(&pos);
}
D3DXVECTOR3 pos;
m_foodIcon[icon].GetPosition(&pos);
// TODO - 4J Stu - This should be scaled based on gui scale and overall size (ie full, split or 480)
pos.y = yo;
m_foodIcon[icon].SetPosition(&pos);
}
// Update armour
int armor = pMinecraft->localplayers[m_iPad]->getArmorValue();
if (armor > 0) {
m_armourGroup.SetShow(TRUE);
for (int icon = 0; icon < 10; icon++) {
if (icon * 2 + 1 < armor)
m_armourIcon[icon].PlayVisualRange(L"Full", NULL, L"Full");
else if (icon * 2 + 1 == armor)
m_armourIcon[icon].PlayVisualRange(L"Half", NULL, L"Half");
else if (icon * 2 + 1 > armor)
m_armourIcon[icon].PlayVisualRange(L"Normal", NULL,
L"Normal");
}
} else {
m_armourGroup.SetShow(FALSE);
}
// Update armour
int armor = pMinecraft->localplayers[m_iPad]->getArmorValue();
if(armor > 0)
{
m_armourGroup.SetShow(TRUE);
for (int icon = 0; icon < 10; icon++)
{
if (icon * 2 + 1 < armor) m_armourIcon[icon].PlayVisualRange(L"Full",NULL,L"Full");
else if (icon * 2 + 1 == armor) m_armourIcon[icon].PlayVisualRange(L"Half",NULL,L"Half");
else if (icon * 2 + 1 > armor) m_armourIcon[icon].PlayVisualRange(L"Normal",NULL,L"Normal");
}
}
else
{
m_armourGroup.SetShow(FALSE);
}
// Update air
if (pMinecraft->localplayers[m_iPad]->isUnderLiquid(Material::water))
{
m_airGroup.SetShow(TRUE);
int count = (int) ceil((pMinecraft->localplayers[m_iPad]->getAirSupply() - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY);
int extra = (int) ceil((pMinecraft->localplayers[m_iPad]->getAirSupply()) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count;
for (int icon = 0; icon < 10; icon++)
{
// Air bubbles
if (icon < count)
{
m_airIcon[icon].SetShow(TRUE);
m_airIcon[icon].PlayVisualRange(L"Bubble",NULL,L"Bubble");
}
else if(icon < count + extra)
{
m_airIcon[icon].SetShow(TRUE);
m_airIcon[icon].PlayVisualRange(L"Pop",NULL,L"Pop");
}
else m_airIcon[icon].SetShow(FALSE);
}
}
else
{
m_airGroup.SetShow(FALSE);
}
}
else
{
m_healthGroup.SetShow(FALSE);
m_foodGroup.SetShow(FALSE);
m_armourGroup.SetShow(FALSE);
m_airGroup.SetShow(FALSE);
}
return S_OK;
// Update air
if (pMinecraft->localplayers[m_iPad]->isUnderLiquid(Material::water)) {
m_airGroup.SetShow(TRUE);
int count = (int)ceil(
(pMinecraft->localplayers[m_iPad]->getAirSupply() - 2) * 10.0f /
Player::TOTAL_AIR_SUPPLY);
int extra =
(int)ceil((pMinecraft->localplayers[m_iPad]->getAirSupply()) *
10.0f / Player::TOTAL_AIR_SUPPLY) -
count;
for (int icon = 0; icon < 10; icon++) {
// Air bubbles
if (icon < count) {
m_airIcon[icon].SetShow(TRUE);
m_airIcon[icon].PlayVisualRange(L"Bubble", NULL, L"Bubble");
} else if (icon < count + extra) {
m_airIcon[icon].SetShow(TRUE);
m_airIcon[icon].PlayVisualRange(L"Pop", NULL, L"Pop");
} else
m_airIcon[icon].SetShow(FALSE);
}
} else {
m_airGroup.SetShow(FALSE);
}
} else {
m_healthGroup.SetShow(FALSE);
m_foodGroup.SetShow(FALSE);
m_armourGroup.SetShow(FALSE);
m_airGroup.SetShow(FALSE);
}
return S_OK;
}
HRESULT CXuiSceneHud::OnCustomMessage_DLCInstalled()
{
// mounted DLC may have changed
bool bPauseMenuDisplayed=false;
bool bInGame=(Minecraft::GetInstance()->level!=NULL);
// ignore this if we have menus up - they'll deal with it
for(int i=0;i<XUSER_MAX_COUNT;i++)
{
if(app.IsPauseMenuDisplayed(i))
{
bPauseMenuDisplayed=true;
break;
}
}
HRESULT CXuiSceneHud::OnCustomMessage_DLCInstalled() {
// mounted DLC may have changed
bool bPauseMenuDisplayed = false;
bool bInGame = (Minecraft::GetInstance()->level != NULL);
// ignore this if we have menus up - they'll deal with it
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
if (app.IsPauseMenuDisplayed(i)) {
bPauseMenuDisplayed = true;
break;
}
}
if(bInGame && !bPauseMenuDisplayed)
{
app.StartInstallDLCProcess(ProfileManager.GetPrimaryPad());
}
if (bInGame && !bPauseMenuDisplayed) {
app.StartInstallDLCProcess(ProfileManager.GetPrimaryPad());
}
// this will send a CustomMessage_DLCMountingComplete when done
return S_OK;
// this will send a CustomMessage_DLCMountingComplete when done
return S_OK;
}
HRESULT CXuiSceneHud::OnCustomMessage_DLCMountingComplete() {
// A join from invite may have installed the trial pack during the game.
// Need to switch to the texture pack if it's not being used yet, and turn
// off background downloads
HRESULT CXuiSceneHud::OnCustomMessage_DLCMountingComplete()
{
// A join from invite may have installed the trial pack during the game.
// Need to switch to the texture pack if it's not being used yet, and turn off background downloads
// what texture pack are we using?
// TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
// if(tPack->getDLCParentPackId()!=app.GetRequiredTexturePackID())
// {
// app.DebugPrintf("DLC install finished, and the game is using a texture pack that isn't the required one\n");
// }
return S_OK;
// what texture pack are we using?
// TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
// if(tPack->getDLCParentPackId()!=app.GetRequiredTexturePackID())
// {
// app.DebugPrintf("DLC install finished, and the game is using a
// texture pack that isn't the required one\n");
// }
return S_OK;
}

View File

@@ -4,126 +4,129 @@
#define CHAT_LINES_COUNT 10
class CXuiSceneHud : public CXuiSceneImpl
{
private:
Random m_random;
int m_tickCount;
class CXuiSceneHud : public CXuiSceneImpl {
private:
Random m_random;
int m_tickCount;
protected:
CXuiControl m_hudHolder; // Contains the HUD group to enable moving all elements together
CXuiControl m_hudGroup; // Contains all the HUD elements except crosshair, in a group that scales
CXuiControl m_hudScaleGroup; // Contains all the HUD elements except crosshair
CXuiControl m_hotbarGroup;
CXuiCtrlSlotItem *m_hotbarIcon[9];
CXuiProgressBar m_ExperienceProgress;
CXuiControl m_healthGroup;
CXuiControl m_healthIcon[10];
CXuiControl m_armourGroup;
CXuiControl m_armourIcon[10];
CXuiControl m_foodGroup;
CXuiControl m_foodIcon[10];
CXuiControl m_airGroup;
CXuiControl m_airIcon[10];
CXuiControl m_xpLevel;
D3DXVECTOR3 m_OriginalPosition;
int m_iPad;
CXuiControl m_hudHolder; // Contains the HUD group to enable moving all
// elements together
CXuiControl m_hudGroup; // Contains all the HUD elements except crosshair,
// in a group that scales
CXuiControl
m_hudScaleGroup; // Contains all the HUD elements except crosshair
CXuiControl m_hotbarGroup;
CXuiCtrlSlotItem* m_hotbarIcon[9];
CXuiProgressBar m_ExperienceProgress;
CXuiControl m_healthGroup;
CXuiControl m_healthIcon[10];
CXuiControl m_armourGroup;
CXuiControl m_armourIcon[10];
CXuiControl m_foodGroup;
CXuiControl m_foodIcon[10];
CXuiControl m_airGroup;
CXuiControl m_airIcon[10];
CXuiControl m_xpLevel;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_ON_XM_CUSTOMTICKSCENE_MESSAGE(OnCustomMessage_TickScene)
XUI_ON_XM_DLCINSTALLED_MESSAGE(OnCustomMessage_DLCInstalled)
XUI_ON_XM_DLCLOADED_MESSAGE(OnCustomMessage_DLCMountingComplete)
XUI_END_MSG_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_HudHolder, m_hudHolder)
BEGIN_MAP_CHILD_CONTROLS(m_hudHolder)
MAP_CONTROL(IDC_HudGroup, m_hudGroup)
BEGIN_MAP_CHILD_CONTROLS(m_hudGroup)
MAP_CONTROL(IDC_HudScaleGroup, m_hudScaleGroup)
BEGIN_MAP_CHILD_CONTROLS(m_hudScaleGroup)
MAP_CONTROL(IDC_Hotbar, m_hotbarGroup)
BEGIN_MAP_CHILD_CONTROLS(m_hotbarGroup)
MAP_OVERRIDE(IDC_Inventory1, m_hotbarIcon[0])
MAP_OVERRIDE(IDC_Inventory2, m_hotbarIcon[1])
MAP_OVERRIDE(IDC_Inventory3, m_hotbarIcon[2])
MAP_OVERRIDE(IDC_Inventory4, m_hotbarIcon[3])
MAP_OVERRIDE(IDC_Inventory5, m_hotbarIcon[4])
MAP_OVERRIDE(IDC_Inventory6, m_hotbarIcon[5])
MAP_OVERRIDE(IDC_Inventory7, m_hotbarIcon[6])
MAP_OVERRIDE(IDC_Inventory8, m_hotbarIcon[7])
MAP_OVERRIDE(IDC_Inventory9, m_hotbarIcon[8])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_ExperienceProgress, m_ExperienceProgress)
MAP_CONTROL(IDC_Health, m_healthGroup)
BEGIN_MAP_CHILD_CONTROLS(m_healthGroup)
MAP_CONTROL(IDC_Health0, m_healthIcon[0])
MAP_CONTROL(IDC_Health1, m_healthIcon[1])
MAP_CONTROL(IDC_Health2, m_healthIcon[2])
MAP_CONTROL(IDC_Health3, m_healthIcon[3])
MAP_CONTROL(IDC_Health4, m_healthIcon[4])
MAP_CONTROL(IDC_Health5, m_healthIcon[5])
MAP_CONTROL(IDC_Health6, m_healthIcon[6])
MAP_CONTROL(IDC_Health7, m_healthIcon[7])
MAP_CONTROL(IDC_Health8, m_healthIcon[8])
MAP_CONTROL(IDC_Health9, m_healthIcon[9])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_Armour, m_armourGroup)
BEGIN_MAP_CHILD_CONTROLS(m_armourGroup)
MAP_CONTROL(IDC_Armour0, m_armourIcon[0])
MAP_CONTROL(IDC_Armour1, m_armourIcon[1])
MAP_CONTROL(IDC_Armour2, m_armourIcon[2])
MAP_CONTROL(IDC_Armour3, m_armourIcon[3])
MAP_CONTROL(IDC_Armour4, m_armourIcon[4])
MAP_CONTROL(IDC_Armour5, m_armourIcon[5])
MAP_CONTROL(IDC_Armour6, m_armourIcon[6])
MAP_CONTROL(IDC_Armour7, m_armourIcon[7])
MAP_CONTROL(IDC_Armour8, m_armourIcon[8])
MAP_CONTROL(IDC_Armour9, m_armourIcon[9])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_Food, m_foodGroup)
BEGIN_MAP_CHILD_CONTROLS(m_foodGroup)
MAP_CONTROL(IDC_Food0, m_foodIcon[0])
MAP_CONTROL(IDC_Food1, m_foodIcon[1])
MAP_CONTROL(IDC_Food2, m_foodIcon[2])
MAP_CONTROL(IDC_Food3, m_foodIcon[3])
MAP_CONTROL(IDC_Food4, m_foodIcon[4])
MAP_CONTROL(IDC_Food5, m_foodIcon[5])
MAP_CONTROL(IDC_Food6, m_foodIcon[6])
MAP_CONTROL(IDC_Food7, m_foodIcon[7])
MAP_CONTROL(IDC_Food8, m_foodIcon[8])
MAP_CONTROL(IDC_Food9, m_foodIcon[9])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_Air, m_airGroup)
BEGIN_MAP_CHILD_CONTROLS(m_airGroup)
MAP_CONTROL(IDC_Air0, m_airIcon[0])
MAP_CONTROL(IDC_Air1, m_airIcon[1])
MAP_CONTROL(IDC_Air2, m_airIcon[2])
MAP_CONTROL(IDC_Air3, m_airIcon[3])
MAP_CONTROL(IDC_Air4, m_airIcon[4])
MAP_CONTROL(IDC_Air5, m_airIcon[5])
MAP_CONTROL(IDC_Air6, m_airIcon[6])
MAP_CONTROL(IDC_Air7, m_airIcon[7])
MAP_CONTROL(IDC_Air8, m_airIcon[8])
MAP_CONTROL(IDC_Air9, m_airIcon[9])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_XPLevel, m_xpLevel)
END_MAP_CHILD_CONTROLS()
END_MAP_CHILD_CONTROLS()
END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
D3DXVECTOR3 m_OriginalPosition;
int m_iPad;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_ON_XM_CUSTOMTICKSCENE_MESSAGE(OnCustomMessage_TickScene)
XUI_ON_XM_DLCINSTALLED_MESSAGE(OnCustomMessage_DLCInstalled)
XUI_ON_XM_DLCLOADED_MESSAGE(OnCustomMessage_DLCMountingComplete)
XUI_END_MSG_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_HudHolder, m_hudHolder)
BEGIN_MAP_CHILD_CONTROLS(m_hudHolder)
MAP_CONTROL(IDC_HudGroup, m_hudGroup)
BEGIN_MAP_CHILD_CONTROLS(m_hudGroup)
MAP_CONTROL(IDC_HudScaleGroup, m_hudScaleGroup)
BEGIN_MAP_CHILD_CONTROLS(m_hudScaleGroup)
MAP_CONTROL(IDC_Hotbar, m_hotbarGroup)
BEGIN_MAP_CHILD_CONTROLS(m_hotbarGroup)
MAP_OVERRIDE(IDC_Inventory1, m_hotbarIcon[0])
MAP_OVERRIDE(IDC_Inventory2, m_hotbarIcon[1])
MAP_OVERRIDE(IDC_Inventory3, m_hotbarIcon[2])
MAP_OVERRIDE(IDC_Inventory4, m_hotbarIcon[3])
MAP_OVERRIDE(IDC_Inventory5, m_hotbarIcon[4])
MAP_OVERRIDE(IDC_Inventory6, m_hotbarIcon[5])
MAP_OVERRIDE(IDC_Inventory7, m_hotbarIcon[6])
MAP_OVERRIDE(IDC_Inventory8, m_hotbarIcon[7])
MAP_OVERRIDE(IDC_Inventory9, m_hotbarIcon[8])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_ExperienceProgress, m_ExperienceProgress)
MAP_CONTROL(IDC_Health, m_healthGroup)
BEGIN_MAP_CHILD_CONTROLS(m_healthGroup)
MAP_CONTROL(IDC_Health0, m_healthIcon[0])
MAP_CONTROL(IDC_Health1, m_healthIcon[1])
MAP_CONTROL(IDC_Health2, m_healthIcon[2])
MAP_CONTROL(IDC_Health3, m_healthIcon[3])
MAP_CONTROL(IDC_Health4, m_healthIcon[4])
MAP_CONTROL(IDC_Health5, m_healthIcon[5])
MAP_CONTROL(IDC_Health6, m_healthIcon[6])
MAP_CONTROL(IDC_Health7, m_healthIcon[7])
MAP_CONTROL(IDC_Health8, m_healthIcon[8])
MAP_CONTROL(IDC_Health9, m_healthIcon[9])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_Armour, m_armourGroup)
BEGIN_MAP_CHILD_CONTROLS(m_armourGroup)
MAP_CONTROL(IDC_Armour0, m_armourIcon[0])
MAP_CONTROL(IDC_Armour1, m_armourIcon[1])
MAP_CONTROL(IDC_Armour2, m_armourIcon[2])
MAP_CONTROL(IDC_Armour3, m_armourIcon[3])
MAP_CONTROL(IDC_Armour4, m_armourIcon[4])
MAP_CONTROL(IDC_Armour5, m_armourIcon[5])
MAP_CONTROL(IDC_Armour6, m_armourIcon[6])
MAP_CONTROL(IDC_Armour7, m_armourIcon[7])
MAP_CONTROL(IDC_Armour8, m_armourIcon[8])
MAP_CONTROL(IDC_Armour9, m_armourIcon[9])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_Food, m_foodGroup)
BEGIN_MAP_CHILD_CONTROLS(m_foodGroup)
MAP_CONTROL(IDC_Food0, m_foodIcon[0])
MAP_CONTROL(IDC_Food1, m_foodIcon[1])
MAP_CONTROL(IDC_Food2, m_foodIcon[2])
MAP_CONTROL(IDC_Food3, m_foodIcon[3])
MAP_CONTROL(IDC_Food4, m_foodIcon[4])
MAP_CONTROL(IDC_Food5, m_foodIcon[5])
MAP_CONTROL(IDC_Food6, m_foodIcon[6])
MAP_CONTROL(IDC_Food7, m_foodIcon[7])
MAP_CONTROL(IDC_Food8, m_foodIcon[8])
MAP_CONTROL(IDC_Food9, m_foodIcon[9])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_Air, m_airGroup)
BEGIN_MAP_CHILD_CONTROLS(m_airGroup)
MAP_CONTROL(IDC_Air0, m_airIcon[0])
MAP_CONTROL(IDC_Air1, m_airIcon[1])
MAP_CONTROL(IDC_Air2, m_airIcon[2])
MAP_CONTROL(IDC_Air3, m_airIcon[3])
MAP_CONTROL(IDC_Air4, m_airIcon[4])
MAP_CONTROL(IDC_Air5, m_airIcon[5])
MAP_CONTROL(IDC_Air6, m_airIcon[6])
MAP_CONTROL(IDC_Air7, m_airIcon[7])
MAP_CONTROL(IDC_Air8, m_airIcon[8])
MAP_CONTROL(IDC_Air9, m_airIcon[9])
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_XPLevel, m_xpLevel)
END_MAP_CHILD_CONTROLS()
END_MAP_CHILD_CONTROLS()
END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnCustomMessage_TickScene();
HRESULT OnCustomMessage_DLCInstalled();
HRESULT OnCustomMessage_DLCMountingComplete();
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnCustomMessage_TickScene();
HRESULT OnCustomMessage_DLCInstalled();
HRESULT OnCustomMessage_DLCMountingComplete();
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CXuiSceneHud, L"CXuiSceneHud", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CXuiSceneHud, L"CXuiSceneHud", XUI_CLASS_SCENE)
};

View File

@@ -6,457 +6,459 @@
#include <assert.h>
#include "XUI_HelpAndOptions.h"
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_HelpAndOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *(int *)pInitData->pvInitData;
bool bNotInGame=(Minecraft::GetInstance()->level==NULL);
HRESULT CScene_HelpAndOptions::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
m_iPad = *(int*)pInitData->pvInitData;
bool bNotInGame = (Minecraft::GetInstance()->level == NULL);
MapChildControls();
XuiControlSetText(m_Buttons[BUTTON_HAO_CHANGESKIN],app.GetString(IDS_CHANGE_SKIN));
XuiControlSetText(m_Buttons[BUTTON_HAO_HOWTOPLAY],app.GetString(IDS_HOW_TO_PLAY));
XuiControlSetText(m_Buttons[BUTTON_HAO_CONTROLS],app.GetString(IDS_CONTROLS));
XuiControlSetText(m_Buttons[BUTTON_HAO_SETTINGS],app.GetString(IDS_SETTINGS));
XuiControlSetText(m_Buttons[BUTTON_HAO_CREDITS],app.GetString(IDS_CREDITS));
XuiControlSetText(m_Buttons[BUTTON_HAO_REINSTALL],app.GetString(IDS_REINSTALL_CONTENT));
XuiControlSetText(m_Buttons[BUTTON_HAO_DEBUG],app.GetString(IDS_DEBUG_SETTINGS));
MapChildControls();
XuiControlSetText(m_Buttons[BUTTON_HAO_CHANGESKIN],
app.GetString(IDS_CHANGE_SKIN));
XuiControlSetText(m_Buttons[BUTTON_HAO_HOWTOPLAY],
app.GetString(IDS_HOW_TO_PLAY));
XuiControlSetText(m_Buttons[BUTTON_HAO_CONTROLS],
app.GetString(IDS_CONTROLS));
XuiControlSetText(m_Buttons[BUTTON_HAO_SETTINGS],
app.GetString(IDS_SETTINGS));
XuiControlSetText(m_Buttons[BUTTON_HAO_CREDITS],
app.GetString(IDS_CREDITS));
XuiControlSetText(m_Buttons[BUTTON_HAO_REINSTALL],
app.GetString(IDS_REINSTALL_CONTENT));
XuiControlSetText(m_Buttons[BUTTON_HAO_DEBUG],
app.GetString(IDS_DEBUG_SETTINGS));
//if(app.GetTMSDLCInfoRead())
{
m_Timer.SetShow(FALSE);
m_bIgnoreInput=false;
// if(app.GetTMSDLCInfoRead())
{
m_Timer.SetShow(FALSE);
m_bIgnoreInput = false;
#ifndef _FINAL_BUILD
if(!app.DebugSettingsOn())
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE);
}
else
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(TRUE);
#ifndef _FINAL_BUILD
if (!app.DebugSettingsOn()) {
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE);
} else {
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(TRUE);
}
#endif
}
#endif
// 4J-PB - do not need a storage device to see this menu - just need one
// when you choose to re-install them
// 4J-PB - do not need a storage device to see this menu - just need one when you choose to re-install them
// any content to be re-installed?
if (m_iPad == ProfileManager.GetPrimaryPad() && bNotInGame) {
// We should show the reinstall menu
app.DebugPrintf("Reinstall Menu required...\n");
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE);
} else {
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE);
}
// any content to be re-installed?
if(m_iPad==ProfileManager.GetPrimaryPad() && bNotInGame)
{
// We should show the reinstall menu
app.DebugPrintf("Reinstall Menu required...\n");
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE);
}
else
{
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE);
}
if (app.GetLocalPlayerCount() > 1) {
// no credits in splitscreen
D3DXVECTOR3 vec;
if(app.GetLocalPlayerCount()>1)
{
// no credits in splitscreen
D3DXVECTOR3 vec;
m_Buttons[BUTTON_HAO_CREDITS].GetPosition(&vec);
m_Buttons[BUTTON_HAO_CREDITS].GetPosition(&vec);
m_Buttons[BUTTON_HAO_CREDITS].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_CREDITS].SetShow(FALSE);
m_Buttons[BUTTON_HAO_CREDITS].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_CREDITS].SetShow(FALSE);
m_Buttons[BUTTON_HAO_REINSTALL].SetPosition(&vec);
m_Buttons[BUTTON_HAO_REINSTALL].SetPosition(&vec);
app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad,
false);
CXuiSceneBase::ShowLogo(m_iPad, FALSE);
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
CXuiSceneBase::ShowLogo( m_iPad, FALSE );
if (ProfileManager.GetPrimaryPad() != m_iPad) {
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE);
}
} else {
if (bNotInGame) {
CXuiSceneBase::ShowLogo(DEFAULT_XUI_MENU_USER, TRUE);
} else {
CXuiSceneBase::ShowLogo(m_iPad, TRUE);
}
}
// Display the tooltips
if(ProfileManager.GetPrimaryPad()!=m_iPad)
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE);
}
}
else
{
if(bNotInGame)
{
CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE );
}
else
{
CXuiSceneBase::ShowLogo( m_iPad, TRUE );
}
}
// Display the tooltips
// if we're not in the game, we need to use basescene 0
if (bNotInGame) {
ui.SetTooltips(DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,
IDS_TOOLTIPS_BACK);
} else {
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK);
}
// if we're not in the game, we need to use basescene 0
if(bNotInGame)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
else
{
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
if (!ProfileManager
.IsFullVersion()) //|| ProfileManager.IsGuest(m_iPad))
{
// disable save button
m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_CHANGESKIN].EnableInput(FALSE);
// set the focus to the second button
if(!ProfileManager.IsFullVersion() )//|| ProfileManager.IsGuest(m_iPad))
{
// disable save button
m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_CHANGESKIN].EnableInput(FALSE);
// set the focus to the second button
XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_HOWTOPLAY].m_hObj,
m_iPad);
}
}
/*else
{
m_bIgnoreInput=true;
m_Timer.SetShow(TRUE);
XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_HOWTOPLAY].m_hObj, m_iPad);
}
}
/*else
{
m_bIgnoreInput=true;
m_Timer.SetShow(TRUE);
// hide all the buttons
for(int i=0;i<BUTTONS_HAO_MAX;i++)
{
m_Buttons[i].SetEnable(FALSE);
m_Buttons[i].SetShow(FALSE);
}
// hide all the buttons
for(int i=0;i<BUTTONS_HAO_MAX;i++)
{
m_Buttons[i].SetEnable(FALSE);
m_Buttons[i].SetShow(FALSE);
}
if(bNotInGame)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, -1,-1);
}
else
{
ui.SetTooltips( m_iPad, -1,-1);
}
}*/
return S_OK;
if(bNotInGame)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, -1,-1);
}
else
{
ui.SetTooltips( m_iPad, -1,-1);
}
}*/
return S_OK;
}
/*HRESULT CScene_HelpAndOptions::OnTMSDLCFileRetrieved( )
{
bool bNotInGame=(Minecraft::GetInstance()->level==NULL);
m_Timer.SetShow(FALSE);
m_bIgnoreInput=false;
bool bNotInGame=(Minecraft::GetInstance()->level==NULL);
m_Timer.SetShow(FALSE);
m_bIgnoreInput=false;
// show all the buttons - except the debug settings and reinstall content
m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_CHANGESKIN].SetShow(TRUE);
m_Buttons[BUTTON_HAO_HOWTOPLAY].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_HOWTOPLAY].SetShow(TRUE);
m_Buttons[BUTTON_HAO_CONTROLS].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_CONTROLS].SetShow(TRUE);
m_Buttons[BUTTON_HAO_SETTINGS].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_SETTINGS].SetShow(TRUE);
m_Buttons[BUTTON_HAO_CREDITS].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_CREDITS].SetShow(TRUE);
// show all the buttons - except the debug settings and reinstall
content m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_CHANGESKIN].SetShow(TRUE);
m_Buttons[BUTTON_HAO_HOWTOPLAY].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_HOWTOPLAY].SetShow(TRUE);
m_Buttons[BUTTON_HAO_CONTROLS].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_CONTROLS].SetShow(TRUE);
m_Buttons[BUTTON_HAO_SETTINGS].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_SETTINGS].SetShow(TRUE);
m_Buttons[BUTTON_HAO_CREDITS].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_CREDITS].SetShow(TRUE);
#ifndef _FINAL_BUILD
if(!app.DebugSettingsOn())
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE);
}
else
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(TRUE);
if(!app.DebugSettingsOn())
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE);
}
else
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(TRUE);
}
}
#endif
// 4J-PB - do not need a storage device to see this menu - just need one when you choose to re-install them
// 4J-PB - do not need a storage device to see this menu - just need one
when you choose to re-install them
// any content to be re-installed?
if(m_iPad==ProfileManager.GetPrimaryPad() && bNotInGame)
{
// We should show the reinstall menu
app.DebugPrintf("Reinstall Menu required...\n");
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE);
}
else
{
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE);
}
// any content to be re-installed?
if(m_iPad==ProfileManager.GetPrimaryPad() && bNotInGame)
{
// We should show the reinstall menu
app.DebugPrintf("Reinstall Menu required...\n");
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE);
}
else
{
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE);
}
if(app.GetLocalPlayerCount()>1)
{
// no credits in splitscreen
D3DXVECTOR3 vec;
if(app.GetLocalPlayerCount()>1)
{
// no credits in splitscreen
D3DXVECTOR3 vec;
m_Buttons[BUTTON_HAO_CREDITS].GetPosition(&vec);
m_Buttons[BUTTON_HAO_CREDITS].GetPosition(&vec);
m_Buttons[BUTTON_HAO_CREDITS].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_CREDITS].SetShow(FALSE);
m_Buttons[BUTTON_HAO_CREDITS].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_CREDITS].SetShow(FALSE);
m_Buttons[BUTTON_HAO_REINSTALL].SetPosition(&vec);
m_Buttons[BUTTON_HAO_REINSTALL].SetPosition(&vec);
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
CXuiSceneBase::ShowLogo( m_iPad, FALSE );
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad,false);
CXuiSceneBase::ShowLogo( m_iPad, FALSE );
if(ProfileManager.GetPrimaryPad()!=m_iPad)
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE);
}
}
else
{
if(bNotInGame)
{
CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE );
}
else
{
CXuiSceneBase::ShowLogo( m_iPad, TRUE );
}
}
// Display the tooltips
if(ProfileManager.GetPrimaryPad()!=m_iPad)
{
m_Buttons[BUTTON_HAO_DEBUG].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_DEBUG].SetShow(FALSE);
}
}
else
{
if(bNotInGame)
{
CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE );
}
else
{
CXuiSceneBase::ShowLogo( m_iPad, TRUE );
}
}
// Display the tooltips
// if we're not in the game, we need to use basescene 0
if(bNotInGame)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
else
{
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
// if we're not in the game, we need to use basescene 0
if(bNotInGame)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER,
IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
else
{
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
if(!ProfileManager.IsFullVersion() )//|| ProfileManager.IsGuest(m_iPad))
{
// disable save button
m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_CHANGESKIN].EnableInput(FALSE);
// set the focus to the second button
if(!ProfileManager.IsFullVersion() )//|| ProfileManager.IsGuest(m_iPad))
{
// disable save button
m_Buttons[BUTTON_HAO_CHANGESKIN].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_CHANGESKIN].EnableInput(FALSE);
// set the focus to the second button
XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_HOWTOPLAY].m_hObj, m_iPad);
}
else
{
XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_CHANGESKIN].m_hObj, m_iPad);
}
return S_OK;
XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_HOWTOPLAY].m_hObj,
m_iPad);
}
else
{
XuiElementSetUserFocus(m_Buttons[BUTTON_HAO_CHANGESKIN].m_hObj,
m_iPad);
}
return S_OK;
}*/
HRESULT CScene_HelpAndOptions::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled)
{
pControlNavigateData->hObjDest=XuiControlGetNavigation(pControlNavigateData->hObjSource,pControlNavigateData->nControlNavigate,TRUE,TRUE);
HRESULT CScene_HelpAndOptions::OnControlNavigate(
XUIMessageControlNavigate* pControlNavigateData, BOOL& bHandled) {
pControlNavigateData->hObjDest = XuiControlGetNavigation(
pControlNavigateData->hObjSource,
pControlNavigateData->nControlNavigate, TRUE, TRUE);
if(pControlNavigateData->hObjDest!=NULL)
{
bHandled=TRUE;
}
if (pControlNavigateData->hObjDest != NULL) {
bHandled = TRUE;
}
return S_OK;
return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_HelpAndOptions::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_HelpAndOptions::OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData,
BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
unsigned int uiButtonCounter=0;
unsigned int uiButtonCounter = 0;
while((uiButtonCounter<BUTTONS_HAO_MAX) && (m_Buttons[uiButtonCounter]!=hObjPressed)) uiButtonCounter++;
while ((uiButtonCounter < BUTTONS_HAO_MAX) &&
(m_Buttons[uiButtonCounter] != hObjPressed))
uiButtonCounter++;
// Determine which button was pressed,
// and call the appropriate function.
// Determine which button was pressed,
// and call the appropriate function.
switch(uiButtonCounter)
{
case BUTTON_HAO_HOWTOPLAY:
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_HowToPlayMenu);
break;
case BUTTON_HAO_CONTROLS:
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_ControlsMenu);
break;
case BUTTON_HAO_SETTINGS:
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SettingsMenu);
break;
case BUTTON_HAO_CHANGESKIN:
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_SkinSelectMenu);
break;
case BUTTON_HAO_CREDITS:
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_Credits);
break;
switch (uiButtonCounter) {
case BUTTON_HAO_HOWTOPLAY:
app.NavigateToScene(pNotifyPressData->UserIndex,
eUIScene_HowToPlayMenu);
break;
case BUTTON_HAO_CONTROLS:
app.NavigateToScene(pNotifyPressData->UserIndex,
eUIScene_ControlsMenu);
break;
case BUTTON_HAO_SETTINGS:
app.NavigateToScene(pNotifyPressData->UserIndex,
eUIScene_SettingsMenu);
break;
case BUTTON_HAO_CHANGESKIN:
app.NavigateToScene(pNotifyPressData->UserIndex,
eUIScene_SkinSelectMenu);
break;
case BUTTON_HAO_CREDITS:
app.NavigateToScene(pNotifyPressData->UserIndex, eUIScene_Credits);
break;
case BUTTON_HAO_REINSTALL:
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_ReinstallMenu);
break;
case BUTTON_HAO_REINSTALL:
app.NavigateToScene(pNotifyPressData->UserIndex,
eUIScene_ReinstallMenu);
break;
case BUTTON_HAO_DEBUG:
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_DebugOptions);
break;
case BUTTON_HAO_DEBUG:
app.NavigateToScene(pNotifyPressData->UserIndex,
eUIScene_DebugOptions);
break;
default:
break;
}
return S_OK;
default:
break;
}
return S_OK;
}
HRESULT CScene_HelpAndOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
if(m_bIgnoreInput) return S_OK;
HRESULT CScene_HelpAndOptions::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
if (m_bIgnoreInput) return S_OK;
// ignore a held down key to avoid skipping this scene if the user changes a setting and presses B for slightly too long
if((pInputData->dwFlags&XUI_INPUT_FLAG_REPEAT)&&(pInputData->dwKeyCode==VK_PAD_B))
{
return S_OK;
}
// ignore a held down key to avoid skipping this scene if the user changes a
// setting and presses B for slightly too long
if ((pInputData->dwFlags & XUI_INPUT_FLAG_REPEAT) &&
(pInputData->dwKeyCode == VK_PAD_B)) {
return S_OK;
}
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch(pInputData->dwKeyCode)
{
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_ESCAPE:
int userIndex = pInputData->UserIndex;
if (!app.IsPauseMenuDisplayed(userIndex)) {
// If we are not from a pause menu, then we are from the main
// menu
userIndex = XUSER_INDEX_ANY;
}
case VK_PAD_B:
case VK_ESCAPE:
int userIndex = pInputData->UserIndex;
if( !app.IsPauseMenuDisplayed(userIndex) )
{
// If we are not from a pause menu, then we are from the main menu
userIndex = XUSER_INDEX_ANY;
}
app.NavigateBack(userIndex);
rfHandled = TRUE;
app.NavigateBack(userIndex);
rfHandled = TRUE;
break;
}
break;
}
return S_OK;
return S_OK;
}
HRESULT CScene_HelpAndOptions::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled)
{
bool bNotInGame=(Minecraft::GetInstance()->level==NULL);
HRESULT CScene_HelpAndOptions::OnNavReturn(HXUIOBJ hObj, BOOL& rfHandled) {
bool bNotInGame = (Minecraft::GetInstance()->level == NULL);
if(bNotInGame)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE );
if (bNotInGame) {
ui.SetTooltips(DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,
IDS_TOOLTIPS_BACK);
CXuiSceneBase::ShowLogo(DEFAULT_XUI_MENU_USER, TRUE);
if(m_iPad==ProfileManager.GetPrimaryPad() )//&&
// StorageManager.GetSaveDeviceSelected(m_iPad) &&
// !StorageManager.GetSaveDisabled() &&
// ( ProfileManager.IsAwardsFlagSet(m_iPad,eAward_mine100Blocks) ||
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_kill10Creepers) ||
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_eatPorkChop) ||
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_play100Days) ||
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_arrowKillCreeper) ||
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_socialPost)) )
{
// We should show the reinstall menu
app.DebugPrintf("Reinstall Menu required...\n");
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE);
}
else
{
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE);
}
if (m_iPad ==
ProfileManager
.GetPrimaryPad()) //&&
// StorageManager.GetSaveDeviceSelected(m_iPad)
//&&
// !StorageManager.GetSaveDisabled() &&
// (
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_mine100Blocks) ||
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_kill10Creepers)
// || ProfileManager.IsAwardsFlagSet(m_iPad,eAward_eatPorkChop) ||
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_play100Days)
// || ProfileManager.IsAwardsFlagSet(m_iPad,eAward_arrowKillCreeper) ||
// ProfileManager.IsAwardsFlagSet(m_iPad,eAward_socialPost))
// )
{
// We should show the reinstall menu
app.DebugPrintf("Reinstall Menu required...\n");
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(TRUE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(TRUE);
} else {
m_Buttons[BUTTON_HAO_REINSTALL].SetEnable(FALSE);
m_Buttons[BUTTON_HAO_REINSTALL].SetShow(FALSE);
}
}
else
{
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
if(app.GetLocalPlayerCount()>1)
{
CXuiSceneBase::ShowLogo( m_iPad, FALSE );
}
else
{
CXuiSceneBase::ShowLogo( m_iPad, TRUE );
}
}
} else {
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK);
if (app.GetLocalPlayerCount() > 1) {
CXuiSceneBase::ShowLogo(m_iPad, FALSE);
} else {
CXuiSceneBase::ShowLogo(m_iPad, TRUE);
}
}
return S_OK;
return S_OK;
}
// int CScene_HelpAndOptions::ResetDefaultsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
// int CScene_HelpAndOptions::ResetDefaultsDialogReturned(void *pParam,int
// iPad,C4JStorage::EMessageResult result)
// {
// CScene_HelpAndOptions* pClass = (CScene_HelpAndOptions*)pParam;
//
//
// // results switched for this dialog
// if(result==C4JStorage::EMessage_ResultDecline)
// if(result==C4JStorage::EMessage_ResultDecline)
// {
// app.SetDefaultOptions(ProfileManager.GetDashboardProfileSettings(pClass->m_iPad),pClass->m_iPad);
// // if the profile data has been changed, then force a profile write
// // It seems we're allowed to break the 5 minute rule if it's the result of a user action
// app.CheckGameSettingsChanged(true,iPad);
// // if the profile data has been changed, then force a profile
// write
// // It seems we're allowed to break the 5 minute rule if it's the
// result of a user action app.CheckGameSettingsChanged(true,iPad);
// }
// return 0;
// }
HRESULT CScene_HelpAndOptions::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled )
{
if(pTransition->dwTransAction==XUI_TRANSITION_ACTION_DESTROY ) return S_OK;
HRESULT CScene_HelpAndOptions::OnTransitionStart(
XUIMessageTransition* pTransition, BOOL& bHandled) {
if (pTransition->dwTransAction == XUI_TRANSITION_ACTION_DESTROY)
return S_OK;
if(pTransition->dwTransType == XUI_TRANSITION_TO || pTransition->dwTransType == XUI_TRANSITION_BACKTO)
{
if (pTransition->dwTransType == XUI_TRANSITION_TO ||
pTransition->dwTransType == XUI_TRANSITION_BACKTO) {
// 4J-PB - Going to resize buttons if the text is too big to fit on any
// of them (Br-pt problem with the length of Unlock Full Game)
XUIRect xuiRect;
HXUIOBJ visual = NULL;
HXUIOBJ text;
float fMaxTextLen = 0.0f;
float fTextVisualLen;
float fMaxButton;
float fWidth, fHeight;
// 4J-PB - Going to resize buttons if the text is too big to fit on any of them (Br-pt problem with the length of Unlock Full Game)
XUIRect xuiRect;
HXUIOBJ visual=NULL;
HXUIOBJ text;
float fMaxTextLen=0.0f;
float fTextVisualLen;
float fMaxButton;
float fWidth,fHeight;
HRESULT hr = XuiControlGetVisual(m_Buttons[0].m_hObj, &visual);
hr = XuiElementGetChildById(visual, L"text_Label", &text);
hr = XuiElementGetBounds(text, &fTextVisualLen, &fHeight);
m_Buttons[0].GetBounds(&fMaxButton, &fHeight);
HRESULT hr=XuiControlGetVisual(m_Buttons[0].m_hObj,&visual);
hr=XuiElementGetChildById(visual,L"text_Label",&text);
hr=XuiElementGetBounds(text,&fTextVisualLen,&fHeight);
m_Buttons[0].GetBounds(&fMaxButton,&fHeight);
for (int i = 0; i < BUTTONS_HAO_MAX; i++) {
hr = XuiTextPresenterMeasureText(text, m_Buttons[i].GetText(),
&xuiRect);
if (xuiRect.right > fMaxTextLen) fMaxTextLen = xuiRect.right;
}
if (fTextVisualLen < fMaxTextLen) {
D3DXVECTOR3 vec;
for(int i=0;i<BUTTONS_HAO_MAX;i++)
{
hr=XuiTextPresenterMeasureText(text, m_Buttons[i].GetText(), &xuiRect);
if(xuiRect.right>fMaxTextLen) fMaxTextLen=xuiRect.right;
}
// centre is vec.x+(fWidth/2)
for (int i = 0; i < BUTTONS_HAO_MAX; i++) {
// need to resize and reposition the buttons
m_Buttons[i].GetPosition(&vec);
m_Buttons[i].GetBounds(&fWidth, &fHeight);
vec.x = vec.x + (fWidth / 2.0f) - (fMaxTextLen / 2.0f);
if(fTextVisualLen<fMaxTextLen)
{
D3DXVECTOR3 vec;
m_Buttons[i].SetPosition(&vec);
m_Buttons[i].SetBounds(
fMaxButton + fMaxTextLen - fTextVisualLen, fHeight);
}
}
}
// centre is vec.x+(fWidth/2)
for(int i=0;i<BUTTONS_HAO_MAX;i++)
{
// need to resize and reposition the buttons
m_Buttons[i].GetPosition(&vec);
m_Buttons[i].GetBounds(&fWidth,&fHeight);
vec.x= vec.x+(fWidth/2.0f)-(fMaxTextLen/2.0f);
m_Buttons[i].SetPosition(&vec);
m_Buttons[i].SetBounds(fMaxButton+fMaxTextLen-fTextVisualLen,fHeight);
}
}
}
return S_OK;
return S_OK;
}
HRESULT CScene_HelpAndOptions::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining,false);
HRESULT CScene_HelpAndOptions::OnCustomMessage_Splitscreenplayer(
bool bJoining, BOOL& bHandled) {
bHandled = true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj, &m_OriginalPosition,
m_iPad, bJoining, false);
}

View File

@@ -3,68 +3,67 @@
#include "../media/xuiscene_helpandoptions.h"
#include "XUI_CustomMessages.h"
#define BUTTON_HAO_CHANGESKIN 0
#define BUTTON_HAO_HOWTOPLAY 1
#define BUTTON_HAO_CONTROLS 2
#define BUTTON_HAO_SETTINGS 3
#define BUTTON_HAO_CREDITS 4
#define BUTTON_HAO_REINSTALL 5
#define BUTTON_HAO_DEBUG 6
#define BUTTONS_HAO_MAX BUTTON_HAO_DEBUG + 1
#define BUTTON_HAO_CHANGESKIN 0
#define BUTTON_HAO_HOWTOPLAY 1
#define BUTTON_HAO_CONTROLS 2
#define BUTTON_HAO_SETTINGS 3
#define BUTTON_HAO_CREDITS 4
#define BUTTON_HAO_REINSTALL 5
#define BUTTON_HAO_DEBUG 6
#define BUTTONS_HAO_MAX BUTTON_HAO_DEBUG + 1
class CScene_HelpAndOptions : public CXuiSceneImpl
{
class CScene_HelpAndOptions : public CXuiSceneImpl {
protected:
// Control and Element wrapper objects.
CXuiScene m_Scene;
CXuiControl m_Buttons[BUTTONS_HAO_MAX];
CXuiElement m_Background;
CXuiControl m_Timer;
// Control and Element wrapper objects.
CXuiScene m_Scene;
CXuiControl m_Buttons[BUTTONS_HAO_MAX];
CXuiElement m_Background;
CXuiControl m_Timer;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate )
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
//XUI_ON_XM_TMS_DLCFILE_RETRIEVED_MESSAGE(OnTMSDLCFileRetrieved)
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
// XUI_ON_XM_TMS_DLCFILE_RETRIEVED_MESSAGE(OnTMSDLCFileRetrieved)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiButton1, m_Buttons[BUTTON_HAO_CHANGESKIN])
MAP_CONTROL(IDC_XuiButton2, m_Buttons[BUTTON_HAO_HOWTOPLAY ])
MAP_CONTROL(IDC_XuiButton3, m_Buttons[BUTTON_HAO_CONTROLS ])
MAP_CONTROL(IDC_XuiButton4, m_Buttons[BUTTON_HAO_SETTINGS ])
MAP_CONTROL(IDC_XuiButton5, m_Buttons[BUTTON_HAO_CREDITS])
MAP_CONTROL(IDC_XuiButton6, m_Buttons[BUTTON_HAO_REINSTALL])
MAP_CONTROL(IDC_XuiButton7, m_Buttons[BUTTON_HAO_DEBUG])
MAP_CONTROL(IDC_Timer, m_Timer)
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiButton1, m_Buttons[BUTTON_HAO_CHANGESKIN])
MAP_CONTROL(IDC_XuiButton2, m_Buttons[BUTTON_HAO_HOWTOPLAY])
MAP_CONTROL(IDC_XuiButton3, m_Buttons[BUTTON_HAO_CONTROLS])
MAP_CONTROL(IDC_XuiButton4, m_Buttons[BUTTON_HAO_SETTINGS])
MAP_CONTROL(IDC_XuiButton5, m_Buttons[BUTTON_HAO_CREDITS])
MAP_CONTROL(IDC_XuiButton6, m_Buttons[BUTTON_HAO_REINSTALL])
MAP_CONTROL(IDC_XuiButton7, m_Buttons[BUTTON_HAO_DEBUG])
MAP_CONTROL(IDC_Timer, m_Timer)
END_CONTROL_MAP()
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled);
//HRESULT OnTMSDLCFileRetrieved( );
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNavReturn(HXUIOBJ hObj, BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnTransitionStart(XUIMessageTransition* pTransition,
BOOL& bHandled);
HRESULT OnControlNavigate(XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled);
// HRESULT OnTMSDLCFileRetrieved( );
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_HelpAndOptions, L"CScene_HelpAndOptions", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_HelpAndOptions, L"CScene_HelpAndOptions",
XUI_CLASS_SCENE)
private:
int m_iPad;
bool m_bIgnoreInput;
D3DXVECTOR3 m_OriginalPosition;
int m_iPad;
bool m_bIgnoreInput;
D3DXVECTOR3 m_OriginalPosition;
};

File diff suppressed because it is too large Load Diff

View File

@@ -5,111 +5,107 @@
class CXuiCtrl4JList;
#define MAX_CONTROLS 17
class CScene_Controls : public CXuiSceneImpl
{
protected:
// Control and Element wrapper objects.
CXuiControl m_TextA[MAX_CONTROLS];
HXUIOBJ m_TextPresenterA[MAX_CONTROLS];
CXuiElement m_FigA[MAX_CONTROLS];
CXuiList m_SchemeList;
CXuiElement m_Group;
CXuiControl m_BuildVer;
CXuiControl m_CurrentLayout;
CXuiCheckbox m_InvertLook;
CXuiCheckbox m_SouthPaw;
static LPCWSTR m_LayoutNameA[3];
class CScene_Controls : public CXuiSceneImpl {
protected:
// Control and Element wrapper objects.
CXuiControl m_TextA[MAX_CONTROLS];
HXUIOBJ m_TextPresenterA[MAX_CONTROLS];
CXuiElement m_FigA[MAX_CONTROLS];
CXuiList m_SchemeList;
CXuiElement m_Group;
CXuiControl m_BuildVer;
CXuiControl m_CurrentLayout;
CXuiCheckbox m_InvertLook;
CXuiCheckbox m_SouthPaw;
static LPCWSTR m_LayoutNameA[3];
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_END_MSG_MAP()
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_SchemeList, m_SchemeList)
MAP_CONTROL(IDC_CurrentLayout, m_CurrentLayout)
MAP_CONTROL(IDC_XuiBuildVer, m_BuildVer)
MAP_CONTROL(IDC_XuiLabel1, m_TextA[0])
MAP_CONTROL(IDC_XuiLabel2, m_TextA[1])
MAP_CONTROL(IDC_XuiLabel3, m_TextA[2])
MAP_CONTROL(IDC_XuiLabel4, m_TextA[3])
MAP_CONTROL(IDC_XuiLabel5, m_TextA[4])
MAP_CONTROL(IDC_XuiLabel6, m_TextA[5])
MAP_CONTROL(IDC_XuiLabel7, m_TextA[6])
MAP_CONTROL(IDC_XuiLabel8, m_TextA[7])
MAP_CONTROL(IDC_XuiLabel9, m_TextA[8])
MAP_CONTROL(IDC_XuiLabel10, m_TextA[9])
MAP_CONTROL(IDC_XuiLabel11, m_TextA[10])
MAP_CONTROL(IDC_XuiLabel12, m_TextA[11])
MAP_CONTROL(IDC_XuiLabel13, m_TextA[12])
MAP_CONTROL(IDC_XuiLabel14, m_TextA[13])
MAP_CONTROL(IDC_XuiLabel15, m_TextA[14])
MAP_CONTROL(IDC_XuiLabel16, m_TextA[15])
MAP_CONTROL(IDC_XuiLabel17, m_TextA[16])
MAP_CONTROL(IDC_FigGroup, m_Group)
MAP_CONTROL(IDC_InvertLook, m_InvertLook)
MAP_CONTROL(IDC_SouthPaw, m_SouthPaw)
BEGIN_MAP_CHILD_CONTROLS(m_Group)
MAP_CONTROL(IDC_A, m_FigA[0])
MAP_CONTROL(IDC_B, m_FigA[1])
MAP_CONTROL(IDC_X, m_FigA[2])
MAP_CONTROL(IDC_Y, m_FigA[3])
MAP_CONTROL(IDC_Start, m_FigA[4])
MAP_CONTROL(IDC_Back, m_FigA[5])
MAP_CONTROL(IDC_RB, m_FigA[6])
MAP_CONTROL(IDC_LB, m_FigA[7])
MAP_CONTROL(IDC_RStickButton, m_FigA[8])
MAP_CONTROL(IDC_LStickButton, m_FigA[9])
MAP_CONTROL(IDC_RStick, m_FigA[10])
MAP_CONTROL(IDC_LStick, m_FigA[11])
MAP_CONTROL(IDC_RT, m_FigA[12])
MAP_CONTROL(IDC_LT, m_FigA[13])
MAP_CONTROL(IDC_DpadR, m_FigA[14])
MAP_CONTROL(IDC_DpadL, m_FigA[15])
MAP_CONTROL(IDC_Dpad, m_FigA[16])
END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_SchemeList, m_SchemeList)
MAP_CONTROL(IDC_CurrentLayout, m_CurrentLayout)
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled );
MAP_CONTROL(IDC_XuiBuildVer, m_BuildVer)
MAP_CONTROL(IDC_XuiLabel1, m_TextA[0])
MAP_CONTROL(IDC_XuiLabel2, m_TextA[1])
MAP_CONTROL(IDC_XuiLabel3, m_TextA[2])
MAP_CONTROL(IDC_XuiLabel4, m_TextA[3])
MAP_CONTROL(IDC_XuiLabel5, m_TextA[4])
MAP_CONTROL(IDC_XuiLabel6, m_TextA[5])
MAP_CONTROL(IDC_XuiLabel7, m_TextA[6])
MAP_CONTROL(IDC_XuiLabel8, m_TextA[7])
MAP_CONTROL(IDC_XuiLabel9, m_TextA[8])
MAP_CONTROL(IDC_XuiLabel10, m_TextA[9])
MAP_CONTROL(IDC_XuiLabel11, m_TextA[10])
MAP_CONTROL(IDC_XuiLabel12, m_TextA[11])
MAP_CONTROL(IDC_XuiLabel13, m_TextA[12])
MAP_CONTROL(IDC_XuiLabel14, m_TextA[13])
MAP_CONTROL(IDC_XuiLabel15, m_TextA[14])
MAP_CONTROL(IDC_XuiLabel16, m_TextA[15])
MAP_CONTROL(IDC_XuiLabel17, m_TextA[16])
MAP_CONTROL(IDC_FigGroup, m_Group)
MAP_CONTROL(IDC_InvertLook, m_InvertLook)
MAP_CONTROL(IDC_SouthPaw, m_SouthPaw)
BEGIN_MAP_CHILD_CONTROLS(m_Group)
MAP_CONTROL(IDC_A, m_FigA[0])
MAP_CONTROL(IDC_B, m_FigA[1])
MAP_CONTROL(IDC_X, m_FigA[2])
MAP_CONTROL(IDC_Y, m_FigA[3])
MAP_CONTROL(IDC_Start, m_FigA[4])
MAP_CONTROL(IDC_Back, m_FigA[5])
MAP_CONTROL(IDC_RB, m_FigA[6])
MAP_CONTROL(IDC_LB, m_FigA[7])
MAP_CONTROL(IDC_RStickButton, m_FigA[8])
MAP_CONTROL(IDC_LStickButton, m_FigA[9])
MAP_CONTROL(IDC_RStick, m_FigA[10])
MAP_CONTROL(IDC_LStick, m_FigA[11])
MAP_CONTROL(IDC_RT, m_FigA[12])
MAP_CONTROL(IDC_LT, m_FigA[13])
MAP_CONTROL(IDC_DpadR, m_FigA[14])
MAP_CONTROL(IDC_DpadL, m_FigA[15])
MAP_CONTROL(IDC_Dpad, m_FigA[16])
END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnTransitionStart(XUIMessageTransition* pTransition,
BOOL& bHandled);
void PositionText(int iPad,int iTextID, unsigned char ucAction);
void PositionTextDirect(int iPad,int iTextID, int iControlDetailsIndex, bool bShow);
void PositionAllText(int iPad);
void PositionText(int iPad, int iTextID, unsigned char ucAction);
void PositionTextDirect(int iPad, int iTextID, int iControlDetailsIndex,
bool bShow);
void PositionAllText(int iPad);
int m_iCurrentTextIndex;
int m_iCurrentNavigatedControlsLayout;
int m_iSchemeTextA[3];
int m_nItems;
int m_iPad;
CXuiCtrl4JList *m_pLayoutList;
bool m_bIgnoreNotifies;
D3DXVECTOR3 m_OriginalPosition;
bool m_bCreativeMode;
int m_iCurrentTextIndex;
int m_iCurrentNavigatedControlsLayout;
int m_iSchemeTextA[3];
int m_nItems;
int m_iPad;
CXuiCtrl4JList* m_pLayoutList;
bool m_bIgnoreNotifies;
D3DXVECTOR3 m_OriginalPosition;
bool m_bCreativeMode;
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_Controls, L"CScene_Controls", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_Controls, L"CScene_Controls", XUI_CLASS_SCENE)
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,73 +1,73 @@
#pragma once
#define CREDITS_TICK_TIMER_ID (6) // Arbitrary timer ID used to tick credits for scrolling.
#define CREDITS_TICK_TIMER_ID \
(6) // Arbitrary timer ID used to tick credits for scrolling.
#define MAX_CREDIT_STRINGS 360
#define MAX_CREDIT_STRINGS 360
// 213
#include "../UI/UIStructs.h"
class CScene_Credits : public CXuiSceneImpl
{
class CScene_Credits : public CXuiSceneImpl {
protected:
// Control and Element wrapper objects.
// Control and Element wrapper objects.
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_ON_XM_TIMER( OnTimer )
XUI_ON_XM_DESTROY( OnDestroy )
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_ON_XM_TIMER(OnTimer)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
END_CONTROL_MAP()
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled);
HRESULT OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled );
HRESULT OnDestroy();
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnControlNavigate(XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled);
HRESULT OnTimer(XUIMessageTimer* pTimer, BOOL& bHandled);
HRESULT OnDestroy();
private:
struct STextType {
// Array of pointers to text elements.
CXuiControl** m_appTextElements;
int m_iNextFreeElement;
int m_iNumUsedElements;
int m_iMaxElements;
};
struct STextType
{
// Array of pointers to text elements.
CXuiControl** m_appTextElements;
STextType m_aTextTypes[eNumTextTypes];
int m_iNextFreeElement;
int m_iNumUsedElements;
int m_iMaxElements;
};
int m_iCurrDefIndex; // Index of last created text def.
float m_fMoveSinceLastDef; // How far have credits scrolled since we last
// created a new text item.
float m_fMoveToNextDef; // How far we need to move before starting next
// text item.
int m_iNumTextDefs; // Total number of text defs in the credits.
STextType m_aTextTypes[ eNumTextTypes ];
float CREDITS_SCREEN_MIN_Y; // ( 200.0f ) // Y pos at
//which credits are removed from top of screen.
float CREDITS_SCREEN_MAX_Y; // ( 630.0f ) // Y pos at
//which credits appear at bottom of screen.
float CREDITS_FADE_HEIGHT; // ( 100.0f ) //
//Height over which credits fade in or fade out.
int m_iCurrDefIndex; // Index of last created text def.
float m_fMoveSinceLastDef; // How far have credits scrolled since we last created a new text item.
float m_fMoveToNextDef; // How far we need to move before starting next text item.
int m_iNumTextDefs; // Total number of text defs in the credits.
float CREDITS_SCREEN_MIN_Y;// ( 200.0f ) // Y pos at which credits are removed from top of screen.
float CREDITS_SCREEN_MAX_Y;// ( 630.0f ) // Y pos at which credits appear at bottom of screen.
float CREDITS_FADE_HEIGHT;// ( 100.0f ) // Height over which credits fade in or fade out.
float gs_aLineSpace[ eNumTextTypes ];
float gs_aLineSpace[eNumTextTypes];
public:
static SCreditTextItemDef gs_aCreditDefs[MAX_CREDIT_STRINGS];
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_Credits, L"CScene_Credits", XUI_CLASS_SCENE )
static SCreditTextItemDef gs_aCreditDefs[MAX_CREDIT_STRINGS];
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_Credits, L"CScene_Credits", XUI_CLASS_SCENE)
};

View File

@@ -4,235 +4,284 @@
#include "XUI_HelpHowToPlay.h"
#include "../../Minecraft.World/Util/StringHelpers.h"
static SHowToPlayPageDef gs_aPageDefs[ eHowToPlay_NumPages ] =
{
{ eHowToPlay_WhatsNew, IDS_HOW_TO_PLAY_WHATSNEW, eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_WhatsNew
{ eHowToPlay_TextBasics, IDS_HOW_TO_PLAY_BASICS, eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_Basics
{ eHowToPlay_TextMultiplayer, IDS_HOW_TO_PLAY_MULTIPLAYER, eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_Multiplayer
{ eHowToPlay_TextHUD, IDS_HOW_TO_PLAY_HUD, eHowToPlay_ImageHUD, 0, 0}, // eHowToPlay_HUD
{ eHowToPlay_TextCreative, IDS_HOW_TO_PLAY_CREATIVE, eHowToPlay_ImageCreative, eHowToPlay_LabelCreativeInventory, 1}, // eHowToPlay_Creative
{ eHowToPlay_TextInventory, IDS_HOW_TO_PLAY_INVENTORY, eHowToPlay_ImageInventory, eHowToPlay_LabelIInventory, 1}, // eHowToPlay_Inventory
{ eHowToPlay_TextSmallChest, IDS_HOW_TO_PLAY_CHEST, eHowToPlay_ImageChest, eHowToPlay_LabelSCInventory, 2}, // eHowToPlay_Chest
{ eHowToPlay_TextLargeChest, IDS_HOW_TO_PLAY_LARGECHEST, eHowToPlay_ImageLargeChest, eHowToPlay_LabelLCInventory, 2}, // eHowToPlay_LargeChest
{ eHowToPlay_TextEnderchest, IDS_HOW_TO_PLAY_ENDERCHEST, eHowToPlay_ImageEnderChest, 0, 0}, // eHowToPlay_EnderChest
{ eHowToPlay_TextCrafting, IDS_HOW_TO_PLAY_CRAFTING, eHowToPlay_ImageInventoryCrafting, eHowToPlay_LabelCItem, 3}, // eHowToPlay_InventoryCrafting
{ eHowToPlay_TextCraftTable, IDS_HOW_TO_PLAY_CRAFT_TABLE, eHowToPlay_ImageCraftingTable, eHowToPlay_LabelCTItem, 3}, // eHowToPlay_CraftTable
{ eHowToPlay_TextFurnace, IDS_HOW_TO_PLAY_FURNACE, eHowToPlay_ImageFurnace, eHowToPlay_LabelFFuel, 4}, // eHowToPlay_Furnace
{ eHowToPlay_TextDispenser, IDS_HOW_TO_PLAY_DISPENSER, eHowToPlay_ImageDispenser, eHowToPlay_LabelDText, 2}, // eHowToPlay_Dispenser
{ eHowToPlay_TextBrewing, IDS_HOW_TO_PLAY_BREWING, eHowToPlay_ImageBrewing, eHowToPlay_LabelBBrew, 2}, // eHowToPlay_Brewing
{ eHowToPlay_TextEnchantment, IDS_HOW_TO_PLAY_ENCHANTMENT, eHowToPlay_ImageEnchantment, eHowToPlay_LabelEEnchant, 2}, // eHowToPlay_Enchantment
{ eHowToPlay_TextAnvil, IDS_HOW_TO_PLAY_ANVIL, eHowToPlay_ImageAnvil, eHowToPlay_LabelAnvil_Inventory, 3}, // eHowToPlay_Anvil
{ eHowToPlay_TextFarmingAnimals,IDS_HOW_TO_PLAY_FARMANIMALS, eHowToPlay_ImageFarmingAnimals, 0, 0}, // eHowToPlay_Farming
{ eHowToPlay_TextBreeding, IDS_HOW_TO_PLAY_BREEDANIMALS, eHowToPlay_ImageBreeding, 0, 0}, // eHowToPlay_Breeding
{ eHowToPlay_TextTrading, IDS_HOW_TO_PLAY_TRADING, eHowToPlay_ImageTrading, eHowToPlay_LabelTrading_Inventory, 5}, // eHowToPlay_Trading
{ eHowToPlay_TextNetherPortal, IDS_HOW_TO_PLAY_NETHERPORTAL, eHowToPlay_ImageNetherPortal, 0, 0}, // eHowToPlay_NetherPortal
{ eHowToPlay_TextTheEnd, IDS_HOW_TO_PLAY_THEEND, eHowToPlay_ImageTheEnd, 0, 0}, // eHowToPlay_TheEnd
{ eHowToPlay_TextSocialMedia, IDS_HOW_TO_PLAY_SOCIALMEDIA, eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_SocialMedia
{ eHowToPlay_TextBanList, IDS_HOW_TO_PLAY_BANLIST, eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_BanList
{ eHowToPlay_TextHostOptions, IDS_HOW_TO_PLAY_HOSTOPTIONS, eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_HostOptions
static SHowToPlayPageDef gs_aPageDefs[eHowToPlay_NumPages] = {
{eHowToPlay_WhatsNew, IDS_HOW_TO_PLAY_WHATSNEW, eHowToPlay_ImageNone, 0,
0}, // eHowToPlay_WhatsNew
{eHowToPlay_TextBasics, IDS_HOW_TO_PLAY_BASICS, eHowToPlay_ImageNone, 0,
0}, // eHowToPlay_Basics
{eHowToPlay_TextMultiplayer, IDS_HOW_TO_PLAY_MULTIPLAYER,
eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_Multiplayer
{eHowToPlay_TextHUD, IDS_HOW_TO_PLAY_HUD, eHowToPlay_ImageHUD, 0,
0}, // eHowToPlay_HUD
{eHowToPlay_TextCreative, IDS_HOW_TO_PLAY_CREATIVE,
eHowToPlay_ImageCreative, eHowToPlay_LabelCreativeInventory,
1}, // eHowToPlay_Creative
{eHowToPlay_TextInventory, IDS_HOW_TO_PLAY_INVENTORY,
eHowToPlay_ImageInventory, eHowToPlay_LabelIInventory,
1}, // eHowToPlay_Inventory
{eHowToPlay_TextSmallChest, IDS_HOW_TO_PLAY_CHEST, eHowToPlay_ImageChest,
eHowToPlay_LabelSCInventory, 2}, // eHowToPlay_Chest
{eHowToPlay_TextLargeChest, IDS_HOW_TO_PLAY_LARGECHEST,
eHowToPlay_ImageLargeChest, eHowToPlay_LabelLCInventory,
2}, // eHowToPlay_LargeChest
{eHowToPlay_TextEnderchest, IDS_HOW_TO_PLAY_ENDERCHEST,
eHowToPlay_ImageEnderChest, 0, 0}, // eHowToPlay_EnderChest
{eHowToPlay_TextCrafting, IDS_HOW_TO_PLAY_CRAFTING,
eHowToPlay_ImageInventoryCrafting, eHowToPlay_LabelCItem,
3}, // eHowToPlay_InventoryCrafting
{eHowToPlay_TextCraftTable, IDS_HOW_TO_PLAY_CRAFT_TABLE,
eHowToPlay_ImageCraftingTable, eHowToPlay_LabelCTItem,
3}, // eHowToPlay_CraftTable
{eHowToPlay_TextFurnace, IDS_HOW_TO_PLAY_FURNACE, eHowToPlay_ImageFurnace,
eHowToPlay_LabelFFuel, 4}, // eHowToPlay_Furnace
{eHowToPlay_TextDispenser, IDS_HOW_TO_PLAY_DISPENSER,
eHowToPlay_ImageDispenser, eHowToPlay_LabelDText,
2}, // eHowToPlay_Dispenser
{eHowToPlay_TextBrewing, IDS_HOW_TO_PLAY_BREWING, eHowToPlay_ImageBrewing,
eHowToPlay_LabelBBrew, 2}, // eHowToPlay_Brewing
{eHowToPlay_TextEnchantment, IDS_HOW_TO_PLAY_ENCHANTMENT,
eHowToPlay_ImageEnchantment, eHowToPlay_LabelEEnchant,
2}, // eHowToPlay_Enchantment
{eHowToPlay_TextAnvil, IDS_HOW_TO_PLAY_ANVIL, eHowToPlay_ImageAnvil,
eHowToPlay_LabelAnvil_Inventory, 3}, // eHowToPlay_Anvil
{eHowToPlay_TextFarmingAnimals, IDS_HOW_TO_PLAY_FARMANIMALS,
eHowToPlay_ImageFarmingAnimals, 0, 0}, // eHowToPlay_Farming
{eHowToPlay_TextBreeding, IDS_HOW_TO_PLAY_BREEDANIMALS,
eHowToPlay_ImageBreeding, 0, 0}, // eHowToPlay_Breeding
{eHowToPlay_TextTrading, IDS_HOW_TO_PLAY_TRADING, eHowToPlay_ImageTrading,
eHowToPlay_LabelTrading_Inventory, 5}, // eHowToPlay_Trading
{eHowToPlay_TextNetherPortal, IDS_HOW_TO_PLAY_NETHERPORTAL,
eHowToPlay_ImageNetherPortal, 0, 0}, // eHowToPlay_NetherPortal
{eHowToPlay_TextTheEnd, IDS_HOW_TO_PLAY_THEEND, eHowToPlay_ImageTheEnd, 0,
0}, // eHowToPlay_TheEnd
{eHowToPlay_TextSocialMedia, IDS_HOW_TO_PLAY_SOCIALMEDIA,
eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_SocialMedia
{eHowToPlay_TextBanList, IDS_HOW_TO_PLAY_BANLIST, eHowToPlay_ImageNone, 0,
0}, // eHowToPlay_BanList
{eHowToPlay_TextHostOptions, IDS_HOW_TO_PLAY_HOSTOPTIONS,
eHowToPlay_ImageNone, 0, 0}, // eHowToPlay_HostOptions
};
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_HowToPlay::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
// Extract pad and required page from init data. We just put the data into the pointer rather than using it as an address.
size_t uiInitData = ( size_t )( pInitData->pvInitData );
HRESULT CScene_HowToPlay::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
// Extract pad and required page from init data. We just put the data into
// the pointer rather than using it as an address.
size_t uiInitData = (size_t)(pInitData->pvInitData);
m_iPad = ( int )( ( short )( uiInitData & 0xFFFF ) );
EHowToPlayPage eStartPage = ( EHowToPlayPage )( ( uiInitData >> 16 ) & 0xFFF ); // Ignores MSB which is set to 1!
m_iPad = (int)((short)(uiInitData & 0xFFFF));
EHowToPlayPage eStartPage =
(EHowToPlayPage)((uiInitData >> 16) &
0xFFF); // Ignores MSB which is set to 1!
TelemetryManager->RecordMenuShown(m_iPad, eUIScene_HowToPlay, (ETelemetry_HowToPlay_SubMenuId)eStartPage);
TelemetryManager->RecordMenuShown(
m_iPad, eUIScene_HowToPlay, (ETelemetry_HowToPlay_SubMenuId)eStartPage);
MapChildControls();
MapChildControls();
std::wstring wsTemp, inventoryString = app.GetString(IDS_INVENTORY);
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelCTItem],app.GetString(IDS_ITEM_HATCHET_WOOD));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelCTGroup],app.GetString(IDS_GROUPNAME_TOOLS));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelCTInventory3x3],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelCItem],app.GetString(IDS_TILE_WORKBENCH));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelCGroup],app.GetString(IDS_GROUPNAME_STRUCTURES));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelCInventory2x2],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelFFuel],app.GetString(IDS_FUEL));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelFInventory],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelFIngredient],app.GetString(IDS_INGREDIENT));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelFChest],app.GetString(IDS_FURNACE));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelLCInventory],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelCreativeInventory],app.GetString(IDS_GROUPNAME_BUILDING_BLOCKS));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelLCChest],app.GetString(IDS_CHEST));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelSCInventory],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelSCChest],app.GetString(IDS_CHEST));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelIInventory],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelDInventory],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelDText],app.GetString(IDS_DISPENSER));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelEEnchant],app.GetString(IDS_ENCHANT));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelEInventory],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelBBrew],app.GetString(IDS_BREWING_STAND));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelBInventory],inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelAnvil_Inventory], inventoryString.c_str());
wsTemp = app.GetString(IDS_REPAIR_COST);
wsTemp.replace( wsTemp.find(L"%d"), 2, std::wstring(L"8") );
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelAnvil_Cost], wsTemp.c_str());
std::wstring wsTemp, inventoryString = app.GetString(IDS_INVENTORY);
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelCTItem],
app.GetString(IDS_ITEM_HATCHET_WOOD));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelCTGroup],
app.GetString(IDS_GROUPNAME_TOOLS));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelCTInventory3x3],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelCItem],
app.GetString(IDS_TILE_WORKBENCH));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelCGroup],
app.GetString(IDS_GROUPNAME_STRUCTURES));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelCInventory2x2],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelFFuel],
app.GetString(IDS_FUEL));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelFInventory],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelFIngredient],
app.GetString(IDS_INGREDIENT));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelFChest],
app.GetString(IDS_FURNACE));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelLCInventory],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelCreativeInventory],
app.GetString(IDS_GROUPNAME_BUILDING_BLOCKS));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelLCChest],
app.GetString(IDS_CHEST));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelSCInventory],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelSCChest],
app.GetString(IDS_CHEST));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelIInventory],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelDInventory],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelDText],
app.GetString(IDS_DISPENSER));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelEEnchant],
app.GetString(IDS_ENCHANT));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelEInventory],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelBBrew],
app.GetString(IDS_BREWING_STAND));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelBInventory],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelAnvil_Inventory],
inventoryString.c_str());
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelAnvil_ARepairAndName], app.GetString(IDS_REPAIR_AND_NAME));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelTrading_Inventory], inventoryString.c_str());
//XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelTrading_Offer2], app.GetString(IDS_ITEM_HATCHET_DIAMOND));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelTrading_Offer1], app.GetString(IDS_ITEM_EMERALD));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelTrading_NeededForTrade], app.GetString(IDS_REQUIRED_ITEMS_FOR_TRADE));
wsTemp = app.GetString(IDS_REPAIR_COST);
wsTemp.replace(wsTemp.find(L"%d"), 2, std::wstring(L"8"));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelAnvil_Cost],
wsTemp.c_str());
wsTemp = app.GetString(IDS_VILLAGER_OFFERS_ITEM);
wsTemp = replaceAll(wsTemp,L"{*VILLAGER_TYPE*}",app.GetString(IDS_VILLAGER_PRIEST));
wsTemp.replace(wsTemp.find(L"%s"),2, app.GetString(IDS_TILE_LIGHT_GEM));
XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelTrading_VillagerOffers], wsTemp.c_str());
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelAnvil_ARepairAndName],
app.GetString(IDS_REPAIR_AND_NAME));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelTrading_Inventory],
inventoryString.c_str());
// XuiControlSetText(m_aLabelControls[ eHowToPlay_LabelTrading_Offer2],
// app.GetString(IDS_ITEM_HATCHET_DIAMOND));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelTrading_Offer1],
app.GetString(IDS_ITEM_EMERALD));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelTrading_NeededForTrade],
app.GetString(IDS_REQUIRED_ITEMS_FOR_TRADE));
if(app.GetLocalPlayerCount()>1)
{
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad);
}
wsTemp = app.GetString(IDS_VILLAGER_OFFERS_ITEM);
wsTemp = replaceAll(wsTemp, L"{*VILLAGER_TYPE*}",
app.GetString(IDS_VILLAGER_PRIEST));
wsTemp.replace(wsTemp.find(L"%s"), 2, app.GetString(IDS_TILE_LIGHT_GEM));
XuiControlSetText(m_aLabelControls[eHowToPlay_LabelTrading_VillagerOffers],
wsTemp.c_str());
if (app.GetLocalPlayerCount() > 1) {
app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad);
}
StartPage( eStartPage );
StartPage(eStartPage);
return S_OK;
return S_OK;
}
HRESULT CScene_HowToPlay::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
// Explicitly handle B button presses
switch(pInputData->dwKeyCode)
{
case VK_PAD_B:
case VK_ESCAPE:
{
app.NavigateBack(pInputData->UserIndex);
rfHandled = TRUE;
}
break;
case VK_PAD_A:
{
// Next page
int iNextPage = ( int )( m_eCurrPage ) + 1;
if ( iNextPage != eHowToPlay_NumPages )
{
StartPage( ( EHowToPlayPage )( iNextPage ) );
CXuiSceneBase::PlayUISFX(eSFX_Press);
}
rfHandled = TRUE;
}
break;
case VK_PAD_X:
{
// Next page
int iPrevPage = ( int )( m_eCurrPage ) - 1;
if ( iPrevPage >= 0 )
{
StartPage( ( EHowToPlayPage )( iPrevPage ) );
CXuiSceneBase::PlayUISFX(eSFX_Press);
}
rfHandled = TRUE;
}
break;
}
return S_OK;
HRESULT CScene_HowToPlay::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
// Explicitly handle B button presses
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_ESCAPE: {
app.NavigateBack(pInputData->UserIndex);
rfHandled = TRUE;
} break;
case VK_PAD_A: {
// Next page
int iNextPage = (int)(m_eCurrPage) + 1;
if (iNextPage != eHowToPlay_NumPages) {
StartPage((EHowToPlayPage)(iNextPage));
CXuiSceneBase::PlayUISFX(eSFX_Press);
}
rfHandled = TRUE;
} break;
case VK_PAD_X: {
// Next page
int iPrevPage = (int)(m_eCurrPage)-1;
if (iPrevPage >= 0) {
StartPage((EHowToPlayPage)(iPrevPage));
CXuiSceneBase::PlayUISFX(eSFX_Press);
}
rfHandled = TRUE;
} break;
}
return S_OK;
}
void CScene_HowToPlay::StartPage(EHowToPlayPage ePage) {
int iBaseSceneUser;
// if we're not in the game, we need to use basescene 0
if (Minecraft::GetInstance()->level == NULL) {
iBaseSceneUser = DEFAULT_XUI_MENU_USER;
} else {
iBaseSceneUser = m_iPad;
}
m_eCurrPage = ePage;
void CScene_HowToPlay::StartPage( EHowToPlayPage ePage )
{
int iBaseSceneUser;
// if we're not in the game, we need to use basescene 0
if(Minecraft::GetInstance()->level==NULL)
{
iBaseSceneUser=DEFAULT_XUI_MENU_USER;
}
else
{
iBaseSceneUser=m_iPad;
}
m_eCurrPage = ePage;
// Turn off everything.
for (int i = 0; i < eHowToPlay_NumTexts; ++i) {
m_aTextControls[i].SetShow(FALSE);
}
for (int i = 0; i < eHowToPlay_NumImages; ++i) {
m_aImageControls[i].SetShow(FALSE);
}
for (int i = 0; i < eHowToPlay_NumLabels; ++i) {
m_aLabelControls[i].SetShow(FALSE);
}
// Turn off everything.
for ( int i = 0; i < eHowToPlay_NumTexts; ++i )
{
m_aTextControls[ i ].SetShow( FALSE );
}
for ( int i = 0; i < eHowToPlay_NumImages; ++i )
{
m_aImageControls[ i ].SetShow( FALSE );
}
for ( int i = 0; i < eHowToPlay_NumLabels; ++i )
{
m_aLabelControls[ i ].SetShow( FALSE );
}
// Turn on just what we need for this screen.
SHowToPlayPageDef* pDef = &(gs_aPageDefs[m_eCurrPage]);
// Turn on just what we need for this screen.
SHowToPlayPageDef* pDef = &( gs_aPageDefs[ m_eCurrPage ] );
if (pDef->m_iTextControlIndex != eHowToPlay_TextNone) {
// Replace button identifiers in the text with actual button images.
std::wstring replacedText =
app.FormatHTMLString(m_iPad, app.GetString(pDef->m_iTextStringID));
if ( pDef->m_iTextControlIndex != eHowToPlay_TextNone )
{
// Replace button identifiers in the text with actual button images.
std::wstring replacedText = app.FormatHTMLString(m_iPad, app.GetString( pDef->m_iTextStringID ));
// 4J-PB - replace the title with the platform specific title, and the
// platform name
replacedText = replaceAll(replacedText, L"{*PLATFORM_NAME*}",
app.GetString(IDS_PLATFORM_NAME));
replacedText = replaceAll(replacedText, L"{*BACK_BUTTON*}",
app.GetString(IDS_BACK_BUTTON));
replacedText =
replaceAll(replacedText, L"{*DISABLES_ACHIEVEMENTS*}",
app.GetString(IDS_HOST_OPTION_DISABLES_ACHIEVEMENTS));
// 4J-PB - replace the title with the platform specific title, and the platform name
replacedText = replaceAll(replacedText,L"{*PLATFORM_NAME*}",app.GetString(IDS_PLATFORM_NAME));
replacedText = replaceAll(replacedText,L"{*BACK_BUTTON*}",app.GetString(IDS_BACK_BUTTON));
replacedText = replaceAll(replacedText,L"{*DISABLES_ACHIEVEMENTS*}",app.GetString(IDS_HOST_OPTION_DISABLES_ACHIEVEMENTS));
// Set the text colour
std::wstring finalText(replacedText.c_str());
wchar_t startTags[64];
swprintf(startTags, 64, L"<font color=\"#%08x\">",
app.GetHTMLColour(eHTMLColor_White));
finalText = startTags + finalText;
// Set the text colour
std::wstring finalText(replacedText.c_str() );
wchar_t startTags[64];
swprintf(startTags,64,L"<font color=\"#%08x\">",app.GetHTMLColour(eHTMLColor_White));
finalText = startTags + finalText;
// Set the text in the xui scene.
m_aTextControls[pDef->m_iTextControlIndex].SetText(finalText.c_str());
// Set the text in the xui scene.
m_aTextControls[ pDef->m_iTextControlIndex ].SetText( finalText.c_str() );
// Make it visible.
m_aTextControls[pDef->m_iTextControlIndex].SetShow(TRUE);
// Make it visible.
m_aTextControls[ pDef->m_iTextControlIndex ].SetShow( TRUE );
XuiElementSetUserFocus(
m_aTextControls[pDef->m_iTextControlIndex].m_hObj, m_iPad);
}
XuiElementSetUserFocus(m_aTextControls[ pDef->m_iTextControlIndex ].m_hObj, m_iPad);
}
if (pDef->m_iLabelCount != 0) {
for (int i = pDef->m_iLabelStartIndex;
i < (pDef->m_iLabelStartIndex + pDef->m_iLabelCount); i++) {
m_aLabelControls[i].SetShow(TRUE);
}
}
if(pDef->m_iLabelCount!=0)
{
for(int i=pDef->m_iLabelStartIndex;i<(pDef->m_iLabelStartIndex+pDef->m_iLabelCount);i++)
{
m_aLabelControls[i].SetShow( TRUE );
}
}
if (pDef->m_iImageControlIndex != eHowToPlay_ImageNone) {
m_aImageControls[pDef->m_iImageControlIndex].SetShow(TRUE);
}
if ( pDef->m_iImageControlIndex != eHowToPlay_ImageNone )
{
m_aImageControls[ pDef->m_iImageControlIndex ].SetShow( TRUE );
}
// Tool tips.
int iPage = (int)(m_eCurrPage);
if (iPage == 0) {
// No previous page.
ui.SetTooltips(iBaseSceneUser, IDS_HOW_TO_PLAY_NEXT, IDS_TOOLTIPS_BACK,
-1);
} else if ((iPage + 1) == eHowToPlay_NumPages) {
// No next page.
ui.SetTooltips(iBaseSceneUser, -1, IDS_TOOLTIPS_BACK,
IDS_HOW_TO_PLAY_PREV);
} else {
ui.SetTooltips(iBaseSceneUser, IDS_HOW_TO_PLAY_NEXT, IDS_TOOLTIPS_BACK,
IDS_HOW_TO_PLAY_PREV);
}
// Tool tips.
int iPage = ( int )( m_eCurrPage );
if ( iPage == 0 )
{
// No previous page.
ui.SetTooltips( iBaseSceneUser, IDS_HOW_TO_PLAY_NEXT, IDS_TOOLTIPS_BACK, -1 );
}
else if ( ( iPage + 1 ) == eHowToPlay_NumPages )
{
// No next page.
ui.SetTooltips( iBaseSceneUser, -1, IDS_TOOLTIPS_BACK, IDS_HOW_TO_PLAY_PREV );
}
else
{
ui.SetTooltips( iBaseSceneUser, IDS_HOW_TO_PLAY_NEXT, IDS_TOOLTIPS_BACK, IDS_HOW_TO_PLAY_PREV );
}
TelemetryManager->RecordMenuShown(m_iPad, eUIScene_HowToPlay, (ETelemetry_HowToPlay_SubMenuId)ePage);
TelemetryManager->RecordMenuShown(m_iPad, eUIScene_HowToPlay,
(ETelemetry_HowToPlay_SubMenuId)ePage);
}
HRESULT CScene_HowToPlay::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining);
HRESULT CScene_HowToPlay::OnCustomMessage_Splitscreenplayer(bool bJoining,
BOOL& bHandled) {
bHandled = true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj, &m_OriginalPosition,
m_iPad, bJoining);
}

View File

@@ -3,215 +3,249 @@
#include "../media/xuiscene_howtoplay.h"
#include "XUI_CustomMessages.h"
enum EHowToPlayTextControls
{
eHowToPlay_TextNone = -1,
eHowToPlay_TextWhatsNew = 0,
eHowToPlay_TextBasics,
eHowToPlay_TextMultiplayer,
eHowToPlay_TextHUD,
eHowToPlay_TextCreative,
eHowToPlay_TextInventory,
eHowToPlay_TextSmallChest,
eHowToPlay_TextLargeChest,
eHowToPlay_TextEnderchest,
eHowToPlay_TextCrafting,
eHowToPlay_TextCraftTable,
eHowToPlay_TextFurnace,
eHowToPlay_TextDispenser,
eHowToPlay_TextBrewing,
eHowToPlay_TextEnchantment,
eHowToPlay_TextAnvil,
eHowToPlay_TextFarmingAnimals,
eHowToPlay_TextBreeding,
eHowToPlay_TextTrading,
eHowToPlay_TextNetherPortal,
eHowToPlay_TextTheEnd,
eHowToPlay_TextSocialMedia,
eHowToPlay_TextBanList,
eHowToPlay_TextHostOptions,
eHowToPlay_NumTexts
enum EHowToPlayTextControls {
eHowToPlay_TextNone = -1,
eHowToPlay_TextWhatsNew = 0,
eHowToPlay_TextBasics,
eHowToPlay_TextMultiplayer,
eHowToPlay_TextHUD,
eHowToPlay_TextCreative,
eHowToPlay_TextInventory,
eHowToPlay_TextSmallChest,
eHowToPlay_TextLargeChest,
eHowToPlay_TextEnderchest,
eHowToPlay_TextCrafting,
eHowToPlay_TextCraftTable,
eHowToPlay_TextFurnace,
eHowToPlay_TextDispenser,
eHowToPlay_TextBrewing,
eHowToPlay_TextEnchantment,
eHowToPlay_TextAnvil,
eHowToPlay_TextFarmingAnimals,
eHowToPlay_TextBreeding,
eHowToPlay_TextTrading,
eHowToPlay_TextNetherPortal,
eHowToPlay_TextTheEnd,
eHowToPlay_TextSocialMedia,
eHowToPlay_TextBanList,
eHowToPlay_TextHostOptions,
eHowToPlay_NumTexts
};
enum EHowToPlayImageControls
{
eHowToPlay_ImageNone = -1,
eHowToPlay_ImageHUD = 0,
eHowToPlay_ImageCreative,
eHowToPlay_ImageInventory,
eHowToPlay_ImageChest,
eHowToPlay_ImageLargeChest,
eHowToPlay_ImageEnderChest,
eHowToPlay_ImageInventoryCrafting,
eHowToPlay_ImageCraftingTable,
eHowToPlay_ImageFurnace,
eHowToPlay_ImageDispenser,
eHowToPlay_ImageBrewing,
eHowToPlay_ImageEnchantment,
eHowToPlay_ImageAnvil,
eHowToPlay_ImageFarmingAnimals,
eHowToPlay_ImageBreeding,
eHowToPlay_ImageTrading,
eHowToPlay_ImageNetherPortal,
eHowToPlay_ImageTheEnd,
eHowToPlay_NumImages
enum EHowToPlayImageControls {
eHowToPlay_ImageNone = -1,
eHowToPlay_ImageHUD = 0,
eHowToPlay_ImageCreative,
eHowToPlay_ImageInventory,
eHowToPlay_ImageChest,
eHowToPlay_ImageLargeChest,
eHowToPlay_ImageEnderChest,
eHowToPlay_ImageInventoryCrafting,
eHowToPlay_ImageCraftingTable,
eHowToPlay_ImageFurnace,
eHowToPlay_ImageDispenser,
eHowToPlay_ImageBrewing,
eHowToPlay_ImageEnchantment,
eHowToPlay_ImageAnvil,
eHowToPlay_ImageFarmingAnimals,
eHowToPlay_ImageBreeding,
eHowToPlay_ImageTrading,
eHowToPlay_ImageNetherPortal,
eHowToPlay_ImageTheEnd,
eHowToPlay_NumImages
};
enum EHowToPlayLabelControls
{
eHowToPlay_LabelNone = -1,
eHowToPlay_LabelIInventory =0,
eHowToPlay_LabelSCInventory ,
eHowToPlay_LabelSCChest ,
eHowToPlay_LabelLCInventory ,
eHowToPlay_LabelLCChest ,
eHowToPlay_LabelCItem ,
eHowToPlay_LabelCGroup ,
eHowToPlay_LabelCInventory2x2 ,
eHowToPlay_LabelCTItem ,
eHowToPlay_LabelCTGroup ,
eHowToPlay_LabelCTInventory3x3 ,
eHowToPlay_LabelFFuel ,
eHowToPlay_LabelFInventory ,
eHowToPlay_LabelFIngredient ,
eHowToPlay_LabelFChest ,
eHowToPlay_LabelDText ,
eHowToPlay_LabelDInventory ,
eHowToPlay_LabelCreativeInventory,
eHowToPlay_LabelEEnchant,
eHowToPlay_LabelEInventory,
eHowToPlay_LabelBBrew,
eHowToPlay_LabelBInventory,
eHowToPlay_LabelAnvil_Inventory,
eHowToPlay_LabelAnvil_Cost,
eHowToPlay_LabelAnvil_ARepairAndName,
eHowToPlay_LabelTrading_Inventory,
eHowToPlay_LabelTrading_Offer2,
eHowToPlay_LabelTrading_Offer1,
eHowToPlay_LabelTrading_NeededForTrade,
eHowToPlay_LabelTrading_VillagerOffers,
eHowToPlay_NumLabels
enum EHowToPlayLabelControls {
eHowToPlay_LabelNone = -1,
eHowToPlay_LabelIInventory = 0,
eHowToPlay_LabelSCInventory,
eHowToPlay_LabelSCChest,
eHowToPlay_LabelLCInventory,
eHowToPlay_LabelLCChest,
eHowToPlay_LabelCItem,
eHowToPlay_LabelCGroup,
eHowToPlay_LabelCInventory2x2,
eHowToPlay_LabelCTItem,
eHowToPlay_LabelCTGroup,
eHowToPlay_LabelCTInventory3x3,
eHowToPlay_LabelFFuel,
eHowToPlay_LabelFInventory,
eHowToPlay_LabelFIngredient,
eHowToPlay_LabelFChest,
eHowToPlay_LabelDText,
eHowToPlay_LabelDInventory,
eHowToPlay_LabelCreativeInventory,
eHowToPlay_LabelEEnchant,
eHowToPlay_LabelEInventory,
eHowToPlay_LabelBBrew,
eHowToPlay_LabelBInventory,
eHowToPlay_LabelAnvil_Inventory,
eHowToPlay_LabelAnvil_Cost,
eHowToPlay_LabelAnvil_ARepairAndName,
eHowToPlay_LabelTrading_Inventory,
eHowToPlay_LabelTrading_Offer2,
eHowToPlay_LabelTrading_Offer1,
eHowToPlay_LabelTrading_NeededForTrade,
eHowToPlay_LabelTrading_VillagerOffers,
eHowToPlay_NumLabels
};
struct SHowToPlayPageDef
{
int m_iTextControlIndex; // eHowToPlay_TextNone if not used.
int m_iTextStringID; // -1 if not used.
int m_iImageControlIndex; // eHowToPlay_ImageNone if not used.
int m_iLabelStartIndex; // index of the labels if there are any for the page
int m_iLabelCount;
struct SHowToPlayPageDef {
int m_iTextControlIndex; // eHowToPlay_TextNone if not used.
int m_iTextStringID; // -1 if not used.
int m_iImageControlIndex; // eHowToPlay_ImageNone if not used.
int m_iLabelStartIndex; // index of the labels if there are any for the
// page
int m_iLabelCount;
};
class CScene_HowToPlay : public CXuiSceneImpl
{
class CScene_HowToPlay : public CXuiSceneImpl {
protected:
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
EHowToPlayPage m_eCurrPage;
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
EHowToPlayPage m_eCurrPage;
// Control and Element wrapper objects.
CXuiHtmlElement m_aTextControls[ eHowToPlay_NumTexts ];
CXuiControl m_aImageControls[ eHowToPlay_NumImages ];
CXuiControl m_aLabelControls[ eHowToPlay_NumLabels ];
// Control and Element wrapper objects.
CXuiHtmlElement m_aTextControls[eHowToPlay_NumTexts];
CXuiControl m_aImageControls[eHowToPlay_NumImages];
CXuiControl m_aLabelControls[eHowToPlay_NumLabels];
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiHtmlControlMultiplayer, m_aTextControls[ eHowToPlay_TextMultiplayer ] )
MAP_CONTROL(IDC_XuiHtmlControlBasics, m_aTextControls[ eHowToPlay_TextBasics ] )
MAP_CONTROL(IDC_XuiHtmlControlHUD, m_aTextControls[ eHowToPlay_TextHUD ] )
MAP_CONTROL(IDC_XuiHtmlControlCreative, m_aTextControls[ eHowToPlay_TextCreative ] )
MAP_CONTROL(IDC_XuiHtmlControlInventory, m_aTextControls[ eHowToPlay_TextInventory ] )
MAP_CONTROL(IDC_XuiHtmlControlChest, m_aTextControls[ eHowToPlay_TextSmallChest ] )
MAP_CONTROL(IDC_XuiHtmlControlLargeChest, m_aTextControls[ eHowToPlay_TextLargeChest ] )
MAP_CONTROL(IDC_XuiHtmlControlEnderchest, m_aTextControls[ eHowToPlay_TextEnderchest ] )
MAP_CONTROL(IDC_XuiHtmlControlCrafting, m_aTextControls[ eHowToPlay_TextCrafting ] )
MAP_CONTROL(IDC_XuiHtmlControlCraftingTable, m_aTextControls[ eHowToPlay_TextCraftTable ] )
MAP_CONTROL(IDC_XuiHtmlControlFurnace, m_aTextControls[ eHowToPlay_TextFurnace ] )
MAP_CONTROL(IDC_XuiHtmlControlDispenser, m_aTextControls[ eHowToPlay_TextDispenser ] )
MAP_CONTROL(IDC_XuiHtmlControlBrewing, m_aTextControls[ eHowToPlay_TextBrewing ] )
MAP_CONTROL(IDC_XuiHtmlControlEnchantment, m_aTextControls[ eHowToPlay_TextEnchantment ] )
MAP_CONTROL(IDC_XuiHtmlControlAnvil, m_aTextControls[ eHowToPlay_TextAnvil ] )
MAP_CONTROL(IDC_XuiHtmlControlFarmingAnimals, m_aTextControls[ eHowToPlay_TextFarmingAnimals ] )
MAP_CONTROL(IDC_XuiHtmlControlBreeding, m_aTextControls[ eHowToPlay_TextBreeding ] )
MAP_CONTROL(IDC_XuiHtmlControlTrading, m_aTextControls[ eHowToPlay_TextTrading ] )
MAP_CONTROL(IDC_XuiHtmlControlNetherPortal, m_aTextControls[ eHowToPlay_TextNetherPortal ] )
MAP_CONTROL(IDC_XuiHtmlControlTheEnd, m_aTextControls[ eHowToPlay_TextTheEnd ] )
MAP_CONTROL(IDC_XuiHtmlControlSocialMedia, m_aTextControls[ eHowToPlay_TextSocialMedia ] )
MAP_CONTROL(IDC_XuiHtmlControlBanList, m_aTextControls[ eHowToPlay_TextBanList ] )
MAP_CONTROL(IDC_XuiHtmlControlWhatsNew, m_aTextControls[ eHowToPlay_TextWhatsNew ] )
MAP_CONTROL(IDC_XuiHtmlControlHostOptions, m_aTextControls[ eHowToPlay_TextHostOptions] )
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiHtmlControlMultiplayer,
m_aTextControls[eHowToPlay_TextMultiplayer])
MAP_CONTROL(IDC_XuiHtmlControlBasics,
m_aTextControls[eHowToPlay_TextBasics])
MAP_CONTROL(IDC_XuiHtmlControlHUD, m_aTextControls[eHowToPlay_TextHUD])
MAP_CONTROL(IDC_XuiHtmlControlCreative,
m_aTextControls[eHowToPlay_TextCreative])
MAP_CONTROL(IDC_XuiHtmlControlInventory,
m_aTextControls[eHowToPlay_TextInventory])
MAP_CONTROL(IDC_XuiHtmlControlChest,
m_aTextControls[eHowToPlay_TextSmallChest])
MAP_CONTROL(IDC_XuiHtmlControlLargeChest,
m_aTextControls[eHowToPlay_TextLargeChest])
MAP_CONTROL(IDC_XuiHtmlControlEnderchest,
m_aTextControls[eHowToPlay_TextEnderchest])
MAP_CONTROL(IDC_XuiHtmlControlCrafting,
m_aTextControls[eHowToPlay_TextCrafting])
MAP_CONTROL(IDC_XuiHtmlControlCraftingTable,
m_aTextControls[eHowToPlay_TextCraftTable])
MAP_CONTROL(IDC_XuiHtmlControlFurnace,
m_aTextControls[eHowToPlay_TextFurnace])
MAP_CONTROL(IDC_XuiHtmlControlDispenser,
m_aTextControls[eHowToPlay_TextDispenser])
MAP_CONTROL(IDC_XuiHtmlControlBrewing,
m_aTextControls[eHowToPlay_TextBrewing])
MAP_CONTROL(IDC_XuiHtmlControlEnchantment,
m_aTextControls[eHowToPlay_TextEnchantment])
MAP_CONTROL(IDC_XuiHtmlControlAnvil, m_aTextControls[eHowToPlay_TextAnvil])
MAP_CONTROL(IDC_XuiHtmlControlFarmingAnimals,
m_aTextControls[eHowToPlay_TextFarmingAnimals])
MAP_CONTROL(IDC_XuiHtmlControlBreeding,
m_aTextControls[eHowToPlay_TextBreeding])
MAP_CONTROL(IDC_XuiHtmlControlTrading,
m_aTextControls[eHowToPlay_TextTrading])
MAP_CONTROL(IDC_XuiHtmlControlNetherPortal,
m_aTextControls[eHowToPlay_TextNetherPortal])
MAP_CONTROL(IDC_XuiHtmlControlTheEnd,
m_aTextControls[eHowToPlay_TextTheEnd])
MAP_CONTROL(IDC_XuiHtmlControlSocialMedia,
m_aTextControls[eHowToPlay_TextSocialMedia])
MAP_CONTROL(IDC_XuiHtmlControlBanList,
m_aTextControls[eHowToPlay_TextBanList])
MAP_CONTROL(IDC_XuiHtmlControlWhatsNew,
m_aTextControls[eHowToPlay_TextWhatsNew])
MAP_CONTROL(IDC_XuiHtmlControlHostOptions,
m_aTextControls[eHowToPlay_TextHostOptions])
MAP_CONTROL(IDC_XuiImageHUD, m_aImageControls[ eHowToPlay_ImageHUD ] )
MAP_CONTROL(IDC_XuiImageCreative, m_aImageControls[ eHowToPlay_ImageCreative ] )
MAP_CONTROL(IDC_XuiImageInventory, m_aImageControls[ eHowToPlay_ImageInventory ] )
MAP_CONTROL(IDC_XuiImageChest, m_aImageControls[ eHowToPlay_ImageChest ] )
MAP_CONTROL(IDC_XuiImageLargeChest, m_aImageControls[ eHowToPlay_ImageLargeChest ] )
MAP_CONTROL(IDC_XuiImageEnderchest, m_aImageControls[ eHowToPlay_ImageEnderChest ] )
MAP_CONTROL(IDC_XuiImageCrafting, m_aImageControls[ eHowToPlay_ImageInventoryCrafting ] )
MAP_CONTROL(IDC_XuiImageCraftingTable, m_aImageControls[ eHowToPlay_ImageCraftingTable ] )
MAP_CONTROL(IDC_XuiImageFurnace, m_aImageControls[ eHowToPlay_ImageFurnace ] )
MAP_CONTROL(IDC_XuiImageDispenser, m_aImageControls[ eHowToPlay_ImageDispenser ] )
MAP_CONTROL(IDC_XuiImageBrewing, m_aImageControls[ eHowToPlay_ImageBrewing ] )
MAP_CONTROL(IDC_XuiImageEnchantment, m_aImageControls[ eHowToPlay_ImageEnchantment ] )
MAP_CONTROL(IDC_XuiImageAnvil, m_aImageControls[ eHowToPlay_ImageAnvil ] )
MAP_CONTROL(IDC_XuiImageBreeding, m_aImageControls[ eHowToPlay_ImageBreeding ] )
MAP_CONTROL(IDC_XuiImageFarmingAnimals, m_aImageControls[ eHowToPlay_ImageFarmingAnimals ] )
MAP_CONTROL(IDC_XuiImageTrading, m_aImageControls[ eHowToPlay_ImageTrading ] )
MAP_CONTROL(IDC_XuiImageNetherPortal, m_aImageControls[ eHowToPlay_ImageNetherPortal ] )
MAP_CONTROL(IDC_XuiImageTheEnd, m_aImageControls[ eHowToPlay_ImageTheEnd ] )
MAP_CONTROL(IDC_XuiImageHUD, m_aImageControls[eHowToPlay_ImageHUD])
MAP_CONTROL(IDC_XuiImageCreative,
m_aImageControls[eHowToPlay_ImageCreative])
MAP_CONTROL(IDC_XuiImageInventory,
m_aImageControls[eHowToPlay_ImageInventory])
MAP_CONTROL(IDC_XuiImageChest, m_aImageControls[eHowToPlay_ImageChest])
MAP_CONTROL(IDC_XuiImageLargeChest,
m_aImageControls[eHowToPlay_ImageLargeChest])
MAP_CONTROL(IDC_XuiImageEnderchest,
m_aImageControls[eHowToPlay_ImageEnderChest])
MAP_CONTROL(IDC_XuiImageCrafting,
m_aImageControls[eHowToPlay_ImageInventoryCrafting])
MAP_CONTROL(IDC_XuiImageCraftingTable,
m_aImageControls[eHowToPlay_ImageCraftingTable])
MAP_CONTROL(IDC_XuiImageFurnace, m_aImageControls[eHowToPlay_ImageFurnace])
MAP_CONTROL(IDC_XuiImageDispenser,
m_aImageControls[eHowToPlay_ImageDispenser])
MAP_CONTROL(IDC_XuiImageBrewing, m_aImageControls[eHowToPlay_ImageBrewing])
MAP_CONTROL(IDC_XuiImageEnchantment,
m_aImageControls[eHowToPlay_ImageEnchantment])
MAP_CONTROL(IDC_XuiImageAnvil, m_aImageControls[eHowToPlay_ImageAnvil])
MAP_CONTROL(IDC_XuiImageBreeding,
m_aImageControls[eHowToPlay_ImageBreeding])
MAP_CONTROL(IDC_XuiImageFarmingAnimals,
m_aImageControls[eHowToPlay_ImageFarmingAnimals])
MAP_CONTROL(IDC_XuiImageTrading, m_aImageControls[eHowToPlay_ImageTrading])
MAP_CONTROL(IDC_XuiImageNetherPortal,
m_aImageControls[eHowToPlay_ImageNetherPortal])
MAP_CONTROL(IDC_XuiImageTheEnd, m_aImageControls[eHowToPlay_ImageTheEnd])
MAP_CONTROL(IDC_CTItem, m_aLabelControls[ eHowToPlay_LabelCTItem ] )
MAP_CONTROL(IDC_CTGroup, m_aLabelControls[ eHowToPlay_LabelCTGroup ] )
MAP_CONTROL(IDC_CTInventory3x3, m_aLabelControls[ eHowToPlay_LabelCTInventory3x3 ] )
MAP_CONTROL(IDC_CItem, m_aLabelControls[ eHowToPlay_LabelCItem ] )
MAP_CONTROL(IDC_CGroup, m_aLabelControls[ eHowToPlay_LabelCGroup ] )
MAP_CONTROL(IDC_CInventory, m_aLabelControls[ eHowToPlay_LabelCInventory2x2 ] )
MAP_CONTROL(IDC_FFuel, m_aLabelControls[ eHowToPlay_LabelFFuel ] )
MAP_CONTROL(IDC_FInventory, m_aLabelControls[ eHowToPlay_LabelFInventory ] )
MAP_CONTROL(IDC_FIngredient, m_aLabelControls[ eHowToPlay_LabelFIngredient ] )
MAP_CONTROL(IDC_FChest, m_aLabelControls[ eHowToPlay_LabelFChest ] )
MAP_CONTROL(IDC_LCInventory, m_aLabelControls[ eHowToPlay_LabelLCInventory ] )
MAP_CONTROL(IDC_CIGroup, m_aLabelControls[ eHowToPlay_LabelCreativeInventory ] )
MAP_CONTROL(IDC_LCChest, m_aLabelControls[ eHowToPlay_LabelLCChest ] )
MAP_CONTROL(IDC_SCInventory, m_aLabelControls[ eHowToPlay_LabelSCInventory ] )
MAP_CONTROL(IDC_SCChest, m_aLabelControls[ eHowToPlay_LabelSCChest ] )
MAP_CONTROL(IDC_IInventory, m_aLabelControls[ eHowToPlay_LabelIInventory ] )
MAP_CONTROL(IDC_DInventory, m_aLabelControls[ eHowToPlay_LabelDInventory ] )
MAP_CONTROL(IDC_DText, m_aLabelControls[ eHowToPlay_LabelDText ] )
MAP_CONTROL(IDC_EEnchant, m_aLabelControls[ eHowToPlay_LabelEEnchant ] )
MAP_CONTROL(IDC_EInventory, m_aLabelControls[ eHowToPlay_LabelEInventory ] )
MAP_CONTROL(IDC_BBrew, m_aLabelControls[ eHowToPlay_LabelBBrew ] )
MAP_CONTROL(IDC_BInventory, m_aLabelControls[ eHowToPlay_LabelBInventory ] )
MAP_CONTROL(IDC_AInventory, m_aLabelControls[ eHowToPlay_LabelAnvil_Inventory ] )
MAP_CONTROL(IDC_ACost, m_aLabelControls[ eHowToPlay_LabelAnvil_Cost ] )
MAP_CONTROL(IDC_ARepairAndName, m_aLabelControls[ eHowToPlay_LabelAnvil_ARepairAndName ] )
MAP_CONTROL(IDC_TInventory, m_aLabelControls[ eHowToPlay_LabelTrading_Inventory ] )
//MAP_CONTROL(IDC_TOffer2Label, m_aLabelControls[ eHowToPlay_LabelTrading_Offer2 ] )
MAP_CONTROL(IDC_TOffer1Label, m_aLabelControls[ eHowToPlay_LabelTrading_Offer1 ] )
MAP_CONTROL(IDC_TNeededForTrade, m_aLabelControls[ eHowToPlay_LabelTrading_NeededForTrade ] )
MAP_CONTROL(IDC_TVillagerOffers, m_aLabelControls[ eHowToPlay_LabelTrading_VillagerOffers ] )
MAP_CONTROL(IDC_CTItem, m_aLabelControls[eHowToPlay_LabelCTItem])
MAP_CONTROL(IDC_CTGroup, m_aLabelControls[eHowToPlay_LabelCTGroup])
MAP_CONTROL(IDC_CTInventory3x3,
m_aLabelControls[eHowToPlay_LabelCTInventory3x3])
MAP_CONTROL(IDC_CItem, m_aLabelControls[eHowToPlay_LabelCItem])
MAP_CONTROL(IDC_CGroup, m_aLabelControls[eHowToPlay_LabelCGroup])
MAP_CONTROL(IDC_CInventory, m_aLabelControls[eHowToPlay_LabelCInventory2x2])
MAP_CONTROL(IDC_FFuel, m_aLabelControls[eHowToPlay_LabelFFuel])
MAP_CONTROL(IDC_FInventory, m_aLabelControls[eHowToPlay_LabelFInventory])
MAP_CONTROL(IDC_FIngredient, m_aLabelControls[eHowToPlay_LabelFIngredient])
MAP_CONTROL(IDC_FChest, m_aLabelControls[eHowToPlay_LabelFChest])
MAP_CONTROL(IDC_LCInventory, m_aLabelControls[eHowToPlay_LabelLCInventory])
MAP_CONTROL(IDC_CIGroup,
m_aLabelControls[eHowToPlay_LabelCreativeInventory])
MAP_CONTROL(IDC_LCChest, m_aLabelControls[eHowToPlay_LabelLCChest])
MAP_CONTROL(IDC_SCInventory, m_aLabelControls[eHowToPlay_LabelSCInventory])
MAP_CONTROL(IDC_SCChest, m_aLabelControls[eHowToPlay_LabelSCChest])
MAP_CONTROL(IDC_IInventory, m_aLabelControls[eHowToPlay_LabelIInventory])
MAP_CONTROL(IDC_DInventory, m_aLabelControls[eHowToPlay_LabelDInventory])
MAP_CONTROL(IDC_DText, m_aLabelControls[eHowToPlay_LabelDText])
MAP_CONTROL(IDC_EEnchant, m_aLabelControls[eHowToPlay_LabelEEnchant])
MAP_CONTROL(IDC_EInventory, m_aLabelControls[eHowToPlay_LabelEInventory])
MAP_CONTROL(IDC_BBrew, m_aLabelControls[eHowToPlay_LabelBBrew])
MAP_CONTROL(IDC_BInventory, m_aLabelControls[eHowToPlay_LabelBInventory])
MAP_CONTROL(IDC_AInventory,
m_aLabelControls[eHowToPlay_LabelAnvil_Inventory])
MAP_CONTROL(IDC_ACost, m_aLabelControls[eHowToPlay_LabelAnvil_Cost])
MAP_CONTROL(IDC_ARepairAndName,
m_aLabelControls[eHowToPlay_LabelAnvil_ARepairAndName])
MAP_CONTROL(IDC_TInventory,
m_aLabelControls[eHowToPlay_LabelTrading_Inventory])
// MAP_CONTROL(IDC_TOffer2Label,
// m_aLabelControls[ eHowToPlay_LabelTrading_Offer2 ] )
MAP_CONTROL(IDC_TOffer1Label,
m_aLabelControls[eHowToPlay_LabelTrading_Offer1])
MAP_CONTROL(IDC_TNeededForTrade,
m_aLabelControls[eHowToPlay_LabelTrading_NeededForTrade])
MAP_CONTROL(IDC_TVillagerOffers,
m_aLabelControls[eHowToPlay_LabelTrading_VillagerOffers])
END_CONTROL_MAP()
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
void StartPage(EHowToPlayPage ePage);
void StartPage( EHowToPlayPage ePage );
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_HowToPlay, L"CScene_HowToPlay", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_HowToPlay, L"CScene_HowToPlay", XUI_CLASS_SCENE)
};

View File

@@ -1,38 +1,32 @@
#pragma once
#define BEGIN_CONTROL_MAP() \
HRESULT MapChildControls() \
{ \
HRESULT hr = S_OK; \
CXuiElement e = m_hObj; \
#define BEGIN_CONTROL_MAP() \
HRESULT MapChildControls() { \
HRESULT hr = S_OK; \
CXuiElement e = m_hObj;
#define MAP_CONTROL(name, member) \
hr = e.GetChildById(name, &member); \
assert(hr == 0);
#define MAP_CONTROL(name, member) \
hr = e.GetChildById(name, &member); \
assert(hr==0); \
#define BEGIN_MAP_CHILD_CONTROLS( member ) \
{ \
CXuiElement tempE = e; \
e = member; \
#define BEGIN_MAP_CHILD_CONTROLS(member) \
{ \
CXuiElement tempE = e; \
e = member;
#define END_MAP_CHILD_CONTROLS() \
e = tempE; \
} \
#define MAP_OVERRIDE(name, member) \
{ \
HXUIOBJ h; \
hr = e.GetChildById(name, &h); \
assert(hr==0); \
hr = XuiObjectFromHandle(h, reinterpret_cast<PVOID*>(&member)); \
assert(hr==0); \
} \
e = tempE; \
}
#define MAP_OVERRIDE(name, member) \
{ \
HXUIOBJ h; \
hr = e.GetChildById(name, &h); \
assert(hr == 0); \
hr = XuiObjectFromHandle(h, reinterpret_cast<PVOID*>(&member)); \
assert(hr == 0); \
}
#define END_CONTROL_MAP() \
return hr; \
} \
return hr; \
}

View File

@@ -4,229 +4,209 @@
#include "XUI_HowToPlayMenu.h"
#include "XUI_HelpHowToPlay.h"
// strings for buttons in the list
unsigned int CScene_HowToPlayMenu::m_uiHTPButtonNameA[]=
{
IDS_HOW_TO_PLAY_MENU_WHATSNEW, // eHTPButton_WhatsNew
IDS_HOW_TO_PLAY_MENU_BASICS, // eHTPButton_Basics,
IDS_HOW_TO_PLAY_MENU_MULTIPLAYER, // eHTPButton_Multiplayer
IDS_HOW_TO_PLAY_MENU_HUD, // eHTPButton_Hud,
IDS_HOW_TO_PLAY_MENU_CREATIVE, // eHTPButton_Creative,
IDS_HOW_TO_PLAY_MENU_INVENTORY, // eHTPButton_Inventory,
IDS_HOW_TO_PLAY_MENU_CHESTS, // eHTPButton_Chest,
IDS_HOW_TO_PLAY_MENU_CRAFTING, // eHTPButton_Crafting,
IDS_HOW_TO_PLAY_MENU_FURNACE, // eHTPButton_Furnace,
IDS_HOW_TO_PLAY_MENU_DISPENSER, // eHTPButton_Dispenser,
// strings for buttons in the list
unsigned int CScene_HowToPlayMenu::m_uiHTPButtonNameA[] = {
IDS_HOW_TO_PLAY_MENU_WHATSNEW, // eHTPButton_WhatsNew
IDS_HOW_TO_PLAY_MENU_BASICS, // eHTPButton_Basics,
IDS_HOW_TO_PLAY_MENU_MULTIPLAYER, // eHTPButton_Multiplayer
IDS_HOW_TO_PLAY_MENU_HUD, // eHTPButton_Hud,
IDS_HOW_TO_PLAY_MENU_CREATIVE, // eHTPButton_Creative,
IDS_HOW_TO_PLAY_MENU_INVENTORY, // eHTPButton_Inventory,
IDS_HOW_TO_PLAY_MENU_CHESTS, // eHTPButton_Chest,
IDS_HOW_TO_PLAY_MENU_CRAFTING, // eHTPButton_Crafting,
IDS_HOW_TO_PLAY_MENU_FURNACE, // eHTPButton_Furnace,
IDS_HOW_TO_PLAY_MENU_DISPENSER, // eHTPButton_Dispenser,
IDS_HOW_TO_PLAY_MENU_BREWING, // eHTPButton_Brewing,
IDS_HOW_TO_PLAY_MENU_ENCHANTMENT, // eHTPButton_Enchantment,
IDS_HOW_TO_PLAY_MENU_ANVIL,
IDS_HOW_TO_PLAY_MENU_FARMANIMALS, // eHTPButton_Breeding,
IDS_HOW_TO_PLAY_MENU_BREEDANIMALS, // eHTPButton_Breeding,
IDS_HOW_TO_PLAY_MENU_TRADING,
IDS_HOW_TO_PLAY_MENU_BREWING, // eHTPButton_Brewing,
IDS_HOW_TO_PLAY_MENU_ENCHANTMENT, // eHTPButton_Enchantment,
IDS_HOW_TO_PLAY_MENU_ANVIL,
IDS_HOW_TO_PLAY_MENU_FARMANIMALS, // eHTPButton_Breeding,
IDS_HOW_TO_PLAY_MENU_BREEDANIMALS, // eHTPButton_Breeding,
IDS_HOW_TO_PLAY_MENU_TRADING,
IDS_HOW_TO_PLAY_MENU_NETHERPORTAL, // eHTPButton_NetherPortal,
IDS_HOW_TO_PLAY_MENU_THEEND, // eHTPButton_TheEnd,
IDS_HOW_TO_PLAY_MENU_SOCIALMEDIA, // eHTPButton_SocialMedia,
IDS_HOW_TO_PLAY_MENU_BANLIST, // eHTPButton_BanningLevels,
IDS_HOW_TO_PLAY_MENU_HOSTOPTIONS, // eHTPButton_HostOptions,
IDS_HOW_TO_PLAY_MENU_NETHERPORTAL, // eHTPButton_NetherPortal,
IDS_HOW_TO_PLAY_MENU_THEEND, // eHTPButton_TheEnd,
IDS_HOW_TO_PLAY_MENU_SOCIALMEDIA, // eHTPButton_SocialMedia,
IDS_HOW_TO_PLAY_MENU_BANLIST, // eHTPButton_BanningLevels,
IDS_HOW_TO_PLAY_MENU_HOSTOPTIONS, // eHTPButton_HostOptions,
};
// mapping the buttons to a scene value
unsigned int CScene_HowToPlayMenu::m_uiHTPSceneA[]=
{
eHowToPlay_WhatsNew,
eHowToPlay_Basics,
eHowToPlay_Multiplayer,
eHowToPlay_HUD,
eHowToPlay_Creative,
eHowToPlay_Inventory,
eHowToPlay_Chest,
eHowToPlay_InventoryCrafting,
eHowToPlay_Furnace,
eHowToPlay_Dispenser,
unsigned int CScene_HowToPlayMenu::m_uiHTPSceneA[] = {
eHowToPlay_WhatsNew, eHowToPlay_Basics,
eHowToPlay_Multiplayer, eHowToPlay_HUD,
eHowToPlay_Creative, eHowToPlay_Inventory,
eHowToPlay_Chest, eHowToPlay_InventoryCrafting,
eHowToPlay_Furnace, eHowToPlay_Dispenser,
eHowToPlay_Brewing,
eHowToPlay_Enchantment,
eHowToPlay_Anvil,
eHowToPlay_FarmingAnimals,
eHowToPlay_Breeding,
eHowToPlay_Trading,
eHowToPlay_Brewing, eHowToPlay_Enchantment,
eHowToPlay_Anvil, eHowToPlay_FarmingAnimals,
eHowToPlay_Breeding, eHowToPlay_Trading,
eHowToPlay_NetherPortal,
eHowToPlay_TheEnd,
eHowToPlay_SocialMedia,
eHowToPlay_BanList,
eHowToPlay_HostOptions,
eHowToPlay_NetherPortal, eHowToPlay_TheEnd,
eHowToPlay_SocialMedia, eHowToPlay_BanList,
eHowToPlay_HostOptions,
};
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_HowToPlayMenu::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *(int *)pInitData->pvInitData;
// if we're not in the game, we need to use basescene 0
bool bNotInGame=(Minecraft::GetInstance()->level==NULL);
bool bSplitscreen= app.GetLocalPlayerCount()>1;
m_ButtonList=NULL;
HRESULT CScene_HowToPlayMenu::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
m_iPad = *(int*)pInitData->pvInitData;
// if we're not in the game, we need to use basescene 0
bool bNotInGame = (Minecraft::GetInstance()->level == NULL);
bool bSplitscreen = app.GetLocalPlayerCount() > 1;
m_ButtonList = NULL;
//MapChildControls();
// MapChildControls();
//m_iButtons=0;
if(bSplitscreen)
{
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad, false);
}
// m_iButtons=0;
if (bSplitscreen) {
app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad, false);
}
// 4J-PB - changing all versions to use a list of buttons, since we're adding some
// We're going to use a list of buttons here
CXuiElement e = m_hObj;
HRESULT hr = e.GetChildById(L"HowToListButtons", &m_ButtonList);
m_iButtons=eHTPButton_Max;
for(int i=0;i<eHTPButton_Max;i++)
{
//m_Buttons[i].SetShow(FALSE);
//m_Buttons[i].SetEnable(FALSE);
m_ButtonList.InsertItems( m_ButtonList.GetItemCount(), 1 );
}
// 4J-PB - changing all versions to use a list of buttons, since we're
// adding some We're going to use a list of buttons here
CXuiElement e = m_hObj;
HRESULT hr = e.GetChildById(L"HowToListButtons", &m_ButtonList);
m_iButtons = eHTPButton_Max;
for (int i = 0; i < eHTPButton_Max; i++) {
// m_Buttons[i].SetShow(FALSE);
// m_Buttons[i].SetEnable(FALSE);
m_ButtonList.InsertItems(m_ButtonList.GetItemCount(), 1);
}
// set the focus to the list
m_ButtonList.SetFocus(m_iPad);
// set the focus to the list
m_ButtonList.SetFocus(m_iPad);
if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) || bSplitscreen)
{
if(bNotInGame)
{
CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, FALSE );
}
else
{
CXuiSceneBase::ShowLogo( m_iPad, FALSE );
}
}
else if(bNotInGame)
{
CXuiSceneBase::ShowLogo( DEFAULT_XUI_MENU_USER, TRUE );
}
else
{
CXuiSceneBase::ShowLogo( m_iPad, TRUE );
}
// Display the tooltips
// if we're not in the game, we need to use basescene 0
if(bNotInGame)
{
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
else
{
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
}
if ((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) ||
bSplitscreen) {
if (bNotInGame) {
CXuiSceneBase::ShowLogo(DEFAULT_XUI_MENU_USER, FALSE);
} else {
CXuiSceneBase::ShowLogo(m_iPad, FALSE);
}
} else if (bNotInGame) {
CXuiSceneBase::ShowLogo(DEFAULT_XUI_MENU_USER, TRUE);
} else {
CXuiSceneBase::ShowLogo(m_iPad, TRUE);
}
// Display the tooltips
// if we're not in the game, we need to use basescene 0
if (bNotInGame) {
ui.SetTooltips(DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,
IDS_TOOLTIPS_BACK);
} else {
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK);
}
return S_OK;
return S_OK;
}
HRESULT CScene_HowToPlayMenu::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled)
{
if( pGetSourceTextData->bItemData )
{
if( pGetSourceTextData->iItem < (int)eHTPButton_Max )
{
pGetSourceTextData->szText = app.GetString(m_uiHTPButtonNameA[pGetSourceTextData->iItem]);//m_Buttons[pGetSourceTextData->iItem].GetText();
pGetSourceTextData->bDisplay = TRUE;
HRESULT CScene_HowToPlayMenu::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
if (pGetSourceTextData->bItemData) {
if (pGetSourceTextData->iItem < (int)eHTPButton_Max) {
pGetSourceTextData->szText = app.GetString(
m_uiHTPButtonNameA
[pGetSourceTextData
->iItem]); // m_Buttons[pGetSourceTextData->iItem].GetText();
pGetSourceTextData->bDisplay = TRUE;
bHandled = TRUE;
}
}
return S_OK;
bHandled = TRUE;
}
}
return S_OK;
}
HRESULT CScene_HowToPlayMenu::OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled)
{
pGetItemCountData->cItems = m_iButtons;
bHandled = TRUE;
return S_OK;
HRESULT CScene_HowToPlayMenu::OnGetItemCountAll(
XUIMessageGetItemCount* pGetItemCountData, BOOL& bHandled) {
pGetItemCountData->cItems = m_iButtons;
bHandled = TRUE;
return S_OK;
}
HRESULT CScene_HowToPlayMenu::OnNotifySelChanged(
HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled) {
// In a list, we need to play the 'focus' sound ourselves
if ((pNotifySelChangedData->iOldItem != -1) && m_ButtonList &&
(hObjSource == m_ButtonList.m_hObj)) {
CXuiSceneBase::PlayUISFX(eSFX_Focus);
}
HRESULT CScene_HowToPlayMenu::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelChanged *pNotifySelChangedData, BOOL& bHandled)
{
// In a list, we need to play the 'focus' sound ourselves
if((pNotifySelChangedData->iOldItem!=-1) && m_ButtonList && (hObjSource==m_ButtonList.m_hObj))
{
CXuiSceneBase::PlayUISFX(eSFX_Focus);
}
return S_OK;
return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_HowToPlayMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
unsigned int uiInitData;
unsigned int uiButtonCounter=0;
HRESULT CScene_HowToPlayMenu::OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData,
BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
unsigned int uiInitData;
unsigned int uiButtonCounter = 0;
// 4J-PB - now using a list for all resolutions
//if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) || app.GetLocalPlayerCount()>1)
{
if(hObjPressed==m_ButtonList && m_ButtonList.TreeHasFocus() && (m_ButtonList.GetItemCount() > 0) && (m_ButtonList.GetCurSel() < (int)eHTPButton_Max) )
{
uiButtonCounter=m_ButtonList.GetCurSel();
}
}
/*else
{
while((uiButtonCounter<BUTTONS_HTP_MAX) && (m_Buttons[uiButtonCounter]!=hObjPressed)) uiButtonCounter++;
}*/
// 4J-PB - now using a list for all resolutions
// if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) ||
// app.GetLocalPlayerCount()>1)
{
if (hObjPressed == m_ButtonList && m_ButtonList.TreeHasFocus() &&
(m_ButtonList.GetItemCount() > 0) &&
(m_ButtonList.GetCurSel() < (int)eHTPButton_Max)) {
uiButtonCounter = m_ButtonList.GetCurSel();
}
}
/*else
{
while((uiButtonCounter<BUTTONS_HTP_MAX) &&
(m_Buttons[uiButtonCounter]!=hObjPressed)) uiButtonCounter++;
}*/
// Determine which button was pressed,
// and call the appropriate function.
// Determine which button was pressed,
// and call the appropriate function.
uiInitData = ( ( 1 << 31 ) | ( m_uiHTPSceneA[uiButtonCounter] << 16 ) | ( short )( m_iPad ) );
if(app.GetLocalPlayerCount()>1)
{
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_HowToPlay, ( void* )( uiInitData ) );
}
else
{
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_HowToPlay, ( void* )( uiInitData ) );
}
rfHandled=TRUE;
return S_OK;
uiInitData =
((1 << 31) | (m_uiHTPSceneA[uiButtonCounter] << 16) | (short)(m_iPad));
if (app.GetLocalPlayerCount() > 1) {
app.NavigateToScene(pNotifyPressData->UserIndex, eUIScene_HowToPlay,
(void*)(uiInitData));
} else {
app.NavigateToScene(pNotifyPressData->UserIndex, eUIScene_HowToPlay,
(void*)(uiInitData));
}
rfHandled = TRUE;
return S_OK;
}
HRESULT CScene_HowToPlayMenu::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_HowToPlayMenu::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
switch(pInputData->dwKeyCode)
{
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_ESCAPE:
app.NavigateBack(pInputData->UserIndex);
rfHandled = TRUE;
case VK_PAD_B:
case VK_ESCAPE:
app.NavigateBack(pInputData->UserIndex);
rfHandled = TRUE;
break;
}
break;
}
return S_OK;
return S_OK;
}
HRESULT CScene_HowToPlayMenu::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled)
{
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
HRESULT CScene_HowToPlayMenu::OnNavReturn(HXUIOBJ hObj, BOOL& rfHandled) {
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK);
return S_OK;
return S_OK;
}
HRESULT CScene_HowToPlayMenu::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining,false);
HRESULT CScene_HowToPlayMenu::OnCustomMessage_Splitscreenplayer(
bool bJoining, BOOL& bHandled) {
bHandled = true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj, &m_OriginalPosition,
m_iPad, bJoining, false);
}

View File

@@ -3,74 +3,75 @@
#include "../media/xuiscene_howtoplay_menu.h"
#include "XUI_CustomMessages.h"
class CScene_HowToPlayMenu : public CXuiSceneImpl
{
class CScene_HowToPlayMenu : public CXuiSceneImpl {
protected:
enum eHTPButton {
eHTPButton_WhatsNew = 0,
eHTPButton_Basics,
eHTPButton_Multiplayer,
eHTPButton_Hud,
eHTPButton_Creative,
eHTPButton_Inventory,
eHTPButton_Chest,
eHTPButton_Crafting,
eHTPButton_Furnace,
eHTPButton_Dispenser,
eHTPButton_Brewing,
eHTPButton_Enchantment,
eHTPButton_Anvil,
eHTPButton_FarmingAnimals,
eHTPButton_Breeding,
eHTPButton_Trading,
eHTPButton_NetherPortal,
eHTPButton_TheEnd,
eHTPButton_SocialMedia,
eHTPButton_BanningLevels,
eHTPButton_HostOptions,
eHTPButton_Max,
};
enum eHTPButton
{
eHTPButton_WhatsNew = 0,
eHTPButton_Basics,
eHTPButton_Multiplayer,
eHTPButton_Hud,
eHTPButton_Creative,
eHTPButton_Inventory,
eHTPButton_Chest,
eHTPButton_Crafting,
eHTPButton_Furnace,
eHTPButton_Dispenser,
eHTPButton_Brewing,
eHTPButton_Enchantment,
eHTPButton_Anvil,
eHTPButton_FarmingAnimals,
eHTPButton_Breeding,
eHTPButton_Trading,
eHTPButton_NetherPortal,
eHTPButton_TheEnd,
eHTPButton_SocialMedia,
eHTPButton_BanningLevels,
eHTPButton_HostOptions,
eHTPButton_Max,
};
// Control and Element wrapper objects.
CXuiScene m_Scene;
CXuiElement m_Background;
CXuiList m_ButtonList;
// Control and Element wrapper objects.
CXuiScene m_Scene;
CXuiElement m_Background;
CXuiList m_ButtonList;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_END_MSG_MAP()
XUI_END_MSG_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelChanged *pNotifySelChangedData, BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNavReturn(HXUIOBJ hObj, BOOL& rfHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_HowToPlayMenu, L"CScene_HowToPlayMenu", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_HowToPlayMenu, L"CScene_HowToPlayMenu",
XUI_CLASS_SCENE)
private:
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
static unsigned int m_uiHTPButtonNameA[eHTPButton_Max];
static unsigned int m_uiHTPSceneA[eHTPButton_Max];
int m_iButtons;
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
static unsigned int m_uiHTPButtonNameA[eHTPButton_Max];
static unsigned int m_uiHTPSceneA[eHTPButton_Max];
int m_iButtons;
};

View File

@@ -10,141 +10,141 @@
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_InGameHostOptions::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *(int *)pInitData->pvInitData;
HRESULT CScene_InGameHostOptions::OnInit(XUIMessageInit* pInitData,
BOOL& bHandled) {
m_iPad = *(int*)pInitData->pvInitData;
MapChildControls();
MapChildControls();
m_focusElement = m_CheckboxFireSpreads.m_hObj;
m_focusElement = m_CheckboxFireSpreads.m_hObj;
XuiControlSetText(m_CheckboxFireSpreads,app.GetString(IDS_FIRE_SPREADS));
XuiControlSetText(m_CheckboxTNTExplodes,app.GetString(IDS_TNT_EXPLODES));
XuiControlSetText(m_CheckboxFireSpreads, app.GetString(IDS_FIRE_SPREADS));
XuiControlSetText(m_CheckboxTNTExplodes, app.GetString(IDS_TNT_EXPLODES));
if(app.GetLocalPlayerCount()>1)
{
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad);
}
if (app.GetLocalPlayerCount() > 1) {
app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad);
}
m_CheckboxFireSpreads.SetEnable(TRUE);
m_CheckboxTNTExplodes.SetEnable(TRUE);
m_CheckboxFireSpreads.SetCheck((app.GetGameHostOption(eGameHostOption_FireSpreads)!=0)?TRUE:FALSE);
m_CheckboxTNTExplodes.SetCheck((app.GetGameHostOption(eGameHostOption_TNT)!=0)?TRUE:FALSE);
m_CheckboxFireSpreads.SetEnable(TRUE);
m_CheckboxTNTExplodes.SetEnable(TRUE);
m_CheckboxFireSpreads.SetCheck(
(app.GetGameHostOption(eGameHostOption_FireSpreads) != 0) ? TRUE
: FALSE);
m_CheckboxTNTExplodes.SetCheck(
(app.GetGameHostOption(eGameHostOption_TNT) != 0) ? TRUE : FALSE);
INetworkPlayer *localPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad );
unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId());
if ( app.GetGameHostOption(eGameHostOption_CheatsEnabled)
&& Player::getPlayerGamePrivilege(privs,Player::ePlayerGamePrivilege_CanTeleport)
&& (g_NetworkManager.GetPlayerCount() > 1) )
{
m_buttonTeleportToPlayer.SetText(app.GetString(IDS_TELEPORT_TO_PLAYER));
m_buttonTeleportToMe.SetText(app.GetString(IDS_TELEPORT_TO_ME));
}
else
{
removeControl(m_buttonTeleportToPlayer, true);
removeControl(m_buttonTeleportToMe, true);
}
INetworkPlayer* localPlayer =
g_NetworkManager.GetLocalPlayerByUserIndex(m_iPad);
unsigned int privs = app.GetPlayerPrivileges(localPlayer->GetSmallId());
if (app.GetGameHostOption(eGameHostOption_CheatsEnabled) &&
Player::getPlayerGamePrivilege(
privs, Player::ePlayerGamePrivilege_CanTeleport) &&
(g_NetworkManager.GetPlayerCount() > 1)) {
m_buttonTeleportToPlayer.SetText(app.GetString(IDS_TELEPORT_TO_PLAYER));
m_buttonTeleportToMe.SetText(app.GetString(IDS_TELEPORT_TO_ME));
} else {
removeControl(m_buttonTeleportToPlayer, true);
removeControl(m_buttonTeleportToMe, true);
}
ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK);
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK);
CXuiSceneBase::ShowLogo( m_iPad, FALSE );
CXuiSceneBase::ShowLogo(m_iPad, FALSE);
//SentientManager.RecordMenuShown(m_iPad, eUIScene_CreateWorldMenu, 0);
// SentientManager.RecordMenuShown(m_iPad, eUIScene_CreateWorldMenu, 0);
return S_OK;
return S_OK;
}
HRESULT CScene_InGameHostOptions::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_InGameHostOptions::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
// Explicitly handle B button presses
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_ESCAPE: {
unsigned int hostOptions =
app.GetGameHostOption(eGameHostOption_All);
app.SetGameHostOption(hostOptions, eGameHostOption_FireSpreads,
m_CheckboxFireSpreads.IsChecked());
app.SetGameHostOption(hostOptions, eGameHostOption_TNT,
m_CheckboxTNTExplodes.IsChecked());
// Explicitly handle B button presses
switch(pInputData->dwKeyCode)
{
case VK_PAD_B:
case VK_ESCAPE:
{
unsigned int hostOptions = app.GetGameHostOption(eGameHostOption_All);
app.SetGameHostOption(hostOptions,eGameHostOption_FireSpreads,m_CheckboxFireSpreads.IsChecked());
app.SetGameHostOption(hostOptions,eGameHostOption_TNT,m_CheckboxTNTExplodes.IsChecked());
// Send update settings packet to server
if (hostOptions != app.GetGameHostOption(eGameHostOption_All)) {
Minecraft* pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> player =
pMinecraft->localplayers[m_iPad];
if (player != NULL && player->connection) {
player->connection->send(std::shared_ptr<
ServerSettingsChangedPacket>(
new ServerSettingsChangedPacket(
ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS,
hostOptions)));
}
}
// Send update settings packet to server
if(hostOptions != app.GetGameHostOption(eGameHostOption_All) )
{
Minecraft *pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> player = pMinecraft->localplayers[m_iPad];
if(player != NULL && player->connection)
{
player->connection->send( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, hostOptions) ) );
}
}
app.NavigateBack(pInputData->UserIndex);
rfHandled = TRUE;
}
break;
}
return S_OK;
app.NavigateBack(pInputData->UserIndex);
rfHandled = TRUE;
} break;
}
return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_InGameHostOptions::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_InGameHostOptions::OnNotifyPressEx(
HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if(hObjPressed == m_buttonTeleportToPlayer || hObjPressed == m_buttonTeleportToMe)
{
TeleportMenuInitData *initData = new TeleportMenuInitData();
initData->iPad = m_iPad;
initData->teleportToPlayer = false;
if( hObjPressed == m_buttonTeleportToPlayer )
{
initData->teleportToPlayer = true;
}
ui.NavigateToScene(m_iPad,eUIScene_TeleportMenu,(void*)initData);
}
return S_OK;
if (hObjPressed == m_buttonTeleportToPlayer ||
hObjPressed == m_buttonTeleportToMe) {
TeleportMenuInitData* initData = new TeleportMenuInitData();
initData->iPad = m_iPad;
initData->teleportToPlayer = false;
if (hObjPressed == m_buttonTeleportToPlayer) {
initData->teleportToPlayer = true;
}
ui.NavigateToScene(m_iPad, eUIScene_TeleportMenu, (void*)initData);
}
return S_OK;
}
void CScene_InGameHostOptions::removeControl(HXUIOBJ hObjToRemove, bool center)
{
D3DXVECTOR3 pos;
float fControlHeight, fTempHeight, fWidth;
void CScene_InGameHostOptions::removeControl(HXUIOBJ hObjToRemove,
bool center) {
D3DXVECTOR3 pos;
float fControlHeight, fTempHeight, fWidth;
bool changeFocus = m_focusElement == hObjToRemove;
bool changeFocus = m_focusElement == hObjToRemove;
XuiElementGetBounds(hObjToRemove,&fWidth,&fControlHeight);
XuiElementGetBounds(hObjToRemove, &fWidth, &fControlHeight);
// Hide this control
XuiControlSetEnable(hObjToRemove, FALSE);
XuiElementSetShow(hObjToRemove, FALSE);
// Hide this control
XuiControlSetEnable(hObjToRemove, FALSE);
XuiElementSetShow(hObjToRemove, FALSE);
// Move future downwards nav up
HXUIOBJ controlToMove = hObjToRemove;
while(controlToMove = XuiControlGetNavigation(controlToMove, XUI_CONTROL_NAVIGATE_DOWN, FALSE, TRUE) )
{
if(changeFocus && XuiElementIsShown(controlToMove))
{
m_focusElement = controlToMove;
XuiElementSetUserFocus( controlToMove, m_iPad );
changeFocus = FALSE;
}
XuiElementGetPosition(controlToMove, &pos);
pos.y -= fControlHeight;
XuiElementSetPosition(controlToMove, &pos);
}
// Move future downwards nav up
HXUIOBJ controlToMove = hObjToRemove;
while (controlToMove = XuiControlGetNavigation(
controlToMove, XUI_CONTROL_NAVIGATE_DOWN, FALSE, TRUE)) {
if (changeFocus && XuiElementIsShown(controlToMove)) {
m_focusElement = controlToMove;
XuiElementSetUserFocus(controlToMove, m_iPad);
changeFocus = FALSE;
}
XuiElementGetPosition(controlToMove, &pos);
pos.y -= fControlHeight;
XuiElementSetPosition(controlToMove, &pos);
}
// Resize and move scene
GetBounds(&fWidth, &fTempHeight);
SetBounds(fWidth, fTempHeight - fControlHeight);
// Resize and move scene
GetBounds(&fWidth, &fTempHeight);
SetBounds(fWidth, fTempHeight - fControlHeight);
GetPosition(&pos);
pos.y += fControlHeight/2;
SetPosition(&pos);
GetPosition(&pos);
pos.y += fControlHeight / 2;
SetPosition(&pos);
}

View File

@@ -1,45 +1,44 @@
#pragma once
#include "../Media/xuiscene_ingame_host_options.h"
class CScene_InGameHostOptions : public CXuiSceneImpl
{
class CScene_InGameHostOptions : public CXuiSceneImpl {
protected:
CXuiScene m_GameOptionsGroup;
CXuiCheckbox m_CheckboxFireSpreads;
CXuiCheckbox m_CheckboxTNTExplodes;
CXuiControl m_buttonTeleportToPlayer, m_buttonTeleportToMe;
CXuiScene m_GameOptionsGroup;
CXuiCheckbox m_CheckboxFireSpreads;
CXuiCheckbox m_CheckboxTNTExplodes;
CXuiControl m_buttonTeleportToPlayer, m_buttonTeleportToMe;
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_END_MSG_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_GameOptions, m_GameOptionsGroup)
BEGIN_MAP_CHILD_CONTROLS(m_GameOptionsGroup)
MAP_CONTROL(IDC_CheckboxFireSpreads, m_CheckboxFireSpreads)
MAP_CONTROL(IDC_CheckboxTNT, m_CheckboxTNTExplodes)
MAP_CONTROL(IDC_ButtonTeleportToPlayer, m_buttonTeleportToPlayer)
MAP_CONTROL(IDC_ButtonTeleportPlayerToMe, m_buttonTeleportToMe)
END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_GameOptions, m_GameOptionsGroup)
BEGIN_MAP_CHILD_CONTROLS(m_GameOptionsGroup)
MAP_CONTROL(IDC_CheckboxFireSpreads, m_CheckboxFireSpreads)
MAP_CONTROL(IDC_CheckboxTNT, m_CheckboxTNTExplodes)
MAP_CONTROL(IDC_ButtonTeleportToPlayer, m_buttonTeleportToPlayer)
MAP_CONTROL(IDC_ButtonTeleportPlayerToMe, m_buttonTeleportToMe)
END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_InGameHostOptions, L"CScene_InGameHostOptions", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_InGameHostOptions, L"CScene_InGameHostOptions",
XUI_CLASS_SCENE)
private:
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
HXUIOBJ m_focusElement; // Only used for the remove control process
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
HXUIOBJ m_focusElement; // Only used for the remove control process
void removeControl(HXUIOBJ hObjToRemove, bool center);
void removeControl(HXUIOBJ hObjToRemove, bool center);
};

View File

@@ -22,516 +22,494 @@
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_InGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_bIgnoreKeyPresses=true;
m_iPad = *(int *)pInitData->pvInitData;
HRESULT CScene_InGameInfo::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
m_bIgnoreKeyPresses = true;
m_iPad = *(int*)pInitData->pvInitData;
MapChildControls();
MapChildControls();
XuiControlSetText(m_gameOptionsButton,app.GetString(IDS_HOST_OPTIONS));
XuiControlSetText(m_title,app.GetString(IDS_PLAYERS_INVITE));
XuiControlSetText(m_gameOptionsButton, app.GetString(IDS_HOST_OPTIONS));
XuiControlSetText(m_title, app.GetString(IDS_PLAYERS_INVITE));
if(app.GetLocalPlayerCount()>1)
{
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad);
}
if (app.GetLocalPlayerCount() > 1) {
app.AdjustSplitscreenScene(m_hObj, &m_OriginalPosition, m_iPad);
}
int playerCount = g_NetworkManager.GetPlayerCount();
int playerCount = g_NetworkManager.GetPlayerCount();
m_playersCount = 0;
for(int i = 0; i < playerCount; ++i)
{
INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i );
m_playersCount = 0;
for (int i = 0; i < playerCount; ++i) {
INetworkPlayer* player = g_NetworkManager.GetPlayerByIndex(i);
if( player != NULL )
{
m_players[i] = player->GetSmallId();
++m_playersCount;
}
}
if (player != NULL) {
m_players[i] = player->GetSmallId();
++m_playersCount;
}
}
g_NetworkManager.RegisterPlayerChangedCallback(m_iPad, &CScene_InGameInfo::OnPlayerChanged, this);
g_NetworkManager.RegisterPlayerChangedCallback(
m_iPad, &CScene_InGameInfo::OnPlayerChanged, this);
INetworkPlayer *thisPlayer = g_NetworkManager.GetLocalPlayerByUserIndex( m_iPad );
m_isHostPlayer = false;
if(thisPlayer != NULL) m_isHostPlayer = thisPlayer->IsHost() == TRUE;
INetworkPlayer* thisPlayer =
g_NetworkManager.GetLocalPlayerByUserIndex(m_iPad);
m_isHostPlayer = false;
if (thisPlayer != NULL) m_isHostPlayer = thisPlayer->IsHost() == TRUE;
Minecraft *pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> localPlayer = pMinecraft->localplayers[m_iPad];
if(!m_isHostPlayer && !localPlayer->isModerator() )
{
m_gameOptionsButton.SetEnable(FALSE);
m_gameOptionsButton.SetShow(FALSE);
playersList.SetFocus(m_iPad);
}
Minecraft* pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> localPlayer =
pMinecraft->localplayers[m_iPad];
if (!m_isHostPlayer && !localPlayer->isModerator()) {
m_gameOptionsButton.SetEnable(FALSE);
m_gameOptionsButton.SetShow(FALSE);
playersList.SetFocus(m_iPad);
}
int keyX = IDS_TOOLTIPS_INVITE_FRIENDS;
XPARTY_USER_LIST partyList;
if((XPartyGetUserList( &partyList ) != XPARTY_E_NOT_IN_PARTY ) && (partyList.dwUserCount>1))
{
keyX = IDS_TOOLTIPS_INVITE_PARTY;
}
if(g_NetworkManager.IsLocalGame()) keyX = -1;
int keyX = IDS_TOOLTIPS_INVITE_FRIENDS;
XPARTY_USER_LIST partyList;
if ((XPartyGetUserList(&partyList) != XPARTY_E_NOT_IN_PARTY) &&
(partyList.dwUserCount > 1)) {
keyX = IDS_TOOLTIPS_INVITE_PARTY;
}
if (g_NetworkManager.IsLocalGame()) keyX = -1;
int keyA = -1;
ui.SetTooltips( m_iPad, keyA,IDS_TOOLTIPS_BACK,keyX,-1);
int keyA = -1;
ui.SetTooltips(m_iPad, keyA, IDS_TOOLTIPS_BACK, keyX, -1);
CXuiSceneBase::ShowDarkOverlay( m_iPad, TRUE );
CXuiSceneBase::ShowDarkOverlay(m_iPad, TRUE);
SetTimer( TOOLTIP_TIMERID , INGAME_INFO_TOOLTIP_TIMER );
SetTimer(TOOLTIP_TIMERID, INGAME_INFO_TOOLTIP_TIMER);
// get rid of the quadrant display if it's on
CXuiSceneBase::HidePressStart();
// get rid of the quadrant display if it's on
CXuiSceneBase::HidePressStart();
SetTimer(IGNORE_KEYPRESS_TIMERID,IGNORE_KEYPRESS_TIME);
SetTimer(IGNORE_KEYPRESS_TIMERID, IGNORE_KEYPRESS_TIME);
return S_OK;
return S_OK;
}
HRESULT CScene_InGameInfo::OnDestroy()
{
XuiKillTimer(m_hObj,TOOLTIP_TIMERID);
g_NetworkManager.UnRegisterPlayerChangedCallback(m_iPad, &CScene_InGameInfo::OnPlayerChanged, this);
return S_OK;
HRESULT CScene_InGameInfo::OnDestroy() {
XuiKillTimer(m_hObj, TOOLTIP_TIMERID);
g_NetworkManager.UnRegisterPlayerChangedCallback(
m_iPad, &CScene_InGameInfo::OnPlayerChanged, this);
return S_OK;
}
//----------------------------------------------------------------------------------
// Updates the UI when the list selection changes.
//----------------------------------------------------------------------------------
HRESULT CScene_InGameInfo::OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled )
{
if( hObjSource == playersList)
{
updateTooltips();
HRESULT CScene_InGameInfo::OnNotifySelChanged(
HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled) {
if (hObjSource == playersList) {
updateTooltips();
bHandled = TRUE;
}
bHandled = TRUE;
}
return S_OK;
return S_OK;
}
HRESULT CScene_InGameInfo::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
if(m_bIgnoreKeyPresses) return S_OK;
HRESULT CScene_InGameInfo::OnKeyDown(XUIMessageInput* pInputData,
BOOL& rfHandled) {
if (m_bIgnoreKeyPresses) return S_OK;
// 4J-PB - ignore repeats to stop the scene displaying and quitting right away if you hold the back button down
if((pInputData->dwKeyCode==VK_PAD_BACK) &&(pInputData->dwFlags&XUI_INPUT_FLAG_REPEAT ))
{
rfHandled = TRUE;
return S_OK;
}
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
// 4J-PB - ignore repeats to stop the scene displaying and quitting right
// away if you hold the back button down
if ((pInputData->dwKeyCode == VK_PAD_BACK) &&
(pInputData->dwFlags & XUI_INPUT_FLAG_REPEAT)) {
rfHandled = TRUE;
return S_OK;
}
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT hr = S_OK;
switch(pInputData->dwKeyCode)
{
HRESULT hr = S_OK;
switch (pInputData->dwKeyCode) {
case VK_PAD_B:
case VK_PAD_BACK:
case VK_ESCAPE:
CXuiSceneBase::PlayUISFX(eSFX_Back);
app.CloseXuiScenes(pInputData->UserIndex);
rfHandled = TRUE;
case VK_PAD_B:
case VK_PAD_BACK:
case VK_ESCAPE:
CXuiSceneBase::PlayUISFX(eSFX_Back);
app.CloseXuiScenes(pInputData->UserIndex);
rfHandled = TRUE;
break;
case VK_PAD_Y:
if (playersList.TreeHasFocus() &&
(playersList.GetItemCount() > 0) &&
(playersList.GetCurSel() < m_playersCount)) {
INetworkPlayer* player = g_NetworkManager.GetPlayerBySmallId(
m_players[playersList.GetCurSel()]);
if (player != NULL) {
PlayerUID xuid = ((NetworkPlayerXbox*)player)->GetUID();
if (xuid != INVALID_XUID)
hr = XShowGamerCardUI(pInputData->UserIndex, xuid);
}
}
break;
case VK_PAD_X: {
if (!g_NetworkManager.IsLocalGame()) {
XPARTY_USER_LIST partyList;
if ((XPartyGetUserList(&partyList) != XPARTY_E_NOT_IN_PARTY) &&
(partyList.dwUserCount > 1)) {
hr = XShowPartyUI(pInputData->UserIndex);
} else {
hr = XShowFriendsUI(pInputData->UserIndex);
}
}
} break;
}
break;
case VK_PAD_Y:
if(playersList.TreeHasFocus() && (playersList.GetItemCount() > 0) && (playersList.GetCurSel() < m_playersCount) )
{
INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId(m_players[playersList.GetCurSel()]);
if( player != NULL )
{
PlayerUID xuid = ((NetworkPlayerXbox *)player)->GetUID();
if( xuid != INVALID_XUID )
hr = XShowGamerCardUI(pInputData->UserIndex, xuid);
}
}
break;
case VK_PAD_X:
{
if(!g_NetworkManager.IsLocalGame())
{
XPARTY_USER_LIST partyList;
if((XPartyGetUserList( &partyList ) != XPARTY_E_NOT_IN_PARTY) && (partyList.dwUserCount>1))
{
hr = XShowPartyUI( pInputData->UserIndex );
}
else
{
hr = XShowFriendsUI( pInputData->UserIndex );
}
}
}
break;
}
return hr;
return hr;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_InGameInfo::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_InGameInfo::OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData,
BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
if( hObjPressed == playersList )
{
INetworkPlayer *selectedPlayer = g_NetworkManager.GetPlayerBySmallId( m_players[ playersList.GetCurSel() ] );
Minecraft *pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> localPlayer = pMinecraft->localplayers[m_iPad];
if (hObjPressed == playersList) {
INetworkPlayer* selectedPlayer = g_NetworkManager.GetPlayerBySmallId(
m_players[playersList.GetCurSel()]);
bool isOp = m_isHostPlayer || localPlayer->isModerator();
bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0;
bool trust = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0;
Minecraft* pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> localPlayer =
pMinecraft->localplayers[m_iPad];
if( isOp && selectedPlayer != NULL && playersList.TreeHasFocus() && (playersList.GetItemCount() > 0) && (playersList.GetCurSel() < m_playersCount) )
{
bool editingHost = selectedPlayer->IsHost();
if( (cheats && (m_isHostPlayer || !editingHost ) )
|| (!trust && (m_isHostPlayer || !editingHost))
|| (m_isHostPlayer && !editingHost)
#if (!defined(_CONTENT_PACKAGE) && !defined(_FINAL_BUILD) && defined(_DEBUG_MENUS_ENABLED))
|| (m_isHostPlayer && editingHost)
bool isOp = m_isHostPlayer || localPlayer->isModerator();
bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0;
bool trust = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0;
if (isOp && selectedPlayer != NULL && playersList.TreeHasFocus() &&
(playersList.GetItemCount() > 0) &&
(playersList.GetCurSel() < m_playersCount)) {
bool editingHost = selectedPlayer->IsHost();
if ((cheats && (m_isHostPlayer || !editingHost)) ||
(!trust && (m_isHostPlayer || !editingHost)) ||
(m_isHostPlayer && !editingHost)
#if (!defined(_CONTENT_PACKAGE) && !defined(_FINAL_BUILD) && \
defined(_DEBUG_MENUS_ENABLED))
|| (m_isHostPlayer && editingHost)
#endif
)
{
InGamePlayerOptionsInitData *pInitData = new InGamePlayerOptionsInitData();
pInitData->iPad = m_iPad;
pInitData->networkSmallId = m_players[ playersList.GetCurSel() ];
pInitData->playerPrivileges = app.GetPlayerPrivileges(m_players[ playersList.GetCurSel() ] );
app.NavigateToScene(m_iPad,eUIScene_InGamePlayerOptionsMenu,pInitData);
}
else if(selectedPlayer->IsLocal() != TRUE && selectedPlayer->IsSameSystem(g_NetworkManager.GetHostPlayer()) != TRUE)
{
// Only ops will hit this, can kick anyone not local and not local to the host
std::uint8_t *smallId = new std::uint8_t();
*smallId = m_players[playersList.GetCurSel()];
unsigned int uiIDA[2];
uiIDA[0]=IDS_CONFIRM_OK;
uiIDA[1]=IDS_CONFIRM_CANCEL;
) {
InGamePlayerOptionsInitData* pInitData =
new InGamePlayerOptionsInitData();
pInitData->iPad = m_iPad;
pInitData->networkSmallId = m_players[playersList.GetCurSel()];
pInitData->playerPrivileges =
app.GetPlayerPrivileges(m_players[playersList.GetCurSel()]);
app.NavigateToScene(m_iPad, eUIScene_InGamePlayerOptionsMenu,
pInitData);
} else if (selectedPlayer->IsLocal() != TRUE &&
selectedPlayer->IsSameSystem(
g_NetworkManager.GetHostPlayer()) != TRUE) {
// Only ops will hit this, can kick anyone not local and not
// local to the host
std::uint8_t* smallId = new std::uint8_t();
*smallId = m_players[playersList.GetCurSel()];
unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_OK;
uiIDA[1] = IDS_CONFIRM_CANCEL;
StorageManager.RequestMessageBox(IDS_UNLOCK_KICK_PLAYER_TITLE, IDS_UNLOCK_KICK_PLAYER, uiIDA, 2, m_iPad,&CScene_InGameInfo::KickPlayerReturned,smallId,app.GetStringTable());
}
}
}
else if( hObjPressed == m_gameOptionsButton )
{
app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_InGameHostOptionsMenu);
}
return S_OK;
StorageManager.RequestMessageBox(
IDS_UNLOCK_KICK_PLAYER_TITLE, IDS_UNLOCK_KICK_PLAYER, uiIDA,
2, m_iPad, &CScene_InGameInfo::KickPlayerReturned, smallId,
app.GetStringTable());
}
}
} else if (hObjPressed == m_gameOptionsButton) {
app.NavigateToScene(pNotifyPressData->UserIndex,
eUIScene_InGameHostOptionsMenu);
}
return S_OK;
}
HRESULT CScene_InGameInfo::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled)
{
if(pData->nId==IGNORE_KEYPRESS_TIMERID)
{
XuiKillTimer(m_hObj,IGNORE_KEYPRESS_TIMERID);
m_bIgnoreKeyPresses=false;
}
else
{
updateTooltips();
}
HRESULT CScene_InGameInfo::OnTimer(XUIMessageTimer* pData, BOOL& rfHandled) {
if (pData->nId == IGNORE_KEYPRESS_TIMERID) {
XuiKillTimer(m_hObj, IGNORE_KEYPRESS_TIMERID);
m_bIgnoreKeyPresses = false;
} else {
updateTooltips();
}
return S_OK;
return S_OK;
}
HRESULT CScene_InGameInfo::OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled )
{
if(pTransition->dwTransType == XUI_TRANSITION_FROM)
{
KillTimer( TOOLTIP_TIMERID );
}
return S_OK;
HRESULT CScene_InGameInfo::OnTransitionStart(XUIMessageTransition* pTransition,
BOOL& bHandled) {
if (pTransition->dwTransType == XUI_TRANSITION_FROM) {
KillTimer(TOOLTIP_TIMERID);
}
return S_OK;
}
HRESULT CScene_InGameInfo::OnTransitionEnd( XUIMessageTransition *pTransition, BOOL& bHandled )
{
if(pTransition->dwTransType == XUI_TRANSITION_BACKTO)
{
SetTimer( TOOLTIP_TIMERID , INGAME_INFO_TOOLTIP_TIMER );
g_NetworkManager.RegisterPlayerChangedCallback(m_iPad, &CScene_InGameInfo::OnPlayerChanged, this);
}
return S_OK;
HRESULT CScene_InGameInfo::OnTransitionEnd(XUIMessageTransition* pTransition,
BOOL& bHandled) {
if (pTransition->dwTransType == XUI_TRANSITION_BACKTO) {
SetTimer(TOOLTIP_TIMERID, INGAME_INFO_TOOLTIP_TIMER);
g_NetworkManager.RegisterPlayerChangedCallback(
m_iPad, &CScene_InGameInfo::OnPlayerChanged, this);
}
return S_OK;
}
HRESULT CScene_InGameInfo::OnNotifySetFocus( HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled )
{
updateTooltips();
return S_OK;
HRESULT CScene_InGameInfo::OnNotifySetFocus(HXUIOBJ hObjSource,
XUINotifyFocus* pNotifyFocusData,
BOOL& bHandled) {
updateTooltips();
return S_OK;
}
void CScene_InGameInfo::OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving)
{
CScene_InGameInfo *scene = (CScene_InGameInfo *)callbackParam;
bool playerFound = false;
void CScene_InGameInfo::OnPlayerChanged(void* callbackParam,
INetworkPlayer* pPlayer, bool leaving) {
CScene_InGameInfo* scene = (CScene_InGameInfo*)callbackParam;
bool playerFound = false;
for(int i = 0; i < scene->m_playersCount; ++i)
{
if(playerFound)
{
scene->m_players[i-1] = scene->m_players[i];
}
else if( scene->m_players[i] == pPlayer->GetSmallId() )
{
if( scene->playersList.GetCurSel() == scene->playersList.GetItemCount() - 1 )
{
scene->playersList.SetCurSel( scene->playersList.GetItemCount() - 2 );
}
// Player removed
playerFound = true;
}
}
for (int i = 0; i < scene->m_playersCount; ++i) {
if (playerFound) {
scene->m_players[i - 1] = scene->m_players[i];
} else if (scene->m_players[i] == pPlayer->GetSmallId()) {
if (scene->playersList.GetCurSel() ==
scene->playersList.GetItemCount() - 1) {
scene->playersList.SetCurSel(scene->playersList.GetItemCount() -
2);
}
// Player removed
playerFound = true;
}
}
if( playerFound )
{
--scene->m_playersCount;
scene->playersList.DeleteItems( scene->playersList.GetItemCount() - 1, 1 );
}
if (playerFound) {
--scene->m_playersCount;
scene->playersList.DeleteItems(scene->playersList.GetItemCount() - 1,
1);
}
if( !playerFound )
{
// Player added
scene->m_players[scene->m_playersCount] = pPlayer->GetSmallId();
++scene->m_playersCount;
scene->playersList.InsertItems( scene->playersList.GetItemCount(), 1 );
}
if (!playerFound) {
// Player added
scene->m_players[scene->m_playersCount] = pPlayer->GetSmallId();
++scene->m_playersCount;
scene->playersList.InsertItems(scene->playersList.GetItemCount(), 1);
}
}
HRESULT CScene_InGameInfo::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled)
{
if( pGetSourceTextData->bItemData )
{
if( pGetSourceTextData->iItem < m_playersCount )
{
INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId( m_players[pGetSourceTextData->iItem] );
if( player != NULL )
{
HRESULT CScene_InGameInfo::OnGetSourceDataText(
XUIMessageGetSourceText* pGetSourceTextData, BOOL& bHandled) {
if (pGetSourceTextData->bItemData) {
if (pGetSourceTextData->iItem < m_playersCount) {
INetworkPlayer* player = g_NetworkManager.GetPlayerBySmallId(
m_players[pGetSourceTextData->iItem]);
if (player != NULL) {
#ifndef _CONTENT_PACKAGE
if(app.DebugSettingsOn() && (app.GetGameSettingsDebugMask()&(1L<<eDebugSetting_DebugLeaderboards)))
{
pGetSourceTextData->szText = L"WWWWWWWWWWWWWWWW";
}
else
if (app.DebugSettingsOn() &&
(app.GetGameSettingsDebugMask() &
(1L << eDebugSetting_DebugLeaderboards))) {
pGetSourceTextData->szText = L"WWWWWWWWWWWWWWWW";
} else
#endif
{
pGetSourceTextData->szText = player->GetOnlineName();
}
}
else
{
pGetSourceTextData->szText = L"";
}
{
pGetSourceTextData->szText = player->GetOnlineName();
}
} else {
pGetSourceTextData->szText = L"";
}
HRESULT hr;
HXUIOBJ hButton, hVisual, hPlayerIcon, hVoiceIcon;
hButton = playersList.GetItemControl(pGetSourceTextData->iItem);
hr=XuiControlGetVisual(hButton,&hVisual);
HRESULT hr;
HXUIOBJ hButton, hVisual, hPlayerIcon, hVoiceIcon;
hButton = playersList.GetItemControl(pGetSourceTextData->iItem);
hr = XuiControlGetVisual(hButton, &hVisual);
// Set the players icon
hr=XuiElementGetChildById(hVisual,L"IconGroup",&hPlayerIcon);
short colourIndex = app.GetPlayerColour( m_players[pGetSourceTextData->iItem] );
int playFrame = 0;
switch(colourIndex)
{
case 1:
XuiElementFindNamedFrame(hPlayerIcon, L"P1", &playFrame);
break;
case 2:
XuiElementFindNamedFrame(hPlayerIcon, L"P2", &playFrame);
break;
case 3:
XuiElementFindNamedFrame(hPlayerIcon, L"P3", &playFrame);
break;
case 4:
XuiElementFindNamedFrame(hPlayerIcon, L"P4", &playFrame);
break;
case 5:
XuiElementFindNamedFrame(hPlayerIcon, L"P5", &playFrame);
break;
case 6:
XuiElementFindNamedFrame(hPlayerIcon, L"P6", &playFrame);
break;
case 7:
XuiElementFindNamedFrame(hPlayerIcon, L"P7", &playFrame);
break;
case 8:
XuiElementFindNamedFrame(hPlayerIcon, L"P8", &playFrame);
break;
case 9:
XuiElementFindNamedFrame(hPlayerIcon, L"P9", &playFrame);
break;
case 10:
XuiElementFindNamedFrame(hPlayerIcon, L"P10", &playFrame);
break;
case 11:
XuiElementFindNamedFrame(hPlayerIcon, L"P11", &playFrame);
break;
case 12:
XuiElementFindNamedFrame(hPlayerIcon, L"P12", &playFrame);
break;
case 13:
XuiElementFindNamedFrame(hPlayerIcon, L"P13", &playFrame);
break;
case 14:
XuiElementFindNamedFrame(hPlayerIcon, L"P14", &playFrame);
break;
case 15:
XuiElementFindNamedFrame(hPlayerIcon, L"P15", &playFrame);
break;
case 0:
default:
XuiElementFindNamedFrame(hPlayerIcon, L"P0", &playFrame);
break;
};
if(playFrame < 0) playFrame = 0;
XuiElementPlayTimeline(hPlayerIcon,playFrame,playFrame,playFrame,FALSE,FALSE);
// Set the players icon
hr = XuiElementGetChildById(hVisual, L"IconGroup", &hPlayerIcon);
short colourIndex =
app.GetPlayerColour(m_players[pGetSourceTextData->iItem]);
int playFrame = 0;
switch (colourIndex) {
case 1:
XuiElementFindNamedFrame(hPlayerIcon, L"P1", &playFrame);
break;
case 2:
XuiElementFindNamedFrame(hPlayerIcon, L"P2", &playFrame);
break;
case 3:
XuiElementFindNamedFrame(hPlayerIcon, L"P3", &playFrame);
break;
case 4:
XuiElementFindNamedFrame(hPlayerIcon, L"P4", &playFrame);
break;
case 5:
XuiElementFindNamedFrame(hPlayerIcon, L"P5", &playFrame);
break;
case 6:
XuiElementFindNamedFrame(hPlayerIcon, L"P6", &playFrame);
break;
case 7:
XuiElementFindNamedFrame(hPlayerIcon, L"P7", &playFrame);
break;
case 8:
XuiElementFindNamedFrame(hPlayerIcon, L"P8", &playFrame);
break;
case 9:
XuiElementFindNamedFrame(hPlayerIcon, L"P9", &playFrame);
break;
case 10:
XuiElementFindNamedFrame(hPlayerIcon, L"P10", &playFrame);
break;
case 11:
XuiElementFindNamedFrame(hPlayerIcon, L"P11", &playFrame);
break;
case 12:
XuiElementFindNamedFrame(hPlayerIcon, L"P12", &playFrame);
break;
case 13:
XuiElementFindNamedFrame(hPlayerIcon, L"P13", &playFrame);
break;
case 14:
XuiElementFindNamedFrame(hPlayerIcon, L"P14", &playFrame);
break;
case 15:
XuiElementFindNamedFrame(hPlayerIcon, L"P15", &playFrame);
break;
case 0:
default:
XuiElementFindNamedFrame(hPlayerIcon, L"P0", &playFrame);
break;
};
if (playFrame < 0) playFrame = 0;
XuiElementPlayTimeline(hPlayerIcon, playFrame, playFrame, playFrame,
FALSE, FALSE);
// Set the voice icon
hr=XuiElementGetChildById(hVisual,L"VoiceGroup",&hVoiceIcon);
// Set the voice icon
hr = XuiElementGetChildById(hVisual, L"VoiceGroup", &hVoiceIcon);
playFrame = -1;
if(player != NULL && player->HasVoice() )
{
if( player->IsMutedByLocalUser(m_iPad) )
{
// Muted image
XuiElementFindNamedFrame(hVoiceIcon, L"Muted", &playFrame);
}
else if( player->IsTalking() )
{
// Talking image
XuiElementFindNamedFrame(hVoiceIcon, L"Speaking", &playFrame);
}
else
{
// Not talking image
XuiElementFindNamedFrame(hVoiceIcon, L"NotSpeaking", &playFrame);
}
}
if(playFrame < 0)
{
XuiElementFindNamedFrame(hVoiceIcon, L"Normal", &playFrame);
}
XuiElementPlayTimeline(hVoiceIcon,playFrame,playFrame,playFrame,FALSE,FALSE);
playFrame = -1;
if (player != NULL && player->HasVoice()) {
if (player->IsMutedByLocalUser(m_iPad)) {
// Muted image
XuiElementFindNamedFrame(hVoiceIcon, L"Muted", &playFrame);
} else if (player->IsTalking()) {
// Talking image
XuiElementFindNamedFrame(hVoiceIcon, L"Speaking",
&playFrame);
} else {
// Not talking image
XuiElementFindNamedFrame(hVoiceIcon, L"NotSpeaking",
&playFrame);
}
}
pGetSourceTextData->bDisplay = TRUE;
if (playFrame < 0) {
XuiElementFindNamedFrame(hVoiceIcon, L"Normal", &playFrame);
}
XuiElementPlayTimeline(hVoiceIcon, playFrame, playFrame, playFrame,
FALSE, FALSE);
bHandled = TRUE;
}
}
return S_OK;
pGetSourceTextData->bDisplay = TRUE;
bHandled = TRUE;
}
}
return S_OK;
}
HRESULT CScene_InGameInfo::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled)
{
if( pGetSourceImageData->bItemData )
{
if( pGetSourceImageData->iItem < m_playersCount )
{
bHandled = TRUE;
}
}
return S_OK;
HRESULT CScene_InGameInfo::OnGetSourceDataImage(
XUIMessageGetSourceImage* pGetSourceImageData, BOOL& bHandled) {
if (pGetSourceImageData->bItemData) {
if (pGetSourceImageData->iItem < m_playersCount) {
bHandled = TRUE;
}
}
return S_OK;
}
HRESULT CScene_InGameInfo::OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled)
{
pGetItemCountData->cItems = m_playersCount;
bHandled = TRUE;
return S_OK;
HRESULT CScene_InGameInfo::OnGetItemCountAll(
XUIMessageGetItemCount* pGetItemCountData, BOOL& bHandled) {
pGetItemCountData->cItems = m_playersCount;
bHandled = TRUE;
return S_OK;
}
void CScene_InGameInfo::updateTooltips()
{
int keyX = IDS_TOOLTIPS_INVITE_FRIENDS;
int ikeyY = -1;
void CScene_InGameInfo::updateTooltips() {
int keyX = IDS_TOOLTIPS_INVITE_FRIENDS;
int ikeyY = -1;
XPARTY_USER_LIST partyList;
if((XPartyGetUserList( &partyList ) != XPARTY_E_NOT_IN_PARTY ) && (partyList.dwUserCount>1))
{
keyX = IDS_TOOLTIPS_INVITE_PARTY;
}
if(g_NetworkManager.IsLocalGame()) keyX = -1;
XPARTY_USER_LIST partyList;
if ((XPartyGetUserList(&partyList) != XPARTY_E_NOT_IN_PARTY) &&
(partyList.dwUserCount > 1)) {
keyX = IDS_TOOLTIPS_INVITE_PARTY;
}
if (g_NetworkManager.IsLocalGame()) keyX = -1;
INetworkPlayer *selectedPlayer = g_NetworkManager.GetPlayerBySmallId( m_players[ playersList.GetCurSel() ] );
INetworkPlayer* selectedPlayer =
g_NetworkManager.GetPlayerBySmallId(m_players[playersList.GetCurSel()]);
int keyA = -1;
Minecraft *pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> localPlayer = pMinecraft->localplayers[m_iPad];
bool isOp = m_isHostPlayer || localPlayer->isModerator();
bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0;
bool trust = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0;
int keyA = -1;
Minecraft* pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> localPlayer =
pMinecraft->localplayers[m_iPad];
if( isOp )
{
if(m_gameOptionsButton.HasFocus())
{
keyA = IDS_TOOLTIPS_SELECT;
}
else if( selectedPlayer != NULL)
{
bool editingHost = selectedPlayer->IsHost();
if( (cheats && (m_isHostPlayer || !editingHost ) ) || (!trust && (m_isHostPlayer || !editingHost))
#if (!defined(_CONTENT_PACKAGE) && !defined(_FINAL_BUILD) && defined(_DEBUG_MENUS_ENABLED))
|| (m_isHostPlayer && editingHost)
bool isOp = m_isHostPlayer || localPlayer->isModerator();
bool cheats = app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0;
bool trust = app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0;
if (isOp) {
if (m_gameOptionsButton.HasFocus()) {
keyA = IDS_TOOLTIPS_SELECT;
} else if (selectedPlayer != NULL) {
bool editingHost = selectedPlayer->IsHost();
if ((cheats && (m_isHostPlayer || !editingHost)) ||
(!trust && (m_isHostPlayer || !editingHost))
#if (!defined(_CONTENT_PACKAGE) && !defined(_FINAL_BUILD) && \
defined(_DEBUG_MENUS_ENABLED))
|| (m_isHostPlayer && editingHost)
#endif
)
{
keyA = IDS_TOOLTIPS_PRIVILEGES;
}
else if(selectedPlayer->IsLocal() != TRUE && selectedPlayer->IsSameSystem(g_NetworkManager.GetHostPlayer()) != TRUE)
{
// Only ops will hit this, can kick anyone not local and not local to the host
keyA = IDS_TOOLTIPS_KICK;
}
}
}
) {
keyA = IDS_TOOLTIPS_PRIVILEGES;
} else if (selectedPlayer->IsLocal() != TRUE &&
selectedPlayer->IsSameSystem(
g_NetworkManager.GetHostPlayer()) != TRUE) {
// Only ops will hit this, can kick anyone not local and not
// local to the host
keyA = IDS_TOOLTIPS_KICK;
}
}
}
if(!m_gameOptionsButton.HasFocus())
{
// if the player is me, then view gamer profile
if(selectedPlayer != NULL && selectedPlayer->IsLocal() && selectedPlayer->GetUserIndex()==m_iPad)
{
ikeyY = IDS_TOOLTIPS_VIEW_GAMERPROFILE;
}
else
{
ikeyY = IDS_TOOLTIPS_VIEW_GAMERCARD;
}
}
ui.SetTooltips( m_iPad, keyA,IDS_TOOLTIPS_BACK,keyX,ikeyY);
if (!m_gameOptionsButton.HasFocus()) {
// if the player is me, then view gamer profile
if (selectedPlayer != NULL && selectedPlayer->IsLocal() &&
selectedPlayer->GetUserIndex() == m_iPad) {
ikeyY = IDS_TOOLTIPS_VIEW_GAMERPROFILE;
} else {
ikeyY = IDS_TOOLTIPS_VIEW_GAMERCARD;
}
}
ui.SetTooltips(m_iPad, keyA, IDS_TOOLTIPS_BACK, keyX, ikeyY);
}
HRESULT CScene_InGameInfo::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining);
HRESULT CScene_InGameInfo::OnCustomMessage_Splitscreenplayer(bool bJoining,
BOOL& bHandled) {
bHandled = true;
return app.AdjustSplitscreenScene_PlayerChanged(m_hObj, &m_OriginalPosition,
m_iPad, bJoining);
}
int CScene_InGameInfo::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
std::uint8_t smallId = *static_cast<std::uint8_t *>(pParam);
delete pParam;
int CScene_InGameInfo::KickPlayerReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result) {
std::uint8_t smallId = *static_cast<std::uint8_t*>(pParam);
delete pParam;
if(result==C4JStorage::EMessage_ResultAccept)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> localPlayer = pMinecraft->localplayers[iPad];
if(localPlayer != NULL && localPlayer->connection)
{
localPlayer->connection->send( std::shared_ptr<KickPlayerPacket>( new KickPlayerPacket(smallId) ) );
}
}
if (result == C4JStorage::EMessage_ResultAccept) {
Minecraft* pMinecraft = Minecraft::GetInstance();
std::shared_ptr<MultiplayerLocalPlayer> localPlayer =
pMinecraft->localplayers[iPad];
if (localPlayer != NULL && localPlayer->connection) {
localPlayer->connection->send(std::shared_ptr<KickPlayerPacket>(
new KickPlayerPacket(smallId)));
}
}
return 0;
return 0;
}

View File

@@ -1,5 +1,5 @@
#pragma once
//using namespace std;
// using namespace std;
#include <cstdint>
#include "../media/xuiscene_ingameinfo.h"
@@ -13,74 +13,84 @@ class INetworkPlayer;
#define MAP_ICON_DATA_ID 1
#define OPS_ICON_DATA_ID 2
class CScene_InGameInfo : public CXuiSceneImpl
{
class CScene_InGameInfo : public CXuiSceneImpl {
protected:
// Control and Element wrapper objects.
CXuiList playersList;
CXuiControl m_gameOptionsButton;
CXuiControl m_title;
// Control and Element wrapper objects.
CXuiList playersList;
CXuiControl m_gameOptionsButton;
CXuiControl m_title;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY( OnDestroy )
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_TIMER( OnTimer )
XUI_ON_XM_TRANSITION_START( OnTransitionStart )
XUI_ON_XM_TRANSITION_END( OnTransitionEnd )
XUI_ON_XM_NOTIFY_SET_FOCUS( OnNotifySetFocus )
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_TIMER(OnTimer)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_ON_XM_TRANSITION_END(OnTransitionEnd)
XUI_ON_XM_NOTIFY_SET_FOCUS(OnNotifySetFocus)
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_GamePlayers, playersList)
MAP_CONTROL(IDC_GameOptionsButton, m_gameOptionsButton)
MAP_CONTROL(IDC_Title, m_title)
END_CONTROL_MAP()
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_SPLITSCREENPLAYER_MESSAGE(OnCustomMessage_Splitscreenplayer)
XUI_END_MSG_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnDestroy();
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnTimer(XUIMessageTimer *pData,BOOL& rfHandled);
HRESULT OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnTransitionEnd( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnNotifySetFocus( HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled );
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_GamePlayers, playersList)
MAP_CONTROL(IDC_GameOptionsButton, m_gameOptionsButton)
MAP_CONTROL(IDC_Title, m_title)
END_CONTROL_MAP()
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnTimer(XUIMessageTimer* pData, BOOL& rfHandled);
HRESULT OnTransitionStart(XUIMessageTransition* pTransition,
BOOL& bHandled);
HRESULT OnTransitionEnd(XUIMessageTransition* pTransition, BOOL& bHandled);
HRESULT OnNotifySetFocus(HXUIOBJ hObjSource,
XUINotifyFocus* pNotifyFocusData, BOOL& bHandled);
HRESULT OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetSourceImageData,
BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_InGameInfo, L"CScene_InGameInfo",
XUI_CLASS_SCENE)
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_InGameInfo, L"CScene_InGameInfo", XUI_CLASS_SCENE )
static void OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving);
static void OnPlayerChanged(void* callbackParam, INetworkPlayer* pPlayer,
bool leaving);
private:
bool m_isHostPlayer;
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
bool m_isHostPlayer;
int m_iPad;
D3DXVECTOR3 m_OriginalPosition;
int m_playersCount;
std::uint8_t m_players[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's
bool m_bIgnoreKeyPresses;
int m_playersCount;
std::uint8_t
m_players[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's
bool m_bIgnoreKeyPresses;
void updateTooltips();
void updateTooltips();
public:
static int KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int KickPlayerReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
};

View File

@@ -3,96 +3,99 @@
#include "../Media/xuiscene_ingame_player_options.h"
class CScene_InGamePlayerOptions : public CXuiSceneImpl
{
class CScene_InGamePlayerOptions : public CXuiSceneImpl {
private:
enum EControls
{
// Checkboxes
eControl_BuildAndMine,
eControl_UseDoorsAndSwitches,
eControl_UseContainers,
eControl_AttackPlayers,
eControl_AttackAnimals,
eControl_Op,
eControl_CheatTeleport,
eControl_HostFly,
eControl_HostHunger,
eControl_HostInvisible,
enum EControls {
// Checkboxes
eControl_BuildAndMine,
eControl_UseDoorsAndSwitches,
eControl_UseContainers,
eControl_AttackPlayers,
eControl_AttackAnimals,
eControl_Op,
eControl_CheatTeleport,
eControl_HostFly,
eControl_HostHunger,
eControl_HostInvisible,
eControl_CHECKBOXES_COUNT,
eControl_CHECKBOXES_COUNT,
// Others
eControl_Kick = eControl_CHECKBOXES_COUNT,
};
// Others
eControl_Kick = eControl_CHECKBOXES_COUNT,
};
protected:
HXUIOBJ m_focusElement; // Only used for the remove control process
HXUIOBJ m_focusElement; // Only used for the remove control process
CXuiControl m_Icon;
CXuiControl m_Gamertag;
CXuiScene m_TeleportGroup;
CXuiControl m_buttonKick;
CXuiCheckbox m_checkboxes[eControl_CHECKBOXES_COUNT];
CXuiControl m_Icon;
CXuiControl m_Gamertag;
CXuiScene m_TeleportGroup;
CXuiControl m_buttonKick;
CXuiCheckbox m_checkboxes[eControl_CHECKBOXES_COUNT];
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY( OnDestroy )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate )
XUI_ON_XM_TRANSITION_START( OnTransitionStart )
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_END_MSG_MAP()
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Icon, m_Icon)
MAP_CONTROL(IDC_Gamertag, m_Gamertag)
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_Icon, m_Icon)
MAP_CONTROL(IDC_Gamertag, m_Gamertag)
MAP_CONTROL(IDC_CheckboxBuildAndMine, m_checkboxes[eControl_BuildAndMine])
MAP_CONTROL(IDC_CheckboxAttackPlayers, m_checkboxes[eControl_AttackPlayers])
MAP_CONTROL(IDC_CheckboxAttackAnimals, m_checkboxes[eControl_AttackAnimals])
MAP_CONTROL(IDC_CheckboxUseContainers, m_checkboxes[eControl_UseContainers])
MAP_CONTROL(IDC_CheckboxUseDoorsAndSwitches, m_checkboxes[eControl_UseDoorsAndSwitches])
MAP_CONTROL(IDC_CheckboxOp, m_checkboxes[eControl_Op])
MAP_CONTROL(IDC_CheckboxTeleport, m_checkboxes[eControl_CheatTeleport])
MAP_CONTROL(IDC_CheckboxHostInvisible, m_checkboxes[eControl_HostInvisible])
MAP_CONTROL(IDC_CheckboxHostFly, m_checkboxes[eControl_HostFly])
MAP_CONTROL(IDC_CheckboxHostHunger, m_checkboxes[eControl_HostHunger])
MAP_CONTROL(IDC_CheckboxBuildAndMine, m_checkboxes[eControl_BuildAndMine])
MAP_CONTROL(IDC_CheckboxAttackPlayers, m_checkboxes[eControl_AttackPlayers])
MAP_CONTROL(IDC_CheckboxAttackAnimals, m_checkboxes[eControl_AttackAnimals])
MAP_CONTROL(IDC_CheckboxUseContainers, m_checkboxes[eControl_UseContainers])
MAP_CONTROL(IDC_CheckboxUseDoorsAndSwitches,
m_checkboxes[eControl_UseDoorsAndSwitches])
MAP_CONTROL(IDC_CheckboxOp, m_checkboxes[eControl_Op])
MAP_CONTROL(IDC_CheckboxTeleport, m_checkboxes[eControl_CheatTeleport])
MAP_CONTROL(IDC_CheckboxHostInvisible, m_checkboxes[eControl_HostInvisible])
MAP_CONTROL(IDC_CheckboxHostFly, m_checkboxes[eControl_HostFly])
MAP_CONTROL(IDC_CheckboxHostHunger, m_checkboxes[eControl_HostHunger])
MAP_CONTROL(IDC_ButtonKick, m_buttonKick)
END_CONTROL_MAP()
MAP_CONTROL(IDC_ButtonKick, m_buttonKick)
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled);
HRESULT OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnControlNavigate(XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled);
HRESULT OnTransitionStart(XUIMessageTransition* pTransition,
BOOL& bHandled);
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_InGamePlayerOptions,
L"CScene_InGamePlayerOptions", XUI_CLASS_SCENE)
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_InGamePlayerOptions, L"CScene_InGamePlayerOptions", XUI_CLASS_SCENE )
static void OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving);
static void OnPlayerChanged(void* callbackParam, INetworkPlayer* pPlayer,
bool leaving);
private:
bool m_editingSelf;
int m_iPad;
std::uint8_t m_networkSmallId;
unsigned int m_playerPrivileges;
D3DXVECTOR3 m_OriginalPosition;
bool m_editingSelf;
int m_iPad;
std::uint8_t m_networkSmallId;
unsigned int m_playerPrivileges;
D3DXVECTOR3 m_OriginalPosition;
void removeControl(HXUIOBJ hObjToRemove, bool center);
void removeControl(HXUIOBJ hObjToRemove, bool center);
/** 4J-JEV:
For enabling/disabling 'Can Fly', 'Can Teleport', 'Can Disable Hunger' etc
used after changing the moderator checkbox.
*/
void resetCheatCheckboxes();
/** 4J-JEV:
For enabling/disabling 'Can Fly', 'Can Teleport', 'Can Disable
Hunger' etc used after changing the moderator checkbox.
*/
void resetCheatCheckboxes();
public:
static int KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int KickPlayerReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
};

View File

@@ -6,148 +6,133 @@
#include <assert.h>
#include "XUI_Intro.h"
#define TIMELINE_NORMAL 0
#define TIMELINE_ESRBFADE 1
#define TIMELINE_LOGOSFADE 2
#define TIMELINE_NORMAL 0
#define TIMELINE_ESRBFADE 1
#define TIMELINE_LOGOSFADE 2
//----------------------------------------------------------------------------------
// Performs initialization tasks - retrieves controls.
//----------------------------------------------------------------------------------
HRESULT CScene_Intro::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
MapChildControls();
HRESULT CScene_Intro::OnInit(XUIMessageInit* pInitData, BOOL& bHandled) {
MapChildControls();
// We may need to display a ratings image for a while at the start...
m_bWantsToSkip=false;
m_iTimeline=TIMELINE_NORMAL;
// We may need to display a ratings image for a while at the start...
m_bWantsToSkip = false;
m_iTimeline = TIMELINE_NORMAL;
// 4J-PB - We can't check to see if the version is a trial or full game until after 5 seconds...
// The reason that this is a requirement is that there is a problem that occasionally happens *only* in the production
// environment (not partnernet or cert), where if you dont wait 5 seconds, you can run into an issue where the timing
// of the call fails and the game is always identified as being the trial version even if you have upgraded to the full version.
// -Joe Dunavant
// 4J-PB - We can't check to see if the version is a trial or full game
// until after 5 seconds... The reason that this is a requirement is that
// there is a problem that occasionally happens *only* in the production
// environment (not partnernet or cert), where if you dont wait 5 seconds,
// you can run into an issue where the timing of the call fails and the game
// is always identified as being the trial version even if you have upgraded
// to the full version. -Joe Dunavant
// start a timer for the required 5 seconds, plus an extra bit to allow the lib timer to enable the xcontent license check call
// start a timer for the required 5 seconds, plus an extra bit to allow the
// lib timer to enable the xcontent license check call
#ifdef _CONTENT_PACKAGE
m_bSkippable=false;
XuiSetTimer( m_hObj,0,5200);
m_bSkippable = false;
XuiSetTimer(m_hObj, 0, 5200);
#else
m_bSkippable=true;
m_bSkippable = true;
#endif
return S_OK;
return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScene_Intro::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
HRESULT CScene_Intro::OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData,
BOOL& rfHandled) {
// This assumes all buttons can only be pressed with the A button
ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
return S_OK;
return S_OK;
}
HRESULT CScene_Intro::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
{
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
HRESULT CScene_Intro::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) {
ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
static bool bPressed=false;
static bool bPressed = false;
if(bPressed==false)
{
if(m_bSkippable)
{
// stop the animation
XuiElementStopTimeline(m_hObj,TRUE);
app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_SaveMessage);
app.SetIntroRunning(false);
}
else
{
m_bWantsToSkip=true;
}
bPressed=true;
}
if (bPressed == false) {
if (m_bSkippable) {
// stop the animation
XuiElementStopTimeline(m_hObj, TRUE);
app.NavigateToScene(XUSER_INDEX_ANY, eUIScene_SaveMessage);
app.SetIntroRunning(false);
} else {
m_bWantsToSkip = true;
}
return S_OK;
bPressed = true;
}
return S_OK;
}
HRESULT CScene_Intro::OnTimelineEnd(HXUIOBJ hObjSource, BOOL& bHandled)
{
int nStart, nEnd;
HRESULT CScene_Intro::OnTimelineEnd(HXUIOBJ hObjSource, BOOL& bHandled) {
int nStart, nEnd;
if(m_bSkippable && m_bWantsToSkip)
{
// straight to the game
app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_SaveMessage);
app.SetIntroRunning(false);
}
else
{
switch(m_iTimeline)
{
case TIMELINE_NORMAL:
{
// 4J-PB - lots of discussions over this because Brazil is in the NA region. This is what I have been advised to do...
//if(ProfileManager.RegionIsNorthAmerica())
if(ProfileManager.LocaleIsUSorCanada())
{
m_iTimeline=TIMELINE_ESRBFADE;
XuiElementFindNamedFrame( m_hObj, L"ESRBFade", &nStart );
XuiElementFindNamedFrame( m_hObj, L"ESRBFadeEnd", &nEnd );
XuiElementPlayTimeline( m_hObj, nStart, nStart, nEnd, FALSE, TRUE );
}
else
{
m_iTimeline=TIMELINE_LOGOSFADE;
XuiElementFindNamedFrame( m_hObj, L"StartFade", &nStart );
XuiElementFindNamedFrame( m_hObj, L"EndFade", &nEnd );
XuiElementPlayTimeline( m_hObj, nStart, nStart, nEnd, FALSE, TRUE );
}
}
break;
if (m_bSkippable && m_bWantsToSkip) {
// straight to the game
app.NavigateToScene(XUSER_INDEX_ANY, eUIScene_SaveMessage);
app.SetIntroRunning(false);
} else {
switch (m_iTimeline) {
case TIMELINE_NORMAL: {
// 4J-PB - lots of discussions over this because Brazil is in
// the NA region. This is what I have been advised to do...
// if(ProfileManager.RegionIsNorthAmerica())
if (ProfileManager.LocaleIsUSorCanada()) {
m_iTimeline = TIMELINE_ESRBFADE;
XuiElementFindNamedFrame(m_hObj, L"ESRBFade", &nStart);
XuiElementFindNamedFrame(m_hObj, L"ESRBFadeEnd", &nEnd);
XuiElementPlayTimeline(m_hObj, nStart, nStart, nEnd, FALSE,
TRUE);
} else {
m_iTimeline = TIMELINE_LOGOSFADE;
XuiElementFindNamedFrame(m_hObj, L"StartFade", &nStart);
XuiElementFindNamedFrame(m_hObj, L"EndFade", &nEnd);
XuiElementPlayTimeline(m_hObj, nStart, nStart, nEnd, FALSE,
TRUE);
}
} break;
case TIMELINE_ESRBFADE:
if(m_bWantsToSkip && m_bSkippable)
{
app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_SaveMessage);
app.SetIntroRunning(false);
}
else
{
m_iTimeline=TIMELINE_LOGOSFADE;
XuiElementFindNamedFrame( m_hObj, L"StartFade", &nStart );
XuiElementFindNamedFrame( m_hObj, L"EndFade", &nEnd );
XuiElementPlayTimeline( m_hObj, nStart, nStart, nEnd, FALSE, TRUE );
}
break;
case TIMELINE_LOGOSFADE:
app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_SaveMessage);
app.SetIntroRunning(false);
break;
}
}
case TIMELINE_ESRBFADE:
if (m_bWantsToSkip && m_bSkippable) {
app.NavigateToScene(XUSER_INDEX_ANY, eUIScene_SaveMessage);
app.SetIntroRunning(false);
} else {
m_iTimeline = TIMELINE_LOGOSFADE;
XuiElementFindNamedFrame(m_hObj, L"StartFade", &nStart);
XuiElementFindNamedFrame(m_hObj, L"EndFade", &nEnd);
XuiElementPlayTimeline(m_hObj, nStart, nStart, nEnd, FALSE,
TRUE);
}
break;
case TIMELINE_LOGOSFADE:
app.NavigateToScene(XUSER_INDEX_ANY, eUIScene_SaveMessage);
app.SetIntroRunning(false);
break;
}
}
return S_OK;
return S_OK;
}
HRESULT CScene_Intro::OnTimer(XUIMessageTimer* pData, BOOL& rfHandled) {
HRESULT hr = XuiKillTimer(m_hObj, 0);
m_bSkippable = true;
HRESULT CScene_Intro::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled)
{
HRESULT hr=XuiKillTimer(m_hObj,0);
m_bSkippable=true;
if (m_bWantsToSkip) {
// stop the animation
XuiElementStopTimeline(m_hObj, TRUE);
app.NavigateToScene(XUSER_INDEX_ANY, eUIScene_SaveMessage);
app.SetIntroRunning(false);
}
if(m_bWantsToSkip)
{
// stop the animation
XuiElementStopTimeline(m_hObj,TRUE);
app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_SaveMessage);
app.SetIntroRunning(false);
}
return hr;
return hr;
}

View File

@@ -2,43 +2,41 @@
#include "../media/xuiscene_intro.h"
class CScene_Intro : public CXuiSceneImpl
{
protected:
CXuiScene m_Scene;
CXuiControl m_4jlogo;
CXuiElement m_grpXbox;
class CScene_Intro : public CXuiSceneImpl {
protected:
CXuiScene m_Scene;
CXuiControl m_4jlogo;
CXuiElement m_grpXbox;
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_TIMELINE_END(OnTimelineEnd)
XUI_ON_XM_TIMER( OnTimer )
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_TIMELINE_END(OnTimelineEnd)
XUI_ON_XM_TIMER(OnTimer)
XUI_END_MSG_MAP()
BEGIN_CONTROL_MAP()
//MAP_CONTROL(IDC_LogoGroup, m_grpXbox)
//BEGIN_MAP_CHILD_CONTROLS(m_grpXbox)
MAP_CONTROL(IDC_Logo4J, m_4jlogo)
//END_MAP_CHILD_CONTROLS()
BEGIN_CONTROL_MAP()
// MAP_CONTROL(IDC_LogoGroup, m_grpXbox)
// BEGIN_MAP_CHILD_CONTROLS(m_grpXbox)
MAP_CONTROL(IDC_Logo4J, m_4jlogo)
// END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
END_CONTROL_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnTimelineEnd(HXUIOBJ hObjSource, BOOL& bHandled);
HRESULT OnTimer(XUIMessageTimer* pData, BOOL& rfHandled);
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData,BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnTimelineEnd(HXUIOBJ hObjSource, BOOL& bHandled);
HRESULT OnTimer(XUIMessageTimer *pData,BOOL& rfHandled);
bool m_bSkippable;
bool m_bWantsToSkip;
int m_iTimeline;
bool m_bSkippable;
bool m_bWantsToSkip;
int m_iTimeline;
public:
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_Intro, L"CScene_Intro", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_Intro, L"CScene_Intro", XUI_CLASS_SCENE)
};

File diff suppressed because it is too large Load Diff

View File

@@ -6,164 +6,190 @@
class CXuiCtrlCraftIngredientSlot;
class CScene_Leaderboards : public CXuiSceneImpl, public LeaderboardReadListener
{
class CScene_Leaderboards : public CXuiSceneImpl,
public LeaderboardReadListener {
private:
// 4J Stu - Because the kills leaderboard doesn't a peaceful entry there are some special
// handling to make it skip that. We have re-arranged the order of the leaderboards so
// I am making this in case we do it again.
// 4J Stu - Made it a member of the class, rather than a #define
static const int LEADERBOARD_KILLS_POSITION = 3;
// 4J Stu - Because the kills leaderboard doesn't a peaceful entry there are
// some special handling to make it skip that. We have re-arranged the order
// of the leaderboards so I am making this in case we do it again. 4J Stu -
// Made it a member of the class, rather than a #define
static const int LEADERBOARD_KILLS_POSITION = 3;
static const int NUM_LEADERBOARDS = 4;//6; //Number of leaderboards
static const int NUM_ENTRIES = 101; //Cache up to this many entries
static const int READ_SIZE = 15; //Read this many entries at a time
static const int NUM_LEADERBOARDS =
4; // 6; //Number of leaderboards
static const int NUM_ENTRIES = 101; // Cache up to this many entries
static const int READ_SIZE = 15; // Read this many entries at a time
// static LPCWSTR FLAG_ICON_PATHS[37];
int m_iPad;
// static LPCWSTR FLAG_ICON_PATHS[37];
int m_iPad;
bool m_bPopulatedOnce;
bool m_bPopulatedOnce;
static const int LEADERBOARD_HEADERS[NUM_LEADERBOARDS][4];
static const int LEADERBOARD_HEADERS[NUM_LEADERBOARDS][4];
static const int TitleIcons[NUM_LEADERBOARDS][7];
static LPCWSTR m_TitleIconNameA[7];
static LPCWSTR m_TextColumnNameA[7];
HXUIOBJ m_hTextEntryA[7];
static const int TitleIcons[NUM_LEADERBOARDS][7];
static LPCWSTR m_TitleIconNameA[7];
static LPCWSTR m_TextColumnNameA[7];
HXUIOBJ m_hTextEntryA[7];
struct LeaderboardDescriptor {
DWORD m_viewId;
DWORD m_columnCount;
WORD m_columnIds[8];
struct LeaderboardDescriptor {
DWORD m_viewId;
DWORD m_columnCount;
WORD m_columnIds[8];
LeaderboardDescriptor(DWORD viewId, DWORD columnCount, WORD columnId_0, WORD columnId_1, WORD columnId_2, WORD columnId_3, WORD columnId_4, WORD columnId_5, WORD columnId_6, WORD columnId_7)
{
m_viewId = viewId;
m_columnCount = columnCount;
m_columnIds[0] = columnId_0;
m_columnIds[1] = columnId_1;
m_columnIds[2] = columnId_2;
m_columnIds[3] = columnId_3;
m_columnIds[4] = columnId_4;
m_columnIds[5] = columnId_5;
m_columnIds[6] = columnId_6;
m_columnIds[7] = columnId_7;
}
};
LeaderboardDescriptor(DWORD viewId, DWORD columnCount, WORD columnId_0,
WORD columnId_1, WORD columnId_2, WORD columnId_3,
WORD columnId_4, WORD columnId_5, WORD columnId_6,
WORD columnId_7) {
m_viewId = viewId;
m_columnCount = columnCount;
m_columnIds[0] = columnId_0;
m_columnIds[1] = columnId_1;
m_columnIds[2] = columnId_2;
m_columnIds[3] = columnId_3;
m_columnIds[4] = columnId_4;
m_columnIds[5] = columnId_5;
m_columnIds[6] = columnId_6;
m_columnIds[7] = columnId_7;
}
};
static const LeaderboardDescriptor LEADERBOARD_DESCRIPTORS[NUM_LEADERBOARDS][4];
static const LeaderboardDescriptor LEADERBOARD_DESCRIPTORS[NUM_LEADERBOARDS]
[4];
struct LeaderboardEntry {
PlayerUID m_xuid;
DWORD m_rank;
WCHAR m_wcRank[12];
WCHAR m_gamerTag[XUSER_NAME_SIZE+1];
//int m_locale;
unsigned int m_columns[7];
WCHAR m_wcColumns[7][12];
bool m_bPlayer; //Is the player
bool m_bOnline; //Is online
bool m_bFriend; //Is friend
bool m_bRequestedFriend; //Friend request sent but not answered
};
struct LeaderboardEntry {
PlayerUID m_xuid;
DWORD m_rank;
WCHAR m_wcRank[12];
WCHAR m_gamerTag[XUSER_NAME_SIZE + 1];
// int m_locale;
unsigned int m_columns[7];
WCHAR m_wcColumns[7][12];
bool m_bPlayer; // Is the player
bool m_bOnline; // Is online
bool m_bFriend; // Is friend
bool m_bRequestedFriend; // Friend request sent but not answered
};
struct Leaderboard {
DWORD m_totalEntryCount; //Either total number of entries in leaderboard, or total number of results for a friends query
DWORD m_entryStartIndex; //Index of first entry
DWORD m_currentEntryCount; //Current number of entries
LeaderboardEntry m_entries[NUM_ENTRIES];
DWORD m_numColumns;
};
Leaderboard m_leaderboard; //All leaderboard data for the currently selected filter
struct Leaderboard {
DWORD m_totalEntryCount; // Either total number of entries in
// leaderboard, or total number of results for
// a friends query
DWORD m_entryStartIndex; // Index of first entry
DWORD m_currentEntryCount; // Current number of entries
LeaderboardEntry m_entries[NUM_ENTRIES];
DWORD m_numColumns;
};
unsigned int m_currentLeaderboard; //The current leaderboard selected for view
Leaderboard m_leaderboard; // All leaderboard data for the currently
// selected filter
unsigned int
m_currentLeaderboard; // The current leaderboard selected for view
#ifdef _XBOX
LeaderboardManager::EFilterMode m_currentFilter; //The current filter selected
LeaderboardManager::EFilterMode
m_currentFilter; // The current filter selected
#endif
unsigned int m_currentDifficulty; //The current difficulty selected
unsigned int m_newEntryIndex; //Index of the first entry being read
unsigned int m_newReadSize; //Number of entries in the current read operation
unsigned int m_currentDifficulty; // The current difficulty selected
int m_newTop; //Index of the element that should be at the top of the list
int m_newSel; //Index of the element that should be selected in the list
unsigned int m_newEntryIndex; // Index of the first entry being read
unsigned int
m_newReadSize; // Number of entries in the current read operation
XONLINE_FRIEND* m_friends; //Current player's friends
unsigned int m_numFriends; //Count of friends
PlayerUID* m_filteredFriends; //List of all friend XUIDs (and player's), only counting actual friends, not pending
unsigned int m_numFilteredFriends; //Count of filtered friends
int m_newTop; // Index of the element that should be at the top of the list
int m_newSel; // Index of the element that should be selected in the list
CXuiList m_listGamers; //The XUI list showing the leaderboard info
CXuiControl m_textLeaderboard; //The XUI text box showing the current leaderboard name
CXuiControl m_textInfo; //The XUI text box showing info messages (loading, no results, etc.)
CXuiControl m_textFilter; //The XUI text box showing the current filter
CXuiControl m_textEntries; //The XUI text box showing the total number of entries in this leaderboard
CXuiCtrlCraftIngredientSlot *m_pHTitleIconSlots[7];
float m_fTitleIconXPositions[7];
float m_fTextXPositions[7];
XONLINE_FRIEND* m_friends; // Current player's friends
unsigned int m_numFriends; // Count of friends
PlayerUID* m_filteredFriends; // List of all friend XUIDs (and player's),
// only counting actual friends, not pending
unsigned int m_numFilteredFriends; // Count of filtered friends
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_DESTROY( OnDestroy )
XUI_ON_XM_KEYDOWN( OnKeyDown )
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_SET_FOCUS(OnNotifySetFocus)
CXuiList m_listGamers; // The XUI list showing the leaderboard info
CXuiControl m_textLeaderboard; // The XUI text box showing the current
// leaderboard name
CXuiControl m_textInfo; // The XUI text box showing info messages (loading,
// no results, etc.)
CXuiControl m_textFilter; // The XUI text box showing the current filter
CXuiControl m_textEntries; // The XUI text box showing the total number of
// entries in this leaderboard
CXuiCtrlCraftIngredientSlot* m_pHTitleIconSlots[7];
float m_fTitleIconXPositions[7];
float m_fTextXPositions[7];
XUI_END_MSG_MAP()
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_GET_ITEMCOUNT_ALL(OnGetItemCountAll)
XUI_ON_XM_GET_SOURCE_TEXT(OnGetSourceDataText)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_NOTIFY_SET_FOCUS(OnNotifySetFocus)
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiListGamers, m_listGamers)
MAP_CONTROL(IDC_XuiTextLeaderboard, m_textLeaderboard)
MAP_CONTROL(IDC_XuiTextInfo, m_textInfo)
MAP_CONTROL(IDC_XuiTextFilter, m_textFilter)
MAP_CONTROL(IDC_XuiTextEntries, m_textEntries)
END_CONTROL_MAP()
XUI_END_MSG_MAP()
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData, BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetImage, BOOL& bHandled);
HRESULT OnNotifySetFocus(HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelChanged *pNotifySelChangedData, BOOL& bHandled);
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_XuiListGamers, m_listGamers)
MAP_CONTROL(IDC_XuiTextLeaderboard, m_textLeaderboard)
MAP_CONTROL(IDC_XuiTextInfo, m_textInfo)
MAP_CONTROL(IDC_XuiTextFilter, m_textFilter)
MAP_CONTROL(IDC_XuiTextEntries, m_textEntries)
END_CONTROL_MAP()
//Start a read request with the current parameters
void ReadStats(int startIndex);
//Callback function called when stats read completes, userdata contains pointer to instance of CScene_Leaderboards
virtual bool OnStatsReadComplete(bool success, int numResults, LeaderboardManager::ViewOut results);
//Copy the stats from the raw m_stats structure into the m_leaderboards structure
int m_numStats;
PXUSER_STATS_READ_RESULTS m_stats;
bool RetrieveStats();
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& bHandled);
HRESULT OnGetItemCountAll(XUIMessageGetItemCount* pGetItemCountData,
BOOL& bHandled);
HRESULT OnGetSourceDataText(XUIMessageGetSourceText* pGetSourceTextData,
BOOL& bHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetImage,
BOOL& bHandled);
HRESULT OnNotifySetFocus(HXUIOBJ hObjSource,
XUINotifyFocus* pNotifyFocusData, BOOL& bHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
//Populate the XUI leaderboard with the contents of m_leaderboards
void PopulateLeaderboard(bool noResults);
// Start a read request with the current parameters
void ReadStats(int startIndex);
//Copy a leaderboard entry from the stats row
void CopyLeaderboardEntry(PXUSER_STATS_ROW statsRow, LeaderboardEntry* leaderboardEntry, bool isDistanceLeaderboard);
// Callback function called when stats read completes, userdata contains
// pointer to instance of CScene_Leaderboards
virtual bool OnStatsReadComplete(bool success, int numResults,
LeaderboardManager::ViewOut results);
//Set the header text of the leaderboard
void SetLeaderboardHeader();
// Copy the stats from the raw m_stats structure into the m_leaderboards
// structure
int m_numStats;
PXUSER_STATS_READ_RESULTS m_stats;
bool RetrieveStats();
// Set the title icons
int SetLeaderboardTitleIcons();
void ClearLeaderboardTitlebar();
void Reposition(int iNumber);
void RepositionText(int iNumber);
void UpdateTooltips();
// Populate the XUI leaderboard with the contents of m_leaderboards
void PopulateLeaderboard(bool noResults);
// Copy a leaderboard entry from the stats row
void CopyLeaderboardEntry(PXUSER_STATS_ROW statsRow,
LeaderboardEntry* leaderboardEntry,
bool isDistanceLeaderboard);
// Set the header text of the leaderboard
void SetLeaderboardHeader();
// Set the title icons
int SetLeaderboardTitleIcons();
void ClearLeaderboardTitlebar();
void Reposition(int iNumber);
void RepositionText(int iNumber);
void UpdateTooltips();
protected:
bool m_isProcessingStatsRead;
bool m_bReady;
public:
bool m_isProcessingStatsRead;
bool m_bReady;
XUI_IMPLEMENT_CLASS( CScene_Leaderboards, L"CScene_Leaderboards", XUI_CLASS_SCENE )
public:
XUI_IMPLEMENT_CLASS(CScene_Leaderboards, L"CScene_Leaderboards",
XUI_CLASS_SCENE)
};

File diff suppressed because it is too large Load Diff

View File

@@ -5,150 +5,165 @@
#include "XUI_CustomMessages.h"
#include "XUI_MultiGameLaunchMoreOptions.h"
class CScene_LoadGameSettings : public CXuiSceneImpl
{
class CScene_LoadGameSettings : public CXuiSceneImpl {
public:
typedef struct
{
unsigned int uiLen;
unsigned int uiCode;
}
PNG_CHUNK;
typedef struct {
unsigned int uiLen;
unsigned int uiCode;
} PNG_CHUNK;
protected:
// Control and Element wrapper objects.
CXuiScene m_MainScene;
CXuiScene m_TexturePackDetails;
CXuiControl m_GameName;
CXuiControl m_GameSeed;
CXuiControl m_GameCreatedMode;
CXuiControl m_ButtonLoad;
CXuiControl m_ButtonGameMode;
CXuiControl m_MoreOptions;
CXuiCtrl4JIcon m_GameIcon;
CXuiCtrlSliderWrapper m_SliderDifficulty;
CXuiCtrl4JList *m_pTexturePacksList;
CXuiControl m_texturePackTitle, m_texturePackDescription;
CXuiCtrl4JIcon *m_texturePackIcon, *m_texturePackComparison;
// Control and Element wrapper objects.
CXuiScene m_MainScene;
CXuiScene m_TexturePackDetails;
CXuiControl m_GameName;
CXuiControl m_GameSeed;
CXuiControl m_GameCreatedMode;
CXuiControl m_ButtonLoad;
CXuiControl m_ButtonGameMode;
CXuiControl m_MoreOptions;
CXuiCtrl4JIcon m_GameIcon;
CXuiCtrlSliderWrapper m_SliderDifficulty;
CXuiCtrl4JList* m_pTexturePacksList;
CXuiControl m_texturePackTitle, m_texturePackDescription;
CXuiCtrl4JIcon *m_texturePackIcon, *m_texturePackComparison;
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT( OnInit )
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate )
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_ON_XM_TRANSITION_END(OnTransitionEnd)
XUI_ON_XM_FONTRENDERERCHANGE_MESSAGE(OnFontRendererChange)
XUI_ON_XM_NOTIFY_SELCHANGED( OnNotifySelChanged )
XUI_ON_XM_TIMER( OnTimer )
XUI_ON_XM_NOTIFY_KILL_FOCUS( OnNotifyKillFocus )
XUI_ON_XM_DESTROY( OnDestroy )
XUI_ON_XM_DLCINSTALLED_MESSAGE(OnCustomMessage_DLCInstalled)
XUI_ON_XM_DLCLOADED_MESSAGE(OnCustomMessage_DLCMountingComplete)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_END_MSG_MAP()
// Message map. Here we tie messages to message handlers.
XUI_BEGIN_MSG_MAP()
XUI_ON_XM_INIT(OnInit)
XUI_ON_XM_NOTIFY_PRESS_EX(OnNotifyPressEx)
XUI_ON_XM_CONTROL_NAVIGATE(OnControlNavigate)
XUI_ON_XM_KEYDOWN(OnKeyDown)
XUI_ON_XM_NOTIFY_VALUE_CHANGED(OnNotifyValueChanged)
XUI_ON_XM_GET_SOURCE_IMAGE(OnGetSourceDataImage)
XUI_ON_XM_TRANSITION_START(OnTransitionStart)
XUI_ON_XM_TRANSITION_END(OnTransitionEnd)
XUI_ON_XM_FONTRENDERERCHANGE_MESSAGE(OnFontRendererChange)
XUI_ON_XM_NOTIFY_SELCHANGED(OnNotifySelChanged)
XUI_ON_XM_TIMER(OnTimer)
XUI_ON_XM_NOTIFY_KILL_FOCUS(OnNotifyKillFocus)
XUI_ON_XM_DESTROY(OnDestroy)
XUI_ON_XM_DLCINSTALLED_MESSAGE(OnCustomMessage_DLCInstalled)
XUI_ON_XM_DLCLOADED_MESSAGE(OnCustomMessage_DLCMountingComplete)
XUI_ON_XM_NAV_RETURN(OnNavReturn)
XUI_END_MSG_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_MainScene, m_MainScene)
BEGIN_MAP_CHILD_CONTROLS(m_MainScene)
MAP_CONTROL(IDC_XuiLoadSettings, m_ButtonLoad)
MAP_CONTROL(IDC_XuiGameModeToggle, m_ButtonGameMode)
MAP_CONTROL(IDC_XuiMoreOptions, m_MoreOptions)
MAP_CONTROL(IDC_XuiGameIcon, m_GameIcon);
MAP_CONTROL(IDC_XuiGameName, m_GameName)
MAP_CONTROL(IDC_XuiGameSeed, m_GameSeed)
MAP_CONTROL(IDC_XuiCreatedMode, m_GameCreatedMode)
MAP_CONTROL(IDC_XuiSliderDifficulty, m_SliderDifficulty)
MAP_OVERRIDE(IDC_TexturePacksList, m_pTexturePacksList)
//MAP_CONTROL(IDC_XuiGameMode, m_GameMode)
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_TexturePackDetails, m_TexturePackDetails)
BEGIN_MAP_CHILD_CONTROLS(m_TexturePackDetails)
MAP_CONTROL(IDC_TexturePackName, m_texturePackTitle)
MAP_CONTROL(IDC_TexturePackDescription, m_texturePackDescription)
MAP_OVERRIDE(IDC_Icon, m_texturePackIcon)
MAP_OVERRIDE(IDC_ComparisonPic, m_texturePackComparison)
END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
// Control mapping to objects
BEGIN_CONTROL_MAP()
MAP_CONTROL(IDC_MainScene, m_MainScene)
BEGIN_MAP_CHILD_CONTROLS(m_MainScene)
MAP_CONTROL(IDC_XuiLoadSettings, m_ButtonLoad)
MAP_CONTROL(IDC_XuiGameModeToggle, m_ButtonGameMode)
MAP_CONTROL(IDC_XuiMoreOptions, m_MoreOptions)
MAP_CONTROL(IDC_XuiGameIcon, m_GameIcon);
MAP_CONTROL(IDC_XuiGameName, m_GameName)
MAP_CONTROL(IDC_XuiGameSeed, m_GameSeed)
MAP_CONTROL(IDC_XuiCreatedMode, m_GameCreatedMode)
MAP_CONTROL(IDC_XuiSliderDifficulty, m_SliderDifficulty)
MAP_OVERRIDE(IDC_TexturePacksList, m_pTexturePacksList)
// MAP_CONTROL(IDC_XuiGameMode, m_GameMode)
END_MAP_CHILD_CONTROLS()
MAP_CONTROL(IDC_TexturePackDetails, m_TexturePackDetails)
BEGIN_MAP_CHILD_CONTROLS(m_TexturePackDetails)
MAP_CONTROL(IDC_TexturePackName, m_texturePackTitle)
MAP_CONTROL(IDC_TexturePackDescription, m_texturePackDescription)
MAP_OVERRIDE(IDC_Icon, m_texturePackIcon)
MAP_OVERRIDE(IDC_ComparisonPic, m_texturePackComparison)
END_MAP_CHILD_CONTROLS()
END_CONTROL_MAP()
HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled );
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled);
HRESULT OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged* pNotifyValueChanged, BOOL& bHandled );
HRESULT OnTransitionStart( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnTransitionEnd( XUIMessageTransition *pTransition, BOOL& bHandled );
HRESULT OnFontRendererChange();
HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled);
HRESULT OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, BOOL& bHandled );
HRESULT OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled );
HRESULT OnNotifyKillFocus(HXUIOBJ hObjSource, XUINotifyFocus *pNotifyFocusData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnCustomMessage_DLCInstalled();
HRESULT OnCustomMessage_DLCMountingComplete();
HRESULT OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled);
HRESULT OnInit(XUIMessageInit* pInitData, BOOL& bHandled);
HRESULT OnNotifyPressEx(HXUIOBJ hObjPressed,
XUINotifyPress* pNotifyPressData, BOOL& rfHandled);
HRESULT OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled);
HRESULT OnGetSourceDataImage(XUIMessageGetSourceImage* pGetSourceImageData,
BOOL& bHandled);
HRESULT OnNotifyValueChanged(HXUIOBJ hObjSource,
XUINotifyValueChanged* pNotifyValueChanged,
BOOL& bHandled);
HRESULT OnTransitionStart(XUIMessageTransition* pTransition,
BOOL& bHandled);
HRESULT OnTransitionEnd(XUIMessageTransition* pTransition, BOOL& bHandled);
HRESULT OnFontRendererChange();
HRESULT OnControlNavigate(XUIMessageControlNavigate* pControlNavigateData,
BOOL& bHandled);
HRESULT OnNotifySelChanged(HXUIOBJ hObjSource,
XUINotifySelChanged* pNotifySelChangedData,
BOOL& bHandled);
HRESULT OnTimer(XUIMessageTimer* pTimer, BOOL& bHandled);
HRESULT OnNotifyKillFocus(HXUIOBJ hObjSource,
XUINotifyFocus* pNotifyFocusData, BOOL& bHandled);
HRESULT OnDestroy();
HRESULT OnCustomMessage_DLCInstalled();
HRESULT OnCustomMessage_DLCMountingComplete();
HRESULT OnNavReturn(HXUIOBJ hObj, BOOL& rfHandled);
static int LoadSaveDataReturned(void* pParam, bool bContinue);
static int LoadSaveDataForNameChangeReturned(void* pParam, bool bContinue);
static int DeviceRemovedDialogReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static void StartGameFromSave(CScene_LoadGameSettings* pClass,
DWORD dwLocalUsersMask);
static int StartGame_SignInReturned(void* pParam, bool bContinue, int iPad);
static int DeviceSelectReturned(void* pParam, bool bContinue);
static int ConfirmLoadReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int DeleteSaveDialogReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int DeleteSaveDataReturned(void* pParam, bool bSuccess);
static int CheckResetNetherReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int TexturePackDialogReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int LoadSaveDataReturned(void *pParam,bool bContinue);
static int LoadSaveDataForNameChangeReturned(void *pParam,bool bContinue);
static int DeviceRemovedDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static void StartGameFromSave(CScene_LoadGameSettings* pClass, DWORD dwLocalUsersMask);
static int StartGame_SignInReturned(void *pParam,bool bContinue, int iPad);
static int DeviceSelectReturned(void *pParam,bool bContinue);
static int ConfirmLoadReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int DeleteSaveDataReturned(void *pParam,bool bSuccess);
static int CheckResetNetherReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int Progress(void* pParam, float fProgress);
static int Progress(void *pParam,float fProgress);
void LoadLevelGen(LevelGenerationOptions* levelGen);
void LoadLevelGen(LevelGenerationOptions *levelGen);
HRESULT LaunchGame(void);
HRESULT LaunchGame(void);
public:
static unsigned char szPNG[8];
static unsigned char szPNG[8];
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS( CScene_LoadGameSettings, L"CScene_LoadGameSettings", XUI_CLASS_SCENE )
// Define the class. The class name must match the ClassOverride property
// set for the scene in the UI Authoring tool.
XUI_IMPLEMENT_CLASS(CScene_LoadGameSettings, L"CScene_LoadGameSettings",
XUI_CLASS_SCENE)
private:
static int UnlockTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
void UpdateTexturePackDescription(int index);
void ClearTexturePackDescription();
void UpdateCurrentTexturePack();
static int UnlockTexturePackReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
void UpdateTexturePackDescription(int index);
void ClearTexturePackDescription();
void UpdateCurrentTexturePack();
bool m_bIgnoreInput;
HXUIBRUSH m_hXuiBrush;
HXUIBRUSH m_hTexturePackIconBrush;
HXUIBRUSH m_hTexturePackComparisonBrush;
bool m_bIgnoreInput;
HXUIBRUSH m_hXuiBrush;
HXUIBRUSH m_hTexturePackIconBrush;
HXUIBRUSH m_hTexturePackComparisonBrush;
int m_iPad;
int m_iSaveGameInfoIndex;
bool m_bMultiplayerAllowed;
static int m_iDifficultyTitleSettingA[4];
int m_CurrentDifficulty;
bool m_bHasBeenInCreative;
bool m_bSetup;
bool m_texturePackDescDisplayed;
int m_iPad;
int m_iSaveGameInfoIndex;
bool m_bMultiplayerAllowed;
static int m_iDifficultyTitleSettingA[4];
int m_CurrentDifficulty;
bool m_bHasBeenInCreative;
bool m_bSetup;
bool m_texturePackDescDisplayed;
DWORD m_dwSaveFileC;
DWORD m_dwSaveFileC;
#ifdef _XBOX
C4JStorage::CACHEINFOSTRUCT *m_InfoA;
C4JStorage::CACHEINFOSTRUCT* m_InfoA;
#endif
unsigned char m_szSeed[50];
XCONTENT_DATA m_XContentData;
LaunchMoreOptionsMenuInitData m_MoreOptionsParams;
bool m_bGameModeSurvival;
unsigned int m_currentTexturePackIndex;
DLCPack * m_pDLCPack;
LevelGenerationOptions *m_levelGen;
unsigned char m_szSeed[50];
XCONTENT_DATA m_XContentData;
LaunchMoreOptionsMenuInitData m_MoreOptionsParams;
bool m_bGameModeSurvival;
unsigned int m_currentTexturePackIndex;
DLCPack* m_pDLCPack;
LevelGenerationOptions* m_levelGen;
int m_iTexturePacksNotInstalled;
int *m_iConfigA; // track the texture packs that we don't have installed
LoadMenuInitData *m_params;
int m_iTexturePacksNotInstalled;
int* m_iConfigA; // track the texture packs that we don't have installed
LoadMenuInitData* m_params;
};

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More