mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-03-23 01:18:13 +05:00
* Fix split-screen UI wrong positioning on window resize In vertical split at window heights below 1080, ComputeTileScale's min-scale clamp (>= 1.0) prevented the SWF from scaling down to fit, cropping the bottom and causing repositionHud to shift HUD elements downward. Chat and Tooltips additionally applied an offset from ComputeSplitContentOffset that only produced correct values at the 1920x1080 design resolution. Override the scale for vertical split so the SWF fits the full window height when it is shorter than the movie. Remove the broken content offset from Chat and Tooltips -- the tile crop already positions the content correctly. * Fix gamma post-process in split-screen The gamma shader sampled the full backbuffer texture (UV 0..1) into each player's viewport, stretching the entire screen into every split region. Extended the shader constant buffer with per-viewport UV offset and scale so each pass samples only its own portion of the backbuffer. ComputeViewportForPlayer was hardcoded to top/bottom for 2 players, ignoring the vertical split setting. Rewrote it to read each player's m_iScreenSection directly, which already accounts for the split orientation preference. Secondary players have no Graphics menu and cannot change gamma. CachePlayerGammas now reads the primary player's setting and applies it uniformly to all viewports.
174 lines
4.8 KiB
C++
174 lines
4.8 KiB
C++
#include "stdafx.h"
|
|
#include "UI.h"
|
|
#include "UIComponent_Chat.h"
|
|
#include "UISplitScreenHelpers.h"
|
|
#include "..\..\Minecraft.h"
|
|
#include "..\..\Gui.h"
|
|
|
|
UIComponent_Chat::UIComponent_Chat(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
|
{
|
|
// Setup all the Iggy references we need for this scene
|
|
initialiseMovie();
|
|
|
|
for(unsigned int i = 0; i < CHAT_LINES_COUNT; ++i)
|
|
{
|
|
m_labelChatText[i].init(L"");
|
|
}
|
|
m_labelJukebox.init(L"");
|
|
|
|
addTimer(0, 100);
|
|
}
|
|
|
|
wstring UIComponent_Chat::getMoviePath()
|
|
{
|
|
switch( m_parentLayer->getViewport() )
|
|
{
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
|
|
m_bSplitscreen = true;
|
|
return L"ComponentChatSplit";
|
|
break;
|
|
case C4JRender::VIEWPORT_TYPE_FULLSCREEN:
|
|
default:
|
|
m_bSplitscreen = false;
|
|
return L"ComponentChat";
|
|
break;
|
|
}
|
|
}
|
|
|
|
void UIComponent_Chat::handleTimerComplete(int id)
|
|
{
|
|
Minecraft *pMinecraft = Minecraft::GetInstance();
|
|
|
|
bool anyVisible = false;
|
|
if(pMinecraft->localplayers[m_iPad]!= nullptr)
|
|
{
|
|
Gui *pGui = pMinecraft->gui;
|
|
//DWORD messagesToDisplay = 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 )
|
|
{
|
|
#ifdef _WINDOWS64
|
|
// Chat drawn by Gui::render with color codes. Hides Iggy chat to avoid double chats.
|
|
m_controlLabelBackground[i].setOpacity(0);
|
|
m_labelChatText[i].setOpacity(0);
|
|
m_labelChatText[i].setLabel(L"");
|
|
#else
|
|
m_controlLabelBackground[i].setOpacity(opacity);
|
|
m_labelChatText[i].setOpacity(opacity);
|
|
m_labelChatText[i].setLabel( pGui->getMessage(m_iPad,i) );
|
|
#endif
|
|
anyVisible = true;
|
|
}
|
|
else
|
|
{
|
|
m_controlLabelBackground[i].setOpacity(0);
|
|
m_labelChatText[i].setOpacity(0);
|
|
m_labelChatText[i].setLabel(L"");
|
|
}
|
|
}
|
|
if(pGui->getJukeboxOpacity(m_iPad) > 0) anyVisible = true;
|
|
m_labelJukebox.setOpacity( pGui->getJukeboxOpacity(m_iPad) );
|
|
m_labelJukebox.setLabel( pGui->getJukeboxMessage(m_iPad) );
|
|
}
|
|
else
|
|
{
|
|
for( unsigned int i = 0; i < CHAT_LINES_COUNT; ++i )
|
|
{
|
|
m_controlLabelBackground[i].setOpacity(0);
|
|
m_labelChatText[i].setOpacity(0);
|
|
m_labelChatText[i].setLabel(L"");
|
|
}
|
|
m_labelJukebox.setOpacity( 0 );
|
|
}
|
|
|
|
setVisible(anyVisible);
|
|
}
|
|
|
|
void UIComponent_Chat::render(S32 width, S32 height, C4JRender::eViewportType viewport)
|
|
{
|
|
if(m_bSplitscreen)
|
|
{
|
|
S32 xPos = 0;
|
|
S32 yPos = 0;
|
|
switch( viewport )
|
|
{
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
|
|
yPos = static_cast<S32>(ui.getScreenHeight() / 2);
|
|
break;
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
|
|
xPos = static_cast<S32>(ui.getScreenWidth() / 2);
|
|
break;
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
|
|
xPos = static_cast<S32>(ui.getScreenWidth() / 2);
|
|
yPos = static_cast<S32>(ui.getScreenHeight() / 2);
|
|
break;
|
|
}
|
|
ui.setupRenderPosition(xPos, yPos);
|
|
|
|
S32 tileXStart = 0;
|
|
S32 tileYStart = 0;
|
|
S32 tileWidth = width;
|
|
S32 tileHeight = height;
|
|
|
|
bool needsYTile = false;
|
|
switch( viewport )
|
|
{
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
|
|
tileHeight = static_cast<S32>(ui.getScreenHeight());
|
|
break;
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
|
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
|
|
tileWidth = static_cast<S32>(ui.getScreenWidth());
|
|
needsYTile = true;
|
|
break;
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
|
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
|
|
needsYTile = true;
|
|
break;
|
|
}
|
|
|
|
F32 scale;
|
|
ComputeTileScale(tileWidth, tileHeight, m_movieWidth, m_movieHeight, needsYTile, scale, tileYStart);
|
|
|
|
// For vertical split, scale down to fit the full SWF height when the
|
|
// window is shorter than the movie (same fix as HUD).
|
|
if(!needsYTile && m_movieHeight > 0)
|
|
{
|
|
F32 scaleH = (F32)tileHeight / (F32)m_movieHeight;
|
|
if(scaleH < scale)
|
|
scale = scaleH;
|
|
}
|
|
|
|
IggyPlayerSetDisplaySize( getMovie(), (S32)(m_movieWidth * scale), (S32)(m_movieHeight * scale) );
|
|
|
|
IggyPlayerDrawTilesStart ( getMovie() );
|
|
|
|
m_renderWidth = tileWidth;
|
|
m_renderHeight = tileHeight;
|
|
IggyPlayerDrawTile ( getMovie() ,
|
|
tileXStart ,
|
|
tileYStart ,
|
|
tileXStart + tileWidth ,
|
|
tileYStart + tileHeight ,
|
|
0 );
|
|
IggyPlayerDrawTilesEnd ( getMovie() );
|
|
}
|
|
else
|
|
{
|
|
UIScene::render(width, height, viewport);
|
|
}
|
|
} |