From 6bab975972475502e8813215f00816c3a8192576 Mon Sep 17 00:00:00 2001 From: terminx Date: Fri, 7 Jul 2006 18:41:05 +0000 Subject: [PATCH] GRP selection from JonoF git-svn-id: https://svn.eduke32.com/eduke32@214 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/devcpp/Build.dev | 29 +- polymer/build/devcpp/Game.dev | 50 +- polymer/build/devcpp/engineinfo.c | 5 - polymer/build/devcpp/libEditor.dev | 4 +- polymer/build/devcpp/libEngine.dev | 36 +- polymer/build/include/build.h | 1 + polymer/build/include/scriptfile.h | 1 + polymer/build/src/engine.c | 47 +- polymer/build/src/scriptfile.c | 6 + polymer/eduke32/Makefile | 4 +- polymer/eduke32/Makefile.deps | 5 +- polymer/eduke32/source/game.c | 58 +- polymer/eduke32/source/misc/gameres.rc | 11 +- polymer/eduke32/source/startdlg.c | 180 +++++ polymer/eduke32/source/startdlg.h | 12 + polymer/eduke32/source/startgtk.game.c | 870 ++++++++++++------------- polymer/eduke32/source/startwin.game.c | 157 +++-- polymer/eduke32/source/startwin.game.h | 4 + 18 files changed, 909 insertions(+), 571 deletions(-) delete mode 100644 polymer/build/devcpp/engineinfo.c create mode 100755 polymer/eduke32/source/startdlg.c create mode 100755 polymer/eduke32/source/startdlg.h diff --git a/polymer/build/devcpp/Build.dev b/polymer/build/devcpp/Build.dev index 6c9c7e729..4cd104380 100644 --- a/polymer/build/devcpp/Build.dev +++ b/polymer/build/devcpp/Build.dev @@ -6,13 +6,13 @@ Type=0 Ver=1 ObjFiles= Includes=..\include -Libs=C:\sdks\msc\dx7\include +Libs=C:\sdks\directx\dx7\include PrivateResource=Build_private.rc -ResourceIncludes=..\ +ResourceIncludes=..\;..\include MakeIncludes= -Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-funsigned-char_@@_ +Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-funsigned-char_@@_-fno-strict-aliasing_@@_ CppCompiler= -Linker=libeditor.a_@@_libengine.a_@@_-ldxguid_@@_-lws2_32_@@_ +Linker=libeditor.a_@@_libengine.a_@@_-ldxguid_@@_-lws2_32_@@_-lcomctl32_@@_ IsCpp=0 Icon= ExeOutput=..\devcpp @@ -48,17 +48,8 @@ ProductVersion= AutoIncBuildNr=0 [Unit1] -FileName=..\src\bstub.c -CompileCpp=0 -Folder=KenBuild Editor -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] FileName=..\src\misc\buildres.rc +CompileCpp=0 Folder=KenBuild Editor Compile=1 Link=0 @@ -66,3 +57,13 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit2] +FileName=..\testgame\bstub.c +Folder=KenBuild Editor +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= +CompileCpp=0 + diff --git a/polymer/build/devcpp/Game.dev b/polymer/build/devcpp/Game.dev index b4b498a11..003052106 100644 --- a/polymer/build/devcpp/Game.dev +++ b/polymer/build/devcpp/Game.dev @@ -5,14 +5,14 @@ UnitCount=5 Type=0 Ver=1 ObjFiles= -Includes=..\include;C:\sdks\fmodapi373win\api\inc -Libs=C:\sdks\msc\dx7\include;C:\sdks\fmodapi373win\api\lib +Includes=..\include;..\testgame;..\..\jfaud\inc +Libs=C:\sdks\directx\dx7\include;..\..\jfaud PrivateResource=Game_private.rc -ResourceIncludes=..\ +ResourceIncludes=..\;..\testgame MakeIncludes= -Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-funsigned-char_@@_ +Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-funsigned-char_@@_-fno-strict-aliasing_@@_ CppCompiler= -Linker=libeditor.a_@@_libengine.a_@@_-ldxguid_@@_-lws2_32_@@_-lfmod_@@_ +Linker=libeditor.a_@@_libengine.a_@@_-ldxguid_@@_-lws2_32_@@_-lsupc++_@@_-lcomctl32_@@_-ljfaud_@@_-lwinmm_@@_ IsCpp=0 Icon= ExeOutput=..\devcpp @@ -48,9 +48,9 @@ ProductVersion= AutoIncBuildNr=0 [Unit3] -FileName=..\src\sound.c +FileName=..\testgame\startwin.game.c CompileCpp=0 -Folder=KenBuild Editor +Folder=KenBuild Game Compile=1 Link=1 Priority=1000 @@ -58,13 +58,14 @@ OverrideBuildCmd=0 BuildCmd= [Unit4] -FileName=..\src\misc\gameres.rc +FileName=..\testgame\jfaud_sound.cpp Folder=KenBuild Game Compile=1 -Link=0 +Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= +CompileCpp=0 [Unit1] FileName=..\src\config.c @@ -76,18 +77,8 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= -[Unit2] -FileName=..\src\game.c -CompileCpp=0 -Folder=KenBuild Editor -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - [Unit5] -FileName=..\src\gamestartwin.c +FileName=..\testgame\game.c CompileCpp=0 Folder=KenBuild Game Compile=1 @@ -96,3 +87,22 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit6] +FileName=..\testgame\game.c +CompileCpp=0 +Folder=KenBuild Game +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=..\src\misc\gameres.rc +Folder=KenBuild Game +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/polymer/build/devcpp/engineinfo.c b/polymer/build/devcpp/engineinfo.c deleted file mode 100644 index 71cd27509..000000000 --- a/polymer/build/devcpp/engineinfo.c +++ /dev/null @@ -1,5 +0,0 @@ -const char _engine_cflags[] = "Dev-C++ made this"; -const char _engine_libs[] = "Dev-C++ made this"; -const char _engine_uname[] = "Dev-C++"; -const char _engine_compiler[] = "Dev-C++"; -const char _engine_date[] = __DATE__ " " __TIME__; diff --git a/polymer/build/devcpp/libEditor.dev b/polymer/build/devcpp/libEditor.dev index c297369be..09185d6b4 100644 --- a/polymer/build/devcpp/libEditor.dev +++ b/polymer/build/devcpp/libEditor.dev @@ -48,9 +48,9 @@ ProductVersion= AutoIncBuildNr=0 [Unit3] -FileName=..\src\buildstartwin.c +FileName=..\src\startwin.editor.c CompileCpp=0 -Folder=KenBuild Editor +Folder=Build Editor library Compile=1 Link=1 Priority=1000 diff --git a/polymer/build/devcpp/libEngine.dev b/polymer/build/devcpp/libEngine.dev index 2e9adace8..40a74b500 100644 --- a/polymer/build/devcpp/libEngine.dev +++ b/polymer/build/devcpp/libEngine.dev @@ -1,16 +1,16 @@ [Project] FileName=libEngine.dev Name=Build Engine library -UnitCount=15 +UnitCount=18 Type=2 Ver=1 ObjFiles= -Includes=..\include;..\src;C:\sdks\msc\dx7\include +Includes=..\include;..\src;C:\sdks\directx\dx7\include Libs= PrivateResource= ResourceIncludes= MakeIncludes= -Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-DKSFORBUILD_@@_-funsigned-char_@@_ +Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-DKSFORBUILD_@@_-funsigned-char_@@_-fno-strict-aliasing_@@_ CppCompiler= Linker= IsCpp=0 @@ -196,3 +196,33 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit16] +FileName=..\src\md4.c +CompileCpp=0 +Folder=Build Engine library +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit17] +FileName=..\src\lzf_d.c +CompileCpp=0 +Folder=Build Engine library +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit18] +FileName=..\src\lzf_c.c +CompileCpp=0 +Folder=Build Engine library +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/polymer/build/include/build.h b/polymer/build/include/build.h index 857bb0a59..c0ed07520 100644 --- a/polymer/build/include/build.h +++ b/polymer/build/include/build.h @@ -355,6 +355,7 @@ OTHER VARIABLES: you call the loadboard function. ***************************************************************************/ +int preinitengine(void); // a partial setup of the engine used for launch windows int initengine(void); void uninitengine(void); void initspritelists(void); diff --git a/polymer/build/include/scriptfile.h b/polymer/build/include/scriptfile.h index 01557f2f6..c27c46d2d 100644 --- a/polymer/build/include/scriptfile.h +++ b/polymer/build/include/scriptfile.h @@ -20,6 +20,7 @@ int scriptfile_getbraces(scriptfile *sf, char **braceend); scriptfile *scriptfile_fromfile(char *fn); scriptfile *scriptfile_fromstring(char *string); void scriptfile_close(scriptfile *sf); +int scriptfile_eof(scriptfile *sf); int scriptfile_getsymbolvalue(char *name, int *val); int scriptfile_addsymbolvalue(char *name, int val); diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index 38a162a0f..0d38726e2 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -5454,13 +5454,38 @@ static void sighandler(int sig, const siginfo_t *info, void *ctx) } #endif +// +// preinitengine +// +static int preinitcalled = 0; +int preinitengine(void) +{ + char *e; + if (initsystem()) exit(1); + + if ((e = Bgetenv("BUILD_NOP6")) != NULL) + if (!Bstrcasecmp(e, "TRUE")) { + Bprintf("Disabling P6 optimizations.\n"); + dommxoverlay = 0; + } + if (dommxoverlay) mmxoverlay(); + + validmodecnt = 0; + getvalidmodes(); + + initcrc32table(); + + preinitcalled = 1; + return 0; +} + + // // initengine // int initengine(void) { long i, j; - char *e; #if !defined _WIN32 && defined DEBUGGINGAIDS struct sigaction sigact, oldact; @@ -5469,16 +5494,11 @@ int initengine(void) sigact.sa_flags = SA_SIGINFO; sigaction(SIGFPE, &sigact, &oldact); #endif - - if (initsystem()) exit(1); - - if ((e = Bgetenv("BUILD_NOP6")) != NULL) - if (!Bstrcasecmp(e, "TRUE")) { - Bprintf("Disabling P6 optimizations.\n"); - dommxoverlay = 0; - } - if (dommxoverlay) mmxoverlay(); - + if (!preinitcalled) { + i = preinitengine(); + if (i) return i; + } + if (loadtables()) return 1; xyaspect = -1; @@ -5518,8 +5538,6 @@ int initengine(void) clearbuf(&show2dwall[0],(long)((MAXWALLS+3)>>5),0L); automapping = 0; - validmodecnt = 0; - pointhighlight = -1; linehighlight = -1; highlightcnt = 0; @@ -5531,14 +5549,11 @@ int initengine(void) captureformat = 0; loadpalette(); - getvalidmodes(); #if defined(POLYMOST) && defined(USE_OPENGL) if (!hicfirstinit) hicinit(); if (!mdinited) mdinit(); #endif - initcrc32table(); - return 0; } diff --git a/polymer/build/src/scriptfile.c b/polymer/build/src/scriptfile.c index deb6b1d03..4fbded1b9 100644 --- a/polymer/build/src/scriptfile.c +++ b/polymer/build/src/scriptfile.c @@ -321,6 +321,12 @@ void scriptfile_close(scriptfile *sf) free(sf); } +int scriptfile_eof(scriptfile *sf) +{ + skipoverws(sf); + if (sf->textptr >= sf->eof) return 1; + return 0; +} #define SYMBTABSTARTSIZE 256 static int symbtablength=0, symbtaballoclength=0; diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index 69e258d41..013539acc 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -106,7 +106,7 @@ EDITOROBJS=$(OBJ)astub.$o ifeq ($(PLATFORM),WINDOWS) OURCFLAGS+= -DUNDERSCORES -I$(DXROOT)/include NASMFLAGS+= -DUNDERSCORES -f win32 - GAMEOBJS+= $(OBJ)gameres.$o $(OBJ)winbits.$o $(OBJ)startwin.game.$o + GAMEOBJS+= $(OBJ)gameres.$o $(OBJ)winbits.$o $(OBJ)startwin.game.$o $(OBJ)startdlg.$o EDITOROBJS+= $(OBJ)buildres.$o endif @@ -121,7 +121,7 @@ ifeq ($(RENDERTYPE),SDL) ifeq (1,$(HAVE_GTK2)) OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0) - GAMEOBJS+= $(OBJ)game_banner.$o $(OBJ)startgtk.game.$o + GAMEOBJS+= $(OBJ)game_banner.$o $(OBJ)startgtk.game.$o $(OBJ)startdlg.$o EDITOROBJS+= $(OBJ)editor_banner.$o endif diff --git a/polymer/eduke32/Makefile.deps b/polymer/eduke32/Makefile.deps index dbfaf4126..f418cf433 100644 --- a/polymer/eduke32/Makefile.deps +++ b/polymer/eduke32/Makefile.deps @@ -27,9 +27,12 @@ $(OBJ)astub.$o: $(SRC)astub.c $(EINC)build.h $(EINC)pragmas.h $(EINC)compat.h $( $(OBJ)game_icon.$o: $(RSRC)game_icon.c $(OBJ)build_icon.$o: $(RSRC)build_icon.c +$(OBJ)startdlg.$o: $(SRC)startdlg.c $(EINC)compat.h $(EINC)baselayer.h $(EINC)scriptfile.h $(EINC)cache1d.h $(EINC)crc32.h $(INC)startdlg.h $(OBJ)gameres.$o: $(SRC)misc/gameres.rc $(SRC)startwin.game.h $(RSRC)game.bmp $(RSRC)game_icon.ico $(OBJ)buildres.$o: $(SRC)misc/buildres.rc $(EINC)startwin.editor.h $(RSRC)build.bmp $(RSRC)build_icon.ico -$(OBJ)startwin.game.$o: $(SRC)startwin.game.c $(duke3d_h) $(EINC)build.h $(EINC)winlayer.h $(EINC)compat.h +$(OBJ)startwin.game.$o: $(SRC)startwin.game.c $(duke3d_h) $(EINC)build.h $(EINC)winlayer.h $(EINC)compat.h $(INC)startdlg.h +$(OBJ)startgtk.game.$o: $(SRC)startgtk.game.c $(duke3d_h) $(EINC)dynamicgtk.h $(EINC)build.h $(EINC)baselayer.h $(EINC)compat.h + # jMACT objects $(OBJ)animlib.$o: $(SRC)jmact/animlib.c $(SRC)jmact/types.h $(INC)develop.h $(SRC)jmact/util_lib.h $(SRC)jmact/animlib.h $(EINC)compat.h diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index e5b3adaa3..ad92d2c69 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -127,7 +127,7 @@ void pitch_test( void ); char restorepalette,screencapt,nomorelogohack; int sendmessagecommand = -1; -static char *duke3dgrp = "duke3d.grp"; // JBF 20030925 +char *duke3dgrp = "duke3d.grp"; // JBF 20030925 static char *duke3ddef = "duke3d.def"; extern long lastvisinc; @@ -7763,7 +7763,6 @@ void checkcommandline(int argc,char **argv) if (((*c == '/') || (*c == '-')) && (!firstnet)) { if (!Bstrcasecmp(c+1,"setup")) { - CommandSetup = 1; i++; continue; } @@ -7927,23 +7926,12 @@ void checkcommandline(int argc,char **argv) continue; } - - if(*c == '?') - { - comlinehelp(argv); - exit(-1); - } - if((*c == '/') || (*c == '-')) { c++; switch(*c) { - default: - // printf("Unknown command line parameter '%s'\n",argv[i]); - case '?': - comlinehelp(argv); - exit(0); + default: break; case 'x': case 'X': c++; @@ -8525,7 +8513,7 @@ void Startup(void) compilecons(); - i = CONFIG_ReadSetup(); + // i = CONFIG_ReadSetup(); if (initengine()) { wm_msgbox("Build Engine Initialisation Error", @@ -8534,16 +8522,6 @@ void Startup(void) exit(1); } -#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) - if (i < 0 || (netparamcount == 0 && ForceSetup) || CommandSetup) { - if (quitevent | !startwin_run()) { - uninitengine(); - freeconmem(); - exit(0); - } - } -#endif - setupdynamictostatic(); if (ud.multimode > 1) sanitizegametype(); @@ -8814,8 +8792,6 @@ void backtomenu(void) int shareware = 0; -char *startwin_labeltext = "Starting EDuke32..."; - int load_script(char *szScript) { FILE* fp = fopenfrompath(szScript, "r"); @@ -8888,6 +8864,34 @@ void app_main(int argc,char **argv) duke3dgrp = getenv("DUKE3DGRP"); initprintf("Using `%s' as main GRP file\n", duke3dgrp); } + + for (i=1;inext = grpcache; + grpcache = fg; + + strncpy(fg->name, fname, BMAX_PATH); + fg->size = fsize; + fg->mtime = fmtime; + fg->crcval = fcrcval; + } + + scriptfile_close(script); + return 0; +} + +static void FreeGroupsCache(void) +{ + struct grpcache *fg; + + while (grpcache) { + fg = grpcache->next; + free(grpcache); + grpcache = fg; + } +} + +int ScanGroups(void) +{ + CACHE1D_FIND_REC *srch, *sidx; + struct grpcache *fg, *fgg; + struct grpfile *grp; + char *fn; + struct Bstat st; + + initprintf("Scanning for GRP files...\n"); + + LoadGroupsCache(); + + srch = klistpath("/", "*.grp", CACHE1D_FIND_FILE); + + for (sidx = srch; sidx; sidx = sidx->next) { + for (fg = grpcache; fg; fg = fg->next) { + if (!Bstrcmp(fg->name, sidx->name)) break; + } + + if (fg) { + if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename + if (Bstat(fn, &st)) { free(fn); continue; } // failed to stat the file + free(fn); + if (fg->size == st.st_size && fg->mtime == st.st_mtime) { + grp = (struct grpfile *)calloc(1, sizeof(struct grpfile)); + grp->name = strdup(sidx->name); + grp->crcval = fg->crcval; + grp->size = fg->size; + grp->next = foundgrps; + foundgrps = grp; + + fgg = (struct grpcache *)calloc(1, sizeof(struct grpcache)); + strcpy(fgg->name, fg->name); + fgg->size = fg->size; + fgg->mtime = fg->mtime; + fgg->crcval = fg->crcval; + fgg->next = usedgrpcache; + usedgrpcache = fgg; + continue; + } + } + + { + int b, fh; + int crcval; + char buf[16*512]; + + fh = openfrompath(sidx->name, BO_RDONLY|BO_BINARY, BS_IREAD); + if (fh < 0) continue; + if (fstat(fh, &st)) continue; + + initprintf(" Checksumming %s...", sidx->name); + crc32init((unsigned long *)&crcval); + do { + b = read(fh, buf, sizeof(buf)); + if (b > 0) crc32block((unsigned long *)&crcval, buf, b); + } while (b == sizeof(buf)); + crc32finish((unsigned long *)&crcval); + close(fh); + initprintf(" Done\n"); + + grp = (struct grpfile *)calloc(1, sizeof(struct grpfile)); + grp->name = strdup(sidx->name); + grp->crcval = crcval; + grp->size = st.st_size; + grp->next = foundgrps; + foundgrps = grp; + + fgg = (struct grpcache *)calloc(1, sizeof(struct grpcache)); + strncpy(fgg->name, sidx->name, BMAX_PATH); + fgg->size = st.st_size; + fgg->mtime = st.st_mtime; + fgg->crcval = crcval; + fgg->next = usedgrpcache; + usedgrpcache = fgg; + } + } + + klistfree(srch); + FreeGroupsCache(); + + if (usedgrpcache) { + FILE *fp; + fp = fopen(GRPCACHEFILE, "wt"); + if (fp) { + for (fg = usedgrpcache; fg; fg=fgg) { + fgg = fg->next; + fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval); + free(fg); + } + fclose(fp); + } + } + + return 0; +} + +void FreeGroups(void) +{ + struct grpfile *fg; + + while (foundgrps) { + fg = foundgrps->next; + free((char*)foundgrps->name); + free(foundgrps); + foundgrps = fg; + } +} + diff --git a/polymer/eduke32/source/startdlg.h b/polymer/eduke32/source/startdlg.h new file mode 100755 index 000000000..f15da2f08 --- /dev/null +++ b/polymer/eduke32/source/startdlg.h @@ -0,0 +1,12 @@ +// List of internally-known GRP files +#define numgrpfiles 6 +struct grpfile { + const char *name; + int crcval; + int size; + struct grpfile *next; +} grpfiles[numgrpfiles], *foundgrps; + +int ScanGroups(void); +void FreeGroups(void); + diff --git a/polymer/eduke32/source/startgtk.game.c b/polymer/eduke32/source/startgtk.game.c index 5f4bf241c..789017056 100755 --- a/polymer/eduke32/source/startgtk.game.c +++ b/polymer/eduke32/source/startgtk.game.c @@ -28,10 +28,10 @@ #define TAB_MESSAGES 1 static struct { - int fullscreen; - int xdim3d, ydim3d, bpp3d; - int forcesetup; - int usemouse, usejoy; + int fullscreen; + int xdim3d, ydim3d, bpp3d; + int forcesetup; + int usemouse, usejoy; } settings; extern int gtkenabled; @@ -53,104 +53,104 @@ static int retval = -1, mode = TAB_MESSAGES; static GdkPixbuf *load_banner(void) { - extern const GdkPixdata startbanner_pixdata; - return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); + extern const GdkPixdata startbanner_pixdata; + return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); } static void SetPage(int n) { - if (!gtkenabled || !startwin) return; - mode = n; - gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); + if (!gtkenabled || !startwin) return; + mode = n; + gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); - // each control in the config page vertical layout plus the start button should be made (in)sensitive - if (n == TAB_CONFIG) n = TRUE; else n = FALSE; - gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); - gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), - (GtkCallback)gtk_widget_set_sensitive, (gpointer)n); + // each control in the config page vertical layout plus the start button should be made (in)sensitive + if (n == TAB_CONFIG) n = TRUE; else n = FALSE; + gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); + gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), + (GtkCallback)gtk_widget_set_sensitive, (gpointer)n); } static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); static void PopulateForm(void) { - int mode3d, i; - GtkListStore *modes3d; - GtkTreeIter iter; - GtkComboBox *box3d; - char buf[64]; + int mode3d, i; + GtkListStore *modes3d; + GtkTreeIter iter; + GtkComboBox *box3d; + char buf[64]; - mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); - if (mode3d < 0) { - int i, cd[] = { 32, 24, 16, 15, 8, 0 }; - for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } - for ( ; cd[i]; i++) { - mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); - if (mode3d < 0) continue; - settings.bpp3d = cd[i]; - break; - } - } + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); + if (mode3d < 0) { + int i, cd[] = { 32, 24, 16, 15, 8, 0 }; + for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } + for ( ; cd[i]; i++) { + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); + if (mode3d < 0) continue; + settings.bpp3d = cd[i]; + break; + } + } - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup); - box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo")); - modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d)); - gtk_list_store_clear(modes3d); + box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo")); + modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d)); + gtk_list_store_clear(modes3d); - for (i=0; i aptr) - gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); + gtk_text_buffer_get_end_iter(textbuffer, &enditer); + for (aptr = bptr = str; *aptr != 0; ) { + switch (*bptr) { + case '\b': + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); #if GTK_CHECK_VERSION(2,6,0) - gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); + gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); #else - { - GtkTextIter iter2 = enditer; - gtk_text_iter_backward_cursor_position(&iter2); - //FIXME: this seems be deleting one too many chars somewhere! - if (!gtk_text_iter_equal(&iter2, &enditer)) - gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); - } + { + GtkTextIter iter2 = enditer; + gtk_text_iter_backward_cursor_position(&iter2); + //FIXME: this seems be deleting one too many chars somewhere! + if (!gtk_text_iter_equal(&iter2, &enditer)) + gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); + } #endif - aptr = ++bptr; - break; - case 0: - if (bptr > aptr) - gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); - aptr = bptr; - break; - case '\r': // FIXME - default: - bptr++; - break; - } - } + aptr = ++bptr; + break; + case 0: + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); + aptr = bptr; + break; + case '\r': // FIXME + default: + bptr++; + break; + } + } - mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); - gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); - gtk_text_buffer_delete_mark(textbuffer, mark); + mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); + gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); + gtk_text_buffer_delete_mark(textbuffer, mark); - return 0; + return 0; } int startwin_settitle(const char *title) { - if (!gtkenabled) return 0; - if (!startwin) return 1; - gtk_window_set_title (GTK_WINDOW (startwin), title); - return 0; + if (!gtkenabled) return 0; + if (!startwin) return 1; + gtk_window_set_title (GTK_WINDOW (startwin), title); + return 0; } int startwin_idle(void *s) { - if (!gtkenabled) return 0; - //if (!startwin) return 1; - gtk_main_iteration_do (FALSE); - return 0; + if (!gtkenabled) return 0; + //if (!startwin) return 1; + gtk_main_iteration_do (FALSE); + return 0; } -extern int xdimgame, ydimgame, bppgame, forcesetup; - int startwin_run(void) { - if (!gtkenabled) return 0; - if (!startwin) return 1; + if (!gtkenabled) return 0; + if (!startwin) return 1; - SetPage(TAB_CONFIG); + SetPage(TAB_CONFIG); - settings.fullscreen = ScreenMode; - settings.xdim3d = ScreenWidth; - settings.ydim3d = ScreenHeight; - settings.bpp3d = ScreenBPP; - settings.forcesetup = ForceSetup; - settings.usemouse = UseMouse; - settings.usejoy = UseJoystick; - PopulateForm(); - - gtk_main(); - - SetPage(TAB_MESSAGES); - if (retval) { - ScreenMode = settings.fullscreen; - ScreenWidth = settings.xdim3d; - ScreenHeight = settings.ydim3d; - ScreenBPP = settings.bpp3d; - ForceSetup = settings.forcesetup; - UseMouse = settings.usemouse; - UseJoystick = settings.usejoy; - } + settings.fullscreen = ScreenMode; + settings.xdim3d = ScreenWidth; + settings.ydim3d = ScreenHeight; + settings.bpp3d = ScreenBPP; + settings.forcesetup = ForceSetup; + settings.usemouse = UseMouse; + settings.usejoy = UseJoystick; + PopulateForm(); - return retval; + gtk_main(); + + SetPage(TAB_MESSAGES); + if (retval) { + ScreenMode = settings.fullscreen; + ScreenWidth = settings.xdim3d; + ScreenHeight = settings.ydim3d; + ScreenBPP = settings.bpp3d; + ForceSetup = settings.forcesetup; + UseMouse = settings.usemouse; + UseJoystick = settings.usejoy; + } + + return retval; } diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index dafeb0650..65e9616f8 100755 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -8,6 +8,8 @@ #include "winlayer.h" #include "compat.h" +#include "startdlg.h" + #define WIN32_LEAN_AND_MEAN #include #include @@ -18,56 +20,79 @@ #include "startwin.game.h" #define TAB_CONFIG 0 -#define TAB_MESSAGES 1 +#define TAB_GAME 1 +#define TAB_MESSAGES 2 static struct { int fullscreen; int xdim, ydim, bpp; int forcesetup; int usemouse, usejoy; + char selectedgrp[BMAX_PATH+1]; } settings; static HWND startupdlg = NULL; -static HWND pages[2] = { NULL, NULL}; +static HWND pages[3] = { NULL, NULL, NULL }; static int done = -1, mode = TAB_CONFIG; -static void PopulateForm(void) +static void PopulateForm(int pgs) { - int i,j; - char buf[64]; - int mode; HWND hwnd; + if (pgs & (1<= settings.bpp) i++; else break; } - for ( ; cd[i]; i++) { - mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1); - if (mode < 0) continue; - settings.bpp = cd[i]; - break; + mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1); + if (mode < 0) { + int cd[] = { 32, 24, 16, 15, 8, 0 }; + for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp) i++; else break; } + for ( ; cd[i]; i++) { + mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1); + if (mode < 0) continue; + settings.bpp = cd[i]; + break; + } + } + + Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED)); + Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); + + ComboBox_ResetContent(hwnd); + for (i=0; inext) { + for (i = 0; icrcval == grpfiles[i].crcval) break; + if (i == numgrpfiles) continue; // unrecognised grp file + + Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name); + j = ListBox_AddString(hwnd, buf); + ListBox_SetItemData(hwnd, j, (LPARAM)fg); + if (!Bstrcasecmp(fg->name, settings.selectedgrp)) ListBox_SetCurSel(hwnd, j); } } - - Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED)); - Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); - - ComboBox_ResetContent(hwnd); - for (i=0; iname); + return TRUE; + } + default: break; + } + break; + default: break; + } + return FALSE; +} + static void SetPage(int n) @@ -132,6 +177,8 @@ static void EnableConfig(int n) EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), n); EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), n); + + EnableWindow(GetDlgItem(pages[TAB_GAME], IDGDATA), n); } static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -208,10 +255,13 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, ZeroMemory(&tab, sizeof(tab)); tab.mask = TCIF_TEXT; tab.pszText = TEXT("Configuration"); - SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab); + SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); + tab.mask = TCIF_TEXT; + tab.pszText = TEXT("Game"); + SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab); tab.mask = TCIF_TEXT; tab.pszText = TEXT("Messages"); - SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab); + SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); // Work out the position and size of the area inside the tab control for the pages ZeroMemory(&r, sizeof(r)); @@ -225,8 +275,11 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, // Create the pages and position them in the tab control, but hide them pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); + pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(), + MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc); 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_GAME], 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 @@ -235,7 +288,14 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, r.left = r.top = 0; SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); + // Set a tab stop in the game data listbox + { + DWORD tabs[1] = { 150 }; + ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs); + } + SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START)); + SetWindowText(hwndDlg, apptitle); } return FALSE; } @@ -261,8 +321,8 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, } case WM_CLOSE: - if (mode == TAB_CONFIG) done = 0; - else quitevent++; + if (mode == TAB_CONFIG) done = 0; + else quitevent++; return TRUE; case WM_DESTROY: @@ -271,6 +331,11 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, hbmp = NULL; } + if (pages[TAB_GAME]) { + DestroyWindow(pages[TAB_GAME]); + pages[TAB_GAME] = NULL; + } + if (pages[TAB_CONFIG]) { DestroyWindow(pages[TAB_CONFIG]); pages[TAB_CONFIG] = NULL; @@ -281,10 +346,10 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, case WM_COMMAND: switch (LOWORD(wParam)) { - case WIN_STARTWIN_CANCEL: - if (mode == TAB_CONFIG) done = 0; - else quitevent++; - return TRUE; + case WIN_STARTWIN_CANCEL: + if (mode == TAB_CONFIG) done = 0; + else quitevent++; + return TRUE; case WIN_STARTWIN_START: done = 1; return TRUE; } return FALSE; @@ -390,6 +455,8 @@ int startwin_idle(void *v) return 0; } +extern char *duke3dgrp; + int startwin_run(void) { MSG msg; @@ -397,6 +464,8 @@ int startwin_run(void) done = -1; + ScanGroups(); + SetPage(TAB_CONFIG); EnableConfig(1); @@ -407,7 +476,8 @@ int startwin_run(void) settings.forcesetup = ForceSetup; settings.usemouse = UseMouse; settings.usejoy = UseJoystick; - PopulateForm(); + strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH); + PopulateForm(-1); while (done < 0) { switch (GetMessage(&msg, NULL, 0,0)) { @@ -431,6 +501,7 @@ int startwin_run(void) ForceSetup = settings.forcesetup; UseMouse = settings.usemouse; UseJoystick = settings.usejoy; + duke3dgrp = settings.selectedgrp; } return done; diff --git a/polymer/eduke32/source/startwin.game.h b/polymer/eduke32/source/startwin.game.h index 446a9b087..fd2cacc6c 100755 --- a/polymer/eduke32/source/startwin.game.h +++ b/polymer/eduke32/source/startwin.game.h @@ -1,6 +1,7 @@ // resource ids #define WIN_STARTWIN 1000 #define WIN_STARTWINPAGE_CONFIG 2000 +#define WIN_STARTWINPAGE_GAME 3000 #define WIN_STARTWIN_BITMAP 100 // banner bitmap #define WIN_STARTWIN_TABCTL 101 #define WIN_STARTWIN_CANCEL IDCANCEL @@ -21,3 +22,6 @@ #define IDCINPUTJOY 106 #define IDCALWAYSSHOW 107 +// game page +#define IDGDATA 100 +