diff --git a/doomsday/apps/client/include/render/rend_main.h b/doomsday/apps/client/include/render/rend_main.h index 407532e6a2..9bbd8c868f 100644 --- a/doomsday/apps/client/include/render/rend_main.h +++ b/doomsday/apps/client/include/render/rend_main.h @@ -129,9 +129,9 @@ DENG_EXTERN_C int useSmartFilter; DENG_EXTERN_C int texMagMode; DENG_EXTERN_C int glmode[6]; DENG_EXTERN_C dd_bool fillOutlines; -DENG_EXTERN_C dd_bool noHighResTex; -DENG_EXTERN_C dd_bool noHighResPatches; -DENG_EXTERN_C dd_bool highResWithPWAD; +//DENG_EXTERN_C dd_bool noHighResTex; +//DENG_EXTERN_C dd_bool noHighResPatches; +//DENG_EXTERN_C dd_bool highResWithPWAD; DENG_EXTERN_C byte loadExtAlways; DENG_EXTERN_C int devNoCulling; @@ -141,6 +141,15 @@ DENG_EXTERN_C byte devDrawLums; DENG_EXTERN_C byte freezeRLs; +struct ResourceConfigVars +{ + de::Variable *noHighResTex; + de::Variable *noHighResPatches; + de::Variable *highResWithPWAD; +}; + +ResourceConfigVars &R_Config(); + void Rend_Register(); void Rend_Reset(); diff --git a/doomsday/apps/client/include/ui/dialogs/renderersettingsdialog.h b/doomsday/apps/client/include/ui/dialogs/renderersettingsdialog.h index 21864850fc..ffdd50973e 100644 --- a/doomsday/apps/client/include/ui/dialogs/renderersettingsdialog.h +++ b/doomsday/apps/client/include/ui/dialogs/renderersettingsdialog.h @@ -38,6 +38,9 @@ protected slots: void showDeveloperPopup(); void editProfile(); +protected: + void finish(int result) override; + private: DENG2_PRIVATE(d) }; diff --git a/doomsday/apps/client/net.dengine.client.pack/modules/appconfig.de b/doomsday/apps/client/net.dengine.client.pack/modules/appconfig.de index 6984c0ec11..097a251c3f 100644 --- a/doomsday/apps/client/net.dengine.client.pack/modules/appconfig.de +++ b/doomsday/apps/client/net.dengine.client.pack/modules/appconfig.de @@ -93,6 +93,9 @@ def setDefaults(d) record d.resource d.resource.iwadFolder = '' d.resource.packageFolder = '' + d.resource.noHighResTex = False + d.resource.noHighResPatches = False + d.resource.highResWithPWAD = True # Renderer settings. record d.render diff --git a/doomsday/apps/client/src/gl/gl_texmanager.cpp b/doomsday/apps/client/src/gl/gl_texmanager.cpp index 98f8e92a06..b9d678e684 100644 --- a/doomsday/apps/client/src/gl/gl_texmanager.cpp +++ b/doomsday/apps/client/src/gl/gl_texmanager.cpp @@ -71,11 +71,21 @@ void GL_InitTextureManager() return; // Already been here. } + auto &cfg = R_Config(); // Disable the use of 'high resolution' textures and/or patches? - noHighResTex = CommandLine_Exists("-nohightex"); - noHighResPatches = CommandLine_Exists("-nohighpat"); + if (CommandLine_Exists("-nohightex")) + { + cfg.noHighResTex->set(NumberValue(true)); + } + if (CommandLine_Exists("-nohighpat")) + { + cfg.noHighResPatches->set(NumberValue(true)); + } // Should we allow using external resources with PWAD textures? - highResWithPWAD = CommandLine_Exists("-pwadtex"); + if (CommandLine_Exists("-pwadtex")) + { + cfg.highResWithPWAD->set(NumberValue(true)); + } // System textures. zap(sysFlareTextures); @@ -109,6 +119,8 @@ void GL_TexReset() { if (!initedOk) return; + Rend_ResetLookups(); + App_Resources().releaseAllGLTextures(); LOG_GL_VERBOSE("Released all GL textures"); diff --git a/doomsday/apps/client/src/render/rend_main.cpp b/doomsday/apps/client/src/render/rend_main.cpp index 29e41d57e1..2528080671 100644 --- a/doomsday/apps/client/src/render/rend_main.cpp +++ b/doomsday/apps/client/src/render/rend_main.cpp @@ -206,9 +206,9 @@ dint filterSprites = true; dint texMagMode = 1; ///< Linear. dint texAniso = -1; ///< Use best. -dd_bool noHighResTex; -dd_bool noHighResPatches; -dd_bool highResWithPWAD; +//dd_bool noHighResTex; +//dd_bool noHighResPatches; +//dd_bool highResWithPWAD; dbyte loadExtAlways; ///< Always check for extres (cvar) dfloat texGamma; @@ -6446,3 +6446,15 @@ void Rend_Register() Shard::consoleRegister(); VR_ConsoleRegister(); } + +ResourceConfigVars &R_Config() +{ + static ResourceConfigVars vars { nullptr, nullptr, nullptr}; + if (!vars.noHighResTex) + { + vars.noHighResTex = &App::config("resource.noHighResTex"); + vars.noHighResPatches = &App::config("resource.noHighResPatches"); + vars.highResWithPWAD = &App::config("resource.highResWithPWAD"); + } + return vars; +} diff --git a/doomsday/apps/client/src/resource/image.cpp b/doomsday/apps/client/src/resource/image.cpp index b0d5c2a82a..79e6ad4c94 100644 --- a/doomsday/apps/client/src/resource/image.cpp +++ b/doomsday/apps/client/src/resource/image.cpp @@ -755,13 +755,15 @@ Source GL_LoadSourceImage(image_t &image, ClientTexture const &tex, TextureVariantSpec const &spec) { de::FS1 &fileSys = App_FileSystem(); + auto &cfg = R_Config(); Source source = None; variantspecification_t const &vspec = spec.variant; if (!tex.manifest().schemeName().compareWithoutCase("Textures")) { // Attempt to load an external replacement for this composite texture? - if (!noHighResTex && (loadExtAlways || highResWithPWAD || !tex.isFlagged(Texture::Custom))) + if (cfg.noHighResTex->value().isFalse() && + (loadExtAlways || cfg.highResWithPWAD->value().isTrue() || !tex.isFlagged(Texture::Custom))) { // First try the textures scheme. de::Uri uri = tex.manifest().composeUri(); @@ -785,7 +787,8 @@ Source GL_LoadSourceImage(image_t &image, ClientTexture const &tex, else if (!tex.manifest().schemeName().compareWithoutCase("Flats")) { // Attempt to load an external replacement for this flat? - if (!noHighResTex && (loadExtAlways || highResWithPWAD || !tex.isFlagged(Texture::Custom))) + if (cfg.noHighResTex->value().isFalse() && + (loadExtAlways || cfg.highResWithPWAD->value().isTrue() || !tex.isFlagged(Texture::Custom))) { // First try the flats scheme. de::Uri uri = tex.manifest().composeUri(); @@ -831,7 +834,8 @@ Source GL_LoadSourceImage(image_t &image, ClientTexture const &tex, } // Attempt to load an external replacement for this patch? - if (!noHighResTex && (loadExtAlways || highResWithPWAD || !tex.isFlagged(Texture::Custom))) + if (cfg.noHighResTex->value().isFalse() && + (loadExtAlways || cfg.highResWithPWAD->value().isTrue() || !tex.isFlagged(Texture::Custom))) { de::Uri uri = tex.manifest().composeUri(); source = loadExternalTexture(image, uri.compose(), "-ck"); @@ -870,7 +874,7 @@ Source GL_LoadSourceImage(image_t &image, ClientTexture const &tex, } // Attempt to load an external replacement for this sprite? - if (!noHighResPatches) + if (cfg.noHighResPatches->value().isFalse()) { de::Uri uri = tex.manifest().composeUri(); diff --git a/doomsday/apps/client/src/ui/dialogs/renderersettingsdialog.cpp b/doomsday/apps/client/src/ui/dialogs/renderersettingsdialog.cpp index dfcf310f27..beaecc27c1 100644 --- a/doomsday/apps/client/src/ui/dialogs/renderersettingsdialog.cpp +++ b/doomsday/apps/client/src/ui/dialogs/renderersettingsdialog.cpp @@ -25,14 +25,18 @@ #include "ui/widgets/profilepickerwidget.h" #include "ui/clientwindow.h" #include "render/rendersystem.h" +#include "gl/gl_texmanager.h" #include "clientapp.h" +#include + #include #include #include #include #include #include +#include using namespace de; using namespace de::ui; @@ -41,6 +45,9 @@ DENG_GUI_PIMPL(RendererSettingsDialog) { ProfilePickerWidget *appear; CVarSliderWidget *fov; + VariableToggleWidget *enableExtWithPWADs; + VariableToggleWidget *disableExtTextures; + VariableToggleWidget *disableExtPatches; CVarToggleWidget *precacheModels; CVarToggleWidget *precacheSprites; CVarToggleWidget *multiLight; @@ -50,6 +57,8 @@ DENG_GUI_PIMPL(RendererSettingsDialog) // Developer settings. GridPopupWidget *devPopup; + bool texSettingsToggled = false; + Impl(Public *i) : Base(i) { ScrollAreaWidget &area = self.area(); @@ -62,6 +71,10 @@ DENG_GUI_PIMPL(RendererSettingsDialog) fov->setPrecision(0); fov->setRange(Ranged(30, 160)); + area.add(enableExtWithPWADs = new VariableToggleWidget(tr("Use with PWADs"), App::config("resource.highResWithPWAD"))); + area.add(disableExtTextures = new VariableToggleWidget(tr("Disable for textures"), App::config("resource.noHighResTex"))); + area.add(disableExtPatches = new VariableToggleWidget(tr("Disable for patches"), App::config("resource.noHighResPatches"))); + // Set up a separate popup for developer settings. self.add(devPopup = new GridPopupWidget); @@ -157,6 +170,17 @@ RendererSettingsDialog::RendererSettingsDialog(String const &name) layout << *LabelWidget::newWithText(tr("Pixel Density:"), &area()) << *pd; } + // Textures options. + LabelWidget *texturesLabel = LabelWidget::newWithText(_E(D) + tr("Textures"), &area()); + texturesLabel->setFont("separator.label"); + texturesLabel->margins().setTop("gap"); + layout.setCellAlignment(Vector2i(0, layout.gridSize().y), ui::AlignLeft); + layout.append(*texturesLabel, 2); + + layout << *LabelWidget::newWithText(tr("External Images:"), &area()) << *d->enableExtWithPWADs + << Const(0) << *d->disableExtTextures + << Const(0) << *d->disableExtPatches; + area().setContentSize(layout.width(), layout.height()); buttons() @@ -173,6 +197,14 @@ RendererSettingsDialog::RendererSettingsDialog(String const &name) connect(d->appear, SIGNAL(profileEditorRequested()), this, SLOT(editProfile())); d->fetch(); + + auto toggledFunc = [this] (ToggleWidget::ToggleState) { + d->texSettingsToggled = true; + }; + + connect(d->enableExtWithPWADs, &ToggleWidget::stateChangedByUser, toggledFunc); + connect(d->disableExtTextures, &ToggleWidget::stateChangedByUser, toggledFunc); + connect(d->disableExtPatches, &ToggleWidget::stateChangedByUser, toggledFunc); } void RendererSettingsDialog::resetToDefaults() @@ -194,3 +226,14 @@ void RendererSettingsDialog::editProfile() ClientWindow::main().taskBar().closeConfigMenu(); } + +void RendererSettingsDialog::finish(int result) +{ + DialogWidget::finish(result); + + if (d->texSettingsToggled) + { + //Con_Execute(CMDS_DDAY, "texreset", true /* silent */, false /* network */); + GL_TexReset(); + } +}