Skip to content

Commit 354852f

Browse files
committed
one startup window to rule them all
Every platform different, but all the common pieces live inside the engine. All is detailed in include/startwin.h and demonstrated in kenbuild/src/game.c. Game data importing is a common feature now with versatility covering all four of the JF-ports. Windows: The app name, version, and website URL are read from the VERSIONINFO resource defined src/xxxxres.rc, which #include's the common dialog templates etc from include/startwin_win.rc. Gtk+: The app name is in rsrc/xxx_startwin_gtk_appname.txt, the website URL is markup in rsrc/startwin_gtk_website.txt, the version is in rsrc/startwin_gtk_version.txt Mac: The website is in rsrc/Credits.rtf which is automatically recognised by the standard about dialog. The app name comes from Info.plist.
1 parent e06cbd0 commit 354852f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+5296
-4280
lines changed

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ ENGINEOBJS= \
8383
$(SRC)/osd.$o \
8484
$(SRC)/pragmas.$o \
8585
$(SRC)/scriptfile.$o \
86+
$(SRC)/startwin.$o \
8687
$(SRC)/textfont.$o \
8788
$(SRC)/talltextfont.$o \
8889
$(SRC)/smalltextfont.$o
@@ -152,15 +153,15 @@ ifeq ($(RENDERTYPE),SDL)
152153
ifeq (1,$(HAVE_GTK))
153154
OURCFLAGS+= $(GTKCONFIG_CFLAGS)
154155
OURLDFLAGS+= $(GTKCONFIG_LIBS)
155-
ENGINEOBJS+= $(SRC)/gtkbits.$o
156-
EDITOROBJS+= $(SRC)/startgtk_editor.$o
157-
else
158-
ENGINEOBJS+= $(SRC)/startwin_stub.$o
156+
ENGINEOBJS+= \
157+
$(SRC)/gtkbits.$o \
158+
$(SRC)/startwin_gtk.$o
159159
endif
160160
endif
161161
ifeq ($(RENDERTYPE),WIN)
162-
ENGINEOBJS+= $(SRC)/winlayer.$o
163-
EDITOROBJS+= $(SRC)/startwin_editor.$o
162+
ENGINEOBJS+= \
163+
$(SRC)/winlayer.$o \
164+
$(SRC)/startwin_win.$o
164165
endif
165166

166167
# TARGETS

