Subversion Repositories eduke32

Compare Revisions

Ignore whitespace Rev 193 → Rev 194

/polymer/build/build.cfg
File deleted
/polymer/build/game.cfg
File deleted
/polymer/build/Makefile
82,7 → 82,6
$(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 (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
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
 
OURCFLAGS+= $(BUILDCFLAGS)
 
.PHONY: clean veryclean all utils writeengineinfo enginelib editorlib
.PHONY: clean veryclean all utils enginelib editorlib
 
# TARGETS
 
221,15 → 221,6
# 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
$(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
/polymer/build/Makefile.deps
21,7 → 21,7
$(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)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
/polymer/build/Makefile.msvc
58,7 → 58,6
$(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
$(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
# 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)
/polymer/build/Makefile.shared
58,7 → 58,7
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
/polymer/build/Makefile.watcom
52,7 → 52,6
$(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
 
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
# 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
/polymer/build/include/engineinfo.h
File deleted
/polymer/build/include/baselayer.h
14,8 → 14,13
 
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
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);
/polymer/build/include/compat.h
411,6 → 411,7
#endif
 
char *Bgethomedir(void);
char *Bgetsupportdir(int global);
unsigned int Bgetsysmemsize(void);
int Bcorrectfilename(char *filename, int removefn);
int Bcanonicalisefilename(char *filename, int removefn);
/polymer/build/include/editor.h
22,7 → 22,7
 
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);
/polymer/build/include/gtkbits.h
5,11 → 5,5
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
/polymer/build/include/osxmain.h
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
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/include/pragmas.h
7,109 → 7,9
 
extern long dmval;
 
#if defined(NOASM)
#if defined(__GNUC__) && defined(__i386__) && !defined(NOASM)
 
//
// Generic C
//
 
#define qw(x) ((int64)(x)) // quadword cast
#define dw(x) ((long)(x)) // doubleword cast
#define wo(x) ((short)(x)) // word cast
#define by(x) ((char)(x)) // byte cast
 
#define _scaler(a) \
static inline long mulscale##a(long eax, long edx) \
{ \
return dw((qw(eax) * qw(edx)) >> a); \
} \
\
static inline long divscale##a(long eax, long ebx) \
{ \
return dw((qw(eax) << a) / qw(ebx)); \
} \
\
static inline long dmulscale##a(long eax, long edx, long esi, long edi) \
{ \
return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> a); \
} \
\
static inline long tmulscale##a(long eax, long edx, long ebx, long ecx, long esi, long edi) \
{ \
return dw(((qw(eax) * qw(edx)) + (qw(ebx) * qw(ecx)) + (qw(esi) * qw(edi))) >> a); \
} \
 
_scaler(1) _scaler(2) _scaler(3) _scaler(4)
_scaler(5) _scaler(6) _scaler(7) _scaler(8)
_scaler(9) _scaler(10) _scaler(11) _scaler(12)
_scaler(13) _scaler(14) _scaler(15) _scaler(16)
_scaler(17) _scaler(18) _scaler(19) _scaler(20)
_scaler(21) _scaler(22) _scaler(23) _scaler(24)
_scaler(25) _scaler(26) _scaler(27) _scaler(28)
_scaler(29) _scaler(30) _scaler(31) _scaler(32)
 
static inline void swapchar(void* a, void* b) { char t = *((char*)b); *((char*)b) = *((char*)a); *((char*)a) = t; }
static inline void swapchar2(void* a, void* b, long s) { swapchar(a,b); swapchar((char*)a+1,(char*)b+s); }
static inline void swapshort(void* a, void* b) { short t = *((short*)b); *((short*)b) = *((short*)a); *((short*)a) = t; }
static inline void swaplong(void* a, void* b) { long t = *((long*)b); *((long*)b) = *((long*)a); *((long*)a) = t; }
static inline void swap64bit(void* a, void* b) { int64 t = *((int64*)b); *((int64*)b) = *((int64*)a); *((int64*)a) = t; }
 
static inline char readpixel(void* s) { return (*((char*)(s))); }
static inline void drawpixel(void* s, char a) { *((char*)(s)) = a; }
static inline void drawpixels(void* s, short a) { *((short*)(s)) = a; }
static inline void drawpixelses(void* s, long a) { *((long*)(s)) = a; }
 
static inline long mul3(long a) { return (a<<1)+a; }
static inline long mul5(long a) { return (a<<2)+a; }
static inline long mul9(long a) { return (a<<3)+a; }
 
static inline long divmod(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a%_b; return _a/_b; }
static inline long moddiv(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a/_b; return _a%_b; }
 
static inline long klabs(long a) { if (a < 0) return -a; return a; }
static inline long ksgn(long a) { if (a > 0) return 1; if (a < 0) return -1; return 0; }
 
static inline long umin(long a, long b) { if ((unsigned long)a < (unsigned long)b) return a; return b; }
static inline long umax(long a, long b) { if ((unsigned long)a < (unsigned long)b) return b; return a; }
static inline long kmin(long a, long b) { if ((signed long)a < (signed long)b) return a; return b; }
static inline long kmax(long a, long b) { if ((signed long)a < (signed long)b) return b; return a; }
 
static inline long sqr(long eax) { return (eax) * (eax); }
static inline long scale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) / qw(ecx)); }
static inline long mulscale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); }
static inline long divscale(long eax, long ebx, long ecx) { return dw((qw(eax) << by(ecx)) / qw(ebx)); }
static inline long dmulscale(long eax, long edx, long esi, long edi, long ecx) { return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx)); }
 
