Added the first version of the "exploder" tool.

It works, but it is pretty useless now, without documentation. But
this should come shortly.
This commit is contained in:
Philippe Plantier 2004-06-20 17:13:59 +00:00
parent d619f20818
commit 2df8675fa8
33 changed files with 1991 additions and 1144 deletions

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# Makefile.in generated by automake 1.7.6 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
@ -84,6 +84,8 @@ KDE_ICON = @KDE_ICON@
KDE_TRUE = @KDE_TRUE@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBPNG_FALSE = @LIBPNG_FALSE@
LIBPNG_TRUE = @LIBPNG_TRUE@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
@ -97,6 +99,9 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PNG_CFLAGS = @PNG_CFLAGS@
PNG_CONFIG = @PNG_CONFIG@
PNG_LIBS = @PNG_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_IMAGE_LIBS = @SDL_IMAGE_LIBS@
@ -175,10 +180,10 @@ RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive
DIST_COMMON = README $(dist_man6_MANS) $(dist_noinst_DATA) \
$(nobase_dist_pkgdata_DATA) $(srcdir)/Makefile.in \
$(srcdir)/configure COPYING INSTALL Makefile.am aclocal.m4 \
config.h.in config/depcomp config/install-sh config/missing \
config/mkinstalldirs configure configure.ac
$(nobase_dist_pkgdata_DATA) COPYING INSTALL Makefile.am \
Makefile.in aclocal.m4 config.h.in config/depcomp \
config/install-sh config/missing config/mkinstalldirs configure \
configure.ac
DIST_SUBDIRS = $(SUBDIRS)
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@ -551,7 +556,7 @@ install-am: all-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
@ -559,7 +564,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -570,7 +575,6 @@ clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
dvi: dvi-recursive
@ -594,7 +598,6 @@ installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive

4
aclocal.m4 vendored
View file

@ -1,4 +1,4 @@
# generated automatically by aclocal 1.7.9 -*- Autoconf -*-
# generated automatically by aclocal 1.7.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
@ -163,7 +163,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.7.9])])
[AM_AUTOMAKE_VERSION([1.7.6])])
# Helper functions for option handling. -*- Autoconf -*-

View file

@ -98,11 +98,9 @@
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
if it is not supported. */
#undef inline
#endif
/* Define to `int' if <sys/types.h> does not define. */
#undef mode_t

1582
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,33 @@
{tools/exploder/models/castle.cfg}
[part]
name=castle-concave-nw
pos=36,36
[/part]
[part]
name=castle-concave-ne
pos=72,36
[/part]
[part]
name=castle-concave-e
pos=90,72
[/part]
[part]
name=castle-concave-se
pos=72,108
[/part]
[part]
name=castle-concave-sw
pos=36,108
[/part]
[part]
name=castle-concave-w
pos=18,72
[/part]

View file

@ -0,0 +1,33 @@
{tools/exploder/models/castle.cfg}
[part]
name=castle-convex-nw
pos=36,36
[/part]
[part]
name=castle-convex-ne
pos=72,36
[/part]
[part]
name=castle-convex-e
pos=90,72
[/part]
[part]
name=castle-convex-se
pos=72,108
[/part]
[part]
name=castle-convex-sw
pos=36,108
[/part]
[part]
name=castle-convex-w
pos=18,72
[/part]

View file

@ -0,0 +1,208 @@
{tools/exploder/models/castle.cfg}
# *
# _
# _/ \_
# / \
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-concave-nw
pos=90,36
[/part]
[part]
name=castle-concave-ne
pos=126,36
[/part]
#
# _
# _/ \_
# / \ *
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-concave-ne
pos=180,72
[/part]
[part]
name=castle-concave-e
pos=198,108
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# \_ _/ *
# \_/
#
[part]
name=castle-concave-e
pos=198,180
[/part]
[part]
name=castle-concave-se
pos=180,216
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# \_ _/
# \_/
# *
[part]
name=castle-concave-se
pos=126,252
[/part]
[part]
name=castle-concave-sw
pos=90,252
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# * \_ _/
# \_/
#
[part]
name=castle-concave-sw
pos=36,216
[/part]
[part]
name=castle-concave-w
pos=18,180
[/part]
#
# _
# _/ \_
# * / \
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-concave-w
pos=18,108
[/part]
[part]
name=castle-concave-nw
pos=36,72
[/part]
#
# _
# _/ \_
# / * \
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-convex-sw
pos=144,72
[/part]
#
# _
# _/ \_
# / \
# \ /
# / *\
# \_ _/
# \_/
#
[part]
name=castle-convex-w
pos=180,144
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# \_ *_/
# \_/
#
[part]
name=castle-convex-nw
pos=144,216
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# \_* _/
# \_/
#
[part]
name=castle-convex-ne
pos=72,216
[/part]
#
# _
# _/ \_
# / \
# \ /
# /* \
# \_ _/
# \_/
#
[part]
name=castle-convex-e
pos=36,144
[/part]
#
# _
# _/ \_
# / * \
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-convex-se
pos=72,72
[/part]

View file

