void PonscripterLabel::executeSystemLoad()
{
    SaveFileInfo save_file_info;

    current_font = &menu_font;
    if (event_mode & WAIT_BUTTON_MODE) {
        if (current_button_state.button == 0) return;

        event_mode = IDLE_EVENT_MODE;

        if (current_button_state.button > 0) {
            searchSaveFile(save_file_info, current_button_state.button);
            if (!save_file_info.valid) {
                event_mode = WAIT_BUTTON_MODE;
                refreshMouseOverButton();
                return;
            }

            deleteButtons();
            yesno_selected_file_no = current_button_state.button;
            yesno_caller = SYSTEM_LOAD;
            system_menu_mode = SYSTEM_YESNO;
            advancePhase();
        }
        else {
            deleteButtons();
            leaveSystemCall();
        }
    }
    else {
        system_menu_mode = SYSTEM_LOAD;
        createSaveLoadMenu(false);
    }
}
void PonscripterLabel::executeSystemLookback()
{
    current_font = &sentence_font;
    if (event_mode & WAIT_BUTTON_MODE) {
        if (current_button_state.button == 0
            || (current_text_buffer == start_text_buffer
                && current_button_state.button == -2))
            return;

        if (current_button_state.button == -1
            || (current_button_state.button == -3
                && current_text_buffer->next == cached_text_buffer)
            || current_button_state.button <= -4) {
            event_mode = IDLE_EVENT_MODE;
            deleteButtons();
            if (lookback_sp[0] >= 0)
                sprite_info[lookback_sp[0]].visible(false);

            if (lookback_sp[1] >= 0)
                sprite_info[lookback_sp[1]].visible(false);

            leaveSystemCall();
            return;
        }

        if (current_button_state.button == 1
            || current_button_state.button == -2) {
            current_text_buffer = current_text_buffer->previous;
        }
        else
            current_text_buffer = current_text_buffer->next;
    }
    else {
        current_text_buffer = current_text_buffer->previous;
        if (current_text_buffer->empty()) {
            if (lookback_sp[0] >= 0)
                sprite_info[lookback_sp[0]].visible(false);

            if (lookback_sp[1] >= 0)
                sprite_info[lookback_sp[1]].visible(false);

            leaveSystemCall();
            return;
        }

        event_mode = WAIT_BUTTON_MODE;
        system_menu_mode = SYSTEM_LOOKBACK;
    }

    setupLookbackButton();
    refreshMouseOverButton();

    rgb_t color = sentence_font.color;
    sentence_font.color = lookback_color;
    restoreTextBuffer();
    sentence_font.color = color;

    dirty_rect.fill(screen_width, screen_height);
    flush(refreshMode());
}
void PonscripterLabel::executeSystemSave()
{
    current_font = &menu_font;
    if (event_mode & WAIT_BUTTON_MODE) {
        if (current_button_state.button == 0) return;

        event_mode = IDLE_EVENT_MODE;

        deleteButtons();

        if (current_button_state.button > 0) {
            yesno_selected_file_no = current_button_state.button;
            yesno_caller = SYSTEM_SAVE;
            system_menu_mode = SYSTEM_YESNO;
            advancePhase();
            return;
        }

        leaveSystemCall();
    }
    else {
        system_menu_mode = SYSTEM_SAVE;
        createSaveLoadMenu(true);
    }
}
Beispiel #4
0
JoyControlStick::~JoyControlStick()
{
    axisX->removeControlStick();
    axisY->removeControlStick();

    deleteButtons();
}
Beispiel #5
0
SetJoystick::~SetJoystick()
{
    deleteSticks();
    deleteVDpads();
    deleteButtons();
    deleteAxes();
    deleteHats();
}
Beispiel #6
0
void SetJoystick::refreshButtons()
{
    deleteButtons();

    for (int i=0; i < device->getNumberRawButtons(); i++)
    {
        JoyButton *button = new JoyButton (i, index, this);
        buttons.insert(i, button);
        enableButtonConnections(button);
    }
}
    void createMainButton()
    {
        deleteButtons();
        Lancelot::HoverIcon * button = new Lancelot::HoverIcon(KIcon(mainIcon), "", q);
        layout->addItem(button);
        connect(button, SIGNAL(activated()), q, SLOT(showLancelot()));
        connect(button, SIGNAL(clicked()), q, SLOT(toggleLancelot()));
        button->setActivationMethod(clickActivation?(Lancelot::ClickActivate):(Lancelot::HoverActivate));

        buttons << button;
    }
    void createCategoriesButtons()
    {
        deleteButtons();

        // Loading Lancelot application categories
        QDBusReply<QStringList> replyIDs   = lancelot->sectionIDs();
        QDBusReply<QStringList> replyNames = lancelot->sectionNames();
        QDBusReply<QStringList> replyIcons_ = lancelot->sectionIcons();

        if (!replyIDs.isValid() || !replyNames.isValid() || !replyIcons_.isValid()) {
            // Error connecting to Lancelot via d-bus
            // setFailedToLaunch(true);
            return;
        }

        QStringList replyIcons = q->config().readEntry(
            "overrideSectionIcons", replyIcons_.value());

        // Creating buttons...
        for (int i = 0; i < replyIDs.value().size(); i++) {
            if (categsHide.contains(replyIDs.value().at(i))) {
                continue;
            }

            Lancelot::HoverIcon * button = new Lancelot::HoverIcon(
                KIcon(replyIcons.at(i)), "", q);

            connect(
                button, SIGNAL(activated()),
                & signalMapper, SLOT(map())
            );

            signalMapper.setMapping(button, replyIDs.value().at(i));

            connect(
                button, SIGNAL(clicked()),
                & signalMapperToggle, SLOT(map())
            );

            signalMapperToggle.setMapping(button, replyIDs.value().at(i));

            layout->addItem(button);
            button->setActivationMethod(clickActivation?(Lancelot::ClickActivate):(Lancelot::HoverActivate));

            buttons << button;
        }
    }
