New startup window from JonoF + some other stuff

This was not at all pleasant to merge, and problems should be expected. ;)


git-svn-id: https://svn.eduke32.com/eduke32@194 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-07-01 01:40:18 +00:00
parent 0d61f3bc55
commit 42b4208d1e
65 changed files with 5852 additions and 2097 deletions

View file

@ -82,7 +82,6 @@ ENGINEOBJS+= \
$(OBJ)crc32.$o \
$(OBJ)defs.$o \
$(OBJ)engine.$o \
$(OBJ)engineinfo.$o \
$(OBJ)glbuild.$o \
$(OBJ)kplib.$o \
$(OBJ)lzf_c.$o \
@ -139,7 +138,8 @@ ifeq ($(RENDERTYPE),SDL)
ifeq (1,$(HAVE_GTK2))
OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0)
ENGINEOBJS+= $(OBJ)gtkbits.$o
GAMEEXEOBJS+= $(OBJ)game_banner.$o
EDITOROBJS+= $(OBJ)startgtk.editor.$o
GAMEEXEOBJS+= $(OBJ)game_banner.$o $(OBJ)startgtk.game.$o
EDITOREXEOBJS+= $(OBJ)editor_banner.$o
endif
@ -148,8 +148,8 @@ ifeq ($(RENDERTYPE),SDL)
endif
ifeq ($(RENDERTYPE),WIN)
ENGINEOBJS+= $(OBJ)winlayer.$o
EDITOROBJS+= $(OBJ)buildstartwin.$o
GAMEEXEOBJS+= $(OBJ)gameres.$(res) $(OBJ)gamestartwin.$o
EDITOROBJS+= $(OBJ)startwin.editor.$o
GAMEEXEOBJS+= $(OBJ)gameres.$(res) $(OBJ)startwin.game.$o
EDITOREXEOBJS+= $(OBJ)buildres.$(res)
endif
@ -160,7 +160,7 @@ endif
OURCFLAGS+= $(BUILDCFLAGS)
.PHONY: clean veryclean all utils writeengineinfo enginelib editorlib
.PHONY: clean veryclean all utils enginelib editorlib
# TARGETS
@ -221,15 +221,6 @@ enumdisplay$(EXESUFFIX): src/misc/enumdisplay.c
# DEPENDENCIES
include Makefile.deps
.PHONY: $(OBJ)engineinfo.$o
$(OBJ)engineinfo.$o:
echo "const char _engine_cflags[] = \"$(CFLAGS) $(OURCFLAGS)\";" > $(SRC)tmp/engineinfo.c
echo "const char _engine_libs[] = \"$(LIBS)\";" >> $(SRC)tmp/engineinfo.c
echo "const char _engine_uname[] = \"$(shell uname -a)\";" >> $(SRC)tmp/engineinfo.c
echo "const char _engine_compiler[] = \"$(CC) $(shell $(CC) -dumpversion) $(shell $(CC) -dumpmachine)\";" >> $(SRC)tmp/engineinfo.c
echo "const char _engine_date[] = __DATE__ \" \" __TIME__;" >> $(SRC)tmp/engineinfo.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $(SRC)tmp/engineinfo.c -o $@ 2>&1
# RULES
$(OBJ)%.$o: $(SRC)%.nasm
$(AS) $(ASFLAGS) $< -o $@
@ -244,7 +235,7 @@ $(OBJ)%.$o: $(SRC)tmp/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(OBJ)%.$o: $(SRC)misc/%.rc
$(RC) -i $^ -o $@
$(RC) -i $< -o $@ --include-dir=$(INC) --include-dir=$(SRC)
$(OBJ)%.$o: $(SRC)util/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1

View file

@ -21,7 +21,7 @@ $(OBJ)lzwnew.$o: $(SRC)lzwnew.c
$(OBJ)md4.$o: $(SRC)md4.c $(INC)md4.h $(INC)compat.h
$(OBJ)mmulti_null.$o: $(SRC)mmulti_null.c $(INC)mmulti.h
$(OBJ)mmulti.$o: $(SRC)mmulti.c
$(OBJ)osd.$o: $(SRC)osd.c $(INC)build.h $(INC)osd.h $(INC)compat.h $(INC)engineinfo.h $(INC)baselayer.h
$(OBJ)osd.$o: $(SRC)osd.c $(INC)build.h $(INC)osd.h $(INC)compat.h $(INC)baselayer.h
$(OBJ)pragmas.$o: $(SRC)pragmas.c $(INC)compat.h
$(OBJ)scriptfile.$o: $(SRC)scriptfile.c $(INC)scriptfile.h $(INC)cache1d.h $(INC)compat.h
$(OBJ)sdlayer.$o: $(SRC)sdlayer.c $(INC)compat.h $(INC)sdlayer.h $(INC)baselayer.h $(INC)cache1d.h $(INC)pragmas.h $(INC)a.h $(INC)build.h $(INC)osd.h $(INC)glbuild.h
@ -29,10 +29,12 @@ $(OBJ)sound.$o: $(SRC)sound.c $(INC)osd.h $(INC)compat.h $(INC)cache1d.h
$(OBJ)winlayer.$o: $(SRC)winlayer.c $(INC)compat.h $(INC)winlayer.h $(INC)baselayer.h $(INC)pragmas.h $(INC)build.h $(INC)a.h $(INC)osd.h $(INC)dxdidf.h $(INC)glbuild.h
$(OBJ)gtkbits.$o: $(SRC)gtkbits.c $(INC)baselayer.h $(INC)build.h
$(OBJ)gameres.$(res): $(SRC)misc/gameres.rc
$(OBJ)buildres.$(res): $(SRC)misc/buildres.rc
$(OBJ)gamestartwin.$o: $(SRC)gamestartwin.c $(INC)winlayer.h $(INC)build.h $(INC)compat.h
$(OBJ)buildstartwin.$o: $(SRC)buildstartwin.c $(INC)winlayer.h $(INC)build.h $(INC)compat.h
$(OBJ)gameres.$(res): $(SRC)misc/gameres.rc $(SRC)startwin.game.h
$(OBJ)buildres.$(res): $(SRC)misc/buildres.rc $(INC)startwin.editor.h
$(OBJ)startwin.editor.$o: $(SRC)startwin.editor.c $(INC)build.h $(INC)editor.h $(INC)winlayer.h $(INC)compat.h $(INC)startwin.editor.h
$(OBJ)startwin.game.$o: $(SRC)startwin.game.c $(INC)build.h $(INC)editor.h $(INC)winlayer.h $(INC)compat.h $(SRC)startwin.game.h
$(OBJ)startgtk.editor.$o: $(SRC)startgtk.editor.c $(INC)baselayer.h $(INC)build.h $(INC)editor.h $(INC)compat.h
$(OBJ)startgtk.game.$o: $(SRC)startgtk.game.c $(INC)baselayer.h $(INC)build.h $(INC)compat.h
$(OBJ)game_icon.$o: $(RSRC)game_icon.c
$(OBJ)build_icon.$o: $(RSRC)build_icon.c

View file

@ -58,7 +58,6 @@ ENGINEOBJS=$(OBJ)a.$o \
$(OBJ)crc32.$o \
$(OBJ)defs.$o \
$(OBJ)engine.$o \
$(OBJ)engineinfo.$o \
$(OBJ)glbuild.$o \
$(OBJ)kplib.$o \
$(OBJ)lzf_c.$o \
@ -72,13 +71,13 @@ ENGINEOBJS=$(OBJ)a.$o \
$(OBJ)winlayer.$o
EDITOROBJS=$(OBJ)build.$o \
$(OBJ)buildstartwin.$o \
$(OBJ)startwin.editor.$o \
$(OBJ)config.$o
GAMEEXEOBJS=$(OBJ)config.$o \
$(OBJ)game.$o \
$(OBJ)gameres.$(res) \
$(OBJ)gamestartwin.$o \
$(OBJ)startwin.game.$o \
$(OBJ)sound.$o \
$(OBJ)$(ENGINELIB)
@ -149,17 +148,6 @@ wad2art$(EXESUFFIX): $(OBJ)wad2art.$o $(OBJ)pragmas.$o $(OBJ)compat.$o
# DEPENDENCIES
!include Makefile.deps
$(OBJ)engineinfo.$o: writeengineinfo $(SRC)tmp\engineinfo.c
writeengineinfo:
copy /y << $(SRC)tmp\engineinfo.c
const char _engine_cflags[] = "$(CFLAGS:\=\\)";
const char _engine_libs[] = "$(LIBS)";
const char _engine_uname[] = "unknown";
const char _engine_compiler[] = "$(CC)";
const char _engine_date[] = __DATE__ " " __TIME__;
<<NOKEEP
# PHONIES
clean:
-del $(ENGINEOBJS) $(EDITOROBJS) $(GAMEEXEOBJS) $(EDITOREXEOBJS)

View file

@ -58,7 +58,7 @@ endif
ifeq ($(PLATFORM),WINDOWS)
RENDERTYPE ?= WIN
EXESUFFIX=.exe
LIBS+= -lmingwex -lwinmm -L$(DXROOT)/lib -lwsock32 #-lshfolder
LIBS+= -lmingwex -lwinmm -L$(DXROOT)/lib -lwsock32 -lcomctl32 #-lshfolder
endif
ifeq ($(PLATFORM),BSD)
RENDERTYPE=SDL

View file

@ -52,7 +52,6 @@ ENGINEOBJS=$(OBJ)a.$o &
$(OBJ)crc32.$o &
$(OBJ)defs.$o &
$(OBJ)engine.$o &
$(OBJ)engineinfo.$o &
$(OBJ)glbuild.$o &
$(OBJ)kplib.$o &
$(OBJ)lzf_c.$o &
@ -67,12 +66,12 @@ ENGINEOBJS=$(OBJ)a.$o &
EDITOROBJS=$(OBJ)build.$o &
$(OBJ)config.$o &
$(OBJ)buildstartwin.$o
$(OBJ)startwin.editor.$o
GAMEEXEOBJS=$(OBJ)game.$o &
$(OBJ)sound.$o &
$(OBJ)config.$o &
$(OBJ)gamestartwin.$o
$(OBJ)startwin.game.$o
EDITOREXEOBJS=$(OBJ)bstub.$o
@ -159,15 +158,6 @@ wad2map$(EXESUFFIX): $(OBJ)wad2map.$o $(OBJ)pragmas.$o $(OBJ)compat.$o
# DEPENDENCIES
!include Makefile.deps
$(OBJ)engineinfo.$o: writeengineinfo $(SRC)tmp\engineinfo.c
writeengineinfo: .SYMBOLIC
echo const char _engine_cflags[] = "$(CFLAGS:\=\\)"; > $(SRC)tmp\engineinfo.c
echo const char _engine_libs[] = "$(LIBS:\=\\)"; >> $(SRC)tmp\engineinfo.c
echo const char _engine_uname[] = "unknown"; >> $(SRC)tmp\engineinfo.c
echo const char _engine_compiler[] = "$(CC)"; >> $(SRC)tmp\engineinfo.c
echo const char _engine_date[] = __DATE__ " " __TIME__; >> $(SRC)tmp\engineinfo.c
# PHONIES
clean: .SYMBOLIC
-erase /q $(OBJ)* game$(EXESUFFIX) build$(EXESUFFIX) $(UTILS) *.err

View file

@ -1,104 +0,0 @@
; Build editor configuration
; Video mode selection
; 0 - Windowed
; 1 - Fullscreen
fullscreen = 0
; Video resolution selection
; 0 - 320 x 200
; 1 - 360 x 200
; 2 - 320 x 240
; 3 - 360 x 240
; 4 - 320 x 400
; 5 - 360 x 400
; 6 - 640 x 350
; 7 - 640 x 400
; 8 - 640 x 480
; 9 - 800 x 600
; 10 - 1024 x 768
; 11 - 1280 x 1024
; 12 - 1600 x 1200
; You can select a seperate 2D editor resolution by
; removing the semicolon from the second line below
; and selecting a mode number. The minimum 2D mode
; is 640x480 (mode #8)
resolution = 8
;2dresolution = 8
; 3D-mode colour depth
bpp = 8
; Maximum OpenGL mode refresh rate (Windows only, in Hertz)
maxrefreshfreq = 60
; 3D mode brightness setting
; 0 - lowest
; 15 - highest
brightness = 0
; Sound sample frequency
; 0 - 6 KHz
; 1 - 8 KHz
; 2 - 11.025 KHz
; 3 - 16 KHz
; 4 - 22.05 KHz
; 5 - 32 KHz
; 6 - 44.1 KHz
samplerate = 4
; Music playback
; 0 - Off
; 1 - On
music = 1
; Enable mouse
; 0 - No
; 1 - Yes
mouse = 1
; Mouse sensitivity
mousesensitivity = 1.0
; Key Settings
; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!
; +---------------------------------------------------------------------------------------------+
; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 |
; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL |
; | |
; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A |
; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- |
; | |
; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E |
; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ |
; | |
; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D |
; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C |
; | KPENTER|
; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 |
; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 |
; | |
; | 1D 38 39 B8 9D CB D0 CD 52 53 |
; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |
; +---------------------------------------------------------------------------------------------+
keyforward = C8
keybackward = D0
keyturnleft = CB
keyturnright = CD
keyrun = 2A
keystrafe = 9D
keyfire = 1D
keyuse = 39
keystandhigh = 1E
keystandlow = 2C
keylookup = D1
keylookdown = C9
keystrafeleft = 33
keystraferight = 34
key2dmode = 9C
keyviewcycle = 1C
key2dzoomin = D
key2dzoomout = C
keychat = F

View file

@ -1,97 +0,0 @@
; KenBuild configuration
; Video mode selection
; 0 - Windowed
; 1 - Fullscreen
fullscreen = 0
; Video resolution selection
; 0 - 320 x 200
; 1 - 360 x 200
; 2 - 320 x 240
; 3 - 360 x 240
; 4 - 320 x 400
; 5 - 360 x 400
; 6 - 640 x 350
; 7 - 640 x 400
; 8 - 640 x 480
; 9 - 800 x 600
; 10 - 1024 x 768
; 11 - 1280 x 1024
; 12 - 1600 x 1200
resolution = 8
; 3D-mode colour depth
bpp = 8
; 3D mode brightness setting
; 0 - lowest
; 15 - highest
brightness = 0
; Maximum OpenGL mode refresh rate (Windows only, in Hertz)
maxrefreshfreq = 60
; Sound sample frequency
; 0 - 6 KHz
; 1 - 8 KHz
; 2 - 11.025 KHz
; 3 - 16 KHz
; 4 - 22.05 KHz
; 5 - 32 KHz
; 6 - 44.1 KHz
samplerate = 4
; Music playback
; 0 - Off
; 1 - On
music = 1
; Enable mouse
; 0 - No
; 1 - Yes
mouse = 1
; Key Settings
; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!
; +---------------------------------------------------------------------------------------------+
; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 |
; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL |
; | |
; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A |
; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- |
; | |
; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E |
; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ |
; | |
; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D |
; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C |
; | KPENTER|
; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 |
; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 |
; | |
; | 1D 38 39 B8 9D CB D0 CD 52 53 |
; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |
; +---------------------------------------------------------------------------------------------+
keyforward = C8
keybackward = D0
keyturnleft = CB
keyturnright = CD
keyrun = 2A
keystrafe = 9D
keyfire = 1D
keyuse = 39
keystandhigh = 1E
keystandlow = 2C
keylookup = D1
keylookdown = C9
keystrafeleft = 33
keystraferight = 34
key2dmode = 9C
keyviewcycle = 1C
key2dzoomin = D
key2dzoomout = C
keychat = F
keyconsole = 29

View file

@ -14,8 +14,13 @@ extern char **_buildargv;
extern char quitevent, appactive;
extern char *startwin_labeltext;
// NOTE: these are implemented in game-land so they may be overridden in game specific ways
extern int startwin_open(void);
extern int startwin_close(void);
extern int startwin_puts(const char *);
extern int startwin_settitle(const char *);
extern int startwin_idle(void *);
// video
extern long xres, yres, bpp, fullscreen, bytesperline, imageSize, frameplace;
extern char offscreenrendering;
@ -96,7 +101,7 @@ unsigned long getticks(void);
int gettimerfreq(void);
void (*installusertimercallback(void (*callback)(void)))(void);
int checkvideomode(int *x, int *y, int c, int fs);
int checkvideomode(int *x, int *y, int c, int fs, int forced);
int setvideomode(int x, int y, int c, int fs);
void getvalidmodes(void);
void resetvideomode(void);

View file

@ -411,6 +411,7 @@ char *Bgetenv(const char *name);
#endif
char *Bgethomedir(void);
char *Bgetsupportdir(int global);
unsigned int Bgetsysmemsize(void);
int Bcorrectfilename(char *filename, int removefn);
int Bcanonicalisefilename(char *filename, int removefn);

View file

@ -22,7 +22,7 @@ extern char somethingintab;
extern char buildkeys[NUMBUILDKEYS];
extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d;
extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d, forcesetup;
extern int ExtInit(void);

View file

@ -1,6 +0,0 @@
extern const char _engine_cflags[];
extern const char _engine_libs[];
extern const char _engine_uname[];
extern const char _engine_compiler[];
extern const char _engine_date[];

View file

@ -5,11 +5,5 @@ extern void gtkbuild_init(int *argc, char ***argv);
extern void gtkbuild_exit(int r);
extern int gtkbuild_msgbox(char *name, char *msg);
extern int gtkbuild_ynbox(char *name, char *msg);
extern void gtkbuild_create_startwin(void);
extern void gtkbuild_settitle_startwin(const char *title);
extern void gtkbuild_puts_startwin(const char *str);
extern void gtkbuild_close_startwin(void);
extern void gtkbuild_update_startwin(void);
extern void *gtkbuild_get_app_icon(void);
#endif

11
polymer/build/include/osxmain.h Executable file
View file

@ -0,0 +1,11 @@
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
Feel free to customize this file to suit your needs
*/
#import <Cocoa/Cocoa.h>
@interface SDLMain : NSObject
@end

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
// resource ids
#define WIN_STARTWIN 1000
#define WIN_STARTWINPAGE_CONFIG 2000
#define WIN_STARTWIN_BITMAP 100 // banner bitmap
#define WIN_STARTWIN_TABCTL 101
#define WIN_STARTWIN_CANCEL 102
#define WIN_STARTWIN_START 103
#define WIN_STARTWIN_MESSAGES 104 // output list box
#define RSRC_ICON 100
#define RSRC_BMP 200
// config page
#define IDCFULLSCREEN 100
#define IDC2DVMODE 101
#define IDC3DVMODE 102
#define IDCALWAYSSHOW 103

View file

@ -13,37 +13,9 @@ extern int glusecds;
long win_gethwnd(void);
long win_gethinstance(void);
// resource ids
#define WIN_STARTWIN 1000
#define WIN_STARTWIN_ITEMBITMAP 100 // banner bitmap
#define WIN_STARTWIN_ITEMTEXT 101 // text header
#define WIN_STARTWIN_ITEMLIST 102 // output list box
#define WIN_STARTWINBMP 200
// *hwnd - receives the window handle to the startup dialog box
// saferect[] - receives the safe area to draw controls over (l,t,w,h)
// onclose - called before the startup window closes
// returns 0 if successful, 1 if the window isn't open
int win_getstartupwin(long *hwnd, long saferect[4], void (*onclose)(void));
int win_getstartupcommand(void);
void win_allowtaskswitching(int onf);
int win_checkinstance(void);
/*
#ifdef KENBUILD
#define DISCLAIMER "IMPORTANT:\n" \
"\tThis is a source port by Jonathon Fowler (jonof@edgenetwk.com) of the Build Engine, " \
"editor and test game by Ken Silverman to the Windows and Linux operating systems. It is " \
"distributed under the terms listed in BUILDLIC.TXT included with this package."
#endif
#ifdef DUKE3D
#define DISCLAIMER "IMPORTANT:\n" \
"\tThis port of Duke Nukem 3D was done by Jonathon Fowler (jonof@edgenetwk.com) and is not " \
"endorsed or supported by 3D Realms or Apogee. They will not provide support for it. Visit " \
"http://jonof.edgenetwk.com/buildport/duke3d/ for details."
#endif
*/
#include "baselayer.h"
#else

View file

@ -0,0 +1,189 @@
#import <Cocoa/Cocoa.h>
#include "baselayer.h"
@interface StartupWinController : NSWindowController
{
IBOutlet NSButton *alwaysShowButton;
IBOutlet NSButton *fullscreenButton;
IBOutlet NSTextView *messagesView;
IBOutlet NSTabView *tabView;
IBOutlet NSComboBox *videoModeCbox;
IBOutlet NSButton *cancelButton;
IBOutlet NSButton *startButton;
}
- (IBAction)alwaysShowClicked:(id)sender;
- (IBAction)fullscreenClicked:(id)sender;
- (IBAction)cancel:(id)sender;
- (IBAction)start:(id)sender;
- (void)setupRunMode;
- (void)setupMessagesMode;
- (void)putsMessage:(NSString *)str;
- (void)setTitle:(NSString *)str;
@end
@implementation StartupWinController
- (IBAction)alwaysShowClicked:(id)sender
{
}
- (IBAction)fullscreenClicked:(id)sender
{
// XXX: recalculate the video modes list to take into account the fullscreen status
}
- (IBAction)cancel:(id)sender
{
[NSApp abortModal];
}
- (IBAction)start:(id)sender
{
// XXX: write the states of the form controls to their respective homes
[NSApp stopModal];
}
- (void)setupRunMode
{
// XXX: populate the lists and set everything up to represent the current options
// enable all the controls on the Configuration page
NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator];
NSControl *control;
while (control = [enumerator nextObject])
[control setEnabled:true];
[cancelButton setEnabled:true];
[startButton setEnabled:true];
[tabView selectTabViewItemAtIndex:0];
}
- (void)setupMessagesMode
{
[tabView selectTabViewItemAtIndex:1];
// disable all the controls on the Configuration page except "always show", so the
// 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]) {
if (control == alwaysShowButton) continue;
[control setEnabled:false];
}
[cancelButton setEnabled:false];
[startButton setEnabled:false];
}
- (void)putsMessage:(NSString *)str
{
NSRange end;
NSTextStorage *text = [messagesView textStorage];
BOOL shouldAutoScroll;
shouldAutoScroll = ((int)NSMaxY([messagesView bounds]) == (int)NSMaxY([messagesView visibleRect]));
end.location = [text length];
end.length = 0;
[text beginEditing];
[messagesView replaceCharactersInRange:end withString:str];
[text endEditing];
if (shouldAutoScroll) {
end.location = [text length];
end.length = 0;
[messagesView scrollRangeToVisible:end];
}
}
- (void)setTitle:(NSString *)str
{
[[self window] setTitle:str];
}
@end
static StartupWinController *startwin = nil;
int startwin_open(void)
{
if (startwin != nil) return 1;
startwin = [[StartupWinController alloc] initWithWindowNibName:@"startwin.editor"];
if (startwin == nil) return -1;
[startwin showWindow:nil];
[startwin setupMessagesMode];
return 0;
}
int startwin_close(void)
{
if (startwin == nil) return 1;
[startwin close];
startwin = nil;
return 0;
}
int startwin_puts(const char *s)
{
NSString *ns;
if (!s) return -1;
if (startwin == nil) return 1;
ns = [[NSString alloc] initWithCString:s];
[startwin putsMessage:ns];
[ns release];
return 0;
}
int startwin_settitle(const char *s)
{
NSString *ns;
if (!s) return -1;
if (startwin == nil) return 1;
ns = [[NSString alloc] initWithCString:s];
[startwin setTitle:ns];
[ns release];
return 0;
}
int startwin_idle(void *v)
{
if (startwin) [[startwin window] displayIfNeeded];
return 0;
}
int startwin_run(void)
{
int retval;
if (startwin == nil) return 0;
[startwin setupRunMode];
switch ([NSApp runModalForWindow:[startwin window]]) {
case NSRunStoppedResponse: retval = 1; break;
case NSRunAbortedResponse: retval = 0; break;
default: retval = -1;
}
[startwin setupMessagesMode];
return retval;
}

