chore: realign hud & x360 stuff

This commit is contained in:
str1k3r committed 2026-10-04 01:32:30 -04:00
1 parent 8f7ad6f080
commit dc73daee70
45 files changed
+957 -2623

No files matched your search

-434
View File
@@ -1,434 +0,0 @@
#include "stdafx.h"
#include "XUI_HUD.h"
#include "..\..\Minecraft.h"
#include "..\..\Gui.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\..\Minecraft.World\Random.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.effect.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.material.h"
HRESULT CXuiSceneHud::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
m_iPad = *(int *)pInitData->pvInitData;
MapChildControls();
XuiElementGetPosition(m_hObj,&m_OriginalPosition);
m_tickCount = 0;
return S_OK;
}
HRESULT CXuiSceneHud::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled)
{
bHandled=true;
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;
++m_tickCount;
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);
}
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;
}
}
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;
};
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 );
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 );
}
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;
}
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);
}
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");
}
}
}
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);
}
// 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;
}
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());
}
// 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
// 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;
}
-125
View File
@@ -1,125 +0,0 @@
#pragma once
#include "../Media/XUI/xuiscene_hud.h"
#include "XUI_CustomMessages.h"
#define CHAT_LINES_COUNT 10
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];
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];
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_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()
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();
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 )
};
@@ -62,7 +62,6 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl
// 4J-JEV: Fix for:
// TU12: Content: Gameplay: New "Mass Effect World" remembers and uses the settings of another - lately created - World.
m_MoreOptionsParams.bBonusChest = FALSE;
m_MoreOptionsParams.bFlatWorld = FALSE;
m_MoreOptionsParams.bStructures = TRUE;
@@ -57,7 +57,6 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle
m_MoreOptionsParams.bGenerateOptions=TRUE;
m_MoreOptionsParams.bStructures=TRUE;
m_MoreOptionsParams.bFlatWorld=FALSE;
m_MoreOptionsParams.bBonusChest=FALSE;
m_MoreOptionsParams.bPVP = TRUE;
m_MoreOptionsParams.bTrust = TRUE;
m_MoreOptionsParams.bFireSpreads = TRUE;
@@ -37,7 +37,6 @@ HRESULT CScene_MultiGameLaunchMoreOptions::OnInit( XUIMessageInit* pInitData, BO
m_CheckboxBonusChest.SetEnable(TRUE);
m_CheckboxStructures.SetCheck(m_params->bStructures);
m_CheckboxFlatWorld.SetCheck (m_params->bFlatWorld);
m_CheckboxBonusChest.SetCheck(m_params->bBonusChest);
// This is a create world, so don't need Reset Nether
float fHeight, fCheckboxHeight, fWidth;
@@ -143,7 +142,6 @@ HRESULT CScene_MultiGameLaunchMoreOptions::OnKeyDown(XUIMessageInput* pInputData
m_params->bStructures = m_CheckboxStructures.IsChecked();
m_params->bFlatWorld = m_CheckboxFlatWorld.IsChecked();
m_params->bBonusChest = m_CheckboxBonusChest.IsChecked();
m_params->bPVP = m_CheckboxPVP.IsChecked();
m_params->bTrust = m_CheckboxTrustPlayers.IsChecked();
m_params->bFireSpreads = m_CheckboxFireSpreads.IsChecked();
@@ -40,6 +40,7 @@ protected:
MAP_CONTROL(IDC_XuiViewBob, m_ViewBob)
MAP_CONTROL(IDC_XuiSplitScreen, m_SplitScreen)
MAP_CONTROL(IDC_XuiVisibleOnMaps, m_VisibleOnMaps)
MAP_CONTROL(IDC_XuiDifficultyText, m_DifficultyText)
MAP_CONTROL(IDC_XuiSliderDifficulty, m_SliderA[SLIDER_SETTINGS_DIFFICULTY])
END_CONTROL_MAP()