-static const float MENU_REPEAT_RATE = 0.2f;
-static const float FLICK_CURSOR_TIME = 0.5f;
-
-extern SDL_Surface* screen;
-
-std::vector<Menu*> Menu::last_menus;
-Menu* Menu::current_ = 0;
-Menu* Menu::previous = 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;
-
- // TODO make this a screen and not another mainloop...
- while(true)
- {
- SDL_Event event;
- while (SDL_PollEvent(&event)) {
- if(event.type == SDL_QUIT)
- main_loop->quit();
- main_controller->process_event(event);
- dialog->event(event);
- }
-
- if(background == NULL)
- context.draw_gradient(Color(0.8f, 0.95f, 0.85f), Color(0.8f, 0.8f, 0.8f),
- 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;
-}
-\f
-void
-Menu::push_current(Menu* pmenu)
-{
- previous = current_;
-
- if (current_)
- last_menus.push_back(current_);
-
- current_ = pmenu;
- current_->effect_start_time = real_time;
- current_->effect_progress = 0.0f;
-}
-
-void
-Menu::pop_current()
-{
- previous = current_;
-
- if (last_menus.size() >= 1) {
- current_ = last_menus.back();
- current_->effect_start_time = real_time;
- current_->effect_progress = 0.0f;
- last_menus.pop_back();
- } else {
- current_ = 0;
- }
-}
-
-void
-Menu::set_current(Menu* menu)
-{
- previous = current_;
-
- last_menus.clear();
-
- if (menu)
- {
- menu->effect_start_time = real_time;
- menu->effect_progress = 0.0f;
- }
- current_ = menu;
- // just to be sure...
- main_controller->reset();
-}
-\f
-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_;
-}
-
-void
-MenuItem::set_help(const std::string& help_text)
-{
- std::string overflow;
- help = Menu::default_font->wrap_to_width(help_text, 600, &overflow);
- while (!overflow.empty())
- {
- help += "\n";
- help += Menu::default_font->wrap_to_width(overflow, 600, &overflow);
- }
-}
-
-std::string MenuItem::get_input_with_symbol(bool active_item)
-{
- if(!active_item) {
- input_flickering = true;
- } else {
- input_flickering = ((int) (real_time / FLICK_CURSOR_TIME)) % 2;
- }
-
- char str[1024];
- if(input_flickering)
- snprintf(str, sizeof(str), "%s ",input.c_str());
- else
- snprintf(str, sizeof(str), "%s_",input.c_str());
-
- std::string string = str;