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; }
int main (int argc, char **argv) { int c, i; opterr = 0; bool iactive = false; strcpy (homedir, argv[0]); for (i = strlen (homedir)-1; i >= 0; i--) { bool ended = false; if (homedir[i] == '/') ended = true; homedir[i] = '\0'; if (ended) break; } strcpy (demuxer, DEFAULT_DEMUXER); strcpy (provider, DEFAULT_OTV_PROVIDER); while ((c = getopt (argc, argv, "h:d:x:l:p:k:riyz")) != -1) { switch (c) { case 'd': db_root = optarg; break; case 'x': strcpy (demuxer, optarg); break; case 'l': strcpy (homedir, optarg); break; case 'i': printf ("WARNING! Option -i is deprecated\n"); break; case 'p': strcpy (provider, optarg); break; case 'k': nice (atoi(optarg)); break; case 'r': log_disable (); interactive_enable (); iactive = true; break; case 'y': huffman_debug_summaries = true; break; case 'z': huffman_debug_titles = true; break; case '?': printf ("Usage:\n"); printf (" ./crossepg_downloader [options]\n"); printf ("Options:\n"); printf (" -d db_root crossepg db root folder\n"); printf (" default: %s\n", db_root); printf (" -x demuxer dvb demuxer\n"); printf (" default: %s\n", demuxer); printf (" -l homedir home directory\n"); printf (" default: %s\n", homedir); printf (" -p provider opentv provider\n"); printf (" default: %s\n", provider); printf (" -k nice see \"man nice\"\n"); printf (" -r interactive mode\n"); printf (" -y debug mode for huffman dictionary (summaries)\n"); printf (" -z debug mode for huffman dictionary (titles)\n"); printf (" -h show this help\n"); return 0; } } while (homedir[strlen (homedir) - 1] == '/') homedir[strlen (homedir) - 1] = '\0'; while (db_root[strlen (db_root) - 1] == '/') db_root[strlen (db_root) - 1] = '\0'; mkdir (db_root, S_IRWXU|S_IRWXG|S_IRWXO); log_open (db_root); log_banner ("CrossEPG Downloader"); xmltv_encodings_init (); if (iactive) interactive_manager (); else { char opentv_file[256]; sprintf (opentv_file, "%s/providers/%s.conf", homedir, provider); if (providers_read (opentv_file)) { if (providers_get_protocol () == 1) { log_add ("Provider %s identified as opentv", provider); if (!db_load ()) goto error; download_opentv (); if (epgdb_save (NULL)) log_add ("Data saved"); else log_add ("Error saving data"); db_close (); } else if (providers_get_protocol () == 2) { log_add ("Provider %s identified as xmltv", provider); log_add ("Preferred language: %s", providers_get_xmltv_plang ()); if (!db_load ()) goto error; xmltv_channels_init (); for (i=0; i<10; i++) { if (strlen(providers_get_xmltv_channels (i)) == 0) { log_add ("No more url available"); log_add ("Error downloading/parsing channels file"); goto error; } log_add ("Download channels from url: %s (%d)", providers_get_xmltv_channels (i), i); if (xmltv_downloader_channels (providers_get_xmltv_channels (i), db_root, NULL, NULL, &stop)) break; } xmltv_parser_set_iso639 (providers_get_xmltv_plang ()); for (i=0; i<10; i++) { if (strlen(providers_get_xmltv_url (i)) == 0) { log_add ("No more url available"); log_add ("Error downloading/parsing events file"); goto error; } log_add ("Download events from url: %s", providers_get_xmltv_url (i)); if (xmltv_downloader_events (providers_get_xmltv_url (i), db_root, NULL, NULL, &stop)) { if (epgdb_save (NULL)) log_add ("Data saved"); else log_add ("Error saving data"); break; } } xmltv_channels_cleanup (); db_close (); } else if (providers_get_protocol () == 3) { log_add ("Provider %s identified as xepgdb", provider); log_add ("Headers url: %s", providers_get_xepgdb_headers_url ()); log_add ("Descriptors url: %s", providers_get_xepgdb_descriptors_url ()); if (!db_load ()) goto error; if (dbmerge_downloader (providers_get_xepgdb_headers_url (), providers_get_xepgdb_descriptors_url (), db_root, NULL, NULL, &stop)) { if (epgdb_save (NULL)) log_add ("Data saved"); else log_add ("Error saving data"); } else log_add ("Error downloading/parsing xepgdb files"); db_close (); } else if (providers_get_protocol () == 4) { char filename[1024], tmp[1024], *tmp2; log_add ("Provider %s identified as script", provider); log_add ("Script file name: %s", providers_get_script_filename ()); tmp2 = replace_str (providers_get_script_arguments (), "%%dbroot%%", db_root); strcpy (tmp, tmp2); tmp2 = replace_str (tmp, "%%homedir%%", homedir); sprintf (filename, "LD_LIBRARY_PATH=%s %s/scripts/%s %s", homedir, homedir, providers_get_script_filename (), tmp2); log_add ("Executing script %s ...", filename); system (filename); log_add ("Script terminated"); } } else log_add ("Cannot load provider configuration (%s)", opentv_file); } memory_stats (); error: log_close (); return 0; }
int main (int argc, char **argv) { int c, i; opterr = 0; bool iactive = false; strcpy (homedir, argv[0]); for (i = strlen (homedir)-1; i >= 0; i--) { bool ended = false; if (homedir[i] == '/') ended = true; homedir[i] = '\0'; if (ended) break; } sprintf (db_root, DEFAULT_DB_ROOT); sprintf (import_root, DEFAULT_IMPORT_ROOT); while ((c = getopt (argc, argv, "d:i:l:k:r")) != -1) { switch (c) { case 'd': strcpy (db_root, optarg); break; case 'l': strcpy (homedir, optarg); break; case 'i': strcpy (import_root, optarg); break; case 'k': nice (atoi(optarg)); break; case 'r': log_disable (); interactive_enable (); iactive = true; break; case '?': printf ("Usage:\n"); printf (" ./crossepg_importer [options]\n"); printf ("Options:\n"); printf (" -d db_root crossepg db root folder\n"); printf (" default: %s\n", db_root); printf (" -l homedir home directory\n"); printf (" default: %s\n", homedir); printf (" -i import_root import root folder\n"); printf (" default: %s\n", import_root); printf (" -k nice see \"man nice\"\n"); printf (" -r interactive mode\n"); printf (" -h show this help\n"); return 0; } } while (homedir[strlen (homedir) - 1] == '/') homedir[strlen (homedir) - 1] = '\0'; while (db_root[strlen (db_root) - 1] == '/') db_root[strlen (db_root) - 1] = '\0'; while (import_root[strlen (import_root) - 1] == '/') import_root[strlen (import_root) - 1] = '\0'; log_open (db_root); log_banner ("CrossEPG Importer"); sprintf (import_homedir, "%s/import/", homedir); if (epgdb_open (db_root)) log_add ("EPGDB opened"); else { log_add ("Error opening EPGDB"); epgdb_close (); log_close (); return 0; } epgdb_load (); aliases_make (homedir); if (iactive) interactive_manager (); else { volatile bool useless = false; importer_parse_directory (import_root, db_root, NULL, NULL, NULL, &useless); importer_parse_directory (import_homedir, db_root, NULL, NULL, NULL, &useless); log_add ("Saving data..."); if (epgdb_save (NULL)) log_add ("Data saved"); else log_add ("Error saving data"); } epgdb_clean (); memory_stats (); log_close (); return 0; }
int main (int argc, char **argv) { int c; opterr = 0; char *outputfile; FILE *fd; //char *eventsfile; //bool useless = false; sprintf (db_root, DEFAULT_DB_ROOT); while ((c = getopt (argc, argv, "d:k")) != -1) { switch (c) { case 'd': strcpy (db_root, optarg); break; case 'k': nice (atoi(optarg)); break; case '?': print_help (); return 0; } } if (optind != argc-1) { print_help (); return 0; } else outputfile = argv[argc-1]; while (db_root[strlen (db_root) - 1] == '/') db_root[strlen (db_root) - 1] = '\0'; log_open (db_root); log_banner ("CrossEPG Exporter"); if (epgdb_open (db_root)) log_add ("EPGDB opened (root=%s)", db_root); else { log_add ("Error opening EPGDB"); epgdb_close (); log_close (); return 0; } epgdb_load (); log_add ("Exporting data into %s", outputfile); //log_add ("Exporting data into"); //return 0; fd = fopen (outputfile, "w"); if (fd != NULL) { int count = 0; char *desc, *ldesc, *desc_escaped, *ldesc_escaped; fprintf (fd, "nid, tsid, sid, start time, length, description, long description, iso693, event id, mjd, genre_id, flags, revision\n"); epgdb_channel_t *channel = epgdb_channels_get_first (); while (channel != NULL) { epgdb_title_t *title = channel->title_first; while (title != NULL) { //char row[MAX_ROW_SIZE]; desc = epgdb_read_description (title); ldesc = epgdb_read_long_description (title); desc_escaped = escape_string (desc); ldesc_escaped = escape_string (ldesc); fprintf (fd, "%u, %u, %u, %u, %u, \"%s\", \"%s\", \"%c%c%c\", %u, %u, %u, %u, %u\n", channel->nid, channel->tsid, channel->sid, title->start_time, title->length, desc_escaped, ldesc_escaped, title->iso_639_1, title->iso_639_2, title->iso_639_3, title->event_id, title->mjd, title->genre_id, title->flags, title->revision); count++; _free (desc); _free (ldesc); _free (desc_escaped); _free (ldesc_escaped); title = title->next; } channel = channel->next; } fclose (fd); log_add ("Exported %d events", count); } else log_add ("Cannot open %s", outputfile); epgdb_clean (); memory_stats (); log_close (); return 0; }