mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-03-22 16:38:54 +05:00
* Fix split-screen join failing when connecting to a remote host via UI
When a non-host client connected to a remote server through the in-game
UI (as opposed to the -ip/-port command line flags), the global variables
g_Win64MultiplayerIP and g_Win64MultiplayerPort were never updated from
their defaults ("127.0.0.1" and the default port). JoinSplitScreen()
relies on these globals to open a second TCP connection for the local
split-screen pad, so it would always attempt to connect to localhost,
failing immediately on any remote session.
Fix: update g_Win64MultiplayerIP and g_Win64MultiplayerPort inside
JoinGame() once the primary connection is established. This ensures
subsequent JoinSplitScreen() calls always reach the correct host
regardless of how the session was joined.
Additionally, guard PushFreeSmallId() against recycling smallIds in the
range [0, XUSER_MAX_COUNT), which are permanently reserved for the
host's local controller slots. Previously, if a host-side local pad
disconnected its smallId could re-enter the free pool and be handed
to an incoming remote client, causing that client's IQNetPlayer slot
to collide with a local pad slot on the non-host machine.
* Fix tutorial popup positioning in split-screen viewports
Replace the manual switch-case that computed viewport origin with the shared GetViewportRect/Fit16x9 helpers (from UISplitScreenHelpers.h). This ensures the tutorial popup is positioned and scaled consistently with the rest of the split-screen UI, fitting a 16:9 box inside each viewport and applying safezone offsets correctly.
Also adds missing default:break to safezone switch statements to silence compiler warnings.
Made-with: Cursor
* Prevent split-screen join when game window is not focused
Add g_KBMInput.IsWindowFocused() guard to the tryJoin condition so that gamepad input from background windows does not accidentally trigger a split-screen player join. This avoids phantom joins when the user is interacting with another application.
* Open debug overlay in fullscreen UI group during split-screen
Pass eUIGroup_Fullscreen to NavigateToScene when opening the debug overlay, so it spans the entire window instead of being confined to a single split-screen viewport. This makes the debug info readable regardless of the current split-screen layout.
* Fix non-host split-screen connections missing world updates
Previously, secondary (non-host) split-screen connections used isPrimaryConnection()
to gate nearly all world update packets, meaning the second local player would never
receive tile updates, entity movement, sounds, particles, explosions, etc.
The fix introduces per-connection tracking of which entities and chunks each
ClientConnection has loaded, and uses that information to decide whether a secondary
connection needs to process a given packet or if the primary connection already
handled it.
New members in ClientConnection:
- m_trackedEntityIds: set of entity IDs this connection has received AddEntity/AddMob/AddPlayer etc. for
- m_visibleChunks: set of chunk coordinates (packed into int64) this connection has marked visible
- Both sets are cleared on close(), respawn (dimension change), and destructor
New helpers:
- findPrimaryConnection(): walks the MultiPlayerLevel connection list to find the connection on the primary pad
- shouldProcessForEntity(id): secondary connection skips the packet only if the primary is already tracking that entity
- shouldProcessForPosition(x, z): secondary connection skips the packet only if the primary already has that chunk visible
- anyOtherConnectionHasChunk(x, z): used when a chunk becomes invisible to avoid hiding it from the level if another connection still needs it
- isTrackingEntity(id): public accessor used by shouldProcessForEntity on the primary connection
Packet handler changes:
- handleMoveEntity, handleMoveEntitySmall, handleSetEntityMotion, handleTakeItemEntity:
replaced isPrimaryConnection() with shouldProcessForEntity() so secondary
connections still process movement for entities they know about
- handleExplosion, handleLevelEvent:
replaced isPrimaryConnection() with shouldProcessForPosition() so block
destruction and level events fire for the correct connection based on chunks
- handleChunkTilesUpdate, handleBlockRegionUpdate, handleTileUpdate, handleSignUpdate,
handleTileEntityData, handleTileEvent, handleTileDestruction, handleComplexItemData,
handleSoundEvent, handleParticleEvent:
removed the isPrimaryConnection() guard entirely -- these are world-state updates
that all connections must process regardless of which pad is primary
- handleChunkVisibilityArea / handleChunkVisibility:
now populate m_visibleChunks; on visibility=false, setChunkVisible(false) is
only called on the level if no other connection still has that chunk loaded
- handleAddEntity, handleAddExperienceOrb, handleAddPainting, handleAddPlayer,
handleAddMob: now insert into m_trackedEntityIds on arrival
- handleRemoveEntity: now erases from m_trackedEntityIds on removal
- handleLevelEvent: removed a duplicate levelEvent() call that was always firing
regardless of the isPrimaryConnection() check above it (latent bug)
MultiPlayerLevel: added friend class ClientConnection to allow access to the
connections list without exposing it publicly.
* Fix fullscreen progress screen swallowing input before load completes
Two issues in UIScene_FullscreenProgress::handleInput:
1. The touchpad/button press that triggers movie skip or input forwarding
had no guard on m_threadCompleted, so pressing a button during the loading
phase would fire the skip/send logic before the background thread finished.
Added the m_threadCompleted check so that path is only reachable once
the load is actually done.
2. The `handled = true` assignment was missing from that branch, so input
events were not being consumed and could fall through to other handlers.
Added it unconditionally at the end of the block.
* Update player count decrement logic in PlatformNetworkManagerStub
Refactor the condition for decrementing the player count in CPlatformNetworkManagerStub::DoWork. The previous check was replaced with a while loop to ensure that the player count is only decremented when there are more than one player and the last player's custom data value is zero. This change improves the handling of player connections in the network manager.
* Refactor safe zone calculations in UI components for consistency
Updated the safe zone calculations across multiple UI components to ensure symmetry in split viewports. Removed unnecessary assignments and added comments for clarity. Modified the repositionHud function to include an additional parameter for better handling of HUD positioning in split-screen scenarios.
* Gui.cpp: fix F3 debug overlay in splitscreen + minor perf cleanup
The F3 debug screen was badly broken in splitscreen: it used the GUI
coordinate space which gets distorted by the splitscreen scaling, so
text appeared stretched, misaligned or completely off-screen depending
on the viewport layout.
Fixed by setting up a dedicated projection matrix using physical pixel
coordinates (g_rScreenWidth / g_rScreenHeight) each time the overlay is
drawn, completely decoupled from whatever transform the HUD is using.
The viewport dimensions are now computed per screen section so the ortho
projection matches the actual pixel area of each player's quadrant.
Version and branch strings are only shown for player 0 (iPad == 0) to
avoid repeating them across every splitscreen pane.
Also removed a few redundant calculations that were being done twice in
the same frame (atan for xRot, health halves, air supply scaled value).
These are minor and have negligible real-world impact; more substantial
per-frame caching work (safe zone calculations etc.) will follow in a
separate commit.
539 lines
17 KiB
C++
539 lines
17 KiB
C++
#include "stdafx.h"
|
|
#include "UI.h"
|
|
#include "UIComponent_TutorialPopup.h"
|
|
#include "UISplitScreenHelpers.h"
|
|
#include "..\..\Common\Tutorial\Tutorial.h"
|
|
#include "..\..\..\Minecraft.World\StringHelpers.h"
|
|
#include "..\..\MultiplayerLocalPlayer.h"
|
|
#include "..\..\Minecraft.h"
|
|
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h"
|
|
|
|
UIComponent_TutorialPopup::UIComponent_TutorialPopup(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
|
{
|
|
// Setup all the Iggy references we need for this scene
|
|
initialiseMovie();
|
|
|
|
m_interactScene = nullptr;
|
|
m_lastInteractSceneMoved = nullptr;
|
|
m_lastSceneMovedLeft = false;
|
|
m_bAllowFade = false;
|
|
m_iconItem = nullptr;
|
|
m_iconIsFoil = false;
|
|
|
|
m_bContainerMenuVisible = false;
|
|
m_bSplitscreenGamertagVisible = false;
|
|
m_iconType = e_ICON_TYPE_IGGY;
|
|
|
|
m_labelDescription.init(L"");
|
|
}
|
|
|
|
wstring UIComponent_TutorialPopup::getMoviePath()
|
|
{
|
|
switch( m_parentLayer->getViewport() )
|
|
{
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
|
|
return L"TutorialPopupSplit";
|
|
break;
|
|
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
|
|
default:
|
|
return L"TutorialPopup";
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::UpdateTutorialPopup()
|
|
{
|
|
// has the Splitscreen Gamertag visibility been changed? Re-Adjust Layout to prevent overlaps!
|
|
if(m_bSplitscreenGamertagVisible != (bool)(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags) != 0))
|
|
{
|
|
m_bSplitscreenGamertagVisible = (bool)(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags) != 0);
|
|
handleReload();
|
|
}
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::handleReload()
|
|
{
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
value[0].type = IGGY_DATATYPE_boolean;
|
|
value[0].boolval = (bool)((app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags)!=0) && !m_bContainerMenuVisible); // 4J - TomK - Offset for splitscreen gamertag?
|
|
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAdjustLayout, 1 , value );
|
|
|
|
setupIconHolder(m_iconType);
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::SetTutorialDescription(TutorialPopupInfo *info)
|
|
{
|
|
m_interactScene = info->interactScene;
|
|
|
|
wstring parsed = _SetIcon(info->icon, info->iAuxVal, info->isFoil, info->desc);
|
|
parsed = _SetImage( parsed );
|
|
parsed = ParseDescription(m_iPad, parsed);
|
|
|
|
if(parsed.empty())
|
|
{
|
|
_SetDescription( info->interactScene, L"", L"", info->allowFade, info->isReminder );
|
|
}
|
|
else
|
|
{
|
|
_SetDescription( info->interactScene, parsed, info->title, info->allowFade, info->isReminder );
|
|
}
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::RemoveInteractSceneReference(UIScene *scene)
|
|
{
|
|
if( m_interactScene == scene )
|
|
{
|
|
m_interactScene = nullptr;
|
|
}
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::SetVisible(bool visible)
|
|
{
|
|
m_parentLayer->showComponent(0,eUIComponent_TutorialPopup,visible);
|
|
|
|
if( visible && m_bAllowFade )
|
|
{
|
|
//Initialise a timer to fade us out again
|
|
app.DebugPrintf("UIComponent_TutorialPopup::SetVisible: setting TUTORIAL_POPUP_FADE_TIMER_ID to %d\n",m_tutorial->GetTutorialDisplayMessageTime());
|
|
addTimer(TUTORIAL_POPUP_FADE_TIMER_ID,m_tutorial->GetTutorialDisplayMessageTime());
|
|
}
|
|
}
|
|
|
|
bool UIComponent_TutorialPopup::IsVisible()
|
|
{
|
|
return m_parentLayer->isComponentVisible(eUIComponent_TutorialPopup);
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::handleTimerComplete(int id)
|
|
{
|
|
switch(id)
|
|
{
|
|
case TUTORIAL_POPUP_FADE_TIMER_ID:
|
|
SetVisible(false);
|
|
killTimer(id);
|
|
app.DebugPrintf("handleTimerComplete: setting TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID\n");
|
|
addTimer(TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID,TUTORIAL_POPUP_MOVE_SCENE_TIME);
|
|
break;
|
|
case TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID:
|
|
UpdateInteractScenePosition(IsVisible());
|
|
killTimer(id);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::_SetDescription(UIScene *interactScene, const wstring &desc, const wstring &title, bool allowFade, bool isReminder)
|
|
{
|
|
m_interactScene = interactScene;
|
|
app.DebugPrintf("Setting m_interactScene to %08x\n", m_interactScene);
|
|
if( interactScene != m_lastInteractSceneMoved ) m_lastInteractSceneMoved = nullptr;
|
|
if(desc.empty())
|
|
{
|
|
SetVisible( false );
|
|
app.DebugPrintf("_SetDescription1: setting TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID\n");
|
|
addTimer(TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID,TUTORIAL_POPUP_MOVE_SCENE_TIME);
|
|
killTimer(TUTORIAL_POPUP_FADE_TIMER_ID);
|
|
}
|
|
else
|
|
{
|
|
SetVisible( true );
|
|
app.DebugPrintf("_SetDescription2: setting TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID\n");
|
|
addTimer(TUTORIAL_POPUP_MOVE_SCENE_TIMER_ID,TUTORIAL_POPUP_MOVE_SCENE_TIME);
|
|
|
|
if( allowFade )
|
|
{
|
|
//Initialise a timer to fade us out again
|
|
app.DebugPrintf("_SetDescription: setting TUTORIAL_POPUP_FADE_TIMER_ID\n");
|
|
addTimer(TUTORIAL_POPUP_FADE_TIMER_ID,m_tutorial->GetTutorialDisplayMessageTime());
|
|
}
|
|
else
|
|
{
|
|
app.DebugPrintf("_SetDescription: killing TUTORIAL_POPUP_FADE_TIMER_ID\n");
|
|
killTimer(TUTORIAL_POPUP_FADE_TIMER_ID);
|
|
}
|
|
m_bAllowFade = allowFade;
|
|
|
|
if(isReminder)
|
|
{
|
|
wstring text(app.GetString( IDS_TUTORIAL_REMINDER ));
|
|
text.append( desc );
|
|
stripWhitespaceForHtml( text );
|
|
// set the text colour
|
|
wchar_t formatting[40];
|
|
// 4J Stu - Don't set HTML font size, that's set at design time in flash
|
|
//swprintf(formatting, 40, L"<font color=\"#%08x\" size=\"%d\">",app.GetHTMLColour(eHTMLColor_White),m_textFontSize);
|
|
swprintf(formatting, 40, L"<font color=\"#%08x\">",app.GetHTMLColour(eHTMLColor_White));
|
|
text = formatting + text;
|
|
|
|
m_labelDescription.setLabel( text, true );
|
|
}
|
|
else
|
|
{
|
|
wstring text(desc);
|
|
stripWhitespaceForHtml( text );
|
|
// set the text colour
|
|
wchar_t formatting[40];
|
|
// 4J Stu - Don't set HTML font size, that's set at design time in flash
|
|
//swprintf(formatting, 40, L"<font color=\"#%08x\" size=\"%d\">",app.GetHTMLColour(eHTMLColor_White),m_textFontSize);
|
|
swprintf(formatting, 40, L"<font color=\"#%08x\">",app.GetHTMLColour(eHTMLColor_White));
|
|
text = formatting + text;
|
|
|
|
m_labelDescription.setLabel( text, true );
|
|
|
|
}
|
|
|
|
m_labelTitle.setLabel( title, true );
|
|
m_labelTitle.setVisible(!title.empty());
|
|
|
|
|
|
// read host setting if gamertag is visible or not and pass on to Adjust Layout function (so we can offset it to stay clear of the gamertag)
|
|
m_bSplitscreenGamertagVisible = (bool)(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplaySplitscreenGamertags)!=0);
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
value[0].type = IGGY_DATATYPE_boolean;
|
|
value[0].boolval = (m_bSplitscreenGamertagVisible && !m_bContainerMenuVisible); // 4J - TomK - Offset for splitscreen gamertag?
|
|
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAdjustLayout, 1 , value );
|
|
}
|
|
}
|
|
|
|
wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWSTR desc)
|
|
{
|
|
wstring temp(desc);
|
|
|
|
bool isFixedIcon = false;
|
|
|
|
m_iconIsFoil = isFoil;
|
|
if( icon != TUTORIAL_NO_ICON )
|
|
{
|
|
m_iconIsFoil = false;
|
|
m_iconItem = std::make_shared<ItemInstance>(icon, 1, iAuxVal);
|
|
}
|
|
else
|
|
{
|
|
m_iconItem = nullptr;
|
|
wstring openTag(L"{*ICON*}");
|
|
wstring closeTag(L"{*/ICON*}");
|
|
size_t iconTagStartPos = temp.find(openTag);
|
|
size_t iconStartPos = iconTagStartPos + openTag.length();
|
|
if( iconTagStartPos > 0 && iconStartPos < temp.length() )
|
|
{
|
|
size_t iconEndPos = temp.find(closeTag, iconStartPos);
|
|
|
|
if(iconEndPos > iconStartPos && iconEndPos < temp.length() )
|
|
{
|
|
wstring id = temp.substr(iconStartPos, iconEndPos - iconStartPos);
|
|
|
|
vector<wstring> idAndAux = stringSplit(id,L':');
|
|
|
|
int iconId = _fromString<int>(idAndAux[0]);
|
|
|
|
if(idAndAux.size() > 1)
|
|
{
|
|
iAuxVal = _fromString<int>(idAndAux[1]);
|
|
}
|
|
else
|
|
{
|
|
iAuxVal = 0;
|
|
}
|
|
m_iconItem = std::make_shared<ItemInstance>(iconId, 1, iAuxVal);
|
|
|
|
temp.replace(iconTagStartPos, iconEndPos - iconTagStartPos + closeTag.length(), L"");
|
|
}
|
|
}
|
|
|
|
// remove any icon text
|
|
else if(temp.find(L"{*CraftingTableIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Tile::workBench_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*SticksIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::stick_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*PlanksIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Tile::wood_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*WoodenShovelIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::shovel_wood_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*WoodenHatchetIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::hatchet_wood_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*WoodenPickaxeIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::pickAxe_wood_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*FurnaceIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Tile::furnace_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*WoodenDoorIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::door_wood, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*TorchIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Tile::torch_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*BoatIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::boat_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*FishingRodIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::fishingRod_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*FishIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::fish_raw_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*MinecartIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Item::minecart_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*RailIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Tile::rail_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*PoweredRailIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Tile::goldenRail_Id, 1, 0);
|
|
}
|
|
else if(temp.find(L"{*StructuresIcon*}")!=wstring::npos)
|
|
{
|
|
isFixedIcon = true;
|
|
setupIconHolder(e_ICON_TYPE_STRUCTURES);
|
|
}
|
|
else if(temp.find(L"{*ToolsIcon*}")!=wstring::npos)
|
|
{
|
|
isFixedIcon = true;
|
|
setupIconHolder(e_ICON_TYPE_TOOLS);
|
|
}
|
|
else if(temp.find(L"{*StoneIcon*}")!=wstring::npos)
|
|
{
|
|
m_iconItem = std::make_shared<ItemInstance>(Tile::stone_Id, 1, 0);
|
|
}
|
|
else
|
|
{
|
|
m_iconItem = nullptr;
|
|
}
|
|
}
|
|
if(!isFixedIcon && m_iconItem != nullptr) setupIconHolder(e_ICON_TYPE_IGGY);
|
|
m_controlIconHolder.setVisible( isFixedIcon || m_iconItem != nullptr);
|
|
|
|
return temp;
|
|
}
|
|
|
|
wstring UIComponent_TutorialPopup::_SetImage(wstring &desc)
|
|
{
|
|
// 4J Stu - Unused
|
|
#if 0
|
|
BOOL imageShowAtStart = m_image.IsShown();
|
|
|
|
wstring openTag(L"{*IMAGE*}");
|
|
wstring closeTag(L"{*/IMAGE*}");
|
|
size_t imageTagStartPos = desc.find(openTag);
|
|
size_t imageStartPos = imageTagStartPos + openTag.length();
|
|
if( imageTagStartPos > 0 && imageStartPos < desc.length() )
|
|
{
|
|
size_t imageEndPos = desc.find( closeTag, imageStartPos );
|
|
|
|
if(imageEndPos > imageStartPos && imageEndPos < desc.length() )
|
|
{
|
|
wstring id = desc.substr(imageStartPos, imageEndPos - imageStartPos);
|
|
m_image.SetImagePath( id.c_str() );
|
|
m_image.SetShow( TRUE );
|
|
|
|
desc.replace(imageTagStartPos, imageEndPos - imageTagStartPos + closeTag.length(), L"");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// hide the icon slot
|
|
m_image.SetShow( FALSE );
|
|
}
|
|
|
|
BOOL imageShowAtEnd = m_image.IsShown();
|
|
if(imageShowAtStart != imageShowAtEnd)
|
|
{
|
|
float fHeight, fWidth, fIconHeight, fDescHeight, fDescWidth;
|
|
m_image.GetBounds(&fWidth,&fIconHeight);
|
|
GetBounds(&fWidth,&fHeight);
|
|
|
|
|
|
// 4J Stu - For some reason when we resize the scene it resets the size of the HTML control
|
|
// We don't want that to happen, so get it's size before and set it back after
|
|
m_description.GetBounds(&fDescWidth,&fDescHeight);
|
|
if(imageShowAtEnd)
|
|
{
|
|
SetBounds(fWidth, fHeight + fIconHeight);
|
|
}
|
|
else
|
|
{
|
|
SetBounds(fWidth, fHeight - fIconHeight);
|
|
}
|
|
m_description.SetBounds(fDescWidth, fDescHeight);
|
|
}
|
|
#endif
|
|
return desc;
|
|
}
|
|
|
|
|
|
wstring UIComponent_TutorialPopup::ParseDescription(int iPad, wstring &text)
|
|
{
|
|
text = replaceAll(text, L"{*CraftingTableIcon*}", L"");
|
|
text = replaceAll(text, L"{*SticksIcon*}", L"");
|
|
text = replaceAll(text, L"{*PlanksIcon*}", L"");
|
|
text = replaceAll(text, L"{*WoodenShovelIcon*}", L"");
|
|
text = replaceAll(text, L"{*WoodenHatchetIcon*}", L"");
|
|
text = replaceAll(text, L"{*WoodenPickaxeIcon*}", L"");
|
|
text = replaceAll(text, L"{*FurnaceIcon*}", L"");
|
|
text = replaceAll(text, L"{*WoodenDoorIcon*}", L"");
|
|
text = replaceAll(text, L"{*TorchIcon*}", L"");
|
|
text = replaceAll(text, L"{*MinecartIcon*}", L"");
|
|
text = replaceAll(text, L"{*BoatIcon*}", L"");
|
|
text = replaceAll(text, L"{*FishingRodIcon*}", L"");
|
|
text = replaceAll(text, L"{*FishIcon*}", L"");
|
|
text = replaceAll(text, L"{*RailIcon*}", L"");
|
|
text = replaceAll(text, L"{*PoweredRailIcon*}", L"");
|
|
text = replaceAll(text, L"{*StructuresIcon*}", L"");
|
|
text = replaceAll(text, L"{*ToolsIcon*}", L"");
|
|
text = replaceAll(text, L"{*StoneIcon*}", L"");
|
|
|
|
bool exitScreenshot = false;
|
|
size_t pos = text.find(L"{*EXIT_PICTURE*}");
|
|
if(pos != wstring::npos) exitScreenshot = true;
|
|
text = replaceAll(text, L"{*EXIT_PICTURE*}", L"");
|
|
m_controlExitScreenshot.setVisible(exitScreenshot);
|
|
/*
|
|
#define MINECRAFT_ACTION_RENDER_DEBUG ACTION_INGAME_13
|
|
#define MINECRAFT_ACTION_PAUSEMENU ACTION_INGAME_15
|
|
#define MINECRAFT_ACTION_SNEAK_TOGGLE ACTION_INGAME_17
|
|
*/
|
|
|
|
return app.FormatHTMLString(iPad,text);
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::UpdateInteractScenePosition(bool visible)
|
|
{
|
|
if( m_interactScene == nullptr ) return;
|
|
|
|
// 4J-PB - check this players screen section to see if we should allow the animation
|
|
bool bAllowAnim=false;
|
|
bool isCraftingScene = (m_interactScene->getSceneType() == eUIScene_Crafting2x2Menu) || (m_interactScene->getSceneType() == eUIScene_Crafting3x3Menu);
|
|
bool isCreativeScene = (m_interactScene->getSceneType() == eUIScene_CreativeMenu);
|
|
bool isTradingScene = (m_interactScene->getSceneType() == eUIScene_TradingMenu);
|
|
switch(Minecraft::GetInstance()->localplayers[m_iPad]->m_iScreenSection)
|
|
{
|
|
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
|
|
bAllowAnim=true;
|
|
break;
|
|
default:
|
|
// anim allowed for everything except the crafting 2x2 and 3x3, and the creative menu
|
|
if(!isCraftingScene && !isCreativeScene && !isTradingScene)
|
|
{
|
|
bAllowAnim=true;
|
|
}
|
|
break;
|
|
}
|
|
|
|
if(bAllowAnim)
|
|
{
|
|
bool movingLeft = visible;
|
|
|
|
if( (m_lastInteractSceneMoved != m_interactScene && movingLeft) || ( m_lastInteractSceneMoved == m_interactScene && m_lastSceneMovedLeft != movingLeft ) )
|
|
{
|
|
if(movingLeft)
|
|
{
|
|
m_interactScene->slideLeft();
|
|
}
|
|
else
|
|
{
|
|
m_interactScene->slideRight();
|
|
}
|
|
|
|
m_lastInteractSceneMoved = m_interactScene;
|
|
m_lastSceneMovedLeft = movingLeft;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::render(S32 width, S32 height, C4JRender::eViewportType viewport)
|
|
{
|
|
if(viewport != C4JRender::VIEWPORT_TYPE_FULLSCREEN)
|
|
{
|
|
// Derive the viewport origin and fit a 16:9 box inside it (same as UIScene::render),
|
|
// then apply safezone nudges so the popup stays clear of screen edges.
|
|
F32 originX, originY, viewW, viewH;
|
|
GetViewportRect(ui.getScreenWidth(), ui.getScreenHeight(), viewport, originX, originY, viewW, viewH);
|
|
|
|
S32 fitW, fitH, offsetX, offsetY;
|
|
Fit16x9(viewW, viewH, fitW, fitH, offsetX, offsetY);
|
|
|
|
S32 xPos = static_cast<S32>(originX) + offsetX;
|
|
S32 yPos = static_cast<S32>(originY) + offsetY;
|
|
|
|
//Adjust for safezone
|
|
switch( viewport )
|
|
{
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
|
|
yPos += getSafeZoneHalfHeight();
|
|
break;
|
|
default: break;
|
|
}
|
|
switch( viewport )
|
|
{
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
|
|
xPos -= getSafeZoneHalfWidth();
|
|
break;
|
|
default: break;
|
|
}
|
|
ui.setupRenderPosition(xPos, yPos);
|
|
|
|
IggyPlayerSetDisplaySize( getMovie(), fitW, fitH );
|
|
IggyPlayerDraw( getMovie() );
|
|
}
|
|
else
|
|
{
|
|
UIScene::render(width, height, viewport);
|
|
}
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::customDraw(IggyCustomDrawCallbackRegion *region)
|
|
{
|
|
if(m_iconItem != nullptr) customDrawSlotControl(region,m_iPad,m_iconItem,1.0f,m_iconItem->isFoil() || m_iconIsFoil,false);
|
|
}
|
|
|
|
void UIComponent_TutorialPopup::setupIconHolder(EIcons icon)
|
|
{
|
|
app.DebugPrintf("Setting icon holder to %d\n", icon);
|
|
IggyDataValue result;
|
|
IggyDataValue value[1];
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = static_cast<F64>(icon);
|
|
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetupIconHolder , 1 , value );
|
|
|
|
m_iconType = icon;
|
|
}
|