static inline long boundmulscale(long a, long d, long c)
{ // courtesy of Ken
int64 p;
p = (((int64)a)*((int64)d))>>c;
if (p >= longlong(2147483647)) p = longlong(2147483647);
if (p < longlong(-2147483648)) p = longlong(-2147483648);
return((long)p);
}
 
#undef qw
#undef dw
#undef wo
#undef by
#undef _scaler
 
void qinterpolatedown16 (long bufptr, long num, long val, long add);
void qinterpolatedown16short (long bufptr, long num, long val, long add);
 
void clearbuf(void* d, long c, long a);
void copybuf(void* s, void* d, long c);
void swapbuf4(void* a, void* b, long c);
 
void clearbufbyte(void *D, long c, long a);
void copybufbyte(void *S, void *D, long c);
void copybufreverse(void *S, void *D, long c);
 
 
#elif defined(__GNUC__) && defined(__i386__) // NOASM
 
//
// GCC Inline Assembler version
//
 
1164,7 → 1064,7
 
//}}}
#elif defined(__WATCOMC__) // __GNUC__ && __i386__
#elif defined(__WATCOMC__) && !defined(NOASM) // __GNUC__ && __i386__
 
//
// Watcom C inline assembler
3014,7 → 2914,7
long swapchar2(void*,void*,long);
//}}}
 
#elif defined(_MSC_VER) // __WATCOMC__
#elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__
 
//
// Microsoft C inline assembler
3023,31 → 2923,39
//{{{
static __inline long sqr(long a)
{
_asm mov eax, a
_asm imul eax, eax
_asm {
mov eax, a
imul eax, eax
}
}
 
static __inline long scale(long a, long d, long c)
{
_asm mov eax, a
_asm imul d
_asm idiv c
_asm {
mov eax, a
imul d
idiv c
}
}
 
static __inline long mulscale(long a, long d, long c)
{
_asm mov ecx, c
_asm mov eax, a
_asm imul d
_asm shrd eax, edx, cl
_asm {
mov ecx, c
mov eax, a
imul d
shrd eax, edx, cl
}
}
 
#define MULSCALE(x) \
static __inline long mulscale##x (long a, long d) \
{ \
_asm mov eax, a \
_asm imul d \
_asm shrd eax, edx, x \
_asm { \
mov eax, a \
imul d \
shrd eax, edx, x \
} \
}
 
MULSCALE(1) MULSCALE(2) MULSCALE(3) MULSCALE(4)
3061,37 → 2969,43
#undef MULSCALE
static __inline long mulscale32(long a, long d)
{
_asm mov eax, a
_asm imul d
_asm mov eax, edx
_asm {
mov eax, a
imul d
mov eax, edx
}
}
 
static __inline long dmulscale(long a, long d, long S, long D, long c)
{
_asm mov ecx, c
_asm mov eax, a
_asm imul d
_asm mov ebx, eax
_asm mov eax, S
_asm mov esi, edx
_asm imul D
_asm add eax, ebx
_asm adc edx, esi
_asm shrd eax, edx, cl
_asm {
mov ecx, c
mov eax, a
imul d
mov ebx, eax
mov eax, S
mov esi, edx
imul D
add eax, ebx
adc edx, esi
shrd eax, edx, cl
}
}
 
#define DMULSCALE(x) \
static __inline long dmulscale##x (long a, long d, long S, long D) \
{ \
_asm mov eax, a \
_asm imul d \
_asm mov ebx, eax \
_asm mov eax, S \
_asm mov esi, edx \
_asm imul D \
_asm add eax, ebx \
_asm adc edx, esi \
_asm shrd eax, edx, x \
_asm { \
mov eax, a \
imul d \
mov ebx, eax \
mov eax, S \
mov esi, edx \
imul D \
add eax, ebx \
adc edx, esi \
shrd eax, edx, x \
} \
}
 
DMULSCALE(1) DMULSCALE(2) DMULSCALE(3) DMULSCALE(4)
3105,33 → 3019,38
#undef DMULSCALE
static __inline long dmulscale32(long a, long d, long S, long D)
{
_asm mov eax, a
_asm imul d
_asm mov ebx, eax
_asm mov eax, S
_asm mov esi, edx
_asm imul D
_asm add eax, ebx
_asm adc edx, esi
_asm mov eax, edx
_asm {
mov eax, a
imul d
mov ebx, eax
mov eax, S
mov esi, edx
imul D
add eax, ebx
adc edx, esi
mov eax, edx
}
}
 
#define TMULSCALE(x) \
static __inline long tmulscale##x (long a, long d, long b, long c, long S, long D) \
{ \
_asm mov eax, a \
_asm mov ebx, b \
_asm imul d \
_asm xchg eax, ebx \
_asm mov ecx, c \
_asm xchg edx, ecx \
_asm imul edx \
_asm add ebx, eax \
_asm adc ecx, edx \
_asm mov eax, S \
_asm imul D \
_asm add eax, ebx \
_asm adc edx, ecx \
_asm { \
mov eax, a \
mov ebx, b \
imul d \
xchg eax, ebx \
mov ecx, c \
xchg edx, ecx \
imul edx \
add ebx, eax \
adc ecx, edx \
mov eax, S \
imul D \
add eax, ebx \
adc edx, ecx \
shrd eax, edx, x \
} \
}
 
