Added: Allow to set UI scale with /setuiscale command
--HG-- branch : experimental-ui-scaling
This commit is contained in:
parent
4ba3973295
commit
0af4ea6687
5 changed files with 35 additions and 5 deletions
|
@ -122,6 +122,8 @@
|
|||
|
||||
<command name="loot" action="inv_temp_all" params="" />
|
||||
|
||||
<command name="setuiscale" action="set_ui_scale" params="scale=$"/>
|
||||
|
||||
<!-- WebIG -->
|
||||
<command name="go" action="browse" params="name=ui:interface:webig:content:html|url=home"/>
|
||||
<command name="webdev" action="browse" params="name=ui:interface:webig:content:html|url=http://localhost/index.html"/>
|
||||
|
|
|
@ -839,8 +839,7 @@ void CClientConfig::setValues()
|
|||
READ_FLOAT_FV(Gamma)
|
||||
// UI scaling
|
||||
READ_FLOAT_FV(InterfaceScale);
|
||||
// 50% smaller / 2x bigger
|
||||
clamp(ClientCfg.InterfaceScale, 0.5f, 2.0f);
|
||||
clamp(ClientCfg.InterfaceScale, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE);
|
||||
READ_BOOL_FV(BilinearUI);
|
||||
// 3D Driver
|
||||
varPtr = ClientCfg.ConfigFile.getVarPtr ("Driver3D");
|
||||
|
|
|
@ -46,6 +46,9 @@ using NLMISC::CVector;
|
|||
using NLMISC::CRGBA;
|
||||
using std::string;
|
||||
|
||||
// limits for UI scale
|
||||
const float MIN_INTERFACE_SCALE = 0.8;
|
||||
const float MAX_INTERFACE_SCALE = 2.0;
|
||||
|
||||
//---------------------------------------------------
|
||||
// CClientConfig :
|
||||
|
|
|
@ -3732,6 +3732,34 @@ class CHandlerGameConfigChangeScreenRatioCustom : public IActionHandler
|
|||
};
|
||||
REGISTER_ACTION_HANDLER (CHandlerGameConfigChangeScreenRatioCustom, "game_config_change_screen_ratio_custom");
|
||||
|
||||
// ***************************************************************************
|
||||
class CHandlerSetInterfaceScale : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase *pCaller, const string &Params)
|
||||
{
|
||||
std::string s;
|
||||
s = getParam(Params, "scale");
|
||||
if (!s.empty()) {
|
||||
float scale;
|
||||
if (fromString(s, scale))
|
||||
{
|
||||
if (scale >= MIN_INTERFACE_SCALE && scale <= MAX_INTERFACE_SCALE)
|
||||
{
|
||||
ClientCfg.InterfaceScale = scale;
|
||||
ClientCfg.writeDouble("InterfaceScale", ClientCfg.InterfaceScale);
|
||||
|
||||
ClientCfg.IsInvalidated = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ucstring help("/setuiscale "+toString("%.1f .. %.1f", MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE));
|
||||
CInterfaceManager::getInstance()->displaySystemInfo(help);
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CHandlerSetInterfaceScale, "set_ui_scale");
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
class CHandlerGameMissionAbandon : public IActionHandler
|
||||
|
|
|
@ -2038,8 +2038,7 @@ 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
|
||||
// scale must be updated right before widget manager checks it
|
||||
if (_InterfaceScaleChanged)
|
||||
{
|
||||
CViewRenderer::getInstance()->setInterfaceScale(_InterfaceScale);
|
||||
|
@ -2916,7 +2915,6 @@ NLMISC_COMMAND(loadui, "Load an interface file", "<loadui [all]/interface.xml>")
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CInterfaceManager::displayWebWindow(const string & name, const string & url)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue