Minor start window cleanup. This ended up touching a bunch of other files due to variable renaming, but there are zero functional changes to anything but the startup window in this commit.

git-svn-id: https://svn.eduke32.com/eduke32@7219 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-11-18 18:13:02 +00:00
parent e77324a6d8
commit 21958bc110
10 changed files with 312 additions and 395 deletions

View file

@ -5,9 +5,9 @@
#ifndef build_interface_layer_ #ifndef build_interface_layer_
#define build_interface_layer_ SDL #define build_interface_layer_ SDL
#include "sdl_inc.h"
#include "compat.h"
#include "baselayer.h" #include "baselayer.h"
#include "compat.h"
#include "sdl_inc.h"
#define EDUKE32_SDL_LINKED_PREREQ(x, a, b, c) ((x).major > (a) || ((x).major == (a) && ((x).minor > (b) || ((x).minor == (b) && (x).patch >= (c))))) #define EDUKE32_SDL_LINKED_PREREQ(x, a, b, c) ((x).major > (a) || ((x).major == (a) && ((x).minor > (b) || ((x).minor == (b) && (x).patch >= (c)))))

View file

@ -170,8 +170,8 @@ void CONFIG_SetDefaults(void)
droidinput.toggleCrouch = 1; droidinput.toggleCrouch = 1;
droidinput.yaw_sens = 5.f; droidinput.yaw_sens = 5.f;
ud.config.ScreenWidth = droidinfo.screen_width; ud.setup.xdim = droidinfo.screen_width;
ud.config.ScreenHeight = droidinfo.screen_height; ud.setup.ydim = droidinfo.screen_height;
#else #else
# if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1 # if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1
uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO); uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO);
@ -183,21 +183,21 @@ void CONFIG_SetDefaults(void)
SDL_DisplayMode dm; SDL_DisplayMode dm;
if (SDL_GetDesktopDisplayMode(0, &dm) == 0) if (SDL_GetDesktopDisplayMode(0, &dm) == 0)
{ {
ud.config.ScreenWidth = dm.w; ud.setup.xdim = dm.w;
ud.config.ScreenHeight = dm.h; ud.setup.ydim = dm.h;
} }
else else
# endif # endif
{ {
ud.config.ScreenWidth = 1024; ud.setup.xdim = 1024;
ud.config.ScreenHeight = 768; ud.setup.ydim = 768;
} }
#endif #endif
#ifdef USE_OPENGL #ifdef USE_OPENGL
ud.config.ScreenBPP = 32; ud.setup.bpp = 32;
#else #else
ud.config.ScreenBPP = 8; ud.setup.bpp = 8;
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)
@ -217,14 +217,19 @@ void CONFIG_SetDefaults(void)
#endif #endif
#ifdef GEKKO #ifdef GEKKO
ud.config.UseJoystick = 1; ud.setup.usejoystick = 1;
#else #else
ud.config.UseJoystick = 0; ud.setup.usejoystick = 0;
#endif #endif
g_myAimMode = 1; g_myAimMode = 1;
g_player[0].ps->aim_mode = 1; g_player[0].ps->aim_mode = 1;
ud.setup.forcesetup = 1;
ud.setup.noautoload = 1;
ud.setup.fullscreen = 1;
ud.setup.usemouse = 1;
ud.althud = 1; ud.althud = 1;
ud.angleinterpolation = 0; ud.angleinterpolation = 0;
ud.auto_run = 1; ud.auto_run = 1;
@ -239,20 +244,16 @@ void CONFIG_SetDefaults(void)
ud.config.AutoAim = 1; ud.config.AutoAim = 1;
ud.config.CheckForUpdates = 1; ud.config.CheckForUpdates = 1;
ud.config.FXVolume = 255; ud.config.FXVolume = 255;
ud.config.ForceSetup = 1;
ud.config.MouseBias = 0; ud.config.MouseBias = 0;
ud.config.MouseDeadZone = 0; ud.config.MouseDeadZone = 0;
ud.config.MusicToggle = 1; ud.config.MusicToggle = 1;
ud.config.MusicVolume = 195; ud.config.MusicVolume = 195;
ud.config.NoAutoLoad = 1;
ud.config.NumBits = 16; ud.config.NumBits = 16;
ud.config.NumChannels = 2; ud.config.NumChannels = 2;
ud.config.ReverseStereo = 0; ud.config.ReverseStereo = 0;
ud.config.ScreenMode = 1;
ud.config.ShowWeapons = 0; ud.config.ShowWeapons = 0;
ud.config.SmoothInput = 1; ud.config.SmoothInput = 1;
ud.config.SoundToggle = 1; ud.config.SoundToggle = 1;
ud.config.UseMouse = 1;
ud.config.VoiceToggle = 5; // bitfield, 1 = local, 2 = dummy, 4 = other players in DM ud.config.VoiceToggle = 5; // bitfield, 1 = local, 2 = dummy, 4 = other players in DM
ud.config.useprecache = 1; ud.config.useprecache = 1;
ud.configversion = 0; ud.configversion = 0;
@ -615,8 +616,8 @@ int CONFIG_ReadSetup(void)
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ConfigVersion", &ud.configversion); SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ConfigVersion", &ud.configversion);
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup", &ud.config.ForceSetup); SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup", &ud.setup.forcesetup);
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", &ud.config.NoAutoLoad); SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", &ud.setup.noautoload);
int32_t cachesize; int32_t cachesize;
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "CacheSize", &cachesize); SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "CacheSize", &cachesize);
@ -656,15 +657,15 @@ int CONFIG_ReadSetup(void)
windowy = -1; windowy = -1;
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32_t *)&maxrefreshfreq); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32_t *)&maxrefreshfreq);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.setup.bpp);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight", &ud.config.ScreenHeight); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight", &ud.setup.ydim);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode", &ud.config.ScreenMode); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode", &ud.setup.fullscreen);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth", &ud.config.ScreenWidth); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth", &ud.setup.xdim);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32_t *)&windowx); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32_t *)&windowx);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32_t *)&windowy); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32_t *)&windowy);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32_t *)&windowpos); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32_t *)&windowpos);
if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32; if (ud.setup.bpp < 8) ud.setup.bpp = 32;
#ifdef POLYMER #ifdef POLYMER
int32_t rendmode = 0; int32_t rendmode = 0;
@ -742,17 +743,17 @@ void CONFIG_WriteSetup(uint32_t flags)
SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "CacheSize", MAXCACHE1DSIZE, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "CacheSize", MAXCACHE1DSIZE, FALSE, FALSE);
SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ConfigVersion", BYTEVERSION_EDUKE32, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ConfigVersion", BYTEVERSION_EDUKE32, FALSE, FALSE);
SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup", ud.config.ForceSetup, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup", ud.setup.forcesetup, FALSE, FALSE);
SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", ud.config.NoAutoLoad, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", ud.setup.noautoload, FALSE, FALSE);
#ifdef POLYMER #ifdef POLYMER
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Polymer", videoGetRenderMode() == REND_POLYMER, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Polymer", videoGetRenderMode() == REND_POLYMER, FALSE, FALSE);
#endif #endif
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", ud.config.ScreenBPP, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", ud.setup.bpp, FALSE, FALSE);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight", ud.config.ScreenHeight, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight", ud.setup.ydim, FALSE, FALSE);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode", ud.config.ScreenMode, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode", ud.setup.fullscreen, FALSE, FALSE);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth", ud.config.ScreenWidth, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth", ud.setup.xdim, FALSE, FALSE);
if (g_grpNamePtr && !g_addonNum) if (g_grpNamePtr && !g_addonNum)
SCRIPT_PutString(ud.config.scripthandle, "Setup", "SelectedGRP", g_grpNamePtr); SCRIPT_PutString(ud.config.scripthandle, "Setup", "SelectedGRP", g_grpNamePtr);
@ -785,7 +786,7 @@ void CONFIG_WriteSetup(uint32_t flags)
SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", ud.config.LastUpdateCheck, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", ud.config.LastUpdateCheck, FALSE, FALSE);
#endif #endif
if (ud.config.UseMouse) if (ud.setup.usemouse)
{ {
for (int i=0; i<MAXMOUSEBUTTONS; i++) for (int i=0; i<MAXMOUSEBUTTONS; i++)
{ {
@ -832,7 +833,7 @@ void CONFIG_WriteSetup(uint32_t flags)
} }
} }
if (ud.config.UseJoystick) if (ud.setup.usejoystick)
{ {
for (int dummy=0; dummy<MAXJOYBUTTONSANDHATS; dummy++) for (int dummy=0; dummy<MAXJOYBUTTONSANDHATS; dummy++)
{ {

View file

@ -195,13 +195,13 @@ void G_HandleSpecialKeys(void)
if (g_networkMode != NET_DEDICATED_SERVER && ALT_IS_PRESSED && KB_KeyPressed(sc_Enter)) if (g_networkMode != NET_DEDICATED_SERVER && ALT_IS_PRESSED && KB_KeyPressed(sc_Enter))
{ {
if (videoSetGameMode(!ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP,ud.detail)) if (videoSetGameMode(!ud.setup.fullscreen,ud.setup.xdim,ud.setup.ydim,ud.setup.bpp,ud.detail))
{ {
OSD_Printf(OSD_ERROR "Failed setting fullscreen video mode.\n"); OSD_Printf(OSD_ERROR "Failed setting fullscreen video mode.\n");
if (videoSetGameMode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP, ud.detail)) if (videoSetGameMode(ud.setup.fullscreen, ud.setup.xdim, ud.setup.ydim, ud.setup.bpp, ud.detail))
G_GameExit("Failed to recover from failure to set fullscreen video mode.\n"); G_GameExit("Failed to recover from failure to set fullscreen video mode.\n");
} }
else ud.config.ScreenMode = !ud.config.ScreenMode; else ud.setup.fullscreen = !ud.setup.fullscreen;
KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_Enter);
g_restorePalette = 1; g_restorePalette = 1;
G_UpdateScreenArea(); G_UpdateScreenArea();
@ -290,7 +290,7 @@ void G_GameExit(const char *msg)
g_mostConcurrentPlayers > 1 && g_player[myconnectindex].ps->gm & MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *msg == ' ') g_mostConcurrentPlayers > 1 && g_player[myconnectindex].ps->gm & MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *msg == ' ')
{ {
G_BonusScreen(1); G_BonusScreen(1);
videoSetGameMode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP,ud.detail); videoSetGameMode(ud.setup.fullscreen,ud.setup.xdim,ud.setup.ydim,ud.setup.bpp,ud.detail);
} }
// shareware and TEN screens // shareware and TEN screens
@ -5288,7 +5288,7 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
else else
{ {
initprintf("Using file \"%s\" as game data.\n", fileName); initprintf("Using file \"%s\" as game data.\n", fileName);
if (!g_noAutoLoad && !ud.config.NoAutoLoad) if (!g_noAutoLoad && !ud.setup.noautoload)
G_DoAutoload(fileName); G_DoAutoload(fileName);
} }
} }
@ -6320,7 +6320,7 @@ int app_main(int argc, char const * const * argv)
G_ScanGroups(); G_ScanGroups();
#ifdef STARTUP_SETUP_WINDOW #ifdef STARTUP_SETUP_WINDOW
if (readSetup < 0 || (!g_noSetup && (ud.configversion != BYTEVERSION_EDUKE32 || ud.config.ForceSetup)) || g_commandSetup) if (readSetup < 0 || (!g_noSetup && (ud.configversion != BYTEVERSION_EDUKE32 || ud.setup.forcesetup)) || g_commandSetup)
{ {
if (quitevent || !startwin_run()) if (quitevent || !startwin_run())
{ {
@ -6331,7 +6331,7 @@ int app_main(int argc, char const * const * argv)
#endif #endif
g_logFlushWindow = 0; g_logFlushWindow = 0;
G_LoadGroups(!g_noAutoLoad && !ud.config.NoAutoLoad); G_LoadGroups(!g_noAutoLoad && !ud.setup.noautoload);
// flushlogwindow = 1; // flushlogwindow = 1;
if (!g_useCwd) if (!g_useCwd)
@ -6488,8 +6488,8 @@ int app_main(int argc, char const * const * argv)
CONFIG_SetupMouse(); CONFIG_SetupMouse();
CONFIG_SetupJoystick(); CONFIG_SetupJoystick();
CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent); CONTROL_JoystickEnabled = (ud.setup.usejoystick && CONTROL_JoyPresent);
CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent); CONTROL_MouseEnabled = (ud.setup.usemouse && CONTROL_MousePresent);
// JBF 20040215: evil and nasty place to do this, but joysticks are evil and nasty too // JBF 20040215: evil and nasty place to do this, but joysticks are evil and nasty too
for (bssize_t i=0; i<joystick.numAxes; i++) for (bssize_t i=0; i<joystick.numAxes; i++)
@ -6525,10 +6525,10 @@ int app_main(int argc, char const * const * argv)
if (g_networkMode != NET_DEDICATED_SERVER) if (g_networkMode != NET_DEDICATED_SERVER)
{ {
if (videoSetGameMode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP,ud.detail) < 0) if (videoSetGameMode(ud.setup.fullscreen,ud.setup.xdim,ud.setup.ydim,ud.setup.bpp,ud.detail) < 0)
{ {
vec2_t const res[] = { vec2_t const res[] = {
{ ud.config.ScreenWidth, ud.config.ScreenHeight }, { 800, 600 }, { 640, 480 }, { 320, 240 }, { ud.setup.xdim, ud.setup.ydim }, { 800, 600 }, { 640, 480 }, { 320, 240 },
}; };
#ifdef USE_OPENGL #ifdef USE_OPENGL
@ -6537,8 +6537,8 @@ int app_main(int argc, char const * const * argv)
int const bpp[] = { 8 }; int const bpp[] = { 8 };
#endif #endif
initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...\n", ud.config.ScreenWidth, ud.config.ScreenHeight, initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...\n", ud.setup.xdim, ud.setup.ydim,
ud.config.ScreenBPP, ud.config.ScreenMode ? "fullscreen" : "windowed"); ud.setup.bpp, ud.setup.fullscreen ? "fullscreen" : "windowed");
int resIdx = 0; int resIdx = 0;
int bppIdx = 0; int bppIdx = 0;
@ -6556,9 +6556,9 @@ int app_main(int argc, char const * const * argv)
} }
} }
ud.config.ScreenWidth = res[resIdx].x; ud.setup.xdim = res[resIdx].x;
ud.config.ScreenHeight = res[resIdx].y; ud.setup.ydim = res[resIdx].y;
ud.config.ScreenBPP = bpp[bppIdx]; ud.setup.bpp = bpp[bppIdx];
} }
videoSetPalette(ud.brightness>>2,myplayer.palette,0); videoSetPalette(ud.brightness>>2,myplayer.palette,0);

