예제 #1
0
GUI_status InputDialog::KeyDown(SDL_keysym key) {
	KeyBinder *keybinder = Game::get_game()->get_keybinder();
	ActionType a = keybinder->get_ActionType(key);

	switch(keybinder->GetActionKeyType(a))
	{
		case NORTH_KEY:
		case WEST_KEY:
			if(b_index_num != -1)
				button_index[b_index_num]->set_highlighted(false);

			if(b_index_num <= 0)
				b_index_num = last_index;
			else
				b_index_num = b_index_num - 1;
			button_index[b_index_num]->set_highlighted(true); break;
		case SOUTH_KEY:
		case EAST_KEY:
			if(b_index_num != -1)
				button_index[b_index_num]->set_highlighted(false);

			if(b_index_num == last_index)
				b_index_num = 0;
			else
				b_index_num += 1;
			button_index[b_index_num]->set_highlighted(true); break;
		case DO_ACTION_KEY: if(b_index_num != -1) return button_index[b_index_num]->Activate_button(); break;
		case CANCEL_ACTION_KEY: return close_dialog();
		default: keybinder->handle_always_available_keys(a); break;
	}
	return GUI_YUM;
}
예제 #2
0
파일: ActorView.cpp 프로젝트: Zabeus/nuvie
/* Move the cursor around and use command icons.
 */
GUI_status ActorView::KeyDown(SDL_keysym key)
{
	if(!show_cursor) // FIXME: don't rely on show_cursor to get/pass focus
		return(GUI_PASS);
	KeyBinder *keybinder = Game::get_game()->get_keybinder();
	ActionType a = keybinder->get_ActionType(key);

	switch(keybinder->GetActionKeyType(a))
	{
		case SOUTH_WEST_KEY:
		case NORTH_WEST_KEY:
		case WEST_KEY:
			moveCursorToButton(cursor_pos.x - 1);
			break;
		case NORTH_EAST_KEY:
		case SOUTH_EAST_KEY:
		case EAST_KEY:
			moveCursorToButton(cursor_pos.x + 1);
			break;
		case DO_ACTION_KEY:
			select_button();
			break;
		case NORTH_KEY: // would otherwise move invisible mapwindow cursor
		case SOUTH_KEY:
			break;
		default:
//			set_show_cursor(false); // newAction() can move cursor here
			return GUI_PASS;
	}
	return(GUI_YUM);
}
예제 #3
0
파일: SpellView.cpp 프로젝트: Zabeus/nuvie
/* Move the cursor around
 */