@ -0,0 +1,208 @@
{tools/exploder/models/castle.cfg}
# *
# _
# _/ \_
# / \
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-convex-nw
pos=90,36
[/part]
[part]
name=castle-convex-ne
pos=126,36
[/part]
#
# _
# _/ \_
# / \ *
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-convex-ne
pos=180,72
[/part]
[part]
name=castle-convex-e
pos=198,108
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# \_ _/ *
# \_/
#
[part]
name=castle-convex-e
pos=198,180
[/part]
[part]
name=castle-convex-se
pos=180,216
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# \_ _/
# \_/
# *
[part]
name=castle-convex-se
pos=126,252
[/part]
[part]
name=castle-convex-sw
pos=90,252
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# * \_ _/
# \_/
#
[part]
name=castle-convex-sw
pos=36,216
[/part]
[part]
name=castle-convex-w
pos=18,180
[/part]
#
# _
# _/ \_
# * / \
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-convex-w
pos=18,108
[/part]
[part]
name=castle-convex-nw
pos=36,72
[/part]
#
# _
# _/ \_
# / * \
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-concave-sw
pos=144,72
[/part]
#
# _
# _/ \_
# / \
# \ /
# / *\
# \_ _/
# \_/
#
[part]
name=castle-concave-w
pos=180,144
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# \_ *_/
# \_/
#
[part]
name=castle-concave-nw
pos=144,216
[/part]
#
# _
# _/ \_
# / \
# \ /
# / \
# \_* _/
# \_/
#
[part]
name=castle-concave-ne
pos=72,216
[/part]
#
# _
# _/ \_
# / \
# \ /
# /* \
# \_ _/
# \_/
#
[part]
name=castle-concave-e
pos=36,144
[/part]
#
# _
# _/ \_
# / * \
# \ /
# / \
# \_ _/
# \_/
#
[part]
name=castle-concave-se
pos=72,72
[/part]

View file

@ -0,0 +1,78 @@
# Convex castle images
[mask]
name=castle-convex-ne
image=mask-castle-ne.png
shift=-18,-45
[/mask]
[mask]
name=castle-convex-e
image=mask-castle-e.png
shift=-36,-24
[/mask]
[mask]
name=castle-convex-se
image=mask-castle-se.png
shift=-18,-24
[/mask]
[mask]
name=castle-convex-sw
image=mask-castle-sw.png
shift=-36,-24
[/mask]
[mask]
name=castle-convex-w
image=mask-castle-w.png
shift=-18,-24
[/mask]
[mask]
name=castle-convex-nw
image=mask-castle-nw.png
shift=-36,-45
[/mask]
# Concave castle images
[mask]
name=castle-concave-ne
image=mask-castle-ne.png
shift=-18,-45
[/mask]
[mask]
name=castle-concave-e
image=mask-castle-e.png
shift=-36,-24
[/mask]
[mask]
name=castle-concave-se
image=mask-castle-se.png
shift=-18,-24
[/mask]
[mask]
name=castle-concave-sw
image=mask-castle-sw.png
shift=-36,-24
[/mask]
[mask]
name=castle-concave-w
image=mask-castle-w.png
shift=-18,-24
[/mask]
[mask]
name=castle-concave-nw
image=mask-castle-nw.png
shift=-36,-45
[/mask]

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# Makefile.in generated by automake 1.7.6 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
@ -84,6 +84,8 @@ KDE_ICON = @KDE_ICON@
KDE_TRUE = @KDE_TRUE@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBPNG_FALSE = @LIBPNG_FALSE@
LIBPNG_TRUE = @LIBPNG_TRUE@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
@ -97,6 +99,9 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PNG_CFLAGS = @PNG_CFLAGS@
PNG_CONFIG = @PNG_CONFIG@
PNG_LIBS = @PNG_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_IMAGE_LIBS = @SDL_IMAGE_LIBS@
@ -174,7 +179,7 @@ DATA = $(dist_gnome1desktop_DATA) $(dist_gnome2desktop_DATA) \
$(kdeicon_DATA)
DIST_COMMON = $(dist_gnome1desktop_DATA) $(dist_gnome2desktop_DATA) \
$(dist_kdedesktop_DATA) $(srcdir)/Makefile.in Makefile.am
$(dist_kdedesktop_DATA) Makefile.am Makefile.in
all: all-am
.SUFFIXES:
@ -347,7 +352,7 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
@ -355,7 +360,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -365,7 +370,7 @@ clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
@ -390,7 +395,7 @@ install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# Makefile.in generated by automake 1.7.6 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
@ -95,6 +95,8 @@ KDE_ICON = @KDE_ICON@
KDE_TRUE = @KDE_TRUE@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBPNG_FALSE = @LIBPNG_FALSE@
LIBPNG_TRUE = @LIBPNG_TRUE@
LIBS = @LIBS@ $(am__append_6)
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
@ -108,6 +110,9 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PNG_CFLAGS = @PNG_CFLAGS@
PNG_CONFIG = @PNG_CONFIG@
PNG_LIBS = @PNG_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_IMAGE_LIBS = @SDL_IMAGE_LIBS@
@ -571,7 +576,7 @@ RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
DIST_COMMON = Makefile.am Makefile.in configure configure.ac
DIST_SUBDIRS = . server tools zip
SOURCES = $(wesnoth_SOURCES) $(wesnoth_editor_SOURCES)
@ -695,6 +700,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/widget.Po@am__quote@
distclean-depend:
-rm -rf ./$(DEPDIR)
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
@ -1256,7 +1264,7 @@ install-am: all-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
@ -1264,7 +1272,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -1274,10 +1282,9 @@ clean: clean-recursive
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
distclean-am: clean-am distclean-compile distclean-depend \
distclean-generic distclean-tags
dvi: dvi-recursive
@ -1298,8 +1305,7 @@ install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
@ -1320,10 +1326,10 @@ uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
clean-binPROGRAMS clean-generic clean-recursive ctags \
ctags-recursive distclean distclean-compile distclean-generic \
distclean-recursive distclean-tags distdir dvi dvi-am \
dvi-recursive info info-am info-recursive install install-am \
install-binPROGRAMS install-data install-data-am \
ctags-recursive distclean distclean-compile distclean-depend \
distclean-generic distclean-recursive distclean-tags distdir \
dvi dvi-am dvi-recursive info info-am info-recursive install \
install-am install-binPROGRAMS install-data install-data-am \
install-data-recursive install-exec install-exec-am \
install-exec-recursive install-info install-info-am \
install-info-recursive install-man install-recursive \