View file

@ -159,6 +159,17 @@ extern camera_t g_camera;
#define MAX_RETURN_VALUES 6 #define MAX_RETURN_VALUES 6
// KEEPINSYNC lunatic/_defs_game.lua // KEEPINSYNC lunatic/_defs_game.lua
typedef struct {
int32_t usejoystick;
int32_t usemouse;
int32_t fullscreen;
int32_t xdim;
int32_t ydim;
int32_t bpp;
int32_t forcesetup;
int32_t noautoload;
} ud_setup_t;
typedef struct { typedef struct {
#if !defined LUNATIC #if !defined LUNATIC
vec3_t camerapos; vec3_t camerapos;
@ -210,8 +221,6 @@ typedef struct {
int8_t menutitle_pal, slidebar_palselected, slidebar_paldisabled; int8_t menutitle_pal, slidebar_palselected, slidebar_paldisabled;
struct { struct {
int32_t UseJoystick;
int32_t UseMouse;
int32_t AutoAim; int32_t AutoAim;
int32_t ShowWeapons; int32_t ShowWeapons;
int32_t MouseDeadZone,MouseBias; int32_t MouseDeadZone,MouseBias;
@ -248,18 +257,6 @@ typedef struct {
int32_t ReverseStereo; int32_t ReverseStereo;
//
// Screen variables
//
int32_t ScreenMode;
int32_t ScreenWidth;
int32_t ScreenHeight;
int32_t ScreenBPP;
int32_t ForceSetup;
int32_t NoAutoLoad;
int32_t scripthandle; int32_t scripthandle;
int32_t setupread; int32_t setupread;
@ -269,6 +266,8 @@ typedef struct {
int32_t useprecache; int32_t useprecache;
} config; } config;
ud_setup_t setup;
char overhead_on,last_overhead,showweapons; char overhead_on,last_overhead,showweapons;
char god,warp_on,cashman,eog,showallmap; char god,warp_on,cashman,eog,showallmap;
char show_help,scrollmode,noclip; char show_help,scrollmode,noclip;
@ -517,15 +516,12 @@ enum
}; };
#define G_ModDirSnprintf(buf, size, basename, ...) \ #define G_ModDirSnprintf(buf, size, basename, ...) \
\ (((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/" basename, g_modDir, ##__VA_ARGS__) : Bsnprintf(buf, size, basename, ##__VA_ARGS__)) \
(((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/" basename, g_modDir, ##__VA_ARGS__) \ >= ((int32_t)size) - 1)
: Bsnprintf(buf, size, basename, ##__VA_ARGS__)) >= ((int32_t)size) - 1\
) #define G_ModDirSnprintfLite(buf, size, basename) \
#define G_ModDirSnprintfLite(buf, size, basename) \ ((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/%s", g_modDir, basename) : Bsnprintf(buf, size, basename))
\
((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/%s", g_modDir, basename) \
: Bsnprintf(buf, size, basename))
static inline void G_NewGame_EnterLevel(void) static inline void G_NewGame_EnterLevel(void)
{ {

View file

@ -2867,29 +2867,24 @@ LUNATIC_EXTERN void C_SetCfgName(const char *cfgname)
if (Bstrcmp(g_setupFileName, cfgname) == 0) // no need to do anything if name is the same if (Bstrcmp(g_setupFileName, cfgname) == 0) // no need to do anything if name is the same
return; return;
char temp[BMAX_PATH];
struct Bstat st;
int32_t fullscreen = ud.config.ScreenMode;
int32_t xdim = ud.config.ScreenWidth, ydim = ud.config.ScreenHeight, bpp = ud.config.ScreenBPP;
int32_t usemouse = ud.config.UseMouse, usejoy = ud.config.UseJoystick;
#ifdef USE_OPENGL
int32_t glrm = glrendmode;
#endif
if (Bstrcmp(g_setupFileName, SETUPFILENAME) != 0) // set to something else via -cfg if (Bstrcmp(g_setupFileName, SETUPFILENAME) != 0) // set to something else via -cfg
return; return;
ud_setup_t const config = ud.setup;
#ifdef POLYMER
int const renderMode = glrendmode;
#endif
struct Bstat st;
if (Bstat(g_modDir, &st) < 0) if (Bstat(g_modDir, &st) < 0)
{ {
if (errno == ENOENT) // path doesn't exist if (errno == ENOENT) // path doesn't exist
{ {
if (Bmkdir(g_modDir, S_IRWXU) < 0) if (Bmkdir(g_modDir, S_IRWXU) < 0)
{ {
OSD_Printf("Failed to create configuration file directory %s\n", g_modDir); OSD_Printf("Failed to create directory \"%s\"!\n", g_modDir);
return; return;
} }
else OSD_Printf("Created configuration file directory %s\n", g_modDir);
} }
else else
{ {
@ -2904,7 +2899,8 @@ LUNATIC_EXTERN void C_SetCfgName(const char *cfgname)
} }
// XXX: Back up 'cfgname' as it may be the global 'tempbuf'. // XXX: Back up 'cfgname' as it may be the global 'tempbuf'.
Bstrncpyz(temp, cfgname, sizeof(temp)); char *temp = Xstrdup(cfgname);
CONFIG_WriteSetup(1); CONFIG_WriteSetup(1);
if (g_modDir[0] != '/') if (g_modDir[0] != '/')
@ -2912,18 +2908,15 @@ LUNATIC_EXTERN void C_SetCfgName(const char *cfgname)
else else
Bstrncpyz(g_setupFileName, temp, sizeof(g_setupFileName)); Bstrncpyz(g_setupFileName, temp, sizeof(g_setupFileName));
DO_FREE_AND_NULL(temp);
initprintf("Using config file \"%s\".\n", g_setupFileName); initprintf("Using config file \"%s\".\n", g_setupFileName);
CONFIG_ReadSetup(); CONFIG_ReadSetup();
ud.config.ScreenMode = fullscreen; ud.setup = config;
ud.config.ScreenWidth = xdim; #ifdef POLYMER
ud.config.ScreenHeight = ydim; glrendmode = renderMode;
ud.config.ScreenBPP = bpp;
ud.config.UseMouse = usemouse;
ud.config.UseJoystick = usejoy;
#ifdef USE_OPENGL
glrendmode = glrm;
#endif #endif
} }

View file

@ -383,7 +383,7 @@ static MenuEntry_t ME_GAMESETUP_SAVESETUP = MAKE_MENUENTRY( "Save setup", &MF_Re
#endif #endif
#if defined STARTUP_SETUP_WINDOW && !defined EDUKE32_SIMPLE_MENU #if defined STARTUP_SETUP_WINDOW && !defined EDUKE32_SIMPLE_MENU
static MenuOption_t MEO_GAMESETUP_STARTWIN = MAKE_MENUOPTION( &MF_Redfont, &MEOS_OffOn, &ud.config.ForceSetup ); static MenuOption_t MEO_GAMESETUP_STARTWIN = MAKE_MENUOPTION( &MF_Redfont, &MEOS_OffOn, &ud.setup.forcesetup );
static MenuEntry_t ME_GAMESETUP_STARTWIN = MAKE_MENUENTRY( "Startup window:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_GAMESETUP_STARTWIN, Option ); static MenuEntry_t ME_GAMESETUP_STARTWIN = MAKE_MENUENTRY( "Startup window:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_GAMESETUP_STARTWIN, Option );
#endif #endif
@ -2038,7 +2038,7 @@ static void Menu_Pre(MenuID_t cm)
case MENU_OPTIONS: case MENU_OPTIONS:
MenuEntry_DisableOnCondition(&ME_OPTIONS_PLAYERSETUP, ud.recstat == 1); MenuEntry_DisableOnCondition(&ME_OPTIONS_PLAYERSETUP, ud.recstat == 1);
MenuEntry_HideOnCondition(&ME_OPTIONS_JOYSTICKSETUP, !ud.config.UseJoystick || CONTROL_JoyPresent == 0); MenuEntry_HideOnCondition(&ME_OPTIONS_JOYSTICKSETUP, !ud.setup.usejoystick || CONTROL_JoyPresent == 0);
break; break;
case MENU_COLCORR: case MENU_COLCORR:
@ -3050,10 +3050,10 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
G_UpdateScreenArea(); G_UpdateScreenArea();
videoSetRenderMode(nrend); videoSetRenderMode(nrend);
vsync = videoSetVsync(nvsync); vsync = videoSetVsync(nvsync);
ud.config.ScreenMode = fullscreen; ud.setup.fullscreen = fullscreen;
ud.config.ScreenWidth = xres; ud.setup.xdim = xres;
ud.config.ScreenHeight = yres; ud.setup.ydim = yres;
ud.config.ScreenBPP = bpp; ud.setup.bpp = bpp;
} }
else if (entry == &ME_SOUND_RESTART) else if (entry == &ME_SOUND_RESTART)
{ {
@ -3289,7 +3289,7 @@ static void Menu_EntryOptionDidModify(MenuEntry_t *entry)
videoResetMode(); videoResetMode();
if (videoSetGameMode(fullscreen, xres, yres, bpp, upscalefactor)) if (videoSetGameMode(fullscreen, xres, yres, bpp, upscalefactor))
OSD_Printf("restartvid: Reset failed...\n"); OSD_Printf("restartvid: Reset failed...\n");
onvideomodechange(ud.config.ScreenBPP>8); onvideomodechange(ud.setup.bpp>8);
G_RefreshLights(); G_RefreshLights();
} }
#endif #endif

View file

@ -424,9 +424,9 @@ int osdcmd_restartvid(osdcmdptr_t UNUSED(parm))
{ {
UNREFERENCED_CONST_PARAMETER(parm); UNREFERENCED_CONST_PARAMETER(parm);
videoResetMode(); videoResetMode();
if (videoSetGameMode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP,ud.detail)) if (videoSetGameMode(ud.setup.fullscreen,ud.setup.xdim,ud.setup.ydim,ud.setup.bpp,ud.detail))
G_GameExit("restartvid: Reset failed...\n"); G_GameExit("restartvid: Reset failed...\n");
onvideomodechange(ud.config.ScreenBPP>8); onvideomodechange(ud.setup.bpp>8);
G_UpdateScreenArea(); G_UpdateScreenArea();
return OSDCMD_OK; return OSDCMD_OK;
@ -444,8 +444,8 @@ int osdcmd_restartmap(osdcmdptr_t UNUSED(parm))
static int osdcmd_vidmode(osdcmdptr_t parm) static int osdcmd_vidmode(osdcmdptr_t parm)
{ {
int32_t newbpp = ud.config.ScreenBPP, newwidth = ud.config.ScreenWidth, int32_t newbpp = ud.setup.bpp, newwidth = ud.setup.xdim,
newheight = ud.config.ScreenHeight, newfs = ud.config.ScreenMode; newheight = ud.setup.ydim, newfs = ud.setup.fullscreen;
int32_t tmp; int32_t tmp;
if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP; if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
@ -478,14 +478,14 @@ static int osdcmd_vidmode(osdcmdptr_t parm)
if (videoSetGameMode(newfs,newwidth,newheight,newbpp,upscalefactor)) if (videoSetGameMode(newfs,newwidth,newheight,newbpp,upscalefactor))
{ {
initprintf("vidmode: Mode change failed!\n"); initprintf("vidmode: Mode change failed!\n");
if (videoSetGameMode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP, upscalefactor)) if (videoSetGameMode(ud.setup.fullscreen, ud.setup.xdim, ud.setup.ydim, ud.setup.bpp, upscalefactor))
G_GameExit("vidmode: Reset failed!\n"); G_GameExit("vidmode: Reset failed!\n");
} }
ud.config.ScreenBPP = newbpp; ud.setup.bpp = newbpp;
ud.config.ScreenWidth = newwidth; ud.setup.xdim = newwidth;
ud.config.ScreenHeight = newheight; ud.setup.ydim = newheight;
ud.config.ScreenMode = newfs; ud.setup.fullscreen = newfs;
onvideomodechange(ud.config.ScreenBPP>8); onvideomodechange(ud.setup.bpp>8);
G_UpdateScreenArea(); G_UpdateScreenArea();
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -1397,11 +1397,11 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
} }
else if (!Bstrcasecmp(parm->name, "in_mouse")) else if (!Bstrcasecmp(parm->name, "in_mouse"))
{ {
CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent); CONTROL_MouseEnabled = (ud.setup.usemouse && CONTROL_MousePresent);
} }
else if (!Bstrcasecmp(parm->name, "in_joystick")) else if (!Bstrcasecmp(parm->name, "in_joystick"))
{ {
CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent); CONTROL_JoystickEnabled = (ud.setup.usejoystick && CONTROL_JoyPresent);
} }
else if (!Bstrcasecmp(parm->name, "vid_gamma")) else if (!Bstrcasecmp(parm->name, "vid_gamma"))
{ {
@ -1576,8 +1576,8 @@ int32_t registerosdcommands(void)
{ "hud_hidestick", "hide the touch input stick", (void *)&droidinput.hideStick, CVAR_BOOL, 0, 1 }, { "hud_hidestick", "hide the touch input stick", (void *)&droidinput.hideStick, CVAR_BOOL, 0, 1 },
#endif #endif
{ "in_joystick","enables input from the joystick if it is present",(void *)&ud.config.UseJoystick, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, { "in_joystick","enables input from the joystick if it is present",(void *)&ud.setup.usejoystick, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "in_mouse","enables input from the mouse if it is present",(void *)&ud.config.UseMouse, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, { "in_mouse","enables input from the mouse if it is present",(void *)&ud.setup.usemouse, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "in_aimmode", "0:toggle, 1:hold to aim", (void *)&ud.mouseaiming, CVAR_BOOL, 0, 1 }, { "in_aimmode", "0:toggle, 1:hold to aim", (void *)&ud.mouseaiming, CVAR_BOOL, 0, 1 },
{ {

View file

@ -1821,7 +1821,7 @@ int G_EnterLevel(int gameMode)
FX_StopAllSounds(); FX_StopAllSounds();
S_ClearSoundLocks(); S_ClearSoundLocks();
FX_SetReverb(0); FX_SetReverb(0);
videoSetGameMode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP, upscalefactor); videoSetGameMode(ud.setup.fullscreen, ud.setup.xdim, ud.setup.ydim, ud.setup.bpp, upscalefactor);
} }
if (Menu_HaveUserMap()) if (Menu_HaveUserMap())

View file

@ -20,19 +20,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "compat.h"
#include "gtkpixdata.h"
#include "dynamicgtk.h"
#include "duke3d.h"
#include "grpscan.h"
#include "build.h" #include "build.h"
#include "game.h"
#include "common.h" #include "common.h"
#include "common_game.h" #include "common_game.h"
#include "compat.h"
#include "duke3d.h"
#include "dynamicgtk.h"
#include "game.h"
#include "grpscan.h"
#include "gtkpixdata.h"
enum enum
{ {
@ -105,15 +101,9 @@ static struct
static struct static struct
{ {
grpfile_t const * grp; grpfile_t const * grp;
int32_t fullscreen; char *gamedir;
#ifdef POLYMER ud_setup_t shared;
int32_t polymer; int polymer;
#endif
int32_t xdim3d, ydim3d, bpp3d;
int32_t forcesetup;
int32_t autoload;
int32_t usemouse, usejoy;
char *custommoddir;
} settings; } settings;
static int32_t retval = -1, mode = TAB_MESSAGES; static int32_t retval = -1, mode = TAB_MESSAGES;
@ -133,14 +123,14 @@ static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data)
if (!gtk_combo_box_get_active_iter(combobox, &iter)) return; if (!gtk_combo_box_get_active_iter(combobox, &iter)) return;
if (!(data = gtk_combo_box_get_model(combobox))) return; if (!(data = gtk_combo_box_get_model(combobox))) return;
gtk_tree_model_get(data, &iter, 1, &val, -1); gtk_tree_model_get(data, &iter, 1, &val, -1);
settings.xdim3d = validmode[val].xdim; settings.shared.xdim = validmode[val].xdim;
settings.ydim3d = validmode[val].ydim; settings.shared.ydim = validmode[val].ydim;
} }
static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{ {
UNREFERENCED_PARAMETER(user_data); UNREFERENCED_PARAMETER(user_data);
settings.fullscreen = gtk_toggle_button_get_active(togglebutton); settings.shared.fullscreen = gtk_toggle_button_get_active(togglebutton);
PopulateForm(POPULATE_VIDEO); PopulateForm(POPULATE_VIDEO);
} }
@ -152,9 +142,9 @@ static void on_polymercheck_toggled(GtkToggleButton *togglebutton, gpointer user
{ {
glrendmode = REND_POLYMER; glrendmode = REND_POLYMER;
settings.polymer = TRUE; settings.polymer = TRUE;
if (settings.bpp3d == 8) if (settings.shared.bpp == 8)
{ {
settings.bpp3d = 32; settings.shared.bpp = 32;
PopulateForm(POPULATE_VIDEO); PopulateForm(POPULATE_VIDEO);
} }
} }
@ -171,10 +161,10 @@ static void on_inputdevcombo_changed(GtkComboBox *combobox, gpointer user_data)
UNREFERENCED_PARAMETER(user_data); UNREFERENCED_PARAMETER(user_data);
switch (gtk_combo_box_get_active(combobox)) switch (gtk_combo_box_get_active(combobox))
{ {
case 0: settings.usemouse = 0; settings.usejoy = 0; break; case 0: settings.shared.usemouse = 0; settings.shared.usejoystick = 0; break;
case 1: settings.usemouse = 1; settings.usejoy = 0; break; case 1: settings.shared.usemouse = 1; settings.shared.usejoystick = 0; break;
case 2: settings.usemouse = 0; settings.usejoy = 1; break; case 2: settings.shared.usemouse = 0; settings.shared.usejoystick = 1; break;
case 3: settings.usemouse = 1; settings.usejoy = 1; break; case 3: settings.shared.usemouse = 1; settings.shared.usejoystick = 1; break;
} }
} }
@ -193,21 +183,21 @@ static void on_custommodcombo_changed(GtkComboBox *combobox, gpointer user_data)
path = gtk_tree_model_get_path(model, &iter); path = gtk_tree_model_get_path(model, &iter);
if (*gtk_tree_path_get_indices(path) == NONE) if (*gtk_tree_path_get_indices(path) == NONE)
settings.custommoddir = NULL; settings.gamedir = NULL;
else settings.custommoddir = value; else settings.gamedir = value;
} }
} }
static void on_autoloadcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) static void on_autoloadcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{ {
UNREFERENCED_PARAMETER(user_data); UNREFERENCED_PARAMETER(user_data);
settings.autoload = gtk_toggle_button_get_active(togglebutton); settings.shared.noautoload = !gtk_toggle_button_get_active(togglebutton);
} }
static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{ {
UNREFERENCED_PARAMETER(user_data); UNREFERENCED_PARAMETER(user_data);
settings.forcesetup = gtk_toggle_button_get_active(togglebutton); settings.shared.forcesetup = gtk_toggle_button_get_active(togglebutton);
} }
static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data) static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data)
@ -316,17 +306,17 @@ static void PopulateForm(unsigned char pgs)
GtkTreeIter iter; GtkTreeIter iter;
char buf[64]; char buf[64];
mode3d = videoCheckMode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); mode3d = videoCheckMode(&settings.shared.xdim, &settings.shared.ydim, settings.shared.bpp, settings.shared.fullscreen, 1);
if (mode3d < 0) if (mode3d < 0)
{ {
int32_t i, cd[] = { 32, 24, 16, 15, 8, 0 }; int32_t i, cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; } for (i=0; cd[i];) { if (cd[i] >= settings.shared.bpp) i++; else break; }
for (; cd[i]; i++) for (; cd[i]; i++)
{ {
mode3d = videoCheckMode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); mode3d = videoCheckMode(&settings.shared.xdim, &settings.shared.ydim, cd[i], settings.shared.fullscreen, 1);
if (mode3d < 0) continue; if (mode3d < 0) continue;
settings.bpp3d = cd[i]; settings.shared.bpp = cd[i];
break; break;
} }
} }
@ -336,7 +326,7 @@ static void PopulateForm(unsigned char pgs)
for (i=0; i<validmodecnt; i++) for (i=0; i<validmodecnt; i++)
{ {
if (validmode[i].fs != settings.fullscreen) continue; if (validmode[i].fs != settings.shared.fullscreen) continue;
// all modes get added to the 3D mode list // all modes get added to the 3D mode list
Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp == 8 ? "software" : "OpenGL"); Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp == 8 ? "software" : "OpenGL");
@ -375,14 +365,14 @@ static void PopulateForm(unsigned char pgs)
gtk_list_store_append(devlist, &iter); gtk_list_store_append(devlist, &iter);
gtk_list_store_set(devlist, &iter, 0,availabledev[i], -1); gtk_list_store_set(devlist, &iter, 0,availabledev[i], -1);
} }
switch (settings.usemouse) switch (settings.shared.usemouse)
{ {
case 0: if (settings.usejoy) case 0: if (settings.shared.usejoystick)
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_JOYSTICK); gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_JOYSTICK);
else else
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_KB); gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_KB);
break; break;
case 1: if (settings.usejoy) case 1: if (settings.shared.usejoystick)
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_ALL); gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_ALL);
else else
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_MOUSE); gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_MOUSE);
@ -403,14 +393,14 @@ static void PopulateForm(unsigned char pgs)
gtk_tree_model_get_iter(GTK_TREE_MODEL(modsdir), &iter, path); gtk_tree_model_get_iter(GTK_TREE_MODEL(modsdir), &iter, path);
gtk_tree_model_get(GTK_TREE_MODEL(modsdir), &iter, 0,&value, -1); gtk_tree_model_get(GTK_TREE_MODEL(modsdir), &iter, 0,&value, -1);
if (Bstrcmp(settings.custommoddir, "/") == 0) if (Bstrcmp(settings.gamedir, "/") == 0)
{ {
gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.custommodcombo), NONE); gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.custommodcombo), NONE);
settings.custommoddir = NULL; settings.gamedir = NULL;
break; break;
} }
if (Bstrcmp(settings.custommoddir, value) == 0) if (Bstrcmp(settings.gamedir, value) == 0)
{ {
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stwidgets.custommodcombo), gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stwidgets.custommodcombo),
&iter); &iter);
@ -420,12 +410,12 @@ static void PopulateForm(unsigned char pgs)
} }
// populate check buttons // populate check buttons
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.fullscreen); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.shared.fullscreen);
#ifdef POLYMER #ifdef POLYMER
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.polymercheck), settings.polymer); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.polymercheck), settings.polymer);
#endif #endif
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.autoloadcheck), settings.autoload); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.autoloadcheck), !settings.shared.noautoload);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.alwaysshowcheck), settings.forcesetup); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.alwaysshowcheck), settings.shared.forcesetup);
} }
if ((pgs == ALL) || (pgs == POPULATE_GAME)) if ((pgs == ALL) || (pgs == POPULATE_GAME))
@ -867,23 +857,13 @@ int32_t startwin_run(void)
SetPage(TAB_CONFIG); SetPage(TAB_CONFIG);
settings.xdim3d = ud.config.ScreenWidth; settings.shared = ud.setup;
settings.ydim3d = ud.config.ScreenHeight; settings.gamedir = g_modDir;
settings.bpp3d = ud.config.ScreenBPP;
settings.fullscreen = ud.config.ScreenMode;
settings.usemouse = ud.config.UseMouse;
settings.usejoy = ud.config.UseJoystick;
settings.custommoddir = g_modDir;
settings.forcesetup = ud.config.ForceSetup;
settings.grp = g_selectedGrp; settings.grp = g_selectedGrp;
if (ud.config.NoAutoLoad) settings.autoload = FALSE;
else settings.autoload = TRUE;
#ifdef POLYMER #ifdef POLYMER
if (glrendmode == REND_POLYMER) settings.polymer = (glrendmode == REND_POLYMER);
{ #else
if (settings.bpp3d == 8) settings.bpp3d = 32; settings.polymer = 0;
settings.polymer = TRUE;
}
#endif #endif
PopulateForm(ALL); PopulateForm(ALL);
@ -892,21 +872,11 @@ int32_t startwin_run(void)
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
if (retval) // launch the game with these parameters if (retval) // launch the game with these parameters
{ {
ud.config.ScreenWidth = settings.xdim3d; ud.setup = settings.shared;
ud.config.ScreenHeight = settings.ydim3d; glrendmode = (settings.polymer) ? REND_POLYMER : REND_POLYMOST;
ud.config.ScreenBPP = settings.bpp3d;
ud.config.ScreenMode = settings.fullscreen;
ud.config.UseMouse = settings.usemouse;
ud.config.UseJoystick = settings.usejoy;
ud.config.ForceSetup = settings.forcesetup;
g_selectedGrp = settings.grp; g_selectedGrp = settings.grp;
if (settings.custommoddir != NULL) Bstrcpy(g_modDir, (g_noSetup == 0 && settings.gamedir != NULL) ? settings.gamedir : "/");
Bstrcpy(g_modDir, settings.custommoddir);
else Bsprintf(g_modDir, "/");
if (settings.autoload) ud.config.NoAutoLoad = FALSE;
else ud.config.NoAutoLoad = TRUE;
} }
return retval; return retval;