Makefile.deps

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$(SRC)/a-c.$o: $(SRC)/a-c.c $(INC)/compat.h $(SRC)/a.h
44
$(SRC)/a.$o: $(SRC)/a.$(asm)
55
$(SRC)/asmprot.$o: $(SRC)/asmprot.c $(SRC)/a.h
6-
$(SRC)/baselayer.$o: $(SRC)/baselayer.c $(INC)/build.h $(INC)/compat.h $(INC)/osd.h $(INC)/baselayer.h $(SRC)/baselayer_priv.h $(INC)/glbuild.h
6+
$(SRC)/baselayer.$o: $(SRC)/baselayer.c $(INC)/build.h $(INC)/compat.h $(INC)/osd.h $(INC)/baselayer.h $(SRC)/baselayer_priv.h $(SRC)/startwin_priv.h $(INC)/glbuild.h
77
$(SRC)/build.$o: $(SRC)/build.c $(INC)/build.h $(SRC)/engine_priv.h $(INC)/compat.h $(INC)/pragmas.h $(INC)/osd.h $(INC)/cache1d.h $(INC)/editor.h $(INC)/baselayer.h
88
$(SRC)/cache1d.$o: $(SRC)/cache1d.c $(INC)/build.h $(INC)/compat.h $(INC)/cache1d.h $(INC)/pragmas.h $(SRC)/kplib.h
99
$(SRC)/compat.$o: $(SRC)/compat.c $(INC)/compat.h
@@ -26,13 +26,16 @@ $(SRC)/polymosttex.$o: $(SRC)/polymosttex.c $(INC)/build.h $(INC)/compat.h $(INC
2626
$(SRC)/pragmas.$o: $(SRC)/pragmas.c $(INC)/compat.h
2727
$(SRC)/rg_etc1.$o: $(SRC)/rg_etc1.cpp $(SRC)/rg_etc1.h
2828
$(SRC)/scriptfile.$o: $(SRC)/scriptfile.c $(INC)/build.h $(INC)/compat.h $(INC)/scriptfile.h $(INC)/cache1d.h
29-
$(SRC)/sdlayer2.$o: $(SRC)/sdlayer2.c $(INC)/build.h $(INC)/compat.h $(INC)/sdlayer.h $(INC)/baselayer.h $(SRC)/baselayer_priv.h $(INC)/cache1d.h $(INC)/pragmas.h $(SRC)/a.h $(INC)/osd.h $(SRC)/glbuild_priv.h $(INC)/glbuild.h $(SRC)/glext.h $(SRC)/gtkbits.h
29+
$(SRC)/sdlayer2.$o: $(SRC)/sdlayer2.c $(INC)/build.h $(INC)/compat.h $(INC)/sdlayer.h $(INC)/baselayer.h $(SRC)/baselayer_priv.h $(INC)/cache1d.h $(INC)/pragmas.h $(SRC)/a.h $(INC)/osd.h $(SRC)/glbuild_priv.h $(INC)/startwin.h $(SRC)/startwin_priv.h $(INC)/glbuild.h $(SRC)/glext.h $(SRC)/gtkbits.h
3030
$(SRC)/smalltextfont.$o: $(SRC)/smalltextfont.c
31+
$(SRC)/startwin.$o: $(SRC)/startwin.c $(INC)/startwin.h $(SRC)/startwin_priv.h $(INC)/compat.h $(INC)/cache1d.h $(INC)/crc32.h $(INC)/scriptfile.h
32+
$(SRC)/startwin_gtk.$o: $(SRC)/startwin_gtk.c $(INC)/startwin.h $(SRC)/startwin_priv.h $(INC)/build.h $(INC)/baselayer.h
33+
$(SRC)/startwin_win.$o: $(SRC)/startwin_win.c $(INC)/startwin.h $(SRC)/startwin_priv.h $(INC)/startwin_win.h $(INC)/build.h $(INC)/winlayer.h
3134
$(SRC)/talltextfont.$o: $(SRC)/talltextfont.c
3235
$(SRC)/textfont.$o: $(SRC)/textfont.c
3336
$(SRC)/version-auto.$o: $(SRC)/version-auto.c
3437
$(SRC)/version.$o: $(SRC)/version.c
35-
$(SRC)/winlayer.$o: $(SRC)/winlayer.c $(INC)/compat.h $(INC)/winlayer.h $(INC)/baselayer.h $(SRC)/baselayer_priv.h $(INC)/pragmas.h $(INC)/build.h $(SRC)/a.h $(INC)/osd.h $(SRC)/glbuild_priv.h $(INC)/glbuild.h
38+
$(SRC)/winlayer.$o: $(SRC)/winlayer.c $(INC)/compat.h $(INC)/winlayer.h $(INC)/baselayer.h $(SRC)/baselayer_priv.h $(INC)/pragmas.h $(INC)/build.h $(SRC)/a.h $(INC)/osd.h $(SRC)/glbuild_priv.h $(INC)/glbuild.h $(INC)/startwin.h $(SRC)/startwin_priv.h
3639

3740
$(LIBSQUISH)/alpha.$o: $(LIBSQUISH)/alpha.cpp $(LIBSQUISH)/alpha.h $(LIBSQUISH)/squish.h
3841
$(LIBSQUISH)/clusterfit.$o: $(LIBSQUISH)/clusterfit.cpp $(LIBSQUISH)/clusterfit.h $(LIBSQUISH)/squish.h $(LIBSQUISH)/maths.h $(LIBSQUISH)/config.h $(LIBSQUISH)/simd.h $(LIBSQUISH)/simd_float.h $(LIBSQUISH)/colourfit.h $(LIBSQUISH)/colourset.h $(LIBSQUISH)/colourblock.h
@@ -44,10 +47,6 @@ $(LIBSQUISH)/rangefit.$o: $(LIBSQUISH)/rangefit.cpp $(LIBSQUISH)/rangefit.h $(LI
4447
$(LIBSQUISH)/singlecolourfit.$o: $(LIBSQUISH)/singlecolourfit.cpp $(LIBSQUISH)/singlecolourfit.h $(LIBSQUISH)/squish.h $(LIBSQUISH)/colourfit.h $(LIBSQUISH)/maths.h $(LIBSQUISH)/config.h $(LIBSQUISH)/colourset.h $(LIBSQUISH)/colourblock.h $(LIBSQUISH)/singlecolourlookup.inl
4548
$(LIBSQUISH)/squish.$o: $(LIBSQUISH)/squish.cpp $(LIBSQUISH)/squish.h $(LIBSQUISH)/colourset.h $(LIBSQUISH)/maths.h $(LIBSQUISH)/config.h $(LIBSQUISH)/rangefit.h $(LIBSQUISH)/colourfit.h $(LIBSQUISH)/clusterfit.h $(LIBSQUISH)/simd.h $(LIBSQUISH)/simd_float.h $(LIBSQUISH)/colourblock.h $(LIBSQUISH)/alpha.h $(LIBSQUISH)/singlecolourfit.h
4649

47-
$(SRC)/startgtk_editor.$o: $(SRC)/startgtk_editor.c $(INC)/compat.h $(INC)/baselayer.h $(INC)/build.h $(INC)/compat.h $(INC)/editor.h
48-
$(SRC)/startwin_editor.$o: $(SRC)/startwin_editor.c $(INC)/build.h $(INC)/editor.h $(INC)/winlayer.h $(INC)/compat.h $(INC)/buildres.h
49-
$(SRC)/startwin_stub.$o: $(SRC)/startwin_stub.c
50-
5150
# Derived source files from shader files
5251
$(SRC)/glbuild_fs.c: $(SRC)/glbuild_fs.glsl
5352
$(SRC)/glbuild_fs.$o: $(SRC)/glbuild_fs.c

Makefile.msvc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ ENGINEOBJS=$(SRC)\a-c.$o \
7474
$(SRC)\osd.$o \
7575
$(SRC)\pragmas.$o \
7676
$(SRC)\scriptfile.$o \
77+
$(SRC)\startwin.$o \
78+
$(SRC)\startwin_win.$o \
7779
$(SRC)\textfont.$o \
7880
$(SRC)\talltextfont.$o \
7981
$(SRC)\smalltextfont.$o \
@@ -118,7 +120,6 @@ ENGINEOBJS=$(ENGINEOBJS) \
118120
!endif
119121

120122
EDITOROBJS=$(SRC)\build.$o \
121-
$(SRC)\startwin_editor.$o \
122123
$(SRC)\config.$o
123124

124125
# Source-control version stamping

Makefile.msvcshared

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ EXESUFFIX=.exe
99
BUILDCFLAGS=
1010
BUILDCXXFLAGS=
1111
BUILDCPPFLAGS=/DRENDERTYPEWIN=1
12-
BUILDLIBS=user32.lib gdi32.lib shell32.lib ws2_32.lib comctl32.lib comdlg32.lib uxtheme.lib xinput9_1_0.lib
12+
BUILDLIBS=user32.lib gdi32.lib shell32.lib ws2_32.lib comctl32.lib comdlg32.lib uxtheme.lib version.lib xinput9_1_0.lib
1313
BUILDRFLAGS=
1414

1515
!if "$(PLATFORM)" == "X64" || "$(PLATFORM)" == "x64"

Makefile.shared

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ endif
6969
ifeq ($(PLATFORM),WINDOWS)
7070
RENDERTYPE ?= WIN
7171
EXESUFFIX=.exe
72-
BUILDLDFLAGS+= -lmingwex -lwinmm -lws2_32 -lcomctl32 -lcomdlg32 -luxtheme -lxinput9_1_0
72+
BUILDLDFLAGS+= -lmingwex -lwinmm -lws2_32 -lcomctl32 -lcomdlg32 -luxtheme -lversion -lxinput9_1_0
7373
else
7474
RENDERTYPE=SDL
7575
EXESUFFIX=

include/baselayer.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,8 @@ extern const char **_buildargv;
1414

1515
extern char quitevent, appactive;
1616

17-
enum {
18-
STARTWIN_CANCEL = 0,
19-
STARTWIN_RUN = 1,
20-
};
21-
struct startwin_settings;
22-
2317
// NOTE: these are implemented in game-land so they may be overridden in game specific ways
2418
extern int app_main(int argc, char const * const argv[]);
25-
extern int startwin_open(void);
26-
extern int startwin_close(void);
27-
extern int startwin_puts(const char *);
28-
extern int startwin_settitle(const char *);
29-
extern int startwin_idle(void *);
30-
extern int startwin_run(struct startwin_settings *);
3119

3220
// video
3321
extern int xres, yres, bpp, fullscreen, bytesperline, imageSize;
@@ -129,7 +117,6 @@ int wm_ynbox(const char *name, const char *fmt, ...) PRINTF_FORMAT(2, 3);
129117
// Returns -1 if not supported, 0 if cancelled, 1 if accepted
130118
int wm_filechooser(const char *initialdir, const char *initialfile, const char *type, int foropen, char **choice);
131119

132-
int wm_idle(void *);
133120
void wm_allowbackgroundidle(int onf);
134121
void wm_allowtaskswitching(int onf);
135122
void wm_setapptitle(const char *name);

include/buildres.h

Lines changed: 0 additions & 30 deletions
This file was deleted.

include/cache1d.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ enum {
4444
CACHE1D_FIND_DRIVE = 4,
4545

4646
CACHE1D_OPT_NOSTACK = 0x100,
47+
CACHE1D_OPT_NOZIP = 0x200,
48+
CACHE1D_OPT_NOGRP = 0x400,
4749

4850
// the lower the number, the higher the priority
4951
CACHE1D_SOURCE_DRIVE = 0,
@@ -55,10 +57,15 @@ enum {
5557
typedef struct _CACHE1D_FIND_REC {
5658
char *name;
5759
int type, source;
58-
struct _CACHE1D_FIND_REC *next, *prev, *usera, *userb;
60+
void *user;
61+
struct _CACHE1D_FIND_REC *next, *prev;
5962
} CACHE1D_FIND_REC;
63+
64+
// 'mask' is a null-pointer terminated list of patterns.
65+
// 'usersize' allocates extra memory pointed to by the user member of each record.
66+
CACHE1D_FIND_REC *klistpath(const char *path, const char **masks, int type, unsigned usersize);
67+
#define KLISTPATH_MASK(m) (const char *[]){m,NULL}
6068
void klistfree(CACHE1D_FIND_REC *rec);
61-
CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int type);
6269

6370
unsigned kdfread(void *buffer, unsigned dasizeof, unsigned count, int fil);
6471
unsigned dfread(void *buffer, unsigned dasizeof, unsigned count, BFILE *fil);

include/editor.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ extern int buildkeys[NUMBUILDKEYS];
3131

3232
extern int ydim16, halfxdim16, midydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d, forcesetup;
3333

34-
struct startwin_settings {
35-
int fullscreen;
36-
int xdim2d, ydim2d;
37-
int xdim3d, ydim3d, bpp3d;
38-
int forcesetup;
39-
};
40-
4134
extern int ExtInit(void);
4235
extern void ExtUnInit(void);
4336
extern void ExtPreCheckKeys(void);

include/startwin.h

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// Common Start-up Window
2+
// for the Build Engine
3+
4+
// This file has been modified from Ken Silverman's original release
5+
// by Jonathon Fowler ([email protected])
6+
7+
#ifndef __startwin_h__
8+
#define __startwin_h__
9+
10+
struct startwin_settings {
11+
struct {
12+
// Enable 3D mode options.
13+
unsigned video:1;
14+
15+
// Enable 2D mode options.
16+
unsigned editor:1;
17+
18+
// Enable sound quality options.
19+
unsigned audio:1;
20+
21+
// Enable mouse and controller options.
22+
unsigned input:1;
23+
24+
// Enable multiplayer options.
25+
unsigned network:1;
26+
27+
// Enable game data management.
28+
unsigned game:1;
29+
} features;
30+
31+
struct {
32+
int fullscreen;
33+
int display;
34+
int xdim;
35+
int ydim;
36+
int bpp;
37+
} video;
38+
39+
struct {
40+
int xdim;
41+
int ydim;
42+
} editor;
43+
44+
struct {
45+
int samplerate;
46+
int channels;
47+
int bitspersample;
48+
} audio;
49+
50+
struct {
51+
int mouse;
52+
int controller;
53+
} input;
54+
55+
struct {
56+
int numplayers;
57+
char *joinhost;
58+
int netoverride;
59+
} network;
60+
61+
struct {
62+
// Dataset identifier of the selected game dataset.
63+
int gamedataid;
64+
65+
// A null-pointer-terminated list of wildcards encompassing all the filespec files.
66+
const char **gamedatafilepatterns;
67+
68+
// Specifications of game data sets.
69+
const struct startwin_dataset *gamedata;
70+
71+
// URL where freely-distributable game data files can be downloaded, or NULL.
72+
const char *demourl;
73+
74+
// Advisory text indicating where full-version data can be obtained.
75+
const char *moreinfobrief;
76+
const char *moreinfodetail;
77+
} game;
78+
79+
int alwaysshow;
80+
};
81+
82+
enum {
83+
STARTWIN_CANCEL = 0,
84+
STARTWIN_RUN = 1,
85+
};
86+
87+
enum {
88+
STARTWIN_DATASET_UNIDENTIFIED = 0,
89+
STARTWIN_DATASET_EXTRA0 = 0x10000, // The first ID of extra GRP files being returned as extra datasets.
90+
};
91+
92+
enum {
93+
STARTWIN_PRESENCE_OPTIONAL = 0, // The file is optional.
94+
STARTWIN_PRESENCE_REQUIRED = 1, // The file is required for a dataset to be complete.
95+
STARTWIN_PRESENCE_GROUP = 2, // The file is a required GRP file for passing to cache1d.
96+
STARTWIN_PRESENCE_EXCEPT = 3, // The file cannot exist for a dataset to be complete.
97+
};
98+
99+
// Dataset specification ------------------------
100+
struct startwin_dataset {
101+
const char *name; // Human name.
102+
int id; // Dataset identifier.
103+
int type; // Dataset type, meaning defined by the game, or STARTWIN_DATASET_UNIDENTIFIED.
104+
const struct startwin_datasetfilespec *filespec; // Terminate with a NULL 'file'.
105+
};
106+
107+
struct startwin_datasetfilespec {
108+
const char *name; // If presence is OPTIONAL or EXCEPT, can be a wildcard. Otherwise the size and crc members are necessary.
109+
const char *storename; // An alternative unique filename for importing into where 'name' would conflict with other datasets.
110+
size_t size;
111+
unsigned crc;
112+
unsigned presence:2; // See STARTWIN_PRESENCE_xxx values. Must be OPTIONAL if 'alternate' is 1.
113+
unsigned alternate:1; // If 1 this entry is an alternate version of a non-alternate entry following it (with a 0 here).
114+
};
115+
116+
extern struct startwin_settings startwin_settings; // Declared in the game and populated according to needs.
117+
118+
// Dataset discovery ----------------------------
119+
struct startwin_datasetfoundfile {
120+
const struct startwin_datasetfilespec *filespec; // The dataset filespec the file matches to.
121+
const char *name; // The filename as it exists on-disk.
122+
};
123+
struct startwin_datasetfound {
124+
struct startwin_datasetfound *next;
125+
const struct startwin_dataset *dataset;
126+
unsigned complete:1;
127+
int numfiles; // Count of items in the files member.
128+
struct startwin_datasetfoundfile files[]; // All the presence-required files that were matched.
129+
};
130+
131+
int startwin_run(void);
132+
133+
const struct startwin_datasetfound * startwin_scan_gamedata(void);
134+
void startwin_free_gamedata(void);
135+
136+
const struct startwin_datasetfound * startwin_find_id(int id);
137+
const struct startwin_datasetfound * startwin_find_type(int type);
138+
const struct startwin_datasetfound * startwin_find_filename(const char *filename);
139+
const struct startwin_datasetfoundfile * startwin_find_id_group(int id);
140+
const struct startwin_datasetfoundfile * startwin_find_type_group(int type);
141+
const struct startwin_datasetfoundfile * startwin_find_dataset_group(const struct startwin_datasetfound *dataset);
142+
143+
#endif // __startwin_h__

0 commit comments

Comments
 (0)