Example #1
0
void OutfitWindow::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "next")
    {
        if (mCurrentOutfit < (OUTFITS_COUNT - 1))
            mCurrentOutfit++;
        else
            mCurrentOutfit = 0;
        mCurrentLabel->setCaption(strprintf(_("Outfit: %d"), mCurrentOutfit + 1));
        mUnequipCheck->setSelected(mItemsUnequip[mCurrentOutfit]);
    }
    else if (event.getId() == "previous")
    {
        if (mCurrentOutfit > 0)
        {
            mCurrentOutfit--;
        }
        else
        {
            mCurrentOutfit = OUTFITS_COUNT - 1;
        }
        mCurrentLabel->setCaption(strprintf(_("Outfit: %d"), mCurrentOutfit + 1));
        mUnequipCheck->setSelected(mItemsUnequip[mCurrentOutfit]);
    }
    else if (event.getId() == "unequip")
    {
        mItemsUnequip[mCurrentOutfit] = mUnequipCheck->isSelected();
    }
}
void GlassTabbedContainer::action(const gcn::ActionEvent &ae) {
	GlassTabState s = ((GlassTab*)ae.getSource())->getState();
	if(s == GTS_OPENED || s == GTS_OPENING)
		((GlassTab*)ae.getSource())->close();
	else
		((GlassTab*)ae.getSource())->open();
}
Example #3
0
void StorageWindow::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "close")
    {
        mItems->selectNone();
        close();
    }
    else if (event.getId() == "retrieve" || event.getId() == "default")
    {
        Item *item = mItems->getSelectedItem();

        if (!item)
            return;

        if (item->getQuantity() == 1)
        {
            removeStore(item, 1);
            selectNone();
        }
        // Choose amount of items to retrieve
        else
            new ItemAmountWindow(AMOUNT_STORE_REMOVE, this, item);
    }
    else if (event.getId() == "showpopupmenu")
        mItems->showPopupMenu(STORAGE, false);
}
Example #4
0
void InventoryWindow::action(const gcn::ActionEvent &event)
{
    Item *item = mItems->getSelectedItem();

    if (!item)
        return;

    if (event.getId() == "use")
    {
        if (item->isEquipment())
        {
            if (item->isEquipped())
                Net::getInventoryHandler()->unequipItem(item);
            else
                Net::getInventoryHandler()->equipItem(item);
        }
        else
            Net::getInventoryHandler()->useItem(item);
    }
    else if (event.getId() == "drop")
    {
        ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop, this, item);
    }
    else if (event.getId() == "split")
    {
        ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
                                 (item->getQuantity() - 1));
    }
}
Example #5
0
void ChangeDisplay::action(const gcn::ActionEvent &event)
{
    if (Net::getPlayerHandler()->canCorrectAttributes() &&
        event.getSource() == mDec)
    {
        int newcorpoints = PlayerInfo::getAttribute(CORR_POINTS) - 1;
        PlayerInfo::setAttribute(CORR_POINTS, newcorpoints);

        int newpoints = PlayerInfo::getAttribute(CHAR_POINTS) + 1;
        PlayerInfo::setAttribute(CHAR_POINTS, newpoints);

        int newbase = PlayerInfo::getStatBase(mId) - 1;
        PlayerInfo::setStatBase(mId, newbase);

        Net::getPlayerHandler()->decreaseAttribute(mId);
    }
    else if (event.getSource() == mInc)
    {
        int newpoints = PlayerInfo::getAttribute(CHAR_POINTS) - 1;
        PlayerInfo::setAttribute(CHAR_POINTS, newpoints);

        int newbase = PlayerInfo::getStatBase(mId) + 1;
        PlayerInfo::setStatBase(mId, newbase);

        Net::getPlayerHandler()->increaseAttribute(mId);
    }
}
Example #6
0
void
Wellcome::action(const gcn::ActionEvent &event)
{
    //ResourceManager *resman = ResourceManager::getInstance();
    if (event.getId() == "close")
    {
        if (mAgain->isSelected())
        {
            config.setValue("Wellcome", 1);
            logger->log("Wellcome : 1");
        }
        else
        {
            config.setValue("Wellcome", 0);
            logger->log("Wellcome : 0");
        }
        scheduleDelete();
    }
    else if (event.getId() == "next")
    {
        if (mCurrentSlide< mList.size()-1)
        {
            mCurrentSlide++;
            load();
        }
    }    else if (event.getId() == "prev")
    {
        if (mCurrentSlide> 0)
        {
            mCurrentSlide--;
            load();
        }
    }
}
void ProfileChooser::action(const gcn::ActionEvent &actionEvent)
{
	std::string tmp_string;
	int buttons = 0;

	/*
	 * Check which button was pressed
	 */
	if ( actionEvent.getId() == "mOk" ) {
		hide ();
		mCancelPressed = false;
	}
	else if ( actionEvent.getId() == "mCancel" ) {
		hide();
		mCancelPressed = true;
	}
	else if ( actionEvent.getId() == "mCreateNew" ) {
		mNewProfile.setVisible ( mCreateNew.isSelected() );
		mNewProfileLabel.setVisible ( mCreateNew.isSelected() );
		return;
	}

	distributeActionEvent();

} /* end action */
 void action(const gcn::ActionEvent& actionEvent)
 {
   if(actionEvent.getSource() == cmdPath)
   {
     char tmp[MAX_PATH];
     strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
     wndEditFilesysVirtual->releaseModalFocus();
     if(SelectFolder("Select folder", tmp))
       txtPath->setText(tmp);
     wndEditFilesysVirtual->requestModalFocus();
     cmdPath->requestFocus();
   }
   else
   {
     if (actionEvent.getSource() == cmdOK)
     {
       if(txtDevice->getText().length() <= 0)
       {
         wndEditFilesysVirtual->setCaption("Please enter a device name.");
         return;
       }
       if(txtVolume->getText().length() <= 0)
       {
         wndEditFilesysVirtual->setCaption("Please enter a volume name.");
         return;
       }
       dialogResult = true;
     }
     dialogFinished = true;
   }
 }