GUI_status SpellView::KeyDown(SDL_keysym key)
{
    KeyBinder *keybinder = Game::get_game()->get_keybinder();
    ActionType a = keybinder->get_ActionType(key);

    switch(keybinder->GetActionKeyType(a))
    {
        case NORTH_KEY:
            return move_up();
        case SOUTH_KEY:
            return move_down();
        case WEST_KEY:
        case PREVIOUS_PARTY_MEMBER_KEY:
        	move_left();
            break;
        case EAST_KEY:
        case NEXT_PARTY_MEMBER_KEY:
            move_right();
            break;
        case HOME_KEY:
// TODO - add going to first viable page
            break;
        case END_KEY:
// TODO - add going to last viable page
            break;
        case DO_ACTION_KEY:
        	if(Game::get_game()->get_event()->is_looking_at_spellbook())
        	{
        		show_spell_description();
        		return GUI_YUM;
        	}
        	if(event_mode)
        	{
        		event_mode_select_spell();
        		return GUI_YUM;
        	}

        	return GUI_PASS;
        case CANCEL_ACTION_KEY:
            return cancel_spell();
        case TOGGLE_CURSOR_KEY :

        	break;

        default:
            return GUI_PASS;
    }
    return(GUI_YUM);
}
예제 #4
0
GUI_status ScrollWidgetGump::KeyDown(SDL_keysym key)
{
	ScrollEventType event = SCROLL_ESCAPE;

	KeyBinder *keybinder = Game::get_game()->get_keybinder();
	ActionType a = keybinder->get_ActionType(key);

	switch(keybinder->GetActionKeyType(a))
	{
	case MSGSCROLL_DOWN_KEY: event = SCROLL_PAGE_DOWN; break;
	case SOUTH_KEY: event = SCROLL_DOWN; break;
	case MSGSCROLL_UP_KEY: event = SCROLL_PAGE_UP; break;
	case NORTH_KEY: event = SCROLL_UP; break;
	case HOME_KEY: event = SCROLL_TO_BEGINNING; break;
	case END_KEY: event = SCROLL_TO_END; break;
	default : break;
	}

	if(scroll_movement_event(event) == GUI_YUM)
		return GUI_YUM;

    return MsgScroll::KeyDown(key);
}
예제 #5
0
GUI_status ContainerViewGump::KeyDown(SDL_Keysym key)
{
	if(left_arrow_button && left_arrow_button->Status() == WIDGET_VISIBLE) // okay to change member number
	{
		KeyBinder *keybinder = Game::get_game()->get_keybinder();
		ActionType a = keybinder->get_ActionType(key);

		switch(keybinder->GetActionKeyType(a))
		{
			case NEXT_PARTY_MEMBER_KEY:
				right_arrow(); return GUI_YUM;
			case PREVIOUS_PARTY_MEMBER_KEY:
				left_arrow(); return GUI_YUM;
			case HOME_KEY:
				set_actor(party->get_actor(0));
				force_full_redraw_if_needed();
				return GUI_YUM;
			case END_KEY:
				set_actor(party->get_actor(party->get_party_size() - 1));
				force_full_redraw_if_needed();
				return GUI_YUM;
			default: break;
		}
	}
	/* moved into container widget
	switch(key.sym)
	    {
	        case SDLK_RETURN:
	        case SDLK_KP_ENTER:

	        	return GUI_YUM;
	        default:
	        	break;
	    }
	*/
	return container_widget->KeyDown(key);
}
예제 #6
0
GUI_status GUI_TextInput::KeyDown(SDL_keysym key)
{
// char ascii;
 char ascii = 0;

 if(!focused)
   return GUI_PASS;
 if((key.unicode & 0xFF80) == 0) // high 9bits 0 == ascii code
   ascii = (char)(key.unicode & 0x7F); // (in low 7bits)

 if(!isprint(ascii) && key.sym != SDLK_BACKSPACE)
 {
    KeyBinder *keybinder = Game::get_game()->get_keybinder();
    ActionType a = keybinder->get_ActionType(key);
    switch(keybinder->GetActionKeyType(a))
    {
      case NORTH_KEY: key.sym = SDLK_UP; break;
      case SOUTH_KEY: key.sym = SDLK_DOWN; break;
      case WEST_KEY: key.sym = SDLK_LEFT; break;
      case EAST_KEY: key.sym = SDLK_RIGHT; break;
      case TOGGLE_CURSOR_KEY: release_focus(); return GUI_PASS; // can tab through to SaveDialog
      case DO_ACTION_KEY: key.sym = SDLK_RETURN; break;
      case CANCEL_ACTION_KEY: key.sym = SDLK_ESCAPE; break;
      case HOME_KEY: key.sym = SDLK_HOME;
      case END_KEY: key.sym = SDLK_END;
      default : if(keybinder->handle_always_available_keys(a)) return GUI_YUM; break;
    }
 }

 switch(key.sym)
   {
    case SDLK_LSHIFT   :
    case SDLK_RSHIFT   :
    case SDLK_LCTRL    :
    case SDLK_RCTRL    :
    case SDLK_CAPSLOCK : break;

    case SDLK_KP_ENTER:
    case SDLK_RETURN : if(callback_object)
                         callback_object->callback(TEXTINPUT_CB_TEXT_READY, this, text);
    case SDLK_ESCAPE : release_focus(); break;

    case SDLK_HOME : pos = 0; break;
    case SDLK_END  : pos = length; break;

    case SDLK_KP4  :
    case SDLK_LEFT : if(pos > 0)
                       pos--;
                     break;

    case SDLK_KP6   :
    case SDLK_RIGHT : if(pos < length)
                       pos++;
                      break;

    case SDLK_DELETE    : if(pos < length) //delete the character to the right of the cursor
                            {
                             pos++;
                             remove_char(); break;
                            }
                          break;

    case SDLK_BACKSPACE : remove_char(); break; //delete the character to the left of the cursor

    case SDLK_UP :
    case SDLK_KP8 :
                    if(pos == length)
                    {
                        if(length+1 > max_width * max_height)
                            break;
                        length++;
                        if(pos == 0 || text[pos-1] == ' ')
                            text[pos] = 'A';
                        else
                            text[pos] = 'a';
                        break;
                    }
                    text[pos]++;
                    // We want alphanumeric characters or space
                    if(text[pos] < ' ' || text[pos] > 'z')
                    {
                        text[pos] = ' ';
                        break;
                    }
                    while(!isalnum(text[pos]))
                        text[pos]++;
                    break;

    case SDLK_KP2 :
    case SDLK_DOWN : if(pos == length)
                     {
                         if(length+1 > max_width * max_height)
                             break;
                         length++;
                         if(pos == 0 || text[pos-1] == ' ')
                             text[pos] = 'Z';
                         else
                             text[pos] = 'z';
                         break;
                     }
                     text[pos]--;
                     // We want alphanumeric characters or space
                     if(text[pos] < ' ' || text[pos] > 'z')
                     {
                         text[pos] = 'z';
                         break;
                     }
                     else if(text[pos] < '0')
                     {
                         text[pos] = ' ';
                         break;
                     }
                     while(!isalnum(text[pos]))
                         text[pos]--;
                     break;

    default :
              if(isprint(ascii))
                  add_char(ascii); break;
   }



 return(GUI_YUM);
}
예제 #7
0
GUI_status CommandBarNewUI::KeyDown(SDL_keysym key)
{
    KeyBinder *keybinder = Game::get_game()->get_keybinder();
    ActionType a = keybinder->get_ActionType(key);

    switch(keybinder->GetActionKeyType(a))
    {
        case NORTH_KEY:
        	do
        	{
				if(cur_pos - icon_w < 0)
					cur_pos = icon_w * icon_h - (icon_w - cur_pos%icon_w);
				else
					cur_pos -= icon_w;
        	} while(cur_pos >= num_icons);
            break;
        case SOUTH_KEY:
        	do
        	{
        		cur_pos = (cur_pos + icon_w) % (icon_w * icon_h);
        	} while(cur_pos >= num_icons);
            break;
        case WEST_KEY:
        	do
        	{
				if(cur_pos%icon_w == 0)
					cur_pos = (cur_pos/icon_w)*icon_w+icon_w-1;
				else
					cur_pos--;
        	} while(cur_pos >= num_icons);
            break;
        case EAST_KEY:
        	do
        	{
        		cur_pos = (cur_pos/icon_w)*icon_w + (cur_pos+1) % icon_w;
        	} while(cur_pos >= num_icons);
            break;
        case DO_ACTION_KEY:
        	if(cur_pos < num_icons)
        	{
				hit((sint8)cur_pos);
#ifdef HAVE_JOYSTICK_SUPPORT
				keybinder->set_enable_joy_repeat(true);
#endif
				Hide();
        	}
        	break;
        case CANCEL_ACTION_KEY:
        case NEW_COMMAND_BAR_KEY:
#ifdef HAVE_JOYSTICK_SUPPORT
        	keybinder->set_enable_joy_repeat(true);
#endif
        	Hide();
        	break;

        default : keybinder->handle_always_available_keys(a);
        	break;
    }

    return GUI_YUM;
}