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;

View file

@ -18,8 +18,8 @@
#include "common_game.h" #include "common_game.h"
const char* AppProperName = "KenBuild Editor"; const char *AppProperName = "KenBuild Editor";
const char* AppTechnicalName = "testeditor"; const char *AppTechnicalName = "testeditor";
#if defined(_WIN32) #if defined(_WIN32)
#define DEFAULT_GAME_EXEC "testgame.exe" #define DEFAULT_GAME_EXEC "testgame.exe"
@ -29,8 +29,8 @@ const char* AppTechnicalName = "testeditor";
#define DEFAULT_GAME_LOCAL_EXEC "./eduke32" #define DEFAULT_GAME_LOCAL_EXEC "./eduke32"
#endif #endif
const char* DefaultGameExec = DEFAULT_GAME_EXEC; const char *DefaultGameExec = DEFAULT_GAME_EXEC;
const char* DefaultGameLocalExec = DEFAULT_GAME_LOCAL_EXEC; const char *DefaultGameLocalExec = DEFAULT_GAME_LOCAL_EXEC;
#define SETUPFILENAME "testeditor.cfg" #define SETUPFILENAME "testeditor.cfg"
const char *defaultsetupfilename = SETUPFILENAME; const char *defaultsetupfilename = SETUPFILENAME;
@ -91,7 +91,7 @@ int32_t ExtPreInit(int32_t argc,const char **argv)
UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv); UNREFERENCED_PARAMETER(argv);
OSD_SetLogFile("testeditor.log"); OSD_SetLogFile("testeditor.log");
OSD_SetVersion(AppProperName,0,2); OSD_SetVersion(AppProperName,0,2);
initprintf("%s %s %s\n", AppProperName, s_buildRev, s_buildInfo); initprintf("%s %s %s\n", AppProperName, s_buildRev, s_buildInfo);
initprintf("Compiled %s\n", s_buildTimestamp); initprintf("Compiled %s\n", s_buildTimestamp);
@ -133,9 +133,9 @@ int32_t ExtPostStartupWindow(void)
initgroupfile(G_GrpFile()); initgroupfile(G_GrpFile());
//You can load your own palette lookup tables here if you just //You can load your own palette lookup tables here if you just
//copy the right code! //copy the right code!
for(i=0;i<256;i++) for (i=0; i<256; i++)
tempbuf[i] = ((i+32)&255); //remap colors for screwy palette sectors tempbuf[i] = ((i+32)&255); //remap colors for screwy palette sectors
makepalookup(16,tempbuf,0,0,0,1); makepalookup(16,tempbuf,0,0,0,1);
@ -171,10 +171,13 @@ void ExtPreCheckKeys(void)
{ {
keystatus[0x3e] = 0; keystatus[0x3e] = 0;
//cycle through all vesa modes, then screen-buffer mode //cycle through all vesa modes, then screen-buffer mode
if (keystatus[0x2a]|keystatus[0x36]) { if (keystatus[0x2a]|keystatus[0x36])
{
setgamemode(!fullscreen, xdim, ydim, bpp); setgamemode(!fullscreen, xdim, ydim, bpp);
} else { }
else
{
//cycle through all modes //cycle through all modes
j=-1; j=-1;
@ -185,13 +188,14 @@ void ExtPreCheckKeys(void)
(validmode[i].ydim == ydim) && (validmode[i].ydim == ydim) &&
(validmode[i].fs == fullscreen) && (validmode[i].fs == fullscreen) &&
(validmode[i].bpp == bpp)) (validmode[i].bpp == bpp))
{ j=i; break; } { j=i; break; }
for (k=0; k<validmodecnt; k++) for (k=0; k<validmodecnt; k++)
if (validmode[k].fs == fullscreen && validmode[k].bpp == bpp) break; if (validmode[k].fs == fullscreen && validmode[k].bpp == bpp) break;
if (j==-1) j=k; if (j==-1) j=k;
else { else
{
j++; j++;
if (j==validmodecnt) j=k; if (j==validmodecnt) j=k;
} }
@ -238,8 +242,8 @@ void ExtPreCheckKeys(void)
dy = (ydim + (ydim >> 3) + (ydim >> 4) + (ydim >> 6)) & (~7); dy = (ydim + (ydim >> 3) + (ydim >> 4) + (ydim >> 6)) & (~7);
i = scale(320,ydim,xdim); i = scale(320,ydim,xdim);
if (waloff[4094] == 0) allocache(&waloff[4094],/*240L*384L*/dx*dy,&walock[4094]); if (waloff[4094] == 0) allocache(&waloff[4094],/*240L*384L*/ dx*dy,&walock[4094]);
setviewtotile(4094,/*240L,384L*/dy,dx); setviewtotile(4094,/*240L,384L*/ dy,dx);
cosang = sintable[(hang+512)&2047]; cosang = sintable[(hang+512)&2047];
sinang = sintable[hang&2047]; sinang = sintable[hang&2047];
@ -272,35 +276,39 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr
UNREFERENCED_PARAMETER(oura); UNREFERENCED_PARAMETER(oura);
UNREFERENCED_PARAMETER(smoothr); UNREFERENCED_PARAMETER(smoothr);
for(i=0,tspr=&tsprite[0];i<spritesortcnt;i++,tspr++) for (i=0,tspr=&tsprite[0]; i<spritesortcnt; i++,tspr++)
{ {
if (usevoxels && tiletovox[tspr->picnum] >= 0) if (usevoxels && tiletovox[tspr->picnum] >= 0)
{ {
switch(tspr->picnum) switch (tspr->picnum)
{ {
case PLAYER: case PLAYER:
if (!voxoff[ tiletovox[PLAYER] ][0]) { if (!voxoff[tiletovox[PLAYER]][0])
if (qloadkvx(tiletovox[PLAYER],"voxel000.kvx")) { {
if (qloadkvx(tiletovox[PLAYER],"voxel000.kvx"))
{
tiletovox[PLAYER] = -1; tiletovox[PLAYER] = -1;
break; break;
} }
} }
//tspr->cstat |= 48; tspr->picnum = tiletovox[tspr->picnum]; //tspr->cstat |= 48; tspr->picnum = tiletovox[tspr->picnum];
longptr = (int *)voxoff[ tiletovox[PLAYER] ][0]; longptr = (int *)voxoff[tiletovox[PLAYER]][0];
tspr->xrepeat = scale(tspr->xrepeat,56,longptr[2]); tspr->xrepeat = scale(tspr->xrepeat,56,longptr[2]);
tspr->yrepeat = scale(tspr->yrepeat,56,longptr[2]); tspr->yrepeat = scale(tspr->yrepeat,56,longptr[2]);
tspr->shade -= 6; tspr->shade -= 6;
break; break;
case BROWNMONSTER: case BROWNMONSTER:
if (!voxoff[ tiletovox[BROWNMONSTER] ][0]) { if (!voxoff[tiletovox[BROWNMONSTER]][0])
if (qloadkvx(tiletovox[BROWNMONSTER],"voxel001.kvx")) { {
if (qloadkvx(tiletovox[BROWNMONSTER],"voxel001.kvx"))
{
tiletovox[BROWNMONSTER] = -1; tiletovox[BROWNMONSTER] = -1;
break; break;
} }
} }
//tspr->cstat |= 48; tspr->picnum = tiletovox[tspr->picnum]; //tspr->cstat |= 48; tspr->picnum = tiletovox[tspr->picnum];
break; break;
} }
} }
tspr->shade += 6; tspr->shade += 6;
@ -313,7 +321,7 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr
void ExtCheckKeys(void) void ExtCheckKeys(void)
{ {
int i;//, p, y, dx, dy, cosang, sinang, bufplc, tsizy, tsizyup15; int i; //, p, y, dx, dy, cosang, sinang, bufplc, tsizy, tsizyup15;
int j; int j;
if (qsetmode == 200) //In 3D mode if (qsetmode == 200) //In 3D mode
@ -336,7 +344,7 @@ void ExtCheckKeys(void)
sinang = mulscale14(sinang,daviewingrange); sinang = mulscale14(sinang,daviewingrange);
cosang = mulscale14(cosang,daaspect); cosang = mulscale14(cosang,daaspect);
p = ylookup[windowy1]+frameplace+windowx2+1; p = ylookup[windowy1]+frameplace+windowx2+1;
for(y=windowy1;y<=windowy2;y++) for (y=windowy1; y<=windowy2; y++)
{ {
i = divscale16(tsizyup15,dx); i = divscale16(tsizyup15,dx);
stretchhline(0,(xdim>>1)*i+tsizyup15,xdim>>2,i,mulscale32(i,dy)*tsizy+bufplc,p); stretchhline(0,(xdim>>1)*i+tsizyup15,xdim>>2,i,mulscale32(i,dy)*tsizy+bufplc,p);
@ -361,7 +369,7 @@ void ExtCheckKeys(void)
i = frameval[framecnt&(AVERAGEFRAMES-1)]; i = frameval[framecnt&(AVERAGEFRAMES-1)];
j = frameval[framecnt&(AVERAGEFRAMES-1)] = getticks(); framecnt++; j = frameval[framecnt&(AVERAGEFRAMES-1)] = getticks(); framecnt++;
if (i != j) averagefps = ((mul3(averagefps)+((AVERAGEFRAMES*1000)/(j-i)) )>>2); if (i != j) averagefps = ((mul3(averagefps)+((AVERAGEFRAMES*1000)/(j-i)))>>2);
Bsprintf((char *)tempbuf,"%d",averagefps); Bsprintf((char *)tempbuf,"%d",averagefps);
printext256(0L,0L,31,-1,(char *)tempbuf,1); printext256(0L,0L,31,-1,(char *)tempbuf,1);
@ -411,9 +419,9 @@ const char *ExtGetSectorCaption(short sectnum)
else else
{ {
Bsprintf((char *)tempbuf,"%hu,%hu",(unsigned short)sector[sectnum].hitag, Bsprintf((char *)tempbuf,"%hu,%hu",(unsigned short)sector[sectnum].hitag,
(unsigned short)sector[sectnum].lotag); (unsigned short)sector[sectnum].lotag);
} }
return((char *)tempbuf); return (char *)tempbuf;
} }
const char *ExtGetWallCaption(short wallnum) const char *ExtGetWallCaption(short wallnum)
@ -425,9 +433,9 @@ const char *ExtGetWallCaption(short wallnum)
else else
{ {
Bsprintf((char *)tempbuf,"%hu,%hu",(unsigned short)wall[wallnum].hitag, Bsprintf((char *)tempbuf,"%hu,%hu",(unsigned short)wall[wallnum].hitag,
(unsigned short)wall[wallnum].lotag); (unsigned short)wall[wallnum].lotag);
} }
return((char *)tempbuf); return (char *)tempbuf;
} }
const char *ExtGetSpriteCaption(short spritenum) const char *ExtGetSpriteCaption(short spritenum)
@ -439,9 +447,9 @@ const char *ExtGetSpriteCaption(short spritenum)
else else
{ {
Bsprintf((char *)tempbuf,"%hu,%hu",(unsigned short)sprite[spritenum].hitag, Bsprintf((char *)tempbuf,"%hu,%hu",(unsigned short)sprite[spritenum].hitag,
(unsigned short)sprite[spritenum].lotag); (unsigned short)sprite[spritenum].lotag);
} }
return((char *)tempbuf); return (char *)tempbuf;
} }
//printext16 parameters: //printext16 parameters:
@ -526,11 +534,11 @@ void ExtEditSectorData(short sectnum) //F7
if (qsetmode == 200) //In 3D mode if (qsetmode == 200) //In 3D mode
{ {
//Ceiling //Ceiling
if (searchstat == 1) if (searchstat == 1)
sector[searchsector].ceilingpicnum++; //Just a stupid example sector[searchsector].ceilingpicnum++; //Just a stupid example
//Floor //Floor
if (searchstat == 2) if (searchstat == 2)
sector[searchsector].floorshade++; //Just a stupid example sector[searchsector].floorshade++; //Just a stupid example
} }
@ -590,6 +598,7 @@ void faketimerhandler(void)
void M32RunScript(const char *s) { UNREFERENCED_PARAMETER(s); } void M32RunScript(const char *s) { UNREFERENCED_PARAMETER(s); }
void G_Polymer_UnInit(void) { } void G_Polymer_UnInit(void) { }
void SetGamePalette(int32_t j) { UNREFERENCED_PARAMETER(j); } void SetGamePalette(int32_t j) { UNREFERENCED_PARAMETER(j); }
int32_t AmbienceToggle, MixRate, ParentalLock; int32_t AmbienceToggle, MixRate, ParentalLock;
int32_t taglab_linktags(int32_t spritep, int32_t num) int32_t taglab_linktags(int32_t spritep, int32_t num)
@ -597,7 +606,7 @@ int32_t taglab_linktags(int32_t spritep, int32_t num)
int32_t link = 0; int32_t link = 0;
g_iReturnVar = link; g_iReturnVar = link;
VM_OnEvent(EVENT_LINKTAGS, spritep?num:-1); VM_OnEvent(EVENT_LINKTAGS, spritep ? num : -1);
link = g_iReturnVar; link = g_iReturnVar;
return link; return link;
@ -643,18 +652,32 @@ int32_t taglab_getnextfreetag(int32_t *duetoptr)
return 0; return 0;
} }
int32_t S_InvalidSound(int32_t num) { UNREFERENCED_PARAMETER(num); return 1; }; int32_t S_InvalidSound(int32_t num) {
int32_t S_CheckSoundPlaying(int32_t i, int32_t num) { UNREFERENCED_PARAMETER(i); UNREFERENCED_PARAMETER(num); return 0; }; UNREFERENCED_PARAMETER(num); return 1;
int32_t S_SoundsPlaying(int32_t i) { UNREFERENCED_PARAMETER(i); return -1; } };
int32_t S_SoundFlags(int32_t num) { UNREFERENCED_PARAMETER(num); return 0; }; int32_t S_CheckSoundPlaying(int32_t i, int32_t num) {
int32_t A_PlaySound(uint32_t num, int32_t i) { UNREFERENCED_PARAMETER(num); UNREFERENCED_PARAMETER(i); return 0; }; UNREFERENCED_PARAMETER(i); UNREFERENCED_PARAMETER(num); return 0;
void S_StopSound(int32_t num) { UNREFERENCED_PARAMETER(num); }; };
int32_t S_SoundsPlaying(int32_t i) {
UNREFERENCED_PARAMETER(i); return -1;
}
int32_t S_SoundFlags(int32_t num) {
UNREFERENCED_PARAMETER(num); return 0;
};
int32_t A_PlaySound(uint32_t num, int32_t i) {
UNREFERENCED_PARAMETER(num); UNREFERENCED_PARAMETER(i); return 0;
};
void S_StopSound(int32_t num) {
UNREFERENCED_PARAMETER(num);
};
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
int32_t FX_StopAllSounds(void) { return 0; }; int32_t FX_StopAllSounds(void) {
return 0;
};
//Just thought you might want my getnumber16 code //Just thought you might want my getnumber16 code
/* /*
getnumber16(char namestart[80], short num, int maxnumber) getnumber16(char namestart[80], short num, int maxnumber)
{ {

View file

@ -26,7 +26,8 @@ const char *G_DefFile(void)
return defaultdeffilename; return defaultdeffilename;
} }
uint8_t *basepaltable[1] = { uint8_t *basepaltable[1] =
{
palette palette
}; };
@ -35,17 +36,17 @@ uint32_t PaletteIndexFullbrights[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
void Ken_InitMultiPsky(void) void Ken_InitMultiPsky(void)
{ {
// default // default
psky * const defaultsky = E_DefinePsky(DEFAULTPSKY); psky *const defaultsky = E_DefinePsky(DEFAULTPSKY);
defaultsky->lognumtiles = 1; defaultsky->lognumtiles = 1;
defaultsky->horizfrac = 65536; defaultsky->horizfrac = 65536;
// DAYSKY // DAYSKY
psky * const daysky = E_DefinePsky(DAYSKY); psky *const daysky = E_DefinePsky(DAYSKY);
daysky->lognumtiles = 1; daysky->lognumtiles = 1;
daysky->horizfrac = 65536; daysky->horizfrac = 65536;
// NIGHTSKY // NIGHTSKY
psky * const nightsky = E_DefinePsky(NIGHTSKY); psky *const nightsky = E_DefinePsky(NIGHTSKY);
nightsky->lognumtiles = 3; nightsky->lognumtiles = 3;
nightsky->horizfrac = 65536; nightsky->horizfrac = 65536;
} }

View file

@ -12,8 +12,8 @@
#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)
{ {
@ -24,7 +24,8 @@ static int readconfig(BFILE *fp, const char *key, char *value, unsigned len)
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;
@ -108,7 +109,8 @@ int loadsetup(const char *fn)
if (readconfig(fp, "forcesetup", val, VL) > 0) { if (Batoi(val) != 0) forcesetup = 1; else forcesetup = 0; } 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, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; }
if (readconfig(fp, "resolution", val, VL) > 0) { if (readconfig(fp, "resolution", val, VL) > 0)
{
i = Batoi(val) & 0x0f; i = Batoi(val) & 0x0f;
if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; } if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; }
} }
@ -166,119 +168,119 @@ int writesetup(const char *fn)
if (!fp) return -1; if (!fp) return -1;
Bfprintf(fp, Bfprintf(fp,
"; Always show configuration options on startup\n" "; Always show configuration options on startup\n"
"; 0 - No\n" "; 0 - No\n"
"; 1 - Yes\n" "; 1 - Yes\n"
"forcesetup = %d\n" "forcesetup = %d\n"
"\n" "\n"
"; Video mode selection\n" "; Video mode selection\n"
"; 0 - Windowed\n" "; 0 - Windowed\n"
"; 1 - Fullscreen\n" "; 1 - Fullscreen\n"
"fullscreen = %d\n" "fullscreen = %d\n"
"\n" "\n"
"; Video resolution\n" "; Video resolution\n"
"xdim = %d\n" "xdim = %d\n"
"ydim = %d\n" "ydim = %d\n"
"\n" "\n"
"; 3D-mode colour depth\n" "; 3D-mode colour depth\n"
"bpp = %d\n" "bpp = %d\n"
"\n" "\n"
#ifdef USE_OPENGL #ifdef USE_OPENGL
"; OpenGL mode options\n" "; OpenGL mode options\n"
"glusetexcache = %d\n" "glusetexcache = %d\n"
"\n" "\n"
#endif #endif
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN
"; Maximum OpenGL mode refresh rate (Windows only, in Hertz)\n" "; Maximum OpenGL mode refresh rate (Windows only, in Hertz)\n"
"maxrefreshfreq = %d\n" "maxrefreshfreq = %d\n"
"\n" "\n"
#endif #endif
"; 3D mode brightness setting\n" "; 3D mode brightness setting\n"
"; 0 - lowest\n" "; 0 - lowest\n"
"; 15 - highest\n" "; 15 - highest\n"
"brightness = %d\n" "brightness = %d\n"
"\n" "\n"
"; Sound sample frequency\n" "; Sound sample frequency\n"
"; 0 - 6 KHz\n" "; 0 - 6 KHz\n"
"; 1 - 8 KHz\n" "; 1 - 8 KHz\n"
"; 2 - 11.025 KHz\n" "; 2 - 11.025 KHz\n"
"; 3 - 16 KHz\n" "; 3 - 16 KHz\n"
"; 4 - 22.05 KHz\n" "; 4 - 22.05 KHz\n"
"; 5 - 32 KHz\n" "; 5 - 32 KHz\n"
"; 6 - 44.1 KHz\n" "; 6 - 44.1 KHz\n"
"samplerate = %d\n" "samplerate = %d\n"
"\n" "\n"
"; Music playback\n" "; Music playback\n"
"; 0 - Off\n" "; 0 - Off\n"
"; 1 - On\n" "; 1 - On\n"
"music = %d\n" "music = %d\n"
"\n" "\n"
"; Enable mouse\n" "; Enable mouse\n"
"; 0 - No\n" "; 0 - No\n"
"; 1 - Yes\n" "; 1 - Yes\n"
"mouse = %d\n" "mouse = %d\n"
"\n" "\n"
"; Mouse sensitivity\n" "; Mouse sensitivity\n"
"mousesensitivity = %g\n" "mousesensitivity = %g\n"
"\n" "\n"
"; Key Settings\n" "; Key Settings\n"
"; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n" "; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n"
"; +---------------------------------------------------------------------------------------------+\n" "; +---------------------------------------------------------------------------------------------+\n"
"; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 |\n" "; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 |\n"
"; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL |\n" "; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL |\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" "; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A |\n"
"; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- |\n" "; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* 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" "; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E |\n"
"; |TAB Q W E R T Y U I O P [ ] \\ DEL END PGDN KP7 KP8 KP9 KP+ |\n" "; |TAB Q W E R T Y U I O P [ ] \\ DEL END PGDN KP7 KP8 KP9 KP+ |\n"
"; | |\n" "; | |\n"
"; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D |\n" "; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D |\n"
"; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C |\n" "; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C |\n"
"; | KPENTER|\n" "; | KPENTER|\n"
"; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 |\n" "; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 |\n"
"; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 |\n" "; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 |\n"
"; | |\n" "; | |\n"
"; | 1D 38 39 B8 9D CB D0 CD 52 53 |\n" "; | 1D 38 39 B8 9D CB D0 CD 52 53 |\n"
"; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |\n" "; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |\n"
"; +---------------------------------------------------------------------------------------------+\n" "; +---------------------------------------------------------------------------------------------+\n"
"\n" "\n"
"keyforward = %X\n" "keyforward = %X\n"
"keybackward = %X\n" "keybackward = %X\n"
"keyturnleft = %X\n" "keyturnleft = %X\n"
"keyturnright = %X\n" "keyturnright = %X\n"
"keyrun = %X\n" "keyrun = %X\n"
"keystrafe = %X\n" "keystrafe = %X\n"
"keyfire = %X\n" "keyfire = %X\n"
"keyuse = %X\n" "keyuse = %X\n"
"keystandhigh = %X\n" "keystandhigh = %X\n"
"keystandlow = %X\n" "keystandlow = %X\n"
"keylookup = %X\n" "keylookup = %X\n"
"keylookdown = %X\n" "keylookdown = %X\n"
"keystrafeleft = %X\n" "keystrafeleft = %X\n"
"keystraferight = %X\n" "keystraferight = %X\n"
"key2dmode = %X\n" "key2dmode = %X\n"
"keyviewcycle = %X\n" "keyviewcycle = %X\n"
"key2dzoomin = %X\n" "key2dzoomin = %X\n"
"key2dzoomout = %X\n" "key2dzoomout = %X\n"
"keychat = %X\n" "keychat = %X\n"
"keyconsole = %X\n" "keyconsole = %X\n"
"\n", "\n",
forcesetup, fullscreen, xdimgame, ydimgame, bppgame, forcesetup, fullscreen, xdimgame, ydimgame, bppgame,
#ifdef USE_OPENGL #ifdef USE_OPENGL
glusetexcache, glusetexcache,
#endif #endif
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN
maxrefreshfreq, maxrefreshfreq,
#endif #endif
brightness, option[7]>>4, option[2], brightness, option[7]>>4, option[2],
option[3], msens, option[3], msens,
keys[0], keys[1], keys[2], keys[3], keys[4], keys[5], keys[0], keys[1], keys[2], keys[3], keys[4], keys[5],
keys[6], keys[7], keys[8], keys[9], keys[10], keys[11], 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[12], keys[13], keys[14], keys[15], keys[16], keys[17],
keys[18], keys[19] keys[18], keys[19]
); );
Bfclose(fp); Bfclose(fp);

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;