TMULSCALE(1) TMULSCALE(2) TMULSCALE(3) TMULSCALE(4)
3145,89 → 3064,102
#undef TMULSCALE
static __inline long tmulscale32(long a, long d, long b, long c, long S, long D)
{
_asm mov eax, a
_asm mov ebx, b
_asm imul d
_asm xchg eax, ebx
_asm mov ecx, c
_asm xchg edx, ecx
_asm imul edx
_asm add ebx, eax
_asm adc ecx, edx
_asm mov eax, S
_asm imul D
_asm add eax, ebx
_asm adc edx, ecx
_asm mov eax, edx
_asm {
mov eax, a
mov ebx, b
imul d
xchg eax, ebx
mov ecx, c
xchg edx, ecx
imul edx
add ebx, eax
adc ecx, edx
mov eax, S
imul D
add eax, ebx
adc edx, ecx
mov eax, edx
}
}
 
static __inline long boundmulscale(long a, long b, long c)
{
_asm mov eax, a
_asm mov ecx, c
_asm imul b
_asm mov ebx, edx
_asm shrd eax, edx, cl
_asm sar edx, cl
_asm xor edx, eax
_asm js checkit
_asm xor edx, eax
_asm jz skipboundit
_asm cmp edx, 0xffffffff
_asm je skipboundit
_asm {
mov eax, a
mov ecx, c
imul b
mov ebx, edx
shrd eax, edx, cl
sar edx, cl
xor edx, eax
js checkit
xor edx, eax
jz skipboundit
cmp edx, 0xffffffff
je skipboundit
checkit:
_asm mov eax, ebx
_asm sar eax, 31
_asm xor eax, 0x7fffffff
mov eax, ebx
sar eax, 31
xor eax, 0x7fffffff
skipboundit:
;
}
}
 
static __inline long divscale(long a, long b, long c)
{
_asm mov eax, a
_asm mov ecx, c
_asm mov edx, eax
_asm shl eax, cl
_asm neg cl
_asm sar edx, cl
_asm idiv b
_asm {
mov eax, a
mov ecx, c
mov edx, eax
shl eax, cl
neg cl
sar edx, cl
idiv b
}
}
 
static __inline long divscale1(long a, long b)
{
_asm mov eax, a
_asm add eax, eax
_asm sbb edx, edx
_asm idiv b
_asm {
mov eax, a
add eax, eax
sbb edx, edx
idiv b
}
}
 
static __inline long divscale2(long a, long b)
{
_asm mov eax, a
_asm mov edx, eax
_asm sar edx, 30
_asm lea eax, [eax*4]
_asm idiv b
_asm {
mov eax, a
mov edx, eax
sar edx, 30
lea eax, [eax*4]
idiv b
}
}
 
static __inline long divscale3(long a, long b)
{
_asm mov eax, a
_asm mov edx, eax
_asm sar edx, 29
_asm lea eax, [eax*8]
_asm idiv b
_asm {
mov eax, a
mov edx, eax
sar edx, 29
lea eax, [eax*8]
idiv b
}
}
 
#define DIVSCALE(x,y) \
static __inline long divscale##y(long a, long b) \
{ \
_asm mov eax, a \
_asm mov edx, eax \
_asm sar edx, x \
_asm shl eax, y \
_asm idiv b \
_asm { \
mov eax, a \
mov edx, eax \
sar edx, x \
shl eax, y \
idiv b \
} \
}
 
DIVSCALE(28,4) DIVSCALE(27,5) DIVSCALE(26,6) DIVSCALE(25,7)
3240,441 → 3172,441
 
static __inline long divscale32(long d, long b)
{
_asm mov edx, d
_asm xor eax, eax
_asm idiv b
_asm {
mov edx, d
xor eax, eax
idiv b
}
}
 
static __inline char readpixel(void *d)
{
_asm mov edx, d
_asm mov al, byte ptr [edx]
_asm {
mov edx, d
mov al, byte ptr [edx]
}
}
 
static __inline void drawpixel(void *d, char a)
{
_asm mov edx, d
_asm mov al, a
_asm mov byte ptr [edx], al
_asm {
mov edx, d
mov al, a
mov byte ptr [edx], al
}
}
 
static __inline void drawpixels(void *d, short a)
{
_asm mov edx, d
_asm mov ax, a
_asm mov word ptr [edx], ax
_asm {
mov edx, d
mov ax, a
mov word ptr [edx], ax
}
}
 
static __inline void drawpixelses(void *d, long a)
{
_asm mov edx, d
_asm mov eax, a
_asm mov dword ptr [edx], eax
_asm {
mov edx, d
mov eax, a
mov dword ptr [edx], eax
}
}
 
static __inline void clearbuf(void *d, long c, long a)
{
_asm mov edi, d
_asm mov ecx, c
_asm mov eax, a
_asm rep stosd
_asm {
mov edi, d
mov ecx, c
mov eax, a
rep stosd
}
}
 
static __inline void clearbufbyte(void *d, long c, long a)
{
_asm mov edi, d
_asm mov ecx, c
_asm mov eax, a
_asm {
cmp ecx, 4
jae longcopy
test cl, 1
jz preskip
stosb
}
mov edi, d
mov ecx, c
mov eax, a
cmp ecx, 4
jae longcopy
test cl, 1
jz preskip
stosb
preskip:
_asm {
shr ecx, 1
rep stosw
jmp endit
}
shr ecx, 1
rep stosw
jmp endit
longcopy:
_asm {
test edi, 1
jz skip1
stosb
dec ecx
}
test edi, 1
jz skip1
stosb
dec ecx
skip1:
_asm {
test edi, 2
jz skip2
stosw
sub ecx, 2
}
test edi, 2
jz skip2
stosw
sub ecx, 2
skip2:
_asm {
mov ebx, ecx
shr ecx, 2
rep stosd
test bl, 2
jz skip3
stosw
}
mov ebx, ecx
shr ecx, 2
rep stosd
test bl, 2
jz skip3
stosw
skip3:
_asm {
test bl, 1
jz endit
stosb
test bl, 1
jz endit
stosb
endit:
}
endit:
;
}
 
