Example #1
0
File: menu.c Project: wavebeem/wmfs
void
uicb_menu(uicb_t cmd)
{
    int i, d, u, x, y;
    Window w;

    if(!strcmp(cmd, "menulayout"))
        menu_draw(menulayout, menulayout.x, menulayout.y);

    for(i = 0; i < conf.nmenu; ++i)
        if(!strcmp(cmd, conf.menu[i].name))
        {
            if(conf.menu[i].place_at_mouse)
            {
                XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&u);
                conf.menu[i].x = x;
                conf.menu[i].y = y;
            }
            else
            {
                screen_get_sel();
                x = conf.menu[i].x + spgeo[selscreen].x;
                y = conf.menu[i].y + spgeo[selscreen].y;
            }
            menu_draw(conf.menu[i], x, y);
        }

    return;
}
Example #2
0
File: menu.c Project: wavebeem/wmfs
static Bool
menu_activate_item(Menu *menu, int i)
{
    int j, x, y;
    int chcklen = 0;
    if(menu_get_checkstring_needed(menu->item, menu->nitem))
        chcklen = textw(conf.selected_layout_symbol) + PAD / 3;

    if(menu->item[i].submenu)
    {
        for(j = 0; j < conf.nmenu; ++j)
            if(!strcmp(menu->item[i].submenu, conf.menu[j].name))
            {
                y = menu->y + ((i - 1) * INFOBARH + PAD) - SHADH * 2;
                x = menu->x + menu_get_longer_string(menu->item, menu->nitem) + chcklen + textw(">") + PAD * 3;

                menu_draw(conf.menu[j], x, y);

                return True;
            }
    }
    else if(menu->item[i].func)
    {
        menu->item[i].func(menu->item[i].cmd);

        return True;
    }

    return False;
}
Example #3
0
static menu_st *menu_right_transition(menu_st *menulist, item_st *item)
{
	menu_st *m;
	int i, jump;

	GrCopyArea(menulist->transition, menulist->menu_gc, 0, 0,
			menulist->w, menulist->h, menulist->menu_wid,
			menulist->x, menulist->y, 0);
	m = menu_init(menulist->transition, item->text,
			menulist->w, 0, menulist->w, menulist->h,
			menulist, (item_st *)item->action, menulist->op);
	menu_draw(m);

	m->menu_wid = menulist->menu_wid;
	m->x = menulist->x;
	m->y = menulist->y;

	jump = (ipod_get_setting(SLIDE_TRANSIT)) ?
		menulist->w / TRANSITION_STEPS : 0;
	for (i = 0; i < TRANSITION_STEPS; i++) {
		GrCopyArea(menulist->menu_wid, menulist->menu_gc,
				menulist->x, menulist->y, menulist->w,
				menulist->h, menulist->transition,
				(i + 1) * jump, 0, 0);
	}
	return m;
}
Example #4
0
static void menu_left_transition(menu_st *menulist)
{
	menu_st *m;
	int i, jump;

	m = menulist->parent;
	GrCopyArea(m->transition, menulist->menu_gc, m->w, 0,
			menulist->w, menulist->h, menulist->menu_wid,
			menulist->x, menulist->y, 0);

	if (m->scheme_no != appearance_get_color_scheme()) {
		m->menu_wid = m->transition;
		m->x = 0;
		m->y = 0;

		menu_draw(m);

		m->menu_wid = menulist->menu_wid;
		m->x = menulist->x;
		m->y = menulist->y;
	}
	
	jump = (ipod_get_setting(SLIDE_TRANSIT)) ?
		m->w / TRANSITION_STEPS : 0;
	for (i = TRANSITION_STEPS; i; i--) {
		GrCopyArea(menulist->menu_wid, menulist->menu_gc,
				menulist->x, menulist->y, menulist->w,
				menulist->h, m->transition,
				i * jump, 0, 0);
	}
}
Example #5
0
static void itunes_draw(struct menulist *ml)
{
	int counter=0;

	if (!currentml->user)
		return;
	
	if (!ml->init)
	{
		//add to courtc's menu from the original list.
		while (currentml->get_prev(currentml))counter--;
		do 
		{
			menu_add_item(currentml->itunes_menu, currentml->get_text(currentml), NULL, 0, 0);
			counter++;
		}while (currentml->get_next(currentml));
			while (counter != 0)
			{
				if (counter> 0) {
					counter--;
					currentml->get_prev(currentml);
				}
				if (counter < 0) {
					counter++;
					currentml->get_next(currentml);
				}
			}

		ml->init=1;

	}

	menu_draw(currentml->itunes_menu);
}
Example #6
0
/*
 * in game menu_loop, will called every game loop.
 * As long as this menu is displayed the gamekeys will not work.
 *
 * the drawings will be done from the main loop. So we won't
 * have to draw anything on our own.
 *
 * Pressing ESC will bring you back to the game.
 */