Example #9
0
void LoginDialog::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "login" && canSubmit())
    {
        mLoginData->username = mUserField->getText();
        mLoginData->password = mPassField->getText();
        mLoginData->remember = mKeepCheck->isSelected();
        mLoginData->registerLogin = false;

        mRegisterButton->setEnabled(false);
        mServerButton->setEnabled(false);
        mLoginButton->setEnabled(false);

        Client::setState(STATE_LOGIN_ATTEMPT);
    }
    else if (event.getId() == "server")
    {
        Client::setState(STATE_SWITCH_SERVER);
    }
    else if (event.getId() == "register")
    {
        if (Net::getLoginHandler()->isRegistrationEnabled())
        {
            mLoginData->username = mUserField->getText();
            mLoginData->password = mPassField->getText();
            Client::setState(STATE_REGISTER_PREP);
        }
        else
        {
            new OkDialog(_("Registration disabled"), _("You need to use the "
                           "website to register an account for this server."));
        }
    }
}
Example #10
0
void TabbedArea::action(const gcn::ActionEvent& actionEvent)
{
    Widget* source = actionEvent.getSource();
    Tab* tab = dynamic_cast<Tab*>(source);

    if (tab)
    {
        setSelectedTab(tab);
    }
    else
    {
        if (actionEvent.getId() == "shift_left")
        {
            if (mTabScrollIndex)
                --mTabScrollIndex;
        }
        else if (actionEvent.getId() == "shift_right")
        {
            if (mTabScrollIndex < mTabs.size() - 1)
                ++mTabScrollIndex;
        }
        adjustTabPositions();

        updateArrowEnableState();
    }
}
Example #11
0
    void action(const gcn::ActionEvent &event)
    {
        exitConfirm = NULL;

        if (event.getId() == "yes" || event.getId() == "ok")
            stateManager->setState(QUIT_STATE);
    }