static __inline void copybuf(void *s, void *d, long c)
{
_asm mov esi, s
_asm mov edi, d
_asm mov ecx, c
_asm rep movsd
_asm {
mov esi, s
mov edi, d
mov ecx, c
rep movsd
}
}
 
static __inline void copybufbyte(void *s, void *d, long c)
{
_asm mov esi, s
_asm mov edi, d
_asm mov ecx, c
_asm {
cmp ecx, 4
jae longcopy
test cl, 1
jz preskip
movsb
}
mov esi, s
mov edi, d
mov ecx, c
cmp ecx, 4
jae longcopy
test cl, 1
jz preskip
movsb
preskip:
_asm {
shr ecx, 1
rep movsw
jmp endit
}
shr ecx, 1
rep movsw
jmp endit
longcopy:
_asm {
test edi, 1
jz skip1
movsb
dec ecx
}
test edi, 1
jz skip1
movsb
dec ecx
skip1:
_asm {
test edi, 2
jz skip2
movsw
sub ecx, 2
}
test edi, 2
jz skip2
movsw
sub ecx, 2
skip2:
_asm {
mov ebx, ecx
shr ecx, 2
rep movsd
test bl, 2
jz skip3
movsw
}
mov ebx, ecx
shr ecx, 2
rep movsd
test bl, 2
jz skip3
movsw
skip3:
_asm {
test bl, 1
jz endit
movsb
test bl, 1
jz endit
movsb
endit:
}
endit:
;
}
 
static __inline void copybufreverse(void *s, void *d, long c)
{
_asm mov esi, s
_asm mov edi, d
_asm mov ecx, c
_asm {
shr ecx, 1
jnc skipit1
mov al, byte ptr [esi]
dec esi
mov byte ptr [edi], al
inc edi
}
mov esi, s
mov edi, d
mov ecx, c
shr ecx, 1
jnc skipit1
mov al, byte ptr [esi]
dec esi
mov byte ptr [edi], al
inc edi
skipit1:
_asm {
shr ecx, 1
jnc skipit2
mov ax, word ptr [esi-1]
sub esi, 2
ror ax, 8
mov word ptr [edi], ax
add edi, 2
}
shr ecx, 1
jnc skipit2
mov ax, word ptr [esi-1]
sub esi, 2
ror ax, 8
mov word ptr [edi], ax
add edi, 2
skipit2:
_asm {
test ecx, ecx
jz endloop
}
test ecx, ecx
jz endloop
begloop:
_asm {
mov eax, dword ptr [esi-3]
sub esi, 4
bswap eax
mov dword ptr [edi], eax
add edi, 4
dec ecx
jnz begloop
mov eax, dword ptr [esi-3]
sub esi, 4
bswap eax
mov dword ptr [edi], eax
add edi, 4
dec ecx
jnz begloop
endloop:
}
endloop:
;
}
 
static __inline void qinterpolatedown16(long a, long c, long d, long s)
{
_asm mov eax, a
_asm mov ecx, c
_asm mov edx, d
_asm mov esi, s
_asm {
mov ebx, ecx
shr ecx, 1
jz skipbegcalc
}
mov eax, a
mov ecx, c
mov edx, d
mov esi, s
mov ebx, ecx
shr ecx, 1
jz skipbegcalc
begqcalc:
_asm {
lea edi, [edx+esi]
sar edx, 16
mov dword ptr [eax], edx
lea edx, [edi+esi]
sar edi, 16
mov dword ptr [eax+4], edi
add eax, 8
dec ecx
jnz begqcalc
test ebx, 1
jz skipbegqcalc2
}
lea edi, [edx+esi]
sar edx, 16
mov dword ptr [eax], edx
lea edx, [edi+esi]
sar edi, 16
mov dword ptr [eax+4], edi
add eax, 8
dec ecx
jnz begqcalc
test ebx, 1
jz skipbegqcalc2
skipbegcalc:
_asm {
sar edx, 16
mov dword ptr [eax], edx
sar edx, 16
mov dword ptr [eax], edx
skipbegqcalc2:
}
skipbegqcalc2:
;
}
 
static __inline void qinterpolatedown16short(long a, long c, long d, long s)
{
_asm mov eax, a
_asm mov ecx, c
_asm mov edx, d
_asm mov esi, s
_asm {
test ecx, ecx
jz endit
test al, 2
jz skipalignit
mov ebx, edx
sar ebx, 16
mov word ptr [eax], bx
add edx, esi
add eax, 2
dec ecx
jz endit
}
mov eax, a
mov ecx, c
mov edx, d
mov esi, s
test ecx, ecx
jz endit
test al, 2
jz skipalignit
mov ebx, edx
sar ebx, 16
mov word ptr [eax], bx
add edx, esi
add eax, 2
dec ecx
jz endit
skipalignit:
_asm {
sub ecx, 2
jc finishit
}
sub ecx, 2
jc finishit
begqcalc:
_asm {
mov ebx, edx
add edx, esi
sar ebx, 16
mov edi, edx
and edi, 0ffff0000h
add edx, esi
add ebx, edi
mov dword ptr [eax], ebx
add eax, 4
sub ecx, 2
jnc begqcalc
test cl, 1
jz endit
}
mov ebx, edx
add edx, esi
sar ebx, 16
mov edi, edx
and edi, 0ffff0000h
add edx, esi
add ebx, edi
mov dword ptr [eax], ebx
add eax, 4
sub ecx, 2
jnc begqcalc
test cl, 1
jz endit
finishit:
_asm {
mov ebx, edx
sar ebx, 16
mov word ptr [eax], bx
mov ebx, edx
sar ebx, 16
mov word ptr [eax], bx
endit:
}
endit:
;
}
 
