Ticket #2310: 0ad_save_graphics_settings_v2.diff

File 0ad_save_graphics_settings_v2.diff, 15.8 KB (added by José Manuel Santamaría Lema, 10 years ago)
  • binaries/data/mods/public/gui/options/options.xml

    diff --git a/binaries/data/mods/public/gui/options/options.xml b/binaries/data/mods/public/gui/options/options.xml
    index b6de0e9..352fc97 100644
    a b  
    3131        </object>
    3232        <object name="GraphicsSettings" type="image" sprite="BackgroundIndentFillDark" size="316 16 616 100%-16">
    3333            <object style="TitleText" type="text" size="0 5 100% 25">Graphics Settings</object>
     34
    3435            <object size="0 25 65% 50" type="text" style="RightLabelText" ghost="true">Enable Shadows</object>
    3536            <object name="ShadowsCFG" size="70% 30 70%+25 55" type="checkbox" style="StoneCrossBox">
    36                 <action on="Load">this.checked = Engine.Renderer_GetShadowsEnabled();</action>
    37                 <action on="Press">Engine.Renderer_SetShadowsEnabled(this.checked);</action>
     37                <action on="Load">
     38                    if (Engine.Renderer_GetShadowsAvailable()) {
     39                        Engine.ConfigDB_GetValue("user", "shadows") === "true" ? this.checked = true : this.checked = false;
     40                    } else {
     41                        this.enabled = false;
     42                        this.checked = false;
     43                    }
     44                </action>
     45                <action on="Press">
     46                    Engine.Renderer_SetShadowsEnabled(this.checked);
     47                    Engine.ConfigDB_CreateValue("user", "shadows", String(this.checked));
     48                </action>
    3849            </object>
     50
    3951            <object size="0 50 65% 75" type="text" style="RightLabelText" ghost="true">Enable Shadow Filtering</object>
    4052            <object name="ShadowPCFCFGNow" size="70% 55 70%+25 80" type="checkbox" style="StoneCrossBox">
    41                 <action on="Load">this.checked = Engine.Renderer_GetShadowPCFEnabled();</action>
    42                 <action on="Press">Engine.Renderer_SetShadowPCFEnabled(this.checked);</action>
     53                <action on="Load">
     54                    Engine.ConfigDB_GetValue("user", "shadowpcf") === "true" ? this.checked = true : this.checked = false;
     55                </action>
     56                <action on="Press">
     57                    Engine.Renderer_SetShadowPCFEnabled(this.checked);
     58                    Engine.ConfigDB_CreateValue("user", "shadowpcf", String(this.checked));
     59                </action>
     60            </object>
     61
     62            <object size="0 75 65% 100" type="text" style="RightLabelText" ghost="true">Normal water</object>
     63            <object name="normalWaterCFG" size="70% 80 70%+25 105" type="checkbox" style="StoneCrossBox">
     64                <action on="Load">
     65                    Engine.ConfigDB_GetValue("user", "waternormals") === "true" ? this.checked = true : this.checked = false;
     66                </action>
     67                <action on="Press">
     68                    Engine.Renderer_SetWaterNormalEnabled(this.checked);
     69                    Engine.ConfigDB_CreateValue("user", "waternormals", String(this.checked));
     70                </action>
     71            </object>
     72
     73            <object size="0 100 65% 125" type="text" style="RightLabelText" ghost="true">Real depth water</object>
     74            <object name="realDepthWaterCFG" size="70% 105 70%+25 130" type="checkbox" style="StoneCrossBox">
     75                <action on="Load">
     76                    Engine.ConfigDB_GetValue("user", "waterrealdepth") === "true" ? this.checked = true : this.checked = false;
     77                </action>
     78                <action on="Press">
     79                    Engine.Renderer_SetWaterRealDepthEnabled(this.checked);
     80                    Engine.ConfigDB_CreateValue("user", "waterrealdepth", String(this.checked));
     81                </action>
     82            </object>
     83
     84            <object size="0 125 65% 150" type="text" style="RightLabelText" ghost="true">Water foam</object>
     85            <object name="waterFoamCFG" size="70% 130 70%+25 155" type="checkbox" style="StoneCrossBox">
     86                <action on="Load">
     87                    Engine.ConfigDB_GetValue("user", "waterfoam") === "true" ? this.checked = true : this.checked = false;
     88                </action>
     89                <action on="Press">
     90                    Engine.Renderer_SetWaterFoamEnabled(this.checked);
     91                    Engine.ConfigDB_CreateValue("user", "waterfoam", String(this.checked));
     92                </action>
     93            </object>
     94
     95            <object size="0 150 65% 175" type="text" style="RightLabelText" ghost="true">Coastal Waves</object>
     96            <object name="coastalWavesCFG" size="70% 155 70%+25 180" type="checkbox" style="StoneCrossBox">
     97                <action on="Load">
     98                    Engine.ConfigDB_GetValue("user", "watercoastalwaves") === "true" ? this.checked = true : this.checked = false;
     99                </action>
     100                <action on="Press">
     101                    Engine.Renderer_SetWaterCoastalWavesEnabled(this.checked);
     102                    Engine.ConfigDB_CreateValue("user", "watercoastalwaves", String(this.checked));
     103                </action>
     104            </object>
     105
     106            <object size="0 175 65% 200" type="text" style="RightLabelText" ghost="true">Water reflection</object>
     107            <object name="waterReflectionCFG" size="70% 180 70%+25 205" type="checkbox" style="StoneCrossBox">
     108                <action on="Load">
     109                    Engine.ConfigDB_GetValue("user", "waterreflection") === "true" ? this.checked = true : this.checked = false;
     110                </action>
     111                <action on="Press">
     112                    Engine.Renderer_SetWaterReflectionEnabled(this.checked);
     113                    Engine.ConfigDB_CreateValue("user", "waterreflection", String(this.checked));
     114                </action>
     115            </object>
     116
     117            <object size="0 200 65% 225" type="text" style="RightLabelText" ghost="true">Water refraction</object>
     118            <object name="waterRefractionCFG" size="70% 205 70%+25 230" type="checkbox" style="StoneCrossBox">
     119                <action on="Load">
     120                    Engine.ConfigDB_GetValue("user", "waterrefraction") === "true" ? this.checked = true : this.checked = false;
     121                </action>
     122                <action on="Press">
     123                    Engine.Renderer_SetWaterReafraction(this.checked);
     124                    Engine.ConfigDB_CreateValue("user", "waterrefraction", String(this.checked));
     125                </action>
    43126            </object>
     127
     128            <object size="0 225 65% 250" type="text" style="RightLabelText" ghost="true">Water shadows</object>
     129            <object name="waterShadowsCFG" size="70% 230 70%+25 255" type="checkbox" style="StoneCrossBox">
     130                <action on="Load">
     131                    Engine.ConfigDB_GetValue("user", "watershadows") === "true" ? this.checked = true : this.checked = false;
     132                </action>
     133                <action on="Press">
     134                    Engine.Renderer_SetWaterShadowEnabled(this.checked);
     135                    Engine.ConfigDB_CreateValue("user", "watershadows", String(this.checked));
     136                </action>
     137            </object>
     138
     139            <object size="0 250 65% 275" type="text" style="RightLabelText" ghost="true">Particles</object>
     140            <object name="particlesCFG" size="70% 255 70%+25 280" type="checkbox" style="StoneCrossBox">
     141                <action on="Load">
     142                    Engine.ConfigDB_GetValue("user", "particles") === "true" ? this.checked = true : this.checked = false;
     143                </action>
     144                <action on="Press">
     145                    Engine.Renderer_SetParticlesEnabled(this.checked);
     146                    Engine.ConfigDB_CreateValue("user", "particles", String(this.checked));
     147                </action>
     148            </object>
     149
     150            <object size="0 275 65% 300" type="text" style="RightLabelText" ghost="true">Silhouettes</object>
     151            <object name="silhouettesCFG" size="70% 280 70%+25 305" type="checkbox" style="StoneCrossBox">
     152                <action on="Load">
     153                    Engine.ConfigDB_GetValue("user", "silhouettes") === "true" ? this.checked = true : this.checked = false;
     154                </action>
     155                <action on="Press">
     156                    Engine.Renderer_SetSilhouettesEnabled(this.checked);
     157                    Engine.ConfigDB_CreateValue("user", "silhouettes", String(this.checked));
     158                </action>
     159            </object>
     160
     161            <object size="0 300 65% 325" type="text" style="RightLabelText" ghost="true">Show sky</object>
     162            <object name="showSkyCFG" size="70% 305 70%+25 330" type="checkbox" style="StoneCrossBox">
     163                <action on="Load">
     164                    Engine.ConfigDB_GetValue("user", "showsky") === "true" ? this.checked = true : this.checked = false;
     165                </action>
     166                <action on="Press">
     167                    Engine.Renderer_SetShowSkyEnabled(this.checked);
     168                    Engine.ConfigDB_CreateValue("user", "showsky", String(this.checked));
     169                </action>
     170            </object>
     171
     172            <object size="0 325 65% 350" type="text" style="RightLabelText" ghost="true">Use OpenGL VBO</object>
     173            <object name="noGLVBOCFG" size="70% 330 70%+25 355" type="checkbox" style="StoneCrossBox">
     174                <action on="Load">
     175                    if (Engine.Renderer_GetGLVBOAvailable()) {
     176                        Engine.ConfigDB_GetValue("user", "novbo") === "true" ? this.checked = false : this.checked = true;
     177                    } else {
     178                        this.enabled = false;
     179                        this.checked = false;
     180                    }
     181                </action>
     182                <action on="Press">
     183                    Engine.Renderer_SetWaterRealDepthEnabled(this.checked);
     184                    Engine.ConfigDB_CreateValue("user", "novbo", String(this.checked));
     185                </action>
     186            </object>
     187
    44188        </object>
    45189        <object name="SoundSettings" type="image" sprite="BackgroundIndentFillDark" size="616 16 916 100%-16">
    46190            <object style="TitleText" type="text" size="0 5 100% 25">Sound Settings</object>
     
    60204            </object>
    61205        </object>
    62206<!--
    63              Settings / shadows
    64             <object size="0 10 100%-80 35" type="text" style="RightLabelText" ghost="true">Enable Shadows</object>
    65             <object name="shadowsCheckbox" size="100%-56 15 100%-30 40" type="checkbox" style="StoneCrossBox" checked="true">
    66                     <action on="Load">this.checked = Engine.Renderer_GetShadowsEnabled();</action>
    67                     <action on="Press">Engine.Renderer_SetShadowsEnabled(this.checked);</action>
    68             </object>   
    69              Settings / Shadow PCF
    70             <object size="0 35 100%-80 60" type="text" style="RightLabelText" ghost="true">Enable Shadow Filtering</object>
    71             <object name="shadowPCFCheckbox" size="100%-56 40 100%-30 65" type="checkbox" style="StoneCrossBox" checked="true">
    72                     <action on="Load">this.checked = Engine.Renderer_GetShadowPCFEnabled();</action>
    73                     <action on="Press">Engine.Renderer_SetShadowPCFEnabled(this.checked);</action>
    74             </object>
    75 
    76              Settings / Water
    77             <object size="0 60 100%-80 85" type="text" style="RightLabelText" ghost="true">Enable Water Reflections</object>
    78             <object name="fancyWaterCheckbox" size="100%-56 65 100%-30 90"  type="checkbox" style="StoneCrossBox" checked="true">
    79                     <action on="Load">this.checked = Engine.Renderer_GetWaterNormalEnabled();</action>
    80                     <action on="Press">Engine.Renderer_SetWaterNormalEnabled(this.checked);</action>
    81             </object>
    82 
    83207             Settings / Music
    84208            <object size="0 60 100%-80 85" type="text" style="RightLabelText" ghost="true">Enable Music</object>
    85209            <object size="100%-56 65 100%-30 90" type="checkbox" style="StoneCrossBox" checked="true">
  • source/ps/GameSetup/GameSetup.cpp

    diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp
    index 35f85eb..6543d89 100644
    a b static void InitRenderer()  
    599599
    600600    // set renderer options from command line options - NOVBO must be set before opening the renderer
    601601    g_Renderer.SetOptionBool(CRenderer::OPT_NOVBO, g_NoGLVBO);
     602
     603    g_Shadows = g_Shadows && g_Renderer.GetCapabilities().m_Shadows;
    602604    g_Renderer.SetOptionBool(CRenderer::OPT_SHADOWS, g_Shadows);
    603605
    604606    g_Renderer.SetOptionBool(CRenderer::OPT_WATERNORMAL, g_WaterNormal);
    void InitGraphics(const CmdLineArgs& args, int flags)  
    10111013        // TODO: i18n
    10121014    }
    10131015
    1014     if (!ogl_HaveExtension("GL_ARB_texture_env_crossbar"))
    1015     {
    1016         DEBUG_DISPLAY_ERROR(
    1017             L"The GL_ARB_texture_env_crossbar extension doesn't appear to be available on your computer."
    1018             L" Shadows are not available and overall graphics quality might suffer."
    1019             L" You are advised to try installing newer drivers and/or upgrade your graphics card.");
    1020         g_Shadows = false;
    1021     }
    1022 
    10231016    ogl_WarnIfError();
    10241017    InitRenderer();
    10251018
  • source/renderer/scripting/JSInterface_Renderer.cpp

    diff --git a/source/renderer/scripting/JSInterface_Renderer.cpp b/source/renderer/scripting/JSInterface_Renderer.cpp
    index 88331d1..f72be0f 100644
    a b void JSI_Renderer::Set##SCRIPTNAME##Enabled(void* UNUSED(cbdata), bool Enabled)  
    3131    g_Renderer.SetOptionBool(CRenderer::OPT_##NAME, Enabled); \
    3232}
    3333
     34IMPLEMENT_BOOLEAN_SCRIPT_SETTING(NOVBO, NoGLVBO);
    3435IMPLEMENT_BOOLEAN_SCRIPT_SETTING(PARTICLES, Particles);
    3536IMPLEMENT_BOOLEAN_SCRIPT_SETTING(PREFERGLSL, PreferGLSL);
    3637IMPLEMENT_BOOLEAN_SCRIPT_SETTING(WATERNORMAL, WaterNormal);
    void JSI_Renderer::SetRenderPath(void* UNUSED(cbdata), std::string name)  
    5758    g_Renderer.SetRenderPath(CRenderer::GetRenderPathByName(name));
    5859}
    5960
     61bool JSI_Renderer::GetGLVBOAvailable(void* UNUSED(cbdata))
     62{
     63    if (!g_Renderer.GetCapabilities().m_VBO)
     64    {
     65        DEBUG_DISPLAY_ERROR(
     66            L" OpenGL Vertex Buffer Objects are not available."
     67            L" You are advised to try installing newer drivers and/or upgrade your graphics card.");
     68        return false;
     69    } else {
     70        return true;
     71    }
     72}
     73
     74bool JSI_Renderer::GetShadowsAvailable(void* UNUSED(cbdata))
     75{
     76    if (!g_Renderer.GetCapabilities().m_Shadows)
     77    {
     78        DEBUG_DISPLAY_ERROR(
     79            L" Shadows are not available and overall graphics quality might suffer."
     80            L" You are advised to try installing newer drivers and/or upgrade your graphics card.");
     81        return false;
     82    } else {
     83        return true;
     84    }
     85}
     86
    6087
    6188#define REGISTER_BOOLEAN_SCRIPT_SETTING(NAME) \
    6289scriptInterface.RegisterFunction<bool, &JSI_Renderer::Get##NAME##Enabled>("Renderer_Get" #NAME "Enabled"); \
    void JSI_Renderer::RegisterScriptFunctions(ScriptInterface& scriptInterface)  
    6693{
    6794    scriptInterface.RegisterFunction<std::string, &JSI_Renderer::GetRenderPath>("Renderer_GetRenderPath");
    6895    scriptInterface.RegisterFunction<void, std::string, &JSI_Renderer::SetRenderPath>("Renderer_SetRenderPath");
     96    scriptInterface.RegisterFunction<bool, &JSI_Renderer::GetGLVBOAvailable>("Renderer_GetGLVBOAvailable");
     97    scriptInterface.RegisterFunction<bool, &JSI_Renderer::GetShadowsAvailable>("Renderer_GetShadowsAvailable");
    6998    REGISTER_BOOLEAN_SCRIPT_SETTING(Shadows);
    7099    REGISTER_BOOLEAN_SCRIPT_SETTING(ShadowPCF);
    71100    REGISTER_BOOLEAN_SCRIPT_SETTING(Particles);
  • source/renderer/scripting/JSInterface_Renderer.h

    diff --git a/source/renderer/scripting/JSInterface_Renderer.h b/source/renderer/scripting/JSInterface_Renderer.h
    index eca4afa..e87bbdf 100644
    a b namespace JSI_Renderer  
    2929{
    3030    std::string GetRenderPath(void* cbdata);
    3131    void SetRenderPath(void* cbdata, std::string name);
     32    bool GetGLVBOAvailable(void* cbdata);
     33    bool GetShadowsAvailable(void* cbdata);
    3234
     35    DECLARE_BOOLEAN_SCRIPT_SETTING(NoGLVBO);
    3336    DECLARE_BOOLEAN_SCRIPT_SETTING(Shadows);
    3437    DECLARE_BOOLEAN_SCRIPT_SETTING(ShadowPCF);
    3538    DECLARE_BOOLEAN_SCRIPT_SETTING(Particles);