void
game_menu_loop (SDL_Event * event, int eventstate)
{
    int done;

    if (menu == NULL)
        return;

    menu_draw (menu);

    done = menu_event_loop (menu, event, eventstate);
    /*
     * check if one of the buttons was pressed
     */

    if (done != 0) {
        if (menu->focus->id == 2 && (GT_MP_PTPM || GT_SP)) { /* End Round */
            bman.timeout = -GAME_OVERTIMEOUT;
        }

        else if (menu->focus->id == 3) { /* End Game */
            /* send network update */
            if (GT_MP)
                net_game_send_delplayer (bman.p_nr);
            bman.state = GS_quit;
        }

        else {                  /* Quit Menu */
            menu_delete (menu);
            menu = NULL;
            gfx_blitdraw ();
            draw_field ();
        }
    }
};
Example #7
0
File: menu.c Project: glankk/gz
void menu_draw(struct menu *menu)
{
  if (menu->child)
    return menu_draw(menu->child);
  for (int i = 0; i < 3; ++i) {
    int shift = i * 8;
    uint32_t mask = 0xFF << shift;
    int v = (menu->highlight_color_animated & mask) >> shift;
    v += menu->highlight_state[i];
    if (v < 0x00 || v > 0xFF) {
      v = -v + (v > 0xFF ? 2 * 0xFF : 0);
      menu->highlight_state[i] = -menu->highlight_state[i];
    }
    menu->highlight_color_animated &= ~mask;
    menu->highlight_color_animated |= (uint32_t)v << shift;
  }
  struct gfx_font *font = menu_get_font(menu, 1);
  uint8_t alpha = menu_get_alpha_i(menu, 1);
  for (struct menu_item *item = menu->items.first;
       item; item = list_next(item))
  {
    if (!item->enabled)
      continue;
    struct menu_draw_params draw_params =
    {
      menu_item_screen_x(item),
      menu_item_screen_y(item),
      item->text,
      font,
      (item == menu->selector ? (item->animate_highlight ?
                                 menu->highlight_color_animated :
                                 menu->highlight_color_static) :
       item->color),
      alpha,
    };
    if (item->draw_proc && item->draw_proc(item, &draw_params))
      continue;
    if (item->imenu)
      menu_draw(item->imenu);
    if (!draw_params.text || !draw_params.font)
      continue;
    gfx_mode_set(GFX_MODE_COLOR, GPACK_RGB24A8(draw_params.color,
                                               draw_params.alpha));
    gfx_printf(draw_params.font, draw_params.x, draw_params.y,
               "%s", draw_params.text);
  }
}
Example #8
0
void menubar_draw(menubar_t *m)
{
	int i,x,y;

	x = m->info.x;
	y = m->info.y;
	/*
	HACK HACK HACK

	keeps the recent files menu updated
	*/
	for(i=0;i<10;i++) {
		char str[1024];
		char *fn;

		if((fn = strrchr(config.recent[i],'\\') + 1) == (char*)1)
			if((fn = strrchr(config.recent[i],'/') + 1) == (char*)1)
				fn = config.recent[i];
		sprintf(str,"%d. %s",i+1%10,fn);
		strcpy(m->menus[0].items[i].caption,str);
		m->menus[0].items[i].info.w = strlen(str) * 8;
	}
	/*
	END HACK
	*/
	load_draw(&m->load);
	video_draw(&m->video);
	input_draw(&m->input);
	gui_input_draw(&m->guiinput);
	sound_draw(&m->sound);
	devices_draw(&m->devices);
	palette_draw(&m->palette);
	options_draw(&m->options);
	mappers_draw(&m->mappers);
	paths_draw(&m->paths);
	supported_mappers_draw(&m->supported_mappers);
	tracer_draw(&m->tracer);
	rom_info_draw(&m->rom_info);
	memory_viewer_draw(&m->memory_viewer);
	nt_draw(&m->nametable_viewer);
	pt_draw(&m->patterntable_viewer);
	about_draw(&m->about);
	for(i=0;i<(m->info.h/2);i++)
		gui_draw_hline(GUI_TITLEBARBACKGROUND+i,x,y++,256);
	for(i++;i;i--)
		gui_draw_hline(GUI_TITLEBARBACKGROUND+i,x,y++,256);
	for(i=0;i<MAX_MENUS && m->menus[i].info.w;i++)
		menu_draw(&m->menus[i]);
#ifdef PS2
	i = 3;
#elif defined(WII)
	i = 2;
#else
	i = 0;
#endif
	for(;i<3;i++)
		button_draw(&m->buttons[i]);
}
Example #9
0
static int menu_select_internal(SDL_Surface *screen,
		menu_t *p_menu, int *p_submenus, int sel,
		void (*select_next_cb)(menu_t *p, void *data),
		void *select_next_cb_data, int font_size)
{
	int ret = -1;
	int i;

	for (i = 0; i < p_menu->n_submenus; i++)
		p_menu->p_submenus[i].sel = p_submenus[i];

	while(1)
	{
			
		uint32_t keys;
		
		int sel_last = p_menu->cur_sel;

		menu_draw(screen, p_menu, 0, font_size);
		SDL_Flip(screen);

		keys = menu_wait_key_press();
		
		quit_thread = 1;

		if (keys & KEY_UP)
			{select_next(p_menu, 0, -1, 1);play_click(0);}
		else if (keys & KEY_DOWN)
			{select_next(p_menu, 0, 1, 1);play_click(0);}
		else if (keys & KEY_PAGEUP)
			{select_next(p_menu, 0, -20, 0);play_click(0);}
		else if (keys & KEY_PAGEDOWN)
			{select_next(p_menu, 0, 20, 0);play_click(0);}
		else if (keys & KEY_LEFT)
			{select_next(p_menu, -1, 0 ,1);play_click(0);}
		else if (keys & KEY_RIGHT)
			{select_next(p_menu, 1, 0 ,1);play_click(0);}
		else if (keys & KEY_ESCAPE)
			{play_click(2);break;}
		else if (keys & KEY_SELECT)
		{
			ret = p_menu->cur_sel;
			int i;

			for (i=0; i<p_menu->n_submenus; i++)
				p_submenus[i] = p_menu->p_submenus[i].sel;
			play_click(1);	
			break;
		}
		/* Invoke the callback when an entry is selected */
		if (sel_last != p_menu->cur_sel &&
				select_next_cb != NULL)
			select_next_cb(p_menu, select_next_cb_data);
	}

	SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
	return ret;
}
Example #10
0
static int draw_proc(struct menu_item *item,
                     struct menu_draw_params *draw_params)
{
  struct item_data *data = item->data;
  if (data->active) {
    data->imenu->cxoffset = item->x;
    data->imenu->cyoffset = item->y;
    menu_draw(data->imenu);
  }
  return data->active;
}
static void browser_do_draw()
{
	/* window is focused */
	if(browser_wid == GrGetFocus()) {
		if( ipod_get_setting( BROWSER_PATH ))
			pz_draw_header(browser_shorten_path());
		else
			pz_draw_header(browser_menu->title);
		menu_draw(browser_menu);
	}
}
Example #12
0
int menubar_handler(window *wind, d_event *event, MENU *menu)
{
	int rval = 0;

	if (event->type == EVENT_WINDOW_DRAW)
	{
		menu_draw(&Menu[0]);
		return 1;
	}
	else if (event->type == EVENT_WINDOW_CLOSE)
	{
		int i;
		
		
		//menu_hide_all();
		//menu_hide( &Menu[0] );
		
		for (i=1; i<num_menus; i++ )
		{
			if (Menu[i].wind)
			{
				window_close(Menu[i].wind);
				Menu[i].wind = NULL;
			}
		}
		
		Menu[0].wind = NULL;
	}

	switch (state)
	{
		case 0:
			rval = do_state_0(event);
			break;
			
		case 1:
			rval = do_state_1(event);
			break;
			
		case 2:
			rval = do_state_2(event);
			break;
			
		case 3:
			break;

		default:
			state = 0;
			menu_hide_all();
	}
	
	return rval;
}
Example #13
0
/**
 * \brief Update menu depending on input.
 *
 * \param menu  menu struct with menu options
 * \param keycode  keycode to process
 *
 * \retval selected menu option or status code
 */