static __inline long mul3(long a)
{
_asm mov eax, a
_asm lea eax, [eax+eax*2]
_asm {
mov eax, a
lea eax, [eax+eax*2]
}
}
 
static __inline long mul5(long a)
{
_asm mov eax, a
_asm lea eax, [eax+eax*4]
_asm {
mov eax, a
lea eax, [eax+eax*4]
}
}
 
static __inline long mul9(long a)
{
_asm mov eax, a
_asm lea eax, [eax+eax*8]
_asm {
mov eax, a
lea eax, [eax+eax*8]
}
}
 
//returns eax/ebx, dmval = eax%edx;
static __inline long divmod(long a, long b)
{
_asm mov eax, a
_asm xor edx, edx
_asm div b
_asm mov dmval, edx
_asm {
mov eax, a
xor edx, edx
div b
mov dmval, edx
}
}
 
//returns eax%ebx, dmval = eax/edx;
static __inline long moddiv(long a, long b)
{
_asm mov eax, a
_asm xor edx, edx
_asm div b
_asm mov dmval, eax
_asm mov eax, edx
_asm {
mov eax, a
xor edx, edx
div b
mov dmval, eax
mov eax, edx
}
}
 
static __inline long klabs(long a)
{
_asm mov eax, a
_asm test eax, eax
_asm jns skipnegate
_asm neg eax
_asm {
mov eax, a
test eax, eax
jns skipnegate
neg eax
skipnegate:
;
}
}
 
static __inline long ksgn(long b)
{
_asm mov ebx, b
_asm add ebx, ebx
_asm sbb eax, eax
_asm cmp eax, ebx
_asm adc al, 0
_asm {
mov ebx, b
add ebx, ebx
sbb eax, eax
cmp eax, ebx
adc al, 0
}
}
 
//eax = (unsigned min)umin(eax,ebx)
static __inline long umin(long a, long b)
{
_asm mov eax, a
_asm sub eax, b
_asm sbb ecx, ecx
_asm and eax, ecx
_asm add eax, b
_asm {
mov eax, a
sub eax, b
sbb ecx, ecx
and eax, ecx
add eax, b
}
}
 
//eax = (unsigned max)umax(eax,ebx)
static __inline long umax(long a, long b)
{
_asm mov eax, a
_asm sub eax, b
_asm sbb ecx, ecx
_asm xor ecx, 0xffffffff
_asm and eax, ecx
_asm add eax, b
_asm {
mov eax, a
sub eax, b
sbb ecx, ecx
xor ecx, 0xffffffff
and eax, ecx
add eax, b
}
}
 
static __inline long kmin(long a, long b)
{
_asm mov eax, a
_asm mov ebx, b
_asm cmp eax, ebx
_asm jl skipit
_asm mov eax, ebx
_asm {
mov eax, a
mov ebx, b
cmp eax, ebx
jl skipit
mov eax, ebx
skipit:
;
}
}
 
static __inline long kmax(long a, long b)
{
_asm mov eax, a
_asm mov ebx, b
_asm cmp eax, ebx
_asm jg skipit
_asm mov eax, ebx
_asm {
mov eax, a
mov ebx, b
cmp eax, ebx
jg skipit
mov eax, ebx
skipit:
;
}
}
 
static __inline void swapchar(void *a, void *b)
{
_asm mov eax, a
_asm mov ebx, b
_asm mov cl, [eax]
_asm mov ch, [ebx]
_asm mov [ebx], cl
_asm mov [eax], ch
_asm {
mov eax, a
mov ebx, b
mov cl, [eax]
mov ch, [ebx]
mov [ebx], cl
mov [eax], ch
}
}
 
static __inline void swapshort(void *a, void *b)
{
_asm mov eax, a
_asm mov ebx, b
_asm mov cx, [eax]
_asm mov dx, [ebx]
_asm mov [ebx], cx
_asm mov [eax], dx
_asm {
mov eax, a
mov ebx, b
mov cx, [eax]
mov dx, [ebx]
mov [ebx], cx
mov [eax], dx
}
}
 
static __inline void swaplong(void *a, void *b)
{
_asm mov eax, a
_asm mov ebx, b
_asm mov ecx, [eax]
_asm mov edx, [ebx]
_asm mov [ebx], ecx
_asm mov [eax], edx
_asm {
mov eax, a
mov ebx, b
mov ecx, [eax]
mov edx, [ebx]
mov [ebx], ecx
mov [eax], edx
}
}
 
