From 1e8c560f0737dfd41c0f9afe367b95165bbcef85 Mon Sep 17 00:00:00 2001 From: Dave White Date: Thu, 16 Oct 2003 11:05:26 +0000 Subject: [PATCH] minor re-arrangements --- Makefile | 2 +- data/intro.cfg | 4 +-- data/scenarios/scenario12.cfg | 27 ++++++++++++++- src/game.cpp | 7 +++- src/hotkeys.cpp | 4 ++- src/intro.cpp | 12 ++++--- src/playlevel.cpp | 4 ++- src/playturn.cpp | 3 +- src/preferences.cpp | 8 +++-- src/show_dialog.cpp | 9 ++--- src/video.cpp | 62 ----------------------------------- src/video.hpp | 9 ----- 12 files changed, 60 insertions(+), 91 deletions(-) diff --git a/Makefile b/Makefile index adf831206a2..87ec8e156f1 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ SDL_CFLAGS=`sdl-config --cflags` `freetype-config --cflags` SDL_LIBS=`sdl-config --libs` `freetype-config --libs` -lSDL_mixer -lSDL_ttf -lSDL_image -lSDL_net LIBS=${SDL_LIBS} -lstdc++ INCLUDES=-I. -Isrc -Isrc/tools -Isrc/widgets -OBJS=src/actions.o src/ai.o src/ai_attack.o src/ai_move.o src/config.o src/dialogs.o src/display.o src/filesystem.o src/font.o src/game.o src/game_config.o src/game_events.o src/gamestatus.o src/hotkeys.o src/intro.o src/key.o src/language.o src/log.o src/map.o src/mouse.o src/multiplayer.o src/multiplayer_client.o src/network.o src/pathfind.o src/playlevel.o src/playturn.o src/preferences.o src/replay.o src/sdl_utils.o src/show_dialog.o src/sound.o src/team.o src/terrain.o src/tooltips.o src/unit.o src/unit_types.o src/video.o src/widgets/button.o src/widgets/menu.o src/widgets/slider.o src/widgets/textbox.o +OBJS=src/actions.o src/ai.o src/ai_attack.o src/ai_move.o src/config.o src/dialogs.o src/display.o src/events.o src/filesystem.o src/font.o src/game.o src/game_config.o src/game_events.o src/gamestatus.o src/hotkeys.o src/intro.o src/key.o src/language.o src/log.o src/map.o src/mouse.o src/multiplayer.o src/multiplayer_client.o src/network.o src/pathfind.o src/playlevel.o src/playturn.o src/preferences.o src/replay.o src/sdl_utils.o src/show_dialog.o src/sound.o src/team.o src/terrain.o src/tooltips.o src/unit.o src/unit_types.o src/video.o src/widgets/button.o src/widgets/menu.o src/widgets/slider.o src/widgets/textbox.o MAKE_TRANS_OBJS=src/tools/make_translation.o src/config.o src/filesystem.o src/game_config.o src/log.o MERGE_TRANS_OBJS=src/tools/merge_translations.o src/config.o src/filesystem.o src/game_config.o src/log.o diff --git a/data/intro.cfg b/data/intro.cfg index a681a996a8f..becc380460f 100644 --- a/data/intro.cfg +++ b/data/intro.cfg @@ -63,12 +63,12 @@ id=intro_11 story="Hearing of the orders of Asheviere, Delfador entered the palace by stealth, and stole away Konrad, the youngest of Garard's nephews, saving him from death" delay=4000 - image=misc/map.png + image=misc/story6.png [/part] [part] id=intro_12 story="Taking the child away to the forests of the West, Delfador raised him under the protection of the Elves, watching sadly as Asheviere's reign of terror over the land began..." delay=6000 - image=misc/map.png + image=misc/story6.png [/part] [/story] diff --git a/data/scenarios/scenario12.cfg b/data/scenarios/scenario12.cfg index 72b20d9a582..ca64ab53708 100644 --- a/data/scenarios/scenario12.cfg +++ b/data/scenarios/scenario12.cfg @@ -348,6 +348,31 @@ Defeat [/event] - {deaths.cfg} + #a chest of treasure behind the secret passage + [item] + image=misc/chest.png + x=9 + y=39 + [/item] + [event] + name=moveto + [filter] + x=9 + y=39 + side=1 + [/filter] + [message] + speaker=unit + message="There is a great fortune in this chest of treasure! I can count two hundred pieces of gold!" + [/message] + [gold] + side=1 + amount=200 + [/gold] + [removeitem] + [/removeitem] + [/event] + + {deaths.cfg} [/scenario] diff --git a/src/game.cpp b/src/game.cpp index 5f8ada2429b..f1b6e0ec9b6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -167,7 +167,12 @@ int play_game(int argc, char** argv) game_config::debug = true; } else if(val == "--help" || val == "-h") { std::cout << "usage: " << argv[0] - << " [options] [data-directory]\n"; + << " [options] [data-directory]\n" + << " -d, --debug Shows debugging information in-game\n" + << " -f, --fullscreen Runs the game in full-screen\n" + << " -h, --help Prints this message and exits\n" + << " -t, --test Runs the game in a small example scenario\n" + << " -w, --windowed Runs the game in windowed mode\n"; return 0; } else if(val == "--version" || val == "-v") { std::cout << "Battle for Wesnoth " << game_config::version diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 2d85306497c..1c7abf51a50 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -10,7 +10,9 @@ See the COPYING file for more details. */ + #include "config.hpp" +#include "events.hpp" #include "hotkeys.hpp" #include "language.hpp" #include "playlevel.hpp" @@ -151,7 +153,7 @@ HOTKEY_COMMAND check_keys(display& disp) { const double zoom_amount = 5.0; - ::pump_events(); + events::pump(); CKey key; if(key[KEY_ESCAPE]) { diff --git a/src/intro.cpp b/src/intro.cpp index e4a81e49d73..c58b82f56db 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -10,6 +10,8 @@ See the COPYING file for more details. */ + +#include "events.hpp" #include "font.hpp" #include "intro.hpp" #include "key.hpp" @@ -24,7 +26,7 @@ void show_intro(display& screen, config& data) { //stop the screen being resized while we're in this function - const resize_lock stop_resizing; + const events::resize_lock stop_resizing; CKey key; @@ -107,7 +109,7 @@ void show_intro(display& screen, config& data) const bool left_button = mouse_flags&SDL_BUTTON_LMASK; - pump_events(); + events::pump(); if(key[KEY_ESCAPE] || skip_button.process(mousex,mousey,left_button)) @@ -130,7 +132,7 @@ void show_intro(display& screen, config& data) void show_map_scene(display& screen, config& data) { //stop the screen being resized while we're in this function - const resize_lock stop_resizing; + const events::resize_lock stop_resizing; //clear the screen gui::draw_solid_tinted_rectangle(0,0,screen.x()-1,screen.y()-1,0,0,0,1.0, @@ -214,7 +216,7 @@ void show_map_scene(display& screen, config& data) SDL_Delay(10); - pump_events(); + events::pump(); int a, b; const int mouse_flags = SDL_GetMouseState(&a,&b); @@ -257,7 +259,7 @@ void show_map_scene(display& screen, config& data) last_state = new_state; SDL_Delay(20); - pump_events(); + events::pump(); } //clear the screen diff --git a/src/playlevel.cpp b/src/playlevel.cpp index 7e49b0a5282..53e7c7fb49e 100644 --- a/src/playlevel.cpp +++ b/src/playlevel.cpp @@ -10,6 +10,8 @@ See the COPYING file for more details. */ + +#include "events.hpp" #include "game_events.hpp" #include "intro.hpp" #include "language.hpp" @@ -231,7 +233,7 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& terrain_config, gui.draw(); game_events::pump(); - pump_events(); + events::pump(); } std::cerr << "replay: '" << cfg.children["turn"].front()->write() << "'\n"; diff --git a/src/playturn.cpp b/src/playturn.cpp index f1c85ef465c..c2c7aa9f518 100644 --- a/src/playturn.cpp +++ b/src/playturn.cpp @@ -12,6 +12,7 @@ */ #include "actions.hpp" +#include "events.hpp" #include "hotkeys.hpp" #include "language.hpp" #include "log.hpp" @@ -965,6 +966,6 @@ void play_turn(game_data& gameinfo, game_state& state_of_game, game_events::pump(); - pump_events(); + events::pump(); } } diff --git a/src/preferences.cpp b/src/preferences.cpp index 9ed88674a6a..1a6b5098790 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -10,6 +10,8 @@ See the COPYING file for more details. */ + +#include "events.hpp" #include "filesystem.hpp" #include "font.hpp" #include "hotkeys.hpp" @@ -265,7 +267,7 @@ void show_preferences_dialog(display& disp) { assert(::disp != NULL); - const resize_lock prevent_resizing; + const events::resize_lock prevent_resizing; log_scope("show_preferences_dialog"); @@ -435,7 +437,7 @@ void show_preferences_dialog(display& disp) disp.update_display(); SDL_Delay(10); - pump_events(); + events::pump(); } disp.invalidate_all(); @@ -444,7 +446,7 @@ void show_preferences_dialog(display& disp) void show_video_mode_dialog(display& disp) { - const resize_lock prevent_resizing; + const events::resize_lock prevent_resizing; std::vector > resolutions; std::vector options; diff --git a/src/show_dialog.cpp b/src/show_dialog.cpp index ec389b35c45..45f4d035d67 100644 --- a/src/show_dialog.cpp +++ b/src/show_dialog.cpp @@ -12,6 +12,7 @@ */ #include "config.hpp" +#include "events.hpp" #include "font.hpp" #include "language.hpp" #include "playlevel.hpp" @@ -188,7 +189,7 @@ int show_dialog(display& disp, SDL_Surface* image, if(disp.update_locked()) return -1; - const resize_lock prevent_resizing; + const events::resize_lock prevent_resizing; const std::vector& menu_items = (menu_items_ptr == NULL) ? std::vector() : *menu_items_ptr; @@ -454,7 +455,7 @@ int show_dialog(display& disp, SDL_Surface* image, bool first_time = true; for(;;) { - pump_events(); + events::pump(); int mousex, mousey; const int mouse_flags = SDL_GetMouseState(&mousex,&mousey); @@ -582,7 +583,7 @@ int show_dialog(display& disp, SDL_Surface* image, TITLE_RESULT show_title(display& screen) { - const resize_lock prevent_resizing; + const events::resize_lock prevent_resizing; SDL_Surface* const title_surface = screen.getImage("title.png", display::UNSCALED); @@ -672,7 +673,7 @@ TITLE_RESULT show_title(display& screen) if(key[KEY_ESCAPE]) return QUIT_GAME; - pump_events(); + events::pump(); SDL_Delay(20); } diff --git a/src/video.cpp b/src/video.cpp index aa016ebc234..edb0c8af11f 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -188,65 +188,3 @@ SDL_Surface* CVideo::getSurface( void ) } bool CVideo::isFullScreen() const { return fullScreen; } - -namespace { - int disallow_resize = 0; -} - -resize_lock::resize_lock() -{ - ++disallow_resize; -} - -resize_lock::~resize_lock() -{ - --disallow_resize; -} - -void pump_events() -{ - SDL_PumpEvents(); - - static std::pair resize_dimensions(0,0); - - SDL_Event event; - while(SDL_PollEvent(&event)) { - switch(event.type) { - case SDL_VIDEORESIZE: { - const SDL_ResizeEvent* const resize - = reinterpret_cast(&event); - - if(resize->w < 1024 || resize->h < 768) { - resize_dimensions.first = 0; - resize_dimensions.second = 0; - } else { - resize_dimensions.first = resize->w; - resize_dimensions.second = resize->h; - } - - break; - } - - //mouse wheel support - case SDL_MOUSEBUTTONDOWN: { - if(event.button.button == 4) { - gui::scroll_dec(); - } else if(event.button.button == 5) { - gui::scroll_inc(); - } - - break; - } - - case SDL_QUIT: { - throw CVideo::quit(); - } - } - } - - if(resize_dimensions.first > 0 && disallow_resize == 0) { - preferences::set_resolution(resize_dimensions); - resize_dimensions.first = 0; - resize_dimensions.second = 0; - } -} diff --git a/src/video.hpp b/src/video.hpp index f82b08de0be..8e8440623fa 100644 --- a/src/video.hpp +++ b/src/video.hpp @@ -58,13 +58,4 @@ class CVideo { SDL_Surface* frameBuffer; }; -void allow_resizing(bool); - -struct resize_lock { - resize_lock(); - ~resize_lock(); -}; - -void pump_events(); - #endif