View file

@ -0,0 +1,189 @@
#import <Cocoa/Cocoa.h>
#include "baselayer.h"
@interface StartupWinController : NSWindowController
{
IBOutlet NSButton *alwaysShowButton;
IBOutlet NSButton *fullscreenButton;
IBOutlet NSTextView *messagesView;
IBOutlet NSTabView *tabView;
IBOutlet NSComboBox *videoModeCbox;
IBOutlet NSButton *cancelButton;
IBOutlet NSButton *startButton;
}
- (IBAction)alwaysShowClicked:(id)sender;
- (IBAction)fullscreenClicked:(id)sender;
- (IBAction)cancel:(id)sender;
- (IBAction)start:(id)sender;
- (void)setupRunMode;
- (void)setupMessagesMode;
- (void)putsMessage:(NSString *)str;
- (void)setTitle:(NSString *)str;
@end
@implementation StartupWinController
- (IBAction)alwaysShowClicked:(id)sender
{
}
- (IBAction)fullscreenClicked:(id)sender
{
// XXX: recalculate the video modes list to take into account the fullscreen status
}
- (IBAction)cancel:(id)sender
{
[NSApp abortModal];
}
- (IBAction)start:(id)sender
{
// XXX: write the states of the form controls to their respective homes
[NSApp stopModal];
}
- (void)setupRunMode
{
// XXX: populate the lists and set everything up to represent the current options
// enable all the controls on the Configuration page
NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator];
NSControl *control;
while (control = [enumerator nextObject])
[control setEnabled:true];
[cancelButton setEnabled:true];
[startButton setEnabled:true];
[tabView selectTabViewItemAtIndex:0];
}
- (void)setupMessagesMode
{
[tabView selectTabViewItemAtIndex:1];
// disable all the controls on the Configuration page except "always show", so the
// 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]) {
if (control == alwaysShowButton) continue;
[control setEnabled:false];
}
[cancelButton setEnabled:false];
[startButton setEnabled:false];
}
- (void)putsMessage:(NSString *)str
{
NSRange end;
NSTextStorage *text = [messagesView textStorage];
BOOL shouldAutoScroll;
shouldAutoScroll = ((int)NSMaxY([messagesView bounds]) == (int)NSMaxY([messagesView visibleRect]));
end.location = [text length];
end.length = 0;
[text beginEditing];
[messagesView replaceCharactersInRange:end withString:str];
[text endEditing];
if (shouldAutoScroll) {
end.location = [text length];
end.length = 0;
[messagesView scrollRangeToVisible:end];
}
}
- (void)setTitle:(NSString *)str
{
[[self window] setTitle:str];
}
@end
static StartupWinController *startwin = nil;
int startwin_open(void)
{
if (startwin != nil) return 1;
startwin = [[StartupWinController alloc] initWithWindowNibName:@"startwin.game"];
if (startwin == nil) return -1;
[startwin showWindow:nil];
[startwin setupMessagesMode];
return 0;
}
int startwin_close(void)
{
if (startwin == nil) return 1;
[startwin close];
startwin = nil;
return 0;
}
int startwin_puts(const char *s)
{
NSString *ns;
if (!s) return -1;
if (startwin == nil) return 1;
ns = [[NSString alloc] initWithCString:s];
[startwin putsMessage:ns];
[ns release];
return 0;
}
int startwin_settitle(const char *s)
{
NSString *ns;
if (!s) return -1;
if (startwin == nil) return 1;
ns = [[NSString alloc] initWithCString:s];
[startwin setTitle:ns];
[ns release];
return 0;
}
int startwin_idle(void *v)
{
if (startwin) [[startwin window] displayIfNeeded];
return 0;
}
int startwin_run(void)
{
int retval;
if (startwin == nil) return 0;
[startwin setupRunMode];
switch ([NSApp runModalForWindow:[startwin window]]) {
case NSRunStoppedResponse: retval = 1; break;
case NSRunAbortedResponse: retval = 0; break;
default: retval = -1;
}
[startwin setupMessagesMode];
return retval;
}

View file

@ -1,7 +1,6 @@
#include "compat.h"
#include "osd.h"
#include "build.h"
#include "engineinfo.h"
#include "baselayer.h"
#ifdef RENDERTYPEWIN
@ -25,24 +24,6 @@ struct glinfo glinfo = {
};
#endif
static int osdfunc_dumpbuildinfo(const osdfuncparm_t *parm)
{
OSD_Printf(
"Build engine compilation:\n"
" CFLAGS: %s\n"
" LIBS: %s\n"
" Host: %s\n"
" Compiler: %s\n"
" Built: %s\n",
_engine_cflags,
_engine_libs,
_engine_uname,
_engine_compiler,
_engine_date);
return OSDCMD_OK;
}
static void onvideomodechange(int newmode) { }
void (*baselayer_onvideomodechange)(int) = onvideomodechange;
@ -188,7 +169,6 @@ int baselayer_init(void)
,
osdfunc_setrendermode);
#endif
OSD_RegisterFunction("dumpbuildinfo","dumpbuildinfo: outputs engine compilation information",osdfunc_dumpbuildinfo);
OSD_RegisterFunction("screencaptureformat","screencaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars);
#ifdef SUPERBUILD
OSD_RegisterFunction("novoxmips","novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",osdcmd_vars);

View file

@ -81,6 +81,7 @@ extern long startposx, startposy, startposz;
extern short startang, startsectnum;
extern long frameplace, ydim16, halfxdim16, midydim16;
long xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8;
long forcesetup = 1;
extern long cachesize, artsize;
@ -237,14 +238,12 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
#ifdef RENDERTYPEWIN
int DoLaunchWindow(int initval); // buildstartwin.c
#endif
extern int startwin_run(void);
extern char *defsfilename; // set in bstub.c
int app_main(int argc, char **argv)
{
char ch, quitflag, forcesetup = 0, grpstoadd = 0;
char ch, quitflag, cmdsetup = 0, grpstoadd = 0;
char **grps = NULL;
long i, j, k;
@ -267,7 +266,7 @@ int app_main(int argc, char **argv)
boardfilename[0] = 0;
for (i=1; i<argc; i++) {
if (argv[i][0] == '-') {
if (!strcmp(argv[i], "-setup")) forcesetup = 1;
if (!strcmp(argv[i], "-setup")) cmdsetup = 1;
else if (!strcmp(argv[i], "-g") || !strcmp(argv[i], "-grp")) {
i++;
grps = (char**)realloc(grps, sizeof(char*)*(grpstoadd+1));
@ -280,11 +279,11 @@ int app_main(int argc, char **argv)
"Options:\n"
"\t-grp\tUse an extra GRP or ZIP file.\n"
"\t-g\tSame as above.\n"
#ifdef RENDERTYPEWIN
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
"\t-setup\tDisplays the configuration dialogue box before entering the editor.\n"
#endif
;
#ifdef RENDERTYPEWIN
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
wm_msgbox("Mapster32",s);
#else
puts(s);
@ -306,8 +305,10 @@ int app_main(int argc, char **argv)
//Bcanonicalisefilename(boardfilename,0);
if ((i = ExtInit()) < 0) return -1;
#ifdef RENDERTYPEWIN
if (DoLaunchWindow(i|forcesetup)) return -1;
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
if (i || forcesetup || cmdsetup) {
if (!startwin_run()) return -1;
}
#endif
if (grps && grpstoadd > 0) {

View file

@ -1,178 +0,0 @@
#ifndef RENDERTYPEWIN
#error Only for Windows
#endif
#include "build.h"
#include "editor.h"
#include "winlayer.h"
#include "compat.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#define IDCFULLSCREEN 100
#define IDC2DVMODE 101
#define IDC3DVMODE 102
static void PopulateVideoModeLists(int fs, HWND list2d, HWND list3d)
{
int i,j;
char buf[64];
ComboBox_ResetContent(list2d);
ComboBox_ResetContent(list3d);
for (i=0; i<validmodecnt; i++) {
if (validmode[i].fs != fs) continue;
// all modes get added to the 3D mode list
Bsprintf(buf, "%ldx%ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
j = ComboBox_AddString(list3d, buf);
ComboBox_SetItemData(list3d, j, i);
if (xdimgame == validmode[i].xdim && ydimgame == validmode[i].ydim && bppgame == validmode[i].bpp)
ComboBox_SetCurSel(list3d, j);
// only 8-bit modes get used for 2D
if (validmode[i].bpp != 8) continue;
Bsprintf(buf, "%ldx%ld", validmode[i].xdim, validmode[i].ydim);
j = ComboBox_AddString(list2d, buf);
ComboBox_SetItemData(list2d, j, i);
if (xdim2d == validmode[i].xdim && ydim2d == validmode[i].ydim && 8 == validmode[i].bpp)
ComboBox_SetCurSel(list2d, j);
}
}
static INT_PTR CALLBACK LaunchWindowProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG: {
char buf[64];
if (lParam) {
long *saferect = (long*)lParam;
RECT unresized, playbutton, exitbutton;
int dx, dy;
GetWindowRect(hwndDlg, &unresized);
GetWindowRect(GetDlgItem(hwndDlg, IDOK), &playbutton);
GetWindowRect(GetDlgItem(hwndDlg, IDCANCEL), &exitbutton);
playbutton.right = 1 + playbutton.right - playbutton.left;
playbutton.bottom = 1 + playbutton.bottom - playbutton.top;
exitbutton.right = 1 + exitbutton.right - exitbutton.left;
exitbutton.bottom = 1 + exitbutton.bottom - exitbutton.top;
playbutton.left = playbutton.left - unresized.left;
playbutton.top = playbutton.top - unresized.top;
exitbutton.left = exitbutton.left - unresized.left;
exitbutton.top = exitbutton.top - unresized.top;
dx = saferect[2] - (unresized.right - unresized.left);
dy = saferect[3] - (unresized.bottom - unresized.top);
playbutton.left += dx; exitbutton.left += dx;
playbutton.top += dy; exitbutton.top += dy;
// reposition the dialog, play and exit buttons
MoveWindow(hwndDlg, saferect[0], saferect[1], saferect[2], saferect[3], FALSE);
MoveWindow(GetDlgItem(hwndDlg, IDOK),
playbutton.left, playbutton.top, playbutton.right, playbutton.bottom, FALSE);
MoveWindow(GetDlgItem(hwndDlg, IDCANCEL),
exitbutton.left, exitbutton.top, exitbutton.right, exitbutton.bottom, FALSE);
}
// populate the controls
Button_SetCheck(GetDlgItem(hwndDlg, IDCFULLSCREEN), fullscreen ? BST_CHECKED : BST_UNCHECKED);
PopulateVideoModeLists(fullscreen, GetDlgItem(hwndDlg, IDC2DVMODE), GetDlgItem(hwndDlg, IDC3DVMODE));
ShowWindow(hwndDlg, SW_SHOW);
/*
if (GetDlgCtrlID((HWND)wParam) != IDOK) {
SetFocus(GetDlgItem(hwndDlg, IDOK));
return FALSE;
}
*/
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCFULLSCREEN:
fullscreen = Button_GetCheck((HWND)lParam) == BST_CHECKED ? 1:0;
PopulateVideoModeLists(fullscreen, GetDlgItem(hwndDlg, IDC2DVMODE),
GetDlgItem(hwndDlg, IDC3DVMODE));
break;
case IDC2DVMODE:
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) {
xdim2d = validmode[i].xdim;
ydim2d = validmode[i].ydim;
}
}
break;
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) {
xdimgame = validmode[i].xdim;
ydimgame = validmode[i].ydim;
bppgame = validmode[i].bpp;
}
}
break;
case IDCANCEL:
quitevent = 1; // fall through
case IDOK:
DestroyWindow(hwndDlg);
return TRUE;
default: break;
}
break;
default: break;
}
return FALSE;
}
int DoLaunchWindow(int initval)
{
HWND hwndStart, hwndLaunch;
MSG msg;
long saferect[4];
int x;
// only show config window if no config is loaded, or if it is, only if left control is held
if (initval == 0 /*&& !GetAsyncKeyState(VK_CONTROL)*/) return 0;
if (win_getstartupwin((long*)&hwndStart, saferect, NULL)) return 0;
hwndLaunch = CreateDialogParam((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(2000), hwndStart, LaunchWindowProc, (LPARAM)saferect);
if (hwndLaunch) {
EnableWindow(GetDlgItem(hwndStart,WIN_STARTWIN_ITEMLIST),FALSE);
#if 0
while (GetMessage(&msg, NULL, 0, 0) > 0) {
if (!IsWindow(hwndLaunch) || quitevent) break;
if (IsDialogMessage(hwndStart, &msg) /*|| IsDialogMessage(hwndLaunch, &msg)*/) continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
#else
while (IsWindow(hwndLaunch) && !quitevent) {
x = win_getstartupcommand();
if (x != 0) LaunchWindowProc(hwndLaunch, WM_COMMAND, x, 0);
handleevents();
}
#endif
EnableWindow(GetDlgItem(hwndStart,WIN_STARTWIN_ITEMLIST),TRUE);
}
if (quitevent) return 1;
return 0;
}

View file

@ -26,6 +26,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __APPLE__
# include <CoreFoundation/CoreFoundation.h>
# include <CoreServices/CoreServices.h>
#endif
#if defined(__WATCOMC__)
# include <direct.h>
#elif defined(_MSC_VER)
@ -327,15 +332,25 @@ char *Bgethomedir(void)
#ifdef _WIN32
TCHAR appdata[MAX_PATH];
//# if defined SHGetFolderPath
// if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, appdata)))
//# if defined SHGetSpecialFolderPath
if (SUCCEEDED(SHGetSpecialFolderPathA(NULL, appdata, CSIDL_APPDATA, FALSE)))
//# else
//# error Cannot find SHGetFolderPath or SHGetSpecialFolderPath. Perhaps your shlobj.h is ancient?
//# endif
return strdup(appdata);
return NULL;
#elif defined __APPLE__
FSRef ref;
CFStringRef str;
CFURLRef base;
char *s;
if (FSFindFolder(kUserDomain, kVolumeRootFolderType, kDontCreateFolder, &ref) < 0) return NULL;
base = CFURLCreateFromFSRef(NULL, &ref);
if (!base) return NULL;
str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);
CFRelease(base);
if (!str) return NULL;
s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding());
if (s) s = strdup(s);
CFRelease(str);
return s;
#else
char *e = getenv("HOME");
if (!e) return NULL;
@ -343,6 +358,31 @@ char *Bgethomedir(void)
#endif
}
char *Bgetsupportdir(int global)
{
#ifndef __APPLE__
return Bgethomedir();
#else
FSRef ref;
CFStringRef str;
CFURLRef base;
char *s;
if (FSFindFolder(global ? kLocalDomain : kUserDomain,
kApplicationSupportFolderType,
kDontCreateFolder, &ref) < 0) return NULL;
base = CFURLCreateFromFSRef(NULL, &ref);
if (!base) return NULL;
str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);
CFRelease(base);
if (!str) return NULL;
s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding());
if (s) s = strdup(s);
CFRelease(str);
return s;
#endif
}
int Bcorrectfilename(char *filename, int removefn)
{
char *fn;

View file

@ -106,6 +106,7 @@ int loadsetup(const char *fn)
if ((fp = Bfopen(fn, "rt")) == NULL) return -1;
if (readconfig(fp, "forcesetup", val, VL) > 0) { if (Batoi(val) != 0) forcesetup = 1; else forcesetup = 0; }
if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; }
if (readconfig(fp, "resolution", val, VL) > 0) {
i = Batoi(val) & 0x0f;
@ -195,6 +196,11 @@ 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 = %ld\n"
"\n"
"; Video mode selection\n"
"; 0 - Windowed\n"
"; 1 - Fullscreen\n"
@ -292,7 +298,7 @@ int writesetup(const char *fn)
"keyconsole = %X\n"
"\n",
fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame,
forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame,
#if defined(POLYMOST) && defined(USE_OPENGL)
glusetexcache, glusetexcachecompression,
#endif

View file

@ -123,77 +123,7 @@ static char kensmessage[128];
char *engineerrstr = "No error";
#if defined(NOASM)
static inline unsigned long nsqrtasm(unsigned long a)
{ // JBF 20030901: This was a damn lot simpler to reverse engineer than
// msqrtasm was. Really, it was just like simplifying an algebra equation.
unsigned short c;
if (a & 0xff000000) { // test eax, 0xff000000 / jnz short over24
c = shlookup[(a >> 24) + 4096]; // mov ebx, eax
// over24: shr ebx, 24
// mov cx, word ptr shlookup[ebx*2+8192]
} else {
c = shlookup[a >> 12]; // mov ebx, eax
// shr ebx, 12
// mov cx, word ptr shlookup[ebx*2]
// jmp short under24
}
a >>= c&0xff; // under24: shr eax, cl
a = (a&0xffff0000)|(sqrtable[a]); // mov ax, word ptr sqrtable[eax*2]
a >>= ((c&0xff00) >> 8); // mov cl, ch
// shr eax, cl
return a;
}
static inline long msqrtasm(unsigned long c)
{
unsigned long a,b;
a = 0x40000000l; // mov eax, 0x40000000
b = 0x20000000l; // mov ebx, 0x20000000
do { // begit:
if (c >= a) { // cmp ecx, eax / jl skip
c -= a; // sub ecx, eax
a += b*4; // lea eax, [eax+ebx*4]
} // skip:
a -= b; // sub eax, ebx
a >>= 1; // shr eax, 1
b >>= 2; // shr ebx, 2
} while (b); // jnz begit
if (c >= a) // cmp ecx, eax
a++; // sbb eax, -1
a >>= 1; // shr eax, 1
return a;
}
static inline void setgotpic(long tilenume)
{
if (walock[tilenume] < 200) walock[tilenume] = 199;
gotpic[tilenume>>3] |= pow2char[tilenume&7];
}
static inline long krecipasm(long i)
{ // Ken did this
float f = (float)i; i = *(long *)&f;
return((reciptable[(i>>12)&2047]>>(((i-0x3f800000)>>23)&31))^(i>>31));
}
static inline long getclipmask(long a, long b, long c, long d)
{ // Ken did this
d = ((a<0)*8) + ((b<0)*4) + ((c<0)*2) + (d<0);
return(((d<<4)^0xf0)|d);
}
inline long getkensmessagecrc(long b)
{
return 0x56c764d4l;
b=b;
}
#elif defined(__WATCOMC__)
#if defined(__WATCOMC__) && !defined(NOASM)
//
// Watcom Inline Assembly Routines
@ -297,7 +227,7 @@ long getclipmask(long,long,long,long);
modify exact [eax ebx ecx edx]
long getkensmessagecrc(long);
#elif defined(_MSC_VER) // __WATCOMC__
#elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__
//
// Microsoft C Inline Assembly Routines
@ -434,7 +364,7 @@ static inline long getkensmessagecrc(void *b)
}
}
#elif defined(__GNUC__) && defined(__i386__) // _MSC_VER
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // _MSC_VER
//
// GCC "Inline" Assembly Routines
@ -539,7 +469,73 @@ static inline long getkensmessagecrc(void *b)
#else // __GNUC__ && __i386__
#error Unsupported compiler or architecture.
static inline unsigned long nsqrtasm(unsigned long a)
{ // JBF 20030901: This was a damn lot simpler to reverse engineer than
// msqrtasm was. Really, it was just like simplifying an algebra equation.
unsigned short c;
if (a & 0xff000000) { // test eax, 0xff000000 / jnz short over24
c = shlookup[(a >> 24) + 4096]; // mov ebx, eax
// over24: shr ebx, 24
// mov cx, word ptr shlookup[ebx*2+8192]
} else {
c = shlookup[a >> 12]; // mov ebx, eax
// shr ebx, 12
// mov cx, word ptr shlookup[ebx*2]
// jmp short under24
}
a >>= c&0xff; // under24: shr eax, cl
a = (a&0xffff0000)|(sqrtable[a]); // mov ax, word ptr sqrtable[eax*2]
a >>= ((c&0xff00) >> 8); // mov cl, ch
// shr eax, cl
return a;
}
static inline long msqrtasm(unsigned long c)
{
unsigned long a,b;
a = 0x40000000l; // mov eax, 0x40000000
b = 0x20000000l; // mov ebx, 0x20000000
do { // begit:
if (c >= a) { // cmp ecx, eax / jl skip
c -= a; // sub ecx, eax
a += b*4; // lea eax, [eax+ebx*4]
} // skip:
a -= b; // sub eax, ebx
a >>= 1; // shr eax, 1
b >>= 2; // shr ebx, 2
} while (b); // jnz begit
if (c >= a) // cmp ecx, eax
a++; // sbb eax, -1
a >>= 1; // shr eax, 1
return a;
}
static inline void setgotpic(long tilenume)
{
if (walock[tilenume] < 200) walock[tilenume] = 199;
gotpic[tilenume>>3] |= pow2char[tilenume&7];
}
static inline long krecipasm(long i)
{ // Ken did this
float f = (float)i; i = *(long *)&f;
return((reciptable[(i>>12)&2047]>>(((i-0x3f800000)>>23)&31))^(i>>31));
}
static inline long getclipmask(long a, long b, long c, long d)
{ // Ken did this
d = ((a<0)*8) + ((b<0)*4) + ((c<0)*2) + (d<0);
return(((d<<4)^0xf0)|d);
}
inline long getkensmessagecrc(long b)
{
return 0x56c764d4l;
b=b;
}
#endif