Example #12
0
    void action(const gcn::ActionEvent& actionEvent)
    {
 	    if (actionEvent.getSource() == sldChipmem) {
    		changed_prefs.chipmem_size = ChipMem_values[(int)(sldChipmem->getValue())];
      	if ((changed_prefs.chipmem_size > 0x200000) && (changed_prefs.fastmem_size > 0))
      		changed_prefs.fastmem_size = 0;
			}
			
 	    if (actionEvent.getSource() == sldSlowmem) {
      	changed_prefs.bogomem_size = SlowMem_values[(int)(sldSlowmem->getValue())];
      }
      
	    if (actionEvent.getSource() == sldFastmem) {
     		changed_prefs.fastmem_size = FastMem_values[(int)(sldFastmem->getValue())];
	      if (changed_prefs.fastmem_size > 0 && changed_prefs.chipmem_size > 0x200000)
	        changed_prefs.chipmem_size = 0x200000;
  		}	

	    if (actionEvent.getSource() == sldZ3mem) {
     		changed_prefs.z3fastmem_size = FastMem_values[(int)(sldZ3mem->getValue())];
	      if (changed_prefs.z3fastmem_size > max_z3fastmem)
	        changed_prefs.z3fastmem_size = max_z3fastmem;
  		}	

	    if (actionEvent.getSource() == sldGfxmem) {
     		changed_prefs.gfxmem_size = FastMem_values[(int)(sldGfxmem->getValue())];
  		}	

  		RefreshPanelRAM();
    }
Example #13
0
void Setup::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "Apply")
    {
        setVisible(false);
        for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTabContainer::apply));
    }
    else if (event.getId() == "Cancel")
    {
        setVisible(false);
        for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTabContainer::cancel));
    }
    else if (event.getId() == "Reset Windows")
    {
        Widgets widgets = windowContainer->getWidgetList();
        WidgetIterator iter;

        for (iter = widgets.begin(); iter != widgets.end(); ++iter)
        {
            Window* window = dynamic_cast<Window*>(*iter);

            if (window)
                window->resetToDefaultSize();
        }
    }
}
Example #14
0
File: setup.cpp Project: Ablu/mana
void Setup::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "Apply")
    {
        setVisible(false);
        for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::apply));
    }
    else if (event.getId() == "Cancel")
    {
        setVisible(false);
        for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
    }
    else if (event.getId() == "Reset Windows")
    {
        // Bail out if this action happens to be activated before the windows
        // are created (though it should be disabled then)
        if (!statusWindow)
            return;

        for (std::list<Window*>::iterator it = mWindowsToReset.begin();
                it != mWindowsToReset.end(); it++)
        {
            (*it)->resetToDefaultSize();
        }
    }
}
 void action(const gcn::ActionEvent& actionEvent) {
     if (actionEvent.getSource() == radioButton_quickSwitch_off)
         mainMenu_quickSwitch=0;
     else if (actionEvent.getSource() == radioButton_quickSwitch_1)
         mainMenu_quickSwitch=1;
     else if (actionEvent.getSource() == radioButton_quickSwitch_2)
         mainMenu_quickSwitch=2;
     show_settings_TabOnScreen();
 }
Example #16
0
      void action(const gcn::ActionEvent& actionEvent)
      {
  	    if (actionEvent.getSource() == radioButton_boothd_off)
	      	mainMenu_bootHD=0;
	      else if (actionEvent.getSource() == radioButton_boothd_hddir)
		      mainMenu_bootHD=1;
	      else if (actionEvent.getSource() == radioButton_boothd_hdfile)
		      mainMenu_bootHD=2;
      }
Example #17
0
    void action(const gcn::ActionEvent &event)
    {
        warningDialog = NULL;

        if (event.getId() == "yes" || event.getId() == "ok")
            stateManager->setState(mNextState);
        else if (event.getId() == "no")
            stateManager->setState(mFailState);
    }
