예제 #1
0
파일: menu.c 프로젝트: joakim-d/GroBoy
void load_gui(SDL_Surface *sdl_screen) {
    static Uint8 *keystate;
    int play = 0;

    if(load_bmp("fonts/gui_font.bmp") == -1) {
        printf("Loading bmp font error\n");
    }

    bg_color = SDL_MapRGB(sdl_screen->format, 255, 255, 255);
    display_menu(sdl_screen);
    cursor_pos = 0;
    while (!play) {
        SDL_PumpEvents();
        keystate = SDL_GetKeyState(NULL);
        if(keystate[SDLK_UP]) {
            move_cursor(sdl_screen, UP);
        }
        if(keystate[SDLK_DOWN]) {
            if(strcmp(selected_game, "") == 0 && cursor_pos < 2) move_cursor(sdl_screen, DOWN);
            else if (strcmp(selected_game, "") != 0 && cursor_pos < 3) move_cursor(sdl_screen, DOWN);
        }
        if(keystate[SDLK_RETURN]) play = menu_action(sdl_screen);
        if(keystate[SDLK_ESCAPE]) break;
        SDL_Flip(sdl_screen);
        SDL_Delay(100);
    }
}
예제 #2
0
파일: menu.cpp 프로젝트: maxteufel/supertux
void
Menu::process_action(const MenuAction& menuaction)
{
  int last_active_item = active_item;

  switch(menuaction) {
    case MENU_ACTION_UP:
      do {
        if (active_item > 0)
          --active_item;
        else
          active_item = int(items.size())-1;
      } while (items[active_item]->skippable()
               && (active_item != last_active_item));
      break;

    case MENU_ACTION_DOWN:
      do {
        if(active_item < int(items.size())-1 )
          ++active_item;
        else
          active_item = 0;
      } while (items[active_item]->skippable()
               && (active_item != last_active_item));
      break;

    case MENU_ACTION_BACK:
      if(on_back_action()) {
        MenuManager::instance().pop_menu();
      }
      return;
      break;

    default:
      break;
  }

  if (items[active_item]->no_other_action()) {
    items[active_item]->process_action(menuaction);
    return;
  }

  items[active_item]->process_action(menuaction);
  if(items[active_item]->changes_width()) {
    calculate_width();
  }
  if(menuaction == MENU_ACTION_HIT) {
    menu_action(*items[active_item]);
  }
}
예제 #3
0
파일: menu.cpp 프로젝트: Narre/supertux
void
Menu::process_action(MenuAction menuaction)
{
  int last_active_item = active_item;

  switch(menuaction) {
    case MENU_ACTION_UP:
      do {
        if (active_item > 0)
          --active_item;
        else
          active_item = int(items.size())-1;
      } while (items[active_item]->skippable()
               && (active_item != last_active_item));
      break;
    case MENU_ACTION_DOWN:
      do {
        if(active_item < int(items.size())-1 )
          ++active_item;
        else
          active_item = 0;
      } while (items[active_item]->skippable()
               && (active_item != last_active_item));
      break;
    default:
      break;
  }

  if (items[active_item]->no_other_action()) {
    items[active_item]->process_action(menuaction);
    return;
  }

  items[active_item]->process_action(menuaction);
  switch(menuaction) {

    case MENU_ACTION_BACK:
      MenuManager::instance().pop_menu();
      break;

    case MENU_ACTION_HIT: {
      menu_action(items[active_item].get());
      break;
    }

    default:
      break;
  }
}
예제 #4
0
파일: main.c 프로젝트: ohayak/tars_code
void menu_control(uint8_t c)
{
  if(c == '0')
    menu_goto(menu_left(menu_current()));
  else if(c=='8')
    menu_goto(menu_right(menu_current()));
  else if(c=='*')
    {
      menu_goto(menu_up(menu_current()));
      if(menu_current() == 0)
	menu_goto(menu_down(menu_current()));
    }
  else if(c=='#')
    {
      if(menu_is_leaf(menu_current()))
	menu_action();
      else
	menu_goto(menu_down(menu_current()));
    }

  menu_print();
}
예제 #5
0
파일: menu.c 프로젝트: robots/reflow-oven
void menu_do()
{
	uint16_t new_pos;
	const struct menuitem_t *menu;
		
	// initialize menu
	menu_depth = 0;
	menu_pos_stack[menu_depth] = 0;
	menu_item_stack[menu_depth] = menu_main;

	while (1) {
		uint8_t event = enc_read();
		
		// check encoder
		if (event == ENC_UP) {
			if (menu_pos_stack[menu_depth] > 0)
				menu_pos_stack[menu_depth]--;
		} else if (event == ENC_DOWN) {
			new_pos = menu_pos_stack[menu_depth] + 1;
			menu = menu_item_stack[menu_depth];

			if (pgm_read_byte(&menu[new_pos].type) != MENU_LAST)
				menu_pos_stack[menu_depth] = new_pos;
		}

		// check button - with stupid debouncer
		if (!(BUTTONS & _BV(BUT))) {
			_delay_ms(1);
			while (!(BUTTONS & _BV(BUT)));
			menu_action();
			_delay_ms(1);
			while (!(BUTTONS & _BV(BUT)));
		}

		menu_redraw();

		_delay_ms(10);
	}
}
예제 #6
0
static void SetRateCB(Widget w, XtPointer closure,XtPointer call_data)
{
	char *text,*tag;
	float rateVal;
	Boolean UpdateRequired;
	
	
	text = XmTextFieldGetString(rate_tag);
	puts(text);
   	if(ParseRateParTag(text,&tag,rate_tag,rate_dlg,cur_rpar))
	{
		XtFree(text);   
		return ;
	}
	
	tag=strdup(tag);
	XtFree(text);
	
	text = XmTextFieldGetString(rate_rate);
	
	if(ParseRate(text,&rateVal))
	{
		free(tag);   
		XtFree(text);
		ShowErrorDialog("Rate must be a positive number !",rate_dlg);
		XmProcessTraversal(rate_rate,XmTRAVERSE_CURRENT);			
		return ;
	} 
	
	XtFree(text);

    if(cur_rpar == NULL)
	{
		struct rpar_object * l_rpar;
		
		cur_rpar = (struct rpar_object *) emalloc(RPAOBJ_SIZE);
		cur_rpar->tag = NULL;
		cur_rpar->center.x = fix_x;
		cur_rpar->center.y = fix_y;
		cur_rpar->next = NULL;
		cur_rpar->layer = NewLayerList(CURRENTVIEWANDWHOLE,NULL);
		
		if (netobj->rpars == NULL)
			l_rpar = NULL;
		else
			for (l_rpar = netobj->rpars;l_rpar->next != NULL; l_rpar = l_rpar->next);
		
		if (l_rpar != NULL)
			l_rpar->next = cur_rpar;
		else
			netobj->rpars = cur_rpar;
		
		UpdateRequired=FALSE;
		
	}
	else
		ShowRpar(cur_rpar, CLEAR);
	
     XFlush(XtDisplay(rate_dlg));
	
     if(UpdateRequired)
	{
		ShowRate(FALSE);
	}	
	
     if(cur_rpar->tag != NULL)
		free(cur_rpar->tag);
	
     cur_rpar->tag=tag;
     cur_rpar->value=rateVal;
	
     if(UpdateRequired)
	{
		if (rate_visible)
			ShowRate(TRUE);
	}	
	
    ShowRpar(cur_rpar, OR);
    ClearRes();
    menu_action();	
    SetModify();
    HideRateChangeDialog();
}
예제 #7
0
파일: dlg-vsid.c 프로젝트: AreaScout/vice
static MRESULT EXPENTRY pm_vsid(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    extern int trigger_shutdown;

    switch (msg) {
        case WM_INITDLG:
            {
                HWND hmenu;
                HPOINTER hicon = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, DLG_VSID);

                if (hicon) {
                    WinSendMsg(hwnd, WM_SETICON, MPFROMLONG(hicon), MPVOID);
                }

                //
                // Try to attach the menu and make it visible
                //
                hmenu = WinLoadMenu(hwnd, NULLHANDLE, IDM_VICE2);
                if (hmenu) {
                    SWP swp;
                    WinQueryWindowPos(hwnd, &swp);

                    WinDelMenuItem(hmenu, IDM_FILE);
                    WinDelMenuItem(hmenu, IDM_VIEW);
                    WinDelMenuItem(hmenu, IDM_SETUP);
                    WinDelMenuItem(hmenu, IDM_MONITOR);

                    swp.cy += WinQuerySysValue(HWND_DESKTOP, SV_CYMENU) + 1;
                    WinSetWindowPos(hwnd, 0, 0, 0, swp.cx, swp.cy, SWP_SIZE);

                    WinSendMsg(hwnd, WM_UPDATEFRAME, MPFROMLONG(FID_MENU), MPVOID);
                }

                WinSubclassDlg(hwnd, ID_TBOX, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TNAME, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TAUTHOR, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TCOPYRIGHT, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TSYNC, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TIRQ, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TSID, pm_vsid_dragndrop);
            }
            return FALSE;
        case WM_MENUSELECT:
            menu_select(HWNDFROMMP(mp2), SHORT1FROMMP(mp1));
            break;
        case WM_DESTROY:
            trigger_shutdown = 1;
            break;
        case WM_COMMAND:
            switch (LONGFROMMP(mp1)) {
                case DID_CLOSE:
                    trigger_shutdown = 1;
                    break;
                default:
                    menu_action(hwnd, SHORT1FROMMP(mp1));
                    return FALSE;
            }
            break;
        case WM_CONTROL:
            if (mp1 == MPFROM2SHORT(SPB_SETTUNE, SPBN_ENDSPIN)) {
                const ULONG val = WinGetSpinVal((HWND)mp2);

                resources_set_int("PSIDTune", (int)val);
            }
            break;
        case WM_DISPLAY:
            {
                char *txt = lib_msprintf("Vice/2 SID Player - %d%%", mp1);

                WinSetDlgItemText(hwnd, FID_TITLEBAR, txt);
                lib_free(txt);
            }
            return FALSE;
    }
    return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
