Skip to content

Commit

Permalink
Renderer|UI: “-pwadtex”, “-nohightex”, “-nohighpat” in Renderer Settings
Browse files Browse the repository at this point in the history
Added “-pwadtex” and other texture options that previously were
only available via command line options to the Renderer Settings
dialog, where they can be toggled at runtime.
  • Loading branch information
skyjake committed Nov 13, 2016
1 parent 9068b28 commit fc579af
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 13 deletions.
15 changes: 12 additions & 3 deletions doomsday/apps/client/include/render/rend_main.h
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Expand Up @@ -38,6 +38,9 @@ protected slots:
void showDeveloperPopup();
void editProfile();

protected:
void finish(int result) override;

private:
DENG2_PRIVATE(d)
};
Expand Down
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions doomsday/apps/client/src/gl/gl_texmanager.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -109,6 +119,8 @@ void GL_TexReset()
{
if (!initedOk) return;

Rend_ResetLookups();

App_Resources().releaseAllGLTextures();
LOG_GL_VERBOSE("Released all GL textures");

Expand Down
18 changes: 15 additions & 3 deletions doomsday/apps/client/src/render/rend_main.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
12 changes: 8 additions & 4 deletions doomsday/apps/client/src/resource/image.cpp
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();

Expand Down
43 changes: 43 additions & 0 deletions doomsday/apps/client/src/ui/dialogs/renderersettingsdialog.cpp
Expand Up @@ -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 <doomsday/console/exec.h>

#include <de/GridPopupWidget>
#include <de/GridLayout>
#include <de/SignalAction>
#include <de/DialogContentStylist>
#include <de/InputDialog>
#include <de/VariableSliderWidget>
#include <de/VariableToggleWidget>

using namespace de;
using namespace de::ui;
Expand All @@ -41,6 +45,9 @@ DENG_GUI_PIMPL(RendererSettingsDialog)
{
ProfilePickerWidget *appear;
CVarSliderWidget *fov;
VariableToggleWidget *enableExtWithPWADs;
VariableToggleWidget *disableExtTextures;
VariableToggleWidget *disableExtPatches;
CVarToggleWidget *precacheModels;
CVarToggleWidget *precacheSprites;
CVarToggleWidget *multiLight;
Expand All @@ -50,6 +57,8 @@ DENG_GUI_PIMPL(RendererSettingsDialog)
// Developer settings.
GridPopupWidget *devPopup;

bool texSettingsToggled = false;

Impl(Public *i) : Base(i)
{
ScrollAreaWidget &area = self.area();
Expand All @@ -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);

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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();
}
}

0 comments on commit fc579af

Please sign in to comment.