static __inline void swapbuf4(void *a, void *b, long c)
{
_asm mov eax, a
_asm mov ebx, b
_asm mov ecx, c
_asm {
mov eax, a
mov ebx, b
mov ecx, c
begswap:
_asm {
mov esi, [eax]
mov edi, [ebx]
mov [ebx], esi
mov [eax], edi
add eax, 4
add ebx, 4
dec ecx
jnz short begswap
mov esi, [eax]
mov edi, [ebx]
mov [ebx], esi
mov [eax], edi
add eax, 4
add ebx, 4
dec ecx
jnz short begswap
}
}
 
static __inline void swap64bit(void *a, void *b)
{
_asm mov eax, a
_asm mov ebx, b
_asm mov ecx, [eax]
_asm mov edx, [ebx]
_asm mov [ebx], ecx
_asm mov ecx, [eax+4]
_asm mov [eax], edx
_asm mov edx, [ebx+4]
_asm mov [ebx+4], ecx
_asm mov [eax+4], edx
_asm {
mov eax, a
mov ebx, b
mov ecx, [eax]
mov edx, [ebx]
mov [ebx], ecx
mov ecx, [eax+4]
mov [eax], edx
mov edx, [ebx+4]
mov [ebx+4], ecx
mov [eax+4], edx
}
}
 
//swapchar2(ptr1,ptr2,xsiz); is the same as:
3681,23 → 3613,120
//swapchar(ptr1,ptr2); swapchar(ptr1+1,ptr2+xsiz);
static __inline void swapchar2(void *a, void *b, long s)
{
_asm mov eax, a
_asm mov ebx, b
_asm mov esi, s
_asm add esi, ebx
_asm mov cx, [eax]
_asm mov dl, [ebx]
_asm mov [ebx], cl
_asm mov dh, [esi]
_asm mov [esi], ch
_asm mov [eax], dx
_asm {
mov eax, a
mov ebx, b
mov esi, s
add esi, ebx
mov cx, [eax]
mov dl, [ebx]
mov [ebx], cl
mov dh, [esi]
mov [esi], ch
mov [eax], dx
}
}
//}}}
 
#else // _MSC_VER
 
#error Unsupported compiler or architecture.
//
// Generic C
//
 
#define qw(x) ((int64)(x)) // quadword cast
#define dw(x) ((long)(x)) // doubleword cast
#define wo(x) ((short)(x)) // word cast
#define by(x) ((char)(x)) // byte cast
 
#define _scaler(a) \
static inline long mulscale##a(long eax, long edx) \
{ \
return dw((qw(eax) * qw(edx)) >> a); \
} \
\
static inline long divscale##a(long eax, long ebx) \
{ \
return dw((qw(eax) << a) / qw(ebx)); \
} \
\
static inline long dmulscale##a(long eax, long edx, long esi, long edi) \
{ \
return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> a); \
} \
\
static inline long tmulscale##a(long eax, long edx, long ebx, long ecx, long esi, long edi) \
{ \
return dw(((qw(eax) * qw(edx)) + (qw(ebx) * qw(ecx)) + (qw(esi) * qw(edi))) >> a); \
} \
 
_scaler(1) _scaler(2) _scaler(3) _scaler(4)
_scaler(5) _scaler(6) _scaler(7) _scaler(8)
_scaler(9) _scaler(10) _scaler(11) _scaler(12)
_scaler(13) _scaler(14) _scaler(15) _scaler(16)
_scaler(17) _scaler(18) _scaler(19) _scaler(20)
_scaler(21) _scaler(22) _scaler(23) _scaler(24)
_scaler(25) _scaler(26) _scaler(27) _scaler(28)
_scaler(29) _scaler(30) _scaler(31) _scaler(32)
 
static inline void swapchar(void* a, void* b) { char t = *((char*)b); *((char*)b) = *((char*)a); *((char*)a) = t; }
static inline void swapchar2(void* a, void* b, long s) { swapchar(a,b); swapchar((char*)a+1,(char*)b+s); }
static inline void swapshort(void* a, void* b) { short t = *((short*)b); *((short*)b) = *((short*)a); *((short*)a) = t; }
static inline void swaplong(void* a, void* b) { long t = *((long*)b); *((long*)b) = *((long*)a); *((long*)a) = t; }
static inline void swap64bit(void* a, void* b) { int64 t = *((int64*)b); *((int64*)b) = *((int64*)a); *((int64*)a) = t; }
 
static inline char readpixel(void* s) { return (*((char*)(s))); }
static inline void drawpixel(void* s, char a) { *((char*)(s)) = a; }
static inline void drawpixels(void* s, short a) { *((short*)(s)) = a; }
static inline void drawpixelses(void* s, long a) { *((long*)(s)) = a; }
 
static inline long mul3(long a) { return (a<<1)+a; }
static inline long mul5(long a) { return (a<<2)+a; }
static inline long mul9(long a) { return (a<<3)+a; }
 
static inline long divmod(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a%_b; return _a/_b; }
static inline long moddiv(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a/_b; return _a%_b; }
 
static inline long klabs(long a) { if (a < 0) return -a; return a; }
static inline long ksgn(long a) { if (a > 0) return 1; if (a < 0) return -1; return 0; }
 
static inline long umin(long a, long b) { if ((unsigned long)a < (unsigned long)b) return a; return b; }
static inline long umax(long a, long b) { if ((unsigned long)a < (unsigned long)b) return b; return a; }
static inline long kmin(long a, long b) { if ((signed long)a < (signed long)b) return a; return b; }
static inline long kmax(long a, long b) { if ((signed long)a < (signed long)b) return b; return a; }
 
static inline long sqr(long eax) { return (eax) * (eax); }
static inline long scale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) / qw(ecx)); }
static inline long mulscale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); }
static inline long divscale(long eax, long ebx, long ecx) { return dw((qw(eax) << by(ecx)) / qw(ebx)); }
static inline long dmulscale(long eax, long edx, long esi, long edi, long ecx) { return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx)); }
 
static inline long boundmulscale(long a, long d, long c)
{ // courtesy of Ken
int64 p;
p = (((int64)a)*((int64)d))>>c;
if (p >= longlong(2147483647)) p = longlong(2147483647);
if (p < longlong(-2147483648)) p = longlong(-2147483648);
return((long)p);
}
 
