KenBuild: Astyle and Uncrustify all source.

git-svn-id: https://svn.eduke32.com/eduke32@5327 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-08-15 21:27:27 +00:00
parent 8fb903a83a
commit 8f82bc5239
9 changed files with 6777 additions and 6592 deletions

View file

@ -4,7 +4,8 @@
#include "baselayer.h" #include "baselayer.h"
#include "build.h" #include "build.h"
static struct { static struct
{
int fullscreen; int fullscreen;
int xdim3d, ydim3d, bpp3d; int xdim3d, ydim3d, bpp3d;
int forcesetup; int forcesetup;
@ -53,13 +54,17 @@ static struct {
int idx3d = -1; int idx3d = -1;
int xdim, ydim, bpp; int xdim, ydim, bpp;
if (firstTime) { if (firstTime)
{
xdim = settings.xdim3d; xdim = settings.xdim3d;
ydim = settings.ydim3d; ydim = settings.ydim3d;
bpp = settings.bpp3d; bpp = settings.bpp3d;
} else { }
else
{
mode3d = [[modeslist3d objectAtIndex:[videoMode3DPUButton indexOfSelectedItem]] intValue]; mode3d = [[modeslist3d objectAtIndex:[videoMode3DPUButton indexOfSelectedItem]] intValue];
if (mode3d >= 0) { if (mode3d >= 0)
{
xdim = validmode[mode3d].xdim; xdim = validmode[mode3d].xdim;
ydim = validmode[mode3d].ydim; ydim = validmode[mode3d].ydim;
bpp = validmode[mode3d].bpp; bpp = validmode[mode3d].bpp;
@ -67,10 +72,12 @@ static struct {
} }
mode3d = checkvideomode(&xdim, &ydim, bpp, fullscreen, 1); mode3d = checkvideomode(&xdim, &ydim, bpp, fullscreen, 1);
if (mode3d < 0) { if (mode3d < 0)
{
int i, cd[] = { 32, 24, 16, 15, 8, 0 }; int i, cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i]; ) { if (cd[i] >= bpp) i++; else break; } for (i=0; cd[i]; ) { if (cd[i] >= bpp) i++; else break; }
for ( ; cd[i]; i++) { for (; cd[i]; i++)
{
mode3d = checkvideomode(&xdim, &ydim, cd[i], fullscreen, 1); mode3d = checkvideomode(&xdim, &ydim, cd[i], fullscreen, 1);
if (mode3d < 0) continue; if (mode3d < 0) continue;
break; break;
@ -82,12 +89,14 @@ static struct {
modeslist3d = [[NSMutableArray alloc] init]; modeslist3d = [[NSMutableArray alloc] init];
for (i = 0; i < validmodecnt; i++) { for (i = 0; i < validmodecnt; i++)
if (fullscreen == validmode[i].fs) { {
if (fullscreen == validmode[i].fs)
{
if (i == mode3d) idx3d = [modeslist3d count]; if (i == mode3d) idx3d = [modeslist3d count];
[modeslist3d addObject:[NSNumber numberWithInt:i]]; [modeslist3d addObject:[NSNumber numberWithInt:i]];
[videoMode3DPUButton addItemWithTitle:[NSString stringWithFormat:@"%d %C %d %d-bpp", [videoMode3DPUButton addItemWithTitle:[NSString stringWithFormat:@"%d %C %d %d-bpp",
validmode[i].xdim, 0xd7, validmode[i].ydim, validmode[i].bpp]]; validmode[i].xdim, 0xd7, validmode[i].ydim, validmode[i].bpp]];
} }
} }
@ -111,7 +120,8 @@ static struct {
- (IBAction)start:(id)sender - (IBAction)start:(id)sender
{ {
int mode = [[modeslist3d objectAtIndex:[videoMode3DPUButton indexOfSelectedItem]] intValue]; int mode = [[modeslist3d objectAtIndex:[videoMode3DPUButton indexOfSelectedItem]] intValue];
if (mode >= 0) { if (mode >= 0)
{
settings.xdim3d = validmode[mode].xdim; settings.xdim3d = validmode[mode].xdim;
settings.ydim3d = validmode[mode].ydim; settings.ydim3d = validmode[mode].ydim;
settings.bpp3d = validmode[mode].bpp; settings.bpp3d = validmode[mode].bpp;
@ -151,7 +161,8 @@ static struct {
// user can enable it if they want to while waiting for something else to happen // user can enable it if they want to while waiting for something else to happen
NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator]; NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator];
NSControl *control; NSControl *control;
while (control = [enumerator nextObject]) { while (control = [enumerator nextObject])
{
if (control == alwaysShowButton) continue; if (control == alwaysShowButton) continue;
[control setEnabled:false]; [control setEnabled:false];
} }
@ -175,7 +186,8 @@ static struct {
[messagesView replaceCharactersInRange:end withString:str]; [messagesView replaceCharactersInRange:end withString:str];
[text endEditing]; [text endEditing];
if (shouldAutoScroll) { if (shouldAutoScroll)
{
end.location = [text length]; end.location = [text length];
end.length = 0; end.length = 0;
[messagesView scrollRangeToVisible:end]; [messagesView scrollRangeToVisible:end];
@ -265,15 +277,17 @@ int startwin_run(void)
[startwin setupRunMode]; [startwin setupRunMode];
switch ([NSApp runModalForWindow:[startwin window]]) { switch ([NSApp runModalForWindow:[startwin window]])
case NSRunStoppedResponse: retval = 1; break; {
case NSRunAbortedResponse: retval = 0; break; case NSRunStoppedResponse: retval = 1; break;
default: retval = -1; case NSRunAbortedResponse: retval = 0; break;
default: retval = -1;
} }
[startwin setupMessagesMode]; [startwin setupMessagesMode];
if (retval) { if (retval)
{
fullscreen = settings.fullscreen; fullscreen = settings.fullscreen;
xdimgame = settings.xdim3d; xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d; ydimgame = settings.ydim3d;

File diff suppressed because it is too large Load diff

View file

@ -1,51 +1,52 @@
#include "compat.h" #include "compat.h"
#include "build.h" #include "build.h"
#include "names.h" #include "names.h"
#include "common_game.h" #include "common_game.h"
static const char *defaultgrpfilename = "stuff.dat"; static const char *defaultgrpfilename = "stuff.dat";
static const char *defaultdeffilename = "kenbuild.def"; static const char *defaultdeffilename = "kenbuild.def";
const char *G_DefaultGrpFile(void) const char *G_DefaultGrpFile(void)
{ {
return defaultgrpfilename; return defaultgrpfilename;
} }
const char *G_GrpFile(void) const char *G_GrpFile(void)
{ {
return defaultgrpfilename; return defaultgrpfilename;
} }
const char *G_DefaultDefFile(void) const char *G_DefaultDefFile(void)
{ {
return defaultdeffilename; return defaultdeffilename;
} }
const char *G_DefFile(void) const char *G_DefFile(void)
{ {
return defaultdeffilename; return defaultdeffilename;
} }
uint8_t *basepaltable[1] = { uint8_t *basepaltable[1] =
palette {
}; palette
};
uint32_t PaletteIndexFullbrights[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
uint32_t PaletteIndexFullbrights[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
void Ken_InitMultiPsky(void)
{ void Ken_InitMultiPsky(void)
// default {
psky * const defaultsky = E_DefinePsky(DEFAULTPSKY); // default
defaultsky->lognumtiles = 1; psky *const defaultsky = E_DefinePsky(DEFAULTPSKY);
defaultsky->horizfrac = 65536; defaultsky->lognumtiles = 1;
defaultsky->horizfrac = 65536;
// DAYSKY
psky * const daysky = E_DefinePsky(DAYSKY); // DAYSKY
daysky->lognumtiles = 1; psky *const daysky = E_DefinePsky(DAYSKY);
daysky->horizfrac = 65536; daysky->lognumtiles = 1;
daysky->horizfrac = 65536;
// NIGHTSKY
psky * const nightsky = E_DefinePsky(NIGHTSKY); // NIGHTSKY
nightsky->lognumtiles = 3; psky *const nightsky = E_DefinePsky(NIGHTSKY);
nightsky->horizfrac = 65536; nightsky->lognumtiles = 3;
} nightsky->horizfrac = 65536;
}

View file

@ -1,9 +1,9 @@
#include "compat.h" #include "compat.h"
extern const char *G_DefaultGrpFile(void); extern const char *G_DefaultGrpFile(void);
extern const char *G_GrpFile(void); extern const char *G_GrpFile(void);
extern uint8_t *basepaltable[1]; extern uint8_t *basepaltable[1];
extern void Ken_InitMultiPsky(void); extern void Ken_InitMultiPsky(void);

View file

@ -1,286 +1,288 @@
// Evil and Nasty Configuration File Reader for KenBuild // Evil and Nasty Configuration File Reader for KenBuild
// by Jonathon Fowler // by Jonathon Fowler
#include "compat.h" #include "compat.h"
#include "build.h" #include "build.h"
#include "editor.h" #include "editor.h"
#include "osd.h" #include "osd.h"
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN
#include "winlayer.h" #include "winlayer.h"
#endif #endif
#include "baselayer.h" #include "baselayer.h"
static int vesares[13][2] = {{320,200},{360,200},{320,240},{360,240},{320,400}, static int vesares[13][2] = {{320,200},{360,200},{320,240},{360,240},{320,400},
{360,400},{640,350},{640,400},{640,480},{800,600}, {360,400},{640,350},{640,400},{640,480},{800,600},
{1024,768},{1280,1024},{1600,1200}}; {1024,768},{1280,1024},{1600,1200}};
static int readconfig(BFILE *fp, const char *key, char *value, unsigned len) static int readconfig(BFILE *fp, const char *key, char *value, unsigned len)
{ {
char buf[1000], *k, *v, *eq; char buf[1000], *k, *v, *eq;
int x=0; int x=0;
if (len < 1) return 0; if (len < 1) return 0;
Brewind(fp); Brewind(fp);
while (1) { while (1)
if (!Bfgets(buf, 1000, fp)) return 0; {
if (!Bfgets(buf, 1000, fp)) return 0;
if (buf[0] == ';') continue;
if (buf[0] == ';') continue;
eq = Bstrchr(buf, '=');
if (!eq) continue; eq = Bstrchr(buf, '=');
if (!eq) continue;
k = buf;
v = eq+1; k = buf;
v = eq+1;
while (*k == ' ' || *k == '\t') k++;
*(eq--) = 0; while (*k == ' ' || *k == '\t') k++;
while ((*eq == ' ' || *eq == '\t') && eq>=k) *(eq--) = 0; *(eq--) = 0;
while ((*eq == ' ' || *eq == '\t') && eq>=k) *(eq--) = 0;
if (Bstrcasecmp(k, key)) continue;
if (Bstrcasecmp(k, key)) continue;
while (*v == ' ' || *k == '\t') v++;
eq = v + Bstrlen(v)-1; while (*v == ' ' || *k == '\t') v++;
eq = v + Bstrlen(v)-1;
while ((*eq == ' ' || *eq == '\t' || *eq == '\r' || *eq == '\n') && eq>=v) *(eq--) = 0;
while ((*eq == ' ' || *eq == '\t' || *eq == '\r' || *eq == '\n') && eq>=v) *(eq--) = 0;
value[--len] = 0;
do value[x] = v[x]; while (v[x++] != 0 && len-- > 0); value[--len] = 0;
do value[x] = v[x]; while (v[x++] != 0 && len-- > 0);
return x-1;
} return x-1;
} }
}
extern short brightness;
extern int fullscreen; extern short brightness;
extern unsigned char option[8]; extern int fullscreen;
extern unsigned char keys[NUMBUILDKEYS]; extern unsigned char option[8];
extern double msens; extern unsigned char keys[NUMBUILDKEYS];
extern double msens;
/*
* SETUP.DAT /*
* 0 = video mode (0:chained 1:vesa 2:screen buffered 3/4/5:tseng/paradise/s3 6:red-blue) * SETUP.DAT
* 1 = sound (0:none) * 0 = video mode (0:chained 1:vesa 2:screen buffered 3/4/5:tseng/paradise/s3 6:red-blue)
* 2 = music (0:none) * 1 = sound (0:none)
* 3 = input (0:keyboard 1:+mouse) * 2 = music (0:none)
* 4 = multiplayer (0:single 1-4:com 5-11:ipx) * 3 = input (0:keyboard 1:+mouse)
* 5&0xf0 = com speed * 4 = multiplayer (0:single 1-4:com 5-11:ipx)
* 5&0x0f = com irq * 5&0xf0 = com speed
* 6&0xf0 = chained y-res * 5&0x0f = com irq
* 6&0x0f = chained x-res or vesa mode * 6&0xf0 = chained y-res
* 7&0xf0 = sound samplerate * 6&0x0f = chained x-res or vesa mode
* 7&0x01 = sound quality * 7&0xf0 = sound samplerate
* 7&0x02 = 8/16 bit * 7&0x01 = sound quality
* 7&0x04 = mono/stereo * 7&0x02 = 8/16 bit
* * 7&0x04 = mono/stereo
* bytes 8 to 26 are key settings: *
* 0 = Forward (0xc8) * bytes 8 to 26 are key settings:
* 1 = Backward (0xd0) * 0 = Forward (0xc8)
* 2 = Turn left (0xcb) * 1 = Backward (0xd0)
* 3 = Turn right (0xcd) * 2 = Turn left (0xcb)
* 4 = Run (0x2a) * 3 = Turn right (0xcd)
* 5 = Strafe (0x9d) * 4 = Run (0x2a)
* 6 = Fire (0x1d) * 5 = Strafe (0x9d)
* 7 = Use (0x39) * 6 = Fire (0x1d)
* 8 = Stand high (0x1e) * 7 = Use (0x39)
* 9 = Stand low (0x2c) * 8 = Stand high (0x1e)
* 10 = Look up (0xd1) * 9 = Stand low (0x2c)
* 11 = Look down (0xc9) * 10 = Look up (0xd1)
* 12 = Strafe left (0x33) * 11 = Look down (0xc9)
* 13 = Strafe right (0x34) * 12 = Strafe left (0x33)
* 14 = 2D/3D switch (0x9c) * 13 = Strafe right (0x34)
* 15 = View cycle (0x1c) * 14 = 2D/3D switch (0x9c)
* 16 = 2D Zoom in (0xd) * 15 = View cycle (0x1c)
* 17 = 2D Zoom out (0xc) * 16 = 2D Zoom in (0xd)
* 18 = Chat (0xf) * 17 = 2D Zoom out (0xc)
*/ * 18 = Chat (0xf)
*/
int loadsetup(const char *fn)
{ int loadsetup(const char *fn)
BFILE *fp; {
#define VL 32 BFILE *fp;
char val[VL]; #define VL 32
int i; char val[VL];
int i;
if ((fp = Bfopen(fn, "rt")) == NULL) return -1;
if ((fp = Bfopen(fn, "rt")) == NULL) return -1;
if (readconfig(fp, "forcesetup", val, VL) > 0) { if (Batoi(val) != 0) forcesetup = 1; else forcesetup = 0; }
if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; } if (readconfig(fp, "forcesetup", val, VL) > 0) { if (Batoi(val) != 0) forcesetup = 1; else forcesetup = 0; }
if (readconfig(fp, "resolution", val, VL) > 0) { if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; }
i = Batoi(val) & 0x0f; if (readconfig(fp, "resolution", val, VL) > 0)
if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; } {
} i = Batoi(val) & 0x0f;
if (readconfig(fp, "xdim", val, VL) > 0) xdimgame = xdim2d = Batoi(val); if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; }
if (readconfig(fp, "ydim", val, VL) > 0) ydimgame = xdim2d = Batoi(val); }
if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (Batoi(val) & 0x0f) << 4; if (readconfig(fp, "xdim", val, VL) > 0) xdimgame = xdim2d = Batoi(val);
if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } if (readconfig(fp, "ydim", val, VL) > 0) ydimgame = xdim2d = Batoi(val);
if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (Batoi(val) & 0x0f) << 4;
if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val); if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; }
if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); } if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; }
if (readconfig(fp, "brightness", val, VL) > 0) brightness = min(max(Batoi(val),0),15); if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val);
if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); }
#ifdef RENDERTYPEWIN if (readconfig(fp, "brightness", val, VL) > 0) brightness = min(max(Batoi(val),0),15);
if (readconfig(fp, "maxrefreshfreq", val, VL) > 0) maxrefreshfreq = Batoi(val);
#endif #ifdef RENDERTYPEWIN
if (readconfig(fp, "maxrefreshfreq", val, VL) > 0) maxrefreshfreq = Batoi(val);
option[0] = 1; // vesa all the way... #endif
option[1] = 1; // sound all the way...
option[4] = 0; // no multiplayer option[0] = 1; // vesa all the way...
option[5] = 0; option[1] = 1; // sound all the way...
option[4] = 0; // no multiplayer
if (readconfig(fp, "keyforward", val, VL) > 0) keys[0] = Bstrtol(val, NULL, 16); option[5] = 0;
if (readconfig(fp, "keybackward", val, VL) > 0) keys[1] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keyturnleft", val, VL) > 0) keys[2] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyforward", val, VL) > 0) keys[0] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keyturnright", val, VL) > 0) keys[3] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keybackward", val, VL) > 0) keys[1] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keyrun", val, VL) > 0) keys[4] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyturnleft", val, VL) > 0) keys[2] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keystrafe", val, VL) > 0) keys[5] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyturnright", val, VL) > 0) keys[3] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keyfire", val, VL) > 0) keys[6] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyrun", val, VL) > 0) keys[4] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keyuse", val, VL) > 0) keys[7] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystrafe", val, VL) > 0) keys[5] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keystandhigh", val, VL) > 0) keys[8] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyfire", val, VL) > 0) keys[6] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keystandlow", val, VL) > 0) keys[9] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyuse", val, VL) > 0) keys[7] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keylookup", val, VL) > 0) keys[10] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystandhigh", val, VL) > 0) keys[8] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keylookdown", val, VL) > 0) keys[11] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystandlow", val, VL) > 0) keys[9] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keystrafeleft", val, VL) > 0) keys[12] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keylookup", val, VL) > 0) keys[10] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keystraferight", val, VL) > 0) keys[13] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keylookdown", val, VL) > 0) keys[11] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "key2dmode", val, VL) > 0) keys[14] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystrafeleft", val, VL) > 0) keys[12] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keyviewcycle", val, VL) > 0) keys[15] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystraferight", val, VL) > 0) keys[13] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "key2dzoomin", val, VL) > 0) keys[16] = Bstrtol(val, NULL, 16); if (readconfig(fp, "key2dmode", val, VL) > 0) keys[14] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "key2dzoomout", val, VL) > 0) keys[17] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyviewcycle", val, VL) > 0) keys[15] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keychat", val, VL) > 0) keys[18] = Bstrtol(val, NULL, 16); if (readconfig(fp, "key2dzoomin", val, VL) > 0) keys[16] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keyconsole", val, VL) > 0) { keys[19] = Bstrtol(val, NULL, 16); OSD_CaptureKey(keys[19]); } if (readconfig(fp, "key2dzoomout", val, VL) > 0) keys[17] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "keychat", val, VL) > 0) keys[18] = Bstrtol(val, NULL, 16);
if (readconfig(fp, "mousesensitivity", val, VL) > 0) msens = Bstrtod(val, NULL); if (readconfig(fp, "keyconsole", val, VL) > 0) { keys[19] = Bstrtol(val, NULL, 16); OSD_CaptureKey(keys[19]); }
Bfclose(fp); if (readconfig(fp, "mousesensitivity", val, VL) > 0) msens = Bstrtod(val, NULL);
return 0; Bfclose(fp);
}
return 0;
int writesetup(const char *fn) }
{
BFILE *fp; int writesetup(const char *fn)
{
fp = Bfopen(fn,"wt"); BFILE *fp;
if (!fp) return -1;
fp = Bfopen(fn,"wt");
Bfprintf(fp, if (!fp) return -1;
"; Always show configuration options on startup\n"
"; 0 - No\n" Bfprintf(fp,
"; 1 - Yes\n" "; Always show configuration options on startup\n"
"forcesetup = %d\n" "; 0 - No\n"
"\n" "; 1 - Yes\n"
"; Video mode selection\n" "forcesetup = %d\n"
"; 0 - Windowed\n" "\n"
"; 1 - Fullscreen\n" "; Video mode selection\n"
"fullscreen = %d\n" "; 0 - Windowed\n"
"\n" "; 1 - Fullscreen\n"
"; Video resolution\n" "fullscreen = %d\n"
"xdim = %d\n" "\n"
"ydim = %d\n" "; Video resolution\n"
"\n" "xdim = %d\n"
"; 3D-mode colour depth\n" "ydim = %d\n"
"bpp = %d\n" "\n"
"\n" "; 3D-mode colour depth\n"
#ifdef USE_OPENGL "bpp = %d\n"
"; OpenGL mode options\n" "\n"
"glusetexcache = %d\n" #ifdef USE_OPENGL
"\n" "; OpenGL mode options\n"
#endif "glusetexcache = %d\n"
#ifdef RENDERTYPEWIN "\n"
"; Maximum OpenGL mode refresh rate (Windows only, in Hertz)\n" #endif
"maxrefreshfreq = %d\n" #ifdef RENDERTYPEWIN
"\n" "; Maximum OpenGL mode refresh rate (Windows only, in Hertz)\n"
#endif "maxrefreshfreq = %d\n"
"; 3D mode brightness setting\n" "\n"
"; 0 - lowest\n" #endif
"; 15 - highest\n" "; 3D mode brightness setting\n"
"brightness = %d\n" "; 0 - lowest\n"
"\n" "; 15 - highest\n"
"; Sound sample frequency\n" "brightness = %d\n"
"; 0 - 6 KHz\n" "\n"
"; 1 - 8 KHz\n" "; Sound sample frequency\n"
"; 2 - 11.025 KHz\n" "; 0 - 6 KHz\n"
"; 3 - 16 KHz\n" "; 1 - 8 KHz\n"
"; 4 - 22.05 KHz\n" "; 2 - 11.025 KHz\n"
"; 5 - 32 KHz\n" "; 3 - 16 KHz\n"
"; 6 - 44.1 KHz\n" "; 4 - 22.05 KHz\n"
"samplerate = %d\n" "; 5 - 32 KHz\n"
"\n" "; 6 - 44.1 KHz\n"
"; Music playback\n" "samplerate = %d\n"
"; 0 - Off\n" "\n"
"; 1 - On\n" "; Music playback\n"
"music = %d\n" "; 0 - Off\n"
"\n" "; 1 - On\n"
"; Enable mouse\n" "music = %d\n"
"; 0 - No\n" "\n"
"; 1 - Yes\n" "; Enable mouse\n"
"mouse = %d\n" "; 0 - No\n"
"\n" "; 1 - Yes\n"
"; Mouse sensitivity\n" "mouse = %d\n"
"mousesensitivity = %g\n" "\n"
"\n" "; Mouse sensitivity\n"
"; Key Settings\n" "mousesensitivity = %g\n"
"; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n" "\n"
"; +---------------------------------------------------------------------------------------------+\n" "; Key Settings\n"
"; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 |\n" "; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n"
"; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL |\n" "; +---------------------------------------------------------------------------------------------+\n"
"; | |\n" "; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 |\n"
"; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A |\n" "; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL |\n"
"; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- |\n" "; | |\n"
"; | |\n" "; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A |\n"
"; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E |\n" "; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- |\n"
"; |TAB Q W E R T Y U I O P [ ] \\ DEL END PGDN KP7 KP8 KP9 KP+ |\n" "; | |\n"
"; | |\n" "; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E |\n"
"; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D |\n" "; |TAB Q W E R T Y U I O P [ ] \\ DEL END PGDN KP7 KP8 KP9 KP+ |\n"
"; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C |\n" "; | |\n"
"; | KPENTER|\n" "; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D |\n"
"; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 |\n" "; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C |\n"
"; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 |\n" "; | KPENTER|\n"
"; | |\n" "; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 |\n"
"; | 1D 38 39 B8 9D CB D0 CD 52 53 |\n" "; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 |\n"
"; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |\n" "; | |\n"
"; +---------------------------------------------------------------------------------------------+\n" "; | 1D 38 39 B8 9D CB D0 CD 52 53 |\n"
"\n" "; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |\n"
"keyforward = %X\n" "; +---------------------------------------------------------------------------------------------+\n"
"keybackward = %X\n" "\n"
"keyturnleft = %X\n" "keyforward = %X\n"
"keyturnright = %X\n" "keybackward = %X\n"
"keyrun = %X\n" "keyturnleft = %X\n"
"keystrafe = %X\n" "keyturnright = %X\n"
"keyfire = %X\n" "keyrun = %X\n"
"keyuse = %X\n" "keystrafe = %X\n"
"keystandhigh = %X\n" "keyfire = %X\n"
"keystandlow = %X\n" "keyuse = %X\n"
"keylookup = %X\n" "keystandhigh = %X\n"
"keylookdown = %X\n" "keystandlow = %X\n"
"keystrafeleft = %X\n" "keylookup = %X\n"
"keystraferight = %X\n" "keylookdown = %X\n"
"key2dmode = %X\n" "keystrafeleft = %X\n"
"keyviewcycle = %X\n" "keystraferight = %X\n"
"key2dzoomin = %X\n" "key2dmode = %X\n"
"key2dzoomout = %X\n" "keyviewcycle = %X\n"
"keychat = %X\n" "key2dzoomin = %X\n"
"keyconsole = %X\n" "key2dzoomout = %X\n"
"\n", "keychat = %X\n"
"keyconsole = %X\n"
forcesetup, fullscreen, xdimgame, ydimgame, bppgame, "\n",
#ifdef USE_OPENGL
glusetexcache, forcesetup, fullscreen, xdimgame, ydimgame, bppgame,
#endif #ifdef USE_OPENGL
#ifdef RENDERTYPEWIN glusetexcache,
maxrefreshfreq, #endif
#endif #ifdef RENDERTYPEWIN
brightness, option[7]>>4, option[2], maxrefreshfreq,
option[3], msens, #endif
keys[0], keys[1], keys[2], keys[3], keys[4], keys[5], brightness, option[7]>>4, option[2],
keys[6], keys[7], keys[8], keys[9], keys[10], keys[11], option[3], msens,
keys[12], keys[13], keys[14], keys[15], keys[16], keys[17], keys[0], keys[1], keys[2], keys[3], keys[4], keys[5],
keys[18], keys[19] keys[6], keys[7], keys[8], keys[9], keys[10], keys[11],
); keys[12], keys[13], keys[14], keys[15], keys[16], keys[17],
keys[18], keys[19]
Bfclose(fp); );
return 0; Bfclose(fp);
}
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -52,4 +52,4 @@ void updateinterpolations(void);
void dointerpolations(void); void dointerpolations(void);
void restoreinterpolations(void); void restoreinterpolations(void);
void printext(int x, int y, char *buffer, short tilenum /*, char invisiblecol*/); void printext(int x, int y, char *buffer, short tilenum /*, char invisiblecol*/);
void drawtilebackground (/*int thex, int they,*/ short tilenum, signed char shade, int cx1, int cy1, int cx2, int cy2, char dapalnum); void drawtilebackground(/*int thex, int they,*/ short tilenum, signed char shade, int cx1, int cy1, int cx2, int cy2, char dapalnum);

View file

@ -27,7 +27,8 @@
#define TAB_CONFIG 0 #define TAB_CONFIG 0
#define TAB_MESSAGES 1 #define TAB_MESSAGES 1
static struct { static struct
{
int fullscreen; int fullscreen;
int xdim3d, ydim3d, bpp3d; int xdim3d, ydim3d, bpp3d;
int forcesetup; int forcesetup;
@ -41,18 +42,18 @@ static int retval = -1, mode = TAB_MESSAGES;
// -- SUPPORT FUNCTIONS ------------------------------------------------------- // -- SUPPORT FUNCTIONS -------------------------------------------------------
#define GLADE_HOOKUP_OBJECT(component,widget,name) \ #define GLADE_HOOKUP_OBJECT(component,widget,name) \
g_object_set_data_full (G_OBJECT (component), name, \ g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
g_object_set_data (G_OBJECT (component), name, widget) g_object_set_data (G_OBJECT (component), name, widget)
#define lookup_widget(x,w) \ #define lookup_widget(x,w) \
(GtkWidget*) g_object_get_data(G_OBJECT(x), w) (GtkWidget*) g_object_get_data(G_OBJECT(x), w)
static GdkPixbuf *load_banner(void) static GdkPixbuf *load_banner(void)
{ {
return gdk_pixbuf_from_pixdata((GdkPixdata*)&startbanner_pixdata, FALSE, NULL); return gdk_pixbuf_from_pixdata((GdkPixdata *)&startbanner_pixdata, FALSE, NULL);
} }
static void SetPage(int n) static void SetPage(int n)
@ -65,7 +66,7 @@ static void SetPage(int n)
if (n == TAB_CONFIG) n = TRUE; else n = FALSE; if (n == TAB_CONFIG) n = TRUE; else n = FALSE;
gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n);
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)n); (GtkCallback)gtk_widget_set_sensitive, (gpointer)n);
} }
static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); static void on_vmode3dcombo_changed(GtkComboBox *, gpointer);
@ -78,10 +79,12 @@ static void PopulateForm(void)
char buf[64]; char buf[64];
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode3d < 0) { if (mode3d < 0)
{
int i, cd[] = { 32, 24, 16, 15, 8, 0 }; int 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.bpp3d) i++; else break; }
for ( ; cd[i]; i++) { for (; cd[i]; i++)
{
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue; if (mode3d < 0) continue;
settings.bpp3d = cd[i]; settings.bpp3d = cd[i];
@ -96,14 +99,16 @@ static void PopulateForm(void)
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d)); modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes3d); gtk_list_store_clear(modes3d);
for (i=0; i<validmodecnt; i++) { for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue; if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list // all modes get added to the 3D mode list
Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
gtk_list_store_append(modes3d, &iter); gtk_list_store_append(modes3d, &iter);
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1); gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
if (i == mode3d) { if (i == mode3d)
{
g_signal_handlers_block_by_func(box3d, on_vmode3dcombo_changed, NULL); g_signal_handlers_block_by_func(box3d, on_vmode3dcombo_changed, NULL);
gtk_combo_box_set_active_iter(box3d, &iter); gtk_combo_box_set_active_iter(box3d, &iter);
g_signal_handlers_unblock_by_func(box3d, on_vmode3dcombo_changed, NULL); g_signal_handlers_unblock_by_func(box3d, on_vmode3dcombo_changed, NULL);
@ -158,266 +163,266 @@ static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpo
static GtkWidget *create_window(void) static GtkWidget *create_window(void)
{ {
GtkWidget *startwin; GtkWidget *startwin;
GtkWidget *hlayout; GtkWidget *hlayout;
GtkWidget *banner; GtkWidget *banner;
GtkWidget *vlayout; GtkWidget *vlayout;
GtkWidget *tabs; GtkWidget *tabs;
GtkWidget *configvlayout; GtkWidget *configvlayout;
GtkWidget *configlayout; GtkWidget *configlayout;
GtkWidget *vmode3dlabel; GtkWidget *vmode3dlabel;
GtkWidget *vmode3dcombo; GtkWidget *vmode3dcombo;
GtkWidget *fullscreencheck; GtkWidget *fullscreencheck;
GtkWidget *alwaysshowcheck; GtkWidget *alwaysshowcheck;
GtkWidget *configtab; GtkWidget *configtab;
GtkWidget *messagesscroll; GtkWidget *messagesscroll;
GtkWidget *messagestext; GtkWidget *messagestext;
GtkWidget *messagestab; GtkWidget *messagestab;
GtkWidget *buttons; GtkWidget *buttons;
GtkWidget *cancelbutton; GtkWidget *cancelbutton;
GtkWidget *cancelbuttonalign; GtkWidget *cancelbuttonalign;
GtkWidget *cancelbuttonlayout; GtkWidget *cancelbuttonlayout;
GtkWidget *cancelbuttonicon; GtkWidget *cancelbuttonicon;
GtkWidget *cancelbuttonlabel; GtkWidget *cancelbuttonlabel;
GtkWidget *startbutton; GtkWidget *startbutton;
GtkWidget *startbuttonalign; GtkWidget *startbuttonalign;
GtkWidget *startbuttonlayout; GtkWidget *startbuttonlayout;
GtkWidget *startbuttonicon; GtkWidget *startbuttonicon;
GtkWidget *startbuttonlabel; GtkWidget *startbuttonlabel;
GtkAccelGroup *accel_group; GtkAccelGroup *accel_group;
accel_group = gtk_accel_group_new (); accel_group = gtk_accel_group_new();
// Basic window // Basic window
startwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); startwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (startwin), apptitle); // NOTE: use global app title gtk_window_set_title(GTK_WINDOW(startwin), apptitle); // NOTE: use global app title
gtk_window_set_position (GTK_WINDOW (startwin), GTK_WIN_POS_CENTER); gtk_window_set_position(GTK_WINDOW(startwin), GTK_WIN_POS_CENTER);
gtk_window_set_resizable (GTK_WINDOW (startwin), FALSE); gtk_window_set_resizable(GTK_WINDOW(startwin), FALSE);
gtk_window_set_type_hint (GTK_WINDOW (startwin), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_type_hint(GTK_WINDOW(startwin), GDK_WINDOW_TYPE_HINT_DIALOG);
// Horizontal layout of banner and controls // Horizontal layout of banner and controls
hlayout = gtk_hbox_new (FALSE, 0); hlayout = gtk_hbox_new(FALSE, 0);
gtk_widget_show (hlayout); gtk_widget_show(hlayout);
gtk_container_add (GTK_CONTAINER (startwin), hlayout); gtk_container_add(GTK_CONTAINER(startwin), hlayout);
// Banner // Banner
{ {
GdkPixbuf *pixbuf = load_banner(); GdkPixbuf *pixbuf = load_banner();
banner = gtk_image_new_from_pixbuf(pixbuf); banner = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref((gpointer)pixbuf); g_object_unref((gpointer)pixbuf);
} }
gtk_widget_show (banner); gtk_widget_show(banner);
gtk_box_pack_start (GTK_BOX (hlayout), banner, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hlayout), banner, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (banner), 0.5, 0); gtk_misc_set_alignment(GTK_MISC(banner), 0.5, 0);
// Vertical layout of tab control and start+cancel buttons // Vertical layout of tab control and start+cancel buttons
vlayout = gtk_vbox_new (FALSE, 0); vlayout = gtk_vbox_new(FALSE, 0);
gtk_widget_show (vlayout); gtk_widget_show(vlayout);
gtk_box_pack_start (GTK_BOX (hlayout), vlayout, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hlayout), vlayout, TRUE, TRUE, 0);
// Tab control // Tab control
tabs = gtk_notebook_new (); tabs = gtk_notebook_new();
gtk_widget_show (tabs); gtk_widget_show(tabs);
gtk_box_pack_start (GTK_BOX (vlayout), tabs, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vlayout), tabs, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (tabs), 4); gtk_container_set_border_width(GTK_CONTAINER(tabs), 4);
// Vertical layout of config page main body // Vertical layout of config page main body
configvlayout = gtk_vbox_new (FALSE, 0); configvlayout = gtk_vbox_new(FALSE, 0);
gtk_widget_show (configvlayout); gtk_widget_show(configvlayout);
gtk_container_add (GTK_CONTAINER (tabs), configvlayout); gtk_container_add(GTK_CONTAINER(tabs), configvlayout);
// Fixed-position layout of config page controls // Fixed-position layout of config page controls
configlayout = gtk_fixed_new (); configlayout = gtk_fixed_new();
gtk_widget_show (configlayout); gtk_widget_show(configlayout);
gtk_box_pack_start (GTK_BOX (configvlayout), configlayout, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(configvlayout), configlayout, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (configlayout), 6); gtk_container_set_border_width(GTK_CONTAINER(configlayout), 6);
// 3D video mode label // 3D video mode label
vmode3dlabel = gtk_label_new_with_mnemonic ("_Video mode:"); vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:");
gtk_widget_show (vmode3dlabel); gtk_widget_show(vmode3dlabel);
gtk_fixed_put (GTK_FIXED (configlayout), vmode3dlabel, 0, 0); gtk_fixed_put(GTK_FIXED(configlayout), vmode3dlabel, 0, 0);
gtk_widget_set_size_request (vmode3dlabel, 88, 29); gtk_widget_set_size_request(vmode3dlabel, 88, 29);
gtk_misc_set_alignment (GTK_MISC (vmode3dlabel), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(vmode3dlabel), 0, 0.5);
// 3D video mode combo // 3D video mode combo
{ {
GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
GtkCellRenderer *cell; GtkCellRenderer *cell;
vmode3dcombo = gtk_combo_box_new_with_model (GTK_TREE_MODEL(list)); vmode3dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
g_object_unref(G_OBJECT(list)); g_object_unref(G_OBJECT(list));
cell = gtk_cell_renderer_text_new(); cell = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(vmode3dcombo), cell, FALSE); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(vmode3dcombo), cell, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(vmode3dcombo), cell, "text", 0, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(vmode3dcombo), cell, "text", 0, NULL);
} }
gtk_widget_show (vmode3dcombo); gtk_widget_show(vmode3dcombo);
gtk_fixed_put (GTK_FIXED (configlayout), vmode3dcombo, 88, 0); gtk_fixed_put(GTK_FIXED(configlayout), vmode3dcombo, 88, 0);
gtk_widget_set_size_request (vmode3dcombo, 150, 29); gtk_widget_set_size_request(vmode3dcombo, 150, 29);
gtk_widget_add_accelerator (vmode3dcombo, "grab_focus", accel_group, gtk_widget_add_accelerator(vmode3dcombo, "grab_focus", accel_group,
GDK_V, GDK_MOD1_MASK, GDK_V, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
// Fullscreen checkbox // Fullscreen checkbox
fullscreencheck = gtk_check_button_new_with_mnemonic ("_Fullscreen"); fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
gtk_widget_show (fullscreencheck); gtk_widget_show(fullscreencheck);
gtk_fixed_put (GTK_FIXED (configlayout), fullscreencheck, 248, 0); gtk_fixed_put(GTK_FIXED(configlayout), fullscreencheck, 248, 0);
gtk_widget_set_size_request (fullscreencheck, 85, 29); gtk_widget_set_size_request(fullscreencheck, 85, 29);
gtk_widget_add_accelerator (fullscreencheck, "grab_focus", accel_group, gtk_widget_add_accelerator(fullscreencheck, "grab_focus", accel_group,
GDK_F, GDK_MOD1_MASK, GDK_F, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
// Always show config checkbox // Always show config checkbox
alwaysshowcheck = gtk_check_button_new_with_mnemonic ("_Always show configuration on start"); alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start");
gtk_widget_show (alwaysshowcheck); gtk_widget_show(alwaysshowcheck);
gtk_box_pack_start (GTK_BOX (configvlayout), alwaysshowcheck, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(configvlayout), alwaysshowcheck, FALSE, FALSE, 0);
gtk_widget_add_accelerator (alwaysshowcheck, "grab_focus", accel_group, gtk_widget_add_accelerator(alwaysshowcheck, "grab_focus", accel_group,
GDK_A, GDK_MOD1_MASK, GDK_A, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
// Configuration tab // Configuration tab
configtab = gtk_label_new ("Configuration"); configtab = gtk_label_new("Configuration");
gtk_widget_show (configtab); gtk_widget_show(configtab);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 0), configtab); gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 0), configtab);
// Messages scrollable area // Messages scrollable area
messagesscroll = gtk_scrolled_window_new (NULL, NULL); messagesscroll = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_show (messagesscroll); gtk_widget_show(messagesscroll);
gtk_container_add (GTK_CONTAINER (tabs), messagesscroll); gtk_container_add(GTK_CONTAINER(tabs), messagesscroll);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
// Messages text area // Messages text area
messagestext = gtk_text_view_new (); messagestext = gtk_text_view_new();
gtk_widget_show (messagestext); gtk_widget_show(messagestext);
gtk_container_add (GTK_CONTAINER (messagesscroll), messagestext); gtk_container_add(GTK_CONTAINER(messagesscroll), messagestext);
gtk_text_view_set_editable (GTK_TEXT_VIEW (messagestext), FALSE); gtk_text_view_set_editable(GTK_TEXT_VIEW(messagestext), FALSE);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (messagestext), GTK_WRAP_WORD); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(messagestext), GTK_WRAP_WORD);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (messagestext), FALSE); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(messagestext), FALSE);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (messagestext), 2); gtk_text_view_set_left_margin(GTK_TEXT_VIEW(messagestext), 2);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (messagestext), 2); gtk_text_view_set_right_margin(GTK_TEXT_VIEW(messagestext), 2);
// Messages tab // Messages tab
messagestab = gtk_label_new ("Messages"); messagestab = gtk_label_new("Messages");
gtk_widget_show (messagestab); gtk_widget_show(messagestab);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 1), messagestab); gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 1), messagestab);
// Dialogue box buttons layout // Dialogue box buttons layout
buttons = gtk_hbutton_box_new (); buttons = gtk_hbutton_box_new();
gtk_widget_show (buttons); gtk_widget_show(buttons);
gtk_box_pack_start (GTK_BOX (vlayout), buttons, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vlayout), buttons, FALSE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (buttons), 3); gtk_container_set_border_width(GTK_CONTAINER(buttons), 3);
gtk_button_box_set_layout (GTK_BUTTON_BOX (buttons), GTK_BUTTONBOX_END); gtk_button_box_set_layout(GTK_BUTTON_BOX(buttons), GTK_BUTTONBOX_END);
// Cancel button // Cancel button
cancelbutton = gtk_button_new (); cancelbutton = gtk_button_new();
gtk_widget_show (cancelbutton); gtk_widget_show(cancelbutton);
gtk_container_add (GTK_CONTAINER (buttons), cancelbutton); gtk_container_add(GTK_CONTAINER(buttons), cancelbutton);
GTK_WIDGET_SET_FLAGS (cancelbutton, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(cancelbutton, GTK_CAN_DEFAULT);
gtk_widget_add_accelerator (cancelbutton, "grab_focus", accel_group, gtk_widget_add_accelerator(cancelbutton, "grab_focus", accel_group,
GDK_C, GDK_MOD1_MASK, GDK_C, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator (cancelbutton, "clicked", accel_group, gtk_widget_add_accelerator(cancelbutton, "clicked", accel_group,
GDK_Escape, 0, GDK_Escape, 0,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
cancelbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0); cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
gtk_widget_show (cancelbuttonalign); gtk_widget_show(cancelbuttonalign);
gtk_container_add (GTK_CONTAINER (cancelbutton), cancelbuttonalign); gtk_container_add(GTK_CONTAINER(cancelbutton), cancelbuttonalign);
cancelbuttonlayout = gtk_hbox_new (FALSE, 2); cancelbuttonlayout = gtk_hbox_new(FALSE, 2);
gtk_widget_show (cancelbuttonlayout); gtk_widget_show(cancelbuttonlayout);
gtk_container_add (GTK_CONTAINER (cancelbuttonalign), cancelbuttonlayout); gtk_container_add(GTK_CONTAINER(cancelbuttonalign), cancelbuttonlayout);
cancelbuttonicon = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON); cancelbuttonicon = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (cancelbuttonicon); gtk_widget_show(cancelbuttonicon);
gtk_box_pack_start (GTK_BOX (cancelbuttonlayout), cancelbuttonicon, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(cancelbuttonlayout), cancelbuttonicon, FALSE, FALSE, 0);
cancelbuttonlabel = gtk_label_new_with_mnemonic ("_Cancel"); cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel");
gtk_widget_show (cancelbuttonlabel); gtk_widget_show(cancelbuttonlabel);
gtk_box_pack_start (GTK_BOX (cancelbuttonlayout), cancelbuttonlabel, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(cancelbuttonlayout), cancelbuttonlabel, FALSE, FALSE, 0);
// Start button // Start button
startbutton = gtk_button_new (); startbutton = gtk_button_new();
gtk_widget_show (startbutton); gtk_widget_show(startbutton);
gtk_container_add (GTK_CONTAINER (buttons), startbutton); gtk_container_add(GTK_CONTAINER(buttons), startbutton);
GTK_WIDGET_SET_FLAGS (startbutton, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(startbutton, GTK_CAN_DEFAULT);
gtk_widget_add_accelerator (startbutton, "grab_focus", accel_group, gtk_widget_add_accelerator(startbutton, "grab_focus", accel_group,
GDK_S, GDK_MOD1_MASK, GDK_S, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator (startbutton, "clicked", accel_group, gtk_widget_add_accelerator(startbutton, "clicked", accel_group,
GDK_Return, 0, GDK_Return, 0,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
startbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0); startbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
gtk_widget_show (startbuttonalign); gtk_widget_show(startbuttonalign);
gtk_container_add (GTK_CONTAINER (startbutton), startbuttonalign); gtk_container_add(GTK_CONTAINER(startbutton), startbuttonalign);
startbuttonlayout = gtk_hbox_new (FALSE, 2); startbuttonlayout = gtk_hbox_new(FALSE, 2);
gtk_widget_show (startbuttonlayout); gtk_widget_show(startbuttonlayout);
gtk_container_add (GTK_CONTAINER (startbuttonalign), startbuttonlayout); gtk_container_add(GTK_CONTAINER(startbuttonalign), startbuttonlayout);
startbuttonicon = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_BUTTON); startbuttonicon = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (startbuttonicon); gtk_widget_show(startbuttonicon);
gtk_box_pack_start (GTK_BOX (startbuttonlayout), startbuttonicon, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(startbuttonlayout), startbuttonicon, FALSE, FALSE, 0);
startbuttonlabel = gtk_label_new_with_mnemonic ("_Start"); startbuttonlabel = gtk_label_new_with_mnemonic("_Start");
gtk_widget_show (startbuttonlabel); gtk_widget_show(startbuttonlabel);
gtk_box_pack_start (GTK_BOX (startbuttonlayout), startbuttonlabel, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(startbuttonlayout), startbuttonlabel, FALSE, FALSE, 0);
// Wire up the signals // Wire up the signals
g_signal_connect ((gpointer) startwin, "delete_event", g_signal_connect((gpointer) startwin, "delete_event",
G_CALLBACK (on_startwin_delete_event), G_CALLBACK(on_startwin_delete_event),
NULL); NULL);
g_signal_connect ((gpointer) vmode3dcombo, "changed", g_signal_connect((gpointer) vmode3dcombo, "changed",
G_CALLBACK (on_vmode3dcombo_changed), G_CALLBACK(on_vmode3dcombo_changed),
NULL); NULL);
g_signal_connect ((gpointer) fullscreencheck, "toggled", g_signal_connect((gpointer) fullscreencheck, "toggled",
G_CALLBACK (on_fullscreencheck_toggled), G_CALLBACK(on_fullscreencheck_toggled),
NULL); NULL);
g_signal_connect ((gpointer) alwaysshowcheck, "toggled", g_signal_connect((gpointer) alwaysshowcheck, "toggled",
G_CALLBACK (on_alwaysshowcheck_toggled), G_CALLBACK(on_alwaysshowcheck_toggled),
NULL); NULL);
g_signal_connect ((gpointer) cancelbutton, "clicked", g_signal_connect((gpointer) cancelbutton, "clicked",
G_CALLBACK (on_cancelbutton_clicked), G_CALLBACK(on_cancelbutton_clicked),
NULL); NULL);
g_signal_connect ((gpointer) startbutton, "clicked", g_signal_connect((gpointer) startbutton, "clicked",
G_CALLBACK (on_startbutton_clicked), G_CALLBACK(on_startbutton_clicked),
NULL); NULL);
// Associate labels with their controls // Associate labels with their controls
gtk_label_set_mnemonic_widget (GTK_LABEL (vmode3dlabel), vmode3dcombo); gtk_label_set_mnemonic_widget(GTK_LABEL(vmode3dlabel), vmode3dcombo);
/* Store pointers to all widgets, for use by lookup_widget(). */ /* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (startwin, startwin, "startwin"); GLADE_HOOKUP_OBJECT_NO_REF(startwin, startwin, "startwin");
GLADE_HOOKUP_OBJECT (startwin, hlayout, "hlayout"); GLADE_HOOKUP_OBJECT(startwin, hlayout, "hlayout");
GLADE_HOOKUP_OBJECT (startwin, banner, "banner"); GLADE_HOOKUP_OBJECT(startwin, banner, "banner");
GLADE_HOOKUP_OBJECT (startwin, vlayout, "vlayout"); GLADE_HOOKUP_OBJECT(startwin, vlayout, "vlayout");
GLADE_HOOKUP_OBJECT (startwin, tabs, "tabs"); GLADE_HOOKUP_OBJECT(startwin, tabs, "tabs");
GLADE_HOOKUP_OBJECT (startwin, configvlayout, "configvlayout"); GLADE_HOOKUP_OBJECT(startwin, configvlayout, "configvlayout");
GLADE_HOOKUP_OBJECT (startwin, configlayout, "configlayout"); GLADE_HOOKUP_OBJECT(startwin, configlayout, "configlayout");
GLADE_HOOKUP_OBJECT (startwin, vmode3dlabel, "vmode3dlabel"); GLADE_HOOKUP_OBJECT(startwin, vmode3dlabel, "vmode3dlabel");
GLADE_HOOKUP_OBJECT (startwin, vmode3dcombo, "vmode3dcombo"); GLADE_HOOKUP_OBJECT(startwin, vmode3dcombo, "vmode3dcombo");
GLADE_HOOKUP_OBJECT (startwin, fullscreencheck, "fullscreencheck"); GLADE_HOOKUP_OBJECT(startwin, fullscreencheck, "fullscreencheck");
GLADE_HOOKUP_OBJECT (startwin, alwaysshowcheck, "alwaysshowcheck"); GLADE_HOOKUP_OBJECT(startwin, alwaysshowcheck, "alwaysshowcheck");
GLADE_HOOKUP_OBJECT (startwin, configtab, "configtab"); GLADE_HOOKUP_OBJECT(startwin, configtab, "configtab");
GLADE_HOOKUP_OBJECT (startwin, messagesscroll, "messagesscroll"); GLADE_HOOKUP_OBJECT(startwin, messagesscroll, "messagesscroll");
GLADE_HOOKUP_OBJECT (startwin, messagestext, "messagestext"); GLADE_HOOKUP_OBJECT(startwin, messagestext, "messagestext");
GLADE_HOOKUP_OBJECT (startwin, messagestab, "messagestab"); GLADE_HOOKUP_OBJECT(startwin, messagestab, "messagestab");
GLADE_HOOKUP_OBJECT (startwin, buttons, "buttons"); GLADE_HOOKUP_OBJECT(startwin, buttons, "buttons");
GLADE_HOOKUP_OBJECT (startwin, cancelbutton, "cancelbutton"); GLADE_HOOKUP_OBJECT(startwin, cancelbutton, "cancelbutton");
GLADE_HOOKUP_OBJECT (startwin, cancelbuttonalign, "cancelbuttonalign"); GLADE_HOOKUP_OBJECT(startwin, cancelbuttonalign, "cancelbuttonalign");
GLADE_HOOKUP_OBJECT (startwin, cancelbuttonlayout, "cancelbuttonlayout"); GLADE_HOOKUP_OBJECT(startwin, cancelbuttonlayout, "cancelbuttonlayout");
GLADE_HOOKUP_OBJECT (startwin, cancelbuttonicon, "cancelbuttonicon"); GLADE_HOOKUP_OBJECT(startwin, cancelbuttonicon, "cancelbuttonicon");
GLADE_HOOKUP_OBJECT (startwin, cancelbuttonlabel, "cancelbuttonlabel"); GLADE_HOOKUP_OBJECT(startwin, cancelbuttonlabel, "cancelbuttonlabel");
GLADE_HOOKUP_OBJECT (startwin, startbutton, "startbutton"); GLADE_HOOKUP_OBJECT(startwin, startbutton, "startbutton");
GLADE_HOOKUP_OBJECT (startwin, startbuttonalign, "startbuttonalign"); GLADE_HOOKUP_OBJECT(startwin, startbuttonalign, "startbuttonalign");
GLADE_HOOKUP_OBJECT (startwin, startbuttonlayout, "startbuttonlayout"); GLADE_HOOKUP_OBJECT(startwin, startbuttonlayout, "startbuttonlayout");
GLADE_HOOKUP_OBJECT (startwin, startbuttonicon, "startbuttonicon"); GLADE_HOOKUP_OBJECT(startwin, startbuttonicon, "startbuttonicon");
GLADE_HOOKUP_OBJECT (startwin, startbuttonlabel, "startbuttonlabel"); GLADE_HOOKUP_OBJECT(startwin, startbuttonlabel, "startbuttonlabel");
gtk_window_add_accel_group (GTK_WINDOW (startwin), accel_group); gtk_window_add_accel_group(GTK_WINDOW(startwin), accel_group);
return startwin; return startwin;
} }
// -- BUILD ENTRY POINTS ------------------------------------------------------ // -- BUILD ENTRY POINTS ------------------------------------------------------
@ -428,7 +433,8 @@ int startwin_open(void)
if (startwin) return 1; if (startwin) return 1;
startwin = create_window(); startwin = create_window();
if (startwin) { if (startwin)
{
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
gtk_widget_show(startwin); gtk_widget_show(startwin);
gtk_main_iteration_do(FALSE); gtk_main_iteration_do(FALSE);
@ -441,7 +447,7 @@ int startwin_close(void)
{ {
if (!gtkenabled) return 0; if (!gtkenabled) return 0;
if (!startwin) return 1; if (!startwin) return 1;
gtk_widget_destroy (startwin); gtk_widget_destroy(startwin);
startwin = NULL; startwin = NULL;
return 0; return 0;
} }
@ -460,33 +466,35 @@ int startwin_puts(const char *str)
textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
gtk_text_buffer_get_end_iter(textbuffer, &enditer); gtk_text_buffer_get_end_iter(textbuffer, &enditer);
for (aptr = bptr = str; *aptr != 0; ) { for (aptr = bptr = str; *aptr != 0; )
switch (*bptr) { {
case '\b': switch (*bptr)
if (bptr > aptr) {
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); 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) #if GTK_CHECK_VERSION(2,6,0)
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
#else #else
{ {
GtkTextIter iter2 = enditer; GtkTextIter iter2 = enditer;
gtk_text_iter_backward_cursor_position(&iter2); gtk_text_iter_backward_cursor_position(&iter2);
//FIXME: this seems be deleting one too many chars somewhere! //FIXME: this seems be deleting one too many chars somewhere!
if (!gtk_text_iter_equal(&iter2, &enditer)) if (!gtk_text_iter_equal(&iter2, &enditer))
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
} }
#endif #endif
aptr = ++bptr; aptr = ++bptr;
break; break;
case 0: case 0:
if (bptr > aptr) if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
aptr = bptr; aptr = bptr;
break; break;
case '\r': // FIXME case '\r': // FIXME
default: default:
bptr++; bptr++;
break; break;
} }
} }
@ -501,7 +509,7 @@ int startwin_settitle(const char *title)
{ {
if (!gtkenabled) return 0; if (!gtkenabled) return 0;
if (!startwin) return 1; if (!startwin) return 1;
gtk_window_set_title (GTK_WINDOW (startwin), title); gtk_window_set_title(GTK_WINDOW(startwin), title);
return 0; return 0;
} }
@ -509,7 +517,7 @@ int startwin_idle(void *s)
{ {
if (!gtkenabled) return 0; if (!gtkenabled) return 0;
//if (!startwin) return 1; //if (!startwin) return 1;
gtk_main_iteration_do (FALSE); gtk_main_iteration_do(FALSE);
return 0; return 0;
} }
@ -532,7 +540,8 @@ int startwin_run(void)
gtk_main(); gtk_main();
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
if (retval) { if (retval)
{
fullscreen = settings.fullscreen; fullscreen = settings.fullscreen;
xdimgame = settings.xdim3d; xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d; ydimgame = settings.ydim3d;

View file

@ -18,7 +18,8 @@
#define TAB_CONFIG 0 #define TAB_CONFIG 0
#define TAB_MESSAGES 1 #define TAB_MESSAGES 1
static struct { static struct
{
int fullscreen; int fullscreen;
int xdim3d, ydim3d, bpp3d; int xdim3d, ydim3d, bpp3d;
int forcesetup; int forcesetup;
@ -38,10 +39,12 @@ static void PopulateForm(void)
hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE); hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE);
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode3d < 0) { if (mode3d < 0)
{
int cd[] = { 32, 24, 16, 15, 8, 0 }; int 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.bpp3d) i++; else break; }
for ( ; cd[i]; i++) { for (; cd[i]; i++)
{
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue; if (mode3d < 0) continue;
settings.bpp3d = cd[i]; settings.bpp3d = cd[i];
@ -53,7 +56,8 @@ static void PopulateForm(void)
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
ComboBox_ResetContent(hwnd3d); ComboBox_ResetContent(hwnd3d);
for (i=0; i<validmodecnt; i++) { for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue; if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list // all modes get added to the 3D mode list
@ -66,32 +70,36 @@ static void PopulateForm(void)
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch (uMsg) { switch (uMsg)
case WM_COMMAND: {
switch (LOWORD(wParam)) { case WM_COMMAND:
case IDCFULLSCREEN: switch (LOWORD(wParam))
settings.fullscreen = !settings.fullscreen; {
PopulateForm(); case IDCFULLSCREEN:
return TRUE; settings.fullscreen = !settings.fullscreen;
case IDC3DVMODE: PopulateForm();
if (HIWORD(wParam) == CBN_SELCHANGE) { return TRUE;
int i; case IDC3DVMODE:
i = ComboBox_GetCurSel((HWND)lParam); if (HIWORD(wParam) == CBN_SELCHANGE)
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); {
if (i != CB_ERR) { int i;
settings.xdim3d = validmode[i].xdim; i = ComboBox_GetCurSel((HWND)lParam);
settings.ydim3d = validmode[i].ydim; if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
settings.bpp3d = validmode[i].bpp; if (i != CB_ERR)
} {
} settings.xdim3d = validmode[i].xdim;
return TRUE; settings.ydim3d = validmode[i].ydim;
case IDCALWAYSSHOW: settings.bpp3d = validmode[i].bpp;
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED; }
return TRUE;
default: break;
} }
break; return TRUE;
case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE;
default: break; default: break;
}
break;
default: break;
} }
return FALSE; return FALSE;
} }
@ -125,162 +133,171 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
static HBITMAP hbmp = NULL; static HBITMAP hbmp = NULL;
HDC hdc; HDC hdc;
switch (uMsg) { switch (uMsg)
case WM_INITDIALOG: { {
HWND hwnd; case WM_INITDIALOG:
RECT r, rdlg, chrome, rtab, rcancel, rstart; {
int xoffset = 0, yoffset = 0; HWND hwnd;
RECT r, rdlg, chrome, rtab, rcancel, rstart;
int 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)); ZeroMemory(&chrome, sizeof(chrome));
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
GetWindowRect(hwndDlg, &rdlg); GetWindowRect(hwndDlg, &rdlg);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab); GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel); GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart); 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.top -= chrome.top; rdlg.left -= chrome.left; rdlg.top -= chrome.top;
rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom; rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom;
// 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.bottom -= rtab.top - 1; rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left; rtab.top -= rdlg.top; rtab.left -= rdlg.left; rtab.top -= rdlg.top;
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1; rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top; rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1; rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left; rstart.top -= rdlg.top; rstart.left -= rdlg.left; rstart.top -= rdlg.top;
// And then convert the main dialogue coordinates to just width/length // And then convert the main dialogue coordinates to just width/length
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1; rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0; rdlg.top = 0; rdlg.left = 0; rdlg.top = 0;
// 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 = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
GetClientRect(hwnd, &r);
xoffset = r.right;
yoffset = r.bottom - rdlg.bottom;
// Shift and resize the controls that require it
rtab.left += xoffset; rtab.bottom += yoffset;
rcancel.left += xoffset; rcancel.top += yoffset;
rstart.left += xoffset; rstart.top += yoffset;
rdlg.right += xoffset;
rdlg.bottom += yoffset;
// Move the controls to their new positions
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.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
hdc = GetDC(NULL);
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
ReleaseDC(NULL, hdc);
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
// Add tabs to the tab control
{
TCITEM tab;
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
ZeroMemory(&tab, sizeof(tab));
tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Configuration");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Messages");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab);
// Work out the position and size of the area inside the tab control for the pages
ZeroMemory(&r, sizeof(r));
GetClientRect(hwnd, &r); GetClientRect(hwnd, &r);
xoffset = r.right; SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
yoffset = r.bottom - rdlg.bottom; r.right -= r.left-1;
r.bottom -= r.top-1;
r.top += rtab.top;
r.left += rtab.left;
// Shift and resize the controls that require it // Create the pages and position them in the tab control, but hide them
rtab.left += xoffset; rtab.bottom += yoffset; pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
rcancel.left += xoffset; rcancel.top += yoffset; MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
rstart.left += xoffset; rstart.top += yoffset; pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
rdlg.right += xoffset; SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
rdlg.bottom += yoffset; SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
// Move the controls to their new positions // Tell the editfield acting as the console to exclude the width of the scrollbar
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE); GetClientRect(pages[TAB_MESSAGES],&r);
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE); r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); r.left = r.top = 0;
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
// Move the main dialogue to the centre of the screen SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
hdc = GetDC(NULL); }
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; return FALSE;
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; }
ReleaseDC(NULL, hdc);
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
// Add tabs to the tab control case WM_NOTIFY:
{ {
TCITEM tab; LPNMHDR nmhdr = (LPNMHDR)lParam;
int cur;
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code)
{
case TCN_SELCHANGING:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE);
return TRUE;
}
case TCN_SELCHANGE:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
}
}
break;
}
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); case WM_CLOSE:
if (mode == TAB_CONFIG) done = 0;
else quitevent++;
return TRUE;
ZeroMemory(&tab, sizeof(tab)); case WM_DESTROY:
tab.mask = TCIF_TEXT; if (hbmp)
tab.pszText = TEXT("Configuration"); {
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab); DeleteObject(hbmp);
tab.mask = TCIF_TEXT; hbmp = NULL;
tab.pszText = TEXT("Messages");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab);
// Work out the position and size of the area inside the tab control for the pages
ZeroMemory(&r, sizeof(r));
GetClientRect(hwnd, &r);
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
r.right -= r.left-1;
r.bottom -= r.top-1;
r.top += rtab.top;
r.left += rtab.left;
// 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_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);
// Tell the editfield acting as the console to exclude the width of the scrollbar
GetClientRect(pages[TAB_MESSAGES],&r);
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
r.left = r.top = 0;
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
}
return FALSE;
} }
case WM_NOTIFY: { if (pages[TAB_CONFIG])
LPNMHDR nmhdr = (LPNMHDR)lParam; {
int cur; DestroyWindow(pages[TAB_CONFIG]);
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; pages[TAB_CONFIG] = NULL;
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code) {
case TCN_SELCHANGING: {
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE);
return TRUE;
}
case TCN_SELCHANGE: {
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
}
}
break;
} }
case WM_CLOSE: startupdlg = NULL;
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case WIN_STARTWIN_CANCEL:
if (mode == TAB_CONFIG) done = 0; if (mode == TAB_CONFIG) done = 0;
else quitevent++; else quitevent++;
return TRUE; return TRUE;
case WIN_STARTWIN_START: done = 1; return TRUE;
}
return FALSE;
case WM_DESTROY: case WM_CTLCOLORSTATIC:
if (hbmp) { if ((HWND)lParam == pages[TAB_MESSAGES])
DeleteObject(hbmp); return (BOOL)GetSysColorBrush(COLOR_WINDOW);
hbmp = NULL; break;
}
if (pages[TAB_CONFIG]) { default: break;
DestroyWindow(pages[TAB_CONFIG]);
pages[TAB_CONFIG] = NULL;
}
startupdlg = NULL;
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case WIN_STARTWIN_CANCEL:
if (mode == TAB_CONFIG) done = 0;
else quitevent++;
return TRUE;
case WIN_STARTWIN_START: done = 1; return TRUE;
}
return FALSE;
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == pages[TAB_MESSAGES])
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
break;
default: break;
} }
return FALSE; return FALSE;
@ -295,7 +312,8 @@ int startwin_open(void)
icc.dwICC = 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)
{
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
EnableConfig(0); EnableConfig(0);
return 0; return 0;
@ -332,25 +350,33 @@ int startwin_puts(const char *buf)
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf; 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 = 0;
} }
q = p; q = p;
while (*q && *q != '\n') q++; while (*q && *q != '\n') q++;
memcpy(workbuf, p, q-p); memcpy(workbuf, p, q-p);
if (*q == '\n') { if (*q == '\n')
if (!q[1]) { {
if (!q[1])
{
newline = 1; newline = 1;
workbuf[q-p] = 0; workbuf[q-p] = 0;
} else { }
else
{
workbuf[q-p] = '\r'; workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n'; workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0; workbuf[q-p+2] = 0;
} }
p = q+1; p = q+1;
} else { }
else
{
workbuf[q-p] = 0; workbuf[q-p] = 0;
p = q; p = q;
} }
@ -372,7 +398,7 @@ int startwin_settitle(const char *str)
int startwin_idle(void *v) int startwin_idle(void *v)
{ {
if (!startupdlg || !IsWindow(startupdlg)) return 0; if (!startupdlg || !IsWindow(startupdlg)) return 0;
if (IsDialogMessage(startupdlg, (MSG*)v)) return 1; if (IsDialogMessage(startupdlg, (MSG *)v)) return 1;
return 0; return 0;
} }
@ -395,21 +421,24 @@ int startwin_run(void)
settings.forcesetup = forcesetup; settings.forcesetup = forcesetup;
PopulateForm(); PopulateForm();
while (done < 0) { while (done < 0)
switch (GetMessage(&msg, NULL, 0,0)) { {
case 0: done = 1; break; switch (GetMessage(&msg, NULL, 0,0))
case -1: return -1; {
default: case 0: done = 1; break;
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; case -1: return -1;
TranslateMessage(&msg); default:
DispatchMessage(&msg); if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
break; TranslateMessage(&msg);
DispatchMessage(&msg);
break;
} }
} }
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
EnableConfig(0); EnableConfig(0);
if (done) { if (done)
{
fullscreen = settings.fullscreen; fullscreen = settings.fullscreen;
xdimgame = settings.xdim3d; xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d; ydimgame = settings.ydim3d;