uint8_t gfx_mono_menu_process_key(struct gfx_mono_menu *menu, uint8_t keycode)
{
	switch (keycode) {
	case GFX_MONO_MENU_KEYCODE_DOWN:
		if (menu->current_selection == menu->num_elements - 1) {
			menu->current_selection = 0;
		} else {
			menu->current_selection++;
		}

		/* Update menu on display */
		menu_draw(menu, false);
		/* Nothing selected yet */
		return GFX_MONO_MENU_EVENT_IDLE;

	case GFX_MONO_MENU_KEYCODE_UP:
		if (menu->current_selection) {
			menu->current_selection--;
		} else {
			menu->current_selection = menu->num_elements - 1;
		}

		/* Update menu on display */
		menu_draw(menu, false);
		/* Nothing selected yet */
		return GFX_MONO_MENU_EVENT_IDLE;

	case GFX_MONO_MENU_KEYCODE_ENTER:
		/* Got what we want. Return selection. */
		return menu->current_selection;

	case GFX_MONO_MENU_KEYCODE_BACK:
		/* User pressed "back" key, inform user */
		return GFX_MONO_MENU_EVENT_EXIT;

	default:
		/* Unknown key event */
		return GFX_MONO_MENU_EVENT_IDLE;
	}
}
Example #14
0
/**
 * *\brief Initialize the menu handling. Clear screen and draw menu.
 *
 * \param menu  menu struct with menu options
 *
 */