Example #18
0
void AudioOptions::action(const gcn::ActionEvent &event)
{
  if (event.getId() == "apply") {
    std::cout << "Apply changes" << std::endl << std::flush;
  } else if (event.getId() == "close") {
    m_top->closeWindow(this);
  } else {
    std::cout << "Say what?" << std::endl << std::flush;
  }
}
Example #19
0
void GCNSaveLoadWindow::action(const gcn::ActionEvent& actionEvent) {
    if (actionEvent.getId() == EVENT_CANCEL) {
        platform_->windowCanceled(this);
    } else if (actionEvent.getId() == EVENT_SAVE) {
        // TODO: Use selection listener?
        platform_->saveEvent(listbox_->getSelected());
    } else if (actionEvent.getId() == EVENT_LOAD) {
        platform_->loadEvent(listbox_->getSelected());
    }
}
Example #20
0
    void action(const gcn::ActionEvent& actionEvent)
    {
	    if (actionEvent.getSource() == opt7Mhz)
      	changed_prefs.m68k_speed = M68K_SPEED_7MHZ_CYCLES;
      else if (actionEvent.getSource() == opt14Mhz)
	      changed_prefs.m68k_speed = M68K_SPEED_14MHZ_CYCLES;
      else if (actionEvent.getSource() == opt28Mhz)
	      changed_prefs.m68k_speed = M68K_SPEED_25MHZ_CYCLES;
      else if (actionEvent.getSource() == optFastest)
	      changed_prefs.m68k_speed = -1;
    }
Example #21
0
void NpcIntegerDialog::action(const gcn::ActionEvent &event)
{
    if (!(event.getId() == "reset" || event.getId() == "cancel" ||
            event.getId() == "ok"))
        return;

    if (event.getId() != "ok")
        mValueField->reset();

    if (event.getId() != "reset")
        close();
}
Example #22
0
void CharSelectDialog::action(const gcn::ActionEvent &event)
{
    // Check if a button of a character was pressed
    const gcn::Widget *sourceParent = event.getSource()->getParent();
    int selected = -1;
    for (int i = 0; i < (int)mCharacterEntries.size(); ++i)
    {
        if (mCharacterEntries[i] == sourceParent)
        {
            selected = i;
            break;
        }
    }

    const std::string &eventId = event.getId();

    if (selected != -1)
    {
        if (eventId == "use")
        {
            attemptCharacterSelect(selected);
        }
        else if (eventId == "new"
                 && !mCharacterEntries[selected]->getCharacter())
        {
            // Start new character dialog
            CharCreateDialog *charCreateDialog =
                    new CharCreateDialog(this, selected);
            mCharHandler->setCharCreateDialog(charCreateDialog);
        }
        else if (eventId == "delete"
                 && mCharacterEntries[selected]->getCharacter())
        {
            new CharDeleteConfirm(this, selected);
        }
    }
    else if (eventId == "switch")
    {
        Client::setState(STATE_SWITCH_LOGIN);
    }
    else if (eventId == "change_password")
    {
        Client::setState(STATE_CHANGEPASSWORD);
    }
    else if (eventId == "change_email")
    {
        Client::setState(STATE_CHANGEEMAIL);
    }
    else if (eventId == "unregister")
    {
        Client::setState(STATE_UNREGISTER);
    }
}
void
UnRegisterDialog::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "cancel")
    {
        state = STATE_CHAR_SELECT;
    }
    else if (event.getId() == "unregister")
    {
        const std::string username = mLoginData->username.c_str();
        const std::string password = mPasswordField->getText();
        logger->log("UnregisterDialog::unregistered, Username is %s",
                     username.c_str());

        std::stringstream errorMessage;
        bool error = false;

        unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
        unsigned int max = Net::getLoginHandler()->getMaxPasswordLength();

        // Check password
        if (password.length() < min)
        {
            // Pass too short
            errorMessage << strprintf(_("The password needs to be at least %d "
                                        "characters long."), min);
            error = true;
        }
        else if (password.length() > max - 1)
        {
            // Pass too long
            errorMessage << strprintf(_("The password needs to be less than "
                                        "%d characters long."), max);
            error = true;
        }

        if (error)
        {
            mWrongDataNoticeListener->setTarget(this->mPasswordField);

            OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str());
            dlg->addActionListener(mWrongDataNoticeListener);
        }
        else
        {
            // No errors detected, unregister the new user.
            mUnRegisterButton->setEnabled(false);
            mLoginData->password = password;
            state = STATE_UNREGISTER_ATTEMPT;
        }
    }
}
Example #24
0
    void action(const gcn::ActionEvent &event)
    {
        selectionDialog = NULL;
        config.setValue("opengl", event.getId() == "opengl");

        if (event.getId() == "sdl")
            stateManager->setState(LOGIN_STATE);
        else if (event.getId() == "opengl")
            stateManager->handleWarning(_("Change won't take effect until you "
                                          "restart the client. Would you like "
                                          "to quit now?"), QUIT_STATE,
                                          LOGIN_STATE);
    }
