Skip to content

Commit

Permalink
Merge pull request #750 from qw-ctf/cfg-defaults-and-settings
Browse files Browse the repository at this point in the history
Modernize defaults, and add more settings to menu.
  • Loading branch information
tcsabina authored Mar 18, 2023
2 parents 859f3c7 + b817b63 commit c068c81
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
8 changes: 4 additions & 4 deletions help_variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -4581,7 +4581,7 @@
]
},
"gl_anisotropy": {
"default": "1",
"default": "16",
"desc": "Anisotropic filtering. Improves texture detail on angled surfaces.",
"group-id": "50",
"remarks": "Depends on your Graphics card capabilities and settings. Make sure you have set your graphic card's Anisotropic Filtering setting to \"Application controlled\".",
Expand Down Expand Up @@ -15391,7 +15391,7 @@
]
},
"r_dynamic": {
"default": "1",
"default": "2",
"desc": "Controls dynamic lighting (muzzle-flash, quad & rocket glow, etc) on world surfaces.",
"group-id": "15",
"type": "enum",
Expand Down Expand Up @@ -21774,7 +21774,7 @@
"type": "float"
},
"vid_renderer": {
"default": "0",
"default": "1",
"desc": "Selects which rendering mode to use.",
"group-id": "52",
"remarks": "(variable only available if multiple renderers available)",
Expand Down Expand Up @@ -21812,7 +21812,7 @@
"type": "boolean"
},
"vid_software_palette": {
"default": "0",
"default": "1",
"desc": "Controls whether to adjust gamma at the display level, or as a color correction rendering effect.",
"group-id": "52",
"type": "boolean",
Expand Down
60 changes: 60 additions & 0 deletions src/menu_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keys.h"
#include "hud.h"
#include "hud_common.h"
#include "r_local.h"

extern cvar_t r_farclip, gl_max_size, gl_miptexLevel;
extern cvar_t r_bloom;
extern cvar_t gl_flashblend, r_dynamic, gl_lightmode, gl_modulate;

#ifdef RENDERER_OPTION_MODERN_OPENGL
extern cvar_t vid_framebuffer, vid_framebuffer_hdr, vid_framebuffer_hdr_tonemap, vid_framebuffer_scale, vid_framebuffer_multisample;
#endif

extern cvar_t vid_software_palette;

#ifdef EZ_MULTIPLE_RENDERERS
extern cvar_t vid_renderer;
#endif

typedef enum {
OPTPG_MISC,
OPTPG_PLAYER,
Expand Down Expand Up @@ -414,6 +425,26 @@ const char* gl_texturemode_enum[] = {
"very high", "GL_NEAREST"
};

const char* vid_software_palette_enum[] = {
"hardware", "0",
"shader", "1"
};

#ifdef EZ_MULTIPLE_RENDERERS
const char* vid_renderer_enum[] = {
"classic", "0",
"modern", "1"
};
#endif

#ifdef RENDERER_OPTION_MODERN_OPENGL
const char* vid_framebuffer_enum[] = {
"disabled", "0",
"enabled", "1",
"enabled (separate scene & hud)", "2"
};
#endif

settings_page settfps;

void CT_Opt_FPS_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page)
Expand Down Expand Up @@ -494,6 +525,14 @@ void VideoApplySettings (void)
mss_askmode = true;
}

#if defined(EZ_MULTIPLE_RENDERERS) || defined(RENDERER_OPTION_MODERN_OPENGL)
// performed when user hits the "apply" button
void RendererRestart (void)
{
Cbuf_AddText("vid_restart\n");
}
#endif

