void set_game_state(GAME_STATE_TYPE s) { state = s; switch(state) { case GAME_STATE_MENU : set_menu(MENU_GAME); break; case GAME_STATE_BATTLE : set_menu(MENU_BATTLE); init_battle_player(game_battle, game_player); init_enemies(game_battle); break; default : break; } }
file_dialog::file_dialog(display &disp, const std::string& file_path, const std::string& title, bool show_directory_buttons) : gui::dialog(disp, title, file_path, gui::OK_CANCEL), show_directory_buttons_(show_directory_buttons), files_list_(NULL), last_selection_(-1), last_textbox_text_(), chosen_file_(".."), autocomplete_(true) { files_list_ = new gui::file_menu(disp.video(), file_path); const unsigned file_list_height = (disp.h() / 2); const unsigned file_list_width = std::min<unsigned>(files_list_->width(), (disp.w() / 4)); files_list_->set_measurements(file_list_width, file_list_height); files_list_->set_max_height(file_list_height); set_menu(files_list_); get_message().set_text(format_dirname(files_list_->get_directory())); set_textbox(_("File: "), format_filename(file_path), 100); if (show_directory_buttons_) { add_button( new gui::dialog_button(disp.video(), _("Delete File"), gui::button::TYPE_PRESS, gui::DELETE_ITEM), dialog::BUTTON_EXTRA); add_button( new gui::dialog_button(disp.video(), _("New Folder"), gui::button::TYPE_PRESS, gui::CREATE_ITEM), dialog::BUTTON_EXTRA_LEFT); } }
static void up_long_click_handler(ClickRecognizerRef recognizer, void* context) { if (common_long(TOP)) return; set_menu(); }
void PatchPortModule::create_menu() { WidgetFactory::get_widget_derived("object_menu", _menu); _menu->init(_model, true); set_menu(_menu); }
void toggle_statusline(void) { #ifdef MOTIF if ((resource.expert_mode & XPRT_SHOW_STATUSLINE) == 0) XtUnmanageChild(statusline); else XtManageChild(statusline); set_menu(&resource.expert_mode, Act_set_expert_mode, check_resource_expert); #else static Boolean initialized = False; static Boolean statusline_mapped = False; Boolean make_statusline_visible = False; Boolean make_statusline_invisible = False; if (!initialized) { statusline_mapped = (resource.expert_mode & XPRT_SHOW_STATUSLINE) != 0; initialized = True; } if ((resource.expert_mode & XPRT_SHOW_STATUSLINE) == 0) { if (statusline_mapped) make_statusline_invisible = True; } else { if (!statusline_mapped) make_statusline_visible = True; } if (make_statusline_invisible) { XtDestroyWidget(statusline); statusline_mapped = False; } if (make_statusline_visible) { static Dimension window_w, window_h; static Arg arg_wh[] = { {XtNwidth, (XtArgVal) &window_w}, {XtNheight, (XtArgVal) &window_h}, }; #ifdef MOTIF XtGetValues(globals.widgets.main_window, arg_wh, XtNumber(arg_wh)); #else XtGetValues(globals.widgets.vport_widget, arg_wh, XtNumber(arg_wh)); #endif XtVaSetValues(globals.widgets.vport_widget, XtNresizable, (XtArgVal)True, NULL); TRACE_GUI((stderr, "statusline: w %d, h %d", window_w, window_h)); XtVaSetValues(globals.widgets.vport_widget, XtNwidth, (XtArgVal)window_w, XtNheight, (XtArgVal)window_h, NULL); TRACE_GUI((stderr, "after statusline")); create_statusline(); statusline_mapped = True; } #endif /* MOTIF */ }
void toggle_scrollbars(void) { Widget x_bar = XtNameToWidget(globals.widgets.main_window, "HorScrollBar"); Widget y_bar = XtNameToWidget(globals.widgets.main_window, "VertScrollBar"); if ((resource.expert_mode & XPRT_SHOW_SCROLLBARS) == 0) { XtUnmanageChild(x_bar); XtUnmanageChild(y_bar); } else { XtManageChild(x_bar); XtManageChild(y_bar); } set_menu(&resource.expert_mode, Act_set_expert_mode, check_resource_expert); }
void toggle_toolbar(void) { #if !HAVE_XPM statusline_error(STATUS_LONG, "Compiled without XPM support; no toolbar available."); #else if (resource.toolbar_unusable) { statusline_error(STATUS_LONG, "Toolbar pixmap file not found; toolbar is disabled."); return; } if ((resource.expert_mode & XPRT_SHOW_TOOLBAR) == 0) XtUnmanageChild(tool_bar_frame); else XtManageChild(tool_bar_frame); set_menu(&resource.expert_mode, Act_set_expert_mode, check_resource_expert); #endif /* not HAVE_XPM */ }
void TEventWindow::set_menu(char *res) //------------------------------------ { if (m_hmenu) DeleteObject(m_hmenu); set_menu(LoadMenu(hInst,res)); }
bool loop(int argc, char** argv) { char home[256]; //NEED TO MAKE THIS DYNAMIC strcpy(home, getenv("HOME")); //parse the config file settings.parse_config(strcat(home, config_file)); //load the controls into list ElementList list(settings.card); list_ptr = &list; //reorder the controls to the order specified in the config file settings.reorder_list(&list); //set the scale list.set_scale((Element::scale_t)settings.scaling); //set the auto_mute list.set_auto_mute(settings.auto_mute); //initialize gtk gtk_init(&argc, &argv); //set up the tray_slider that goes in the tray if (settings.enable_tray_icon){ GtkWidget *tray_frame; tray_frame = gtk_alignment_new(0.5,0.0,0,0); settings.tray_slider = new retro_slider; settings.set_tray_slider(&list); settings.apply_to_tray_slider(settings.tray_slider); if (list.num_elems > 0){ settings.tray_slider->init(tray_frame, (void*)settings.tray_control, &Element::get_callback, &Element::set_callback, (settings.tray_control->values > 1)); } else { settings.tray_control = NULL; } //set up the small window that holds the tray_slider settings.slider_window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_resizable(GTK_WINDOW(settings.slider_window), false); gtk_window_set_decorated(GTK_WINDOW(settings.slider_window), false); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(settings.slider_window), true); gtk_window_set_skip_pager_hint(GTK_WINDOW(settings.slider_window), true); gtk_widget_set_usize(settings.slider_window, settings.tray_slider->width, settings.tray_slider->height); //don't want accidental closure of the slider window to destroy the window g_signal_connect(settings.slider_window, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); //want the widow to go away when it loses focus g_signal_connect(settings.slider_window, "focus-out-event", G_CALLBACK (gtk_widget_hide), NULL); gtk_container_add( GTK_CONTAINER(settings.slider_window), tray_frame ); //we want it hidden by default, but it must be shown at least once or else scrolling over the icon will cause a hang gtk_widget_show_all(settings.slider_window); gtk_widget_hide_all(settings.slider_window); //set up tray icon #if GTK_CHECK_VERSION(2,16,0) settings.tray_icon = gtk_status_icon_new(); gtk_status_icon_set_from_file(settings.tray_icon, VOL_MUTED_IMAGE); #else settings.tray_icon = GTK_WIDGET(egg_tray_icon_new("Retrovol Tray Icon")); //set the background color bool enable_tray_icon_background_color = settings.enable_tray_icon_background_color; GdkColor bg_color; char bg_color_str[8]; if (cmdline_enable_bg_color){ enable_tray_icon_background_color = true; strcpy(bg_color_str, cmdline_bg_color); } else if (settings.enable_tray_icon_background_color){ settings.nftoh(settings.tray_icon_background_color, bg_color_str); } if (enable_tray_icon_background_color){ if (gdk_color_parse(bg_color_str, &bg_color)){ GtkStyle *style = gtk_style_copy(gtk_widget_get_style(settings.tray_icon)); style->bg[GTK_STATE_NORMAL] = bg_color; gtk_widget_set_style(settings.tray_icon, style); } else { fprintf(stderr, _("Error: Failed to set background color to %s\n"), bg_color_str); } } //set up the images settings.tray_icon_image = gtk_image_new(); gtk_container_add( GTK_CONTAINER(settings.tray_icon), settings.tray_icon_image ); gtk_image_set_from_file(GTK_IMAGE(settings.tray_icon_image), VOL_MEDIUM_IMAGE); //set the event mask gtk_widget_set_events (settings.tray_icon, GDK_BUTTON_PRESS_MASK | GDK_SCROLL_MASK); #endif //signals g_signal_connect(G_OBJECT(settings.tray_icon), "button_press_event", G_CALLBACK (&tray_button_press_event_callback), settings.slider_window); if (settings.tray_control){ g_signal_connect(G_OBJECT(settings.tray_icon), "scroll_event", G_CALLBACK (&retro_slider::scroll_event_callback), settings.tray_slider); } #if GTK_CHECK_VERSION(2,16,0) //make icon visible gtk_status_icon_set_visible(settings.tray_icon, true); #else //handle situations where the icon's window dies, such as due to the tray itself exiting g_signal_connect(G_OBJECT(settings.tray_icon), "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); //make icon visible gtk_widget_show_all(settings.tray_icon); #endif //set up the popup menu (the function checks if it should actually do anything) set_menu(); } //set up the window settings.main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); //gtk_window_set_position(GTK_WINDOW(settings.main_window), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(settings.main_window), settings.window_width, settings.window_height); gtk_window_set_title(GTK_WINDOW(settings.main_window), "Retrovol"); restore_posdim(); g_signal_connect(settings.main_window, "configure-event", G_CALLBACK (save_posdim), NULL); //if the tray icon is enabled, we want the window to hide rather than closing if (settings.enable_tray_icon){ g_signal_connect(settings.main_window, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); } //make the over_box, which will hold stuff like the menu, status bar, and the actual content in the middle GtkWidget *over_box; over_box = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(settings.main_window), over_box); //define the menu GtkItemFactoryEntry menu_items_1[] = { { (gchar*)_("/_File"), NULL, NULL, 0, (gchar*)"<Branch>" }, { (gchar*)_("/File/_Configure"), (gchar*)"<CTRL>C", G_CALLBACK(configure), 0, (gchar*)"<StockItem>", GTK_STOCK_EXECUTE }, { (gchar*)_("/File/_Quit"), (gchar*)"<CTRL>Q", G_CALLBACK(close_window), 0, (gchar*)"<StockItem>", GTK_STOCK_QUIT }, }; gint nmenu_items_1 = sizeof (menu_items_1) / sizeof (menu_items_1[0]); GtkItemFactoryEntry menu_items_2[] = { { (gchar*)_("/_File"), NULL, NULL, 0, (gchar*)"<Branch>" }, { (gchar*)_("/File/_Configure"), (gchar*)"<CTRL>C", G_CALLBACK(configure), 0, (gchar*)"<StockItem>", GTK_STOCK_EXECUTE }, { (gchar*)_("/File/_Exit completely"), (gchar*)"<CTRL>E", G_CALLBACK(gtk_main_quit), 0, (gchar*)"<StockItem>", GTK_STOCK_QUIT }, { (gchar*)_("/File/_Quit"), (gchar*)"<CTRL>Q", G_CALLBACK(close_window), 0, (gchar*)"<StockItem>", GTK_STOCK_QUIT }, }; gint nmenu_items_2 = sizeof (menu_items_2) / sizeof (menu_items_2[0]); GtkItemFactoryEntry *menu_items; gint nmenu_items; //if the tray menu is enabled, don't have the "Exit" entry in the main menu if (settings.enable_tray_menu){ menu_items = menu_items_1; nmenu_items = nmenu_items_1; } else { menu_items = menu_items_2; nmenu_items = nmenu_items_2; } //build the menu GtkWidget *menubar; menubar = get_menubar_menu(settings.main_window, menu_items, nmenu_items, "<RetrovolMain>"); gtk_box_pack_start(GTK_BOX(over_box), menubar, FALSE, TRUE, 0); //use a scrolled window GtkWidget *scrolled_window; scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(over_box), scrolled_window); //put the stuff into a viewport manually, so we can specify that it should have no shadow GtkWidget *viewport; viewport = gtk_viewport_new(NULL, NULL); gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); gtk_container_add(GTK_CONTAINER(scrolled_window), viewport); //and create an Hbox to hold all the stuff GtkWidget *hbox; if (settings.vertical){ hbox = gtk_hbox_new(TRUE, 2); gtk_container_add(GTK_CONTAINER(viewport), hbox); } else { hbox = gtk_vbox_new(TRUE, 2); gtk_container_add(GTK_CONTAINER(viewport), hbox); } //add the sliders retro_slider *sliders = new retro_slider[list.num_items]; for(int i=0; i<list.num_items; i++){ //use a vbox w/ slider on top and label on bottom GtkWidget *vbox; if (settings.vertical){ vbox = gtk_vbox_new(FALSE, 2); } else { vbox = gtk_hbox_new(FALSE, 2); } gtk_box_pack_start(GTK_BOX(hbox), vbox, false, false, 0); if (strcmp(list.items[i]->type, "INTEGER") == 0){ //integers need sliders //the rslider pseudo-widget likes to be inside a container, lets use a GtkAlignment GtkWidget *frame; if (settings.vertical){ frame = gtk_alignment_new(0.5,0.0,0,0); gtk_box_pack_start(GTK_BOX(vbox), frame, false, false, 0); } else { frame = gtk_alignment_new(0.0,0.5,0,0); gtk_box_pack_end(GTK_BOX(vbox), frame, false, false, 0); } //make the slider and associate with a control settings.apply_to_slider(&sliders[i]); sliders[i].init(frame, (void*)list.items[i], &Element::get_callback, &Element::set_callback, (list.items[i]->values > 1)); } else if (strcmp(list.items[i]->type, "BOOLEAN") == 0){ //booleans need checkboxes GtkWidget *alignment; if (settings.vertical){ alignment = gtk_alignment_new(0.5,1.0,0,0); gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0); } else { alignment = gtk_alignment_new(1.0,0.5,0,0); gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0); } GtkWidget *chkbx; chkbx = gtk_check_button_new(); //set it to the current state gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbx), (bool)list.items[i]->get()); //bind to the toggle_checkbox function Element* ptr = list.items[i]; g_signal_connect(GTK_TOGGLE_BUTTON(chkbx), "toggled", G_CALLBACK (toggle_checkbox), ptr); g_signal_connect_after(GTK_TOGGLE_BUTTON(chkbx), "expose-event", G_CALLBACK (refresh_checkbox), ptr); gtk_container_add(GTK_CONTAINER(alignment), chkbx); } else if (strcmp(list.items[i]->type, "ENUMERATED") == 0){ GtkWidget *alignment; if (settings.vertical){ alignment = gtk_alignment_new(0.5,0.5,0,0); gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0); } else { alignment = gtk_alignment_new(1.0,0.5,0,0); gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0); } //insert a combobox with the different options GtkWidget *combo_box; combo_box=gtk_combo_box_new_text(); for(unsigned int n=0; n<list.items[i]->number_of_enums; n++){ gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), list.items[i]->enums[n]); } gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), list.items[i]->get()); //bind to the change_combo_box function g_signal_connect(GTK_COMBO_BOX(combo_box), "changed", G_CALLBACK (change_combo_box), list.items[i]); gtk_container_add(GTK_CONTAINER(alignment), combo_box); } //add a checkbox for sliders that are muteable if (list.items[i]->switch_id >= 0){ GtkWidget *alignment; if (settings.vertical){ alignment = gtk_alignment_new(0.5,1.0,0,0); gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0); } else { alignment = gtk_alignment_new(1.0,0.5,0,0); gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0); } GtkWidget *chkbx; chkbx = gtk_check_button_new(); //set it to the current state gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbx), (bool)list.elems[list.items[i]->switch_id].get()); //bind to the toggle_checkbox function g_signal_connect(GTK_TOGGLE_BUTTON(chkbx), "toggled", G_CALLBACK (toggle_checkbox), &(list.elems[list.items[i]->switch_id])); g_signal_connect_after(GTK_TOGGLE_BUTTON(chkbx), "expose-event", G_CALLBACK (refresh_checkbox), &(list.elems[list.items[i]->switch_id])); gtk_container_add(GTK_CONTAINER(alignment), chkbx); } //display the name of the control GtkWidget *alignment; char wrapped[256]; if (settings.vertical){ alignment = gtk_alignment_new(0.5,1.0,0,0); gtk_box_pack_end(GTK_BOX(vbox), alignment, false, false, 0); word_wrap(wrapped, list.items[i]->short_name); } else { alignment = gtk_alignment_new(1.0,0.5,0,0); gtk_box_pack_start(GTK_BOX(vbox), alignment, false, false, 0); strcpy(wrapped, list.items[i]->short_name); } GtkWidget *label; label = gtk_label_new(wrapped); gtk_container_add(GTK_CONTAINER(alignment), label); } //finish the window stuff if (!start_hidden){ gtk_widget_show_all(settings.main_window); } g_signal_connect(settings.main_window, "destroy", G_CALLBACK (gtk_main_quit), NULL); //add some periodic refreshment to keep the icon and window up-to-date #if GTK_CHECK_VERSION(2,14,0) int timeout = g_timeout_add_seconds(1, update, NULL); #else //this is less efficient than g_timeout_add_seconds() int timeout = g_timeout_add(1000, update, NULL); #endif //finished with gtk setup gtk_main(); //stop the timeout g_source_remove(timeout); //have the window shown again if it was open before we restarted if (settings.resume_main){ settings.resume_main = false; start_hidden = false; } else { start_hidden = true; } return(settings.restart); }
//update the tray-icon and refresh the window gboolean update(gpointer data){ bool state = true; if (settings.enable_tray_icon){ if (settings.tray_control){ int val = settings.tray_control->get(); char tooltiptext[32]; if (settings.tray_control->switch_id >= 0){ state = (bool)list_ptr->elems[settings.tray_control->switch_id].get(); } if (state){ int image = 2+3*val/100; if (image > 4){ image=4; } else if (image < 0){ image=0; } else if (val == 0){ image=1; } sprintf(tooltiptext, _("Volume: %d%%"), val); #if GTK_CHECK_VERSION(2,16,0) gtk_status_icon_set_from_file(settings.tray_icon, settings.icon_file_names[image]); #else gtk_image_set_from_file(GTK_IMAGE(settings.tray_icon_image), settings.icon_file_names[image]); #endif } else { sprintf(tooltiptext, _("Volume: Muted")); #if GTK_CHECK_VERSION(2,16,0) gtk_status_icon_set_from_file(settings.tray_icon, settings.icon_file_names[0]); #else gtk_image_set_from_file(GTK_IMAGE(settings.tray_icon_image), settings.icon_file_names[0]); #endif } #if GTK_CHECK_VERSION(2,16,0) gtk_status_icon_set_tooltip_text(settings.tray_icon, tooltiptext); #elif GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(settings.tray_icon_image, tooltiptext); #else static GtkTooltips *tooltips = gtk_tooltips_new(); gtk_tooltips_set_tip(tooltips, settings.tray_icon_image, tooltiptext, NULL); #endif //if the tray was moved, update the menu GdkScreen *screen = gdk_screen_get_default(); int icon_x,icon_y; #if GTK_CHECK_VERSION(2,16,0) GdkScreen *screen_from_tray; GdkRectangle area; GtkOrientation orientation; if (gtk_status_icon_get_geometry(settings.tray_icon, &screen_from_tray, &area, &orientation)){ icon_x = area.x; icon_y = area.y; } else { icon_x = gdk_screen_get_width(screen); icon_y = gdk_screen_get_height(screen); } #else gtk_window_get_position(GTK_WINDOW(settings.tray_icon), &icon_x, &icon_y); #endif if ((bool)(icon_y > gdk_screen_get_height(screen)/2) ^ tray_at_bottom){ //the current status does not match the previous status, so update the menu set_menu(); } //in case the icon was hidden due to the tray exiting, try reshowing it again #if GTK_CHECK_VERSION(2,16,0) gtk_status_icon_set_visible(settings.tray_icon, true); #else gtk_widget_show_all(settings.tray_icon); #endif } } if (GTK_WIDGET_VISIBLE(settings.main_window)){ gtk_widget_queue_draw(settings.main_window); } if (GTK_WIDGET_VISIBLE(settings.slider_window)){ gtk_widget_queue_draw(settings.slider_window); } return(true); }
statistics_dialog::statistics_dialog(game_display &disp, const std::string& title, const unsigned int team, const std::string& team_id, const std::string& player) : dialog(disp, title, "", gui::NULL_DIALOG), detail_btn_(new gui::standard_dialog_button(disp.video(), _("Details"), 0 , false)), player_name_(player), stats_(), team_num_(team), unit_count_(5,0) { add_button(detail_btn_, gui::dialog::BUTTON_EXTRA); add_button(new gui::standard_dialog_button(disp.video(), _("Close"), 1, true), gui::dialog::BUTTON_STANDARD); stats_ = statistics::calculate_stats(0, team_id); int n, cost; std::vector<std::string> items; // Prepare the menu items { std::stringstream str; n = statistics::sum_str_int_map(stats_.recruits); cost = stats_.recruit_cost; unit_count_[0] = n; str << _("Recruits") << COLUMN_SEPARATOR << n << COLUMN_SEPARATOR << COLUMN_SEPARATOR << IMAGE_PREFIX << "themes/gold-t.png" << COLUMN_SEPARATOR << cost; items.push_back(str.str()); } { std::stringstream str; n = statistics::sum_str_int_map(stats_.recalls); cost = stats_.recall_cost; unit_count_[1] = n; str << _("Recalls") << COLUMN_SEPARATOR << n << COLUMN_SEPARATOR << COLUMN_SEPARATOR << IMAGE_PREFIX << "themes/gold-t.png" << COLUMN_SEPARATOR << cost; items.push_back(str.str()); } { std::stringstream str; n = statistics::sum_str_int_map(stats_.advanced_to); unit_count_[2] = n; str << _("Advancements") << COLUMN_SEPARATOR << n; items.push_back(str.str()); } { std::stringstream str; n = statistics::sum_str_int_map(stats_.deaths); unit_count_[3] = n; cost = statistics::sum_cost_str_int_map(stats_.deaths); str << _("Losses") << COLUMN_SEPARATOR << n << COLUMN_SEPARATOR << COLUMN_SEPARATOR << IMAGE_PREFIX << "themes/gold-t.png" << COLUMN_SEPARATOR << cost; items.push_back(str.str()); } { std::stringstream str; n = statistics::sum_str_int_map(stats_.killed); unit_count_[4] = n; cost = statistics::sum_cost_str_int_map(stats_.killed); str << _("Kills") << COLUMN_SEPARATOR << n << COLUMN_SEPARATOR << COLUMN_SEPARATOR << IMAGE_PREFIX << "themes/gold-t.png" << COLUMN_SEPARATOR << cost; items.push_back(str.str()); } items.push_back(""); { std::stringstream str; str << font::BOLD_TEXT << _("Damage") << COLUMN_SEPARATOR << _("Overall") << COLUMN_SEPARATOR << COLUMN_SEPARATOR << COLUMN_SEPARATOR << _("This Turn"); items.push_back(str.str()); } statistics_dialog::make_damage_line(items, _("Inflicted"), stats_.damage_inflicted, stats_.expected_damage_inflicted, stats_.turn_damage_inflicted, stats_.turn_expected_damage_inflicted); statistics_dialog::make_damage_line(items, _("Taken"), stats_.damage_taken, stats_.expected_damage_taken, stats_.turn_damage_taken, stats_.turn_expected_damage_taken); set_menu(items); }
void MenuManager::set_menu(int id) { set_menu(MenuStorage::instance().create(static_cast<MenuStorage::MenuId>(id))); }
static int set_battle_state( BATTLE *battle, BATTLE_ACTOR *ba, BATTLE_STATE state, void *arg ) { SPELL *spell; if (arg != NULL) { #ifdef DEBUG printf("Set battle argument: %x\n", (int) arg); #endif ba->arg = arg; } switch(state) { case BATTLE_STATE_WAIT: set_menu(MENU_BATTLE); break; case BATTLE_STATE_MOVE: if (init_battle_steps(battle, ba) == 0) return 0; break; case BATTLE_STATE_WALK: break; case BATTLE_STATE_ATTACK: if (init_battle_attack(battle, ba) == 0) return 0; break; case BATTLE_STATE_STRIKE: init_battle_strike(battle); break; case BATTLE_STATE_SELECT_MAGIC: set_menu(MENU_MAGIC); break; case BATTLE_STATE_TARGET: if ((spell = get_player_spell(ba->player, (int) arg)) == NULL) return 0; ba->arg = spell; if (init_battle_target(battle, ba, is_spell_support(spell)) == 0) return 0; break; default: free_battle_steps(ba); free_battle_attack(ba); free_battle_target(ba); break; } ba->state = state; return 1; }
/** * @brief Volume control from the Menu. * * This function uses the Alsa API to get and set * the volume for the master channel. * The use inputs a two digit number to set the volume, * or presses the 'F' and 'B' buttons to adjust the * value incrementally. * * The volume control behaves differently from the menu, * so menu flag is set to FALSE. * * @param Void. * @return Void. */ void volume(void){ static long output = 50; int count = 0; char button_read = FALSE; // Local snapshot of Global 'Button' int state_read = SUBMENU_SELECT; get_volume(&output); display_volume(output); set_menu(FALSE); while(alive && state_read == SUBMENU_SELECT){ if(count == 0){ display_volume(output); } pthread_mutex_lock(&button_Mutex); pthread_cond_wait(&button_Signal, &button_Mutex); // Wait for press button_read = button; // Read the button pressed pthread_mutex_unlock(&button_Mutex); get_volume(&output); if(count == 0){ display_volume(output); } pthread_mutex_lock(&state_Mutex); state_read = state; pthread_mutex_unlock(&state_Mutex); if(state_read == EMERGENCY || alive == FALSE){ set_menu(FALSE); // in display.c break; // Get out if there's an emergency } /* Button has been pressed. Now what? */ switch(button_read){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if(count == 0){ reset_buffers(); } if(++count <= 2){ insert_char(button_read); } if(count == 2){ output = (long)atoi(input_buffer); SetAlsaVolume(output); reset_buffers(); count = 0; } break; case 'D': if(count){ count--; delete_char(); } break; case 'B': // Down if(--output >= 0){ SetAlsaVolume(output); printd("output: %lu\n",output); } else{ output = 0; printd("output: MIN\n"); } break; case 'F': // Up if(++output < 100){ SetAlsaVolume(output); printd("output: %lu\n",output); } else{ output = 99; printd("output: MAX\n"); } break; /* Accept, Cancel or Enter * The ACE case ;) */ case 'A': case 'C': case 'E': pthread_mutex_lock(&state_Mutex); reset_buffers(); state = MENU_SELECT; // Go back to menu state_read = state; pthread_mutex_unlock(&state_Mutex); set_menu(TRUE); break; default: break; } } return; }