added [then] and [else] tags under [object] tags

This commit is contained in:
Dave White 2004-07-18 21:07:56 +00:00
parent 5665af2ab3
commit 36e49bc678
9 changed files with 40 additions and 12 deletions

View file

@ -619,6 +619,11 @@ What would you like to wish for?"
type=Merman,Merman Lord,Triton
x,y={X},{Y}
[/filter]
[then]
[removeitem]
x,y={X},{Y}
[/removeitem]
[/then]
[effect]
apply_to=new_attack
name=storm trident

View file

@ -57,7 +57,7 @@ public:
//Starts an animation cycle. The first frame of the animation to start
//may be set to any value
static const int INFINITE_CYCLES = -1;
enum { INFINITE_CYCLES = -1 };
void start_animation(int start_time=0, int cycles=1, int acceleration=1);
int get_first_frame_time() const;

View file

@ -191,6 +191,17 @@ std::string get_dir(const std::string& dir_path)
return dir_path;
}
std::string get_cwd()
{
char buf[1024];
const char* const res = getcwd(buf,sizeof(buf));
if(res != NULL) {
return res;
} else {
return "";
}
}
std::string get_user_data_dir()
{
#ifdef _WIN32

View file

@ -39,6 +39,8 @@ std::string get_saves_dir();
std::string get_cache_dir();
std::string get_user_data_dir();
std::string get_cwd();
std::string read_map(const std::string& name);
//function which returns true iff the given file is a directory

View file

@ -380,16 +380,8 @@ int play_game(int argc, char** argv)
if(val[0] == '/') {
game_config::path = val;
} else if(getcwd(buf,sizeof(buf)) != NULL) {
std::string cwd(buf);
#ifdef _WIN32
std::replace(cwd.begin(),cwd.end(),'\\','/');
#endif
game_config::path = cwd + '/' + val;
} else {
std::cerr << "Could not get working directory\n";
return 0;
game_config::path = get_cwd() + '/' + val;
}
if(!is_directory(game_config::path)) {

View file

@ -753,6 +753,8 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
const unit_map::iterator u = units->find(loc);
std::string command_type = "then";
if(u != units->end() && (filter == NULL || u->second.matches_filter(*filter))) {
const std::string& lang = string_table[id];
if(!lang.empty())
@ -773,6 +775,8 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
text = lang;
else
text = cfg["cannot_use_message"];
command_type = "else";
}
if(cfg["silent"] != "yes") {
@ -787,6 +791,12 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
gui::show_dialog(*screen,surface,caption,text);
}
const config::child_list& commands = cfg.get_children(command_type);
for(config::child_list::const_iterator cmd = commands.begin();
cmd != commands.end(); ++cmd) {
handle_event(event_info,*cmd);
}
}
//displaying a message on-screen

View file

@ -33,6 +33,11 @@ bool rects_overlap(const SDL_Rect& rect1, const SDL_Rect& rect2)
point_in_rect(rect1.x,rect1.y+rect1.h,rect2) || point_in_rect(rect1.x+rect1.w,rect1.y+rect1.h,rect2);
}
bool operator<(const surface& a, const surface& b)
{
return a.get() < b.get();
}
namespace {
SDL_PixelFormat& get_neutral_pixel_format()
{

View file

@ -82,6 +82,8 @@ private:
scoped_sdl_surface surface_;
};
bool operator<(const surface& a, const surface& b);
surface make_neutral_surface(surface surf);
surface create_optimized_surface(surface surface);
surface scale_surface(surface surface, int w, int h);
@ -92,7 +94,7 @@ surface brighten_image(surface surface, double amount);
surface get_surface_portion(surface src, SDL_Rect& rect);
surface adjust_surface_alpha(surface surface, double amount);
surface adjust_surface_alpha_add(surface surface, int amount);
surface mask_surface(surface surface, surface mask);
surface mask_surface(surface surf, surface mask);
surface cut_surface(surface surface, const SDL_Rect& r);
surface blend_surface(surface surface, double amount, Uint32 colour);
surface flip_surface(surface surface);

View file

@ -27,7 +27,8 @@ class unit_animation
{
public:
struct frame {
frame() {};
frame() {}
frame(const std::string& str) {}
frame(const config& cfg);
// int start, end;