예제 #8
0
static void menu_action_stop_movie(GtkWidget * menuitem, gpointer userdata)
{
    menu_action(menuitem, "stop_movie", userdata);
}
예제 #9
0
static void menu_action_scene(GtkWidget * menuitem, gpointer userdata)
{
    menu_action(menuitem, "scene", userdata);
}
예제 #10
0
static void menu_action_screen_shot(GtkWidget * menuitem, gpointer userdata)
{
    menu_action(menuitem, "screen_shot", userdata);
}
예제 #11
0
static void menu_action_perspective(GtkWidget * menuitem, gpointer userdata)
{
    menu_action(menuitem, "perspective", userdata);
}
예제 #12
0
static void menu_action_iface_30d(GtkWidget * menuitem, gpointer userdata)
{
    menu_action(menuitem, "iface3.0D", userdata);
}
예제 #13
0
static void menu_action_ortho(GtkWidget * menuitem, gpointer userdata)
{
    menu_action(menuitem, "ortho", userdata);
}
예제 #14
0
static void menu_action_reset_camera(GtkWidget * menuitem, gpointer userdata)
{
    menu_action(menuitem, "reset_camera", userdata);
}
예제 #15
0
static void menu_action_buffer_manager(GtkWidget * menuitem, gpointer userdata)
{
    menu_action(menuitem, "buffer_manager", userdata);
}
예제 #16
0
void
Menu::process_action(MenuAction menuaction)
{
  int last_active_item = active_item;
  switch(menuaction) {
    case MENU_ACTION_UP:
      do {
        if (active_item > 0)
          --active_item;
        else
          active_item = int(items.size())-1;
      } while ((items[active_item]->kind == MN_HL
                || items[active_item]->kind == MN_LABEL
                || items[active_item]->kind == MN_INACTIVE)
               && (active_item != last_active_item));

      break;

    case MENU_ACTION_DOWN:
      do {
        if(active_item < int(items.size())-1 )
          ++active_item;
        else
          active_item = 0;
      } while ((items[active_item]->kind == MN_HL
                || items[active_item]->kind == MN_LABEL
                || items[active_item]->kind == MN_INACTIVE)
               && (active_item != last_active_item));

      break;

    case MENU_ACTION_LEFT:
      if(items[active_item]->kind == MN_STRINGSELECT) {
        if(items[active_item]->selected > 0)
          items[active_item]->selected--;
        else
          items[active_item]->selected = items[active_item]->list.size()-1;

        menu_action(items[active_item].get());
      }
      break;

    case MENU_ACTION_RIGHT:
      if(items[active_item]->kind == MN_STRINGSELECT) {
        if(items[active_item]->selected+1 < items[active_item]->list.size())
          items[active_item]->selected++;
        else
          items[active_item]->selected = 0;

        menu_action(items[active_item].get());
      }
      break;

    case MENU_ACTION_HIT: {
      switch (items[active_item]->kind) {
        case MN_GOTO:
          assert(items[active_item]->target_menu != 0);
          MenuManager::instance().push_menu(items[active_item]->target_menu);
          break;

        case MN_TOGGLE:
          items[active_item]->toggled = !items[active_item]->toggled;
          menu_action(items[active_item].get());
          break;

        case MN_CONTROLFIELD:
          menu_action(items[active_item].get());
          break;

        case MN_ACTION:
          menu_action(items[active_item].get());
          break;

        case MN_STRINGSELECT:
          if(items[active_item]->selected+1 < items[active_item]->list.size())
            items[active_item]->selected++;
          else
            items[active_item]->selected = 0;

          menu_action(items[active_item].get());
          break;

        case MN_TEXTFIELD:
        case MN_NUMFIELD:
          menuaction = MENU_ACTION_DOWN;
          process_input();
          break;

        case MN_BACK:
          MenuManager::instance().pop_menu();
          return;

        default:
          break;
      }
      break;
    }

    case MENU_ACTION_REMOVE:
      if(items[active_item]->kind == MN_TEXTFIELD
         || items[active_item]->kind == MN_NUMFIELD)
      {
        if(!items[active_item]->input.empty())
        {
          int i = items[active_item]->input.size();

          while(delete_character > 0)        /* remove characters */
          {
            items[active_item]->input.resize(i-1);
            delete_character--;
          }
        }
      }
      break;

    case MENU_ACTION_INPUT:
      if(items[active_item]->kind == MN_TEXTFIELD
         || (items[active_item]->kind == MN_NUMFIELD
             && mn_input_char >= '0' && mn_input_char <= '9'))
      {
        items[active_item]->input.push_back(mn_input_char);
      }
      break;

    case MENU_ACTION_BACK:
      MenuManager::instance().pop_menu();
      return;

    case MENU_ACTION_NONE:
      break;
  }
}
예제 #17
0
/* ------------ */
main()
{
register int which; 										/* Ausgel�ste Aktion */
register int i; 												/* Schleifenindex */
int msg[8]; 														/* Message-Buffer */
int dummy;															/* f�r unwichtige Werte */

appl_init();
open_vwork();

fnt_path[0] = Dgetdrv() + 'A';					/* Aktuellen Pfad ermitteln*/
fnt_path[1] = ':';
Dgetpath(fnt_path + 2, 0);
strcat(fnt_path, "\\*.FNT");

rsrc_load("VDI_FONT.RSC");							/* RSC laden */

graf_mouse(ARROW, 0L);									/* Mauspfeil */

set_workarea(); 												/* Hintergrund anlegen */
count_defined();
set_marker(); 													/* Marker positionieren */
restore_char(); 												/* Erstes Zeichen holen */
show_ccharacter();

do
	{
	which = evnt_multi(MU_BUTTON|MU_KEYBD|MU_MESAG,
										 2, 1, 1,
										 0, 0, 0, 0, 0,
										 0, 0, 0, 0, 0,
										 msg,
										 0, 0,
										 &mousex, &mousey, &dummy,
										 &dummy, &key, &clicks);


	switch(which)
		{
		case MU_KEYBD:											/* Tastendruck ? */
			if ((char)key >= 'a' && (char)key <= 'z')
				key &= 0xDF;
				
			if (!(char)key) 									/* Kontrolltaste ?*/
				{
				key >>= 8;
				key |= 0x80;
				}

			for (i = 0; i < KEY_NUM; i++)					/* Passenden Men�eintrag suchen */
				if (m_keys[i] == (char)key)
					{
					which = MU_MESAG;
					msg[0] = MN_SELECTED;
					msg[4] = m_entry[i];
					menu_action(msg); 						/* Men�eintrag ausf�hren */
					break;
					}
			break;

		case MU_MESAG:
			if (msg[0] == MN_SELECTED)				/* Men�eintrag ? */
				{
				menu_action(msg);
				menu_tnormal(menu_adr, msg[3], TRUE);
				}
			break;

		case MU_BUTTON:
			button_click(); 									/* Mausklick */
			break;
		}

	}while(which != MU_MESAG || msg[0] != MN_SELECTED || msg[4] != F_OK);

cls_vwork();
appl_exit();
}