// two possible results of the "keep these video settings?" dialogue
static void KeepNewVideoSettings (void) { mss_askmode = false; }
static void CancelNewVideoSettings (void) {
Expand Down Expand Up @@ -1238,6 +1277,9 @@ setting settsystem_arr[] = {
//Video
ADDSET_SEPARATOR("Video"),
ADDSET_NUMBER ("Gamma", v_gamma, 0.3, 3.0, 0.1),
ADDSET_ADVANCED_SECTION(),
ADDSET_ENUM ("Gamma control", vid_software_palette, vid_software_palette_enum),
ADDSET_BASIC_SECTION(),
ADDSET_NUMBER ("Contrast", v_contrast, 1, 5, 0.1),
ADDSET_ADVANCED_SECTION(),
ADDSET_NUMBER ("Lightmap Intensity", gl_modulate, 0.5, 3.0, 0.1),
Expand All @@ -1257,6 +1299,24 @@ setting settsystem_arr[] = {
ADDSET_CUSTOM("Fullscreen", FullScreenRead, FullScreenToggle, "Toggle between fullscreen and windowed mode."),
ADDSET_ACTION("Apply Changes", VideoApplySettings, "Restarts the renderer and applies the selected resolution."),

#ifdef EZ_MULTIPLE_RENDERERS
ADDSET_SEPARATOR("Renderer"),
ADDSET_ENUM("Mode", vid_renderer, vid_renderer_enum),
ADDSET_ACTION("Apply Changes", RendererRestart, "Restarts the renderer."),
#endif

#ifdef RENDERER_OPTION_MODERN_OPENGL
ADDSET_ADVANCED_SECTION(),
ADDSET_SEPARATOR("Framebuffer"),
ADDSET_ENUM("Mode", vid_framebuffer, vid_framebuffer_enum),
ADDSET_BOOL("HDR", vid_framebuffer_hdr),
ADDSET_BOOL("HDR Tonemap", vid_framebuffer_hdr_tonemap),
ADDSET_NUMBER("Scale", vid_framebuffer_scale, 0.25, 2.0, 0.25),
ADDSET_NUMBER("Multisample", vid_framebuffer_multisample, 0, 16, 1),
ADDSET_ACTION("Apply Changes", RendererRestart, "Restarts the renderer."),
ADDSET_BASIC_SECTION(),
#endif

//Font
ADDSET_ADVANCED_SECTION(),
ADDSET_SEPARATOR("Font"),
Expand Down
4 changes: 4 additions & 0 deletions src/r_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ cvar_t r_speeds = {"r_speeds", "0"};
cvar_t r_fullbright = {"r_fullbright", "0"};
cvar_t r_shadows = {"r_shadows", "0"};
cvar_t r_wateralpha = {"gl_turbalpha", "1"};
#if defined(EZ_MULTIPLE_RENDERERS) || defined(RENDERER_OPTION_MODERN_OPENGL)
cvar_t r_dynamic = {"r_dynamic", "2", 0, OnDynamicLightingChange };
#else
cvar_t r_dynamic = {"r_dynamic", "1", 0, OnDynamicLightingChange };
#endif
cvar_t r_novis = {"r_novis", "0"};
cvar_t r_netgraph = {"r_netgraph", "0"};
cvar_t r_netstats = {"r_netstats", "0"};
Expand Down
2 changes: 1 addition & 1 deletion src/r_texture_cvars.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ cvar_t gl_picmip = { "gl_picmip", "0", CVAR_RELOAD_GFX };
cvar_t gl_miptexLevel = { "gl_miptexLevel", "0", CVAR_RELOAD_GFX, OnChange_gl_miptexLevel };
cvar_t gl_texturemode = { "gl_texturemode", "GL_LINEAR_MIPMAP_LINEAR", 0, OnChange_gl_texturemode };
cvar_t gl_texturemode_viewmodels = { "gl_texturemode_viewmodels", "GL_LINEAR", 0, OnChange_gl_texturemode };
cvar_t gl_anisotropy = { "gl_anisotropy","1", 0, OnChange_gl_anisotropy };
cvar_t gl_anisotropy = { "gl_anisotropy","16", 0, OnChange_gl_anisotropy };
cvar_t gl_scaleModelTextures = { "gl_scaleModelTextures", "0", CVAR_RELOAD_GFX };
cvar_t gl_scaleModelSimpleTextures = { "gl_scaleModelSimpleTextures", "0", CVAR_RELOAD_GFX };
cvar_t gl_scaleTurbTextures = { "gl_scaleTurbTextures", "1", CVAR_RELOAD_GFX };
Expand Down
12 changes: 9 additions & 3 deletions src/settings_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ float VARFVAL(const cvar_t *v)
else return v->value;
}

#define VARSVAL(x) (((x).flags & CVAR_LATCH) ? ((x).latchedString) : ((x).string))
char* VARSVAL(const cvar_t *v)
{
if (v->flags & CVAR_LATCH && v->latchedString)
return v->latchedString;
else return v->string;
}

static int STHeight(setting* s) {
if (s->advanced && !menu_advanced.value)
Expand Down Expand Up @@ -172,9 +177,10 @@ static void Setting_DrawNamed(int x, int y, int w, setting* set, qbool active)
static int Enum_Find_ValueCode(setting* set)
{
int i;

for (i = 0; i <= set->max; i++)
{
if (!strcmp(set->cvar->string, ENUM_VALUE(set, i)))
if (!strcmp(VARSVAL(set->cvar), ENUM_VALUE(set, i)))
return i;
}
return ENUM_ITEM_NOT_FOUND;
Expand All @@ -200,7 +206,7 @@ static void Setting_DrawString(int x, int y, int w, setting* setting, qbool acti
editbox.width = (w - x + x0) / 8;
CEditBox_Draw(&editbox, x, y, true);
} else {
UI_Print(x, y, VARSVAL(*(setting->cvar)), false);
UI_Print(x, y, VARSVAL(setting->cvar), false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vid_sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ cvar_t in_raw = {"in_raw", "1", CV
cvar_t in_grab_windowed_mouse = {"in_grab_windowed_mouse", "1", CVAR_ARCHIVE | CVAR_SILENT, in_grab_windowed_mouse_callback};
cvar_t vid_grab_keyboard = {"vid_grab_keyboard", CVAR_DEF2, CVAR_LATCH_GFX }; /* Needs vid_restart thus vid_.... */
#ifdef EZ_MULTIPLE_RENDERERS
cvar_t vid_renderer = {"vid_renderer", "0", CVAR_LATCH_GFX };
cvar_t vid_renderer = {"vid_renderer", "1", CVAR_LATCH_GFX };
#endif
cvar_t vid_gl_core_profile = {"vid_gl_core_profile", "0", CVAR_LATCH_GFX };

Expand Down

0 comments on commit c068c81

Please sign in to comment.