diff --git a/Recipe b/Recipe index c946a8d..42618eb 100644 --- a/Recipe +++ b/Recipe @@ -13,6 +13,8 @@ !makefile cygwin Makefile.cyg !makefile osx Makefile.osx +!srcdir icons/ + WINDOWS = windows printing + user32.lib gdi32.lib comctl32.lib comdlg32.lib winspool.lib COMMON = midend drawing misc malloc random version diff --git a/blackbox.R b/blackbox.R index 7ea69a6..884fe44 100644 --- a/blackbox.R +++ b/blackbox.R @@ -2,7 +2,7 @@ blackbox : [X] GTK COMMON blackbox -blackbox : [G] WINDOWS COMMON blackbox +blackbox : [G] WINDOWS COMMON blackbox blackbox.res? ALL += blackbox diff --git a/bridges.R b/bridges.R index 4798195..f11fd41 100644 --- a/bridges.R +++ b/bridges.R @@ -4,7 +4,7 @@ BRIDGES = bridges dsf bridges : [X] GTK COMMON BRIDGES -bridges : [G] WINDOWS COMMON BRIDGES +bridges : [G] WINDOWS COMMON BRIDGES bridges.res? ALL += BRIDGES diff --git a/cube.R b/cube.R index 2c548a4..cc10fde 100644 --- a/cube.R +++ b/cube.R @@ -2,7 +2,7 @@ cube : [X] GTK COMMON cube -cube : [G] WINDOWS COMMON cube +cube : [G] WINDOWS COMMON cube cube.res? ALL += cube diff --git a/dominosa.R b/dominosa.R index 30f35ff..3bc8e34 100644 --- a/dominosa.R +++ b/dominosa.R @@ -2,7 +2,7 @@ dominosa : [X] GTK COMMON dominosa -dominosa : [G] WINDOWS COMMON dominosa +dominosa : [G] WINDOWS COMMON dominosa dominosa.res? ALL += dominosa diff --git a/fifteen.R b/fifteen.R index 3fc0093..fd371d7 100644 --- a/fifteen.R +++ b/fifteen.R @@ -2,7 +2,7 @@ fifteen : [X] GTK COMMON fifteen -fifteen : [G] WINDOWS COMMON fifteen +fifteen : [G] WINDOWS COMMON fifteen fifteen.res? ALL += fifteen diff --git a/flip.R b/flip.R index 0570cb1..91764de 100644 --- a/flip.R +++ b/flip.R @@ -4,7 +4,7 @@ FLIP = flip tree234 flip : [X] GTK COMMON FLIP -flip : [G] WINDOWS COMMON FLIP +flip : [G] WINDOWS COMMON FLIP flip.res? ALL += FLIP diff --git a/guess.R b/guess.R index 3df2b43..fa98337 100644 --- a/guess.R +++ b/guess.R @@ -2,7 +2,7 @@ guess : [X] GTK COMMON guess -guess : [G] WINDOWS COMMON guess +guess : [G] WINDOWS COMMON guess guess.res? ALL += guess diff --git a/icons/Makefile b/icons/Makefile index 934b792..233f767 100644 --- a/icons/Makefile +++ b/icons/Makefile @@ -19,6 +19,7 @@ P16D24 = $(patsubst %,%-16d24.png,$(PUZZLES)) P16D8 = $(patsubst %,%-16d8.png,$(PUZZLES)) P16D4 = $(patsubst %,%-16d4.png,$(PUZZLES)) ICONS = $(patsubst %,%.ico,$(PUZZLES)) +RC = $(patsubst %,%.rc,$(PUZZLES)) BIN = ../ PIC = ./ @@ -26,7 +27,7 @@ PIC = ./ base: $(BASE) web: $(WEB) pngicons: $(P48D24) $(P32D24) $(P16D24) -icons: $(ICONS) +winicons: $(ICONS) $(RC) # Build the base puzzle screenshots from which all the other images # are derived. Some of them involve showing a move animation @@ -108,12 +109,16 @@ $(P16D4): %-16d4.png: %-ibase.png convert -colors 16 -map $(PIC)win16pal.xpm tmp2.png $@ rm -f tmp.png tmp2.png -# And build the actual icons themselves, by feeding all those PNGs -# to my icon builder script. +# Build the actual Windows icons themselves, by feeding all those +# PNGs to my icon builder script. $(ICONS): %.ico: %-48d24.png %-48d8.png %-48d4.png \ %-32d24.png %-32d8.png %-32d4.png \ %-16d24.png %-16d8.png %-16d4.png $(PIC)icon.pl $? > $@ +# Build the .RC files which bind the icons into the applications. +$(RC): %.rc: + echo '200 ICON "$*.ico"' > $@ + clean: - rm -f *.png *.ico + rm -f *.png *.ico *.rc diff --git a/inertia.R b/inertia.R index 6146bc9..33e1841 100644 --- a/inertia.R +++ b/inertia.R @@ -2,7 +2,7 @@ inertia : [X] GTK COMMON inertia -inertia : [G] WINDOWS COMMON inertia +inertia : [G] WINDOWS COMMON inertia inertia.res? ALL += inertia diff --git a/lightup.R b/lightup.R index 9c22e17..17a2c6c 100644 --- a/lightup.R +++ b/lightup.R @@ -4,7 +4,7 @@ LIGHTUP = lightup combi lightup : [X] GTK COMMON LIGHTUP -lightup : [G] WINDOWS COMMON LIGHTUP +lightup : [G] WINDOWS COMMON LIGHTUP lightup.res? lightupsolver : [U] lightup[STANDALONE_SOLVER] combi STANDALONE lightupsolver : [C] lightup[STANDALONE_SOLVER] combi STANDALONE diff --git a/loopy.R b/loopy.R index e390409..37e64b6 100644 --- a/loopy.R +++ b/loopy.R @@ -4,7 +4,7 @@ LOOPY = loopy tree234 dsf loopy : [X] GTK COMMON LOOPY -loopy : [G] WINDOWS COMMON LOOPY +loopy : [G] WINDOWS COMMON LOOPY loopy.res? ALL += LOOPY diff --git a/map.R b/map.R index d600738..7752ec2 100644 --- a/map.R +++ b/map.R @@ -4,7 +4,7 @@ MAP = map dsf map : [X] GTK COMMON MAP -map : [G] WINDOWS COMMON MAP +map : [G] WINDOWS COMMON MAP map.res? mapsolver : [U] map[STANDALONE_SOLVER] dsf STANDALONE m.lib mapsolver : [C] map[STANDALONE_SOLVER] dsf STANDALONE diff --git a/mines.R b/mines.R index 244b0bb..46913de 100644 --- a/mines.R +++ b/mines.R @@ -4,7 +4,7 @@ MINES = mines tree234 mines : [X] GTK COMMON MINES -mines : [G] WINDOWS COMMON MINES +mines : [G] WINDOWS COMMON MINES mines.res? mineobfusc : [U] mines[STANDALONE_OBFUSCATOR] tree234 STANDALONE mineobfusc : [C] mines[STANDALONE_OBFUSCATOR] tree234 STANDALONE diff --git a/mkfiles.pl b/mkfiles.pl index a107737..c81d64d 100755 --- a/mkfiles.pl +++ b/mkfiles.pl @@ -130,8 +130,17 @@ readinput: while (1) { $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) { $type = substr($i,1,(length $i)-2); } else { - push @$listref, $i; - push @allobjs, $i; + if ($i =~ /\?$/) { + # Source files with a trailing question mark are optional: + # the build can proceed fine without them, so we only use + # them if they're present. + $i =~ s/\?$//; + $i = undef unless defined &finddep($i); + } + if (defined $i) { + push @$listref, $i; + push @allobjs, $i; + } } } if ($prog and $type) { @@ -192,23 +201,8 @@ foreach $i (@prognames) { $programs{$i} = [@list]; foreach $jj (@list) { $j = $srcname{$jj}; - # Dependencies for "x" start with "x.c" or "x.m" (depending on - # which one exists). - # Dependencies for "x.res" start with "x.rc". - # Dependencies for "x.rsrc" start with "x.r". - # Both types of file are pushed on the list of files to scan. - # Libraries (.lib) don't have dependencies at all. - if ($j =~ /^(.*)\.res$/) { - $file = "$1.rc"; - $depends{$jj} = [$file]; - push @scanlist, $file; - } elsif ($j =~ /^(.*)\.rsrc$/) { - $file = "$1.r"; - $depends{$jj} = [$file]; - push @scanlist, $file; - } elsif ($j !~ /\./) { - $file = "$j.c"; - $file = "$j.m" unless &findfile($file); + $file = &finddep($j); + if (defined $file) { $depends{$jj} = [$file]; push @scanlist, $file; } @@ -315,6 +309,32 @@ sub findfile { return $findfilecache{$name}; } +sub finddep { + my $j = shift @_; + my $file; + # Find the first dependency of an object. + + # Dependencies for "x" start with "x.c" or "x.m" (depending on + # which one exists). + # Dependencies for "x.res" start with "x.rc". + # Dependencies for "x.rsrc" start with "x.r". + # Both types of file are pushed on the list of files to scan. + # Libraries (.lib) don't have dependencies at all. + if ($j =~ /^(.*)\.res$/) { + $file = "$1.rc"; + } elsif ($j =~ /^(.*)\.rsrc$/) { + $file = "$1.r"; + } elsif ($j !~ /\./) { + $file = "$j.c"; + $file = "$j.m" unless &findfile($file); + } else { + # For everything else, we assume it's its own dependency. + $file = $j; + } + $file = undef unless &findfile($file); + return $file; +} + sub objects { my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_; my @ret; @@ -655,7 +675,7 @@ if (defined $makefiles{'vc'}) { "\n"; if ($d->{obj} =~ /\.res$/) { print "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 ". - "-DWINVER=0x0400 ".$d->{deps}->[0]."\n"; + "-DWINVER=0x0400 -fo".$d->{obj}." ".$d->{deps}->[0]."\n"; } else { $deflist = join "", map { " /D$_" } @{$d->{defs}}; print "\tcl \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist". diff --git a/net.R b/net.R index 945d7ff..ec7c8a3 100644 --- a/net.R +++ b/net.R @@ -6,7 +6,7 @@ net : [X] GTK COMMON NET # The Windows Net shouldn't be called `net.exe' since Windows # already has a reasonably important utility program by that name! -netgame : [G] WINDOWS COMMON NET +netgame : [G] WINDOWS COMMON NET net.res? ALL += NET diff --git a/netslide.R b/netslide.R index a27eb95..69e643d 100644 --- a/netslide.R +++ b/netslide.R @@ -4,7 +4,7 @@ NETSLIDE = netslide tree234 netslide : [X] GTK COMMON NETSLIDE -netslide : [G] WINDOWS COMMON NETSLIDE +netslide : [G] WINDOWS COMMON NETSLIDE netslide.res? ALL += NETSLIDE diff --git a/pattern.R b/pattern.R index 0645db5..13dbfe2 100644 --- a/pattern.R +++ b/pattern.R @@ -2,7 +2,7 @@ pattern : [X] GTK COMMON pattern -pattern : [G] WINDOWS COMMON pattern +pattern : [G] WINDOWS COMMON pattern pattern.res? patternsolver : [U] pattern[STANDALONE_SOLVER] STANDALONE patternsolver : [C] pattern[STANDALONE_SOLVER] STANDALONE diff --git a/pegs.R b/pegs.R index 0284f69..a1ab945 100644 --- a/pegs.R +++ b/pegs.R @@ -4,7 +4,7 @@ PEGS = pegs tree234 pegs : [X] GTK COMMON PEGS -pegs : [G] WINDOWS COMMON PEGS +pegs : [G] WINDOWS COMMON PEGS pegs.res? ALL += PEGS diff --git a/rect.R b/rect.R index 498233d..20d3b49 100644 --- a/rect.R +++ b/rect.R @@ -2,7 +2,7 @@ rect : [X] GTK COMMON rect -rect : [G] WINDOWS COMMON rect +rect : [G] WINDOWS COMMON rect rect.res? ALL += rect diff --git a/samegame.R b/samegame.R index c6a088b..c3905bd 100644 --- a/samegame.R +++ b/samegame.R @@ -2,7 +2,7 @@ samegame : [X] GTK COMMON samegame -samegame : [G] WINDOWS COMMON samegame +samegame : [G] WINDOWS COMMON samegame samegame.res? ALL += samegame diff --git a/sixteen.R b/sixteen.R index dfddaea..46147af 100644 --- a/sixteen.R +++ b/sixteen.R @@ -2,7 +2,7 @@ sixteen : [X] GTK COMMON sixteen -sixteen : [G] WINDOWS COMMON sixteen +sixteen : [G] WINDOWS COMMON sixteen sixteen.res? ALL += sixteen diff --git a/slant.R b/slant.R index a1cc33f..b735ec4 100644 --- a/slant.R +++ b/slant.R @@ -4,7 +4,7 @@ SLANT = slant dsf slant : [X] GTK COMMON SLANT -slant : [G] WINDOWS COMMON SLANT +slant : [G] WINDOWS COMMON SLANT slant.res? slantsolver : [U] slant[STANDALONE_SOLVER] dsf STANDALONE slantsolver : [C] slant[STANDALONE_SOLVER] dsf STANDALONE diff --git a/solo.R b/solo.R index 8e6aa57..6fe4ea0 100644 --- a/solo.R +++ b/solo.R @@ -2,7 +2,7 @@ solo : [X] GTK COMMON solo -solo : [G] WINDOWS COMMON solo +solo : [G] WINDOWS COMMON solo solo.res? solosolver : [U] solo[STANDALONE_SOLVER] STANDALONE solosolver : [C] solo[STANDALONE_SOLVER] STANDALONE diff --git a/tents.R b/tents.R index 269dd7d..ab6066f 100644 --- a/tents.R +++ b/tents.R @@ -4,7 +4,7 @@ TENTS = tents maxflow tents : [X] GTK COMMON TENTS -tents : [G] WINDOWS COMMON TENTS +tents : [G] WINDOWS COMMON TENTS tents.res? ALL += TENTS diff --git a/twiddle.R b/twiddle.R index a7b26b3..c525953 100644 --- a/twiddle.R +++ b/twiddle.R @@ -2,7 +2,7 @@ twiddle : [X] GTK COMMON twiddle -twiddle : [G] WINDOWS COMMON twiddle +twiddle : [G] WINDOWS COMMON twiddle twiddle.res? ALL += twiddle diff --git a/untangle.R b/untangle.R index fdbd6c4..8c467d6 100644 --- a/untangle.R +++ b/untangle.R @@ -4,7 +4,7 @@ UNTANGLE = untangle tree234 untangle : [X] GTK COMMON UNTANGLE -untangle : [G] WINDOWS COMMON UNTANGLE +untangle : [G] WINDOWS COMMON UNTANGLE untangle.res? ALL += UNTANGLE diff --git a/windows.c b/windows.c index ebaa1b6..d282d72 100644 --- a/windows.c +++ b/windows.c @@ -2441,7 +2441,9 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = inst; - wndclass.hIcon = LoadIcon(inst, IDI_APPLICATION); + wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(200)); + if (!wndclass.hIcon) /* in case resource file is absent */ + wndclass.hIcon = LoadIcon(inst, IDI_APPLICATION); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = NULL; wndclass.lpszMenuName = NULL;