Exemple #1
0
void SelectLevelScreen::key_down(const KeyDownEvent& event) {
    switch (_state) {
        case SELECTING:
            switch (event.key()) {
                case Keys::K8:
                case Keys::N_TIMES:
                    _state          = UNLOCKING;
                    _unlock_chapter = 0;
                    _unlock_digits  = ndigits(plug.levels.size());
                    sys.sound.cloak_on();
                    return;
            }
        case UNLOCKING: {
            int digit = key_digit(event.key());
            if (digit < 0) {
                _state = SELECTING;
                break;
            }
            _unlock_chapter = (_unlock_chapter * 10) + digit;
            if (--_unlock_digits == 0) {
                _state = SELECTING;
                if (_unlock_chapter > plug.levels.size()) {
                    return;
                }
                sys.sound.cloak_off();
                Ledger::ledger()->unlock_chapter(_unlock_chapter);
                Ledger::ledger()->unlocked_chapters(&_chapters);
                adjust_interface();
            }
            return;
        } break;
        case FADING_OUT: return;
    }
    InterfaceScreen::key_down(event);
}
Exemple #2
0
 bool key_down_event(const KeyDownEvent &e) const {
   NCursesApp *app = NCursesApp::app();
   if(e.key() == 'q') {
     app->exit();
   }
   return false;
 }
Exemple #3
0
void BriefingScreen::key_down(const KeyDownEvent& event) {
    switch (event.key()) {
        case Key::ESCAPE: {
            *_cancelled = true;
            stack()->pop(this);
        }
            return;
        case Key::K1: return show_object_data(0, event);
        case Key::K2: return show_object_data(1, event);
        case Key::K3: return show_object_data(2, event);
        case Key::K4: return show_object_data(3, event);
        case Key::K5: return show_object_data(4, event);
        case Key::K6: return show_object_data(5, event);
        case Key::K7: return show_object_data(6, event);
        case Key::K8: return show_object_data(7, event);
        case Key::K9: return show_object_data(8, event);
        case Key::K0: return show_object_data(9, event);
        default: { return InterfaceScreen::key_down(event); }
    }
}
Exemple #4
0
void BriefingScreen::show_object_data(int index, const KeyDownEvent& event) {
    show_object_data(index, ObjectDataScreen::KEY, 0, event.key(), Gamepad::Button::NONE);
}
Exemple #5
0
void EventTracker::key_down(const KeyDownEvent& event) {
    if (_strict && _keys.get(event.key())) {
        throw Exception(format("Received KeyDownEvent but key {0} already down.", event.key()));
    }
    _keys.set(event.key(), true);
}