View file

@ -64,10 +64,12 @@ line_source get_line_source(const std::vector<line_source>& line_src, int line)
return res;
}
#if 0
struct close_FILE
{
void operator()(FILE* f) const { if(f != NULL) { fclose(f); } }
};
#endif
void read_file_internal(const std::string& fname, std::string& res)
{
@ -79,7 +81,9 @@ void read_file_internal(const std::string& fname, std::string& res)
std::vector<char> v;
v.reserve(size);
const util::scoped_resource<FILE*,close_FILE> file(fopen(fname.c_str(),"rb"));
//const util::scoped_resource<FILE*,close_FILE> file(fopen(fname.c_str(),"rb"));
const util::scoped_FILE file(fopen(fname.c_str(),"rb"));
if(file == NULL) {
return;
}
@ -150,7 +154,8 @@ std::string read_file(const std::string& fname)
//throws io_exception if an error occurs
void write_file(const std::string& fname, const std::string& data)
{
const util::scoped_resource<FILE*,close_FILE> file(fopen(fname.c_str(),"wb"));
//const util::scoped_resource<FILE*,close_FILE> file(fopen(fname.c_str(),"wb"));
const util::scoped_FILE file(fopen(fname.c_str(),"wb"));
if(file.get() == NULL) {
throw io_exception("Could not open file for writing: '" + fname + "'");
}

View file

@ -347,6 +347,24 @@ int file_size(const std::string& fname)
return buf.st_size;
}
std::string file_name(const std::string& file)
{
#ifdef _WIN32
static const std::string dir_separators = "\\/:";
#else
static const std::string dir_separators = "/";
#endif
std::string::size_type pos = file.find_last_of(dir_separators);
if(pos == std::string::npos)
return file;
if(pos == file.size())
return "";
return file.substr(pos+1);
}
namespace {
std::set<std::string> binary_paths;
@ -422,4 +440,5 @@ std::string get_binary_file_location(const std::string& type, const std::string&
}
return "";
}
}

View file

@ -60,6 +60,10 @@ time_t data_tree_modified_time();
//returns the size of a file, or -1 if the file doesn't exist
int file_size(const std::string& fname);
//returns the base filename of a file, with directory name stripped. Equivalent
//to a portable basename() function
std::string file_name(const std::string& file);
///the paths manager is responsible for recording the various paths that
///binary files may be located at. It should be passed a config object
///which holds binary path information. This is in the format

View file

@ -171,6 +171,16 @@ struct scoped_array : public scoped_resource<T*,delete_array>
explicit scoped_array(T* p) : scoped_resource<T*,delete_array>(p) {}
};
/**
* This class specializes the scoped_resource to implement scoped FILEs. Not
* sure this is the best place to place such an utility, though.
*/
struct close_FILE
{
void operator()(FILE* f) const { if(f != NULL) { fclose(f); } }
};
typedef scoped_resource<FILE*,close_FILE> scoped_FILE;
}
#endif

View file

@ -269,7 +269,16 @@ SDL_Surface* greyscale_image(SDL_Surface* surface)
Uint8 red, green, blue, alpha;
SDL_GetRGBA(*beg,surf->format,&red,&green,&blue,&alpha);
const Uint8 avg = (red+green+blue)/3;
//const Uint8 avg = (red+green+blue)/3;
//use the correct formula for RGB to grayscale
//conversion. ok, this is no big deal :)
//the correct formula being:
//gray=0.299red+0.587green+0.114blue
const Uint8 avg = (Uint8)((77*(Uint16)red +
150*(Uint16)green +
29*(Uint16)blue) / 256);
*beg = SDL_MapRGBA(surf->format,avg,avg,avg,alpha);
@ -388,7 +397,7 @@ SDL_Surface* mask_surface(SDL_Surface* surface, SDL_Surface* mask)
return NULL;
}
scoped_sdl_surface surf(make_neutral_surface(surface));
SDL_Surface* surf(make_neutral_surface(surface));
scoped_sdl_surface nmask(make_neutral_surface(mask));
if(surf == NULL || nmask == NULL) {
@ -421,7 +430,8 @@ SDL_Surface* mask_surface(SDL_Surface* surface, SDL_Surface* mask)
}
}
return clone_surface(surf);
return surf;
//return clone_surface(surf);
}
// Cuts a rectangle from a surface.

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# Makefile.in generated by automake 1.7.6 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
@ -84,6 +84,8 @@ KDE_ICON = @KDE_ICON@
KDE_TRUE = @KDE_TRUE@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBPNG_FALSE = @LIBPNG_FALSE@
LIBPNG_TRUE = @LIBPNG_TRUE@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
@ -97,6 +99,9 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PNG_CFLAGS = @PNG_CFLAGS@
PNG_CONFIG = @PNG_CONFIG@
PNG_LIBS = @PNG_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_IMAGE_LIBS = @SDL_IMAGE_LIBS@
@ -208,7 +213,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(wesnothd_SOURCES)
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
DIST_COMMON = Makefile.am Makefile.in
SOURCES = $(wesnothd_SOURCES)
all: all-am
@ -264,6 +269,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/variable.Po@am__quote@
distclean-depend:
-rm -rf ./$(DEPDIR)
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
@ -499,7 +507,7 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
@ -507,7 +515,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -517,10 +525,9 @@ clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
distclean-am: clean-am distclean-compile distclean-depend \
distclean-generic distclean-tags
dvi: dvi-am
@ -541,8 +548,7 @@ install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
@ -561,11 +567,11 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am info \
info-am install install-am install-binPROGRAMS install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
distclean-depend distclean-generic distclean-tags distdir dvi \
dvi-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-man install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-info-am

