mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Change the shadow map quality without restarting the match.
Differential Revision: https://code.wildfiregames.com/D804 Refs #4351 Patch By: Vladislav This was SVN commit r20011.
This commit is contained in:
@@ -238,9 +238,11 @@ function setupControl(option, i, category)
|
||||
control.onMouseLeave = onUpdate;
|
||||
break;
|
||||
case "dropdown":
|
||||
{
|
||||
control = Engine.GetGUIObjectByName(category + "Dropdown[" + i + "]");
|
||||
control.onSelectionChange = function(){}; // just the time to setup the value
|
||||
let config;
|
||||
let callbackFunction;
|
||||
|
||||
for (let param in option.parameters)
|
||||
{
|
||||
@@ -249,6 +251,10 @@ function setupControl(option, i, category)
|
||||
case "config":
|
||||
config = Engine.ConfigDB_GetValue("user", key);
|
||||
break;
|
||||
case "function":
|
||||
if (Engine[option.parameters.function])
|
||||
callbackFunction = option.parameters.function;
|
||||
break;
|
||||
case "list":
|
||||
control.list = option.parameters.list.map(e => translate(e.label));
|
||||
let values = option.parameters.list.map(e => e.value);
|
||||
@@ -260,18 +266,21 @@ function setupControl(option, i, category)
|
||||
}
|
||||
}
|
||||
|
||||
onUpdate = function(key)
|
||||
onUpdate = function(key, callbackFunction)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
Engine.ConfigDB_CreateValue("user", key, this.list_data[this.selected]);
|
||||
Engine.ConfigDB_SetChanges("user", true);
|
||||
if (callbackFunction)
|
||||
Engine[callbackFunction](this.list_data[this.selected]);
|
||||
updateOptionPanel();
|
||||
};
|
||||
}(key);
|
||||
}(key, callbackFunction);
|
||||
|
||||
control.onSelectionChange = onUpdate;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
warn("Unknown option type " + option.type + ", assuming string.");
|
||||
control = Engine.GetGUIObjectByName(category + "Input[" + i + "]");
|
||||
@@ -359,7 +368,7 @@ function revertChanges()
|
||||
// and the possible function calls (which are of number or string types)
|
||||
if (control.parameters.function)
|
||||
{
|
||||
if (control.type !== "string" && control.type !== "number" && control.type !== "slider")
|
||||
if (control.type != "string" && control.type != "number" && control.type != "slider" && control.type != "dropdown")
|
||||
{
|
||||
warn("Invalid type option " + control.type + " defined with function for " + item + ": will not be reverted");
|
||||
continue;
|
||||
|
||||
@@ -166,9 +166,10 @@
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "Shadow Quality",
|
||||
"tooltip": "Shadow map resolution. High values can crash the game when using a graphics card with low memory! REQUIRES GAME RESTART",
|
||||
"tooltip": "Shadow map resolution. High values can crash the game when using a graphics card with low memory!",
|
||||
"parameters": {
|
||||
"config": "shadowquality",
|
||||
"function": "Renderer_RecreateShadowMap",
|
||||
"list": [
|
||||
{ "value": -2, "label": "Very Low" },
|
||||
{ "value": -1, "label": "Low" },
|
||||
|
||||
@@ -2126,6 +2126,11 @@ CFontManager& CRenderer::GetFontManager()
|
||||
return m->fontManager;
|
||||
}
|
||||
|
||||
ShadowMap& CRenderer::GetShadowMap()
|
||||
{
|
||||
return m->shadow;
|
||||
}
|
||||
|
||||
void CRenderer::ResetState()
|
||||
{
|
||||
// Clear all emitters, that were created in previous games
|
||||
|
||||
@@ -48,6 +48,7 @@ class CTextureManager;
|
||||
class CTimeManager;
|
||||
class RenderPathVertexShader;
|
||||
class ScriptInterface;
|
||||
class ShadowMap;
|
||||
class SkyManager;
|
||||
class TerrainRenderer;
|
||||
class WaterManager;
|
||||
@@ -330,6 +331,8 @@ public:
|
||||
*/
|
||||
const Caps& GetCapabilities() const { return m_Caps; }
|
||||
|
||||
ShadowMap& GetShadowMap();
|
||||
|
||||
static void RegisterScriptFunctions(ScriptInterface& scriptInterface);
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "JSInterface_Renderer.h"
|
||||
#include "ps/Profile.h"
|
||||
#include "renderer/Renderer.h"
|
||||
#include "renderer/ShadowMap.h"
|
||||
|
||||
#define IMPLEMENT_BOOLEAN_SCRIPT_SETTING(NAME, SCRIPTNAME) \
|
||||
bool JSI_Renderer::Get##SCRIPTNAME##Enabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) \
|
||||
@@ -60,6 +61,11 @@ void JSI_Renderer::SetRenderPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate),
|
||||
g_Renderer.SetRenderPath(CRenderer::GetRenderPathByName(name));
|
||||
}
|
||||
|
||||
void JSI_Renderer::RecreateShadowMap(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
||||
{
|
||||
g_Renderer.GetShadowMap().RecreateTexture();
|
||||
}
|
||||
|
||||
|
||||
#define REGISTER_BOOLEAN_SCRIPT_SETTING(NAME) \
|
||||
scriptInterface.RegisterFunction<bool, &JSI_Renderer::Get##NAME##Enabled>("Renderer_Get" #NAME "Enabled"); \
|
||||
@@ -69,6 +75,7 @@ void JSI_Renderer::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
||||
{
|
||||
scriptInterface.RegisterFunction<std::string, &JSI_Renderer::GetRenderPath>("Renderer_GetRenderPath");
|
||||
scriptInterface.RegisterFunction<void, std::string, &JSI_Renderer::SetRenderPath>("Renderer_SetRenderPath");
|
||||
scriptInterface.RegisterFunction<void, &JSI_Renderer::RecreateShadowMap>("Renderer_RecreateShadowMap");
|
||||
REGISTER_BOOLEAN_SCRIPT_SETTING(Shadows);
|
||||
REGISTER_BOOLEAN_SCRIPT_SETTING(ShadowPCF);
|
||||
REGISTER_BOOLEAN_SCRIPT_SETTING(Particles);
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace JSI_Renderer
|
||||
{
|
||||
std::string GetRenderPath(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
void SetRenderPath(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name);
|
||||
void RecreateShadowMap(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
|
||||
DECLARE_BOOLEAN_SCRIPT_SETTING(Shadows);
|
||||
DECLARE_BOOLEAN_SCRIPT_SETTING(ShadowPCF);
|
||||
|
||||
Reference in New Issue
Block a user