- 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();
-}
-
-void
-Menu::recalc_pos()
-{
- if (current_)
- current_->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
-
- for(std::list<Menu*>::iterator i = all_menus.begin(); i != all_menus.end(); ++i)
- {
- // FIXME: This is of course not quite right, since it ignores any previous set_pos() calls
- (*i)->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
- }
-}
-\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;
-
- return string;
-}
-\f
-Menu::~Menu()
-{
- all_menus.remove(this);
-
- for(std::vector<MenuItem*>::iterator i = items.begin();
- i != items.end(); ++i)
- delete *i;
-
- if(current_ == this)
- current_ = NULL;
-
- if (previous == this)
- previous = NULL;
-}
-
-Menu::Menu()
-{
- all_menus.push_back(this);