static int title_enter(void) { int id, jd, kd; /* Build the title GUI. */ if ((id = gui_vstack(0))) { gui_label(id, "Neverputt", GUI_LRG, GUI_ALL, 0, 0); gui_space(id); if ((jd = gui_harray(id))) { gui_filler(jd); if ((kd = gui_varray(jd))) { gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 1); gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0); gui_state(kd, sgettext("menu^Exit"), GUI_MED, TITLE_EXIT, 0); } gui_filler(jd); } gui_layout(id, 0, 0); } course_init(); course_rand(); return id; }
/*========================================================== * transl_get_predefined_menukey -- Menu key for predefined translation * (localized) *========================================================*/ ZSTR transl_get_predefined_menukey (INT trnum) { ASSERT(trnum>=0); ASSERT(trnum<ARRSIZE(conversions_keys)); return zs_news(sgettext(conversions_keys[trnum])); }
void show_preferences_dialog(display& disp, const config& game_cfg) { std::vector<std::string> items; std::string const pre = IMAGE_PREFIX + std::string("icons/icon-"); char const sep = COLUMN_SEPARATOR; items.push_back(pre + "general.png" + sep + sgettext("Prefs section^General")); items.push_back(pre + "display.png" + sep + sgettext("Prefs section^Display")); items.push_back(pre + "music.png" + sep + sgettext("Prefs section^Sound")); items.push_back(pre + "multiplayer.png" + sep + sgettext("Prefs section^Multiplayer")); items.push_back(pre + "advanced.png" + sep + sgettext("Advanced section^Advanced")); for(;;) { try { preferences_dialog dialog(disp,game_cfg); dialog.parent.assign(new preferences_parent_dialog(disp)); dialog.parent->set_menu(items); dialog.parent->add_pane(&dialog); dialog.parent->show(); return; } catch(preferences_dialog::video_mode_change_exception& e) { switch(e.type) { case preferences_dialog::video_mode_change_exception::CHANGE_RESOLUTION: show_video_mode_dialog(disp); break; case preferences_dialog::video_mode_change_exception::MAKE_FULLSCREEN: set_fullscreen(true); break; case preferences_dialog::video_mode_change_exception::MAKE_WINDOWED: set_fullscreen(false); break; } if(items[1].empty() || items[1][0] != '*') { items[1] = "*" + items[1]; } } } }
static int title_gui(void) { int id, jd, kd; /* Build the title GUI. */ if ((id = gui_vstack(0))) { if ((jd = gui_label(id, " Neverball ", GUI_LRG, 0, 0))) gui_set_fill(jd); gui_space(id); if ((jd = gui_hstack(id))) { gui_filler(jd); if ((kd = gui_varray(jd))) { if (config_cheat()) play_id = gui_start(kd, sgettext("menu^Cheat"), GUI_MED, TITLE_PLAY, 0); else play_id = gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 0); gui_state(kd, sgettext("menu^Replay"), GUI_MED, TITLE_DEMO, 0); gui_state(kd, sgettext("menu^Help"), GUI_MED, TITLE_HELP, 0); gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0); gui_state(kd, sgettext("menu^Exit"), GUI_MED, GUI_BACK, 0); /* Hilight the start button. */ gui_set_hilite(play_id, 1); } gui_filler(jd); } gui_layout(id, 0, 0); } return id; }
TITLE_RESULT show_title(game_display& screen, config& tips_of_day) { disableTerrainCache(); free_all_caches(); cursor::set(cursor::NORMAL); const preferences::display_manager disp_manager(&screen); const hotkey::basic_handler key_handler(&screen); const font::floating_label_context label_manager; screen.video().modeChanged(); // resets modeChanged value // if (background_is_dirty_) { draw_background(screen); } //- Texts for the menu-buttons. //- Members of this array must correspond to the enumeration TITLE_RESULT static const char* button_labels[] = { //N_("TitleScreen button^Tutorial"), N_("TitleScreen button^Campaign"), #ifndef FREE_VERSION N_("TitleScreen button^Skirmish"), N_("TitleScreen button^Multiplayer"), #endif N_("TitleScreen button^Load"), // N_("TitleScreen button^Add-ons"), //#ifndef DISABLE_EDITOR2 //N_("TitleScreen button^Map Editor"), //#endif //N_("TitleScreen button^Language"), N_("TitleScreen button^Preferences"), N_("Sync Saves"), #ifndef DISABLE_OPENFEINT N_("TitleScreen button^OpenFeint"), #endif N_("TitleScreen button^Help"), //N_("TitleScreen button^Quit"), // Only the above buttons go into the menu-frame // Next 2 buttons go into frame for the tip-of-the-day: N_("TitleScreen button^Previous"), N_("TitleScreen button^Next"), //N_("TitleScreen button^Help"), // Next entry is no button, but shown as a mail-icon instead: //N_("TitleScreen button^Help Wesnoth") }; //- Texts for the tooltips of the menu-buttons static const char* help_button_labels[] = { //N_("Start a tutorial to familiarize yourself with the game"), N_("Start a new single player campaign"), #ifndef FREE_VERSION N_("Play a single scenario against the AI"), N_("Play multiplayer (hotseat or Internet)"), #endif N_("Load a saved game"), // N_("Download usermade campaigns, eras, or map packs"), //#ifndef DISABLE_EDITOR2 //N_("Start the map editor"), //#endif //N_("Change the language"), N_("Configure the game's settings"), N_("Sync saved games"), #ifndef DISABLE_OPENFEINT N_("Launch the OpenFeint dashboard"), #endif N_("Show Battle for Wesnoth help"), //N_("Quit the game"), N_("Show next tip of the day"), //N_("Upload statistics") }; //static const size_t nbuttons = sizeof(button_labels)/sizeof(*button_labels); #ifdef FREE_VERSION int nbuttons = 10; #else int nbuttons = 8; #endif #ifdef DISABLE_OPENFEINT nbuttons--; #endif #ifndef __IPAD__ nbuttons--; // because help is off to the left now #endif int menu_xbase = CVideo::getx()-108-10; //380; //(game_config::title_buttons_x*screen.w())/1024; const int menu_xincr = 0; #ifdef USE_TINY_GUI //const int menu_ybase = 15; //(330*screen.h())/768 - 50; //15; const int menu_yincr = 36+5; //(35*3)/4;//15; const int menu_ybase = (screen.h() - (36+5)*nbuttons - 5) / 2 + 4; #else const int menu_ybase = (screen.h() - (36+5)*nbuttons - 5) / 2 + 4; const int menu_yincr = 36+5; #endif #ifdef __IPAD__ menu_xbase -= 10; #endif const int padding = 4; //game_config::title_buttons_padding; std::vector<button> buttons; size_t b, max_width = 0; size_t n_menubuttons = 0; for(b = 0; b != nbuttons; ++b) { //#ifdef __IPHONEOS__ // if (b + TUTORIAL == TUTORIAL || b + TUTORIAL == START_MAP_EDITOR || b+TUTORIAL == CHANGE_LANGUAGE) // continue; //#endif buttons.push_back(button(screen.video(),sgettext(button_labels[b]))); buttons.back().set_help_string(sgettext(help_button_labels[b])); max_width = std::max<size_t>(max_width,buttons.back().width()); n_menubuttons = b; #ifdef __IPAD__ if(b + NEW_CAMPAIGN == SHOW_HELP) break; #else if(b + NEW_CAMPAIGN == SHOW_OPENFEINT) break; #endif } SDL_Rect main_dialog_area = {menu_xbase-padding, menu_ybase-padding, max_width+padding*2, menu_yincr*(n_menubuttons)+buttons.back().height()+padding*2}; gui::dialog_frame main_frame(screen.video(), "", gui::dialog_frame::titlescreen_style, false); main_frame.layout(main_dialog_area); // we only redraw transparent parts when asked, // to prevent alpha growing if (background_is_dirty_) { main_frame.draw_background(); main_frame.draw_border(); } int i=0; for(b = 0; b != nbuttons; ++b) { //#ifdef __IPHONEOS__ // if (b + TUTORIAL == TUTORIAL || b + TUTORIAL == START_MAP_EDITOR || b+TUTORIAL == CHANGE_LANGUAGE) // continue; //#endif buttons[i].set_width(max_width); buttons[i].set_location(menu_xbase + i*menu_xincr, menu_ybase + i*menu_yincr); #ifdef __IPAD__ if(b + NEW_CAMPAIGN == SHOW_HELP) break; #else if(b + NEW_CAMPAIGN == SHOW_OPENFEINT) break; #endif i++; } #ifndef __IPAD__ buttons.push_back(button(screen.video(),sgettext(button_labels[i+1]))); buttons.back().set_help_string(sgettext(help_button_labels[i+1])); buttons[i+1].set_width(max_width); buttons[i+1].set_location(5, 320-menu_yincr); #endif // b = TIP_PREVIOUS - NEW_CAMPAIGN; // gui::button previous_tip_button(screen.video(),sgettext(button_labels[b]),button::TYPE_PRESS,"lite_small"); // previous_tip_button.set_help_string( sgettext(button_labels[b] )); // b = TIP_NEXT - NEW_CAMPAIGN; // gui::button next_tip_button(screen.video(),sgettext(button_labels[b]),button::TYPE_PRESS,"lite_small"); // next_tip_button.set_help_string( sgettext(button_labels[b] )); // b = SHOW_HELP - NEW_CAMPAIGN; // gui::button help_tip_button(screen.video(),sgettext(button_labels[b]),button::TYPE_PRESS,"lite_small"); // help_tip_button.set_help_string( sgettext(button_labels[b] )); // gui::button beg_button(screen.video(),_("Help Wesnoth"),button::TYPE_IMAGE,"menu-button",button::MINIMUM_SPACE); // beg_button.set_help_string(_("Help Wesnoth by sending us information")); // next_tip_of_day(tips_of_day); // surface_restorer tip_of_day_restorer; // draw_tip_of_day(screen, tips_of_day, gui::dialog_frame::titlescreen_style, // &previous_tip_button, &next_tip_button, NULL/*&help_tip_button*/, &main_dialog_area, tip_of_day_restorer); // const int pad = game_config::title_tip_padding; // beg_button.set_location(screen.w() - pad - beg_button.location().w, // screen.h() - pad - beg_button.location().h); events::raise_draw_event(); LOG_DP << "drew buttons dialog\n"; // draw logo over everything #ifdef __IPAD__ std::string path = game_config::path + "/data/core/images/misc/logo.png"; #else std::string path = game_config::path + "/data/core/images/misc/logo_small.png"; #endif surface logo_surface = IMG_Load(path.c_str()); //blit_surface(480-logo_surface.get()->w, 0, logo_surface); CKey key; size_t keyboard_button = nbuttons; bool key_processed = false; // update_whole_screen(); background_is_dirty_ = false; titlescreen_handler ts_handler(key[SDLK_ESCAPE] != 0); //!= 0 to avoid a MSVC warning C4800 LOG_DP << "entering interactive loop...\n"; memory_stats("At titlescreen"); // Initialize OpenFeint now of_init(); for(;;) { events::pump(); for(size_t b = 0; b != buttons.size(); ++b) { if(buttons[b].pressed()) { free_title(); return static_cast<TITLE_RESULT>(b + NEW_CAMPAIGN); } } /* if(previous_tip_button.pressed()) { next_tip_of_day(tips_of_day, true); draw_tip_of_day(screen, tips_of_day, gui::dialog_frame::titlescreen_style, &previous_tip_button, &next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer); } if(next_tip_button.pressed()) { next_tip_of_day(tips_of_day, false); draw_tip_of_day(screen, tips_of_day, gui::dialog_frame::titlescreen_style, &previous_tip_button, &next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer); } */ // if(help_tip_button.pressed()) { // return SHOW_HELP; // } // if(beg_button.pressed()) { // return BEG_FOR_UPLOAD; // } if (key[SDLK_UP]) { if (!key_processed) { buttons[keyboard_button].set_active(false); if (keyboard_button == 0) { keyboard_button = nbuttons - 1; } else { keyboard_button--; } key_processed = true; buttons[keyboard_button].set_active(true); } } else if (key[SDLK_DOWN]) { if (!key_processed) { buttons[keyboard_button].set_active(false); if (keyboard_button > nbuttons - 1) { keyboard_button = 0; } else { keyboard_button++; } key_processed = true; buttons[keyboard_button].set_active(true); } } else { key_processed = false; } events::raise_process_event(); // KP: redraw draw_background(screen); main_frame.draw_background(); main_frame.draw_border(); events::raise_draw_event(); //blit_surface(480-logo_surface.get()->w, 0, logo_surface); #ifdef __IPAD__ blit_surface(-10, 0, logo_surface); #else blit_surface(-15, -10, logo_surface); #endif screen.flip(); // if (key[SDLK_ESCAPE] && !ts_handler.get_esc_ignore()) // return QUIT_GAME; if (key[SDLK_F5]) return RELOAD_GAME_DATA; if (key[SDLK_RETURN] && keyboard_button < nbuttons) { return static_cast<TITLE_RESULT>(keyboard_button + NEW_CAMPAIGN); } // If the resolution has changed due to the user resizing the screen, // or from changing between windowed and fullscreen: if(screen.video().modeChanged()) { return REDRAW_BACKGROUND; } screen.delay(10); } free_title(); return REDRAW_BACKGROUND; }
static int title_action(int tok, int val) { static const char keyphrase[] = "xyzzy"; static char queue[sizeof (keyphrase)] = ""; size_t queue_len = strlen(queue); audio_play(AUD_MENU, 1.0f); switch (tok) { case GUI_BACK: return 0; break; case TITLE_PLAY: if (strlen(config_get_s(CONFIG_PLAYER)) == 0) return goto_name(&st_set, &st_title, 0); else return goto_state(&st_set); break; case TITLE_HELP: return goto_state(&st_help); break; case TITLE_DEMO: return goto_state(&st_demo); break; case TITLE_CONF: return goto_state(&st_conf); break; case GUI_CHAR: /* Let the queue fill up. */ if (queue_len < sizeof (queue) - 1) { queue[queue_len] = (char) val; queue[queue_len + 1] = '\0'; } /* Advance the queue before adding the new element. */ else { int k; for (k = 1; k < queue_len; k++) queue[k - 1] = queue[k]; queue[queue_len - 1] = (char) val; } if (strcmp(queue, keyphrase) == 0) { config_set_cheat(); gui_set_label(play_id, sgettext("menu^Cheat")); gui_pulse(play_id, 1.2f); } else if (config_cheat()) { config_clr_cheat(); gui_set_label(play_id, sgettext("menu^Play")); gui_pulse(play_id, 1.2f); } break; } return 1; }