View file

@ -131,6 +131,7 @@ char keys[NUMKEYS] =
0x9c,0x1c,0xd,0xc,0xf
};
long xdimgame = 320, ydimgame = 200, bppgame = 8, xdim2d = 640, ydim2d = 480; // JBF 20050318: config.c expects to find these
long forcesetup = 1;
static long digihz[8] = {6000,8000,11025,16000,22050,32000,44100,48000};
@ -387,15 +388,11 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
#ifdef RENDERTYPEWIN
int DoLaunchWindow(void); // gamestartwin.c
#endif
char *startwin_labeltext = "Starting KenBuild...";
extern int startwin_run(void);
long app_main(long argc, char *argv[])
{
long i, j, k, l, fil, waitplayers, x1, y1, x2, y2;
long cmdsetup = 0, i, j, k, l, fil, waitplayers, x1, y1, x2, y2;
long other, packleng, netparm;
#ifdef USE_OPENGL
@ -416,33 +413,31 @@ long app_main(long argc, char *argv[])
}
if (isvalidipaddress(argv[i])) continue;
} else {
Bstrcpy(boardfilename, argv[i]);
if (!Bstrrchr(boardfilename,'.')) Bstrcat(boardfilename,".map");
if (!Bstrcasecmp(argv[i], "-setup")) cmdsetup = 1;
else {
Bstrcpy(boardfilename, argv[i]);
if (!Bstrrchr(boardfilename,'.')) Bstrcat(boardfilename,".map");
}
}
}
OSD_SetLogFile("console.txt");
/*
if ((fil = open("setup.dat",O_BINARY|O_RDWR,S_IREAD)) != -1)
{
read(fil,&option[0],NUMOPTIONS);
read(fil,&keys[0],NUMKEYS);
close(fil);
}
*/
if (loadsetup("game.cfg") < 0) initprintf("Configuration file not found, using defaults.\n");
initgroupfile("stuff.dat");
if (initengine()) {
initprintf("There was a problem initialising the engine.\n");
return -1;
}
#ifdef RENDERTYPEWIN
if (DoLaunchWindow()) return -1;
writesetup("game.cfg");
if ((i = loadsetup("game.cfg")) < 0)
initprintf("Configuration file not found, using defaults.\n");
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
if (i || forcesetup || cmdsetup) {
if (!startwin_run()) return -1;
}
#endif
writesetup("game.cfg");
initinput();
if (option[3] != 0) initmouse();
@ -3633,13 +3628,13 @@ void drawscreen(short snum, long dasmoothratio)
y2 = y1 + scale(screensize,ydim-32,xdim)-1;
setview(x1,y1,x2,y2);
// (ox1,oy1)ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
// ³ (x1,y1) ³
// ³ ÚÄÄÄÄÄ¿ ³
// ³ ³ ³ ³
// ³ ÀÄÄÄÄÄÙ ³
// ³ (x2,y2) ³
// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ(ox2,oy2)
// (ox1,oy1)⁄ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒø
// ≥ (x1,y1) ≥
// ≥ ⁄ƒƒƒƒƒø ≥
// ≥ ≥ ≥ ≥
// ≥ ¿ƒƒƒƒƒŸ ≥
// ≥ (x2,y2) ≥
// ¿ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒŸ(ox2,oy2)
drawtilebackground(0L,0L,BACKGROUND,8,ox1,oy1,x1-1,oy2,0);
drawtilebackground(0L,0L,BACKGROUND,8,x2+1,oy1,ox2,oy2,0);
@ -3801,7 +3796,7 @@ void drawscreen(short snum, long dasmoothratio)
else
setviewtotile(MAXTILES-2,320L>>detailmode,320L>>detailmode);
if ((tiltlock&1023) == 512)
{ //Block off unscreen section of 90ø tilted screen
{ //Block off unscreen section of 90¯ tilted screen
j = ((320-60)>>detailmode);
for(i=(60>>detailmode)-1;i>=0;i--)
{
@ -4907,13 +4902,7 @@ void initlava(void)
lavanumframes = 0;
}
#if defined(NOASM)
inline long addlava(long bx)
{
char *b = (char *)bx;
return b[-133] + b[-132] + b[-131] + b[1] + b[-1] + b[131] + b[132];
}
#elif defined(__WATCOMC__)
#if defined(__WATCOMC__) && !defined(NOASM)
#pragma aux addlava =\
"mov al, byte ptr [ebx-133]",\
"mov dl, byte ptr [ebx-1]",\
@ -4926,7 +4915,7 @@ inline long addlava(long bx)
parm [ebx]\
modify exact [eax edx]
long addlava(long);
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && !defined(NOASM)
inline long addlava(long b)
{
_asm {
@ -4941,7 +4930,7 @@ inline long addlava(long b)
add al, dl
}
}
#elif defined(__GNUC__) && defined(__i386__)
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM)
inline long addlava(long b)
{
long r;
@ -4960,7 +4949,11 @@ inline long addlava(long b)
return r;
}
#else
#error Unsupported compiler or architecture
inline long addlava(long bx)
{
char *b = (char *)bx;
return b[-133] + b[-132] + b[-131] + b[1] + b[-1] + b[131] + b[132];
}
#endif
void movelava(char *dapic)

View file

@ -1,144 +0,0 @@
#ifndef RENDERTYPEWIN
#error Only for Windows
#endif
#include "build.h"
#include "editor.h"
#include "winlayer.h"
#include "compat.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#define IDCFULLSCREEN 100
#define IDCVMODE 101
static void PopulateVideoModeLists(int fs, HWND list3d)
{
int i,j;
char buf[64];
ComboBox_ResetContent(list3d);
for (i=0; i<validmodecnt; i++) {
if (validmode[i].fs != fs) continue;
Bsprintf(buf, "%ldx%ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
j = ComboBox_AddString(list3d, buf);
ComboBox_SetItemData(list3d, j, i);
if (xdimgame == validmode[i].xdim && ydimgame == validmode[i].ydim && bppgame == validmode[i].bpp)
ComboBox_SetCurSel(list3d, j);
}
}
static INT_PTR CALLBACK LaunchWindowProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG: {
char buf[64];
if (lParam) {
long *saferect = (long*)lParam;
RECT unresized, playbutton, exitbutton;
int dx, dy;
GetWindowRect(hwndDlg, &unresized);
GetWindowRect(GetDlgItem(hwndDlg, IDOK), &playbutton);
GetWindowRect(GetDlgItem(hwndDlg, IDCANCEL), &exitbutton);
playbutton.right = 1 + playbutton.right - playbutton.left;
playbutton.bottom = 1 + playbutton.bottom - playbutton.top;
exitbutton.right = 1 + exitbutton.right - exitbutton.left;
exitbutton.bottom = 1 + exitbutton.bottom - exitbutton.top;
playbutton.left = playbutton.left - unresized.left;
playbutton.top = playbutton.top - unresized.top;
exitbutton.left = exitbutton.left - unresized.left;
exitbutton.top = exitbutton.top - unresized.top;
dx = saferect[2] - (unresized.right - unresized.left);
dy = saferect[3] - (unresized.bottom - unresized.top);
playbutton.left += dx; exitbutton.left += dx;
playbutton.top += dy; exitbutton.top += dy;
// reposition the dialog, play and exit buttons
MoveWindow(hwndDlg, saferect[0], saferect[1], saferect[2], saferect[3], FALSE);
MoveWindow(GetDlgItem(hwndDlg, IDOK),
playbutton.left, playbutton.top, playbutton.right, playbutton.bottom, FALSE);
MoveWindow(GetDlgItem(hwndDlg, IDCANCEL),
exitbutton.left, exitbutton.top, exitbutton.right, exitbutton.bottom, FALSE);
}
// populate the controls
Button_SetCheck(GetDlgItem(hwndDlg, IDCFULLSCREEN), fullscreen ? BST_CHECKED : BST_UNCHECKED);
PopulateVideoModeLists(fullscreen, GetDlgItem(hwndDlg, IDCVMODE));
ShowWindow(hwndDlg, SW_SHOW);
if (GetDlgCtrlID((HWND)wParam) != IDOK) {
SetFocus(GetDlgItem(hwndDlg, IDOK));
return FALSE;
}
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCFULLSCREEN:
fullscreen = Button_GetCheck((HWND)lParam) == BST_CHECKED ? 1:0;
PopulateVideoModeLists(fullscreen, GetDlgItem(hwndDlg, IDCVMODE));
break;
case IDCVMODE:
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) {
xdimgame = validmode[i].xdim;
ydimgame = validmode[i].ydim;
bppgame = validmode[i].bpp;
}
}
break;
case IDCANCEL:
quitevent = 1; // fall through
case IDOK:
DestroyWindow(hwndDlg);
return TRUE;
default: break;
}
break;
default: break;
}
return FALSE;
}
int DoLaunchWindow(int initval)
{
HWND hwndStart, hwndLaunch;
MSG msg;
long saferect[4];
// only show config window if no config is loaded, or if it is, only if left control is held
if (initval == 0 && !GetAsyncKeyState(VK_CONTROL)) return 0;
if (win_getstartupwin((long*)&hwndStart, saferect, NULL)) return 0;
hwndLaunch = CreateDialogParam((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(2000), hwndStart, LaunchWindowProc, (LPARAM)saferect);
if (hwndLaunch) {
EnableWindow(GetDlgItem(hwndStart,WIN_STARTWIN_ITEMLIST),FALSE);
while (GetMessage(&msg, NULL, 0, 0) > 0) {
if (!IsWindow(hwndLaunch) || quitevent) break;
if (IsDialogMessage(hwndStart, &msg) /*|| IsDialogMessage(hwndLaunch, &msg)*/) continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
EnableWindow(GetDlgItem(hwndStart,WIN_STARTWIN_ITEMLIST),TRUE);
}
if (quitevent) return 1;
return 0;
}

View file

@ -6,8 +6,12 @@
#if defined USE_OPENGL
#ifdef RENDERTYPESDL
#include "SDL.h"
#ifdef RENDERTYPESDL
# ifdef __APPLE__
# include <SDL/SDL.h>
# else
#include "SDL.h"
#endif
#endif
void (APIENTRY * bglClearColor)( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha );
@ -131,8 +135,10 @@ int loadgldriver(const char *driver)
#endif
if (!driver) {
#ifdef _WIN32
#ifdef _WIN32
driver = "OPENGL32.DLL";
#elif defined __APPLE__
driver = "OpenGLLibrary";
#else
driver = "libGL.so";
#endif

View file

@ -13,164 +13,10 @@
#include "baselayer.h"
#include "build.h"
static int gtkenabled = 0;
int gtkenabled = 0;
extern const GdkPixdata startbanner_pixdata;
static GtkWidget *startwin = NULL;
static GdkPixbuf *appicon = NULL;
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
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)
#define lookup_widget(x,w) \
(GtkWidget*) g_object_get_data(G_OBJECT(x), w)
static gboolean on_startwin_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
quitevent++;
return TRUE; // FALSE would let the event go through. we want the game to decide when to close
}
void gtkbuild_create_startwin(void)
{
GtkWidget *banner, *label, *content, *scroll;
GtkWidget *hbox1, *fixed1;
GdkPixbuf *startbanner_pixbuf;
if (!gtkenabled) return;
startwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (startwin), apptitle);
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);
hbox1 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox1);
gtk_container_add (GTK_CONTAINER (startwin), hbox1);
startbanner_pixbuf = gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL);
banner = gtk_image_new_from_pixbuf(startbanner_pixbuf);
g_object_unref((gpointer)startbanner_pixbuf);
gtk_widget_show (banner);
gtk_box_pack_start (GTK_BOX (hbox1), banner, FALSE, FALSE, 0);
fixed1 = gtk_fixed_new ();
gtk_widget_show (fixed1);
gtk_box_pack_start (GTK_BOX (hbox1), fixed1, TRUE, TRUE, 0);
gtk_widget_set_size_request (fixed1, 390, -1);
label = gtk_label_new (startwin_labeltext);
gtk_widget_show (label);
gtk_fixed_put (GTK_FIXED (fixed1), label, 6, 6);
gtk_widget_set_size_request (label, 378, 16);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scroll);
gtk_fixed_put (GTK_FIXED (fixed1), scroll, 6, 28);
gtk_widget_set_size_request (scroll, 378, 248);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
content = gtk_text_view_new ();
gtk_widget_show (content);
gtk_container_add (GTK_CONTAINER(scroll), content);
//gtk_fixed_put (GTK_FIXED (fixed1), content, 6, 28);
gtk_widget_set_size_request (content, 378, 248);
gtk_text_view_set_editable (GTK_TEXT_VIEW (content), FALSE);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (content), GTK_WRAP_WORD);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (content), FALSE);
g_signal_connect ((gpointer) startwin, "delete_event",
G_CALLBACK (on_startwin_delete_event),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (startwin, startwin, "startwin");
GLADE_HOOKUP_OBJECT (startwin, banner, "banner");
GLADE_HOOKUP_OBJECT (startwin, label, "label");
GLADE_HOOKUP_OBJECT (startwin, scroll, "scroll");
GLADE_HOOKUP_OBJECT (startwin, content, "content");
g_signal_connect((gpointer)startwin, "destroy", G_CALLBACK(gtk_widget_destroyed), (gpointer)&startwin);
gtk_widget_show (startwin);
gtk_main_iteration_do (FALSE);
}
void gtkbuild_settitle_startwin(const char *title)
{
if (!gtkenabled || !startwin) return;
gtk_window_set_title (GTK_WINDOW (startwin), title);
}
void gtkbuild_puts_startwin(const char *str)
{
GtkWidget *textview;
GtkTextBuffer *textbuffer;
GtkTextIter enditer;
GtkTextMark *mark;
const char *aptr, *bptr;
if (!gtkenabled || !startwin || !str) return;
if (!(textview = lookup_widget(startwin, "content"))) return;
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);
#if GTK_CHECK_VERSION(2,6,0)
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;
}
}
mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1);
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0);
gtk_text_buffer_delete_mark(textbuffer, mark);
}
void gtkbuild_close_startwin(void)
{
if (!gtkenabled) return;
if (startwin) {
gtk_widget_destroy (startwin);
startwin = NULL;
}
}
void gtkbuild_update_startwin(void)
{
if (!gtkenabled) return;
gtk_main_iteration_do (FALSE);
}
int gtkbuild_msgbox(char *name, char *msg)
{
GtkWidget *dialog;
@ -213,7 +59,7 @@ int gtkbuild_ynbox(char *name, char *msg)
#include "sdlayer.h"
extern struct sdlappicon sdlappicon;
#endif
void gtkbuild_init(int argc, char **argv)
void gtkbuild_init(int *argc, char ***argv)
{
gtkenabled = gtk_init_check(argc, argv);
if (!gtkenabled) return;
@ -231,8 +77,3 @@ void gtkbuild_exit(int r)
if (appicon) g_object_unref((gpointer)appicon);
//gtk_exit(r);
}
void *gtkbuild_get_app_icon(void)
{
return appicon;
}

View file

@ -1,10 +1,10 @@
/**************************************************************************************************
KPLIB.C: Ken's Picture LIBrary written by Ken Silverman
Copyright (c) 1998-2005 Ken Silverman
Copyright (c) 1998-2006 Ken Silverman
Ken Silverman's official web site: http://advsys.net/ken
Features of KPLIB.C:
* Routines for decoding JPG, PNG, GIF, PCX, TGA, BMP, CEL.
* Routines for decoding JPG, PNG, GIF, PCX, TGA, BMP, DDS, CEL.
See kpgetdim(), kprender(), and optional helper function: kpzload().
* Routines for ZIP decompression. All ZIP functions start with the letters "kz".
* Multi-platform support: Dos/Windows/Linux/Mac/etc..
@ -20,6 +20,7 @@ Brief history:
2003: Added support for BMP
05/18/2004: Added support for 8&24 bit PCX
12/09/2005: Added support for progressive JPEG
01/05/2006: Added support for DDS
I offer this code to the community for free use - all I ask is that my name be included in the
credits.
@ -153,8 +154,8 @@ static kzfilestate kzfs;
// pow2mask 128*
// dcflagor 64
long palcol[256] ASMNAME("palcol"), paleng;
unsigned char coltype, bitdepth;
long palcol[256] ASMNAME("palcol"), paleng, bakcol, numhufblocks, zlibcompflags;
signed char coltype, filtype, bitdepth;
//============================ KPNGILIB begins ===============================
@ -169,7 +170,7 @@ unsigned char coltype, bitdepth;
// * Some useless ancillary chunks, like: gAMA(gamma) & pHYs(aspect ratio)
//.PNG specific variables:
static long bakcol = 0xff808080, bakr = 0x80, bakg = 0x80, bakb = 0x80; //this used to be public...
static long bakr = 0x80, bakg = 0x80, bakb = 0x80; //this used to be public...
static long gslidew = 0, gslider = 0, xm, xmn[4], xr0, xr1, xplc, yplc, nfplace;
static long clen[320], cclen[19], bitpos, filt, xsiz, ysiz;
static long xsizbpl, ixsiz, ixoff, iyoff, ixstp, iystp, intlac, nbpl, trnsrgb ASMNAME("trnsrgb");
@ -186,25 +187,7 @@ static long gotcmov = -2, abstab10[1024] ASMNAME("abstab10");
static long qhufval0[1<<LOGQHUFSIZ0], qhufval1[1<<LOGQHUFSIZ1];
static unsigned char qhufbit0[1<<LOGQHUFSIZ0], qhufbit1[1<<LOGQHUFSIZ1];
#if defined(NOASM)
static inline unsigned long bswap (unsigned long a)
{
return(((a&0xff0000)>>8) + ((a&0xff00)<<8) + (a<<24) + (a>>24));
}
static inline long bitrev (long b, long c)
{
long i, j;
for(i=1,j=0,c=(1<<c);i<c;i+=i) { j += j; if (b&i) j++; }
return(j);
}
static inline long testflag (long c) { return(0); }
static inline void cpuid(long a, long *s) {}
#elif defined(__WATCOMC__)
#if defined(__WATCOMC__) && !defined(NOASM)
long bswap (long);
#pragma aux bswap =\
@ -256,7 +239,7 @@ void cpuid (long, long *);
modify exact [eax ebx ecx edx]\
value
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && !defined(NOASM)
static _inline unsigned long bswap (unsigned long a)
{
@ -320,7 +303,7 @@ static _inline void cpuid (long a, long *s)
}
}
#elif defined(__GNUC__) && defined(__i386__)
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM)
static inline unsigned long bswap (unsigned long a)
{
@ -358,7 +341,21 @@ static inline void cpuid (long a, long *s)
#else
#error Unsupported compiler or architecture.
static inline unsigned long bswap (unsigned long a)
{
return(((a&0xff0000)>>8) + ((a&0xff00)<<8) + (a<<24) + (a>>24));
}
static inline long bitrev (long b, long c)
{
long i, j;
for(i=1,j=0,c=(1<<c);i<c;i+=i) { j += j; if (b&i) j++; }
return(j);
}
static inline long testflag (long c) { return(0); }
static inline void cpuid(long a, long *s) {}
#endif
@ -575,35 +572,7 @@ static long Paeth (long a, long b, long c)
if (pb <= pc) return(b); else return(c);
}
#if defined(NOASM)
static inline long Paeth686 (long a, long b, long c)
{
return(Paeth(a,b,c));
}
static inline void rgbhlineasm (long x, long xr1, long p, long ixstp)
{
long i;
if (!trnsrgb)
{
for(;x>xr1;p+=ixstp,x-=3) *(long *)p = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000);
return;
}
for(;x>xr1;p+=ixstp,x-=3)
{
i = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000);
if (i == trnsrgb) i &= LSWAPIB(0xffffff);
*(long *)p = i;
}
}
static inline void pal8hlineasm (long x, long xr1, long p, long ixstp)
{
for(;x>xr1;p+=ixstp,x--) *(long *)p = palcol[olinbuf[x]];
}
#elif defined(__WATCOMC__)
#if defined(__WATCOMC__) && !defined(NOASM)
//NOTE: cmov now has correctly ordered registers (thx to bug fix in 11.0c!)
long Paeth686 (long, long, long);
@ -669,7 +638,7 @@ void pal8hlineasm (long, long, long, long);
modify exact [eax ecx edi]\
value
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && !defined(NOASM)
static _inline long Paeth686 (long a, long b, long c)
{
@ -746,7 +715,7 @@ static _inline void pal8hlineasm (long c, long d, long t, long b)
}
}
#elif defined(__GNUC__) && defined(__i386__)
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM)
static inline long Paeth686 (long a, long b, long c)
{
@ -791,10 +760,43 @@ static inline void pal8hlineasm (long c, long d, long t, long b)
#else
#error Unsupported compiler or architecture.
static inline long Paeth686 (long a, long b, long c)
{
return(Paeth(a,b,c));
}
static inline void rgbhlineasm (long x, long xr1, long p, long ixstp)
{
long i;
if (!trnsrgb)
{
for(;x>xr1;p+=ixstp,x-=3) *(long *)p = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000);
return;
}
for(;x>xr1;p+=ixstp,x-=3)
{
i = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000);
if (i == trnsrgb) i &= LSWAPIB(0xffffff);
*(long *)p = i;
}
}
static inline void pal8hlineasm (long x, long xr1, long p, long ixstp)
{
for(;x>xr1;p+=ixstp,x--) *(long *)p = palcol[olinbuf[x]];
}
#endif
//Autodetect filter
// /f0: 0000000...
// /f1: 1111111...
// /f2: 2222222...
// /f3: 1333333...
// /f3: 3333333...
// /f4: 4444444...
// /f5: 0142321...
static long filter1st, filterest;
static void putbuf (const unsigned char *buf, long leng)
{
long i, x, p;
@ -802,7 +804,9 @@ static void putbuf (const unsigned char *buf, long leng)
if (filt < 0)
{
if (leng <= 0) return;
filt = buf[0]; if (filt == gotcmov) filt = 5;
filt = buf[0];
if (filter1st < 0) filter1st = filt; else filterest |= (1<<filt);
if (filt == gotcmov) filt = 5;
i = 1;
} else i = 0;
@ -912,7 +916,12 @@ static void putbuf (const unsigned char *buf, long leng)
*(long *)&opixbuf0[0] = *(long *)&opixbuf1[0] = 0;
xplc = xsizbpl; yplc += iystp;
if ((intlac) && (yplc >= globyoffs+ysiz)) { intlac--; initpass(); }
if (i < leng) { filt = buf[i++]; if (filt == gotcmov) filt = 5; } else filt = -1;
if (i < leng)
{
filt = buf[i++];
if (filter1st < 0) filter1st = filt; else filterest |= (1<<filt);
if (filt == gotcmov) filt = 5;
} else filt = -1;
}
}
@ -960,7 +969,7 @@ static long kpngrend (const char *kfilebuf, long kfilength,
return(-1); //"Invalid PNG file signature"
filptr = (unsigned char *)&kfilebuf[8];
trnsrgb = 0;
trnsrgb = 0; filter1st = -1; filterest = 0;
while (1)
{
@ -1000,7 +1009,7 @@ static long kpngrend (const char *kfilebuf, long kfilength,
bakcol = bakcol*0x10101+0xff000000; break;
case 2: case 6:
if (bitdepth == 8)
{ bakcol = (((long)filptr[0])<<16)+(((long)filptr[2])<<8)+((long)filptr[4])+0xff000000; }
{ bakcol = (((long)filptr[1])<<16)+(((long)filptr[3])<<8)+((long)filptr[5])+0xff000000; }
else
{
for(i=0,bakcol=0xff000000;i<3;i++)
@ -1087,9 +1096,10 @@ static long kpngrend (const char *kfilebuf, long kfilength,
initpass();
slidew = 0; slider = 16384;
suckbits(16); //Actually 2 fields: 8:compmethflags, 8:addflagscheck
zlibcompflags = getbits(16); //Actually 2 fields: 8:compmethflags, 8:addflagscheck
do
{
numhufblocks++;
bfinal = getbits(1); btype = getbits(2);
if (btype == 0)
{
@ -1101,7 +1111,7 @@ static long kpngrend (const char *kfilebuf, long kfilength,
if (slidew >= slider)
{
putbuf(&slidebuf[(slider-16384)&32767],16384); slider += 16384;
if ((yplc >= yres) && (intlac < 2)) return(0);
if ((yplc >= yres) && (intlac < 2)) goto kpngrend_goodret;
}
slidebuf[(slidew++)&32767] = (char)getbits(8);
}
@ -1153,7 +1163,7 @@ static long kpngrend (const char *kfilebuf, long kfilength,
if (slidew >= slider)
{
putbuf(&slidebuf[(slider-16384)&32767],16384); slider += 16384;
if ((yplc >= yres) && (intlac < 2)) return(0);
if ((yplc >= yres) && (intlac < 2)) goto kpngrend_goodret;
}
k = peekbits(LOGQHUFSIZ0);
@ -1181,6 +1191,12 @@ static long kpngrend (const char *kfilebuf, long kfilength,
putbuf(&slidebuf[slider&32767],(-slider)&32767);
putbuf(slidebuf,slidew&32767);
}
kpngrend_goodret:;
if (!(filterest&~(1<<filter1st))) filtype = filter1st;
else if ((filter1st == 1) && (!(filterest&~(1<<3)))) filtype = 3;
else filtype = 5;
if (coltype == 4) paleng = 0; //For /c4, palcol/paleng used as LUT for "*0x10101": alpha is invalid!
return(0);
}
@ -1205,19 +1221,7 @@ static long lcomphvsamp0, lcomphsampshift0, lcompvsampshift0;
static long colclip[1024], colclipup8[1024], colclipup16[1024];
static unsigned char pow2char[8] = {1,2,4,8,16,32,64,128};
#if defined(NOASM)
static inline long mulshr24 (long a, long b)
{
return((long)((((__int64)a)*((__int64)b))>>24));
}
static inline long mulshr32 (long a, long b)
{
return((long)((((__int64)a)*((__int64)b))>>32));
}
#elif defined(__WATCOMC__)
#if defined(__WATCOMC__) && !defined(NOASM)
long mulshr24 (long, long);
#pragma aux mulshr24 =\
@ -1233,7 +1237,7 @@ long mulshr32 (long, long);
modify exact [eax edx]\
value [edx]
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && !defined(NOASM)
static _inline long mulshr24 (long a, long d)
{
@ -1255,7 +1259,7 @@ static _inline long mulshr32 (long a, long d)
}
}
#elif defined(__GNUC__) && defined(__i386__)
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM)
#define mulshr24(a,d) \
({ long __a=(a), __d=(d); \
@ -1271,7 +1275,15 @@ static _inline long mulshr32 (long a, long d)
#else
#error Unsupported compiler or architecture.
static inline long mulshr24 (long a, long b)
{
return((long)((((__int64)a)*((__int64)b))>>24));
}
static inline long mulshr32 (long a, long b)
{
return((long)((((__int64)a)*((__int64)b))>>32));
}
#endif
@ -2263,7 +2275,8 @@ if (ysiz < 0) { ysiz = -ysiz; } else { cptr = &cptr[(ysiz-1)*cptrinc]; cptrinc =
}
return(0);
}
//=============================== BMP ends ==================================
//============================== PCX begins =================================
//Note: currently only supports 8 and 24 bit PCX
static long kpcxrend (const char *buf, long fleng,
long daframeplace, long dabytesperline, long daxres, long dayres,
@ -2343,7 +2356,127 @@ static long kpcxrend (const char *buf, long fleng,
return(0);
}
//=============================== BMP ends ==================================
//=============================== PCX ends ==================================
//============================== DDS begins =================================
//Note:currently supports: DXT1,DXT2,DXT3,DXT4,DXT5,A8R8G8B8
static long kddsrend (const char *buf, long leng,
long frameptr, long bpl, long xdim, long ydim, long xoff, long yoff)
{
long x, y, z, xx, yy, xsiz, ysiz, dxt, al[2], ai, j, k, v, c0, c1, stride;
unsigned long lut[256], r[4], g[4], b[4], a[8], rr, gg, bb;
unsigned char *uptr, *wptr;
xsiz = LSWAPIB(*(long *)&buf[16]);
ysiz = LSWAPIB(*(long *)&buf[12]);
if ((*(long *)&buf[80])&LSWAPIB(64)) //Uncompressed supports only A8R8G8B8 for now
{
if ((*(long *)&buf[88]) != LSWAPIB(32)) return(-1);
if ((*(long *)&buf[92]) != LSWAPIB(0x00ff0000)) return(-1);
if ((*(long *)&buf[96]) != LSWAPIB(0x0000ff00)) return(-1);
if ((*(long *)&buf[100]) != LSWAPIB(0x000000ff)) return(-1);
if ((*(long *)&buf[104]) != LSWAPIB(0xff000000)) return(-1);
buf += 128;
j = yoff*bpl + (xoff<<2) + frameptr; xx = (xsiz<<2);
if (xoff < 0) { j -= (xoff<<2); buf -= (xoff<<2); xsiz += xoff; }
xsiz = (min(xsiz,xdim-xoff)<<2); ysiz = min(ysiz,ydim);
for(y=0;y<ysiz;y++,j+=bpl,buf+=xx)
{
if ((unsigned long)(y+yoff) >= (unsigned long)ydim) continue;
memcpy((void *)j,(void *)buf,xsiz);
}
return(0);
}
if (!((*(long *)&buf[80])&LSWAPIB(4))) return(-1); //FOURCC invalid
dxt = buf[87]-'0';
if ((buf[84] != 'D') || (buf[85] != 'X') || (buf[86] != 'T') || (dxt < 1) || (dxt > 5)) return(-1);
buf += 128;
if (!(dxt&1))
{
for(z=256-1;z>0;z--) lut[z] = (255<<16)/z;
lut[0] = (1<<16);
}
if (dxt == 1) stride = (xsiz<<1); else stride = (xsiz<<2);
for(y=0;y<ysiz;y+=4,buf+=stride)
for(x=0;x<xsiz;x+=4)
{
if (dxt == 1) uptr = (unsigned char *)(((long)buf)+(x<<1));
else uptr = (unsigned char *)(((long)buf)+(x<<2)+8);
c0 = SSWAPIB(*(unsigned short *)&uptr[0]);
r[0] = ((c0>>8)&0xf8); g[0] = ((c0>>3)&0xfc); b[0] = ((c0<<3)&0xfc); a[0] = 255;
c1 = SSWAPIB(*(unsigned short *)&uptr[2]);
r[1] = ((c1>>8)&0xf8); g[1] = ((c1>>3)&0xfc); b[1] = ((c1<<3)&0xfc); a[1] = 255;
if ((c0 > c1) || (dxt != 1))
{
r[2] = (((r[0]*2 + r[1] + 1)*(65536/3))>>16);
g[2] = (((g[0]*2 + g[1] + 1)*(65536/3))>>16);
b[2] = (((b[0]*2 + b[1] + 1)*(65536/3))>>16); a[2] = 255;
r[3] = (((r[0] + r[1]*2 + 1)*(65536/3))>>16);
g[3] = (((g[0] + g[1]*2 + 1)*(65536/3))>>16);
b[3] = (((b[0] + b[1]*2 + 1)*(65536/3))>>16); a[3] = 255;
}
else
{
r[2] = (r[0] + r[1])>>1;
g[2] = (g[0] + g[1])>>1;
b[2] = (b[0] + b[1])>>1; a[2] = 255;
r[3] = g[3] = b[3] = a[3] = 0; //Transparent
}
v = LSWAPIB(*(long *)&uptr[4]);
if (dxt >= 4)
{
a[0] = uptr[-8]; a[1] = uptr[-7]; k = a[1]-a[0];
if (k < 0)
{
z = a[0]*6 + a[1] + 3;
for(j=2;j<8;j++) { a[j] = ((z*(65536/7))>>16); z += k; }
}
else
{
z = a[0]*4 + a[1] + 2;
for(j=2;j<6;j++) { a[j] = ((z*(65536/5))>>16); z += k; }
a[6] = 0; a[7] = 255;
}
al[0] = LSWAPIB(*(long *)&uptr[-6]);
al[1] = LSWAPIB(*(long *)&uptr[-3]);
}
wptr = (unsigned char *)((y+yoff)*bpl + ((x+xoff)<<2) + frameptr);
ai = 0;
for(yy=0;yy<4;yy++,wptr+=bpl)
{
if ((unsigned long)(y+yy+yoff) >= (unsigned long)ydim) { ai += 4; continue; }
for(xx=0;xx<4;xx++,ai++)
{
if ((unsigned long)(x+xx+xoff) >= (unsigned long)xdim) continue;
j = ((v>>(ai<<1))&3);
switch(dxt)
{
case 1: z = a[j]; break;
case 2: case 3: z = (( uptr[(ai>>1)-8] >> ((xx&1)<<2) )&15)*17; break;
case 4: case 5: z = a[( al[yy>>1] >> ((ai&7)*3) )&7]; break;
}
rr = r[j]; gg = g[j]; bb = b[j];
if (!(dxt&1))
{
bb = min((bb*lut[z])>>16,255);
gg = min((gg*lut[z])>>16,255);
rr = min((rr*lut[z])>>16,255);
}
wptr[(xx<<2)+0] = bb;
wptr[(xx<<2)+1] = gg;
wptr[(xx<<2)+2] = rr;
wptr[(xx<<2)+3] = z;
}
}
}
return(0);
}
//=============================== DDS ends ==================================
//=================== External picture interface begins ======================
void kpgetdim (const char *buf, long leng, long *xsiz, long *ysiz)
@ -2410,6 +2543,11 @@ void kpgetdim (const char *buf, long leng, long *xsiz, long *ysiz)
(*xsiz) = SSWAPIB(*(short *)&buf[ 8])-SSWAPIB(*(short *)&buf[4])+1;
(*ysiz) = SSWAPIB(*(short *)&buf[10])-SSWAPIB(*(short *)&buf[6])+1;
}
else if ((*(long *)ubuf == LSWAPIB(0x20534444)) && (*(long *)&ubuf[4] == LSWAPIB(124))) //.DDS
{
(*xsiz) = LSWAPIB(*(long *)&buf[16]);
(*ysiz) = LSWAPIB(*(long *)&buf[12]);
}
else
{ //Unreliable .TGA identification - this MUST be final case!
if ((leng >= 20) && (!(ubuf[1]&0xfe)))
@ -2428,6 +2566,8 @@ long kprender (const char *buf, long leng, long frameptr, long bpl,
{
unsigned char *ubuf = (unsigned char *)buf;
paleng = 0; bakcol = 0; numhufblocks = zlibcompflags = 0; filtype = -1;
if ((ubuf[0] == 0x89) && (ubuf[1] == 0x50)) //.PNG
return(kpngrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));
@ -2446,6 +2586,9 @@ long kprender (const char *buf, long leng, long frameptr, long bpl,
if (*(long *)ubuf == LSWAPIB(0x0801050a)) //.PCX
return(kpcxrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));
if ((*(long *)ubuf == LSWAPIB(0x20534444)) && (*(long *)&ubuf[4] == LSWAPIB(124))) //.DDS
return(kddsrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff));
//Unreliable .TGA identification - this MUST be final case!
if ((leng >= 20) && (!(ubuf[1]&0xfe)))
if ((ubuf[2] < 12) && ((1<<ubuf[2])&0xe0e))
@ -2708,7 +2851,8 @@ static struct dirent *findata = NULL;
void kzfindfilestart (const char *st)
{
#ifdef _WIN32
#if defined(__DOS__)
#elif defined(_WIN32)
if (hfind != INVALID_HANDLE_VALUE)
{ FindClose(hfind); hfind = INVALID_HANDLE_VALUE; }
#else
@ -2794,21 +2938,17 @@ long kzfindfile (char *filnam)
strcpy(&filnam[i],findata.cFileName);
if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) strcat(&filnam[i],"\\");
#else
{
struct stat st;
if ((findata = readdir(hfind)) == NULL)
{ closedir(hfind); hfind = NULL; if (!kzhashbuf) return 0; srchstat = kzlastfnam; break; }
i = wildstpathleng;
strcpy(&filnam[i],findata->d_name);
if (stat(filnam,&st) < 0) continue;
if (st.st_mode & S_IFDIR)
{ if (findata->d_name[0] == '.' && !findata->d_name[1]) continue; } //skip .
else if ((st.st_mode & S_IFREG) || (st.st_mode & S_IFLNK))
{ if (findata->d_name[0] == '.') continue; } //skip hidden (dot) files
else continue; //skip devices and fifos and such
if (!wildmatch(findata->d_name,&wildst[wildstpathleng])) continue;
if (st.st_mode & S_IFDIR) strcat(&filnam[i],"/");
}
if ((findata = readdir(hfind)) == NULL)
{ closedir(hfind); hfind = NULL; if (!kzhashbuf) return 0; srchstat = kzlastfnam; break; }
i = wildstpathleng;
if (findata->d_type == DT_DIR)
{ if (findata->d_name[0] == '.' && !findata->d_name[1]) continue; } //skip .
else if ((findata->d_type == DT_REG) || (findata->d_type == DT_LNK))
{ if (findata->d_name[0] == '.') continue; } //skip hidden (dot) files
else continue; //skip devices and fifos and such
if (!wildmatch(findata->d_name,&wildst[wildstpathleng])) continue;
strcpy(&filnam[i],findata->d_name);
if (findata->d_type == DT_DIR) strcat(&filnam[i],"/");
#endif
return(1);
}

View file

@ -561,7 +561,7 @@ long mdloadskin_trytexcache(char *fn, long len, char effect, texcacheheader *hea
return -1;
}
md4once(fn, strlen(fn), mdsum);
md4once((unsigned char *)fn, strlen(fn), mdsum);
for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++);
*(cp++) = '/';
for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2);
@ -2233,9 +2233,9 @@ kread(fil,&i,4); if (B_LITTLE32(i) != 0x6c78764b) { kclose(fil); return(-1); } /
kread(fil,&xsiz,4); xsiz = B_LITTLE32(xsiz);
kread(fil,&ysiz,4); ysiz = B_LITTLE32(ysiz);
kread(fil,&zsiz,4); zsiz = B_LITTLE32(zsiz);
kread(fil,&xpiv,4); xpiv = B_LITTLE32(xpiv);
kread(fil,&ypiv,4); ypiv = B_LITTLE32(ypiv);
kread(fil,&zpiv,4); zpiv = B_LITTLE32(zpiv);
kread(fil,&i,4); xpiv = (float)(B_LITTLE32(i));
kread(fil,&i,4); ypiv = (float)(B_LITTLE32(i));
kread(fil,&i,4); zpiv = (float)(B_LITTLE32(i));
kread(fil,&numvoxs,4); numvoxs = B_LITTLE32(numvoxs);
ylen = (unsigned short *)malloc(xsiz*ysiz*sizeof(short));

View file

@ -1,31 +1,33 @@
#include <windows.h>
#include <commctrl.h>
#include "startwin.editor.h"
100 ICON "rsrc/build_icon.ico"
200 BITMAP "rsrc/build.bmp"
RSRC_ICON ICON "rsrc/build_icon.ico"
RSRC_BMP BITMAP "rsrc/build.bmp"
1000 DIALOGEX DISCARDABLE 20, 40, 265, 233
WIN_STARTWIN DIALOGEX DISCARDABLE 20, 40, 260, 200
STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU
CAPTION "Startup"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255
CONTROL "Starting Build Editor...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8
//CONTROL "", 102, "LISTBOX", LBS_HASSTRINGS | LBS_NOSEL | LBS_USETABSTOPS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_DISABLENOSCROLL, 5, 92, 255, 138
CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138
CONTROL "", WIN_STARTWIN_BITMAP, "STATIC", SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32
CONTROL "", WIN_STARTWIN_TABCTL, WC_TABCONTROL, WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 250, 170
CONTROL "&Start", WIN_STARTWIN_START, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 154, 180, 48, 14
CONTROL "&Cancel", WIN_STARTWIN_CANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 207, 180, 48, 14
CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32
END
2000 DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL
WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
CAPTION "Dialog"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 64
CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10
CONTROL "&2D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8
CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56
CONTROL "&3D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 47, 37, 8
CONTROL "", 102, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 46, 75, 56
CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17
CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17
CONTROL "&2D Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 8, 50, 8
CONTROL "", IDC2DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56
CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10
CONTROL "&3D Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 24, 50, 8
CONTROL "", IDC3DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 22, 80, 56
CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8
END

View file

@ -1,29 +1,31 @@
#include <windows.h>
#include <commctrl.h>
#include "startwin.game.h"
100 ICON "rsrc/game_icon.ico"
200 BITMAP "rsrc/game.bmp"
RSRC_ICON ICON "rsrc/game_icon.ico"
RSRC_BMP BITMAP "rsrc/game.bmp"
1000 DIALOGEX DISCARDABLE 20, 40, 265, 233
WIN_STARTWIN DIALOGEX DISCARDABLE 20, 40, 260, 200
STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU
CAPTION "Startup"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255
CONTROL "Starting KenBuild...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8
//CONTROL "", 102, "LISTBOX", LBS_HASSTRINGS | LBS_NOSEL | LBS_USETABSTOPS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_DISABLENOSCROLL, 5, 92, 255, 138
CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138
CONTROL "", WIN_STARTWIN_BITMAP, "STATIC", SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32
CONTROL "", WIN_STARTWIN_TABCTL, WC_TABCONTROL, WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 250, 170
CONTROL "&Start", WIN_STARTWIN_START, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 154, 180, 48, 14
CONTROL "&Cancel", WIN_STARTWIN_CANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 207, 180, 48, 14
CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32
END
2000 DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL
WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
CAPTION "Dialog"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 46
CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10
CONTROL "&Mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8
CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56
CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17
CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17
CONTROL "&Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 8, 50, 8
CONTROL "", IDC3DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56
CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10
CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8
END

View file

@ -0,0 +1,450 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="startwin">
<property name="visible">True</property>
<property name="title" translatable="yes">Startup</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="delete_event" handler="on_startwin_delete_event" last_modification_time="Fri, 30 Jun 2006 05:55:35 GMT"/>
<child>
<widget class="GtkHBox" id="hlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="banner">
<property name="visible">True</property>
<property name="pixbuf">game.bmp</property>
<property name="xalign">0.5</property>
<property name="yalign">0</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkNotebook" id="tabs">
<property name="border_width">4</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">True</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkVBox" id="configvlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkFixed" id="configlayout">
<property name="border_width">6</property>
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="vmode2dlabel">
<property name="width_request">88</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<property name="label" translatable="yes">_2D Video mode:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">vmode2dcombo</property>
</widget>
<packing>
<property name="x">0</property>
<property name="y">0</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="vmode3dlabel">
<property name="width_request">88</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<property name="label" translatable="yes">_3D Video mode:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">vmode3dcombo</property>
</widget>
<packing>
<property name="x">0</property>
<property name="y">32</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="fullscreencheck">
<property name="width_request">85</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Fullscreen</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_fullscreencheck_toggled" last_modification_time="Fri, 30 Jun 2006 05:13:03 GMT"/>
<accelerator key="F" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="x">248</property>
<property name="y">0</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="vmode2dcombo">
<property name="width_request">150</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
<signal name="changed" handler="on_vmode2dcombo_changed" last_modification_time="Fri, 30 Jun 2006 05:12:16 GMT"/>
<accelerator key="2" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="x">96</property>
<property name="y">0</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="vmode3dcombo">
<property name="width_request">150</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<signal name="changed" handler="on_vmode3dcombo_changed" last_modification_time="Fri, 30 Jun 2006 05:12:25 GMT"/>
<accelerator key="3" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="x">96</property>
<property name="y">32</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="alwaysshowcheck">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Always show configuration on start</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_alwaysshowcheck_toggled" last_modification_time="Fri, 30 Jun 2006 05:13:09 GMT"/>
<accelerator key="A" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="configtab">
<property name="visible">True</property>
<property name="label" translatable="yes">Configuration</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="messagesscroll">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="messagestext">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="messagestab">
<property name="visible">True</property>
<property name="label" translatable="yes">Messages</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="buttons">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="cancelbutton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_cancelbutton_clicked" last_modification_time="Fri, 30 Jun 2006 05:13:27 GMT"/>
<accelerator key="C" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
<child>
<widget class="GtkAlignment" id="cancelbuttonalign">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="cancelbuttonlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="cancelbuttonicon">
<property name="visible">True</property>
<property name="stock">gtk-cancel</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="cancelbuttonlabel">
<property name="visible">True</property>
<property name="label" translatable="yes">_Cancel</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkButton" id="startbutton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_startbutton_clicked" last_modification_time="Fri, 30 Jun 2006 05:13:37 GMT"/>
<accelerator key="S" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
<child>
<widget class="GtkAlignment" id="startbuttonalign">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="startbuttonlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="startbuttonicon">
<property name="visible">True</property>
<property name="stock">gtk-execute</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="startbuttonlabel">
<property name="visible">True</property>
<property name="label" translatable="yes">_Start</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>Gtkstartwin</name>
<program_name>gtkstartwin</program_name>
<gnome_support>FALSE</gnome_support>
<gettext_support>FALSE</gettext_support>
<output_build_files>FALSE</output_build_files>
<backup_source_files>FALSE</backup_source_files>
</glade-project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -1,37 +1,52 @@
#include "osxbits.h"
#include <Cocoa/Cocoa.h>
#import <Cocoa/Cocoa.h>
#ifndef MAC_OS_VERSION_10_3
# define MAC_OS_VERSION_10_3 1030
#endif
int osx_msgbox(char *name, char *msg)
{
NSAlert *alert = [[NSAlert alloc] init];
NSString *mmsg = [[NSString alloc] initWithCString: msg];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle: @"OK"];
[alert setMessageText: mmsg];
[alert setInformativeText: mmsg];
[alert setAlertStyle: NSInformationalAlertStyle];
[alert runModal];
[alert release];
#else
NSRunAlertPanel(nil, mmsg, @"OK", nil, nil);
#endif
[mmsg release];
return 0;
}
int osx_ynbox(char *name, char *msg)
{
NSAlert *alert = [[NSAlert alloc] init];
NSString *mmsg = [[NSString alloc] initWithCString: msg];
int r;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"Yes"];
[alert addButtonWithTitle:@"No"];
[alert setMessageText: mmsg];
[alert setInformativeText: mmsg];
[alert setAlertStyle: NSInformationalAlertStyle];
r = ([alert runModal] == NSAlertFirstButtonReturn);
[alert release];
#else
r = (NSRunAlertPanel(nil, mmsg, @"Yes", @"No", nil) == NSAlertDefaultReturn);
#endif
[mmsg release];
return r;
}

View file

@ -856,7 +856,7 @@ long trytexcache(char *fn, long len, long dameth, char effect, texcacheheader *h
return -1;
}
md4once(fn, strlen(fn), mdsum);
md4once((unsigned char *)fn, strlen(fn), mdsum);
for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++);
*(cp++) = '/';
for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2);
@ -929,7 +929,7 @@ void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *h
bglGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &gi);
if (gi != GL_TRUE) return;
md4once(fn, strlen(fn), mdsum);
md4once((unsigned char *)fn, strlen(fn), mdsum);
for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++);
*(cp++) = '/';
for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2);
@ -2757,11 +2757,11 @@ static void polymost_drawalls (long bunch)
if ((oy < cy0) && (oy < cy1)) domost(x1,oy,x0,oy);
else if ((oy < cy0) != (oy < cy1))
{ /* cy1 cy0
// / \
//oy---------- oy---------
// / \
// cy0 cy1
*/
// / \
//oy---------- oy---------
// / \
// cy0 cy1
*/
ox = (oy-cy0)*(x1-x0)/(cy1-cy0) + x0;
if (oy < cy0) { domost(ox,oy,x0,oy); domost(x1,cy1,ox,oy); }
else { domost(ox,oy,x0,cy0); domost(x1,oy,ox,oy); }

View file

@ -12,73 +12,7 @@
long dmval;
#if defined(NOASM)
//
// Generic C version
//
void qinterpolatedown16(long bufptr, long num, long val, long add)
{ // gee, I wonder who could have provided this...
long i, *lptr = (long *)bufptr;
for(i=0;i<num;i++) { lptr[i] = (val>>16); val += add; }
}
void qinterpolatedown16short(long bufptr, long num, long val, long add)
{ // ...maybe the same person who provided this too?
long i; short *sptr = (short *)bufptr;
for(i=0;i<num;i++) { sptr[i] = (short)(val>>16); val += add; }
}
void clearbuf(void *d, long c, long a)
{
long *p = (long*)d;
while ((c--) > 0) *(p++) = a;
}
void copybuf(void *s, void *d, long c)
{
long *p = (long*)s, *q = (long*)d;
while ((c--) > 0) *(q++) = *(p++);
}
void swapbuf4(void *a, void *b, long c)
{
long *p = (long*)a, *q = (long*)b;
long x, y;
while ((c--) > 0) {
x = *q;
y = *p;
*(q++) = y;
*(p++) = x;
}
}
void clearbufbyte(void *D, long c, long a)
{ // Cringe City
char *p = (char*)D;
long m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l };
long n[4] = { 0,8,16,24 };
long z=0;
while ((c--) > 0) {
*(p++) = (char)((a & m[z])>>n[z]);
z=(z+1)&3;
}
}
void copybufbyte(void *S, void *D, long c)
{
char *p = (char*)S, *q = (char*)D;
while((c--) > 0) *(q++) = *(p++);
}
void copybufreverse(void *S, void *D, long c)
{
char *p = (char*)S, *q = (char*)D;
while((c--) > 0) *(q++) = *(p--);
}
#elif defined(__GNUC__) && defined(__i386__) // NOASM
#if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // NOASM
//
// GCC Inline Assembler version
@ -229,13 +163,13 @@ void copybufreverse(void *S, void *D, long c)
);
}
#elif defined(__WATCOMC__) // __GNUC__ && __i386__
#elif defined(__WATCOMC__) && !defined(NOASM) // __GNUC__ && __i386__
//
// Watcom C Inline Assembler version
//
#elif defined(_MSC_VER) // __WATCOMC__
#elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__
//
// Microsoft C Inline Assembler version
@ -243,7 +177,69 @@ void copybufreverse(void *S, void *D, long c)
#else // _MSC_VER
#error Unsupported compiler or architecture.
//
// Generic C version
//
void qinterpolatedown16(long bufptr, long num, long val, long add)
{ // gee, I wonder who could have provided this...
long i, *lptr = (long *)bufptr;
for(i=0;i<num;i++) { lptr[i] = (val>>16); val += add; }
}
void qinterpolatedown16short(long bufptr, long num, long val, long add)
{ // ...maybe the same person who provided this too?
long i; short *sptr = (short *)bufptr;
for(i=0;i<num;i++) { sptr[i] = (short)(val>>16); val += add; }
}
void clearbuf(void *d, long c, long a)
{
long *p = (long*)d;
while ((c--) > 0) *(p++) = a;
}
void copybuf(void *s, void *d, long c)
{
long *p = (long*)s, *q = (long*)d;
while ((c--) > 0) *(q++) = *(p++);
}
void swapbuf4(void *a, void *b, long c)
{
long *p = (long*)a, *q = (long*)b;
long x, y;
while ((c--) > 0) {
x = *q;
y = *p;
*(q++) = y;
*(p++) = x;
}
}
void clearbufbyte(void *D, long c, long a)
{ // Cringe City
char *p = (char*)D;
long m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l };
long n[4] = { 0,8,16,24 };
long z=0;
while ((c--) > 0) {
*(p++) = (char)((a & m[z])>>n[z]);
z=(z+1)&3;
}
}
void copybufbyte(void *S, void *D, long c)
{
char *p = (char*)S, *q = (char*)D;
while((c--) > 0) *(q++) = *(p++);
}
void copybufreverse(void *S, void *D, long c)
{
char *p = (char*)S, *q = (char*)D;
while((c--) > 0) *(q++) = *(p--);
}
#endif

