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 "build.h"
static struct {
static struct
{
int fullscreen;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
@ -53,13 +54,17 @@ static struct {
int idx3d = -1;
int xdim, ydim, bpp;
if (firstTime) {
if (firstTime)
{
xdim = settings.xdim3d;
ydim = settings.ydim3d;
bpp = settings.bpp3d;
} else {
}
else
{
mode3d = [[modeslist3d objectAtIndex:[videoMode3DPUButton indexOfSelectedItem]] intValue];
if (mode3d >= 0) {
if (mode3d >= 0)
{
xdim = validmode[mode3d].xdim;
ydim = validmode[mode3d].ydim;
bpp = validmode[mode3d].bpp;
@ -67,10 +72,12 @@ static struct {
}
mode3d = checkvideomode(&xdim, &ydim, bpp, fullscreen, 1);
if (mode3d < 0) {
if (mode3d < 0)
{
int i, cd[] = { 32, 24, 16, 15, 8, 0 };
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);
if (mode3d < 0) continue;
break;
@ -82,12 +89,14 @@ static struct {
modeslist3d = [[NSMutableArray alloc] init];
for (i = 0; i < validmodecnt; i++) {
if (fullscreen == validmode[i].fs) {
for (i = 0; i < validmodecnt; i++)
{
if (fullscreen == validmode[i].fs)
{
if (i == mode3d) idx3d = [modeslist3d count];
[modeslist3d addObject:[NSNumber numberWithInt:i]];
[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
{
int mode = [[modeslist3d objectAtIndex:[videoMode3DPUButton indexOfSelectedItem]] intValue];
if (mode >= 0) {
if (mode >= 0)
{
settings.xdim3d = validmode[mode].xdim;
settings.ydim3d = validmode[mode].ydim;
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
NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator];
NSControl *control;
while (control = [enumerator nextObject]) {
while (control = [enumerator nextObject])
{
if (control == alwaysShowButton) continue;
[control setEnabled:false];
}
@ -175,7 +186,8 @@ static struct {
[messagesView replaceCharactersInRange:end withString:str];
[text endEditing];
if (shouldAutoScroll) {
if (shouldAutoScroll)
{
end.location = [text length];
end.length = 0;
[messagesView scrollRangeToVisible:end];
@ -265,15 +277,17 @@ int startwin_run(void)
[startwin setupRunMode];
switch ([NSApp runModalForWindow:[startwin window]]) {
case NSRunStoppedResponse: retval = 1; break;
case NSRunAbortedResponse: retval = 0; break;
default: retval = -1;
switch ([NSApp runModalForWindow:[startwin window]])
{
case NSRunStoppedResponse: retval = 1; break;
case NSRunAbortedResponse: retval = 0; break;
default: retval = -1;
}
[startwin setupMessagesMode];
if (retval) {
if (retval)
{
fullscreen = settings.fullscreen;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;

View file

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

View file

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

View file

@ -12,8 +12,8 @@
#include "baselayer.h"
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},
{1024,768},{1280,1024},{1600,1200}};
{360,400},{640,350},{640,400},{640,480},{800,600},
{1024,768},{1280,1024},{1600,1200}};
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);
while (1) {
while (1)
{
if (!Bfgets(buf, 1000, fp)) return 0;
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, "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;
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;
Bfprintf(fp,
"; Always show configuration options on startup\n"
"; 0 - No\n"
"; 1 - Yes\n"
"forcesetup = %d\n"
"\n"
"; Video mode selection\n"
"; 0 - Windowed\n"
"; 1 - Fullscreen\n"
"fullscreen = %d\n"
"\n"
"; Video resolution\n"
"xdim = %d\n"
"ydim = %d\n"
"\n"
"; 3D-mode colour depth\n"
"bpp = %d\n"
"\n"
"; Always show configuration options on startup\n"
"; 0 - No\n"
"; 1 - Yes\n"
"forcesetup = %d\n"
"\n"
"; Video mode selection\n"
"; 0 - Windowed\n"
"; 1 - Fullscreen\n"
"fullscreen = %d\n"
"\n"
"; Video resolution\n"
"xdim = %d\n"
"ydim = %d\n"
"\n"
"; 3D-mode colour depth\n"
"bpp = %d\n"
"\n"
#ifdef USE_OPENGL
"; OpenGL mode options\n"
"glusetexcache = %d\n"
"\n"
"; OpenGL mode options\n"
"glusetexcache = %d\n"
"\n"
#endif
#ifdef RENDERTYPEWIN
"; Maximum OpenGL mode refresh rate (Windows only, in Hertz)\n"
"maxrefreshfreq = %d\n"
"\n"
"; Maximum OpenGL mode refresh rate (Windows only, in Hertz)\n"
"maxrefreshfreq = %d\n"
"\n"
#endif
"; 3D mode brightness setting\n"
"; 0 - lowest\n"
"; 15 - highest\n"
"brightness = %d\n"
"\n"
"; Sound sample frequency\n"
"; 0 - 6 KHz\n"
"; 1 - 8 KHz\n"
"; 2 - 11.025 KHz\n"
"; 3 - 16 KHz\n"
"; 4 - 22.05 KHz\n"
"; 5 - 32 KHz\n"
"; 6 - 44.1 KHz\n"
"samplerate = %d\n"
"\n"
"; Music playback\n"
"; 0 - Off\n"
"; 1 - On\n"
"music = %d\n"
"\n"
"; Enable mouse\n"
"; 0 - No\n"
"; 1 - Yes\n"
"mouse = %d\n"
"\n"
"; Mouse sensitivity\n"
"mousesensitivity = %g\n"
"\n"
"; Key Settings\n"
"; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n"
"; +---------------------------------------------------------------------------------------------+\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"
"; | |\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"
"; | |\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"
"; | |\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"
"; | KPENTER|\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"
"; | |\n"
"; | 1D 38 39 B8 9D CB D0 CD 52 53 |\n"
"; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |\n"
"; +---------------------------------------------------------------------------------------------+\n"
"\n"
"keyforward = %X\n"
"keybackward = %X\n"
"keyturnleft = %X\n"
"keyturnright = %X\n"
"keyrun = %X\n"
"keystrafe = %X\n"
"keyfire = %X\n"
"keyuse = %X\n"
"keystandhigh = %X\n"
"keystandlow = %X\n"
"keylookup = %X\n"
"keylookdown = %X\n"
"keystrafeleft = %X\n"
"keystraferight = %X\n"
"key2dmode = %X\n"
"keyviewcycle = %X\n"
"key2dzoomin = %X\n"
"key2dzoomout = %X\n"
"keychat = %X\n"
"keyconsole = %X\n"
"\n",
"; 3D mode brightness setting\n"
"; 0 - lowest\n"
"; 15 - highest\n"
"brightness = %d\n"
"\n"
"; Sound sample frequency\n"
"; 0 - 6 KHz\n"
"; 1 - 8 KHz\n"
"; 2 - 11.025 KHz\n"
"; 3 - 16 KHz\n"
"; 4 - 22.05 KHz\n"
"; 5 - 32 KHz\n"
"; 6 - 44.1 KHz\n"
"samplerate = %d\n"
"\n"
"; Music playback\n"
"; 0 - Off\n"
"; 1 - On\n"
"music = %d\n"
"\n"
"; Enable mouse\n"
"; 0 - No\n"
"; 1 - Yes\n"
"mouse = %d\n"
"\n"
"; Mouse sensitivity\n"
"mousesensitivity = %g\n"
"\n"
"; Key Settings\n"
"; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n"
"; +---------------------------------------------------------------------------------------------+\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"
"; | |\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"
"; | |\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"
"; | |\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"
"; | KPENTER|\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"
"; | |\n"
"; | 1D 38 39 B8 9D CB D0 CD 52 53 |\n"
"; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |\n"
"; +---------------------------------------------------------------------------------------------+\n"
"\n"
"keyforward = %X\n"
"keybackward = %X\n"
"keyturnleft = %X\n"
"keyturnright = %X\n"
"keyrun = %X\n"
"keystrafe = %X\n"
"keyfire = %X\n"
"keyuse = %X\n"
"keystandhigh = %X\n"
"keystandlow = %X\n"
"keylookup = %X\n"
"keylookdown = %X\n"
"keystrafeleft = %X\n"
"keystraferight = %X\n"
"key2dmode = %X\n"
"keyviewcycle = %X\n"
"key2dzoomin = %X\n"
"key2dzoomout = %X\n"
"keychat = %X\n"
"keyconsole = %X\n"
"\n",
forcesetup, fullscreen, xdimgame, ydimgame, bppgame,
forcesetup, fullscreen, xdimgame, ydimgame, bppgame,
#ifdef USE_OPENGL
glusetexcache,
glusetexcache,
#endif
#ifdef RENDERTYPEWIN
maxrefreshfreq,
maxrefreshfreq,
#endif
brightness, option[7]>>4, option[2],
option[3], msens,
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[12], keys[13], keys[14], keys[15], keys[16], keys[17],
keys[18], keys[19]
);
brightness, option[7]>>4, option[2],
option[3], msens,
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[12], keys[13], keys[14], keys[15], keys[16], keys[17],
keys[18], keys[19]
);
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 restoreinterpolations(void);
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_MESSAGES 1
static struct {
static struct
{
int fullscreen;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
@ -41,18 +42,18 @@ static int retval = -1, mode = TAB_MESSAGES;
// -- SUPPORT FUNCTIONS -------------------------------------------------------
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
#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) \
(GtkWidget*) g_object_get_data(G_OBJECT(x), w)
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)
@ -65,7 +66,7 @@ static void SetPage(int n)
if (n == TAB_CONFIG) n = TRUE; else n = FALSE;
gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n);
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)n);
(GtkCallback)gtk_widget_set_sensitive, (gpointer)n);
}
static void on_vmode3dcombo_changed(GtkComboBox *, gpointer);
@ -78,10 +79,12 @@ static void PopulateForm(void)
char buf[64];
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 };
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);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
@ -96,14 +99,16 @@ static void PopulateForm(void)
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes3d);
for (i=0; i<validmodecnt; i++) {
for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list
Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
gtk_list_store_append(modes3d, &iter);
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);
gtk_combo_box_set_active_iter(box3d, &iter);
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)
{
GtkWidget *startwin;
GtkWidget *hlayout;
GtkWidget *banner;
GtkWidget *vlayout;
GtkWidget *tabs;
GtkWidget *configvlayout;
GtkWidget *configlayout;
GtkWidget *vmode3dlabel;
GtkWidget *vmode3dcombo;
GtkWidget *fullscreencheck;
GtkWidget *alwaysshowcheck;
GtkWidget *configtab;
GtkWidget *messagesscroll;
GtkWidget *messagestext;
GtkWidget *messagestab;
GtkWidget *buttons;
GtkWidget *cancelbutton;
GtkWidget *cancelbuttonalign;
GtkWidget *cancelbuttonlayout;
GtkWidget *cancelbuttonicon;
GtkWidget *cancelbuttonlabel;
GtkWidget *startbutton;
GtkWidget *startbuttonalign;
GtkWidget *startbuttonlayout;
GtkWidget *startbuttonicon;
GtkWidget *startbuttonlabel;
GtkAccelGroup *accel_group;
GtkWidget *startwin;
GtkWidget *hlayout;
GtkWidget *banner;
GtkWidget *vlayout;
GtkWidget *tabs;
GtkWidget *configvlayout;
GtkWidget *configlayout;
GtkWidget *vmode3dlabel;
GtkWidget *vmode3dcombo;
GtkWidget *fullscreencheck;
GtkWidget *alwaysshowcheck;
GtkWidget *configtab;
GtkWidget *messagesscroll;
GtkWidget *messagestext;
GtkWidget *messagestab;
GtkWidget *buttons;
GtkWidget *cancelbutton;
GtkWidget *cancelbuttonalign;
GtkWidget *cancelbuttonlayout;
GtkWidget *cancelbuttonicon;
GtkWidget *cancelbuttonlabel;
GtkWidget *startbutton;
GtkWidget *startbuttonalign;
GtkWidget *startbuttonlayout;
GtkWidget *startbuttonicon;
GtkWidget *startbuttonlabel;
GtkAccelGroup *accel_group;
accel_group = gtk_accel_group_new ();
accel_group = gtk_accel_group_new();
// Basic window
startwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
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_resizable (GTK_WINDOW (startwin), FALSE);
gtk_window_set_type_hint (GTK_WINDOW (startwin), GDK_WINDOW_TYPE_HINT_DIALOG);
// Basic window
startwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
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_resizable(GTK_WINDOW(startwin), FALSE);
gtk_window_set_type_hint(GTK_WINDOW(startwin), GDK_WINDOW_TYPE_HINT_DIALOG);
// Horizontal layout of banner and controls
hlayout = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hlayout);
gtk_container_add (GTK_CONTAINER (startwin), hlayout);
// Horizontal layout of banner and controls
hlayout = gtk_hbox_new(FALSE, 0);
gtk_widget_show(hlayout);
gtk_container_add(GTK_CONTAINER(startwin), hlayout);
// Banner
{
GdkPixbuf *pixbuf = load_banner();
banner = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref((gpointer)pixbuf);
}
gtk_widget_show (banner);
gtk_box_pack_start (GTK_BOX (hlayout), banner, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (banner), 0.5, 0);
// Banner
{
GdkPixbuf *pixbuf = load_banner();
banner = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref((gpointer)pixbuf);
}
gtk_widget_show(banner);
gtk_box_pack_start(GTK_BOX(hlayout), banner, FALSE, FALSE, 0);
gtk_misc_set_alignment(GTK_MISC(banner), 0.5, 0);
// Vertical layout of tab control and start+cancel buttons
vlayout = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vlayout);
gtk_box_pack_start (GTK_BOX (hlayout), vlayout, TRUE, TRUE, 0);
// Vertical layout of tab control and start+cancel buttons
vlayout = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vlayout);
gtk_box_pack_start(GTK_BOX(hlayout), vlayout, TRUE, TRUE, 0);
// Tab control
tabs = gtk_notebook_new ();
gtk_widget_show (tabs);
gtk_box_pack_start (GTK_BOX (vlayout), tabs, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (tabs), 4);
// Tab control
tabs = gtk_notebook_new();
gtk_widget_show(tabs);
gtk_box_pack_start(GTK_BOX(vlayout), tabs, TRUE, TRUE, 0);
gtk_container_set_border_width(GTK_CONTAINER(tabs), 4);
// Vertical layout of config page main body
configvlayout = gtk_vbox_new (FALSE, 0);
gtk_widget_show (configvlayout);
gtk_container_add (GTK_CONTAINER (tabs), configvlayout);
// Vertical layout of config page main body
configvlayout = gtk_vbox_new(FALSE, 0);
gtk_widget_show(configvlayout);
gtk_container_add(GTK_CONTAINER(tabs), configvlayout);
// Fixed-position layout of config page controls
configlayout = gtk_fixed_new ();
gtk_widget_show (configlayout);
gtk_box_pack_start (GTK_BOX (configvlayout), configlayout, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (configlayout), 6);
// Fixed-position layout of config page controls
configlayout = gtk_fixed_new();
gtk_widget_show(configlayout);
gtk_box_pack_start(GTK_BOX(configvlayout), configlayout, TRUE, TRUE, 0);
gtk_container_set_border_width(GTK_CONTAINER(configlayout), 6);
// 3D video mode label
vmode3dlabel = gtk_label_new_with_mnemonic ("_Video mode:");
gtk_widget_show (vmode3dlabel);
gtk_fixed_put (GTK_FIXED (configlayout), vmode3dlabel, 0, 0);
gtk_widget_set_size_request (vmode3dlabel, 88, 29);
gtk_misc_set_alignment (GTK_MISC (vmode3dlabel), 0, 0.5);
// 3D video mode label
vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:");
gtk_widget_show(vmode3dlabel);
gtk_fixed_put(GTK_FIXED(configlayout), vmode3dlabel, 0, 0);
gtk_widget_set_size_request(vmode3dlabel, 88, 29);
gtk_misc_set_alignment(GTK_MISC(vmode3dlabel), 0, 0.5);
// 3D video mode combo
{
GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
GtkCellRenderer *cell;
// 3D video mode combo
{
GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
GtkCellRenderer *cell;
vmode3dcombo = gtk_combo_box_new_with_model (GTK_TREE_MODEL(list));
g_object_unref(G_OBJECT(list));
vmode3dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
g_object_unref(G_OBJECT(list));
cell = gtk_cell_renderer_text_new();
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_widget_show (vmode3dcombo);
gtk_fixed_put (GTK_FIXED (configlayout), vmode3dcombo, 88, 0);
gtk_widget_set_size_request (vmode3dcombo, 150, 29);
gtk_widget_add_accelerator (vmode3dcombo, "grab_focus", accel_group,
GDK_V, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
cell = gtk_cell_renderer_text_new();
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_widget_show(vmode3dcombo);
gtk_fixed_put(GTK_FIXED(configlayout), vmode3dcombo, 88, 0);
gtk_widget_set_size_request(vmode3dcombo, 150, 29);
gtk_widget_add_accelerator(vmode3dcombo, "grab_focus", accel_group,
GDK_V, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// Fullscreen checkbox
fullscreencheck = gtk_check_button_new_with_mnemonic ("_Fullscreen");
gtk_widget_show (fullscreencheck);
gtk_fixed_put (GTK_FIXED (configlayout), fullscreencheck, 248, 0);
gtk_widget_set_size_request (fullscreencheck, 85, 29);
gtk_widget_add_accelerator (fullscreencheck, "grab_focus", accel_group,
GDK_F, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// Fullscreen checkbox
fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
gtk_widget_show(fullscreencheck);
gtk_fixed_put(GTK_FIXED(configlayout), fullscreencheck, 248, 0);
gtk_widget_set_size_request(fullscreencheck, 85, 29);
gtk_widget_add_accelerator(fullscreencheck, "grab_focus", accel_group,
GDK_F, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// Always show config checkbox
alwaysshowcheck = gtk_check_button_new_with_mnemonic ("_Always show configuration on start");
gtk_widget_show (alwaysshowcheck);
gtk_box_pack_start (GTK_BOX (configvlayout), alwaysshowcheck, FALSE, FALSE, 0);
gtk_widget_add_accelerator (alwaysshowcheck, "grab_focus", accel_group,
GDK_A, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// Always show config checkbox
alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start");
gtk_widget_show(alwaysshowcheck);
gtk_box_pack_start(GTK_BOX(configvlayout), alwaysshowcheck, FALSE, FALSE, 0);
gtk_widget_add_accelerator(alwaysshowcheck, "grab_focus", accel_group,
GDK_A, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// Configuration tab
configtab = gtk_label_new ("Configuration");
gtk_widget_show (configtab);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 0), configtab);
// Configuration tab
configtab = gtk_label_new("Configuration");
gtk_widget_show(configtab);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 0), configtab);
// Messages scrollable area
messagesscroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (messagesscroll);
gtk_container_add (GTK_CONTAINER (tabs), messagesscroll);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
// Messages scrollable area
messagesscroll = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_show(messagesscroll);
gtk_container_add(GTK_CONTAINER(tabs), messagesscroll);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
// Messages text area
messagestext = gtk_text_view_new ();
gtk_widget_show (messagestext);
gtk_container_add (GTK_CONTAINER (messagesscroll), messagestext);
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_cursor_visible (GTK_TEXT_VIEW (messagestext), FALSE);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (messagestext), 2);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (messagestext), 2);
// Messages text area
messagestext = gtk_text_view_new();
gtk_widget_show(messagestext);
gtk_container_add(GTK_CONTAINER(messagesscroll), messagestext);
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_cursor_visible(GTK_TEXT_VIEW(messagestext), FALSE);
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(messagestext), 2);
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(messagestext), 2);
// Messages tab
messagestab = gtk_label_new ("Messages");
gtk_widget_show (messagestab);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 1), messagestab);
// Messages tab
messagestab = gtk_label_new("Messages");
gtk_widget_show(messagestab);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 1), messagestab);
// Dialogue box buttons layout
buttons = gtk_hbutton_box_new ();
gtk_widget_show (buttons);
gtk_box_pack_start (GTK_BOX (vlayout), buttons, FALSE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (buttons), 3);
gtk_button_box_set_layout (GTK_BUTTON_BOX (buttons), GTK_BUTTONBOX_END);
// Dialogue box buttons layout
buttons = gtk_hbutton_box_new();
gtk_widget_show(buttons);
gtk_box_pack_start(GTK_BOX(vlayout), buttons, FALSE, TRUE, 0);
gtk_container_set_border_width(GTK_CONTAINER(buttons), 3);
gtk_button_box_set_layout(GTK_BUTTON_BOX(buttons), GTK_BUTTONBOX_END);
// Cancel button
cancelbutton = gtk_button_new ();
gtk_widget_show (cancelbutton);
gtk_container_add (GTK_CONTAINER (buttons), cancelbutton);
GTK_WIDGET_SET_FLAGS (cancelbutton, GTK_CAN_DEFAULT);
gtk_widget_add_accelerator (cancelbutton, "grab_focus", accel_group,
GDK_C, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator (cancelbutton, "clicked", accel_group,
GDK_Escape, 0,
GTK_ACCEL_VISIBLE);
// Cancel button
cancelbutton = gtk_button_new();
gtk_widget_show(cancelbutton);
gtk_container_add(GTK_CONTAINER(buttons), cancelbutton);
GTK_WIDGET_SET_FLAGS(cancelbutton, GTK_CAN_DEFAULT);
gtk_widget_add_accelerator(cancelbutton, "grab_focus", accel_group,
GDK_C, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator(cancelbutton, "clicked", accel_group,
GDK_Escape, 0,
GTK_ACCEL_VISIBLE);
cancelbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (cancelbuttonalign);
gtk_container_add (GTK_CONTAINER (cancelbutton), cancelbuttonalign);
cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
gtk_widget_show(cancelbuttonalign);
gtk_container_add(GTK_CONTAINER(cancelbutton), cancelbuttonalign);
cancelbuttonlayout = gtk_hbox_new (FALSE, 2);
gtk_widget_show (cancelbuttonlayout);
gtk_container_add (GTK_CONTAINER (cancelbuttonalign), cancelbuttonlayout);
cancelbuttonlayout = gtk_hbox_new(FALSE, 2);
gtk_widget_show(cancelbuttonlayout);
gtk_container_add(GTK_CONTAINER(cancelbuttonalign), cancelbuttonlayout);
cancelbuttonicon = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (cancelbuttonicon);
gtk_box_pack_start (GTK_BOX (cancelbuttonlayout), cancelbuttonicon, FALSE, FALSE, 0);
cancelbuttonicon = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON);
gtk_widget_show(cancelbuttonicon);
gtk_box_pack_start(GTK_BOX(cancelbuttonlayout), cancelbuttonicon, FALSE, FALSE, 0);
cancelbuttonlabel = gtk_label_new_with_mnemonic ("_Cancel");
gtk_widget_show (cancelbuttonlabel);
gtk_box_pack_start (GTK_BOX (cancelbuttonlayout), cancelbuttonlabel, FALSE, FALSE, 0);
cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel");
gtk_widget_show(cancelbuttonlabel);
gtk_box_pack_start(GTK_BOX(cancelbuttonlayout), cancelbuttonlabel, FALSE, FALSE, 0);
// Start button
startbutton = gtk_button_new ();
gtk_widget_show (startbutton);
gtk_container_add (GTK_CONTAINER (buttons), startbutton);
GTK_WIDGET_SET_FLAGS (startbutton, GTK_CAN_DEFAULT);
gtk_widget_add_accelerator (startbutton, "grab_focus", accel_group,
GDK_S, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator (startbutton, "clicked", accel_group,
GDK_Return, 0,
GTK_ACCEL_VISIBLE);
// Start button
startbutton = gtk_button_new();
gtk_widget_show(startbutton);
gtk_container_add(GTK_CONTAINER(buttons), startbutton);
GTK_WIDGET_SET_FLAGS(startbutton, GTK_CAN_DEFAULT);
gtk_widget_add_accelerator(startbutton, "grab_focus", accel_group,
GDK_S, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator(startbutton, "clicked", accel_group,
GDK_Return, 0,
GTK_ACCEL_VISIBLE);
startbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (startbuttonalign);
gtk_container_add (GTK_CONTAINER (startbutton), startbuttonalign);
startbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
gtk_widget_show(startbuttonalign);
gtk_container_add(GTK_CONTAINER(startbutton), startbuttonalign);
startbuttonlayout = gtk_hbox_new (FALSE, 2);
gtk_widget_show (startbuttonlayout);
gtk_container_add (GTK_CONTAINER (startbuttonalign), startbuttonlayout);
startbuttonlayout = gtk_hbox_new(FALSE, 2);
gtk_widget_show(startbuttonlayout);
gtk_container_add(GTK_CONTAINER(startbuttonalign), startbuttonlayout);
startbuttonicon = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (startbuttonicon);
gtk_box_pack_start (GTK_BOX (startbuttonlayout), startbuttonicon, FALSE, FALSE, 0);
startbuttonicon = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_BUTTON);
gtk_widget_show(startbuttonicon);
gtk_box_pack_start(GTK_BOX(startbuttonlayout), startbuttonicon, FALSE, FALSE, 0);
startbuttonlabel = gtk_label_new_with_mnemonic ("_Start");
gtk_widget_show (startbuttonlabel);
gtk_box_pack_start (GTK_BOX (startbuttonlayout), startbuttonlabel, FALSE, FALSE, 0);
startbuttonlabel = gtk_label_new_with_mnemonic("_Start");
gtk_widget_show(startbuttonlabel);
gtk_box_pack_start(GTK_BOX(startbuttonlayout), startbuttonlabel, FALSE, FALSE, 0);
// Wire up the signals
g_signal_connect ((gpointer) startwin, "delete_event",
G_CALLBACK (on_startwin_delete_event),
NULL);
g_signal_connect ((gpointer) vmode3dcombo, "changed",
G_CALLBACK (on_vmode3dcombo_changed),
NULL);
g_signal_connect ((gpointer) fullscreencheck, "toggled",
G_CALLBACK (on_fullscreencheck_toggled),
NULL);
g_signal_connect ((gpointer) alwaysshowcheck, "toggled",
G_CALLBACK (on_alwaysshowcheck_toggled),
NULL);
g_signal_connect ((gpointer) cancelbutton, "clicked",
G_CALLBACK (on_cancelbutton_clicked),
NULL);
g_signal_connect ((gpointer) startbutton, "clicked",
G_CALLBACK (on_startbutton_clicked),
NULL);
// Wire up the signals
g_signal_connect((gpointer) startwin, "delete_event",
G_CALLBACK(on_startwin_delete_event),
NULL);
g_signal_connect((gpointer) vmode3dcombo, "changed",
G_CALLBACK(on_vmode3dcombo_changed),
NULL);
g_signal_connect((gpointer) fullscreencheck, "toggled",
G_CALLBACK(on_fullscreencheck_toggled),
NULL);
g_signal_connect((gpointer) alwaysshowcheck, "toggled",
G_CALLBACK(on_alwaysshowcheck_toggled),
NULL);
g_signal_connect((gpointer) cancelbutton, "clicked",
G_CALLBACK(on_cancelbutton_clicked),
NULL);
g_signal_connect((gpointer) startbutton, "clicked",
G_CALLBACK(on_startbutton_clicked),
NULL);
// Associate labels with their controls
gtk_label_set_mnemonic_widget (GTK_LABEL (vmode3dlabel), vmode3dcombo);
// Associate labels with their controls
gtk_label_set_mnemonic_widget(GTK_LABEL(vmode3dlabel), vmode3dcombo);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (startwin, startwin, "startwin");
GLADE_HOOKUP_OBJECT (startwin, hlayout, "hlayout");
GLADE_HOOKUP_OBJECT (startwin, banner, "banner");
GLADE_HOOKUP_OBJECT (startwin, vlayout, "vlayout");
GLADE_HOOKUP_OBJECT (startwin, tabs, "tabs");
GLADE_HOOKUP_OBJECT (startwin, configvlayout, "configvlayout");
GLADE_HOOKUP_OBJECT (startwin, configlayout, "configlayout");
GLADE_HOOKUP_OBJECT (startwin, vmode3dlabel, "vmode3dlabel");
GLADE_HOOKUP_OBJECT (startwin, vmode3dcombo, "vmode3dcombo");
GLADE_HOOKUP_OBJECT (startwin, fullscreencheck, "fullscreencheck");
GLADE_HOOKUP_OBJECT (startwin, alwaysshowcheck, "alwaysshowcheck");
GLADE_HOOKUP_OBJECT (startwin, configtab, "configtab");
GLADE_HOOKUP_OBJECT (startwin, messagesscroll, "messagesscroll");
GLADE_HOOKUP_OBJECT (startwin, messagestext, "messagestext");
GLADE_HOOKUP_OBJECT (startwin, messagestab, "messagestab");
GLADE_HOOKUP_OBJECT (startwin, buttons, "buttons");
GLADE_HOOKUP_OBJECT (startwin, cancelbutton, "cancelbutton");
GLADE_HOOKUP_OBJECT (startwin, cancelbuttonalign, "cancelbuttonalign");
GLADE_HOOKUP_OBJECT (startwin, cancelbuttonlayout, "cancelbuttonlayout");
GLADE_HOOKUP_OBJECT (startwin, cancelbuttonicon, "cancelbuttonicon");
GLADE_HOOKUP_OBJECT (startwin, cancelbuttonlabel, "cancelbuttonlabel");
GLADE_HOOKUP_OBJECT (startwin, startbutton, "startbutton");
GLADE_HOOKUP_OBJECT (startwin, startbuttonalign, "startbuttonalign");
GLADE_HOOKUP_OBJECT (startwin, startbuttonlayout, "startbuttonlayout");
GLADE_HOOKUP_OBJECT (startwin, startbuttonicon, "startbuttonicon");
GLADE_HOOKUP_OBJECT (startwin, startbuttonlabel, "startbuttonlabel");
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF(startwin, startwin, "startwin");
GLADE_HOOKUP_OBJECT(startwin, hlayout, "hlayout");
GLADE_HOOKUP_OBJECT(startwin, banner, "banner");
GLADE_HOOKUP_OBJECT(startwin, vlayout, "vlayout");
GLADE_HOOKUP_OBJECT(startwin, tabs, "tabs");
GLADE_HOOKUP_OBJECT(startwin, configvlayout, "configvlayout");
GLADE_HOOKUP_OBJECT(startwin, configlayout, "configlayout");
GLADE_HOOKUP_OBJECT(startwin, vmode3dlabel, "vmode3dlabel");
GLADE_HOOKUP_OBJECT(startwin, vmode3dcombo, "vmode3dcombo");
GLADE_HOOKUP_OBJECT(startwin, fullscreencheck, "fullscreencheck");
GLADE_HOOKUP_OBJECT(startwin, alwaysshowcheck, "alwaysshowcheck");
GLADE_HOOKUP_OBJECT(startwin, configtab, "configtab");
GLADE_HOOKUP_OBJECT(startwin, messagesscroll, "messagesscroll");
GLADE_HOOKUP_OBJECT(startwin, messagestext, "messagestext");
GLADE_HOOKUP_OBJECT(startwin, messagestab, "messagestab");
GLADE_HOOKUP_OBJECT(startwin, buttons, "buttons");
GLADE_HOOKUP_OBJECT(startwin, cancelbutton, "cancelbutton");
GLADE_HOOKUP_OBJECT(startwin, cancelbuttonalign, "cancelbuttonalign");
GLADE_HOOKUP_OBJECT(startwin, cancelbuttonlayout, "cancelbuttonlayout");
GLADE_HOOKUP_OBJECT(startwin, cancelbuttonicon, "cancelbuttonicon");
GLADE_HOOKUP_OBJECT(startwin, cancelbuttonlabel, "cancelbuttonlabel");
GLADE_HOOKUP_OBJECT(startwin, startbutton, "startbutton");
GLADE_HOOKUP_OBJECT(startwin, startbuttonalign, "startbuttonalign");
GLADE_HOOKUP_OBJECT(startwin, startbuttonlayout, "startbuttonlayout");
GLADE_HOOKUP_OBJECT(startwin, startbuttonicon, "startbuttonicon");
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 ------------------------------------------------------
@ -428,7 +433,8 @@ int startwin_open(void)
if (startwin) return 1;
startwin = create_window();
if (startwin) {
if (startwin)
{
SetPage(TAB_MESSAGES);
gtk_widget_show(startwin);
gtk_main_iteration_do(FALSE);
@ -441,7 +447,7 @@ int startwin_close(void)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
gtk_widget_destroy (startwin);
gtk_widget_destroy(startwin);
startwin = NULL;
return 0;
}
@ -460,33 +466,35 @@ int startwin_puts(const char *str)
textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
gtk_text_buffer_get_end_iter(textbuffer, &enditer);
for (aptr = bptr = str; *aptr != 0; ) {
switch (*bptr) {
case '\b':
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
for (aptr = bptr = str; *aptr != 0; )
{
switch (*bptr)
{
case '\b':
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
#if GTK_CHECK_VERSION(2,6,0)
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
#else
{
{
GtkTextIter iter2 = enditer;
gtk_text_iter_backward_cursor_position(&iter2);
//FIXME: this seems be deleting one too many chars somewhere!
if (!gtk_text_iter_equal(&iter2, &enditer))
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
}
}
#endif
aptr = ++bptr;
break;
case 0:
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
aptr = bptr;
break;
case '\r': // FIXME
default:
bptr++;
break;
aptr = ++bptr;
break;
case 0:
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
aptr = bptr;
break;
case '\r': // FIXME
default:
bptr++;
break;
}
}
@ -501,7 +509,7 @@ int startwin_settitle(const char *title)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
gtk_window_set_title (GTK_WINDOW (startwin), title);
gtk_window_set_title(GTK_WINDOW(startwin), title);
return 0;
}
@ -509,7 +517,7 @@ int startwin_idle(void *s)
{
if (!gtkenabled) return 0;
//if (!startwin) return 1;
gtk_main_iteration_do (FALSE);
gtk_main_iteration_do(FALSE);
return 0;
}
@ -532,7 +540,8 @@ int startwin_run(void)
gtk_main();
SetPage(TAB_MESSAGES);
if (retval) {
if (retval)
{
fullscreen = settings.fullscreen;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;

View file

@ -18,7 +18,8 @@
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct {
static struct
{
int fullscreen;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
@ -38,10 +39,12 @@ static void PopulateForm(void)
hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE);
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 };
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);
if (mode3d < 0) continue;
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));
ComboBox_ResetContent(hwnd3d);
for (i=0; i<validmodecnt; i++) {
for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue;
// 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)
{
switch (uMsg) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen;
PopulateForm();
return TRUE;
case IDC3DVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE) {
int i;
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) {
settings.xdim3d = validmode[i].xdim;
settings.ydim3d = validmode[i].ydim;
settings.bpp3d = validmode[i].bpp;
}
}
return TRUE;
case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE;
default: break;
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen;
PopulateForm();
return TRUE;
case IDC3DVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
int i;
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR)
{
settings.xdim3d = validmode[i].xdim;
settings.ydim3d = validmode[i].ydim;
settings.bpp3d = validmode[i].bpp;
}
}
break;
return TRUE;
case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE;
default: break;
}
break;
default: break;
}
return FALSE;
}
@ -125,162 +133,171 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
static HBITMAP hbmp = NULL;
HDC hdc;
switch (uMsg) {
case WM_INITDIALOG: {
HWND hwnd;
RECT r, rdlg, chrome, rtab, rcancel, rstart;
int xoffset = 0, yoffset = 0;
switch (uMsg)
{
case WM_INITDIALOG:
{
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
ZeroMemory(&chrome, sizeof(chrome));
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
GetWindowRect(hwndDlg, &rdlg);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
// Fetch the positions (in screen coordinates) of all the windows we need to tweak
ZeroMemory(&chrome, sizeof(chrome));
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
GetWindowRect(hwndDlg, &rdlg);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
// Knock off the non-client area of the main dialogue to give just the client area
rdlg.left -= chrome.left; rdlg.top -= chrome.top;
rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom;
// 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.right -= chrome.right; rdlg.bottom -= chrome.bottom;
// Translate them to client-relative coordinates wrt the main dialogue window
rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left; rtab.top -= rdlg.top;
// Translate them to client-relative coordinates wrt the main dialogue window
rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left; rtab.top -= rdlg.top;
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left; rstart.top -= rdlg.top;
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left; rstart.top -= rdlg.top;
// And then convert the main dialogue coordinates to just width/length
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0; rdlg.top = 0;
// And then convert the main dialogue coordinates to just width/length
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0; rdlg.top = 0;
// Load the bitmap into the bitmap control and fetch its dimensions
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
// Load the bitmap into the bitmap control and fetch its dimensions
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
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);
xoffset = r.right;
yoffset = r.bottom - rdlg.bottom;
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;
// 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;
// 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);
// 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);
// 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);
// 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);
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
}
return FALSE;
}
// Add tabs to the tab control
{
TCITEM tab;
case WM_NOTIFY:
{
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));
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);
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_DESTROY:
if (hbmp)
{
DeleteObject(hbmp);
hbmp = NULL;
}
case WM_NOTIFY: {
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;
if (pages[TAB_CONFIG])
{
DestroyWindow(pages[TAB_CONFIG]);
pages[TAB_CONFIG] = NULL;
}
case WM_CLOSE:
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_DESTROY:
if (hbmp) {
DeleteObject(hbmp);
hbmp = NULL;
}
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == pages[TAB_MESSAGES])
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
break;
if (pages[TAB_CONFIG]) {
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;
default: break;
}
return FALSE;
@ -295,7 +312,8 @@ int startwin_open(void)
icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) {
if (startupdlg)
{
SetPage(TAB_MESSAGES);
EnableConfig(0);
return 0;
@ -332,25 +350,33 @@ int startwin_puts(const char *buf)
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf;
while (*p) {
if (newline) {
while (*p)
{
if (newline)
{
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
newline = 0;
}
q = p;
while (*q && *q != '\n') q++;
memcpy(workbuf, p, q-p);
if (*q == '\n') {
if (!q[1]) {
if (*q == '\n')
{
if (!q[1])
{
newline = 1;
workbuf[q-p] = 0;
} else {
}
else
{
workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0;
}
p = q+1;
} else {
}
else
{
workbuf[q-p] = 0;
p = q;
}
@ -372,7 +398,7 @@ int startwin_settitle(const char *str)
int startwin_idle(void *v)
{
if (!startupdlg || !IsWindow(startupdlg)) return 0;
if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
if (IsDialogMessage(startupdlg, (MSG *)v)) return 1;
return 0;
}
@ -395,21 +421,24 @@ int startwin_run(void)
settings.forcesetup = forcesetup;
PopulateForm();
while (done < 0) {
switch (GetMessage(&msg, NULL, 0,0)) {
case 0: done = 1; break;
case -1: return -1;
default:
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
while (done < 0)
{
switch (GetMessage(&msg, NULL, 0,0))
{
case 0: done = 1; break;
case -1: return -1;
default:
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
}
}
SetPage(TAB_MESSAGES);
EnableConfig(0);
if (done) {
if (done)
{
fullscreen = settings.fullscreen;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;