Added: Scaling options to client config

--HG--
branch : experimental-ui-scaling
This commit is contained in:
Nimetu 2016-06-03 14:26:17 +03:00
parent cf357edcb9
commit b474f39970
8 changed files with 54 additions and 2 deletions

View file

@ -878,10 +878,17 @@
posparent="lum"
x="0"
y="-2" />
<instance template="tgcw_scrollbarfloat"
id="scale"
text="uiInterfaceScale"
posref="BL TL"
posparent="gam"
x="0"
y="-2" />
<instance template="tgcw_checkbox"
id="waitvbl"
text="uiWaitVBL"
posparent="gam"
posparent="scale"
posref="BL TL"
x="-20"
y="-28" />
@ -3086,6 +3093,13 @@
realtime="true"
widget="sbfloat"
link="Gamma" />
<param ui="general:scale:c"
type="cfg"
realtime="false"
ui_view="general:scale:c_res"
ui_decimal="2"
widget="sbfloat"
link="InterfaceScale" />
<param ui="general:waitvbl:c"
type="cfg"
realtime="true"

View file

@ -300,6 +300,8 @@ CClientConfig::CClientConfig()
Luminosity = 0.f; // Default Monitor Luminosity.
Gamma = 0.f; // Default Monitor Gamma.
InterfaceScale = 1.0f; // Resize UI
VREnable = false;
VRDisplayDevice = "Auto";
VRDisplayDeviceId = "";
@ -833,6 +835,10 @@ void CClientConfig::setValues()
READ_FLOAT_FV(Luminosity)
// Gamma
READ_FLOAT_FV(Gamma)
// UI scaling
READ_FLOAT_FV(InterfaceScale);
// 50% smaller / 2x bigger
clamp(ClientCfg.InterfaceScale, 0.5f, 2.0f);
// 3D Driver
varPtr = ClientCfg.ConfigFile.getVarPtr ("Driver3D");
if (varPtr)

View file

@ -146,6 +146,9 @@ struct CClientConfig
/// Monitor Gamma [-1 ~ 1], default 0
float Gamma;
// UI scaling
float InterfaceScale;
// VR
bool VREnable;
std::string VRDisplayDevice;

View file

@ -227,6 +227,9 @@ void connectionRestoreVideoMode ()
SetMouseCursor ();
SetMouseSpeed (ClientCfg.CursorSpeed);
SetMouseAcceleration (ClientCfg.CursorAcceleration);
// Restore user UI scaling
CViewRenderer::getInstance()->setInterfaceScale(ClientCfg.InterfaceScale);
}
@ -290,6 +293,8 @@ void setOutGameFullScreen()
*/
}
// Enable auto scaling in login window
CViewRenderer::getInstance()->setInterfaceScale(1.0f, 1024, 768);
}
@ -454,6 +459,9 @@ bool connection (const string &cookie, const string &fsaddr)
firstConnection = false;
// Restore user UI scaling
CViewRenderer::getInstance()->setInterfaceScale(ClientCfg.InterfaceScale);
// Disable inputs
Actions.enable(false);
EditActions.enable(false);
@ -586,6 +594,9 @@ bool reconnection()
InterfaceState = globalMenu();
}
// Restore user UI scaling
CViewRenderer::getInstance()->setInterfaceScale(ClientCfg.InterfaceScale);
// Disable inputs
Actions.enable(false);
EditActions.enable(false);

View file

@ -1316,6 +1316,7 @@ void prelogInit()
CInterfaceManager::getInstance();
CViewRenderer::getInstance()->setInterfaceScale(1.0f, 1024, 768);
// Yoyo: initialize NOW the InputHandler for Event filtering.
CInputHandlerManager *InputHandlerManager = CInputHandlerManager::getInstance();

View file

@ -475,6 +475,8 @@ CInterfaceManager::CInterfaceManager()
interfaceLinkUpdater = new CInterfaceLink::CInterfaceLinkUpdater();
_ScreenW = _ScreenH = 0;
_LastInGameScreenW = _LastInGameScreenH = 0;
_InterfaceScaleChanged = false;
_InterfaceScale = 1.0f;
_DescTextTarget = NULL;
_ConfigLoaded = false;
_LogState = false;
@ -1984,6 +1986,14 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera)
_CurrentPlayerCharac[i] = node ? node->getValue32() : 0;
}
// update value change from ingame config window
// must update it here, right before widget manager checks it
if (_InterfaceScaleChanged)
{
CViewRenderer::getInstance()->setInterfaceScale(_InterfaceScale);
_InterfaceScaleChanged = false;
}
CWidgetManager::getInstance()->drawViews( camera );
// flush obs

View file

@ -543,6 +543,7 @@ public:
NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_FACTION_TYPE;
void updateDesktops( uint32 newScreenW, uint32 newScreenH );
void setInterfaceScale( float scale ) { _InterfaceScaleChanged = true; _InterfaceScale = scale; }
private:
@ -581,6 +582,8 @@ private:
uint32 _ScreenW, _ScreenH; // Change res detection
sint32 _LastInGameScreenW, _LastInGameScreenH; // Resolution used for last InGame interface
float _InterfaceScale;
bool _InterfaceScaleChanged;
// Modes
CInterfaceConfig::CDesktopImage _Modes[MAX_NUM_MODES];

View file

@ -36,6 +36,7 @@
#include "input.h"
#include "sound_manager.h"
#include "camera.h"
#include "interface_v3/interface_manager.h"
using namespace NLMISC;
using namespace NL3D;
@ -100,6 +101,9 @@ void updateFromClientCfg()
Driver->forceTextureResize(1);
}
if (ClientCfg.InterfaceScale != LastClientCfg.InterfaceScale)
CInterfaceManager::getInstance()->setInterfaceScale(ClientCfg.InterfaceScale);
//---------------------------------------------------
if (ClientCfg.WaitVBL != LastClientCfg.WaitVBL)
{
@ -395,4 +399,4 @@ void updateFromClientCfg()
LastClientCfg = ClientCfg;
}
/* end of file */
/* end of file */