View file

@ -26,6 +26,12 @@
# include "osxbits.h"
#elif defined HAVE_GTK2
# include "gtkbits.h"
#else
int startwin_open(void) { return 0; }
int startwin_close(void) { return 0; }
int startwin_puts(const char *s) { s=s; return 0; }
int startwin_idle(void *s) { return 0; }
int startwin_settitle(const char *s) { s=s; return 0; }
#endif
#define SURFACE_FLAGS (SDL_SWSURFACE|SDL_HWPALETTE|SDL_HWACCEL)
@ -130,9 +136,7 @@ void wm_setapptitle(char *name)
SDL_WM_SetCaption(apptitle, NULL);
#ifdef HAVE_GTK2
gtkbuild_settitle_startwin(apptitle);
#endif
startwin_settitle(apptitle);
}
@ -154,8 +158,8 @@ int main(int argc, char *argv[])
#ifdef HAVE_GTK2
gtkbuild_init(&argc, &argv);
gtkbuild_create_startwin();
#endif
startwin_open();
_buildargc = argc;
_buildargv = (char**)argv;
@ -165,8 +169,8 @@ int main(int argc, char *argv[])
baselayer_init();
r = app_main(argc, argv);
startwin_close();
#ifdef HAVE_GTK2
gtkbuild_close_startwin();
gtkbuild_exit(r);
#endif
return r;
@ -280,10 +284,8 @@ void initprintf(const char *f, ...)
va_end(va);
OSD_Printf(buf);
#ifdef HAVE_GTK2
gtkbuild_puts_startwin(buf);
gtkbuild_update_startwin();
#endif
startwin_puts(buf);
startwin_idle(NULL);
}
@ -689,6 +691,9 @@ void getvalidmodes(void)
// do fullscreen modes first
for (j=0; cdepths[j]; j++) {
#ifdef USE_OPENGL
if (nogl && cdepths[j] > 8) continue;
#endif
pf.BitsPerPixel = cdepths[j];
pf.BytesPerPixel = cdepths[j] >> 3;
@ -722,6 +727,9 @@ void getvalidmodes(void)
// add windowed modes next
for (j=0; cdepths[j]; j++) {
#ifdef USE_OPENGL
if (nogl && cdepths[j] > 8) continue;
#endif
if (cdepths[j] < 0) continue;
for (i=0; defaultres[i][0]; i++)
CHECK(defaultres[i][0],defaultres[i][1])
@ -740,7 +748,7 @@ void getvalidmodes(void)
//
// checkvideomode() -- makes sure the video mode passed is legal
//
int checkvideomode(int *x, int *y, int c, int fs)
int checkvideomode(int *x, int *y, int c, int fs, int forced)
{
int i, nearest=-1, dx, dy, odx=9999, ody=9999;
@ -775,10 +783,10 @@ int checkvideomode(int *x, int *y, int c, int fs)
}
}
#ifdef ANY_WINDOWED_SIZE
if ((fs&1) == 0 && (nearest < 0 || (validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y)))
#ifdef ANY_WINDOWED_SIZE
if (!forced && (fs&1) == 0 && (nearest < 0 || (validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y)))
return 0x7fffffffl;
#endif
#endif
if (nearest < 0) {
// no mode that will match (eg. if no fullscreen modes)
@ -806,11 +814,9 @@ int setvideomode(int x, int y, int c, int fs)
return 0;
}
if (checkvideomode(&x,&y,c,fs) < 0) return -1;
if (checkvideomode(&x,&y,c,fs,0) < 0) return -1;
#ifdef HAVE_GTK2
gtkbuild_close_startwin();
#endif
startwin_close();
if (mouseacquired) {
regrab = 1;
@ -1365,9 +1371,7 @@ int handleevents(void)
sampletimer();
#ifdef HAVE_GTK2
gtkbuild_update_startwin();
#endif
startwin_idle(NULL);
#undef SetKey

View file

@ -0,0 +1,607 @@
/* NOTE: Glade will generate code for a dialogue box which you should
* then patch into this file whenever you make a change to the Glade
* template.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <gdk-pixbuf/gdk-pixdata.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "baselayer.h"
#include "compat.h"
#include "build.h"
#include "editor.h"
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct {
int fullscreen;
int xdim2d, ydim2d;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
} settings;
extern int gtkenabled;
static GtkWidget *startwin = NULL;
static int retval = -1, mode = 0;
// -- 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)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
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)
{
extern const GdkPixdata startbanner_pixdata;
return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL);
}
static void SetPage(int n)
{
if (!gtkenabled || !startwin) return;
gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n);
}
static void EnableConfig(int n)
{
// each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive
mode = n;
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)mode);
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)mode);
}
static void on_vmode2dcombo_changed(GtkComboBox *, gpointer);
static void on_vmode3dcombo_changed(GtkComboBox *, gpointer);
static void PopulateForm(void)
{
int mode2d, mode3d, i;
GtkListStore *modes2d, *modes3d;
GtkTreeIter iter;
GtkComboBox *box2d, *box3d;
char buf[64];
mode2d = checkvideomode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1);
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode2d < 0) mode2d = 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++) {
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
break;
}
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup);
box2d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode2dcombo"));
box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo"));
modes2d = GTK_LIST_STORE(gtk_combo_box_get_model(box2d));
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes2d);
gtk_list_store_clear(modes3d);
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) {
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);
}
// only 8-bit modes get used for 2D
if (validmode[i].bpp != 8) continue;
Bsprintf(buf, "%ld x %ld", validmode[i].xdim, validmode[i].ydim);
gtk_list_store_append(modes2d, &iter);
gtk_list_store_set(modes2d, &iter, 0,buf, 1,i, -1);
if (i == mode2d) {
g_signal_handlers_block_by_func(box2d, on_vmode2dcombo_changed, NULL);
gtk_combo_box_set_active_iter(box2d, &iter);
g_signal_handlers_unblock_by_func(box2d, on_vmode2dcombo_changed, NULL);
}
}
}
// -- EVENT CALLBACKS AND CREATION STUFF --------------------------------------
static void on_vmode2dcombo_changed(GtkComboBox *combobox, gpointer user_data)
{
GtkTreeModel *data;
GtkTreeIter iter;
int val;
if (!gtk_combo_box_get_active_iter(combobox, &iter)) return;
if (!(data = gtk_combo_box_get_model(combobox))) return;
gtk_tree_model_get(data, &iter, 1, &val, -1);
settings.xdim2d = validmode[val].xdim;
settings.ydim2d = validmode[val].ydim;
}
static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data)
{
GtkTreeModel *data;
GtkTreeIter iter;
int val;
if (!gtk_combo_box_get_active_iter(combobox, &iter)) return;
if (!(data = gtk_combo_box_get_model(combobox))) return;
gtk_tree_model_get(data, &iter, 1, &val, -1);
settings.xdim3d = validmode[val].xdim;
settings.ydim3d = validmode[val].ydim;
}
static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
settings.fullscreen = (gtk_toggle_button_get_active(togglebutton) == TRUE);
PopulateForm();
}
static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
settings.forcesetup = (gtk_toggle_button_get_active(togglebutton) == TRUE);
}
static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data)
{
retval = 0;
gtk_main_quit();
}
static void on_startbutton_clicked(GtkButton *button, gpointer user_data)
{
retval = 1;
gtk_main_quit();
}
static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
//quitevent++;
return TRUE; // FALSE would let the event go through. we want the game to decide when to close
}
static GtkWidget *create_window(void)
{
GtkWidget *startwin;
GtkWidget *hlayout;
GtkWidget *banner;
GtkWidget *vlayout;
GtkWidget *tabs;
GtkWidget *configvlayout;
GtkWidget *configlayout;
GtkWidget *vmode2dlabel;
GtkWidget *vmode3dlabel;
GtkWidget *vmode2dcombo;
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 ();
// 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);
// 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);
// 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);
// 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);
// 2D video mode label
vmode2dlabel = gtk_label_new_with_mnemonic ("_2D Video mode:");
gtk_widget_show (vmode2dlabel);
gtk_fixed_put (GTK_FIXED (configlayout), vmode2dlabel, 0, 0);
gtk_widget_set_size_request (vmode2dlabel, 88, 29);
gtk_misc_set_alignment (GTK_MISC (vmode2dlabel), 0, 0.5);
// 3D video mode label
vmode3dlabel = gtk_label_new_with_mnemonic ("_3D Video mode:");
gtk_widget_show (vmode3dlabel);
gtk_fixed_put (GTK_FIXED (configlayout), vmode3dlabel, 0, 32);
gtk_widget_set_size_request (vmode3dlabel, 88, 29);
gtk_misc_set_alignment (GTK_MISC (vmode3dlabel), 0, 0.5);
// 2D video mode combo
{
GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
GtkCellRenderer *cell;
vmode2dcombo = 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(vmode2dcombo), cell, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(vmode2dcombo), cell, "text", 0, NULL);
}
gtk_widget_show (vmode2dcombo);
gtk_fixed_put (GTK_FIXED (configlayout), vmode2dcombo, 96, 0);
gtk_widget_set_size_request (vmode2dcombo, 150, 29);
gtk_widget_add_accelerator (vmode2dcombo, "grab_focus", accel_group,
GDK_2, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// 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));
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, 96, 32);
gtk_widget_set_size_request (vmode3dcombo, 150, 29);
gtk_widget_add_accelerator (vmode3dcombo, "grab_focus", accel_group,
GDK_3, 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);
// 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 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);
// 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);
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);
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);
// 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);
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);
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);
// Wire up the signals
g_signal_connect ((gpointer) startwin, "delete_event",
G_CALLBACK (on_startwin_delete_event),
NULL);
g_signal_connect ((gpointer) vmode2dcombo, "changed",
G_CALLBACK (on_vmode2dcombo_changed),
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 (vmode2dlabel), vmode2dcombo);
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, vmode2dlabel, "vmode2dlabel");
GLADE_HOOKUP_OBJECT (startwin, vmode3dlabel, "vmode3dlabel");
GLADE_HOOKUP_OBJECT (startwin, vmode2dcombo, "vmode2dcombo");
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);
return startwin;
}
// -- BUILD ENTRY POINTS ------------------------------------------------------
int startwin_open(void)
{
if (!gtkenabled) return 0;
if (startwin) return 1;
startwin = create_window();
if (startwin) {
SetPage(TAB_MESSAGES);
EnableConfig(FALSE);
gtk_widget_show(startwin);
gtk_main_iteration_do(FALSE);
return 0;
}
return -1;
}
int startwin_close(void)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
gtk_widget_destroy (startwin);
startwin = NULL;
return 0;
}
int startwin_puts(const char *str)
{
GtkWidget *textview;
GtkTextBuffer *textbuffer;
GtkTextIter enditer;
GtkTextMark *mark;
const char *aptr, *bptr;
if (!gtkenabled || !str) return 0;
if (!startwin) return 1;
if (!(textview = lookup_widget(startwin, "messagestext"))) return -1;
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);
#if GTK_CHECK_VERSION(2,6,0)
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;
}
}
mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1);
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0);
gtk_text_buffer_delete_mark(textbuffer, mark);
return 0;
}
int startwin_settitle(const char *title)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
gtk_window_set_title (GTK_WINDOW (startwin), title);
return 0;
}
int startwin_idle(void *s)
{
if (!gtkenabled) return 0;
//if (!startwin) return 1;
gtk_main_iteration_do (FALSE);
return 0;
}
int startwin_run(void)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
SetPage(TAB_CONFIG);
EnableConfig(TRUE);
settings.fullscreen = fullscreen;
settings.xdim2d = xdim2d;
settings.ydim2d = ydim2d;
settings.xdim3d = xdimgame;
settings.ydim3d = ydimgame;
settings.bpp3d = bppgame;
settings.forcesetup = forcesetup;
PopulateForm();
gtk_main();
SetPage(TAB_MESSAGES);
EnableConfig(FALSE);
if (retval) {
fullscreen = settings.fullscreen;
xdim2d = settings.xdim2d;
ydim2d = settings.ydim2d;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;
bppgame = settings.bpp3d;
forcesetup = settings.forcesetup;
}
return retval;
}

540
polymer/build/src/startgtk.game.c Executable file
View file

@ -0,0 +1,540 @@
/* NOTE: Glade will generate code for a dialogue box which you should
* then patch into this file whenever you make a change to the Glade
* template.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <gdk-pixbuf/gdk-pixdata.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "baselayer.h"
#include "compat.h"
#include "build.h"
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct {
int fullscreen;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
} settings;
extern int gtkenabled;
static GtkWidget *startwin = NULL;
static int retval = -1, mode = 0;
// -- 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)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
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)
{
extern const GdkPixdata startbanner_pixdata;
return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL);
}
static void SetPage(int n)
{
if (!gtkenabled || !startwin) return;
gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n);
}
static void EnableConfig(int n)
{
// each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive
mode = n;
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)mode);
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)mode);
}
static void on_vmode3dcombo_changed(GtkComboBox *, gpointer);
static void PopulateForm(void)
{
int mode3d, i;
GtkListStore *modes3d;
GtkTreeIter iter;
GtkComboBox *box3d;
char buf[64];
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode3d < 0) {
int i, cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; }
for ( ; cd[i]; i++) {
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
break;
}
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup);
box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo"));
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes3d);
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) {
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);
}
}
}
// -- EVENT CALLBACKS AND CREATION STUFF --------------------------------------
static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data)
{
GtkTreeModel *data;
GtkTreeIter iter;
int val;
if (!gtk_combo_box_get_active_iter(combobox, &iter)) return;
if (!(data = gtk_combo_box_get_model(combobox))) return;
gtk_tree_model_get(data, &iter, 1, &val, -1);
settings.xdim3d = validmode[val].xdim;
settings.ydim3d = validmode[val].ydim;
}
static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
settings.fullscreen = (gtk_toggle_button_get_active(togglebutton) == TRUE);
PopulateForm();
}
static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
settings.forcesetup = (gtk_toggle_button_get_active(togglebutton) == TRUE);
}
static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data)
{
retval = 0;
gtk_main_quit();
}
static void on_startbutton_clicked(GtkButton *button, gpointer user_data)
{
retval = 1;
gtk_main_quit();
}
static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
//quitevent++;
return TRUE; // FALSE would let the event go through. we want the game to decide when to close
}
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;
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);
// 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);
// 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);
// 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);
// 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;
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);
// 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);
// 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 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);
// 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);
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);
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);
// 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);
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);
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);
// 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);
/* 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);
return startwin;
}
// -- BUILD ENTRY POINTS ------------------------------------------------------
int startwin_open(void)
{
if (!gtkenabled) return 0;
if (startwin) return 1;
startwin = create_window();
if (startwin) {
SetPage(TAB_MESSAGES);
EnableConfig(FALSE);
gtk_widget_show(startwin);
gtk_main_iteration_do(FALSE);
return 0;
}
return -1;
}
int startwin_close(void)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
gtk_widget_destroy (startwin);
startwin = NULL;
return 0;
}
int startwin_puts(const char *str)
{
GtkWidget *textview;
GtkTextBuffer *textbuffer;
GtkTextIter enditer;
GtkTextMark *mark;
const char *aptr, *bptr;
if (!gtkenabled || !str) return 0;
if (!startwin) return 1;
if (!(textview = lookup_widget(startwin, "messagestext"))) return -1;
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);
#if GTK_CHECK_VERSION(2,6,0)
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;
}
}
mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1);
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0);
gtk_text_buffer_delete_mark(textbuffer, mark);
return 0;
}
int startwin_settitle(const char *title)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
gtk_window_set_title (GTK_WINDOW (startwin), title);
return 0;
}
int startwin_idle(void *s)
{
if (!gtkenabled) return 0;
//if (!startwin) return 1;
gtk_main_iteration_do (FALSE);
return 0;
}
extern int xdimgame, ydimgame, bppgame, forcesetup;
int startwin_run(void)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
SetPage(TAB_CONFIG);
EnableConfig(TRUE);
settings.fullscreen = fullscreen;
settings.xdim3d = xdimgame;
settings.ydim3d = ydimgame;
settings.bpp3d = bppgame;
settings.forcesetup = forcesetup;
PopulateForm();
gtk_main();
SetPage(TAB_MESSAGES);
EnableConfig(FALSE);
if (retval) {
fullscreen = settings.fullscreen;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;
bppgame = settings.bpp3d;
forcesetup = settings.forcesetup;
}
return retval;
}

View file

@ -0,0 +1,442 @@
#ifndef RENDERTYPEWIN
#error Only for Windows
#endif
#include "build.h"
#include "editor.h"
#include "winlayer.h"
#include "compat.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#define _WIN32_IE 0x0300
#include <commctrl.h>
#include <stdio.h>
#include "startwin.editor.h"
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct {
int fullscreen;
int xdim2d, ydim2d;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
} settings;
static HWND startupdlg = NULL;
static HWND pages[2] = { NULL, NULL};
static int done = -1;
static void PopulateForm(void)
{
int i,j;
char buf[64];
int mode2d, mode3d;
HWND hwnd2d, hwnd3d;
hwnd2d = GetDlgItem(pages[TAB_CONFIG], IDC2DVMODE);
hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE);
mode2d = checkvideomode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1);
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode2d < 0) mode2d = 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++) {
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
break;
}
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
ComboBox_ResetContent(hwnd2d);
ComboBox_ResetContent(hwnd3d);
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);
j = ComboBox_AddString(hwnd3d, buf);
ComboBox_SetItemData(hwnd3d, j, i);
if (i == mode3d) ComboBox_SetCurSel(hwnd3d, j);
// only 8-bit modes get used for 2D
if (validmode[i].bpp != 8) continue;
Bsprintf(buf, "%ld x %ld", validmode[i].xdim, validmode[i].ydim);
j = ComboBox_AddString(hwnd2d, buf);
ComboBox_SetItemData(hwnd2d, j, i);
if (i == mode2d) ComboBox_SetCurSel(hwnd2d, j);
}
}
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 IDC2DVMODE:
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.xdim2d = validmode[i].xdim;
settings.ydim2d = validmode[i].ydim;
}
}
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;
}
break;
default: break;
}
return FALSE;
}
static void SetPage(int n)
{
HWND tab;
int cur;
tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0);
ShowWindow(pages[cur],SW_HIDE);
SendMessage(tab, TCM_SETCURSEL, n, 0);
ShowWindow(pages[n],SW_SHOW);
}
static void EnableConfig(int n)
{
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC2DVMODE), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE), n);
}
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
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;
// 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;
// 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;
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;
// 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);
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: {
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;
}
case WM_CLOSE:
done = 0;
return TRUE;
case WM_DESTROY:
if (hbmp) {
DeleteObject(hbmp);
hbmp = NULL;
}
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: done = 0; 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;
}
int startwin_open(void)
{
INITCOMMONCONTROLSEX icc;
if (startupdlg) return 1;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) {
SetPage(TAB_MESSAGES);
EnableConfig(0);
return 0;
}
return -1;
}
int startwin_close(void)
{
if (!startupdlg) return 1;
DestroyWindow(startupdlg);
startupdlg = NULL;
return 0;
}
int startwin_puts(const char *buf)
{
const char *p = NULL, *q = NULL;
char workbuf[1024];
static int newline = 0;
int curlen, linesbefore, linesafter;
HWND edctl;
int vis;
if (!startupdlg) return 1;
edctl = pages[TAB_MESSAGES];
if (!edctl) return -1;
vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES);
if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf;
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]) {
newline = 1;
workbuf[q-p] = 0;
} else {
workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0;
}
p = q+1;
} else {
workbuf[q-p] = 0;
p = q;
}
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
}
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
return 0;
}
int startwin_settitle(const char *str)
{
if (!startupdlg) return 1;
SetWindowText(startupdlg, str);
return 0;
}
int startwin_idle(void *v)
{
if (!startupdlg || !IsWindow(startupdlg)) return 0;
if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
return 0;
}
int startwin_run(void)
{
MSG msg;
if (!startupdlg) return 1;
done = -1;
SetPage(TAB_CONFIG);
EnableConfig(1);
settings.fullscreen = fullscreen;
settings.xdim2d = xdim2d;
settings.ydim2d = ydim2d;
settings.xdim3d = xdimgame;
settings.ydim3d = ydimgame;
settings.bpp3d = bppgame;
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;
}
}
SetPage(TAB_MESSAGES);
EnableConfig(0);
if (done) {
fullscreen = settings.fullscreen;
xdim2d = settings.xdim2d;
ydim2d = settings.ydim2d;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;
bppgame = settings.bpp3d;
forcesetup = settings.forcesetup;
}
return done;
}

415
polymer/build/src/startwin.game.c Executable file
View file

@ -0,0 +1,415 @@
#ifndef RENDERTYPEWIN
#error Only for Windows
#endif
#include "build.h"
#include "winlayer.h"
#include "compat.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#define _WIN32_IE 0x0300
#include <commctrl.h>
#include <stdio.h>
#include "startwin.game.h"
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct {
int fullscreen;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
} settings;
static HWND startupdlg = NULL;
static HWND pages[2] = { NULL, NULL};
static int done = -1;
static void PopulateForm(void)
{
int i,j;
char buf[64];
int mode3d;
HWND hwnd3d;
hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE);
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
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++) {
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
break;
}
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
ComboBox_ResetContent(hwnd3d);
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);
j = ComboBox_AddString(hwnd3d, buf);
ComboBox_SetItemData(hwnd3d, j, i);
if (i == mode3d) ComboBox_SetCurSel(hwnd3d, j);
}
}
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;
}
break;
default: break;
}
return FALSE;
}
static void SetPage(int n)
{
HWND tab;
int cur;
tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0);
ShowWindow(pages[cur],SW_HIDE);
SendMessage(tab, TCM_SETCURSEL, n, 0);
ShowWindow(pages[n],SW_SHOW);
}
static void EnableConfig(int n)
{
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE), n);
}
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
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;
// 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;
// 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;
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;
// 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);
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: {
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;
}
case WM_CLOSE:
done = 0;
return TRUE;
case WM_DESTROY:
if (hbmp) {
DeleteObject(hbmp);
hbmp = NULL;
}
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: done = 0; 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;
}
int startwin_open(void)
{
INITCOMMONCONTROLSEX icc;
if (startupdlg) return 1;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) {
SetPage(TAB_MESSAGES);
EnableConfig(0);
return 0;
}
return -1;
}
int startwin_close(void)
{
if (!startupdlg) return 1;
DestroyWindow(startupdlg);
startupdlg = NULL;
return 0;
}
int startwin_puts(const char *buf)
{
const char *p = NULL, *q = NULL;
char workbuf[1024];
static int newline = 0;
int curlen, linesbefore, linesafter;
HWND edctl;
int vis;
if (!startupdlg) return 1;
edctl = pages[TAB_MESSAGES];
if (!edctl) return -1;
vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES);
if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf;
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]) {
newline = 1;
workbuf[q-p] = 0;
} else {
workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0;
}
p = q+1;
} else {
workbuf[q-p] = 0;
p = q;
}
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
}
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
return 0;
}
int startwin_settitle(const char *str)
{
if (!startupdlg) return 1;
SetWindowText(startupdlg, str);
return 0;
}
int startwin_idle(void *v)
{
if (!startupdlg || !IsWindow(startupdlg)) return 0;
if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
return 0;
}
extern int xdimgame, ydimgame, bppgame, forcesetup;
int startwin_run(void)
{
MSG msg;
if (!startupdlg) return 1;
done = -1;
SetPage(TAB_CONFIG);
EnableConfig(1);
settings.fullscreen = fullscreen;
settings.xdim3d = xdimgame;
settings.ydim3d = ydimgame;
settings.bpp3d = bppgame;
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;
}
}
SetPage(TAB_MESSAGES);
EnableConfig(0);
if (done) {
fullscreen = settings.fullscreen;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;
bppgame = settings.bpp3d;
forcesetup = settings.forcesetup;
}
return done;
}

View file

@ -0,0 +1,18 @@
// resource ids
#define WIN_STARTWIN 1000
#define WIN_STARTWINPAGE_CONFIG 2000
#define WIN_STARTWIN_BITMAP 100 // banner bitmap
#define WIN_STARTWIN_TABCTL 101
#define WIN_STARTWIN_CANCEL 102
#define WIN_STARTWIN_START 103
#define WIN_STARTWIN_MESSAGES 104 // output list box
#define RSRC_ICON 100
#define RSRC_BMP 200
// config page
#define IDCFULLSCREEN 100
#define IDC3DVMODE 101
#define IDCALWAYSSHOW 102

View file

@ -56,10 +56,6 @@ static HWND hWindow = 0;
static BOOL window_class_registered = FALSE;
static HANDLE instanceflag = NULL;
static HWND startupdlg = NULL;
static long startupdlgsaferect[4] = { -1,-1,-1,-1 };
static int startupdlgcommand = 0;
static void (*startupdlgonclose)(void) = NULL;
int backgroundidle = 1;
static WORD sysgamma[3][256];
@ -233,11 +229,7 @@ void wm_setapptitle(char *name)
}
if (hWindow) SetWindowText(hWindow, apptitle);
if (startupdlg) {
char buf[1000];
Bsnprintf(buf, 1000, "%s Startup", apptitle);
SetWindowText(startupdlg, buf);
}
startwin_settitle(apptitle);
}
//
@ -256,143 +248,6 @@ static void SignalHandler(int signum)
}
}
//
// startup_dlgproc() -- dialog procedure for the initialisation dialog
//
#define FIELDSWIDE 366
#define PADWIDE 5 // 5 units of padding
// An overlayed child dialog should have the DS_CONTROL style
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HBITMAP hbmp = NULL;
RECT rdlg, rbmp, rtxt;
HDC hdc;
int height=5;
switch (uMsg) {
case WM_INITDIALOG:
// set the bitmap
hbmp = LoadBitmap(hInstance, MAKEINTRESOURCE(WIN_STARTWINBMP));
SendDlgItemMessage(hwndDlg, WIN_STARTWIN_ITEMBITMAP, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
// fetch the adjusted size
GetClientRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMBITMAP), &rbmp);
rbmp.right++; rbmp.bottom++;
GetClientRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMTEXT), &rtxt);
rtxt.bottom++;
// move the bitmap to the top of the client area
MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMBITMAP),
0,0, rbmp.right,rbmp.bottom,
FALSE);
// move the label
MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMTEXT),
rbmp.right+PADWIDE,PADWIDE, FIELDSWIDE,rtxt.bottom,
FALSE);
// move the list box
MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMLIST),
rbmp.right+PADWIDE,PADWIDE+rtxt.bottom+PADWIDE,
FIELDSWIDE,rbmp.bottom-(PADWIDE+rtxt.bottom+PADWIDE+PADWIDE),
FALSE);
SendDlgItemMessage(hwndDlg,WIN_STARTWIN_ITEMLIST, EM_LIMITTEXT, 0,0);
{
RECT rg;
GetWindowRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMLIST),&rg);
rg.right -= rg.left + GetSystemMetrics(SM_CXVSCROLL)+4;
rg.bottom -= rg.top;
rg.left = rg.top = 0;
SendDlgItemMessage(hwndDlg,WIN_STARTWIN_ITEMLIST, EM_SETRECTNP,0,(LPARAM)&rg);
}
rdlg.left = 0;
rdlg.top = 0;
rdlg.right = rbmp.right+PADWIDE+FIELDSWIDE+PADWIDE;
rdlg.bottom = rbmp.bottom;
AdjustWindowRect(&rdlg,
GetWindowLong(hwndDlg, GWL_STYLE),
FALSE);
rdlg.right -= rdlg.left;
rdlg.bottom -= rdlg.top;
hdc = GetDC(NULL);
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
ReleaseDC(NULL, hdc);
SetWindowPos(hwndDlg,NULL,
rdlg.left,rdlg.top,
rdlg.right,rdlg.bottom,
SWP_NOREPOSITION);
// save the safe region of the window
startupdlgsaferect[0] = rbmp.right; // left
startupdlgsaferect[1] = 0; // top
startupdlgsaferect[2] = PADWIDE+FIELDSWIDE+PADWIDE; // width
startupdlgsaferect[3] = rbmp.bottom; // height
return TRUE;
case WM_CLOSE:
quitevent = 1;
return TRUE;
case WM_DESTROY:
if (hbmp) {
DeleteObject(hbmp);
hbmp = NULL;
}
if (startupdlgonclose) startupdlgonclose();
startupdlg = NULL;
return TRUE;
case WM_COMMAND:
startupdlgcommand = LOWORD(wParam);
return FALSE;
case WM_CTLCOLORSTATIC:
switch (GetDlgCtrlID((HWND)lParam)) {
case WIN_STARTWIN_ITEMLIST:
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
default: break;
}
break;
default: break;
}
return FALSE;
}
int win_getstartupwin(long *hwnd, long saferect[4], void (*onclose)(void))
{
if (!startupdlg) return 1;
*hwnd = (long)startupdlg;
memcpy(saferect, startupdlgsaferect, sizeof(long)*4);
startupdlgonclose = onclose;
return 0;
}
int win_getstartupcommand(void)
{
int t = startupdlgcommand;
startupdlgcommand = 0;
return t;
}
//
// WinMain() -- main Windows entry point
//
@ -502,16 +357,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
atexit(uninitsystem);
baselayer_init();
instanceflag = CreateSemaphore(NULL, 1,1, WindowClass);
startupdlg = CreateDialog(hInstance, MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
startwin_open();
baselayer_init();
r = app_main(_buildargc, _buildargv);
fclose(stdout);
startwin_close();
if (instanceflag) CloseHandle(instanceflag);
if (argvbuf) free(argvbuf);
@ -593,9 +448,7 @@ void uninitsystem(void)
{
DestroyAppWindow();
if (startupdlg) {
DestroyWindow(startupdlg);
}
startwin_close();
uninitinput();
uninittimer();
@ -615,57 +468,12 @@ void initprintf(const char *f, ...)
{
va_list va;
char buf[1024],*p=NULL,*q=NULL,workbuf[1024];
//int i = 0;
static int newline = 0;//1;
// int overwriteline = -1;
va_start(va, f);
Bvsnprintf(buf, 1024, f, va);
va_end(va);
OSD_Printf(buf);
if (!startupdlg) return;
{
int curlen, linesbefore, linesafter;
HWND edctl;
edctl = GetDlgItem(startupdlg,102);
if (!edctl) return;
SendMessage(edctl, WM_SETREDRAW, FALSE,0);
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf;
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]) {
newline = 1;
workbuf[q-p] = 0;
} else {
workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0;
}
p = q+1;
} else {
workbuf[q-p] = 0;
p = q;
}
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
}
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
SendMessage(edctl, WM_SETREDRAW, TRUE,0);
}
startwin_puts(buf);
handleevents();
}
@ -705,7 +513,7 @@ int handleevents(void)
if (msg.message == WM_QUIT)
quitevent = 1;
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) continue;
if (startwin_idle((void*)&msg) > 0) continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
@ -1531,67 +1339,6 @@ static void ProcessInputDevices(void)
for (i=0; i<dwElements; i++) {
k = didod[i].dwOfs;
#if 0
// When NumLock is on, the shift keys interact differently with the
// numeric keypad, so we cook things a little bit to work around
// the quirks.
if (numlockon) {
#define NUMPAD 1
#define SHIFT 2
#define UP 0
#define DOWN 4
DWORD j, thiskey = 0, nextkey = 0;
for (j=i; j<=min(i+1,dwElements-1); j++) {
switch (didod[j].dwOfs) {
case DIK_NUMPAD1: case DIK_NUMPAD2: case DIK_NUMPAD3:
case DIK_NUMPAD4: case DIK_NUMPAD5: case DIK_NUMPAD6:
case DIK_NUMPAD7: case DIK_NUMPAD8: case DIK_NUMPAD9:
case DIK_NUMPAD0: case DIK_PERIOD:
if (j==i) thiskey = NUMPAD | ((didod[j].dwData&128)?DOWN:UP);
else nextkey = NUMPAD | ((didod[j].dwData&128)?DOWN:UP);
break;
case DIK_LSHIFT: case DIK_RSHIFT:
if (j==i) thiskey = SHIFT | ((didod[j].dwData&128)?DOWN:UP);
else nextkey = SHIFT | ((didod[j].dwData&128)?DOWN:UP);
break;
default: break;
}
}
if (!shiftkey) {
if (thiskey == (SHIFT|DOWN)) {
shiftkey = 1, shiftkeycount = 0;
initprintf("shift is down --> shiftkey=1, shiftkeycount=0\n");
}
} else {
if ((thiskey == (SHIFT|UP)) && (nextkey == (NUMPAD|DOWN))) {
shiftkeycount--;
initprintf("shift is up and next key is numpad and down, shiftkeycount=%d\n",
shiftkeycount);
continue;
} else if (thiskey & SHIFT) {
if (thiskey & DOWN) {
shiftkeycount++;
initprintf("shift key down, shiftkeycount=%d\n", shiftkeycount);
continue;
} else {
if (shiftkeycount == 0) {
shiftkey = 0;
initprintf("shift key up and shiftkeycount == 0, shiftkey=0\n");
} else {
shiftkeycount--;
initprintf("shift key up and shiftkeycount=%d\n",shiftkeycount);
continue;
}
}
}
}
#undef NUMPAD
#undef SHIFT
#undef UP
#undef DOWN
}
#endif
if (k == DIK_PAUSE) continue; // fucking pause
// hook in the osd
@ -1960,7 +1707,7 @@ static int getgammaramp(WORD gt[3][256]);
//
// checkvideomode() -- makes sure the video mode passed is legal
//
int checkvideomode(int *x, int *y, int c, int fs)
int checkvideomode(int *x, int *y, int c, int fs, int forced)
{
int i, nearest=-1, dx, dy, odx=9999, ody=9999;
@ -1990,7 +1737,7 @@ int checkvideomode(int *x, int *y, int c, int fs)
}
#ifdef ANY_WINDOWED_SIZE
if ((fs&1) == 0 && (nearest < 0 || validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y)) {
if (!forced && (fs&1) == 0 && (nearest < 0 || validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y)) {
// check the colour depth is recognised at the very least
for (i=0;i<validmodecnt;i++)
if (validmode[i].bpp == c)
@ -2025,7 +1772,7 @@ int setvideomode(int x, int y, int c, int fs)
return 0;
}
modenum = checkvideomode(&x,&y,c,fs);
modenum = checkvideomode(&x,&y,c,fs,0);
if (modenum < 0) return -1;
if (modenum == 0x7fffffff) {
customxdim = x;
@ -3190,9 +2937,7 @@ static BOOL CreateAppWindow(int modenum, char *wtitle)
return TRUE;
}
if (startupdlg) {
DestroyWindow(startupdlg);
}
startwin_close();
} else {
SetWindowLong(hWindow,GWL_EXSTYLE,stylebitsex);
SetWindowLong(hWindow,GWL_STYLE,stylebits);

View file

@ -1,4 +1,31 @@
=EDuke32 ChangeLog=
==1.4.0 beta 2=
- Core: cleaned up code to properly build without Polymost/OpenGL support
- Core: added widescreen support for Polymost
- Core: added support for toggling correct HUD model rendering on/off
- Core: removed broken support for linking OpenGL statically
- Game: added support for using the mouse and a joystick simultaneously (JF)
- Game: fixed an issue preventing skill selection, bonus screen and episode ending animation sounds from playing
- Game: fixed a problem where the player was unable to exit some pools of water in some maps
- Game: made further adjustments to the weapon properties in order to more closely emulate Duke 1.5
- Game: fixed an issue where you could disable map exits in multiplayer, have all players quit, start a single player game and then have exits continue to kill you
- Multiplayer: fixed numerous minor bugs in the voting system
- Multiplayer: added a more noticeable message to indicate that the player hasn't voted yet in an active vote
- Multiplayer: added support for /me in text chat
- Multiplayer: increased size of player chat icon
- Multiplayer: added "nat-free" support from Adam Fazakerley
- Multiplayer: fixed inventory respawn bug
- Multiplayer: minor fixes to DukesterX 1.5 compatibility wrapper
- CON: reworked movement_lock member of the player struct to use bit flags
- CON: reworked findnearactor3d, findnearactor3dvar, findnearsprite3d, and findnearsprite3dvar
- CON: added findnearactorz, findnearactorzvar, findnearspritez, and findnearspritezvar
- CON: added WEAPON_FLAG_RESET (65536) to weapon system in order to properly emulate the chaingun and freezer
- CON: fixed eshoot
- CON: reworked weapon system; note that your custom weapons may need adjustments to work again
==1.4.0 beta 1=
- Core: added support for defining dummy tiles in the def files to eliminate the need for placeholders for hightile art

View file

@ -19,6 +19,7 @@ JFAUD?=0
SRC=source/
RSRC=rsrc/
EROOT=../build/
ESRC=$(EROOT)src/
EINC=$(EROOT)include/
INC=$(SRC)
o=o
@ -105,7 +106,7 @@ EDITOROBJS=$(OBJ)astub.$o
ifeq ($(PLATFORM),WINDOWS)
OURCFLAGS+= -DUNDERSCORES -I$(DXROOT)/include
NASMFLAGS+= -DUNDERSCORES -f win32
GAMEOBJS+= $(OBJ)gameres.$o $(OBJ)winbits.$o
GAMEOBJS+= $(OBJ)gameres.$o $(OBJ)winbits.$o $(OBJ)startwin.game.$o
EDITOROBJS+= $(OBJ)buildres.$o
endif
@ -120,7 +121,7 @@ ifeq ($(RENDERTYPE),SDL)
ifeq (1,$(HAVE_GTK2))
OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0)
GAMEOBJS+= $(OBJ)game_banner.$o
GAMEOBJS+= $(OBJ)game_banner.$o $(OBJ)startgtk.game.$o
EDITOROBJS+= $(OBJ)editor_banner.$o
endif
@ -207,7 +208,7 @@ $(OBJ)%.$o: $(SRC)jaudiolib/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(OBJ)%.$o: $(SRC)misc/%.rc
windres -i $< -o $@
windres -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC)
$(OBJ)%.$o: $(SRC)util/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1

View file

@ -27,8 +27,9 @@ $(OBJ)astub.$o: $(SRC)astub.c $(EINC)build.h $(EINC)pragmas.h $(EINC)compat.h $(
$(OBJ)game_icon.$o: $(RSRC)game_icon.c
$(OBJ)build_icon.$o: $(RSRC)build_icon.c
$(OBJ)gameres.$o: $(SRC)misc/gameres.rc $(RSRC)game.bmp $(RSRC)game_icon.ico
$(OBJ)buildres.$o: $(SRC)misc/buildres.rc $(RSRC)build.bmp $(RSRC)build_icon.ico
$(OBJ)gameres.$o: $(SRC)misc/gameres.rc $(SRC)startwin.game.h $(RSRC)game.bmp $(RSRC)game_icon.ico
$(OBJ)buildres.$o: $(SRC)misc/buildres.rc $(EINC)startwin.editor.h $(RSRC)build.bmp $(RSRC)build_icon.ico
$(OBJ)startwin.game.$o: $(SRC)startwin.game.c $(duke3d_h) $(EINC)build.h $(EINC)winlayer.h $(EINC)compat.h
# jMACT objects
$(OBJ)animlib.$o: $(SRC)jmact/animlib.c $(SRC)jmact/types.h $(INC)develop.h $(SRC)jmact/util_lib.h $(SRC)jmact/animlib.h $(EINC)compat.h

View file

@ -1,104 +0,0 @@
; Build editor configuration
; Video mode selection
; 0 - Windowed
; 1 - Fullscreen
fullscreen = 0
; Video resolution selection
; 0 - 320 x 200
; 1 - 360 x 200
; 2 - 320 x 240
; 3 - 360 x 240
; 4 - 320 x 400
; 5 - 360 x 400
; 6 - 640 x 350
; 7 - 640 x 400
; 8 - 640 x 480
; 9 - 800 x 600
; 10 - 1024 x 768
; 11 - 1280 x 1024
; 12 - 1600 x 1200
; You can select a seperate 2D editor resolution by
; removing the semicolon from the second line below
; and selecting a mode number. The minimum 2D mode
; is 640x480 (mode #8)
resolution = 8
;2dresolution = 8
; 3D mode colour depth
bpp = 8
; Maximum OpenGL mode refresh rate (Windows only, in Hertz)
maxrefreshfreq = 60
; 3D mode brightness setting
; 0 - lowest
; 15 - highest
brightness = 0
; Sound sample frequency
; 0 - 6 KHz
; 1 - 8 KHz
; 2 - 11.025 KHz
; 3 - 16 KHz
; 4 - 22.05 KHz
; 5 - 32 KHz
; 6 - 44.1 KHz
samplerate = 4
; Music playback
; 0 - Off
; 1 - On
music = 1
; Enable mouse
; 0 - No
; 1 - Yes
mouse = 1
; Mouse sensitivity
mousesensitivity = 1.0
; Key Settings
; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!
; +---------------------------------------------------------------------------------------------+
; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 |
; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL |
; | |
; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A |
; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- |
; | |
; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E |
; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ |
; | |
; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D |
; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C |
; | KPENTER|
; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 |
; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 |
; | |
; | 1D 38 39 B8 9D CB D0 CD 52 53 |
; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |
; +---------------------------------------------------------------------------------------------+
keyforward = C8
keybackward = D0
keyturnleft = CB
keyturnright = CD
keyrun = 2A
keystrafe = 9D
keyfire = 1D
keyuse = 39
keystandhigh = 1E
keystandlow = 2C
keylookup = D1
keylookdown = C9
keystrafeleft = 33
keystraferight = 34
key2dmode = 9C
keyviewcycle = 1C
key2dzoomin = D
key2dzoomout = C
keychat = F

View file

@ -2429,7 +2429,7 @@ void moveweapons(void)
dax = s->x; day = s->y; daz = s->z;
if(thisprojectile[i].range > 0)
if(thisprojectile[i].workslike & PROJECTILE_FLAG_TIMED && thisprojectile[i].range > 0)
{
if (!(hittype[i].temp_data[8]))
hittype[i].temp_data[8] = 1;

View file

@ -4220,7 +4220,7 @@ int ExtInit(void)
long rv = 0;
char *duke3dgrp = "duke3d.grp";
#if 1 // defined(_WIN32)
#if defined(_WIN32)
if (!access("user_profiles_enabled", F_OK))
#endif
{

View file

@ -95,6 +95,7 @@ int32 ScreenWidth = 800;
int32 ScreenHeight = 600;
int32 ScreenBPP = 8;
#endif
int32 ForceSetup = 1;
static char setupfilename[256]={SETUPFILENAME};
int32 scripthandle = -1;
@ -558,7 +559,7 @@ void readsavenames(void)
===================
*/
void CONFIG_ReadSetup( void )
int32 CONFIG_ReadSetup( void )
{
int32 dummy, i;
char commmacro[] = "CommbatMacro# ";
@ -572,6 +573,8 @@ void CONFIG_ReadSetup( void )
if (SafeFileExists(setupfilename)) // JBF 20031211
scripthandle = SCRIPT_Load( setupfilename );
if (scripthandle < 0) return -1;
if (scripthandle >= 0)
{
for(dummy = 0;dummy < 10;dummy++)
@ -639,6 +642,7 @@ void CONFIG_ReadSetup( void )
SCRIPT_GetNumber( scripthandle, "Misc", "Executions",&ud.executions);
ud.executions++;
SCRIPT_GetNumber( scripthandle, "Setup", "ForceSetup",&ForceSetup);
SCRIPT_GetNumber( scripthandle, "Misc", "RunMode",&RunMode);
SCRIPT_GetNumber( scripthandle, "Misc", "Crosshairs",&ud.crosshair);
SCRIPT_GetNumber( scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale);
@ -702,8 +706,8 @@ void CONFIG_ReadSetup( void )
//CONFIG_SetupMouse(scripthandle);
//CONFIG_SetupJoystick(scripthandle);
setupread = 1;
return 0;
}
/*
@ -742,6 +746,7 @@ void CONFIG_WriteSetup( void )
SCRIPT_PutNumber( scripthandle, "Misc", "Crosshairs",ud.crosshair,false,false);
SCRIPT_PutNumber( scripthandle, "Misc", "DemoCams",ud.democams,false,false);
SCRIPT_PutNumber( scripthandle, "Misc", "Executions",ud.executions,false,false);
SCRIPT_PutNumber( scripthandle, "Setup", "ForceSetup",ForceSetup,false,false);
SCRIPT_PutNumber( scripthandle, "Misc", "IDPlayers",ud.idplayers,false,false);
SCRIPT_PutNumber( scripthandle, "Misc", "MPMessageDisplayTime",ud.msgdisptime,false,false);
SCRIPT_PutNumber( scripthandle, "Misc", "RunMode",RunMode,false,false);

View file

@ -52,6 +52,7 @@ extern int32 ScreenMode;
extern int32 ScreenWidth;
extern int32 ScreenHeight;
extern int32 ScreenBPP;
extern int32 ForceSetup;
extern byte KeyboardKeys[NUMGAMEFUNCTIONS][2];
extern int32 MouseFunctions[MAXMOUSEBUTTONS][2];
@ -65,7 +66,7 @@ extern int32 JoystickAnalogueScale[MAXJOYAXES];
extern int32 JoystickAnalogueDead[MAXJOYAXES];
extern int32 JoystickAnalogueSaturate[MAXJOYAXES];
void CONFIG_ReadSetup( void );
int32 CONFIG_ReadSetup( void );
void CONFIG_GetSetupFilename( void );
void CONFIG_WriteSetup( void );
void CONFIG_SetupMouse( void );

View file

@ -260,7 +260,7 @@ extern char *CONFIG_AnalogNumToName(int32 func);
extern void CONFIG_SetDefaults(void );
extern void CONFIG_ReadKeys(void );
extern void readsavenames(void );
extern void CONFIG_ReadSetup(void );
extern int32 CONFIG_ReadSetup(void );
extern void CONFIG_WriteSetup(void );
extern void CheckAnimStarted(char *funcname);
extern uint16 findpage(uint16 framenumber);

View file

@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "util_lib.h"
#define VERSION " 1.4.0svn"
#define VERSION " 1.4.0 beta 2"
#define HEAD "EDuke32"VERSION" (shareware mode)"
#define HEAD2 "EDuke32"VERSION
@ -56,8 +56,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
long cameradist = 0, cameraclock = 0;
char playerswhenstarted;
char qe,cp;
char qe,cp,usecwd = 0;
static int32 CommandSetup = 0;
static int32 CommandSoundToggleOff = 0;
static int32 CommandMusicToggleOff = 0;
static char *CommandMap = NULL;
@ -7611,7 +7612,11 @@ void comlinehelp(char **argv)
"-map FILE\tUse a map FILE\n"
"-name NAME\tFoward NAME\n"
"-net\t\tNet mode game\n"
"-setup\t\tDisplays the configuration dialog\n"
"-nD\t\tDump game definitions to gamevars.txt\n"
#if !defined(_WIN32)
"-usecwd\t\tRead game data and configuration file from working directory\n"
#endif
"-condebug, -z#\tLine-by-line CON compilation debugging";
wm_msgbox(apptitle,s);
}
@ -7757,6 +7762,11 @@ void checkcommandline(int argc,char **argv)
c = argv[i];
if (((*c == '/') || (*c == '-')) && (!firstnet))
{
if (!Bstrcasecmp(c+1,"setup")) {
CommandSetup = 1;
i++;
continue;
}
if (!Bstrcasecmp(c+1,"keepaddr")) {
keepaddr = 1;
i++;
@ -7895,6 +7905,13 @@ void checkcommandline(int argc,char **argv)
i++;
continue;
}
#if !defined(_WIN32)
if (!Bstrcasecmp(c+1,"usecwd")) {
usecwd = 1;
i++;
continue;
}
#endif
}
if (firstnet > 0) {
@ -8494,6 +8511,8 @@ void sanitizegametype()
// initprintf("ud.m_coop=%i after sanitisation\n",ud.m_coop);
}
extern int startwin_run(void);
void Startup(void)
{
int i;
@ -8502,7 +8521,22 @@ void Startup(void)
compilecons();
CONFIG_ReadSetup();
i = CONFIG_ReadSetup();
if (initengine()) {
wm_msgbox("Build Engine Initialisation Error",
"There was a problem initialising the Build engine: %s", engineerrstr);
exit(1);
}
#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)
if (i < 0 || ForceSetup || CommandSetup) {
if (!startwin_run()) {
uninitengine();
exit(0);
}
}
#endif
setupdynamictostatic();
@ -8558,12 +8592,6 @@ void Startup(void)
if(ud.executions >= 50) initprintf("IT IS NOW TIME TO UPGRADE TO THE COMPLETE VERSION!!!\n");
}
if (initengine()) {
wm_msgbox("Build Engine Initialisation Error",
"There was a problem initialising the Build engine: %s", engineerrstr);
exit(1);
}
if (CONTROL_Startup( 1, &GetTime, TICRATE )) {
uninitengine();
exit(1);
@ -8811,8 +8839,10 @@ void app_main(int argc,char **argv)
OSD_SetLogFile("eduke32.log");
#if 1 // defined(_WIN32)
#if defined(_WIN32)
if (!access("user_profiles_enabled", F_OK))
#else
if (usecwd == 0)
#endif
{
char cwd[BMAX_PATH];

View file

@ -2432,7 +2432,7 @@ cheat_for_port_credits:
case 2:
{
int dax = xdim, day = ydim, daz;
curvidmode = newvidmode = checkvideomode(&dax,&day,bpp,fullscreen);
curvidmode = newvidmode = checkvideomode(&dax,&day,bpp,fullscreen,0);
if (newvidmode == 0x7fffffffl) newvidmode = validmodecnt;
newfullscreen = fullscreen;
changesmade = 0;

View file

@ -1,30 +1,33 @@
#include <windows.h>
#include <commctrl.h>
#include "startwin.editor.h"
100 ICON "rsrc/build_icon.ico"
200 BITMAP "rsrc/build.bmp"
RSRC_ICON ICON "rsrc/build_icon.ico"
RSRC_BMP BITMAP "rsrc/build.bmp"
1000 DIALOGEX DISCARDABLE 20, 40, 265, 233
WIN_STARTWIN DIALOGEX DISCARDABLE 20, 40, 260, 200
STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU
CAPTION "Startup"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255
CONTROL "Starting Build Editor for Duke Nukem 3D...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8
CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138
CONTROL "", WIN_STARTWIN_BITMAP, "STATIC", SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32
CONTROL "", WIN_STARTWIN_TABCTL, WC_TABCONTROL, WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 250, 170
CONTROL "&Start", WIN_STARTWIN_START, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 154, 180, 48, 14
CONTROL "&Cancel", WIN_STARTWIN_CANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 207, 180, 48, 14
CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32
END
2000 DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL
WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
CAPTION "Dialog"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 64
CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10
CONTROL "&2D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8
CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56
CONTROL "&3D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 47, 37, 8
CONTROL "", 102, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 46, 75, 56
CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17
CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17
CONTROL "&2D Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 8, 50, 8
CONTROL "", IDC2DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56
CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10
CONTROL "&3D Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 24, 50, 8
CONTROL "", IDC3DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 22, 80, 56
CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8
END

View file

@ -1,14 +1,45 @@
#include <windows.h>
#include <commctrl.h>
#include "startwin.game.h"
100 ICON "rsrc/game_icon.ico"
200 BITMAP "rsrc/game.bmp"
RSRC_ICON ICON "rsrc/game_icon.ico"
RSRC_ICON+1 ICON "rsrc/game_icon.ico"
RSRC_ICON+2 ICON "rsrc/game_icon.ico"
RSRC_BMP BITMAP "rsrc/game.bmp"
1000 DIALOGEX DISCARDABLE 20, 40, 265, 233
WIN_STARTWIN DIALOGEX DISCARDABLE 20, 40, 260, 200
STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU
CAPTION "Startup"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255
CONTROL "Starting EDuke32...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8
CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138
CONTROL "", WIN_STARTWIN_BITMAP, "STATIC", SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32
CONTROL "", WIN_STARTWIN_TABCTL, WC_TABCONTROL, WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 250, 170
CONTROL "&Start", WIN_STARTWIN_START, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 154, 180, 48, 14
CONTROL "&Cancel", WIN_STARTWIN_CANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 207, 180, 48, 14
CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32
END
WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
CAPTION "Dialog"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "&Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 8, 50, 8
CONTROL "", IDCVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56
CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10
CONTROL "S&ound driver:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 28, 50, 8
CONTROL "", IDCSOUNDDRV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 26, 110, 56
CONTROL "&MIDI device:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 44, 50, 8
CONTROL "", IDCMIDIDEV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 42, 110, 56
CONTROL "C&D drive:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 50, 8
CONTROL "", IDCCDADEV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 58, 40, 56
CONTROL "Input devices:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 80, 50, 8
CONTROL "Mo&use", IDCINPUTMOUSE, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 60, 80, 49, 8
CONTROL "&Joystick", IDCINPUTJOY, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 110, 80, 49, 8
CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8
END

View file

@ -0,0 +1,551 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="startwin">
<property name="visible">True</property>
<property name="title" translatable="yes">Startup</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="delete_event" handler="on_startwin_delete_event" last_modification_time="Fri, 30 Jun 2006 05:55:35 GMT"/>
<child>
<widget class="GtkHBox" id="hlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="banner">
<property name="visible">True</property>
<property name="pixbuf">game.bmp</property>
<property name="xalign">0.5</property>
<property name="yalign">0</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkNotebook" id="tabs">
<property name="border_width">4</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">True</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkVBox" id="configvlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkFixed" id="configlayout">
<property name="border_width">6</property>
<property name="visible">True</property>
<child>
<widget class="GtkCheckButton" id="fullscreencheck">
<property name="width_request">85</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Fullscreen</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_fullscreencheck_toggled" last_modification_time="Fri, 30 Jun 2006 05:13:03 GMT"/>
<accelerator key="F" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="x">248</property>
<property name="y">0</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="vmode3dlabel">
<property name="width_request">88</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<property name="label" translatable="yes">_Video mode:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">vmode3dcombo</property>
</widget>
<packing>
<property name="x">0</property>
<property name="y">0</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="inputdevlabel">
<property name="width_request">88</property>
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Input devices:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="x">0</property>
<property name="y">120</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="sounddrvlabel">
<property name="width_request">88</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<property name="label" translatable="yes">S_ound driver:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">sounddrvcombo</property>
</widget>
<packing>
<property name="x">0</property>
<property name="y">40</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="cddrvlabel">
<property name="width_request">88</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<property name="label" translatable="yes">C_D drive:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">cddrvcombo</property>
</widget>
<packing>
<property name="x">0</property>
<property name="y">72</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="sounddrvcombo">
<property name="width_request">31</property>
<property name="height_request">30</property>
<property name="visible">True</property>
<signal name="changed" handler="on_sounddrvcombo_changed" last_modification_time="Fri, 30 Jun 2006 17:57:14 GMT"/>
<accelerator key="O" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="x">88</property>
<property name="y">40</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="cddrvcombo">
<property name="width_request">31</property>
<property name="height_request">30</property>
<property name="visible">True</property>
<signal name="changed" handler="on_cddrvcombo_changed" last_modification_time="Fri, 30 Jun 2006 17:57:23 GMT"/>
</widget>
<packing>
<property name="x">88</property>
<property name="y">72</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="inputmousecheck">
<property name="width_request">80</property>
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Mo_use</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_inputmousecheck_toggled" last_modification_time="Fri, 30 Jun 2006 17:57:31 GMT"/>
<accelerator key="U" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="x">88</property>
<property name="y">120</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="inputjoycheck">
<property name="width_request">80</property>
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Joystick</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_inputjoycheck_toggled" last_modification_time="Fri, 30 Jun 2006 17:57:37 GMT"/>
<accelerator key="J" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="x">168</property>
<property name="y">120</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="vmode3dcombo">
<property name="width_request">150</property>
<property name="height_request">29</property>
<property name="visible">True</property>
<signal name="changed" handler="on_vmode3dcombo_changed" last_modification_time="Fri, 30 Jun 2006 05:12:25 GMT"/>
<accelerator key="V" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="x">88</property>
<property name="y">0</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="alwaysshowcheck">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Always show configuration on start</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_alwaysshowcheck_toggled" last_modification_time="Fri, 30 Jun 2006 05:13:09 GMT"/>
<accelerator key="A" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="configtab">
<property name="visible">True</property>
<property name="label" translatable="yes">Configuration</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="messagesscroll">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="messagestext">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="messagestab">
<property name="visible">True</property>
<property name="label" translatable="yes">Messages</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="buttons">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="cancelbutton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_cancelbutton_clicked" last_modification_time="Fri, 30 Jun 2006 05:13:27 GMT"/>
<accelerator key="C" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
<child>
<widget class="GtkAlignment" id="cancelbuttonalign">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="cancelbuttonlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="cancelbuttonicon">
<property name="visible">True</property>
<property name="stock">gtk-cancel</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="cancelbuttonlabel">
<property name="visible">True</property>
<property name="label" translatable="yes">_Cancel</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkButton" id="startbutton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_startbutton_clicked" last_modification_time="Fri, 30 Jun 2006 05:13:37 GMT"/>
<accelerator key="S" modifiers="GDK_MOD1_MASK" signal="grab_focus"/>
<child>
<widget class="GtkAlignment" id="startbuttonalign">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="startbuttonlayout">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="startbuttonicon">
<property name="visible">True</property>
<property name="stock">gtk-execute</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="startbuttonlabel">
<property name="visible">True</property>
<property name="label" translatable="yes">_Start</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>Gtkstartwin</name>
<program_name>gtkstartwin</program_name>
<gnome_support>FALSE</gnome_support>
<gettext_support>FALSE</gettext_support>
<output_build_files>FALSE</output_build_files>
<backup_source_files>FALSE</backup_source_files>
</glade-project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View file

@ -1000,6 +1000,7 @@ void newgame(char vn,char ln,char sk)
if(globalskillsound >= 0 && FXDevice >= 0 && SoundToggle)
while(issoundplaying(-1,globalskillsound)) { handleevents(); getpackets(); }
else { handleevents(); getpackets(); }
globalskillsound = -1;
waitforeverybody();

View file

@ -0,0 +1,642 @@
/* NOTE: Glade will generate code for a dialogue box which you should
* then patch into this file whenever you make a change to the Glade
* template.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <gdk-pixbuf/gdk-pixdata.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "duke3d.h"
#include "build.h"
#include "compat.h"
#include "baselayer.h"
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct {
int fullscreen;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
int usemouse, usejoy;
} settings;
extern int gtkenabled;
static GtkWidget *startwin = NULL;
static int retval = -1, mode = 0;
// -- 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)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
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)
{
extern const GdkPixdata startbanner_pixdata;
return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL);
}
static void SetPage(int n)
{
if (!gtkenabled || !startwin) return;
gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n);
}
static void EnableConfig(int n)
{
// each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive
mode = n;
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)mode);
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)mode);
}
static void on_vmode3dcombo_changed(GtkComboBox *, gpointer);
static void PopulateForm(void)
{
int mode3d, i;
GtkListStore *modes3d;
GtkTreeIter iter;
GtkComboBox *box3d;
char buf[64];
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode3d < 0) {
int i, cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; }
for ( ; cd[i]; i++) {
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
break;
}
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup);
box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo"));
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes3d);
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) {
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);
}
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"inputmousecheck")), settings.usemouse);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"inputjoycheck")), settings.usejoy);
}
// -- EVENT CALLBACKS AND CREATION STUFF --------------------------------------
static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data)
{
GtkTreeModel *data;
GtkTreeIter iter;
int val;
if (!gtk_combo_box_get_active_iter(combobox, &iter)) return;
if (!(data = gtk_combo_box_get_model(combobox))) return;
gtk_tree_model_get(data, &iter, 1, &val, -1);
settings.xdim3d = validmode[val].xdim;
settings.ydim3d = validmode[val].ydim;
}
static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
settings.fullscreen = (gtk_toggle_button_get_active(togglebutton) == TRUE);
PopulateForm();
}
static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
settings.forcesetup = (gtk_toggle_button_get_active(togglebutton) == TRUE);
}
static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data)
{
retval = 0;
gtk_main_quit();
}
static void on_startbutton_clicked(GtkButton *button, gpointer user_data)
{
retval = 1;
gtk_main_quit();
}
static void on_sounddrvcombo_changed(GtkComboBox *combobox, gpointer user_data)
{
}
static void on_cddrvcombo_changed(GtkComboBox *combobox, gpointer user_data)
{
}
static void on_inputmousecheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
settings.usemouse = (gtk_toggle_button_get_active(togglebutton) == TRUE);
}
static void on_inputjoycheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
settings.usejoy = (gtk_toggle_button_get_active(togglebutton) == TRUE);
}
static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
//quitevent++;
return TRUE; // FALSE would let the event go through. we want the game to decide when to close
}
static GtkWidget *create_window(void)
{
GtkWidget *startwin;
GtkWidget *hlayout;
GtkWidget *banner;
GtkWidget *vlayout;
GtkWidget *tabs;
GtkWidget *configvlayout;
GtkWidget *configlayout;
GtkWidget *fullscreencheck;
GtkWidget *vmode3dlabel;
GtkWidget *inputdevlabel;
GtkWidget *sounddrvlabel;
GtkWidget *cddrvlabel;
GtkWidget *sounddrvcombo;
GtkWidget *cddrvcombo;
GtkWidget *inputmousecheck;
GtkWidget *inputjoycheck;
GtkWidget *vmode3dcombo;
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 ();
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
inputdevlabel = gtk_label_new ("Input devices:");
gtk_widget_show (inputdevlabel);
gtk_fixed_put (GTK_FIXED (configlayout), inputdevlabel, 0, 120);
gtk_widget_set_size_request (inputdevlabel, 88, 20);
gtk_misc_set_alignment (GTK_MISC (inputdevlabel), 0, 0.5);
sounddrvlabel = gtk_label_new_with_mnemonic ("S_ound driver:");
gtk_widget_show (sounddrvlabel);
gtk_fixed_put (GTK_FIXED (configlayout), sounddrvlabel, 0, 40);
gtk_widget_set_size_request (sounddrvlabel, 88, 29);
gtk_misc_set_alignment (GTK_MISC (sounddrvlabel), 0, 0.5);
cddrvlabel = gtk_label_new_with_mnemonic ("C_D drive:");
gtk_widget_show (cddrvlabel);
gtk_fixed_put (GTK_FIXED (configlayout), cddrvlabel, 0, 72);
gtk_widget_set_size_request (cddrvlabel, 88, 29);
gtk_misc_set_alignment (GTK_MISC (cddrvlabel), 0, 0.5);
sounddrvcombo = gtk_combo_box_new_text ();
gtk_widget_show (sounddrvcombo);
gtk_fixed_put (GTK_FIXED (configlayout), sounddrvcombo, 88, 40);
gtk_widget_set_size_request (sounddrvcombo, 31, 30);
gtk_widget_add_accelerator (sounddrvcombo, "grab_focus", accel_group,
GDK_O, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
cddrvcombo = gtk_combo_box_new_text ();
gtk_widget_show (cddrvcombo);
gtk_fixed_put (GTK_FIXED (configlayout), cddrvcombo, 88, 72);
gtk_widget_set_size_request (cddrvcombo, 31, 30);
inputmousecheck = gtk_check_button_new_with_mnemonic ("Mo_use");
gtk_widget_show (inputmousecheck);
gtk_fixed_put (GTK_FIXED (configlayout), inputmousecheck, 88, 120);
gtk_widget_set_size_request (inputmousecheck, 80, 20);
gtk_widget_add_accelerator (inputmousecheck, "grab_focus", accel_group,
GDK_U, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
inputjoycheck = gtk_check_button_new_with_mnemonic ("_Joystick");
gtk_widget_show (inputjoycheck);
gtk_fixed_put (GTK_FIXED (configlayout), inputjoycheck, 168, 120);
gtk_widget_set_size_request (inputjoycheck, 80, 20);
gtk_widget_add_accelerator (inputjoycheck, "grab_focus", accel_group,
GDK_J, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// 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));
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);
// 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);
// 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 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);
// 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);
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);
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);
// 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);
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);
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);
// Wire up the signals
g_signal_connect ((gpointer) startwin, "delete_event",
G_CALLBACK (on_startwin_delete_event),
NULL);
g_signal_connect ((gpointer) fullscreencheck, "toggled",
G_CALLBACK (on_fullscreencheck_toggled),
NULL);
g_signal_connect ((gpointer) sounddrvcombo, "changed",
G_CALLBACK (on_sounddrvcombo_changed),
NULL);
g_signal_connect ((gpointer) cddrvcombo, "changed",
G_CALLBACK (on_cddrvcombo_changed),
NULL);
g_signal_connect ((gpointer) inputmousecheck, "toggled",
G_CALLBACK (on_inputmousecheck_toggled),
NULL);
g_signal_connect ((gpointer) inputjoycheck, "toggled",
G_CALLBACK (on_inputjoycheck_toggled),
NULL);
g_signal_connect ((gpointer) vmode3dcombo, "changed",
G_CALLBACK (on_vmode3dcombo_changed),
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);
gtk_label_set_mnemonic_widget (GTK_LABEL (sounddrvlabel), sounddrvcombo);
gtk_label_set_mnemonic_widget (GTK_LABEL (cddrvlabel), cddrvcombo);
/* 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, fullscreencheck, "fullscreencheck");
GLADE_HOOKUP_OBJECT (startwin, vmode3dlabel, "vmode3dlabel");
GLADE_HOOKUP_OBJECT (startwin, inputdevlabel, "inputdevlabel");
GLADE_HOOKUP_OBJECT (startwin, sounddrvlabel, "sounddrvlabel");
GLADE_HOOKUP_OBJECT (startwin, cddrvlabel, "cddrvlabel");
GLADE_HOOKUP_OBJECT (startwin, sounddrvcombo, "sounddrvcombo");
GLADE_HOOKUP_OBJECT (startwin, cddrvcombo, "cddrvcombo");
GLADE_HOOKUP_OBJECT (startwin, inputmousecheck, "inputmousecheck");
GLADE_HOOKUP_OBJECT (startwin, inputjoycheck, "inputjoycheck");
GLADE_HOOKUP_OBJECT (startwin, vmode3dcombo, "vmode3dcombo");
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);
return startwin;
}
// -- BUILD ENTRY POINTS ------------------------------------------------------
int startwin_open(void)
{
if (!gtkenabled) return 0;
if (startwin) return 1;
startwin = create_window();
if (startwin) {
SetPage(TAB_MESSAGES);
EnableConfig(FALSE);
gtk_widget_show(startwin);
gtk_main_iteration_do(FALSE);
return 0;
}
return -1;
}
int startwin_close(void)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
gtk_widget_destroy (startwin);
startwin = NULL;
return 0;
}
int startwin_puts(const char *str)
{
GtkWidget *textview;
GtkTextBuffer *textbuffer;
GtkTextIter enditer;
GtkTextMark *mark;
const char *aptr, *bptr;
if (!gtkenabled || !str) return 0;
if (!startwin) return 1;
if (!(textview = lookup_widget(startwin, "messagestext"))) return -1;
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);
#if GTK_CHECK_VERSION(2,6,0)
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;
}
}
mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1);
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0);
gtk_text_buffer_delete_mark(textbuffer, mark);
return 0;
}
int startwin_settitle(const char *title)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
gtk_window_set_title (GTK_WINDOW (startwin), title);
return 0;
}
int startwin_idle(void *s)
{
if (!gtkenabled) return 0;
//if (!startwin) return 1;
gtk_main_iteration_do (FALSE);
return 0;
}
extern int xdimgame, ydimgame, bppgame, forcesetup;
int startwin_run(void)
{
if (!gtkenabled) return 0;
if (!startwin) return 1;
SetPage(TAB_CONFIG);
EnableConfig(TRUE);
settings.fullscreen = ScreenMode;
settings.xdim3d = ScreenWidth;
settings.ydim3d = ScreenHeight;
settings.bpp3d = ScreenBPP;
settings.forcesetup = ForceSetup;
settings.usemouse = UseMouse;
settings.usejoy = UseJoystick;
PopulateForm();
gtk_main();
SetPage(TAB_MESSAGES);
EnableConfig(FALSE);
if (retval) {
ScreenMode = settings.fullscreen;
ScreenWidth = settings.xdim3d;
ScreenHeight = settings.ydim3d;
ScreenBPP = settings.bpp3d;
ForceSetup = settings.forcesetup;
UseMouse = settings.usemouse;
UseJoystick = settings.usejoy;
}
return retval;
}

View file

@ -0,0 +1,431 @@
#ifndef RENDERTYPEWIN
#error Only for Windows
#endif
#include "duke3d.h"
#include "build.h"
#include "winlayer.h"
#include "compat.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#define _WIN32_IE 0x0300
#include <commctrl.h>
#include <stdio.h>
#include "startwin.game.h"
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct {
int fullscreen;
int xdim, ydim, bpp;
int forcesetup;
int usemouse, usejoy;
} settings;
static HWND startupdlg = NULL;
static HWND pages[2] = { NULL, NULL};
static int done = -1;
static void PopulateForm(void)
{
int i,j;
char buf[64];
int mode;
HWND hwnd;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1);
if (mode < 0) {
int cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp) i++; else break; }
for ( ; cd[i]; i++) {
mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1);
if (mode < 0) continue;
settings.bpp = cd[i];
break;
}
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
ComboBox_ResetContent(hwnd);
for (i=0; 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);
j = ComboBox_AddString(hwnd, buf);
ComboBox_SetItemData(hwnd, j, i);
if (i == mode) ComboBox_SetCurSel(hwnd, j);
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), (settings.usemouse ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED));
}
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 IDCVMODE:
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.xdim = validmode[i].xdim;
settings.ydim = validmode[i].ydim;
settings.bpp = validmode[i].bpp;
}
}
return TRUE;
case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE;
case IDCINPUTMOUSE:
settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED;
return TRUE;
case IDCINPUTJOY:
settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
return TRUE;
default: break;
}
break;
default: break;
}
return FALSE;
}
static void SetPage(int n)
{
HWND tab;
int cur;
tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0);
ShowWindow(pages[cur],SW_HIDE);
SendMessage(tab, TCM_SETCURSEL, n, 0);
ShowWindow(pages[n],SW_SHOW);
}
static void EnableConfig(int n)
{
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCVMODE), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTMOUSE), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), n);
}
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
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;
// 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;
// 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;
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;
// 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);
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: {
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;
}
case WM_CLOSE:
done = 0;
return TRUE;
case WM_DESTROY:
if (hbmp) {
DeleteObject(hbmp);
hbmp = NULL;
}
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: done = 0; 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;
}
int startwin_open(void)
{
INITCOMMONCONTROLSEX icc;
if (startupdlg) return 1;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) {
SetPage(TAB_MESSAGES);
EnableConfig(0);
return 0;
}
return -1;
}
int startwin_close(void)
{
if (!startupdlg) return 1;
DestroyWindow(startupdlg);
startupdlg = NULL;
return 0;
}
int startwin_puts(const char *buf)
{
const char *p = NULL, *q = NULL;
char workbuf[1024];
static int newline = 0;
int curlen, linesbefore, linesafter;
HWND edctl;
int vis;
if (!startupdlg) return 1;
edctl = pages[TAB_MESSAGES];
if (!edctl) return -1;
vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES);
if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf;
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]) {
newline = 1;
workbuf[q-p] = 0;
} else {
workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0;
}
p = q+1;
} else {
workbuf[q-p] = 0;
p = q;
}
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
}
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
return 0;
}
int startwin_settitle(const char *str)
{
if (!startupdlg) return 1;
SetWindowText(startupdlg, str);
return 0;
}
int startwin_idle(void *v)
{
if (!startupdlg || !IsWindow(startupdlg)) return 0;
if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
return 0;
}
int startwin_run(void)
{
MSG msg;
if (!startupdlg) return 1;
done = -1;
SetPage(TAB_CONFIG);
EnableConfig(1);
settings.fullscreen = ScreenMode;
settings.xdim = ScreenWidth;
settings.ydim = ScreenHeight;
settings.bpp = ScreenBPP;
settings.forcesetup = ForceSetup;
settings.usemouse = UseMouse;
settings.usejoy = UseJoystick;
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;
}
}
SetPage(TAB_MESSAGES);
EnableConfig(0);
if (done) {
ScreenMode = settings.fullscreen;
ScreenWidth = settings.xdim;
ScreenHeight = settings.ydim;
ScreenBPP = settings.bpp;
ForceSetup = settings.forcesetup;
UseMouse = settings.usemouse;
UseJoystick = settings.usejoy;
}
return done;
}

View file

@ -0,0 +1,23 @@
// resource ids
#define WIN_STARTWIN 1000
#define WIN_STARTWINPAGE_CONFIG 2000
#define WIN_STARTWIN_BITMAP 100 // banner bitmap
#define WIN_STARTWIN_TABCTL 101
#define WIN_STARTWIN_CANCEL 102
#define WIN_STARTWIN_START 103
#define WIN_STARTWIN_MESSAGES 104 // output list box
#define RSRC_ICON 100
#define RSRC_BMP 200
// config page
#define IDCFULLSCREEN 100
#define IDCVMODE 101
#define IDCSOUNDDRV 102
#define IDCMIDIDEV 103
#define IDCCDADEV 104
#define IDCINPUTMOUSE 105
#define IDCINPUTJOY 106
#define IDCALWAYSSHOW 107