void sim_setup_menus(sim_state_t *state) { menu_t *cam_menu = menu_new(NULL, "Camera", NULL, NULL); sg_scene_t *scene = sg_window_get_scene(state->win, 0); size_t object_count = sg_scene_get_object_count(scene); const sg_object_t **objects = sg_scene_get_objects(scene); for (int i = 0 ; i < object_count ; i++) { menu_new(cam_menu, sg_object_get_name(objects[i]), menu_camera, (void*)objects[i]); } }
/* * Choose and create an instance of an object kind */ static void wiz_create_artifact(void) { size_t num, i; menu_type *menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_menu); tval_desc *a_tvals; choose_artifact = TRUE; a_tvals = C_ZNEW(N_ELEMENTS(tvals), tval_desc); for (num = i = 0; i < N_ELEMENTS(tvals); i++) { /* Don't show tvals with no artifacts. */ if (!(tvals[i].can_be_artifact)) continue; /* Increment number of items in list. */ a_tvals[num++] = tvals[i]; } menu->selections = all_letters; menu->title = "What kind of artifact?"; screen_save(); clear_from(0); menu_setpriv(menu, num, a_tvals); menu_layout(menu, &wiz_create_item_area); menu_select(menu, 0, FALSE); screen_load(); FREE(a_tvals); }
/** * Display list of curses to choose from */ int curse_menu(struct object *obj, char *dice_string) { menu_iter menu_f = { 0, 0, get_curse_display, get_curse_action, 0 }; struct menu *m = menu_new(MN_SKIN_SCROLL, &menu_f); int row; unsigned int length = 0; int i, count = 0; size_t array_size = z_info->curse_max * sizeof(struct curse_menu_data); struct curse_menu_data *available = mem_zalloc(array_size); static region area = { 20, 1, -1, -2 }; /* Count and then list the curses */ for (i = 1; i < z_info->curse_max; i++) { if ((obj->known->curses[i].power > 0) && (obj->known->curses[i].power < 100) && player_knows_curse(player, i)) { available[count].index = i; available[count].power = obj->curses[i].power; length = MAX(length, strlen(curses[i].name) + 13); count++; } } if (!count) { mem_free(available); return 0; } /* Set up the menu */ menu_setpriv(m, count, available); m->header = format(" Remove which curse (spell strength %s)?", dice_string); m->selections = lower_case; m->flags = (MN_PVT_TAGS); m->browse_hook = curse_menu_browser; /* Set up the item list variables */ selection = 0; /* Set up the menu region */ area.page_rows = m->count + 2; area.row = 1; area.col = (Term->wid - 1 - length) / 2; if (area.col <= 3) area.col = 0; area.width = MAX(length + 1, strlen(m->header)); for (row = area.row; row < area.row + area.page_rows; row++) prt("", row, MAX(0, area.col - 1)); menu_layout(m, &area); /* Choose */ menu_select(m, 0, true); /* Clean up */ mem_free(available); mem_free(m); /* Result */ return selection; }
/* * Choose and create an instance of an object kind */ static void wiz_create_item(void) { int tvals[TV_MAX]; size_t i, n; menu_type *menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_menu); menu->selections = all_letters; menu->title = "What kind of object?"; /* Make a list of all tvals for the filter */ for (i = 0, n = 0; i < TV_MAX; i++) { if (!kb_info[i].name) continue; tvals[n++] = i; } screen_save(); clear_from(0); menu_setpriv(menu, TV_MAX, kb_info); menu_set_filter(menu, tvals, n); menu_layout(menu, &wiz_create_item_area); menu_select(menu, 0, FALSE); screen_load(); /* Redraw map */ p_ptr->redraw |= (PR_MAP | PR_ITEMLIST); handle_stuff(p_ptr); }
void ex_cmd_init() { key_tbl.tbl = key_defaults; key_tbl.cmd_idx = cmd_idx; key_tbl.maxsize = LENGTH(key_defaults); input_setup_tbl(&key_tbl); ex.menu = menu_new(); }
/** * Display list of curses to choose from */ struct curse *curse_menu(struct object *obj) { menu_iter menu_f = { 0, 0, get_curse_display, get_curse_action, 0 }; struct menu *m = menu_new(MN_SKIN_SCROLL, &menu_f); int row; unsigned int length = 0; int count = 0; struct curse *curse = obj->curses; struct curse **available; static region area = { 20, 1, -1, -2 }; /* Count and then list the curses */ while (curse) { count++; curse = curse->next; } if (!count) { return NULL; } available = mem_zalloc(count * sizeof(struct curse *)); count = 0; for (curse = obj->curses; curse; curse = curse->next) { available[count++] = curse; length = MAX(length, strlen(curse->name)); } /* Set up the menu */ menu_setpriv(m, count, available); m->header = "Remove which curse?"; m->selections = lower_case; m->flags = (MN_PVT_TAGS); m->browse_hook = curse_menu_browser; /* Set up the item list variables */ selection = NULL; /* Set up the menu region */ area.page_rows = m->count + 1; area.row = 1; area.col = (Term->wid - 1 - length) / 2; if (area.col <= 3) area.col = 0; area.width = MAX(length + 1, strlen(m->header)); for (row = area.row; row < area.row + area.page_rows; row++) prt("", row, MAX(0, area.col - 1)); menu_layout(m, &area); /* Choose */ menu_select(m, 0, true); /* Clean up */ mem_free(m); /* Result */ return selection; }
void client_list_combined_menu_startup(gboolean reconfig) { if (!reconfig) client_add_destroy_notify(client_dest, NULL); combined_menu = menu_new(MENU_NAME, _("Windows"), TRUE, NULL); menu_set_update_func(combined_menu, self_update); menu_set_cleanup_func(combined_menu, self_cleanup); menu_set_execute_func(combined_menu, menu_execute); }
void client_list_menu_startup(gboolean reconfig) { ObMenu *menu; if (!reconfig) client_add_destroy_notify(client_dest, NULL); menu = menu_new(MENU_NAME, _("Desktops"), TRUE, NULL); menu_set_update_func(menu, self_update); menu_set_cleanup_func(menu, self_cleanup); menu_set_execute_func(menu, self_execute); }
/** * Display list of svals to be ignored. */ static bool sval_menu(int tval, const char *desc) { struct menu *menu; region area = { 1, 2, -1, -1 }; ignore_choice *choices; int n_choices = ignore_collect_kind(tval, &choices); if (!n_choices) return false; /* Sort by name in ignore menus except for categories of items that are * aware from the start */ switch (tval) { case TV_LIGHT: case TV_MAGIC_BOOK: case TV_PRAYER_BOOK: case TV_DRAG_ARMOR: case TV_GOLD: /* leave sorted by sval */ break; default: /* sort by name */ sort(choices, n_choices, sizeof(*choices), cmp_ignore); } /* Save the screen and clear it */ screen_save(); clear_from(0); /* Help text */ prt(format("Ignore the following %s:", desc), 0, 0); /* Run menu */ menu = menu_new(MN_SKIN_COLUMNS, &ignore_sval_menu); menu_setpriv(menu, n_choices, choices); menu->cmd_keys = "Tt"; menu_layout(menu, &area); menu_set_cursor_x_offset(menu, 1); /* Place cursor in brackets. */ menu_select(menu, 0, false); /* Free memory */ mem_free(choices); /* Load screen */ screen_load(); return true; }
static void wiz_gf_demo(void) { menu_type *m = menu_new(MN_SKIN_SCROLL, &gf_iter); region loc = { 0, 0, 0, 0 }; menu_setpriv(m, GF_MAX, NULL); m->title = "GF_ types display"; menu_layout(m, &loc); screen_save(); clear_from(0); menu_select(m, 0, FALSE); screen_load(); }
/* * Display list of svals to be squelched. */ static bool sval_menu(int tval, const char *desc) { menu_type *menu; region area = { 1, 2, -1, -1 }; squelch_choice *choices; int n_choices = squelch_collect_kind(tval, &choices); if (!n_choices) return false; /* sort by name in squelch menus except for categories of items that are aware from the start */ switch (tval) { case TV_LIGHT: case TV_MAGIC_BOOK: case TV_PRAYER_BOOK: case TV_DRAG_ARMOR: case TV_GOLD: /* leave sorted by sval */ break; default: /* sort by name */ sort(choices, n_choices, sizeof(*choices), cmp_squelch); } /* Save the screen and clear it */ screen_save(); clear_from(0); /* Help text */ prt(format("Squelch the following %s:", desc), 0, 0); /* Run menu */ menu = menu_new(MN_SKIN_COLUMNS, &squelch_sval_menu); menu_setpriv(menu, n_choices, choices); menu_layout(menu, &area); menu_select(menu, 0, false); /* Free memory */ FREE(choices); /* Load screen */ screen_load(); return true; }
/* * Choose and create an instance of an object kind */ static void wiz_create_item(void) { menu_type *menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_menu); menu->selections = all_letters; menu->title = "What kind of object?"; screen_save(); clear_from(0); menu_setpriv(menu, N_ELEMENTS(tvals), tvals); menu_layout(menu, &wiz_create_item_area); menu_select(menu, 0); screen_load(); }
/* * create the in game menu */ void game_menu_create () { if (menu != NULL) return; menu = menu_new ("Gamemenu", 300, 150); menu_create_button (menu, "Back to the Game", -1, 50, 200, 1); if (GT_SP || GT_MP_PTPM) menu_create_button (menu, "End this Round", -1, 80, 200, 2); menu_create_button (menu, "Quit the Game", -1, 110, 200, 3); menu_focus_id (menu, 1); menu->looprunning = 1; };
/** * Interact with some options */ static void option_toggle_menu(const char *name, int page) { int i; struct menu *m = menu_new(MN_SKIN_SCROLL, &option_toggle_iter); /* for all menus */ m->prompt = "Set option (y/n/t), '?' for information"; m->cmd_keys = "?YyNnTt"; m->selections = "abcdefghijklmopqrsuvwxz"; m->flags = MN_DBL_TAP; /* We add 10 onto the page amount to indicate we're at birth */ if (page == OPT_PAGE_BIRTH) { m->prompt = "You can only modify these options at character birth. '?' for information"; m->cmd_keys = "?"; m->flags = MN_NO_TAGS; } else if (page == OPT_PAGE_BIRTH + 10) { page -= 10; } /* for this particular menu */ m->title = name; /* Find the number of valid entries */ for (i = 0; i < OPT_PAGE_PER; i++) { if (option_page[page][i] == OPT_none) break; } /* Set the data to the player's options */ menu_setpriv(m, OPT_MAX, &op_ptr->opt); menu_set_filter(m, option_page[page], i); menu_layout(m, &SCREEN_REGION); /* Run the menu */ screen_save(); clear_from(0); menu_select(m, 0, false); screen_load(); mem_free(m); }
static bool wiz_create_item_action(menu_type *m, const ui_event *e, int oid) { ui_event ret; menu_type *menu; char buf[80]; object_kind *choice[60]; int n_choices; int i; if (e->type != EVT_SELECT) return TRUE; for (n_choices = 0, i = 1; (n_choices < 60) && (i < z_info->k_max); i++) { object_kind *kind = &k_info[i]; if (kind->tval != oid || of_has(kind->flags, OF_INSTA_ART)) continue; choice[n_choices++] = kind; } screen_save(); clear_from(0); menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_submenu); menu->selections = all_letters; object_base_name(buf, sizeof buf, oid, TRUE); menu->title = string_make(format("What kind of %s?", buf)); menu_setpriv(menu, n_choices, choice); menu_layout(menu, &wiz_create_item_area); ret = menu_select(menu, 0, FALSE); screen_load(); string_free((char *)menu->title); return (ret.type == EVT_ESCAPE); }
bool wiz_create_item_action(menu_type *m, const ui_event_data *e, int oid) { ui_event_data ret; menu_type *menu; int choice[60]; int n_choices; int i; if (e->type != EVT_SELECT) return TRUE; for (n_choices = 0, i = 1; (n_choices < 60) && (i < z_info->k_max); i++) { object_kind *kind = &k_info[i]; if (kind->tval != tvals[oid].tval || of_has(kind->flags, OF_INSTA_ART)) continue; choice[n_choices++] = i; } screen_save(); clear_from(0); menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_submenu); menu->selections = all_letters; menu->title = format("What kind of %s?", tvals[oid].desc); menu_setpriv(menu, n_choices, choice); menu_layout(menu, &wiz_create_item_area); ret = menu_select(menu, 0); screen_load(); return (ret.type == EVT_ESCAPE); }
/* * Display a list of command types, allowing the user to select one. */ static struct cmd_info *textui_action_menu_choose(void) { region area = { 21, 5, 37, 6 }; struct cmd_info *chosen_command = NULL; if (!command_menu) command_menu = menu_new(MN_SKIN_SCROLL, &command_menu_iter); menu_setpriv(command_menu, N_ELEMENTS(cmds_all) - 1, &chosen_command); menu_layout(command_menu, &area); /* Set up the screen */ screen_save(); window_make(19, 4, 58, 11); menu_select(command_menu, 0, TRUE); screen_load(); return chosen_command; }
static gboolean self_update(ObMenuFrame *frame, gpointer data) { ObMenu *menu = frame->menu; guint i; menu_clear_entries(menu); while (desktop_menus) { menu_free(desktop_menus->data); desktop_menus = g_slist_delete_link(desktop_menus, desktop_menus); } for (i = 0; i < screen_num_desktops; ++i) { ObMenu *submenu; gchar *name = g_strdup_printf("%s-%u", MENU_NAME, i); DesktopData *ddata = g_slice_new(DesktopData); ddata->desktop = i; submenu = menu_new(name, screen_desktop_names[i], FALSE, ddata); menu_set_update_func(submenu, desk_menu_update); menu_set_execute_func(submenu, desk_menu_execute); menu_set_destroy_func(submenu, desk_menu_destroy); menu_add_submenu(menu, i, name); g_free(name); desktop_menus = g_slist_append(desktop_menus, submenu); } if (config_menu_manage_desktops) { menu_add_separator(menu, SEPARATOR, NULL); menu_add_normal(menu, ADD_DESKTOP, _("_Add new desktop"), NULL, TRUE); menu_add_normal(menu, REMOVE_DESKTOP, _("_Remove last desktop"), NULL, TRUE); } return TRUE; /* always show */ }
/** Create and initialise a spell menu, given an object and a validity hook */ static menu_type *spell_menu_new(const object_type * o_ptr, bool(*is_valid) (int spell)) { menu_type *m = menu_new(MN_SKIN_SCROLL, &spell_menu_iter); struct spell_menu_data *d = mem_alloc(sizeof *d); region loc = { -65, 1, 65, -99 }; /* collect spells from object */ d->n_spells = spell_collect_from_book(o_ptr, d->spells); if (d->n_spells == 0 || !spell_okay_list(is_valid, d->spells, d->n_spells)) { mem_free(m); mem_free(d); return NULL; } /* copy across private data */ d->is_valid = is_valid; d->selected_spell = -1; d->browse = FALSE; d->book_sval = o_ptr->sval; menu_setpriv(m, d->n_spells, d); /* set flags */ m->header = "Name Lv Mana Fail Info"; m->flags = MN_CASELESS_TAGS; m->selections = lower_case; m->browse_hook = spell_menu_browser; /* set size */ loc.page_rows = d->n_spells + 1; menu_layout(m, &loc); return m; }
/** * Create and initialise a spell menu, given an object and a validity hook */ static struct menu *spell_menu_new(const struct object *obj, bool (*is_valid)(int spell_index)) { struct menu *m = menu_new(MN_SKIN_SCROLL, &spell_menu_iter); struct spell_menu_data *d = mem_alloc(sizeof *d); region loc = { -60, 1, 60, -99 }; /* collect spells from object */ d->n_spells = spell_collect_from_book(obj, &d->spells); if (d->n_spells == 0 || !spell_okay_list(is_valid, d->spells, d->n_spells)){ mem_free(m); mem_free(d); return NULL; } /* Copy across private data */ d->is_valid = is_valid; d->selected_spell = -1; d->browse = FALSE; d->show_description = FALSE; menu_setpriv(m, d->n_spells, d); /* Set flags */ m->header = "Name Lv Mana Fail Info"; m->flags = MN_CASELESS_TAGS; m->selections = lower_case; m->browse_hook = spell_menu_browser; m->cmd_keys = "?"; /* Set size */ loc.page_rows = d->n_spells + 1; menu_layout(m, &loc); return m; }
static void parse_menu(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *name = NULL, *title = NULL, *script = NULL; ObMenu *menu; if (!obt_xml_attr_string(node, "id", &name)) goto parse_menu_fail; if (!g_hash_table_lookup(menu_hash, name)) { if (!obt_xml_attr_string(node, "label", &title)) goto parse_menu_fail; if ((menu = menu_new(name, title, TRUE, NULL))) { menu->pipe_creator = state->pipe_creator; if (obt_xml_attr_string(node, "execute", &script)) { menu->execute = obt_paths_expand_tilde(script); } else { ObMenu *old; old = state->parent; state->parent = menu; obt_xml_tree(menu_parse_inst, node->children); state->parent = old; } } } if (state->parent) menu_add_submenu(state->parent, -1, name); parse_menu_fail: g_free(name); g_free(title); g_free(script); }
PuyoCommander::PuyoCommander(bool fs, bool snd, bool audio) { int init_flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK; SDL_Delay(500); corona = NULL; fullscreen = GetBoolPreference(kFullScreen,fs); #ifdef HAVE_OPENGL useGL = GetBoolPreference(kOpenGL,false); #endif sound = GetBoolPreference(kMusic,snd); fx = GetBoolPreference(kAudioFX,audio); music_volume = GetIntPreference(kMusicVolume, 100); int audio_volume = GetIntPreference(kAudioVolume, 80); initGameControls(); #ifdef USE_DGA /* This Hack Allows Hardware Surface on Linux */ if (fullscreen) setenv("SDL_VIDEODRIVER","dga",0); if (SDL_Init(init_flags) < 0) { setenv("SDL_VIDEODRIVER","x11",1); if (SDL_Init(init_flags) < 0) { fprintf(stderr, "SDL initialisation error: %s\n", SDL_GetError()); exit(1); } } else { if (fullscreen) SDL_WM_GrabInput(SDL_GRAB_ON); } #else #ifdef WIN32 _putenv("SDL_VIDEODRIVER=windib"); #endif if ( SDL_Init(init_flags) < 0 ) { fprintf(stderr, "SDL initialisation error: %s\n", SDL_GetError()); exit(1); } #endif initControllers(); initHiScores(AI_NAMES); #ifdef USE_AUDIO audio_init(); audio_music_start(0); if (sound==false) Mix_PauseMusic(); audio_set_music_on_off(sound); audio_set_sound_on_off(fx); audio_set_volume(audio_volume); audio_music_set_volume(music_volume); #endif display = SDL_SetVideoMode( 320, 240, 0, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0)); if ( display == NULL ) { fprintf(stderr, "SDL_SetVideoMode error: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); SDL_ShowCursor(SDL_DISABLE); smallFont = SoFont_new(); SoFont_load (smallFont, IIM_Load_DisplayFormatAlpha ("font4b.png")); menuFont = SoFont_new(); SoFont_load (menuFont, IIM_Load_DisplayFormatAlpha ("font3b.png")); darkFont = SoFont_new(); SoFont_load (darkFont, IIM_Load_DisplayFormatAlpha ("fontdark.png")); IIM_Surface * menuselector = IIM_Load_DisplayFormatAlpha("menusel.png"); mainMenu = menu_new(main_menu_load(menuFont),menuselector); gameOver1PMenu = menu_new(gameover_1p_menu_load(menuFont, smallFont),menuselector); gameOver2PMenu = menu_new(gameover_2p_menu_load(menuFont, smallFont),menuselector); nextLevelMenu = menu_new(nextlevel_1p_menu_load(menuFont, smallFont),menuselector); looserMenu = menu_new(looser_1p_menu_load(menuFont, smallFont),menuselector); finishedMenu = menu_new(finished_1p_menu_load(menuFont, smallFont),menuselector); gameOverMenu = gameOver2PMenu; optionMenu = menu_new(options_menu_load(menuFont, smallFont),menuselector); controlsMenu = menu_new(controls_menu_load(menuFont, smallFont),menuselector); rulesMenu = menu_new(rules_menu_load(menuFont),menuselector); highScoresMenu = menu_new(high_scores_menu_load(menuFont),menuselector); aboutMenu = menu_new(about_menu_load(menuFont),menuselector); singleGameMenu = menu_new(single_game_menu_load(menuFont,smallFont),menuselector); twoPlayerGameMenu = menu_new(two_player_game_menu_load(menuFont,smallFont),menuselector); mustRestartMenu = menu_new(must_restart_menu_load(menuFont),menuselector); if (menu_pause == NULL) menu_pause = menu_new(pause_menu_load(menuFont),menuselector); menu_set_sounds (optionMenu, sound_pop, sound_slide); menu_set_sounds (controlsMenu, sound_pop, sound_slide); menu_set_sounds (mainMenu, sound_pop, sound_slide); menu_set_sounds (rulesMenu, sound_pop, sound_slide); menu_set_sounds (highScoresMenu, sound_pop, sound_slide); menu_set_sounds (aboutMenu, sound_pop, sound_slide); menu_set_sounds (singleGameMenu, sound_pop, sound_slide); menu_set_sounds (twoPlayerGameMenu, sound_pop, sound_slide); menu_set_sounds (menu_pause , sound_pop, sound_slide); melt = doom_melt_new(); scrollingText = scrolling_text_new( "Welcome to the wonderful world of FloboPuyo !!! Enjoy its nice graphics, " "happy music and entertaining gameplay... " "Will you be able to defeat all of the mighty players ? " "Will you beat the Puyo Gods ??? Have a try ! " "We wish you good luck. " " Hello from PuyoLand !", smallFont); theCommander = this; }
menu_type *menu_dynamic_new(void) { menu_type *m = menu_new(MN_SKIN_SCROLL, &dynamic_iter); menu_setpriv(m, 0, NULL); return m; }
menu_type *menu_new_action(menu_action *acts, size_t n) { menu_type *m = menu_new(MN_SKIN_SCROLL, menu_find_iter(MN_ITER_ACTIONS)); menu_setpriv(m, n, acts); return m; }
void open_callb(GtkWidget *wdg, gpointer data) { // Opens an existing file, loading it in a new document // Dialog is modal and varies with application type app_struct *app; doc_wrapper *dw; gchar *path_n_file; GtkWidget *app_toolbar=NULL, *app_menu=NULL; app = (app_struct *)data; // If wdg is NULL, we are trying to open a file given on the command line // doc_read calls doc_prepare_to_load // doc_new (a few lines ahead) "fills up" the structure // prepared by doc_prepare_to_load if (wdg) { // Interactive creation // In this case we commit the changes to the current // document, if there are any commit_or_reset (app->stack); dw = doc_read(&path_n_file, app->types, app->docs, app->default_dir); } else { // File name given on the command line path_n_file = app->file_on_cmdline; dw = doc_prepare_to_load(path_n_file, app->types); } if (!dw) return; if (app->docs->current_doc) if (app->docs->current_doc->creation_mode && INTEGRATED_INTERFACE) cancel_create (app); app->docs->last_doc = app->docs->current_doc; app->docs->current_doc = dw; // current_doc_data may contain a pointer to another document app->docs->current_doc_data = NULL; /************** CHECK: creating a creation dialog not required here **********/ // Create the dialogs needed for managing // this particular document type, if needed create_type_dialogs(app->types, dw->type, (gpointer) &app->docs->current_doc_data, app->stack, app->docs, dw); // Empty window + document creation // Load the data from path_n_file into doc_wrapper struct if (INTEGRATED_INTERFACE) { app->docs->current_doc->tools_container = tools_container_new(app->types); gtk_container_add(GTK_CONTAINER(app->docs->current_doc->tools_container), app->docs->current_doc->tools_dialog); } if (MENU_IN_DOC_WINDOW) app_menu = (menu_new(NBCOMMANDS,commands, app->accel_group, (gpointer) app))->bar; if (ICONS_IN_DOC_WINDOW) app_toolbar = standard_toolbar_new(NBCOMMANDS, commands, app->tooltips, app->window, (gpointer) app, GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS, FALSE); if (!doc_new(app->docs, app->types, path_n_file, app->new_doc_count, &app->stack->commit_data, app_menu, app_toolbar)) cancel_create (app); else { ok_create_callb(NULL,data); app->default_dir = app->docs->current_doc->dir; if (!app->docs->current_doc->fname_tochoose) app->docs->current_doc->if_modified = FALSE; // If it's the first document, we have to re-position the window after building the dialogs place_document_window(app->docs, app->types, app->types->tools_container); } }
void create_callb(GtkWidget *wdg, gpointer data) { // Creates a new document with one of the allowed types for the current application // Dialog is modal and varies with application type GtkWidget *hbox, *button, *vbox, *app_toolbar=NULL, *app_menu=NULL; app_struct *app; app = (app_struct *)data; // First we commit the changes to the current document, if there are any commit_or_reset (app->stack); app->docs->last_doc = app->docs->current_doc; // Create a document window for the current doc // Fill it with the display / controls for the current document type app->docs->current_doc = doc_wrapper_new("*", app->types->default_type->def_dir, app->types->default_type); app->docs->current_doc->fname_tochoose = TRUE; if (INTEGRATED_INTERFACE) { // We pack the creation dialog with OK/CANCEL buttons here app->docs->current_doc->creation_container = creation_container_new(app->types); app->docs->current_doc->tools_container = tools_container_new(app->types); // Commit_data && current_doc_data must not // contain the last document pointer set_commit_data (app->stack, NULL); app->docs->current_doc_data = NULL; create_type_dialogs(app->types, app->docs->current_doc->type, (gpointer) &app->docs->current_doc_data, app->stack, app->docs, app->docs->current_doc); hbox = gtk_hbox_new(TRUE,0); gtk_widget_show(GTK_WIDGET(hbox)); button = gtk_button_new_with_label(_("OK")); gtk_widget_show(GTK_WIDGET(button)); gtk_container_set_border_width(GTK_CONTAINER(button),DEF_PAD); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_create_callb), (gpointer) app); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, DEF_PAD); button = gtk_button_new_with_label(_("Cancel")); gtk_widget_show(GTK_WIDGET(button)); gtk_container_set_border_width(GTK_CONTAINER(button),DEF_PAD); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_create_callb), (gpointer) app); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, DEF_PAD); vbox = gtk_vbox_new(FALSE,0); gtk_widget_show(GTK_WIDGET(vbox)); gtk_box_pack_start(GTK_BOX(vbox), app->docs->current_doc->creation_dialog, TRUE, TRUE, DEF_PAD); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, DEF_PAD); gtk_container_add(GTK_CONTAINER(app->docs->current_doc->creation_container),vbox); // We don't forget the tools dialog, for later use gtk_container_add(GTK_CONTAINER(app->docs->current_doc->tools_container), app->docs->current_doc->tools_dialog); gtk_widget_hide(app->docs->current_doc->tools_container); } else { // Gimp style interface if (!app->types->type_choice_dialog) { // Current document and interface callbacks // are linked in the following process // We create a modal window, containing a hbox which packs: // 1st widget from the top: file type choice toolbar // option widgets, in the middle // OK / Cancel button, at the bottom // The interface is created once, so we keep the widgets embedded in their structs // Creates the type choice dialog if inexistent type_choice_dialog_new(app->types, (gpointer) app, (gpointer) &app->docs->current_doc_data, app->stack, app->docs); modal_dialog_showhide(app->types->creation_container, app->types->type_choice_dialog, _("New document"), ok_create_callb, cancel_create_callb, (gpointer) app, 0, TRUE); } else { // Reactivates the modal dialog type_choice_dialog_show(app->types); gtk_widget_show(GTK_WIDGET(app->types->creation_container)); // ... set_uposition deprecated in GTK2, but I still have to find an alternative... gtk_widget_set_uposition(GTK_WIDGET(app->types->creation_container),app->types->win_pos_x, app->types->win_pos_y); gtk_grab_add(GTK_WIDGET(app->types->creation_container)); } } // Emd Gimp style interface if (MENU_IN_DOC_WINDOW) app_menu = (menu_new(NBCOMMANDS,commands, app->accel_group, (gpointer) app))->bar; if (ICONS_IN_DOC_WINDOW) app_toolbar = standard_toolbar_new(NBCOMMANDS, commands, app->tooltips, app->window, (gpointer) app, GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS, FALSE); // Empty window + document creation // printf("app->docs->doc_list dans CREATE_CALLB: %d\n",app->docs->doc_list); doc_new(app->docs, app->types, NULL, app->new_doc_count, &app->stack->commit_data, app_menu, app_toolbar); // Execute some defaults, if any // 2008-01: Migrated to the type dialog level -doctype.c // if (app->docs->current_doc->type->defaults) // (*app->docs->current_doc->type->defaults) // ((gpointer) &app->docs->current_doc_data); }
app_struct *app_new( gchar *title, option_file_type *current_opt, option_file_type *allowed_opt, gchar *options_file) { // Initializes application app_struct *app; app = (app_struct *) x_malloc(sizeof(app_struct), "app_struct"); app->main_bar_pos_x = MAIN_BAR_X*gdk_screen_width()/100; app->main_bar_pos_y = MAIN_BAR_Y*gdk_screen_height()/100; app->default_dir = (gchar *) x_malloc(strlen(HF_DIR)+1, "gchar (HF_DIR)"); strcpy(app->default_dir, HF_DIR); app->file_on_cmdline = NULL; app->title = title; app->docs = doc_swap_new(); app->new_doc_count = 0; app->rc_options_file = options_file; app->allowed_options = allowed_opt; app->current_options = current_opt; app->options_dialog = NULL; app->stack = stack_struct_new (NULL); // printf("APP: %p; APP->STACK: %p\n",app, app->stack); check_integrated_interface (allowed_opt); app->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_realize(GTK_WIDGET(app->window)); gtk_widget_set_uposition(GTK_WIDGET(app->window), app->main_bar_pos_x, app->main_bar_pos_y); app->types = instantiate_types(app->window); if (!INTEGRATED_INTERFACE) gtk_window_set_resizable(GTK_WINDOW(app->window),FALSE); gtk_signal_connect (GTK_OBJECT (app->window), "delete_event", GTK_SIGNAL_FUNC(app_menu_delete), (gpointer) app); gtk_window_set_title (GTK_WINDOW (app->window), app->title); gtk_container_border_width (GTK_CONTAINER(app->window),DEF_PAD); app->accel_group = gtk_accel_group_new(); gtk_window_add_accel_group (GTK_WINDOW(app->window), app->accel_group); app->tooltips = gtk_tooltips_new(); if ((!INTEGRATED_INTERFACE) || (!MENU_IN_DOC_WINDOW)) app->menu = menu_new(NBCOMMANDS,commands, app->accel_group, (gpointer) app); else app->menu = NULL; if ((!INTEGRATED_INTERFACE) || (!ICONS_IN_DOC_WINDOW)) app->toolbar = standard_toolbar_new(NBCOMMANDS, commands, app->tooltips, app->window, (gpointer) app, GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS, FALSE); else app->toolbar = NULL; if (!INTEGRATED_INTERFACE) { creation_container_new(app->types); tools_container_new(app->types); // We need the accelerators for the tools window, // but not for the creation window, which is modal if (GTK_IS_WINDOW(app->types->tools_container)) gtk_window_add_accel_group (GTK_WINDOW(app->types->tools_container), app->accel_group); } return(app); }
/* * show the manual pages */ void help (int showpage) { int page = showpage, menuselect = 2, y = 0; char title[255]; _menu *menu; menu_displaytext ("Please Wait", "Loading GFX Data"); if (page < 0 || page >= HP_max) page = 0; while (menuselect != -1 && menuselect != 1 && bman.state != GS_quit) { if (page == HP_howto0) { sprintf (title, "How To Play (%d/%d)", page + 1, HP_max); menu = menu_new (title, 500, 400); menu_create_text (menu, "help", 5, 55, 53, 20, COLOR_brown, "The goal of the game is to be the last one, " "who is alive. You can drop bombs which will explode after " "a certain time and destroy everything in horizontal and vertical " "direction. So you can remove stones or kill other players. But take care. " "Don't kill yourself otherwise the game will be over for you. During the " "game you will find diffrenent powerups to raise your skills. If you are " "running faster than your opponent and you have many bombs, you can catch " "him within lots of bombs and he has no chance to escape."); menu_create_image (menu, "img", 450, 255, 0, gfx.players[0].menu_image, NULL); menu_create_text (menu, "help", 5, 255, 45, 10, COLOR_brown, "You will get points for every player you have killed. " "If you win the game, you can earn additional points " "depending on how many players played the game. "); } else if (page == HP_powerup0) { sprintf (title, "Powerups (%d/%d)", page + 1, HP_max); menu = menu_new (title, 500, 400); y = 50; menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown, "In the game you will find some diffend kind of powerups. " "There are the powerups who give you more power for the whole game " "and the special powerups which will hold only for a certain time."); y += 75; menu_create_label (menu, "Permanent Powerups", -1, y, 2, COLOR_yellow); y += (5 + font[2].size.y); menu_create_image (menu, "bomb", 5, y, 0, gfx.menu_field[FT_bomb], NULL); menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown, "Give you another bomb to drop. Maximum number of bombs is %d.", MAX_BOMBS); y += 40; menu_create_image (menu, "fire", 5, y, 1, gfx.menu_field[FT_fire], NULL); menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown, "The range of your bombs will be increased. Maximum range is %d.", MAX_RANGE); y += 40; menu_create_image (menu, "shoe", 5, y, 1, gfx.menu_field[FT_shoe], NULL); menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown, "This will make your player run faster. The maximum speed will be %1.2f.", MAX_SPEED); y += 40; menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown, "Depends how the game is set up, you'll lose " "these powerups if you die. Other players can collect them. " "In the deathmatch mode you can keep the powerups you collected, " "but this depends on the Game if you drop them or not."); y += 40; } else if (page == HP_powerup1) { sprintf (title, "Powerups (%d/%d)", page + 1, HP_max); menu = menu_new (title, 500, 400); y = 45; menu_create_label (menu, "Special Powerups", -1, y, 2, COLOR_yellow); y += (5 + font[2].size.y); menu_create_image (menu, "kick", 5, y, 1, gfx.menu_field[FT_sp_kick], NULL); menu_create_text (menu, "help", 55, y, 48, 10, COLOR_brown, "Allowes you to kick some bombs around the level. This will hold " "just a short time of %d seconds. The maximum distance you can " "kick the bombs is %d fields.", SPECIAL_KICK_TIME, SPECIAL_KICK_MAXDIST); y += 70; menu_create_image (menu, "push", 5, y, 1, gfx.menu_field[FT_sp_push], NULL); menu_create_text (menu, "help", 55, y, 48, 10, COLOR_brown, "Push bombs one field, as long as nothing is behind this bomb."); y += 40; menu_create_image (menu, "droprow", 5, y, 1, gfx.menu_field[FT_sp_row], NULL); menu_create_text (menu, "help", 55, y, 48, 10, COLOR_brown, "You can drop a row of that many bombs you have still left to drop."); y += 40; menu_create_image (menu, "dropliquid", 5, y, 1, gfx.menu_field[FT_sp_liquid], NULL); menu_create_text (menu, "help", 55, y, 48, 10, COLOR_brown, "The bomb you push now won't stop moving untill they explode."); y += 40; menu_create_image (menu, "dropliquid", 5, y, 1, gfx.menu_field[FT_sp_moved], NULL); menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown, "The bomb you push will stop moving on the next border or bomb."); y += 40; menu_create_image (menu, "dropltrigger", 5, y, 1, gfx.menu_field[FT_sp_trigger], NULL); menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown, "You will be able to drop triggered bombs. Use " "the special key to let all your bombs explode. " "at the time where you want it."); y += 40; } else if (page == HP_powerup2) { sprintf (title, "Powerups (%d/%d)", page + 1, HP_max); menu = menu_new (title, 500, 400); y = 45; menu_create_label (menu, "Death Item", -1, y, 2, COLOR_yellow); y += (5 + font[2].size.y); menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown, "In the game you will find another type of item to collect. " "This item is not a powerup at all. If you collect it you will " "get a random illness. This illness will hold for %dseconds. " "If you have contact to another player the other player will " "get all the illnesses you have too.", ILL_TIMEOUT); y += 110; menu_create_image (menu, "pwdeath", 12, y+8, 1, gfx.menu_field[FT_death], NULL); menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown, "This will make your player ill. We have at the moment %d diffrent " "types of illnesses for you to collect. To make the game more", PI_max); y += 3*font[0].size.y; menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown, "interesting we won't put here a list of all types there are."); } else if (page == HP_keyboard0) { sprintf (title, "Keyboard (%d/%d)", page + 1, HP_max); menu = menu_new (title, 500, 400); y = 50; menu_create_label (menu, "During a Game", -1, y, 2, COLOR_yellow); y += font[2].size.y; menu_create_image (menu, "img", 450, 100, 0, gfx.players[7].menu_image, NULL); menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown, "Arrow Keys - Moving of the Player\n" "STRG/CTRL - Dropping bombs\n" "Shift - Special Use Key\n" "F4 - Start the Game (only Server)\n" "F8 - Fullscreen (not in Windows)\n" "Return - Send Entered Text Message\n" "ESC - Exit Game\n"); y += 7*font[0].size.y; menu_create_label (menu, "Player Selection", -1, y, 2, COLOR_yellow); y += font[2].size.y; menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown, "Left/Right - Select and Deselect a Player\n" "F1 - Mini Help Screen\n" "F2 - Player Screen\n" "F3 - Map and Game Settings\n" "F4 - Start the Game if at last 2 Players\n" " are selected. (only Server)\n" "ESC - Exit Game\n"); } else if (page == HP_credit0) { sprintf (title, "About BomberClone (%d/%d)", page + 1, HP_max); menu = menu_new (title, 500, 400); menu_create_image (menu, "img", 15, 60, 0, gfx.players[4].menu_image, NULL); menu_create_text (menu, "help", 75, 50, 45, 10, COLOR_brown, "If you have any problems or questions with the game you can send your questions " "to the mailinglist or directly to me. Bugfixes should be send to the SourceForge " "Projects page about BomberClone."); menu_create_label (menu, "WWW",-1, 140, 2, COLOR_yellow); menu_create_text (menu, "help", -1, 165, 53, 10, COLOR_brown, "http://www.bomberclone.de"); menu_create_label (menu, "EMail",-1, 185, 2, COLOR_yellow); menu_create_text (menu, "help", -1, 210, 53, 10, COLOR_brown, "*****@*****.**"); menu_create_label (menu, "Project Page",-1, 230, 2, COLOR_yellow); menu_create_text (menu, "help", -1, 255, 53, 10, COLOR_brown, "http://sourceforge.net/projects/bomberclone"); } else if (page == HP_credit1) { sprintf (title, "People (%d/%d)", page + 1, HP_max); menu = menu_new (title, 500, 400); menu_create_image (menu, "img", 250, 100, 0, gfx.players[6].menu_image, NULL); y = 50; menu_create_label (menu, "Coding:", 5, y, 2, COLOR_yellow); y += font[2].size.y; menu_create_text (menu, "help", 50, y, 53, 10, COLOR_brown, " Steffen Pohle\n" "Patrick Wilczek\n"); y = 100; menu_create_label (menu, "GFX:", 425, y, 2, COLOR_yellow); y += font[2].size.y; menu_create_text (menu, "help", 325, y, 53, 10, COLOR_brown, "TekkRat\n" "Martijn de Boer\n" "Steffen Pohle\n" "Patrick Wilczek\n"); y = 140; menu_create_label (menu, "Sound/Music:", 5, y, 2, COLOR_yellow); y += font[2].size.y; menu_create_text (menu, "help", 50, y, 53, 10, COLOR_brown, "Henrik_Enqvist\n" "Cerror\n" "Martijn de Boer\n"); y = 240; menu_create_label (menu, "Thanks To:", -1, y, 2, COLOR_yellow); y += font[2].size.y; menu_create_text (menu, "help", -1, y, 53, 10, COLOR_brown, "kitutou(coding/fixing), thaphool(tilesets), ob1kenewb(coding/fixing), " "TeKkraT(website,gfx), caccola(tilesets), Digital_D(music), " "dcdillon(coding), Psycho(music),\nNiklas Sj\xf6sv\xe4rd(music)"); } else break; if (page > 0) menu_create_button (menu, "Previous Page", 20, 370, 150, 0); else if (menuselect == 0) menuselect = 2; menu_create_button (menu, "Main Menu", -1, 370, 150, 1); if (page < HP_max-1) menu_create_button (menu, "Next Page", 350, 370, 150, 2); menu_focus_id (menu, menuselect); menuselect = menu_loop (menu); if (menuselect == 0 && page > 0) page--; if (menuselect == 2 && page < HP_max - 1) page++; menu_delete (menu); } };
int main (int argc, char *argv[]) { DVDResult_t res; char *msgq_str; program_name = argv[0]; #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); #endif if(argc==1) { fprintf(stderr, "Error: Do not start ogle_gui directly. Start ogle\n"); exit(1); } if(pipe(dvdpipe)) { FATAL("dvdpipe: %s", strerror(errno)); exit(1); } msgq_str = argv[2]; init_interpret_config(program_name, add_keybinding, set_dvd_path); interpret_config(); gtk_init(&argc, &argv); dvdpipe_handler_id = gtk_input_add_full(dvdpipe[0], GDK_INPUT_READ, dvdpipe_handler, NULL, NULL, NULL); // Make Solaris 8+24 displays work gdk_rgb_init(); gtk_widget_set_default_colormap(gdk_rgb_get_cmap()); gtk_widget_set_default_visual(gdk_rgb_get_visual()); // Initialize glade, and read in the glade file my_glade_setup(); res = DVDOpenNav(&nav, msgq_str); if(res != DVD_E_Ok ) { DVDPerror("DVDOpen", res); exit(1); } xsniff_init(msgq_str); audio_menu_new(); subpicture_menu_new(); app = get_glade_widget("app"); gtk_widget_show(app); menu_new(app); // If a filename is given on the command line, start immediately. if(argc == 4) { res = DVDSetDVDRoot(nav, argv[3]); if(res != DVD_E_Ok) { DVDPerror("main: DVDSetDVDRoot", res); } autoload_bookmark(); } gtk_main (); return 0; }
static bool initialize_menu_tree(void) { ITEM *item; MENU *sub1, *sub2, *sub3, *sub4; if (menu_new(&sub1, MENU_MAIN)) { if (menu_new(&sub2, MENU_HORIZONTAL)) { if (menu_new(&sub3, MENU_PLAIN)) { } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "TIME", "Set clock time." }, sub3); menu_add_item(sub2, item); if (menu_new(&sub3, MENU_VERTICAL)) { if (menu_new(&sub4, MENU_PLAIN)) { } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "Background", "Set background color." }, sub4); menu_add_item(sub3, item); if (menu_new(&sub4, MENU_PLAIN)) { } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "Foreground", "Set foreground color." }, sub4); menu_add_item(sub3, item); if (menu_new(&sub4, MENU_PLAIN)) { } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "Markers", "Set markers color." }, sub4); menu_add_item(sub3, item); } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "COLORS", "Set clock color." }, sub3); menu_add_item(sub2, item); if (menu_new(&sub3, MENU_PLAIN)) { } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "HELP", "Obtain usage advice." }, sub3); menu_add_item(sub2, item); if (menu_new(&sub3, MENU_VERTICAL)) { menu_new_item(&item, ITEM_HOOK, (DESC) { "Toggle LCD", "Why???" }, toggle_lcd); menu_add_item(sub3, item); menu_new_item(&item, ITEM_HOOK, (DESC) { "Crash Clock", "Good idea!" }, crash_clock); menu_add_item(sub3, item); menu_new_item(&item, ITEM_HOOK, (DESC) { "Neopixel Hello", "Test pixels." }, pixel_hello); menu_add_item(sub3, item); menu_new_item(&item, ITEM_HOOK, (DESC) { "Reset Clock", "Reset the clock." }, reset_clock); menu_add_item(sub3, item); menu_new_item(&item, ITEM_HOOK, (DESC) { "Say Hello", "Ping over Bluetooth." }, say_hello); menu_add_item(sub3, item); } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "ACTIONS", "Perform actions." }, sub3); menu_add_item(sub2, item); if (menu_new(&sub3, MENU_PLAIN)) { } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "ABOUT", "About the clock." }, sub3); menu_add_item(sub2, item); } else return (false); menu_new_item(&item, ITEM_LINK, (DESC) { "MAIN", "Access the main menu." }, sub2); menu_add_item(sub1, item); } else return (false); menu = sub1; return (true); }