#undef qw
#undef dw
#undef wo
#undef by
#undef _scaler
 
void qinterpolatedown16 (long bufptr, long num, long val, long add);
void qinterpolatedown16short (long bufptr, long num, long val, long add);
 
void clearbuf(void* d, long c, long a);
void copybuf(void* s, void* d, long c);
void swapbuf4(void* a, void* b, long c);
 
void clearbufbyte(void *D, long c, long a);
void copybufbyte(void *S, void *D, long c);
void copybufreverse(void *S, void *D, long c);
 
#endif
 
#endif // __pragmas_h__
/polymer/build/include/startwin.editor.h
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
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/include/winlayer.h
13,37 → 13,9
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
/polymer/build/src/buildstartwin.c
File deleted
/polymer/build/src/gamestartwin.c
File deleted
/polymer/build/src/StartupWinController.editor.m
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;
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/StartupWinController.game.m
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;
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/baselayer.c
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
};
#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
,
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);
/polymer/build/src/build.c
81,6 → 81,7
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
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
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
"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
//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) {
/polymer/build/src/compat.c
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
#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
#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;
/polymer/build/src/config.c
106,6 → 106,7
 
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
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
"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
/polymer/build/src/engine.c
123,78 → 123,8
char *engineerrstr = "No error";
 
 
#if defined(NOASM)
#if defined(__WATCOMC__) && !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__)
 
//
// Watcom Inline Assembly Routines
//
297,7 → 227,7
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
}
}
 
#elif defined(__GNUC__) && defined(__i386__) // _MSC_VER
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // _MSC_VER
 
//
// GCC "Inline" Assembly Routines
539,8 → 469,74
 
#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
 
 
/polymer/build/src/game.c
131,6 → 131,7
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
return OSDCMD_OK;
}
 
#ifdef RENDERTYPEWIN
int DoLaunchWindow(void); // gamestartwin.c
#endif
extern int startwin_run(void);
 
char *startwin_labeltext = "Starting KenBuild...";
 
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,23 → 413,16
}
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");
439,10 → 429,15
return -1;
}
 
#ifdef RENDERTYPEWIN
if (DoLaunchWindow()) return -1;
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");
#endif
 
initinput();
if (option[3] != 0) initmouse();
3633,13 → 3628,13
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
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
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
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
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
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)
/polymer/build/src/glbuild.c
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
#endif
 
if (!driver) {
#ifdef _WIN32
#ifdef _WIN32
driver = "OPENGL32.DLL";
#elif defined __APPLE__
driver = "OpenGLLibrary";
#else
driver = "libGL.so";
#endif
/polymer/build/src/gtkbits.c
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
#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
if (appicon) g_object_unref((gpointer)appicon);
//gtk_exit(r);
}
 
void *gtkbuild_get_app_icon(void)
{
return appicon;
}
/polymer/build/src/kplib.c
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
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
// 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
// * 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,26 → 187,8
static long qhufval0[1<<LOGQHUFSIZ0], qhufval1[1<<LOGQHUFSIZ1];
static unsigned char qhufbit0[1<<LOGQHUFSIZ0], qhufbit1[1<<LOGQHUFSIZ1];
 
#if defined(NOASM)
#if defined(__WATCOMC__) && !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__)
 
long bswap (long);
#pragma aux bswap =\
".586"\
256,7 → 239,7
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
}
}
 
#elif defined(__GNUC__) && defined(__i386__)
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM)
 
static inline unsigned long bswap (unsigned long a)
{
358,8 → 341,22
 
#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
 
//Bit numbers of return value:
575,36 → 572,8
if (pb <= pc) return(b); else return(c);
}
 
#if defined(NOASM)
#if defined(__WATCOMC__) && !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__)
 
//NOTE: cmov now has correctly ordered registers (thx to bug fix in 11.0c!)
long Paeth686 (long, long, long);
#pragma aux Paeth686 =\
669,7 → 638,7
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
}
}
 
#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
 
#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
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
*(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
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
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
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
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
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
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,20 → 1221,8
static long colclip[1024], colclipup8[1024], colclipup16[1024];
static unsigned char pow2char[8] = {1,2,4,8,16,32,64,128};
 
#if defined(NOASM)
#if defined(__WATCOMC__) && !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__)
 
long mulshr24 (long, long);
#pragma aux mulshr24 =\
"imul edx"\
1233,7 → 1237,7
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
}
}
 
#elif defined(__GNUC__) && defined(__i386__)
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM)
 
#define mulshr24(a,d) \
({ long __a=(a), __d=(d); \
1271,8 → 1275,16
 
#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
 
static long cosqr16[8] = //cosqr16[i] = ((cos(PI*i/16)*sqrt(2))<<24);
2263,7 → 2275,8
}
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
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
(*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
{
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
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
 
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
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);
}
/polymer/build/src/mdsprite.c
561,7 → 561,7
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,&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));
/polymer/build/src/misc/buildres.rc
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
 
/polymer/build/src/misc/gameres.rc
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
 
/polymer/build/src/misc/gtkstartwin/gtkstartwin.glade
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>
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/misc/gtkstartwin/gtkstartwin.gladep
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>
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/misc/gtkstartwin/pixmaps/game.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/polymer/build/src/osxbits.m
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)
{
NSString *mmsg = [[NSString alloc] initWithCString: msg];
 
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
NSAlert *alert = [[NSAlert alloc] init];
NSString *mmsg = [[NSString alloc] initWithCString: msg];
[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;
}
/polymer/build/src/polymost.c
856,7 → 856,7
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
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
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); }
/polymer/build/src/pragmas.c
12,75 → 12,9
 
