static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) { switch(cmd->id) { case MP_CMD_PAUSE : #if 0 // http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2003-March/017286.html if(!paused && !go2pause) { // Initial pause cmd -> wait the next put_image go2pause = 1; return 1; } #endif if(go2pause == 2) // Msg resent by put_image after saving the image go2pause = 0; break; case MP_CMD_MENU : { // Convert txt cmd from the users into libmenu stuff char* arg = cmd->args[0].v.s; if(!priv->current->show && !(strcmp(arg,"hide") == 0) ) priv->current->show = 1; else if(strcmp(arg,"up") == 0) menu_read_cmd(priv->current,MENU_CMD_UP); else if(strcmp(arg,"down") == 0) menu_read_cmd(priv->current,MENU_CMD_DOWN); else if(strcmp(arg,"left") == 0) menu_read_cmd(priv->current,MENU_CMD_LEFT); else if(strcmp(arg,"right") == 0) menu_read_cmd(priv->current,MENU_CMD_RIGHT); else if(strcmp(arg,"ok") == 0) menu_read_cmd(priv->current,MENU_CMD_OK); else if(strcmp(arg,"cancel") == 0) menu_read_cmd(priv->current,MENU_CMD_CANCEL); else if(strcmp(arg,"hide") == 0 || strcmp(arg,"toggle") == 0) priv->current->show = 0; else mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnknownMenuCommand,arg); return 1; } case MP_CMD_SET_MENU : { char* menu = cmd->args[0].v.s; menu_t* l = priv->current; priv->current = menu_open(menu); if(!priv->current) { mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToOpenMenu,menu); priv->current = l; priv->current->show = 0; } else { priv->current->show = 1; priv->current->parent = l; } return 1; } } return 0; }
static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) { switch(cmd->id) { case MP_CMD_MENU : { // Convert txt cmd from the users into libmenu stuff char* arg = cmd->args[0].v.s; if (!priv->current->show && strcmp(arg,"hide")) priv->current->show = 1; else if(strcmp(arg,"up") == 0) menu_read_cmd(priv->current,MENU_CMD_UP); else if(strcmp(arg,"down") == 0) menu_read_cmd(priv->current,MENU_CMD_DOWN); else if(strcmp(arg,"left") == 0) menu_read_cmd(priv->current,MENU_CMD_LEFT); else if(strcmp(arg,"right") == 0) menu_read_cmd(priv->current,MENU_CMD_RIGHT); else if(strcmp(arg,"ok") == 0) menu_read_cmd(priv->current,MENU_CMD_OK); else if(strcmp(arg,"cancel") == 0) menu_read_cmd(priv->current,MENU_CMD_CANCEL); else if(strcmp(arg,"home") == 0) menu_read_cmd(priv->current,MENU_CMD_HOME); else if(strcmp(arg,"end") == 0) menu_read_cmd(priv->current,MENU_CMD_END); else if(strcmp(arg,"pageup") == 0) menu_read_cmd(priv->current,MENU_CMD_PAGE_UP); else if(strcmp(arg,"pagedown") == 0) menu_read_cmd(priv->current,MENU_CMD_PAGE_DOWN); else if(strcmp(arg,"click") == 0) menu_read_cmd(priv->current,MENU_CMD_CLICK); else if(strcmp(arg,"hide") == 0 || strcmp(arg,"toggle") == 0) priv->current->show = 0; else mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnknownMenuCommand,arg); return 1; } case MP_CMD_SET_MENU : { char* menu = cmd->args[0].v.s; menu_t* l = priv->current; priv->current = menu_open(menu); if(!priv->current) { mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToOpenMenu,menu); priv->current = l; priv->current->show = 0; } else { priv->current->show = 1; priv->current->parent = l; } return 1; } } return 0; }
void player_hit() { game.health--; game.bg_color = COLOR_DARK_RED; soundbuf_play( &game.sound_hit, 0 ); if (game.health < 1) { game.status = STATUS_MENU; menu_open( MENU_GAME_OVER ); level_passed_score_str[1] = '0' + (game.score / 1000) % 10; level_passed_score_str[2] = '0' + (game.score / 100) % 10; level_passed_score_str[3] = '0' + (game.score / 10) % 10; level_passed_score_str[4] = '0' + (game.score / 1) % 10; }; };
static int open_vf(vf_instance_t *vf, char* args){ if(!st_priv) { st_priv = calloc(1,sizeof(struct vf_priv_s)); st_priv->root = st_priv->current = menu_open(args); if(!st_priv->current) { free(st_priv); st_priv = NULL; return 0; } st_priv->root->show = menu_startup; mp_input_add_cmd_filter((mp_input_cmd_filter)cmd_filter,st_priv); } vf->config = config; vf->query_format=query_format; vf->put_image = put_image; vf->get_image = get_image; vf->uninit=uninit; vf->priv=st_priv; go2pause=0; return 1; }
void indicator_disk_mouse(Indicator *indicator, XButtonPressedEvent *ev) { if(ev->type != ButtonPress) { return; } if(ev->window==menu.window) { indicator_disk_expose(indicator, ev->window); return; } switch(ev->button) { case Button1: case Button3: if(indicator->active) menu_close(indicator); else menu_open(indicator); return; case Button4: break; case Button5: break; } if(indicator->active) indicator_disk_expose(indicator, menu.window); }
void creditsExit () { creditsReset(); menu_open(); }
void indicator_music_mouse(Indicator *indicator, XButtonPressedEvent *ev) { if(ev->type != ButtonPress) { Window w; int tmp; int x, y; unsigned int mask; XQueryPointer(dpy, menu.window, &w, &w, &tmp, &tmp, &x, &y, &mask); menu.selected=-1; if(x>=0&&y>=0&&x<menu.w&&y<menu.h) { if(mask&0x100&&y/bh==1) { int sliderw=menu.w-10*2; snd_mixer_handle_events(alsa.handle); volume_set(100*(x-10)/sliderw); } menu.selected=y/bh; menu.button=x>=menu.w/2-BUTTON_W*3/2&&x<menu.w/2+BUTTON_W*2/2?(x-(menu.w/2-BUTTON_W*3/2))/BUTTON_W:-1; } indicator_music_expose(indicator, menu.window); return; } if(ev->window==menu.window) { int sliderw=menu.w-10*2; int item=ev->y/bh; struct MEDIAPLAYER *mp; if(item==0) { snd_mixer_handle_events(alsa.handle); mute_set(!mute_get()); } else if(item==1) { if(ev->x>=10&&ev->x<menu.w-10) { snd_mixer_handle_events(alsa.handle); volume_set(100*(ev->x-10)/sliderw); } } else { int i; for(mp=mediaplayer, i=2; mp; mp=mp->next, i+=5) if(item==i) { mediaplayer_raise(mp->id); indicator->active=False; menu_close(); break; } else if(item==i+4&&menu.button>=0) { mediaplayer_action(mp->id, menu.button); indicator_music_expose(indicator, ev->window); } return; } indicator_music_expose(indicator, ev->window); return; } switch(ev->button) { case Button1: case Button3: if((indicator->active=!indicator->active)) menu_open(indicator); else menu_close(); return; case Button4: snd_mixer_handle_events(alsa.handle); volume_set(volume_get()+6); break; case Button5: snd_mixer_handle_events(alsa.handle); volume_set(volume_get()-4); break; } if(indicator->active) indicator_music_expose(indicator, menu.window); }
/* Event処理 */ static void sdl_getEvent(void) { SDL_Event e; boolean m2b = FALSE, msg_skip = FALSE, had_event = FALSE; int i; while (SDL_PollEvent(&e)) { had_event = TRUE; switch (e.type) { case SDL_ACTIVEEVENT: if (e.active.state & SDL_APPMOUSEFOCUS) { ms_active = e.active.gain; #if 0 if (sdl_fs_on) { if (ms_active) { SDL_WM_GrabInput(SDL_GRAB_ON); } else { SDL_WM_GrabInput(SDL_GRAB_OFF); } } #endif } if (e.active.state & SDL_APPINPUTFOCUS) { } break; case SDL_KEYDOWN: keyEventProsess(&e.key, TRUE); break; case SDL_KEYUP: keyEventProsess(&e.key, FALSE); if (e.key.keysym.sym == SDLK_F1) msg_skip = TRUE; if (e.key.keysym.sym == SDLK_F4) { SDL_WM_ToggleFullScreen(sdl_display); sdl_fs_on = !sdl_fs_on; } break; case SDL_MOUSEMOTION: mousex = e.motion.x; mousey = e.motion.y; break; case SDL_MOUSEBUTTONDOWN: mouseb |= (1 << e.button.button); RawKeyInfo[mouse_to_rawkey(e.button.button)] = TRUE; #if 0 if (e.button.button == 2) { keywait_flag=TRUE; } #endif break; case SDL_MOUSEBUTTONUP: mouseb &= (0xffffffff ^ (1 << e.button.button)); RawKeyInfo[mouse_to_rawkey(e.button.button)] = FALSE; if (e.button.button == 2) { m2b = TRUE; } break; #if HAVE_SDLJOY case SDL_JOYAXISMOTION: if (abs(e.jaxis.value) < 0x4000) { joyinfo &= e.jaxis.axis == 0 ? ~0xc : ~3; } else { i = (e.jaxis.axis == 0 ? 2 : 0) + (e.jaxis.value > 0 ? 1 : 0); joyinfo |= 1 << i; } break; case SDL_JOYBALLMOTION: break; case SDL_JOYHATMOTION: break; case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: if (e.jbutton.button < 4) { i = 1 << (e.jbutton.button+4); if (e.jbutton.state == SDL_PRESSED) joyinfo |= i; else joyinfo &= ~i; } else { if (e.jbutton.state == SDL_RELEASED) { } } break; #endif case SDL_VIDEORESIZE: sdl_updateAll(true); break; default: printf("ev %x\n", e.type); break; } } if (!had_event) usleep(1000); if (m2b) { menu_open(); } if (msg_skip) set_skipMode(!get_skipMode()); }