Example #25
0
void SkillDialog::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "inc")
    {
        SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
        if (SkillInfo *info = tab->getSelectedInfo())
            Net::getPlayerHandler()->increaseSkill(info->id);
    }
    else if (event.getId() == "close")
    {
        setVisible(false);
    }
}
Example #26
0
void SkillDialog::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "inc")
    {
        SkillEntry *disp = dynamic_cast<SkillEntry*>(event.getSource()->getParent());

        if (disp)
            Net::getPlayerHandler()->increaseSkill(disp->mInfo->id);
    }
    else if (event.getId() == "close")
    {
        setVisible(false);
    }
}
Example #27
0
 void action(const gcn::ActionEvent& actionEvent) {
     char tempPath[300];
     strcpy(tempPath, prefs_get_attr ("rom_path"));
     strcpy(currentDir,tempPath);
     if (actionEvent.getSource() == button_main_rom) {
         run_menuLoad_guichan(currentDir, MENU_SELECT_MAIN_ROM);
     }
     if (actionEvent.getSource() == button_ext_rom) {
         run_menuLoad_guichan(currentDir, MENU_SELECT_EXT_ROM);
     }
     if (actionEvent.getSource() == button_key_rom) {
         run_menuLoad_guichan(currentDir, MENU_SELECT_KEY_ROM);
     }
 }
void ServerSelectDialog::action(const gcn::ActionEvent &event)
{
    if (event.getId() == "ok")
    {
        mOkButton->setEnabled(false);
        const SERVER_INFO *si = server_info[mServerList->getSelected()];
        mLoginData->hostname = ipToString(si->address);
        mLoginData->port = si->port;
        mLoginData->updateHost = si->updateHost;
        state = mNextState;
    }
    else if (event.getId() == "cancel")
        state = STATE_LOGIN;
}
Example #29
0
 void action(const gcn::ActionEvent& actionEvent) {
     if (actionEvent.getSource() == checkBox_cpu_cycle_exact)
         if (checkBox_cpu_cycle_exact->isSelected())
             changed_prefs.cpu_cycle_exact = 1;
         else
             changed_prefs.cpu_cycle_exact = 0;
 }
Example #30
0
void DidYouKnowWindow::action(const gcn::ActionEvent &event)
{
    const std::string &eventId = event.getId();
    if (eventId == "close")
    {
        setVisible(false);
    }
    else
    {
        const unsigned num = config.getIntValue("currentTip");
        if (eventId == "prev")
        {
            loadData(num - 1);
        }
        else if (eventId == "next")
        {
            loadData(num + 1);
        }
        else if (eventId == "openagain")
        {
            config.setValue("showDidYouKnow",
                mOpenAgainCheckBox->isSelected());
        }
    }
}