-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include <config.h>
-
-#include <sys/types.h>
-#include <ctype.h>
-
-#include <iostream>
-#include <sstream>
-#include <cstdlib>
-#include <cstdio>
-#include <string>
-#include <cassert>
-#include <stdexcept>
-
-#include "menu.hpp"
-#include "video/screen.hpp"
-#include "video/drawing_context.hpp"
-#include "gettext.hpp"
-#include "math/vector.hpp"
-#include "main.hpp"
-#include "resources.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
-#include "exceptions.hpp"
-
-static const int MENU_REPEAT_INITIAL = 400;
-static const int MENU_REPEAT_RATE = 200;
-static const int FLICK_CURSOR_TIME = 500;
-
-extern SDL_Surface* screen;
-
-std::vector<Menu*> Menu::last_menus;
-Menu* Menu::current_ = 0;
-Font* Menu::default_font;
-Font* Menu::active_font;
-Font* Menu::deactive_font;
-Font* Menu::label_font;
-Font* Menu::field_font;
-
-/* just displays a Yes/No text that can be used to confirm stuff */
-bool confirm_dialog(Surface *background, std::string text)
-{
- //Surface* cap_screen = Surface::CaptureScreen();
- Menu* dialog = new Menu;
- dialog->add_deactive(-1, text);
- dialog->add_hl();
- dialog->add_entry(true, _("Yes"));
- dialog->add_entry(false, _("No"));
- dialog->add_hl();
-
- Menu::set_current(dialog);
-
- DrawingContext context;
-
- while(true)
- {
- SDL_Event event;
- while (SDL_PollEvent(&event)) {
- if(event.type == SDL_QUIT)
- throw graceful_shutdown();
- main_controller->process_event(event);
- dialog->event(event);
- }
-
- if(background == NULL)
- context.draw_gradient(Color(0.8, 0.95, 0.85), Color(0.8, 0.8, 0.8),
- LAYER_BACKGROUND0);
- else
- context.draw_surface(background, Vector(0,0), LAYER_BACKGROUND0);
-
- dialog->draw(context);
- dialog->update();
-
- switch (dialog->check())
- {
- case true:
- //delete cap_screen;
- Menu::set_current(0);
- delete dialog;
- return true;
- break;
- case false:
- //delete cap_screen;
- Menu::set_current(0);
- delete dialog;
- return false;
- break;
- default:
- break;
- }
-
- mouse_cursor->draw(context);
- context.do_drawing();
- SDL_Delay(25);
- }
-
- return false;
-}
-
-void
-Menu::push_current(Menu* pmenu)
-{
- if (current_)
- last_menus.push_back(current_);
-
- current_ = pmenu;
- current_->effect_ticks = SDL_GetTicks();
-}
-
-void
-Menu::pop_current()
-{
- if (last_menus.size() >= 1) {
- current_ = last_menus.back();
- current_->effect_ticks = SDL_GetTicks();
- last_menus.pop_back();
- } else {
- current_ = 0;
- }
-}
-
-void
-Menu::set_current(Menu* menu)
-{
- last_menus.clear();
-
- if (menu)
- menu->effect_ticks = SDL_GetTicks();
-
- current_ = menu;
- // just to be sure...
- main_controller->reset();
-}
-
-MenuItem::MenuItem(MenuItemKind _kind, int _id)
- : kind(_kind) , id(_id)
-{
- toggled = false;
- selected = false;
- target_menu = 0;
-}
-
-void
-MenuItem::change_text(const std::string& text_)
-{
- text = text_;
-}
-
-void
-MenuItem::change_input(const std::string& text_)
-{
- input = text_;
-}
-
-std::string MenuItem::get_input_with_symbol(bool active_item)
-{
- if(!active_item) {
- input_flickering = true;
- } else {
- input_flickering = (SDL_GetTicks() / FLICK_CURSOR_TIME) % 2;
- }
-
- char str[1024];
- if(input_flickering)
- sprintf(str,"%s ",input.c_str());
- else
- sprintf(str,"%s_",input.c_str());