void gfx_mono_menu_init(struct gfx_mono_menu *menu)
{
	/* Clear screen */
	gfx_mono_draw_filled_rect(0, 0,
			GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT, GFX_PIXEL_CLR);

	/* Draw the menu title on the top of the screen */
	gfx_mono_draw_progmem_string((char PROGMEM_PTR_T)menu->title,
			0, 0, &sysfont);

	/* Draw menu options below */
	menu_draw(menu, true);
}
Example #15
0
int menu_select(menu_t *p_menu, uint32_t available_options, int *p_submenus)
{
  vSetActiveFont(p_menu->p_font);

  while (vGetButtonData())
    ;

  p_menu->available_options = available_options;

  while(1)
    {
      uint32_t keys;


      vSetForeColor(vRGB(0,0,0));
      vFillRect(p_menu->x1, p_menu->y1, p_menu->x2, p_menu->y2);
      menu_draw(p_menu);
      vFlipScreen(1);
      msSleep(300);

      keys = wait_key_press();

      if (keys & KEY_UP)
	select_next(p_menu, 0, -1);
      else if (keys & KEY_DOWN)
	select_next(p_menu, 0, 1);
      else if (keys & KEY_LEFT)
	select_next(p_menu, -1, 0);
      else if (keys & KEY_RIGHT)
	select_next(p_menu, 1, 0);
      else if (keys & KEY_SELECT)
	return -1;
      else if (keys & KEY_FIRE ||
	       keys & KEY_FIRE2)
	{
	  int ret = p_menu->cur_sel;
	  int i;

	  if (!is_submenu_title(p_menu, ret))
	    {
	      for (i=0; i<p_menu->n_submenus; i++)
		p_submenus[i] = p_menu->p_submenus[i].sel;
	      p_menu->cur_sel = 0;

	      return ret;
	    }
	}
    }

  return -1;
}
Example #16
0
/* 
 * Move the cursor to a particular id, 
 *   target: where you want it to be 
 */