long dmval;
 
#if defined(NOASM)
#if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // 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
 
//
// GCC Inline Assembler version
//
 
229,13 → 163,13
);
}
 
#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,8 → 177,70
 
#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
 
 
/polymer/build/src/sdlayer.c
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
 
SDL_WM_SetCaption(apptitle, NULL);
 
#ifdef HAVE_GTK2
gtkbuild_settitle_startwin(apptitle);
#endif
startwin_settitle(apptitle);
}
 
 
154,8 → 158,8
 
#ifdef HAVE_GTK2
gtkbuild_init(&argc, &argv);
gtkbuild_create_startwin();
#endif
startwin_open();
 
_buildargc = argc;
_buildargv = (char**)argv;
165,8 → 169,8
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
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
 
// 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
 
// 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
//
// 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
}
}
 
#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
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
 
sampletimer();
 
#ifdef HAVE_GTK2
gtkbuild_update_startwin();
#endif
startwin_idle(NULL);
 
#undef SetKey
 
/polymer/build/src/startgtk.editor.c
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;
}
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/startgtk.game.c
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;
}
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/startwin.editor.c
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;
}
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/startwin.game.c
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;
}
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/startwin.game.h
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
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/build/src/winlayer.c
56,10 → 56,6
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
}
 
if (hWindow) SetWindowText(hWindow, apptitle);
if (startupdlg) {
char buf[1000];
Bsnprintf(buf, 1000, "%s Startup", apptitle);
SetWindowText(startupdlg, buf);
}
startwin_settitle(apptitle);
}
 
//
256,144 → 248,7
}
}
 
 
//
// 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
//
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
502,16 → 357,16
 
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
{
DestroyAppWindow();
 
if (startupdlg) {
DestroyWindow(startupdlg);
}
startwin_close();
 
uninitinput();
uninittimer();
615,57 → 468,12
{
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
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
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
//
// 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
}
 
#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
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
return TRUE;
}
 
if (startupdlg) {
DestroyWindow(startupdlg);
}
startwin_close();
} else {
SetWindowLong(hWindow,GWL_EXSTYLE,stylebitsex);
SetWindowLong(hWindow,GWL_STYLE,stylebits);
/polymer/eduke32/build.cfg
File deleted
/polymer/eduke32/ChangeLog
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
/polymer/eduke32/Makefile
19,6 → 19,7
SRC=source/
RSRC=rsrc/
EROOT=../build/
ESRC=$(EROOT)src/
EINC=$(EROOT)include/
INC=$(SRC)
o=o
105,7 → 106,7
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 (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
$(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
/polymer/eduke32/Makefile.deps
27,8 → 27,9
$(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
/polymer/eduke32/source/actors.c
2429,7 → 2429,7
 
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;
/polymer/eduke32/source/astub.c
4220,7 → 4220,7
long rv = 0;
char *duke3dgrp = "duke3d.grp";
 
#if 1 // defined(_WIN32)
#if defined(_WIN32)
if (!access("user_profiles_enabled", F_OK))
#endif
{
/polymer/eduke32/source/config.c
95,6 → 95,7
int32 ScreenHeight = 600;
int32 ScreenBPP = 8;
#endif
int32 ForceSetup = 1;
 
static char setupfilename[256]={SETUPFILENAME};
int32 scripthandle = -1;
558,7 → 559,7
===================
*/
 
void CONFIG_ReadSetup( void )
int32 CONFIG_ReadSetup( void )
{
int32 dummy, i;
char commmacro[] = "CommbatMacro# ";
572,6 → 573,8
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
 
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
 
//CONFIG_SetupMouse(scripthandle);
//CONFIG_SetupJoystick(scripthandle);
 
setupread = 1;
return 0;
}
 
/*
742,6 → 746,7
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);
/polymer/eduke32/source/config.h
52,6 → 52,7
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 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 );
/polymer/eduke32/source/funct.h
260,7 → 260,7
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);
/polymer/eduke32/source/game.c
44,7 → 44,7
 
#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
 
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
"-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
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
i++;
continue;
}
#if !defined(_WIN32)
if (!Bstrcasecmp(c+1,"usecwd")) {
usecwd = 1;
i++;
continue;
}
#endif
}
 
if (firstnet > 0) {
8494,6 → 8511,8
// initprintf("ud.m_coop=%i after sanitisation\n",ud.m_coop);
}
 
extern int startwin_run(void);
 
void Startup(void)
{
int i;
8502,8 → 8521,23
 
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();
 
if (ud.multimode > 1) sanitizegametype();
8558,12 → 8592,6
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
 
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];
/polymer/eduke32/source/menus.c
2432,7 → 2432,7
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;
/polymer/eduke32/source/misc/buildres.rc
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
 
/polymer/eduke32/source/misc/gameres.rc
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
 
/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.glade
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>
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.gladep
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>
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/eduke32/source/misc/gtkstartwin/pixmaps/game.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/polymer/eduke32/source/premap.c
1000,6 → 1000,7
 
if(globalskillsound >= 0 && FXDevice >= 0 && SoundToggle)
while(issoundplaying(-1,globalskillsound)) { handleevents(); getpackets(); }
else { handleevents(); getpackets(); }
globalskillsound = -1;
 
waitforeverybody();
/polymer/eduke32/source/startgtk.game.c
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;
}
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/eduke32/source/startwin.game.c
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;
}
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/polymer/eduke32/source/startwin.game.h
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
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property