void MainContentComponent::buttonClicked(Button* button) { if(button == load_but) { load_button(); this->startAudioCallback(); } else if (button == calc_but) { calc_tuning(); } }
int load_buttons_toolbar(t_buttons_toolbar *bts_toolbar) { t_bunny_position button_pos; int s; button_pos.x = 38; button_pos.y = 10; s = load_button("res/newfile.bmp", &button_pos, &bts_toolbar->newfile); button_pos.x += 124; s += load_button("res/folder.bmp", &button_pos, &bts_toolbar->folder); button_pos.x += 124; s += load_button("res/save.bmp", &button_pos, &bts_toolbar->save); button_pos.x = WIN_WIDTH - 74; s += load_button("res/cancel.bmp", &button_pos, &bts_toolbar->cancel); if (s < 0) return (-1); else return (0); }
void init_controls_state( game* _pGame ) { _pGame->p_current_state = malloc( sizeof( controls_state ) ); ((controls_state*)_pGame->p_current_state)->p_background_img = load_image( GC_co_background_img, GC_bg_img_width, GC_bg_img_height ); ( ((controls_state*)_pGame->p_current_state) )->p_back = load_button( GC_c_back_button_x, GC_c_back_button_y, GC_button_width, GC_button_height, NULL, GC_c_back_se_img ); // set the back button to be selected: ((controls_state*)_pGame->p_current_state)->p_back->bool_is_selected = 1; _pGame->current_state = CONTROLS; }
void reloadButtons () { int i; static char *button_imgs[BUTTONS_NUM][2] = {{"mount-white", "mount-green-pressed"}, {"unmount-white", "unmount-red-pressed"}, {"eject-white", "eject-red-pressed"}}; static int button_contexts[BUTTONS_NUM] = { MOUNT_CONTEXT, UNMOUNT_CONTEXT, EJECT_CONTEXT}; int btn_size = (AppState.tileWidth - 15) / 2; for ( i = 0 ; i < BUTTONS_NUM ; ++i){ if (AppState.buttons[i] == NULL) AppState.buttons[i] = safecalloc (1, sizeof(struct button_t)); else free_button_resources (AppState.buttons[i]); load_button (AppState.buttons[i], button_imgs[i], Scr.image_manager ); AppState.buttons[i]->context = button_contexts[i]; LOCAL_DEBUG_OUT ("button[%d].size = %dx%d, image %dx%d", i, AppState.buttons[i]->width, AppState.buttons[i]->height, AppState.buttons[i]->pressed.image?AppState.buttons[i]->pressed.image->width:0, AppState.buttons[i]->pressed.image?AppState.buttons[i]->pressed.image->height:0); scale_button (AppState.buttons[i], btn_size, btn_size, Scr.asv); } }
void init_in_game_state( game* _pGame ) { // allocate the necessary memory for the in_game_state struct _pGame->p_current_state = malloc( sizeof( in_game_state ) ); // game is not paused ((in_game_state*)_pGame->p_current_state)->bool_paused = 0; // load esc menu image ((in_game_state*)_pGame->p_current_state)->p_esc_menu_img = load_image( GC_ig_esc_menu_img, GC_ig_esc_menu_width, GC_ig_esc_menu_height ); // init current game state flag variable ((in_game_state*)_pGame->p_current_state)->game_state = PLAYING; // esc menu is not active ((in_game_state*)_pGame->p_current_state)->bool_menu_is_active = 0; // create the top bar ((in_game_state*)_pGame->p_current_state)->p_top_bar = construct_top_bar(); // load esc menu buttons ((in_game_state*)_pGame->p_current_state)->p_continue = load_button( GC_ig_continue_x, GC_ig_continue_y, GC_button_width, GC_button_height, GC_ig_continue_nr_img, GC_ig_continue_se_img ); ((in_game_state*)_pGame->p_current_state)->p_main_menu = load_button( GC_ig_mm_x, GC_ig_mm_y, GC_button_width, GC_button_height, GC_ig_mm_nr_img, GC_ig_mm_se_img ); ((in_game_state*)_pGame->p_current_state)->p_exit = load_button( GC_ig_exit_x, GC_ig_exit_y, GC_button_width, GC_button_height, GC_mm_exit_nr_img, GC_mm_exit_se_img ); // pause main menu backgorund music pause_audio(); _pGame->main_menu_music_is_on = 0; // selected button in esc menu is "continue" ((in_game_state*)_pGame->p_current_state)->selected_button = CONTINUE_BUTTON; ((in_game_state*)_pGame->p_current_state)->p_continue->bool_is_selected = 1; // seed the random number generator srand( time( NULL ) ); // construct the map struct, load a random map file from "maps\" directoty ((in_game_state*)_pGame->p_current_state)->p_map = construct_map( rand() % GC_number_of_maps ); // construct the NPCs( pacmen ) based on how many 'N' characters there are in the map( max being GC_max_NPC_count ) matrix_point* p_NPCs_coords = (matrix_point*)malloc( GC_max_NPC_count * sizeof( matrix_point ) ); ((in_game_state*)_pGame->p_current_state)->NPC_count = find_NPCs_in_map( ((in_game_state*)_pGame->p_current_state)->p_map, p_NPCs_coords ); ((in_game_state*)_pGame->p_current_state)->pp_NPCs = (NPC**)malloc( ((in_game_state*)_pGame->p_current_state)->NPC_count * sizeof( NPC ) ); for ( int i = 0; i < ((in_game_state*)_pGame->p_current_state)->NPC_count; i++ ) ((in_game_state*)_pGame->p_current_state)->pp_NPCs[i] = construct_NPC( p_NPCs_coords[i].i, p_NPCs_coords[i].j ); free( p_NPCs_coords ); // construct the player ((in_game_state*)_pGame->p_current_state)->p_player = construct_player(); ((in_game_state*)_pGame->p_current_state)->game_ended_timer = create_timer( GC_game_ended_duration ); ((in_game_state*)_pGame->p_current_state)->timer_set = 0; // Configure the text that will be outputed(WinBGIm); this is only for the "PAUSED GAME" that appears when game's paused settextjustify( CENTER_TEXT, CENTER_TEXT ); settextstyle( SMALL_FONT, HORIZ_DIR, 9 ); }