View file

@ -24,58 +24,47 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#error Only for Windows #error Only for Windows
#endif #endif
#include "compat.h"
#define NEED_WINDOWSX_H
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "renderlayer.h" #include "renderlayer.h"
#ifdef STARTUP_SETUP_WINDOW #ifdef STARTUP_SETUP_WINDOW
#define NEED_WINDOWSX_H
#define NEED_COMMCTRL_H
#define ONLY_USERDEFS
#include "_control.h"
#include "build.h" #include "build.h"
#include "cache1d.h" #include "cache1d.h"
#include "grpscan.h"
#include "startwin.game.h"
// for ud
#include "keyboard.h"
#include "control.h"
#include "_control.h"
#include "function.h"
#include "inv.h"
#define ONLY_USERDEFS
#include "game.h"
#include "common_game.h"
#include "cmdline.h" #include "cmdline.h"
#include "common_game.h"
#include "compat.h"
#include "control.h"
#include "function.h"
#include "game.h"
#include "grpscan.h"
#include "inv.h"
#include "keyboard.h"
#include "startwin.game.h"
#include "windows_inc.h"
#define TAB_CONFIG 0 #define TAB_CONFIG 0
// #define TAB_GAME 1
#define TAB_MESSAGES 1 #define TAB_MESSAGES 1
static struct static struct
{ {
struct grpfile_t const * grp; struct grpfile_t const * grp;
int32_t flags; // bitfield
int32_t xdim, ydim, bpp;
int32_t forcesetup;
int32_t usemouse, usejoy;
char *gamedir; char *gamedir;
ud_setup_t shared;
int polymer;
} }
settings; settings;
static HWND startupdlg = NULL; static HWND startupdlg;
static HWND pages[3] = static HWND pages[3];
{ static int done = -1;
NULL, NULL, NULL static int mode = TAB_CONFIG;
};
static int32_t done = -1, mode = TAB_CONFIG;
static CACHE1D_FIND_REC *finddirs=NULL; static CACHE1D_FIND_REC *finddirs;
static inline void clearfilenames(void) static inline void clearfilenames(void)
{ {
@ -83,11 +72,10 @@ static inline void clearfilenames(void)
finddirs = NULL; finddirs = NULL;
} }
static inline int32_t getfilenames(char const *path) static inline void getfilenames(char const *path)
{ {
clearfilenames(); clearfilenames();
finddirs = klistpath(path,"*",CACHE1D_FIND_DIR); finddirs = klistpath(path,"*",CACHE1D_FIND_DIR);
return 0;
} }
#define POPULATE_VIDEO 1 #define POPULATE_VIDEO 1
@ -108,22 +96,19 @@ const char *controlstrings[] = { "Keyboard only", "Keyboard and mouse", "Keyboar
static void PopulateForm(int32_t pgs) static void PopulateForm(int32_t pgs)
{ {
HWND hwnd;
char buf[512]; char buf[512];
int32_t i,j;
if (pgs & POPULATE_GAMEDIRS) if (pgs & POPULATE_GAMEDIRS)
{ {
CACHE1D_FIND_REC *dirs = NULL; HWND hwnd = GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR);
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR);
getfilenames("/"); getfilenames("/");
(void)ComboBox_ResetContent(hwnd); (void)ComboBox_ResetContent(hwnd);
j = ComboBox_AddString(hwnd, "None"); int const r = ComboBox_AddString(hwnd, "None");
(void)ComboBox_SetItemData(hwnd, j, 0); (void)ComboBox_SetItemData(hwnd, r, 0);
(void)ComboBox_SetCurSel(hwnd, j); (void)ComboBox_SetCurSel(hwnd, r);
for (dirs=finddirs,i=1,j=1; dirs != NULL; dirs=dirs->next) auto dirs = finddirs;
for (int i=1, j=1; dirs != NULL; dirs=dirs->next)
{ {
if (Bstrcasecmp(dirs->name, "autoload") == 0) if (Bstrcasecmp(dirs->name, "autoload") == 0)
{ {
@ -133,7 +118,7 @@ static void PopulateForm(int32_t pgs)
(void)ComboBox_AddString(hwnd, dirs->name); (void)ComboBox_AddString(hwnd, dirs->name);
(void)ComboBox_SetItemData(hwnd, i, j); (void)ComboBox_SetItemData(hwnd, i, j);
if (Bstrcasecmp(dirs->name,settings.gamedir) == 0) if (Bstrcasecmp(dirs->name, settings.gamedir) == 0)
(void)ComboBox_SetCurSel(hwnd, i); (void)ComboBox_SetCurSel(hwnd, i);
i++; i++;
@ -143,41 +128,41 @@ static void PopulateForm(int32_t pgs)
if (pgs & POPULATE_VIDEO) if (pgs & POPULATE_VIDEO)
{ {
int32_t mode; HWND hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
int mode = videoCheckMode(&settings.shared.xdim, &settings.shared.ydim, settings.shared.bpp, settings.shared.fullscreen, 1);
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE); if (mode < 0 || (settings.shared.bpp < 15 && (settings.polymer)))
mode = videoCheckMode(&settings.xdim, &settings.ydim, settings.bpp, settings.flags&1, 1);
if (mode < 0 || (settings.bpp < 15 && (settings.flags & 2)))
{ {
int32_t cd[] = { 32, 24, 16, 15, 8, 0 }; int CONSTEXPR cd[] = { 32, 24, 16, 15, 8, 0 };
int i;
for (i=0; cd[i];) for (i=0; cd[i];)
{ {
if (cd[i] >= settings.bpp) i++; if (cd[i] >= settings.shared.bpp) i++;
else break; else break;
} }
for (; cd[i]; i++) for (; cd[i]; i++)
{ {
mode = videoCheckMode(&settings.xdim, &settings.ydim, cd[i], settings.flags&1, 1); mode = videoCheckMode(&settings.shared.xdim, &settings.shared.ydim, cd[i], settings.shared.fullscreen, 1);
if (mode < 0) continue; if (mode < 0) continue;
settings.bpp = cd[i]; settings.shared.bpp = cd[i];
break; break;
} }
} }
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.flags&1) ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.shared.fullscreen) ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.flags&2) ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.polymer) ? BST_CHECKED : BST_UNCHECKED));
(void)ComboBox_ResetContent(hwnd); (void)ComboBox_ResetContent(hwnd);
for (i=0; i<validmodecnt; i++) for (int i=0; i<validmodecnt; i++)
{ {
if (validmode[i].fs != (settings.flags & 1)) continue; if (validmode[i].fs != (settings.shared.fullscreen)) continue;
if ((validmode[i].bpp < 15) && (settings.flags & 2)) continue; if ((validmode[i].bpp < 15) && (settings.polymer)) continue;
// all modes get added to the 3D mode list // all modes get added to the 3D mode list
Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp == 8 ? "software" : "OpenGL"); Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp == 8 ? "software" : "OpenGL");
j = ComboBox_AddString(hwnd, buf); int const j = ComboBox_AddString(hwnd, buf);
(void)ComboBox_SetItemData(hwnd, j, i); (void)ComboBox_SetItemData(hwnd, j, i);
if (i == mode)(void)ComboBox_SetCurSel(hwnd, j); if (i == mode)(void)ComboBox_SetCurSel(hwnd, j);
} }
@ -185,21 +170,21 @@ static void PopulateForm(int32_t pgs)
if (pgs & POPULATE_CONFIG) if (pgs & POPULATE_CONFIG)
{ {
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.shared.forcesetup ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCAUTOLOAD), (!(settings.flags & 4) ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCAUTOLOAD), (!(settings.shared.noautoload) ? BST_CHECKED : BST_UNCHECKED));
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCINPUT); HWND hwnd = GetDlgItem(pages[TAB_CONFIG], IDCINPUT);
(void)ComboBox_ResetContent(hwnd); (void)ComboBox_ResetContent(hwnd);
(void)ComboBox_SetCurSel(hwnd, 0); (void)ComboBox_SetCurSel(hwnd, 0);
j = 4; int j = 4;
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN
if (di_disabled) j = 2; if (di_disabled) j = 2;
#endif #endif
for (i=0; i<j; i++) for (int i=0; i<j; i++)
{ {
(void)ComboBox_InsertString(hwnd, i, controlstrings[i]); (void)ComboBox_InsertString(hwnd, i, controlstrings[i]);
(void)ComboBox_SetItemData(hwnd, i, i); (void)ComboBox_SetItemData(hwnd, i, i);
@ -207,13 +192,13 @@ static void PopulateForm(int32_t pgs)
switch (i) switch (i)
{ {
case INPUT_MOUSE: case INPUT_MOUSE:
if (settings.usemouse && !settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); if (settings.shared.usemouse && !settings.shared.usejoystick)(void)ComboBox_SetCurSel(hwnd, i);
break; break;
case INPUT_JOYSTICK: case INPUT_JOYSTICK:
if (!settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); if (!settings.shared.usemouse && settings.shared.usejoystick)(void)ComboBox_SetCurSel(hwnd, i);
break; break;
case INPUT_ALL: case INPUT_ALL:
if (settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i); if (settings.shared.usemouse && settings.shared.usejoystick)(void)ComboBox_SetCurSel(hwnd, i);
break; break;
} }
} }
@ -221,20 +206,15 @@ static void PopulateForm(int32_t pgs)
if (pgs & POPULATE_GAME) if (pgs & POPULATE_GAME)
{ {
int32_t j; HWND hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA);
char buf[1024];
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA); for (auto fg = foundgrps; fg; fg=fg->next)
for (grpfile_t const * fg = foundgrps; fg; fg=fg->next)
{ {
Bsprintf(buf, "%s\t%s", fg->type->name, fg->filename); Bsprintf(buf, "%s\t%s", fg->type->name, fg->filename);
j = ListBox_AddString(hwnd, buf); int const j = ListBox_AddString(hwnd, buf);
(void)ListBox_SetItemData(hwnd, j, (LPARAM)fg); (void)ListBox_SetItemData(hwnd, j, (LPARAM)fg);
if (settings.grp == fg) if (settings.grp == fg)
{
(void)ListBox_SetCurSel(hwnd, j); (void)ListBox_SetCurSel(hwnd, j);
}
} }
} }
} }
@ -247,61 +227,55 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDCFULLSCREEN: case IDCFULLSCREEN:
if (settings.flags & 1) settings.flags &= ~1; settings.shared.fullscreen = !settings.shared.fullscreen;
else settings.flags |= 1;
PopulateForm(POPULATE_VIDEO); PopulateForm(POPULATE_VIDEO);
return TRUE; return TRUE;
case IDCPOLYMER: case IDCPOLYMER:
if (settings.flags & 2) settings.flags &= ~2; settings.polymer = !settings.polymer;
else settings.flags |= 2; if (settings.shared.bpp == 8) settings.shared.bpp = 32;
if (settings.bpp == 8) settings.bpp = 32;
PopulateForm(POPULATE_VIDEO); PopulateForm(POPULATE_VIDEO);
return TRUE; return TRUE;
case IDCVMODE: case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE) if (HIWORD(wParam) == CBN_SELCHANGE)
{ {
int32_t i; int i = ComboBox_GetCurSel((HWND)lParam);
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) if (i != CB_ERR)
{ {
settings.xdim = validmode[i].xdim; settings.shared.xdim = validmode[i].xdim;
settings.ydim = validmode[i].ydim; settings.shared.ydim = validmode[i].ydim;
settings.bpp = validmode[i].bpp; settings.shared.bpp = validmode[i].bpp;
} }
} }
return TRUE; return TRUE;
case IDCALWAYSSHOW: case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED; settings.shared.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE; return TRUE;
case IDCAUTOLOAD: case IDCAUTOLOAD:
if (IsDlgButtonChecked(hwndDlg, IDCAUTOLOAD) == BST_CHECKED) settings.shared.noautoload = (IsDlgButtonChecked(hwndDlg, IDCAUTOLOAD) != BST_CHECKED);
settings.flags &= ~4;
else settings.flags |= 4;
return TRUE; return TRUE;
case IDCINPUT: case IDCINPUT:
if (HIWORD(wParam) == CBN_SELCHANGE) if (HIWORD(wParam) == CBN_SELCHANGE)
{ {
int32_t i; int i = ComboBox_GetCurSel((HWND)lParam);
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) if (i != CB_ERR)
{ {
switch (i) switch (i)
{ {
case INPUT_KB: case INPUT_KB:
settings.usemouse = settings.usejoy = 0; settings.shared.usemouse = settings.shared.usejoystick = 0;
break; break;
case INPUT_MOUSE: case INPUT_MOUSE:
settings.usemouse = 1; settings.shared.usemouse = 1;
settings.usejoy = 0; settings.shared.usejoystick = 0;
break; break;
case INPUT_JOYSTICK: case INPUT_JOYSTICK:
settings.usemouse = 0; settings.shared.usemouse = 0;
settings.usejoy = 1; settings.shared.usejoystick = 1;
break; break;
case INPUT_ALL: case INPUT_ALL:
settings.usemouse = settings.usejoy = 1; settings.shared.usemouse = settings.shared.usejoystick = 1;
break; break;
} }
} }
@ -311,9 +285,7 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
case IDCGAMEDIR: case IDCGAMEDIR:
if (HIWORD(wParam) == CBN_SELCHANGE) if (HIWORD(wParam) == CBN_SELCHANGE)
{ {
int32_t i,j; int i = ComboBox_GetCurSel((HWND)lParam);
CACHE1D_FIND_REC *dir = NULL;
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) if (i != CB_ERR)
{ {
@ -321,21 +293,23 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
settings.gamedir = NULL; settings.gamedir = NULL;
else else
{ {
for (j=1,dir=finddirs; dir != NULL; dir=dir->next,j++) CACHE1D_FIND_REC *dir = finddirs;
for (int j = 1; dir != NULL; dir = dir->next, j++)
{
if (j == i) if (j == i)
{ {
settings.gamedir = dir->name; settings.gamedir = dir->name;
break; break;
} }
}
} }
} }
} }
return TRUE; return TRUE;
case IDCDATA: case IDCDATA:
{ {
intptr_t i;
if (HIWORD(wParam) != LBN_SELCHANGE) break; if (HIWORD(wParam) != LBN_SELCHANGE) break;
i = ListBox_GetCurSel((HWND)lParam); intptr_t i = ListBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) if (i != CB_ERR)
{ {
@ -354,53 +328,43 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
} }
static void SetPage(int32_t n) static void SetPage(int pageNum)
{ {
HWND tab; HWND tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
int32_t cur; auto const cur = SendMessage(tab, TCM_GETCURSEL, 0, 0);
tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); ShowWindow(pages[cur], SW_HIDE);
cur = (int32_t)SendMessage(tab, TCM_GETCURSEL,0,0); SendMessage(tab, TCM_SETCURSEL, pageNum, 0);
ShowWindow(pages[cur],SW_HIDE); ShowWindow(pages[pageNum], SW_SHOW);
SendMessage(tab, TCM_SETCURSEL, n, 0); mode = pageNum;
ShowWindow(pages[n],SW_SHOW);
mode = n;
SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL)); SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
} }
static void EnableConfig(int32_t n) static void EnableConfig(bool n)
{ {
//EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n); //EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n); EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCDATA), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUT), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUT), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCDATA), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR), n);
} }
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
static HBITMAP hbmp = NULL; static HBITMAP hbmp = NULL;
HDC hdc;
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
HWND hwnd;
RECT r, rdlg, chrome, rtab, rcancel, rstart;
int32_t xoffset = 0, yoffset = 0;
// Fetch the positions (in screen coordinates) of all the windows we need to tweak // Fetch the positions (in screen coordinates) of all the windows we need to tweak
ZeroMemory(&chrome, sizeof(chrome)); RECT chrome = {};
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
RECT rdlg;
GetWindowRect(hwndDlg, &rdlg); GetWindowRect(hwndDlg, &rdlg);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
// Knock off the non-client area of the main dialogue to give just the client area // Knock off the non-client area of the main dialogue to give just the client area
rdlg.left -= chrome.left; rdlg.left -= chrome.left;
@ -408,17 +372,26 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
rdlg.right -= chrome.right; rdlg.right -= chrome.right;
rdlg.bottom -= chrome.bottom; rdlg.bottom -= chrome.bottom;
RECT rtab;
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
// Translate them to client-relative coordinates wrt the main dialogue window // Translate them to client-relative coordinates wrt the main dialogue window
rtab.right -= rtab.left - 1; rtab.right -= rtab.left - 1;
rtab.bottom -= rtab.top - 1; rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left; rtab.left -= rdlg.left;
rtab.top -= rdlg.top; rtab.top -= rdlg.top;
RECT rcancel;
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
rcancel.right -= rcancel.left - 1; rcancel.right -= rcancel.left - 1;
rcancel.bottom -= rcancel.top - 1; rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left; rcancel.left -= rdlg.left;
rcancel.top -= rdlg.top; rcancel.top -= rdlg.top;
RECT rstart;
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
rstart.right -= rstart.left - 1; rstart.right -= rstart.left - 1;
rstart.bottom -= rstart.top - 1; rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left; rstart.left -= rdlg.left;
@ -432,11 +405,15 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
// Load the bitmap into the bitmap control and fetch its dimensions // Load the bitmap into the bitmap control and fetch its dimensions
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
HWND hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_BITMAP);
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
RECT r;
GetClientRect(hwnd, &r); GetClientRect(hwnd, &r);
xoffset = r.right;
yoffset = r.bottom - rdlg.bottom; int const xoffset = r.right;
int const yoffset = r.bottom - rdlg.bottom;
// Shift and resize the controls that require it // Shift and resize the controls that require it
rtab.left += xoffset; rtab.left += xoffset;
@ -454,7 +431,7 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
// Move the main dialogue to the centre of the screen // Move the main dialogue to the centre of the screen
hdc = GetDC(NULL); HDC hdc = GetDC(NULL);
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
ReleaseDC(NULL, hdc); ReleaseDC(NULL, hdc);
@ -463,17 +440,16 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
// Add tabs to the tab control // Add tabs to the tab control
{ {
TCITEM tab; static char textSetup[] = TEXT("Setup");
static char textMessageLog[] = TEXT("Message Log");
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
ZeroMemory(&tab, sizeof(tab)); TCITEM tab = {};
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
static char textSetup[] = TEXT("Setup");
tab.pszText = textSetup; tab.pszText = textSetup;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
static char textMessageLog[] = TEXT("Message Log");
tab.pszText = textMessageLog; tab.pszText = textMessageLog;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
@ -487,14 +463,14 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
r.left += rtab.left; r.left += rtab.left;
// Create the pages and position them in the tab control, but hide them // Create the pages and position them in the tab control, but hide them
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); SetWindowPos(pages[TAB_CONFIG], hwnd, r.left, r.top, r.right, r.bottom, SWP_HIDEWINDOW);
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES); pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); SetWindowPos(pages[TAB_MESSAGES], hwnd, r.left, r.top, r.right, r.bottom, SWP_HIDEWINDOW);
SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
// Tell the editfield acting as the console to exclude the width of the scrollbar // Tell the editfield acting as the console to exclude the width of the scrollbar
GetClientRect(pages[TAB_MESSAGES],&r); GetClientRect(pages[TAB_MESSAGES], &r);
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
r.left = r.top = 0; r.left = r.top = 0;
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
@ -513,24 +489,17 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
case WM_NOTIFY: case WM_NOTIFY:
{ {
LPNMHDR nmhdr = (LPNMHDR)lParam; auto nmhdr = (LPNMHDR)lParam;
int32_t cur;
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
cur = (int32_t)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); int const cur = SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code) switch (nmhdr->code)
{ {
case TCN_SELCHANGING: case TCN_SELCHANGING:
{ case TCN_SELCHANGE:
if (cur < 0 || !pages[cur]) break; if (cur < 0 || !pages[cur])
ShowWindow(pages[cur],SW_HIDE); break;
return TRUE; ShowWindow(pages[cur], nmhdr->code == TCN_SELCHANGING ? SW_HIDE : SW_SHOW);
} return TRUE;
case TCN_SELCHANGE:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
}
} }
break; break;
} }
@ -584,10 +553,8 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
int32_t startwin_open(void) int32_t startwin_open(void)
{ {
INITCOMMONCONTROLSEX icc;
if (startupdlg) return 1; if (startupdlg) return 1;
icc.dwSize = sizeof(icc); INITCOMMONCONTROLSEX icc = { sizeof(icc), ICC_TAB_CLASSES };
icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc); InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) if (startupdlg)
@ -609,43 +576,43 @@ int32_t startwin_close(void)
int32_t startwin_puts(const char *buf) int32_t startwin_puts(const char *buf)
{ {
const char *p = NULL, *q = NULL;
static char workbuf[1024];
static int32_t newline = 0;
int32_t curlen, linesbefore, linesafter;
HWND edctl;
int32_t vis;
static HWND dactrl = NULL;
if (!startupdlg) return 1; if (!startupdlg) return 1;
edctl = pages[TAB_MESSAGES]; const HWND edctl = pages[TAB_MESSAGES];
if (!edctl) return -1; if (!edctl) return -1;
static HWND dactrl = NULL;
if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL); if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
vis = ((int32_t)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES); int const vis = ((int)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES);
if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0); if (vis)
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); SendMessage(edctl, WM_SETREDRAW, FALSE, 0);
int const curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf; int const numlines = SendMessage(edctl, EM_GETLINECOUNT, 0, 0);
static bool newline = false;
const char *p = buf;
while (*p) while (*p)
{ {
if (newline) if (newline)
{ {
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
newline = 0; newline = false;
} }
q = p; const char *q = p;
while (*q && *q != '\n') q++; while (*q && *q != '\n') q++;
static char workbuf[1024];
Bmemcpy(workbuf, p, q-p); Bmemcpy(workbuf, p, q-p);
if (*q == '\n') if (*q == '\n')
{ {
if (!q[1]) if (!q[1])
{ {
newline = 1; newline = true;
workbuf[q-p] = 0; workbuf[q-p] = 0;
} }
else else
@ -663,9 +630,13 @@ int32_t startwin_puts(const char *buf)
} }
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
} }
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); int const newnumlines = SendMessage(edctl, EM_GETLINECOUNT, 0, 0);
if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0); SendMessage(edctl, EM_LINESCROLL, 0, newnumlines - numlines);
if (vis)
SendMessage(edctl, WM_SETREDRAW, TRUE, 0);
return 0; return 0;
} }
@ -685,7 +656,6 @@ int32_t startwin_idle(void *v)
int32_t startwin_run(void) int32_t startwin_run(void)
{ {
MSG msg;
if (!startupdlg) return 1; if (!startupdlg) return 1;
done = -1; done = -1;
@ -693,24 +663,22 @@ int32_t startwin_run(void)
SetPage(TAB_CONFIG); SetPage(TAB_CONFIG);
EnableConfig(1); EnableConfig(1);
settings.flags = 0;
if (ud.config.ScreenMode) settings.flags |= 1;
#ifdef POLYMER #ifdef POLYMER
if (glrendmode == REND_POLYMER) settings.flags |= 2; settings.polymer = (glrendmode == REND_POLYMER);
#else
settings.polymer = 0;
#endif #endif
if (ud.config.NoAutoLoad) settings.flags |= 4;
settings.xdim = ud.config.ScreenWidth; settings.shared = ud.setup;
settings.ydim = ud.config.ScreenHeight;
settings.bpp = ud.config.ScreenBPP;
settings.forcesetup = ud.config.ForceSetup;
settings.usemouse = ud.config.UseMouse;
settings.usejoy = ud.config.UseJoystick;
settings.grp = g_selectedGrp; settings.grp = g_selectedGrp;
settings.gamedir = g_modDir; settings.gamedir = g_modDir;
PopulateForm(-1); PopulateForm(-1);
while (done < 0) do
{ {
MSG msg;
switch (GetMessage(&msg, NULL, 0,0)) switch (GetMessage(&msg, NULL, 0,0))
{ {
case 0: case 0:
@ -719,35 +687,24 @@ int32_t startwin_run(void)
case -1: case -1:
return -1; return -1;
default: default:
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg))
break;
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
break; break;
} }
} }
while (done < 0);
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
EnableConfig(0); EnableConfig(0);
if (done) if (done)
{ {
ud.config.ScreenMode = (settings.flags&1); ud.setup = settings.shared;
#ifdef POLYMER glrendmode = (settings.polymer) ? REND_POLYMER : REND_POLYMOST;
if (settings.flags & 2) glrendmode = REND_POLYMER;
else glrendmode = REND_POLYMOST;
#endif
if (settings.flags & 4) ud.config.NoAutoLoad = 1;
else ud.config.NoAutoLoad = 0;
ud.config.ScreenWidth = settings.xdim;
ud.config.ScreenHeight = settings.ydim;
ud.config.ScreenBPP = settings.bpp;
ud.config.ForceSetup = settings.forcesetup;
ud.config.UseMouse = settings.usemouse;
ud.config.UseJoystick = settings.usejoy;
g_selectedGrp = settings.grp; g_selectedGrp = settings.grp;
Bstrcpy(g_modDir, (g_noSetup == 0 && settings.gamedir != NULL) ? settings.gamedir : "/");
if (g_noSetup == 0 && settings.gamedir != NULL)
Bstrcpy(g_modDir,settings.gamedir);
else Bsprintf(g_modDir,"/");
} }
return done; return done;