void PonscripterLabel::setupLookbackButton()
{
    deleteButtons();

    /* ---------------------------------------- */
    /* Previous button check */
    if (current_text_buffer->previous
        && current_text_buffer != start_text_buffer) {
	ButtonElt* button = &buttons[1];

        button->select_rect.x = sentence_font_info.pos.x;
        button->select_rect.y = sentence_font_info.pos.y;
        button->select_rect.w = sentence_font_info.pos.w;
        button->select_rect.h = sentence_font_info.pos.h / 3;

        if (lookback_sp[0] >= 0) {
            button->button_type = ButtonElt::SPRITE_BUTTON;
            button->sprite_no = lookback_sp[0];
            sprite_info[button->sprite_no].visible(true);
            button->image_rect = sprite_info[button->sprite_no].pos;
        }
        else {
            button->button_type = ButtonElt::LOOKBACK_BUTTON;
            button->show_flag = 2;
            button->anim[0] = &lookback_info[0];
            button->anim[1] = &lookback_info[1];
            button->image_rect.x = sentence_font_info.pos.x
		                 + sentence_font_info.pos.w
		                 - button->anim[0]->pos.w;
            button->image_rect.y   = sentence_font_info.pos.y;
            button->image_rect.w   = button->anim[0]->pos.w;
            button->image_rect.h   = button->anim[0]->pos.h;
            button->anim[0]->pos.x = button->anim[1]->pos.x = button->image_rect.x;
            button->anim[0]->pos.y = button->anim[1]->pos.y = button->image_rect.y;
        }
    }
    else if (lookback_sp[0] >= 0) {
        sprite_info[lookback_sp[0]].visible(false);
    }

    /* ---------------------------------------- */
    /* Next button check */
    if (current_text_buffer->next != cached_text_buffer) {
	ButtonElt* button = &buttons[2];

        button->select_rect.x = sentence_font_info.pos.x;
        button->select_rect.y = sentence_font_info.pos.y
	                      + sentence_font_info.pos.h * 2 / 3;
        button->select_rect.w = sentence_font_info.pos.w;
        button->select_rect.h = sentence_font_info.pos.h / 3;

        if (lookback_sp[1] >= 0) {
            button->button_type = ButtonElt::SPRITE_BUTTON;
            button->sprite_no = lookback_sp[1];
            sprite_info[button->sprite_no].visible(true);
            button->image_rect = sprite_info[button->sprite_no].pos;
        }
        else {
            button->button_type = ButtonElt::LOOKBACK_BUTTON;
            button->show_flag = 2;
            button->anim[0] = &lookback_info[2];
            button->anim[1] = &lookback_info[3];
            button->image_rect.x = sentence_font_info.pos.x
		                 + sentence_font_info.pos.w
		                 - button->anim[0]->pos.w;
            button->image_rect.y = sentence_font_info.pos.y
 		                 + sentence_font_info.pos.h
	 	                 - button->anim[0]->pos.h;
            button->image_rect.w = button->anim[0]->pos.w;
            button->image_rect.h = button->anim[0]->pos.h;
            button->anim[0]->pos.x = button->anim[1]->pos.x = button->image_rect.x;
            button->anim[0]->pos.y = button->anim[1]->pos.y = button->image_rect.y;
        }
    }
    else if (lookback_sp[1] >= 0) {
        sprite_info[lookback_sp[1]].visible(false);
    }
}
void PonscripterLabel::executeSystemYesNo()
{
    current_font = &menu_font;
    if (event_mode & WAIT_BUTTON_MODE) {
        if (current_button_state.button == 0) return;

        event_mode = IDLE_EVENT_MODE;

        deleteButtons();

        if (current_button_state.button == 1) { // yes is selected
	    playSound(menuselectvoice_file_name[MENUSELECTVOICE_YES],
		      SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL);

            if (yesno_caller == SYSTEM_SAVE) {
                saveSaveFile(yesno_selected_file_no);
                leaveSystemCall();
            }
            else if (yesno_caller == SYSTEM_LOAD) {
                current_font = &sentence_font;
                if (loadSaveFile(yesno_selected_file_no)) {
                    system_menu_mode = yesno_caller;
                    advancePhase();
                    return;
                }

                leaveSystemCall(false);
                saveon_flag = true;
                internal_saveon_flag = true;
                text_on_flag  = false;
                indent_offset = 0;
                line_enter_status    = 0;
                string_buffer_offset = 0;
                string_buffer_restore = -1;
		break_flag = false;

                if (loadgosub_label)
                    gosubReal(loadgosub_label, script_h.getCurrent());

                readToken();
            }
            else if (yesno_caller == SYSTEM_RESET) {
                resetCommand("reset");
                readToken();
                event_mode = IDLE_EVENT_MODE;
                leaveSystemCall(false);
            }
            else if (yesno_caller == SYSTEM_END) {
                endCommand("end");
            }
        }
        else {
	    playSound(menuselectvoice_file_name[MENUSELECTVOICE_NO],
		      SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL);

            system_menu_mode = yesno_caller & 0xf;
            if (yesno_caller == SYSTEM_RESET)
                leaveSystemCall();

            advancePhase();
        }
    }
    else {
        text_info.fill(0, 0, 0, 0);
	pstring name;

        if (yesno_caller == SYSTEM_SAVE) {
            SaveFileInfo save_file_info;
            searchSaveFile(save_file_info, yesno_selected_file_no);
            processMessage(name, locale.message_save_confirm, save_file_info);
        }
        else if (yesno_caller == SYSTEM_LOAD) {
            SaveFileInfo save_file_info;
            searchSaveFile(save_file_info, yesno_selected_file_no);
            processMessage(name, locale.message_load_confirm, save_file_info);
        }
        else if (yesno_caller == SYSTEM_RESET)
            name = locale.message_reset_confirm;
        else if (yesno_caller == SYSTEM_END)
            name = locale.message_end_confirm;

        current_font->area_x = int (ceil(current_font->StringAdvance(name)));
        current_font->area_y = current_font->line_top(4);
        current_font->top_x  = (screen_width * screen_ratio2 / screen_ratio1 - current_font->area_x) / 2;
        current_font->top_y  = (screen_height * screen_ratio2 / screen_ratio1 - current_font->area_y) / 2;
        current_font->SetXY(0, 0);

	buttons[0] = getSelectableSentence(name, current_font, false);

        flush(refreshMode());

        float yes_len = current_font->StringAdvance(locale.message_yes),
              no_len  = current_font->StringAdvance(locale.message_no);

        name = locale.message_yes;
        current_font->SetXY(float (current_font->area_x) / 4 - yes_len / 2,
			current_font->line_top(2));
	buttons[1] = getSelectableSentence(name, current_font, false);

        name = locale.message_no;
        current_font->SetXY(float (current_font->area_x) * 3 / 4 - no_len / 2,
			current_font->line_top(2));
        buttons[2] = getSelectableSentence(name, current_font, false);

        flush(refreshMode());

        event_mode = WAIT_BUTTON_MODE;
        refreshMouseOverButton();
    }
}
void PonscripterLabel::executeSystemMenu()
{
    int counter = 1;

    current_font = &menu_font;
    if (event_mode & WAIT_BUTTON_MODE) {
        if (current_button_state.button == 0) return;

        event_mode = IDLE_EVENT_MODE;

        deleteButtons();

        if (current_button_state.button == -1) {
	    playSound(menuselectvoice_file_name[MENUSELECTVOICE_CANCEL],
		      SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL);

            leaveSystemCall();
            return;
        }

	playSound(menuselectvoice_file_name[MENUSELECTVOICE_CLICK],
		  SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL);

	for (RMenuElt::iterator it = rmenu.begin(); it != rmenu.end(); ++it) {
	    if (current_button_state.button == counter++) {
                system_menu_mode = it->system_call_no;
                break;
            }
        }

        advancePhase();
    }
    else {
	playSound(menuselectvoice_file_name[MENUSELECTVOICE_OPEN],
		  SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL);

        system_menu_mode = SYSTEM_MENU;
        yesno_caller = SYSTEM_MENU;

        text_info.fill(0, 0, 0, 0);
        flush(refreshMode());

        current_font->area_x = screen_width * screen_ratio2 / screen_ratio1;
        current_font->area_y = current_font->line_top(rmenu.size());
        current_font->top_x  = 0;
        current_font->top_y  = (screen_height * screen_ratio2 / screen_ratio1 -
                                current_font->area_y) / 2;
        current_font->SetXY(0, 0);

	for (RMenuElt::iterator it = rmenu.begin(); it != rmenu.end(); ++it) {
            const float sw = float (screen_width * screen_ratio2)
		           / float (screen_ratio1);
            current_font->SetXY((sw - current_font->StringAdvance(it->label)) / 2);
	    buttons[counter++] = getSelectableSentence(it->label, current_font,
						       false);
            flush(refreshMode());
        }

        flushEvent();
        event_mode = WAIT_BUTTON_MODE;
        refreshMouseOverButton();
    }
}
Beispiel #12
0
void JoyControlStick::refreshButtons()
{
    deleteButtons();
    populateButtons();
}
Beispiel #13
0
 ~Private()
 {
     deleteButtons();
 }