static void put_cursor(int m, int target)
{
    int voice_id;
    
    menus[m].cursor = target;
    menu_draw(m);

    /* "say" the entry under the cursor */
    if(global_settings.talk_menu)
    {
        voice_id = P2ID(menus[m].items[menus[m].cursor].desc);
        if (voice_id >= 0) /* valid ID given? */
            talk_id(voice_id, false); /* say it */
    }
}
Example #17
0
void menu_loop(struct Menu *menu)
{
	int ret;

	while (1) {
		frame_start();
		menu_draw(menu);
		ret = menu_ctrl(menu);

		if(ret != 0)
			break;

		g_frame_count++;
		frame_end();
	}
}
Example #18
0
void menu(void)
{
  int i;

  menu_init();

  /* let LED on pin 4 of the DIP8 blink */
  //Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 2);
  /*
  pcs(pcs_led_out);
  for( i = 0; i < 10; i++ )
  {
      pcs(pcs_led_high);
      delay_micro_seconds(50000UL);
      pcs(pcs_led_low);
      delay_micro_seconds(50000UL);
  }
  */
  
  //key_add_to_queue(KEY_NEXT);
  
  for(;;)
  {
    if ( menu_handle_key() != 0 || clk_o.is_update != 0 )
    {
      clk_o.is_update = 0;
      oled_start_page(&oled_o);
      do
      {
	menu_draw();
	
	/*
	pcs(pcs_led_high);
	delay_micro_seconds(100000UL);
	pcs(pcs_led_low);
	delay_micro_seconds(100000UL);
	*/
      }
      while( oled_next_page(&oled_o) );      
    }
  }
  
}
Example #19
0
void screen_allmodes(void) {
  int current_item = 0;

  while (1) {
    osd_clrscr();
    menu_draw(&allmodes_menu);
    current_item = menu_exec(&allmodes_menu, current_item);

    switch (current_item) {
    case MENU_ABORT:
    case MENUITEM_AM_EXIT:
      return;

    default:
      screen_modesettings(current_item);
      break;
    }
  }
}
Example #20
0
/* update a valueitem */
static void update_value(menu_t *menu, unsigned int itemid, updatetype_t upd) {
  valueitem_t *value = menu->items[itemid].value;
  int curval = value->get();

  switch (value->type) {
  case VALTYPE_BOOL:
  case VALTYPE_EVENODD:
    /* bool always toggles */
    curval = !curval;
    break;

  case VALTYPE_BYTE:
    if (upd == UPDATE_INCREMENT) {
      if (curval < 255)
        curval++;
    } else {
      if (curval > 0)
        curval--;
    }
    break;

  case VALTYPE_SBYTE:
    if (upd == UPDATE_INCREMENT) {
      if (curval < 99)
        curval++;
    } else {
      if (curval > -99)
        curval--;
    }
    break;
  }

  if (value->set(curval)) {
    /* need a full redraw */
    menu_draw(menu);
    mark_item(menu, itemid, MENUMARKER_LEFT);
  } else {
    /* just update the changed value */
    print_value(menu, itemid);
  }
}
Example #21
0
static window_event_result menubar_handler(window *, const d_event &event, MENU *)
{
	if (event.type == EVENT_WINDOW_DRAW)
	{
		menu_draw(&Menu[0]);
		return window_event_result::handled;
	}
	else if (event.type == EVENT_WINDOW_CLOSE)
	{
		//menu_hide_all();
		//menu_hide( &Menu[0] );
		
		range_for (auto &i, partial_range(Menu, 1u, num_menus))
		{
			if (i.wind)
			{
				window_close(exchange(i.wind, nullptr));
			}
		}
		
		Menu[0].wind = nullptr;
	}
Example #22
0
static void ex_draw()
{
  log_msg("EXCMD", "ex_draw");
  werase(ex.nc_win);

  if (ex.ex_state == EX_CMD_STATE)
    menu_draw(ex.menu);

  pos_T max = layout_size();
  wchar_t *wline = str2wide(ex.line);
  int len = 2 + wcswidth(wline, -1);
  int offset = MAX(len - (max.col - 1), 0);

  mvwaddch(ex.nc_win, 0, 0, ex.state_symbol);
  mvwaddwstr(ex.nc_win, 0, 1, &wline[offset]);
  mvwchgat(ex.nc_win, 0, 0, 1, A_NORMAL, ex.col_symb, NULL);
  mvwchgat(ex.nc_win, 0, 1, -1, A_NORMAL, ex.col_text, NULL);

  doupdate();
  curs_set(1);
  wmove(ex.nc_win, 0, (ex.curpos + 1) - offset);
  wnoutrefresh(ex.nc_win);
  free(wline);
}
Example #23
0
static void draw_page(void)
{
	int n = ACTIVE_PAGE.total_widgets;

	if (ACTIVE_PAGE.draw_full) {
		ACTIVE_PAGE.draw_full();
	} else {

		draw_page_title();
		if (ACTIVE_PAGE.draw_const) ACTIVE_PAGE.draw_const();
		if (ACTIVE_PAGE.predraw_hook) ACTIVE_PAGE.predraw_hook();
	}

	/* this doesn't use widgets[] because it needs to draw the page's
	 * widgets whether or not a dialog is active */
	while (n--)
		draw_widget(ACTIVE_PAGE.widgets + n, n == ACTIVE_PAGE.selected_widget);

	/* redraw the area over the menu if there is one */
	if (status.dialog_type & DIALOG_MENU)
		menu_draw();
	else if (status.dialog_type & DIALOG_BOX)
		dialog_draw();
}
Example #24
0
int main(int argc, char *argv[])
{
	GList* list = NULL;
	json_t *root;

	SDL_Surface *optimized_surface = NULL;
	SDL_Surface *temp = NULL;
	Sound *bg_music = NULL;
	Sound *level_music = NULL;
	int done;
	const Uint8 *keys;
	char imagepath[512];

	game_initialize_system();
	SDL_ShowCursor(SDL_DISABLE);

	bg_music = sound_load_music("sounds/vanguard_bouncy.mp3");
	if(!bg_music)
	{
		slog("Could not load music\n");
	}
	
	level_music = sound_load_music("sounds/chippy_cloud_kid.mp3");
	if(!level_music)
	{
		slog("Could not load music\n");
	}
	Mix_VolumeMusic(5);

	if(temp)
	{
		optimized_surface = SDL_ConvertSurface( temp, graphics_surface->format, NULL );
		SDL_FreeSurface(temp);
		
	}

	SDL_Event e;
	done = 0;

	int lock = true;
	do
	{
		if(menu_flag)
		{
			menu_draw();
			if(lock == false)
			{
				Mix_HaltMusic();
				lock = true;
			}

			if(Mix_PlayingMusic() == 0)
			{
				Mix_PlayMusic(bg_music->music, -1);
			}
		}
		else
		{
			tilemap_render_tile();
			entity_draw_all();
			if(lock == true)
			{
				Mix_HaltMusic();
				lock = false;
			}

			if(Mix_PlayingMusic() == 0)
			{
				Mix_PlayMusic(level_music->music, -1);
			}
		}

		mouse_draw_self();

		graphics_next_frame();
		SDL_PumpEvents();

		entity_think_all();

		while(SDL_PollEvent(&e) != 0)
		{
			if(e.type == SDL_QUIT)
			{
				done = 1;
			}
			
			bool leftclick = false ;
			bool rightclick = false;
			if(e.type == SDL_MOUSEBUTTONDOWN)
			{
				if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT))
				{
					leftclick = true;
				}
				else if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT))
				{
					rightclick = true;
				}
			}

			if(leftclick == true)
			{
				if(menu_flag)
					menu_click();
				else
					tilemap_click();
			}
			else if(rightclick == true)
			{
				if(menu_flag)
					menu_click();
				else
					tilemap_remove_tile();
			}

			bool pressed = false;
			if(e.type == SDL_KEYDOWN)
			{
				if(!pressed)
				{
					if(make_flag)
					{
						keys = SDL_GetKeyboardState(NULL);
						if(keys[SDL_SCANCODE_W])
						{
							State state = UP;
							tilemap_m_click(state);
						}
						else if(keys[SDL_SCANCODE_A])
						{
							State state = LEFT;
							tilemap_m_click(state);
						}
						else if(keys[SDL_SCANCODE_S])
						{
							State state = DOWN;
							tilemap_m_click(state);
						}
						else if(keys[SDL_SCANCODE_D])
						{
							State state = RIGHT;
							tilemap_m_click(state);
						}

						if(keys[SDL_SCANCODE_T])
						{
							State state = UP;
							tilemap_c_click(state);
						}
						else if(keys[SDL_SCANCODE_F])
						{
							State state = LEFT;
							tilemap_c_click(state);
						}
						else if(keys[SDL_SCANCODE_G])
						{
							State state = DOWN;
							tilemap_c_click(state);
						}
						else if(keys[SDL_SCANCODE_H])
						{
							State state = RIGHT;
							tilemap_c_click(state);
						}
					}
				}
				pressed = true;
			}
			else if(e.type == SDL_KEYUP)
			{
				pressed = false;
			}
		}

		keys = SDL_GetKeyboardState(NULL);
		if(keys[SDL_SCANCODE_ESCAPE])
		{
			done = 1;
		}

		SDL_RenderPresent(graphics_renderer); // update the screen with any rendering performed since previous call

	} while(!done);

	exit(0);
	return 0;
}
Example #25
0
void screen_othersettings(void) {
  osd_clrscr();
  menu_draw(&otherset_menu);
  menu_exec(&otherset_menu, 0);
}
static int browser_do_keystroke(GR_EVENT * event)
{
	int ret = 0;

	switch(event->type) {
	case GR_EVENT_TYPE_TIMER:
		if(((GR_EVENT_TIMER *)event)->tid == browser_key_timer) {
			GrDestroyTimer(browser_key_timer);
			browser_key_timer = 0;
			menu_handle_timer(browser_menu, 1);
			browser_action(browser_menu->items[browser_menu->sel].orig_pos);
			browser_do_draw();
		}
		else
			menu_draw_timer(browser_menu);
		break;

	case GR_EVENT_TYPE_KEY_DOWN:
		switch (event->keystroke.ch) {
		case '\r':
		case '\n':
			if(browser_menu->parent == NULL)
				browser_key_timer = GrCreateTimer(browser_wid,
						500);
			else {
				menu_handle_timer(browser_menu, 1);
				browser_menu = menu_handle_item(browser_menu, 
						browser_menu->sel);
				if(browser_menu_overlay) {
					browser_menu = browser_menu_overlay;
					browser_menu_overlay = 0;
				}
				browser_do_draw();
			}	
			break;

		case 'm':
		case 'q':
			browser_menu = menu_destroy(browser_menu);
			ret |= KEY_CLICK;
			if(browser_menu != NULL) {
				browser_do_draw();
				break;
			}
			browser_exit();
			GrDestroyGC(browser_gc);
			pz_close_window(browser_wid);
			break;

		case 'r':
			if (menu_shift_selected(browser_menu, 1)) {
				menu_draw(browser_menu);
				ret |= KEY_CLICK;
			}
			break;

		case 'l':
			if (menu_shift_selected(browser_menu, -1)) {
				menu_draw(browser_menu);
				ret |= KEY_CLICK;
			}
			break;
		default:
			ret |= KEY_UNUSED;
		}
		break;
	case GR_EVENT_TYPE_KEY_UP:
		switch (event->keystroke.ch) {
		case '\r':
		case '\n':
			if(browser_key_timer) {
				GrDestroyTimer(browser_key_timer);
				browser_key_timer = 0;
				menu_handle_timer(browser_menu, 1);
				browser_selection_activated(browser_menu->items[browser_menu->sel].orig_pos);
				browser_do_draw();
			}
			break;
		}
		break;
	default:
		ret |= EVENT_UNUSED;
		break;
	}
	return ret;
}
Example #27
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
  mp_image_t *dmpi = NULL;

  if (vf->priv->passthrough) {
    dmpi=vf_get_image(vf->next, IMGFMT_MPEGPES, MP_IMGTYPE_EXPORT,
                      0, mpi->w, mpi->h);
    dmpi->planes[0]=mpi->planes[0];
    return vf_next_put_image(vf,dmpi, pts);
  }

  if(vf->priv->current->show 
  || (vf->priv->current->parent && vf->priv->current->parent->show)) {
  // Close all menu who requested it
  while(vf->priv->current->cl && vf->priv->current != vf->priv->root) {
    menu_t* m = vf->priv->current;
    vf->priv->current = m->parent ? m->parent :  vf->priv->root;
    menu_close(m);
  }

  // Step 1 : save the picture
  while(go2pause == 1) {
    static char delay = 0; // Hack : wait the 2 frame to be sure to show the right picture
    delay ^= 1; // after a seek
    if(!delay) break;

    if(pause_mpi && (mpi->w != pause_mpi->w || mpi->h != pause_mpi->h ||
		     mpi->imgfmt != pause_mpi->imgfmt)) {
      free_mp_image(pause_mpi);
      pause_mpi = NULL;
    }
    if(!pause_mpi)
      pause_mpi = alloc_mpi(mpi->w,mpi->h,mpi->imgfmt);
    copy_mpi(pause_mpi,mpi);
    mp_input_queue_cmd(mp_input_parse_cmd("pause"));
    go2pause = 2;
    break;
  }

  // Grab // Ungrab the keys
  if(!mp_input_key_cb && vf->priv->current->show)
    mp_input_key_cb = key_cb;
  if(mp_input_key_cb && !vf->priv->current->show)
    mp_input_key_cb = NULL;

  if(mpi->flags&MP_IMGFLAG_DIRECT)
    dmpi = mpi->priv;
  else {
    dmpi = vf_get_image(vf->next,mpi->imgfmt,
			MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
			mpi->w,mpi->h);
    copy_mpi(dmpi,mpi);
  }
  menu_draw(vf->priv->current,dmpi);

  } else {
    if(mp_input_key_cb)
      mp_input_key_cb = NULL;

    if(mpi->flags&MP_IMGFLAG_DIRECT)
      dmpi = mpi->priv;
    else {
      dmpi = vf_get_image(vf->next,mpi->imgfmt,
                          MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
                          mpi->w,mpi->h);

      dmpi->stride[0] = mpi->stride[0];
      dmpi->stride[1] = mpi->stride[1];
      dmpi->stride[2] = mpi->stride[2];
      dmpi->planes[0] = mpi->planes[0];
      dmpi->planes[1] = mpi->planes[1];
      dmpi->planes[2] = mpi->planes[2];
      dmpi->priv      = mpi->priv;
    }
  }
  return vf_next_put_image(vf,dmpi, pts);
}
Example #28
0
int main( int argc, char *arvg[] ) {
	int quit = 0;
	int config_status = 0;
	int event;

#ifdef __WIN32__
	freopen( "cabrio.out", "w", stdout );
	freopen( "cabrio.err", "w", stderr );
#endif

	config_status = config_open( NULL );
	if( config_status == -1 )
		return -1;

	if( sdl_init() != 0 )
		bail();

	if( ogl_init() != 0 )
		bail();
	
	/* Clear the screen as soon as we can. This avoids graphics
	 * glitches which can occur with some SDL implementations. */
	ogl_clear();
	sdl_swap();

	if( event_init() != 0 )
		bail();

	if( font_init() != 0 )
		bail();

	if( config_status == 1 ) {
		/* Config file didn't exist, so run the setup utility */
		if( setup() != 0 )
			return -1;
		config_update();
		if( config_create() != 0 )
			return -1;
	}

	location_init();

	/* If config or location results in a new font, it'll be loaded here. */
	font_free();
	font_init();

	/* Large game lists take a while to initialise,
	 * so show the background while we wait... */
	bg_init();
	bg_clear();
	bg_draw();
	sdl_swap();

	if( platform_init() != 0 )
		bail();

	if( category_init() != 0 )
		bail();

	if( game_sel_init() != 0 )
		bail();

	if( hint_init() != 0 )
		bail();

	if( snap_init() != 0 )
		bail();
	
	if( game_list_create() != 0 )
		bail();

	if( menu_init() != 0 )
		bail();

	if( submenu_init() != 0 )
		bail();

	sound_init();
	video_init();
	
	event_flush();

	if( !config_get()->iface.theme.menu.auto_hide )
		menu_show();
		
	focus_set( FOCUS_GAMESEL );

	while( !quit ) {
		ogl_clear();
		bg_draw();
		snap_draw();
		if (!config_get()->iface.hide_buttons)
			hint_draw();
		menu_draw();
		submenu_draw();
		game_sel_draw();
		sdl_swap();
		if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) 
			playmusic();
		if (( event = event_poll() )) {
			if( supress_wait == 0 ) {
				if( event == EVENT_QUIT ) {
					quit = 1;
				}
				else {
					supress();
					event_process( event );
				}
			}
		}
		if( supress_wait > 0 )
			supress_wait--;
		
		sdl_frame_delay();
	}
	clean_up();
	return 0;
}
Example #29
0
void PuyoCommander::updateAll(PuyoDrawable *starter, SDL_Surface *extra_surf)
{
  Uint32  now = 0;

  // mise a jour
  menu_update (mainMenu, display);

  menu_update(gameOver2PMenu, display);
  menu_update(gameOver1PMenu, display);
  menu_update(nextLevelMenu, display);
  menu_update(finishedMenu, display);
  menu_update(looserMenu, display);

  menu_update (optionMenu, display);
  menu_update (controlsMenu, display);
  menu_update (rulesMenu, display);
  menu_update (highScoresMenu, display);
  menu_update (aboutMenu, display);
  menu_update (mustRestartMenu, display);
  menu_update (singleGameMenu, display);
  menu_update (twoPlayerGameMenu, display);
  menu_update (menu_pause,display);
  scrolling_text_update(scrollingText, display);
  doom_melt_update(melt);

  // affichage eventuel (pourrait ne pas avoir lieu de tps en tps si machine
  // trop lente)
  cycle++;
  now = SDL_GetTicks ();

  if ((now < (start_time + (cycle + TIME_TOLERANCE) * cycle_duration))
                  || (cycle - lastRenderedCycle > maxFrameDrop))
  {
    lastRenderedCycle = cycle;

    if (starter) {
      starter->draw();
    }
    else {
      SDL_BlitSurface (menuBGImage->surf, NULL, display, NULL);
    }

    if (corona)
    {
        short frequency[2][512];
        for (int i=0; i<512; ++i) { // Generate random sound.
            frequency[0][i] = rand();
            frequency[1][i] = rand();
        }
        corona32_update(corona, SDL_GetTicks(), frequency);
        corona32_displayRGBA(corona, corona_screen);
        SDL_Surface *tmpsurf =
            SDL_CreateRGBSurfaceFrom (corona_screen, 320, CORONA_HEIGHT,
                                      32, 320*4,
                                      0x00ff0000, 0x0000ff00, 0x000000ff,
                                      0xff000000);
        SDL_Rect rect;
        rect.x = 0;
        rect.y = 240 - tmpsurf->h;
        rect.w = tmpsurf->w;
        rect.h = tmpsurf->h;
        SDL_BlitSurface(tmpsurf, NULL, display, &rect);
        SDL_FreeSurface (tmpsurf);
    }
    if (extra_surf)
    {
        SDL_Rect rect;
        rect.x = 0;
        rect.y = 240 - extra_surf->h;
        rect.w = extra_surf->w;
        rect.h = extra_surf->h;
        SDL_BlitSurface(extra_surf, NULL, display, &rect);
    }

    if (!starter)
      scrolling_text_draw(scrollingText, display, 220);

    menu_draw (mainMenu, display);
    menu_draw(gameOver2PMenu, display);
    menu_draw(gameOver1PMenu, display);
    menu_draw(nextLevelMenu, display);
    menu_draw(finishedMenu, display);
    menu_draw(looserMenu, display);
    menu_draw (optionMenu, display);
    menu_draw (controlsMenu, display);
    menu_draw (rulesMenu, display);
    menu_draw (highScoresMenu, display);
    menu_draw (aboutMenu, display);
    menu_draw (mustRestartMenu, display);
    menu_draw (singleGameMenu, display);
    menu_draw (twoPlayerGameMenu, display);
    menu_draw(menu_pause,display);
    doom_melt_display(melt, display);
    SDL_Flip (display);
  }

  // delay si machine trop rapide
  now = SDL_GetTicks ();
  if (now < (start_time + cycle * cycle_duration)) {
    int ttw = ((start_time + cycle * cycle_duration) - now);
    ttw /= 2;
    SDL_Delay (ttw);
  }
}
Example #30
0
void screen_mainmenu(void) {
  int current_item = 0;

  while (1) {
    modeset_mode = current_videomode;

    /* (re)draw */
    osd_clrscr();
    menu_draw(&mainmenu);

    /* run */
    current_item = menu_exec(&mainmenu, current_item);

    switch (current_item) {
    case MENU_ABORT:
    case MENUITEM_EXIT:
      return;

    case MENUITEM_OSDSET:
      screen_osdsettings();
      break;

    case MENUITEM_OTHERSET:
      screen_othersettings();
      break;

    case MENUITEM_VIEWALL:
      screen_allmodes();
      break;

    case MENUITEM_ABOUT:
      screen_about();
      break;

    case MENUITEM_STORE:
      osd_clrscr();

      /* show "saving" message because page erase needs 1-3s */
      osd_fillbox(13, 13, 18, 3, ' ' | ATTRIB_DIM_BG);
      osd_drawborder(13, 13, 18, 3);
      osd_gotoxy(15, 14);
      osd_puts("Saving...");

      spiflash_write_settings();

      osd_gotoxy(15, 14);
      osd_puts("Settings saved");

      /* wait until all buttons are released */
      while (pad_buttons & PAD_ALL)
        if (pad_buttons & PAD_VIDEOCHANGE)
          return;

      /* now wait for any button press */
      pad_clear(PAD_ALL);
      while (!(pad_buttons & PAD_ALL))
        if (pad_buttons & PAD_VIDEOCHANGE)
          return;
      pad_clear(PAD_ALL);

      break;

    default:
      break;
    }
  }
}