View file

@ -1,12 +1,21 @@
bin_PROGRAMS = make_translation merge_translations
bin_PROGRAMS = make_translation merge_translations
if LIBPNG
bin_PROGRAMS += exploder
endif
#############################################################################
# Translation Tools #
#############################################################################
AM_CXXFLAGS = @SDL_CFLAGS@ -I../
AM_CXXFLAGS = @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" -I../
AM_LDFLAGS = @SDL_LIBS@
if LIBPNG
AM_CXXFLAGS += @PNG_CFLAGS@
endif
#############################################################################
# Make Translation #
#############################################################################
@ -37,3 +46,26 @@ merge_translations_SOURCES = merge_translations.cpp \
../filesystem.hpp \
../game_config.hpp \
../log.hpp
#############################################################################
# Exploder tool
#############################################################################
if LIBPNG
exploder_SOURCES = exploder.cpp \
exploder_utils.cpp \
exploder_cutter.cpp \
exploder_composer.cpp \
../config.cpp \
../filesystem.cpp \
../game_config.cpp \
../sdl_utils.cpp \
../log.cpp \
../server/variable.cpp \
dummy_video.cpp
exploder_LDFLAGS = @SDL_LIBS@ @SDL_IMAGE_LIBS@ @PNG_LIBS@
endif

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# Makefile.in generated by automake 1.7.6 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
@ -35,6 +35,7 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
@LIBPNG_TRUE@am__append_1 = exploder
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
@ -84,6 +85,8 @@ KDE_ICON = @KDE_ICON@
KDE_TRUE = @KDE_TRUE@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBPNG_FALSE = @LIBPNG_FALSE@
LIBPNG_TRUE = @LIBPNG_TRUE@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
@ -97,6 +100,9 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PNG_CFLAGS = @PNG_CFLAGS@
PNG_CONFIG = @PNG_CONFIG@
PNG_LIBS = @PNG_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_IMAGE_LIBS = @SDL_IMAGE_LIBS@
@ -147,13 +153,14 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
bin_PROGRAMS = make_translation merge_translations
bin_PROGRAMS = make_translation merge_translations $(am__append_1)
#############################################################################
# Translation Tools #
#############################################################################
AM_CXXFLAGS = @SDL_CFLAGS@ -I../
AM_CXXFLAGS = @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" -I../
AM_LDFLAGS = @SDL_LIBS@
@ -187,14 +194,49 @@ merge_translations_SOURCES = merge_translations.cpp \
../game_config.hpp \
../log.hpp
#############################################################################
# Exploder tool
#############################################################################
@LIBPNG_TRUE@exploder_SOURCES = exploder.cpp \
@LIBPNG_TRUE@ exploder_utils.cpp \
@LIBPNG_TRUE@ exploder_cutter.cpp \
@LIBPNG_TRUE@ exploder_composer.cpp \
@LIBPNG_TRUE@ ../config.cpp \
@LIBPNG_TRUE@ ../filesystem.cpp \
@LIBPNG_TRUE@ ../game_config.cpp \
@LIBPNG_TRUE@ ../sdl_utils.cpp \
@LIBPNG_TRUE@ ../log.cpp \
@LIBPNG_TRUE@ ../server/variable.cpp \
@LIBPNG_TRUE@ dummy_video.cpp
@LIBPNG_TRUE@exploder_LDFLAGS = @SDL_LIBS@ @SDL_IMAGE_LIBS@ @PNG_LIBS@
subdir = src/tools
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
bin_PROGRAMS = make_translation$(EXEEXT) merge_translations$(EXEEXT)
@LIBPNG_TRUE@bin_PROGRAMS = make_translation$(EXEEXT) \
@LIBPNG_TRUE@ merge_translations$(EXEEXT) exploder$(EXEEXT)
@LIBPNG_FALSE@bin_PROGRAMS = make_translation$(EXEEXT) \
@LIBPNG_FALSE@ merge_translations$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS)
am__exploder_SOURCES_DIST = exploder.cpp exploder_utils.cpp \
exploder_cutter.cpp exploder_composer.cpp ../config.cpp \
../filesystem.cpp ../game_config.cpp ../sdl_utils.cpp \
../log.cpp ../server/variable.cpp dummy_video.cpp
@LIBPNG_TRUE@am_exploder_OBJECTS = exploder.$(OBJEXT) \
@LIBPNG_TRUE@ exploder_utils.$(OBJEXT) exploder_cutter.$(OBJEXT) \
@LIBPNG_TRUE@ exploder_composer.$(OBJEXT) config.$(OBJEXT) \
@LIBPNG_TRUE@ filesystem.$(OBJEXT) game_config.$(OBJEXT) \
@LIBPNG_TRUE@ sdl_utils.$(OBJEXT) log.$(OBJEXT) \
@LIBPNG_TRUE@ variable.$(OBJEXT) dummy_video.$(OBJEXT)
exploder_OBJECTS = $(am_exploder_OBJECTS)
exploder_LDADD = $(LDADD)
exploder_DEPENDENCIES =
am_make_translation_OBJECTS = make_translation.$(OBJEXT) \
config.$(OBJEXT) filesystem.$(OBJEXT) game_config.$(OBJEXT) \
log.$(OBJEXT) variable.$(OBJEXT)
@ -213,11 +255,16 @@ merge_translations_LDFLAGS =
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/config.Po ./$(DEPDIR)/filesystem.Po \
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/config.Po ./$(DEPDIR)/dummy_video.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/exploder.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/exploder_composer.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/exploder_cutter.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/exploder_utils.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/filesystem.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/game_config.Po ./$(DEPDIR)/log.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/make_translation.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/merge_translations.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/variable.Po
@AMDEP_TRUE@ ./$(DEPDIR)/sdl_utils.Po ./$(DEPDIR)/variable.Po
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
@ -227,9 +274,10 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(make_translation_SOURCES) $(merge_translations_SOURCES)
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
SOURCES = $(make_translation_SOURCES) $(merge_translations_SOURCES)
DIST_SOURCES = $(am__exploder_SOURCES_DIST) $(make_translation_SOURCES) \
$(merge_translations_SOURCES)
DIST_COMMON = Makefile.am Makefile.in
SOURCES = $(exploder_SOURCES) $(make_translation_SOURCES) $(merge_translations_SOURCES)
all: all-am
@ -264,6 +312,9 @@ uninstall-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
exploder$(EXEEXT): $(exploder_OBJECTS) $(exploder_DEPENDENCIES)
@rm -f exploder$(EXEEXT)
$(CXXLINK) $(exploder_LDFLAGS) $(exploder_OBJECTS) $(exploder_LDADD) $(LIBS)
make_translation$(EXEEXT): $(make_translation_OBJECTS) $(make_translation_DEPENDENCIES)
@rm -f make_translation$(EXEEXT)
$(CXXLINK) $(make_translation_LDFLAGS) $(make_translation_OBJECTS) $(make_translation_LDADD) $(LIBS)
@ -278,13 +329,22 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy_video.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exploder.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exploder_composer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exploder_cutter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exploder_utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filesystem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game_config.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/make_translation.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/merge_translations.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdl_utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/variable.Po@am__quote@
distclean-depend:
-rm -rf ./$(DEPDIR)
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
@ -373,6 +433,28 @@ game_config.obj: ../game_config.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o game_config.obj `if test -f '../game_config.cpp'; then $(CYGPATH_W) '../game_config.cpp'; else $(CYGPATH_W) '$(srcdir)/../game_config.cpp'; fi`
sdl_utils.o: ../sdl_utils.cpp
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sdl_utils.o -MD -MP -MF "$(DEPDIR)/sdl_utils.Tpo" \
@am__fastdepCXX_TRUE@ -c -o sdl_utils.o `test -f '../sdl_utils.cpp' || echo '$(srcdir)/'`../sdl_utils.cpp; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/sdl_utils.Tpo" "$(DEPDIR)/sdl_utils.Po"; \
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/sdl_utils.Tpo"; exit 1; \
@am__fastdepCXX_TRUE@ fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../sdl_utils.cpp' object='sdl_utils.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/sdl_utils.Po' tmpdepfile='$(DEPDIR)/sdl_utils.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sdl_utils.o `test -f '../sdl_utils.cpp' || echo '$(srcdir)/'`../sdl_utils.cpp
sdl_utils.obj: ../sdl_utils.cpp
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sdl_utils.obj -MD -MP -MF "$(DEPDIR)/sdl_utils.Tpo" \
@am__fastdepCXX_TRUE@ -c -o sdl_utils.obj `if test -f '../sdl_utils.cpp'; then $(CYGPATH_W) '../sdl_utils.cpp'; else $(CYGPATH_W) '$(srcdir)/../sdl_utils.cpp'; fi`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/sdl_utils.Tpo" "$(DEPDIR)/sdl_utils.Po"; \
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/sdl_utils.Tpo"; exit 1; \
@am__fastdepCXX_TRUE@ fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../sdl_utils.cpp' object='sdl_utils.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/sdl_utils.Po' tmpdepfile='$(DEPDIR)/sdl_utils.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sdl_utils.obj `if test -f '../sdl_utils.cpp'; then $(CYGPATH_W) '../sdl_utils.cpp'; else $(CYGPATH_W) '$(srcdir)/../sdl_utils.cpp'; fi`
log.o: ../log.cpp
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT log.o -MD -MP -MF "$(DEPDIR)/log.Tpo" \
@am__fastdepCXX_TRUE@ -c -o log.o `test -f '../log.cpp' || echo '$(srcdir)/'`../log.cpp; \
@ -520,7 +602,7 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
@ -528,7 +610,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -538,10 +620,9 @@ clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
distclean-am: clean-am distclean-compile distclean-depend \
distclean-generic distclean-tags
dvi: dvi-am
@ -562,8 +643,7 @@ install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
@ -582,15 +662,17 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am info \
info-am install install-am install-binPROGRAMS install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
distclean-depend distclean-generic distclean-tags distdir dvi \
dvi-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-man install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-info-am
@LIBPNG_TRUE@ AM_CXXFLAGS += @PNG_CFLAGS@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -0,0 +1,91 @@
/* $Id$ */
/*
Copyright (C) 2004 by Philippe Plantier <ayin@anathas.org>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#include "exploder_composer.hpp"
#include "SDL_image.h"
composer::composer() : interactive_(false), verbose_(false)
{
}
shared_sdl_surface composer::compose(const std::string &src, const std::string &dest)
{
cutter cut;
cut.set_verbose(verbose_);
const config src_conf = cut.load_config(src);
const config dest_conf = cut.load_config(dest);
if(verbose_) {
std::cerr << "Loading masks...\n";
}
cut.load_masks(src_conf);
cut.load_masks(dest_conf);
if(verbose_) {
std::cerr << "Loading images...\n";
}
const shared_sdl_surface src_surface(make_neutral_surface(IMG_Load(src.c_str())));
if(src_surface == NULL)
throw exploder_failure("Unable to load the source image " + src);
const shared_sdl_surface dest_surface(make_neutral_surface(IMG_Load(dest.c_str())));
if(dest_surface == NULL)
throw exploder_failure("Unable to load the destination image " + dest);
if(verbose_) {
std::cerr << "Cutting images...\n";
}
const cutter::surface_map src_surfaces = cut.cut_surface(src_surface, src_conf);
const cutter::surface_map dest_surfaces = cut.cut_surface(dest_surface, dest_conf);
for(cutter::surface_map::const_iterator itor = dest_surfaces.begin();
itor != dest_surfaces.end(); ++itor) {
const std::string& name = itor->second.name;
if(src_surfaces.find(name) == src_surfaces.end())
continue;
const cutter::positioned_surface& src_ps = src_surfaces.find(name)->second;
const cutter::positioned_surface& dest_ps = itor->second;
if(!image_empty(dest_ps.image)) {
if(interactive_) {
//TODO: make "interactive" mode work
} else {
std::cerr << "Warning: element " << name << " not empty on destination image\n";
}
}
if(verbose_) {
std::cerr << "Inserting image " << name << " on position (" << dest_ps.x <<
", " << dest_ps.y << ")\n";
}
masked_overwrite_surface(dest_surface, src_ps.image, src_ps.mask.image,
dest_ps.x, dest_ps.y);
}
return dest_surface;
}
void composer::set_interactive(bool value)
{
interactive_ = value;
}
void composer::set_verbose(bool value)
{
verbose_ = value;
}

View file

@ -0,0 +1,35 @@
/* $Id$ */
/*
Copyright (C) 2004 by Philippe Plantier <ayin@anathas.org>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef EXPLODER_COMPOSER_HPP_INCLUDED
#define EXPLODER_COMPOSER_HPP_INCLUDED
#include "exploder_utils.hpp"
#include "exploder_cutter.hpp"
class composer
{
public:
composer();
shared_sdl_surface compose(const std::string &src, const std::string &dest);
void set_interactive(bool value);
void set_verbose(bool value);
private:
bool interactive_;
bool verbose_;
};
#endif

View file

@ -0,0 +1,174 @@
/* $Id$ */
/*
Copyright (C) 2004 by Philippe Plantier <ayin@anathas.org>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#include "exploder_cutter.hpp"
#include "../filesystem.hpp"
#include "../sdl_utils.hpp"
#include "SDL_image.h"
cutter::cutter() : verbose_(false)
{
}
const config cutter::load_config(const std::string &filename)
{
const std::string conf_string = find_configuration(filename);
const std::string pre_conf_string = preprocess_file(conf_string);
config res;
try {
res.read(pre_conf_string);
} catch(config::error err) {
throw exploder_failure("Unable to load the configuration for the file " + filename + ": "+ err.message);
}
return res;
}
void cutter::load_masks(const config& conf)
{
const config::child_list& masks = conf.get_children("mask");
for(config::child_list::const_iterator itor = masks.begin();
itor != masks.end(); ++itor) {
const std::string name = (**itor)["name"];
const std::string image = get_mask_dir() + "/" + (**itor)["image"];
if(verbose_) {
std::cerr << "Adding mask " << name << "\n";
}
if(image.empty())
throw exploder_failure("Missing image for mask " + name);
int shiftx = 0;
int shifty = 0;
if(!((**itor)["shift"]).empty()) {
std::vector<std::string> shift = config::split((**itor)["shift"]);
if(shift.size() != 2)
throw exploder_failure("Invalid shift " + (**itor)["shift"]);
shiftx = atoi(shift[0].c_str());
shifty = atoi(shift[1].c_str());
}
if(masks_.find(name) != masks_.end() && masks_[name].filename != image) {
throw exploder_failure("Mask " + name +
" correspond to two different files: " +
name + " and " +
masks_.find(name)->second.filename);
}
if(masks_.find(name) == masks_.end()) {
mask& cur_mask = masks_[name];
cur_mask.filename = image;
scoped_sdl_surface tmp(IMG_Load(image.c_str()));
if(tmp == NULL)
throw exploder_failure("Unable to load mask image " + image);
cur_mask.image = shared_sdl_surface(make_neutral_surface(tmp));
cur_mask.shiftx = shiftx;
cur_mask.shifty = shifty;
}
if(masks_[name].image == NULL)
throw exploder_failure("Unable to load mask image " + image);
}
}
cutter::surface_map cutter::cut_surface(shared_sdl_surface surf, const config& conf)
{
surface_map res;
const config::child_list& config_parts = conf.get_children("part");
config::child_list::const_iterator itor;
for(itor = config_parts.begin(); itor != config_parts.end(); ++itor) {
add_sub_image(surf, res, *itor);
}
return res;
}
std::string cutter::find_configuration(const std::string &file)
{
//finds the file prefix.
const std::string fname = file_name(file);
const std::string::size_type dotpos = fname.rfind('.');
int underscorepos = fname.find('_');
//sets "underscore pos" to -1 if there is no underscore.
if(underscorepos == std::string::npos || underscorepos == file.size())
underscorepos = -1;
std::string basename;
if(dotpos == std::string::npos || dotpos < underscorepos) {
basename = file.substr(underscorepos + 1);
} else {
basename = file.substr(underscorepos + 1, dotpos - underscorepos - 1);
}
return get_exploder_dir() + "/" + basename + ".cfg";
}
void cutter::add_sub_image(const shared_sdl_surface &surf, surface_map &map, const config* config)
{
const std::string name = (*config)["name"];
if(name.empty())
throw exploder_failure("Un-named sub-image");
if(masks_.find(name) == masks_.end())
throw exploder_failure("Unable to find mask corresponding to " + name);
const cutter::mask& mask = masks_[name];
std::vector<std::string> pos = config::split((*config)["pos"]);
if(pos.size() != 2)
throw exploder_failure("Invalid position " + (*config)["pos"]);
int x = atoi(pos[0].c_str());
int y = atoi(pos[1].c_str());
const SDL_Rect cut = {x + mask.shiftx, y + mask.shifty, mask.image->w, mask.image->h};
typedef std::pair<std::string, positioned_surface> sme;
positioned_surface ps;
ps.image = shared_sdl_surface(::cut_surface(surf, cut));
if(ps.image == NULL)
throw exploder_failure("Unable to cut surface!");
ps.name = name;
ps.mask = mask;
ps.x = x + mask.shiftx;
ps.y = y + mask.shifty;
map.insert(sme(name, ps));
if(verbose_) {
std::cerr << "Extracting sub-image " << name << ", position (" << x << ", " << y << ")\n";
}
}
void cutter::set_verbose(bool value)
{
verbose_ = value;
}

View file

@ -0,0 +1,65 @@
/* $Id$ */
/*
Copyright (C) 2004 by Philippe Plantier <ayin@anathas.org>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef EXPLODER_CUTTER_HPP_INCLUDED
#define EXPLODER_CUTTER_HPP_INCLUDED
#include "../sdl_utils.hpp"
#include "../config.hpp"
#include "../sdl_utils.hpp"
#include "exploder_utils.hpp"
class cutter
{
public:
struct mask
{
mask() : image(NULL) {}
std::string name;
shared_sdl_surface image;
std::string filename;
int shiftx;
int shifty;
};
typedef std::map<std::string, mask> mask_map;
struct positioned_surface {
positioned_surface() : image(NULL) {};
std::string name;
int x;
int y;
shared_sdl_surface image;
cutter::mask mask;
};
typedef std::multimap<std::string, positioned_surface> surface_map;
cutter();
const config load_config(const std::string& filename);
void load_masks(const config& conf);
surface_map cut_surface(shared_sdl_surface surf, const config& conf);
void set_verbose(bool value);
private:
std::string find_configuration(const std::string &file);
void add_sub_image(const shared_sdl_surface &surf, surface_map &map, const config* config);
mask_map masks_;
bool verbose_;
};
#endif

View file

@ -0,0 +1,216 @@
/* $Id$ */
/*
Copyright (C) 2004 by Philippe Plantier <ayin@anathas.org>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#include "exploder_utils.hpp"
#include "../game_config.hpp"
#include <png.h>
std::string get_mask_dir()
{
// return ".";
return game_config::path + "/images/tools/exploder";
}
std::string get_exploder_dir()
{
return game_config::path + "/data/tools/exploder";
}
//on pixels where mask is not white, overwrite dest with src. Mask and dest are
//translated to the position (x,y) on dest.
//All surfaces are supposed to be neutral surfaces, mask and src are supposed
//to be of identical size.
void masked_overwrite_surface(SDL_Surface* dest, SDL_Surface* src, SDL_Surface* mask, int x, int y)
{
surface_lock dest_lock(dest);
surface_lock src_lock(src);
surface_lock mask_lock(mask);
Uint32* dest_beg = dest_lock.pixels();
Uint32* dest_end = dest_beg + dest->w*dest->h;
Uint32* src_beg = src_lock.pixels();
Uint32* src_end = src_beg + src->w*src->h;
Uint32* mask_beg = mask_lock.pixels();
Uint32* mask_end = mask_beg + mask->w*mask->h;
size_t small_shift_before;
size_t small_shift_after;
size_t dest_shift;
size_t src_width = src->w;
size_t src_height = src->h;
if(x < 0) {
src_width += x;
small_shift_before = -x;
x = 0;
} else {
small_shift_before = 0;
}
if(src_width < 0)
return;
if(x + src_width <= dest->w) {
small_shift_after = 0;
} else {
small_shift_after = src_width - (dest->w - x);
src_width = dest->w - x;
}
if(src_width < 0)
return;
if(y >= 0) {
dest_beg += dest->w * y + x;
} else {
src_beg += (-y) * src->w;
mask_beg += (-y) * mask->w;
dest_beg += x;
src_height += y;
y = 0;
}
if(src_height < 0)
return;
if(y + src_height > dest->h) {
src_height = dest->h - y;
}
dest_shift = dest->w - src_width;
for(int j = 0; j < src_height; ++j) {
src_beg += small_shift_before;
mask_beg += small_shift_before;
for(int i = 0; i < src_width; ++i) {
//Assuming here alpha mask is 0xff000000
if((*mask_beg & 0x00ffffff) != 0x00ffffff) {
*dest_beg = *src_beg;
}
++dest_beg;
++src_beg;
++mask_beg;
}
src_beg += small_shift_after;
mask_beg += small_shift_after;
dest_beg += dest_shift;
}
}
//returns true if the image is empty. the surface surf is considered to be a
//neutral surface.
bool image_empty(SDL_Surface* surf)
{
//an image is considered empty if
// * all its pixels have 0 alpha, OR
// * all of its pixels have the same color (and the same alpha)
surface_lock lock(surf);
Uint32* beg = lock.pixels();
Uint32* end = beg + surf->w*surf->h;
Uint32 colour = *beg;
while(beg != end) {
if((*beg & 0xff000000) != 0 && (*beg != colour))
return false;
++beg;
}
return true;
}
namespace {
struct rgba {
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 a;
};
}
//saves the given SDL structure into a given filename.
void save_image(SDL_Surface *surf, const std::string &filename)
{
//opens the actual file
const util::scoped_FILE file(fopen(filename.c_str(),"wb"));
//initializes PNG write structures
//TODO: review whether providing NULL error handlers is something
//sensible
png_struct* png_ptr = png_create_write_struct
(PNG_LIBPNG_VER_STRING, (png_voidp)png_voidp_NULL,
png_error_ptr_NULL, png_error_ptr_NULL);
if(!png_ptr)
throw exploder_failure("Unable to initialize the png write structure");
png_info* info_ptr = png_create_info_struct(png_ptr);
if(!info_ptr) {
png_destroy_write_struct(&png_ptr,
(png_infopp)NULL);
throw exploder_failure("Unable to initialize the png info structure");
}
//instructs the PNG library to use the open file
png_init_io(png_ptr, file);
//sets compression level to the maximum
png_set_compression_level(png_ptr,
Z_BEST_COMPRESSION);
//configures the header
png_set_IHDR(png_ptr, info_ptr, surf->w, surf->h,
8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
//puts the actual image data in the row_pointers array
png_byte *row_pointers[surf->h];
surface_lock lock(surf);
//converts the data to the RGBA format. We cannot pass SDL data
//directly to the png lib, even if we know its pixel format, because of
//endianness problems.
util::scoped_array<rgba> rgba_data(new rgba[surf->w * surf->h]);
Uint32 *surf_data = lock.pixels();
int pos = 0;
for(int y = 0; y < surf->h; ++y) {
row_pointers[y] = (png_byte*) (rgba_data + pos);
for(int x = 0; x < surf->w; ++x) {
Uint8 red, green, blue, alpha;
SDL_GetRGBA(*surf_data, surf->format, &red, &green, &blue, &alpha);
rgba_data[pos].r = red;
rgba_data[pos].g = green;
rgba_data[pos].b = blue;
rgba_data[pos].a = alpha;
pos++;
surf_data++;
}
}
png_set_rows(png_ptr, info_ptr, row_pointers);
//writes the actual image data
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
//cleans everything
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
}

View file

@ -0,0 +1,36 @@
/* $Id$ */
/*
Copyright (C) 2004 by Philippe Plantier <ayin@anathas.org>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef EXPLODER_UTILS_HPP_INCLUDED
#define EXPLODER_UTILS_HPP_INCLUDED
#include "../sdl_utils.hpp"
#include <string>
struct exploder_failure
{
public:
exploder_failure(const std::string& message) :
message(message) {}
std::string message;
};
std::string get_mask_dir();
std::string get_exploder_dir();
void masked_overwrite_surface(SDL_Surface* dest, SDL_Surface* src, SDL_Surface* mask, int x, int y);
bool image_empty(SDL_Surface* surf);
void save_image(SDL_Surface *surf, const std::string &filename);
#endif

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# Makefile.in generated by automake 1.7.6 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
@ -84,6 +84,8 @@ KDE_ICON = @KDE_ICON@
KDE_TRUE = @KDE_TRUE@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBPNG_FALSE = @LIBPNG_FALSE@
LIBPNG_TRUE = @LIBPNG_TRUE@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
@ -97,6 +99,9 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PNG_CFLAGS = @PNG_CFLAGS@
PNG_CONFIG = @PNG_CONFIG@
PNG_LIBS = @PNG_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_IMAGE_LIBS = @SDL_IMAGE_LIBS@
@ -203,7 +208,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(wesnoth_zip_SOURCES)
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
DIST_COMMON = Makefile.am Makefile.in
SOURCES = $(wesnoth_zip_SOURCES)
all: all-am
@ -257,6 +262,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/variable.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zip.Po@am__quote@
distclean-depend:
-rm -rf ./$(DEPDIR)
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
@ -514,7 +522,7 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
@ -522,7 +530,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -532,10 +540,9 @@ clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
distclean-am: clean-am distclean-compile distclean-depend \
distclean-generic distclean-tags
dvi: dvi-am
@ -556,8 +563,7 @@ install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
@ -576,11 +582,11 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am info \
info-am install install-am install-binPROGRAMS install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
distclean-depend distclean-generic distclean-tags distdir dvi \
dvi-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-man install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-info-am

Binary file not shown.