mirror of
https://github.com/OpenMW/openmw.git
synced 2026-02-11 08:08:28 +00:00
Add controller supoprt to enchanting menu
This commit is contained in:
parent
40441a065a
commit
2d532100eb
4 changed files with 45 additions and 0 deletions
|
|
@ -59,6 +59,12 @@ namespace MWGui
|
|||
mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onBuyButtonClicked);
|
||||
mTypeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onTypeButtonClicked);
|
||||
mName->eventEditSelectAccept += MyGUI::newDelegate(this, &EnchantingDialog::onAccept);
|
||||
|
||||
mControllerButtons.a = "#{sSelect}";
|
||||
mControllerButtons.b = "#{sBack}";
|
||||
mControllerButtons.y = "Cast Type";
|
||||
mControllerButtons.l1 = "#{sItem}";
|
||||
mControllerButtons.r1 = "#{sSoulGem}";
|
||||
}
|
||||
|
||||
void EnchantingDialog::onOpen()
|
||||
|
|
@ -152,6 +158,7 @@ namespace MWGui
|
|||
mEnchanting.setSelfEnchanting(false);
|
||||
mEnchanting.setEnchanter(ptr);
|
||||
mBuyButton->setCaptionWithReplacing("#{sBuy}");
|
||||
mControllerButtons.x = "#{sBuy}";
|
||||
mChanceLayout->setVisible(false);
|
||||
mPtr = ptr;
|
||||
setSoulGem(MWWorld::Ptr());
|
||||
|
|
@ -163,6 +170,7 @@ namespace MWGui
|
|||
mEnchanting.setSelfEnchanting(true);
|
||||
mEnchanting.setEnchanter(MWMechanics::getPlayer());
|
||||
mBuyButton->setCaptionWithReplacing("#{sCreate}");
|
||||
mControllerButtons.x = "#{sCreate}";
|
||||
mChanceLayout->setVisible(Settings::game().mShowEnchantChance);
|
||||
mPtr = MWMechanics::getPlayer();
|
||||
setSoulGem(ptr);
|
||||
|
|
@ -382,4 +390,22 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EnchantingDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
|
||||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
onCancelButtonClicked(mCancelButton);
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_X)
|
||||
onBuyButtonClicked(mBuyButton);
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_Y)
|
||||
onTypeButtonClicked(mTypeButton);
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER)
|
||||
onSelectItem(mItemBox);
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
|
||||
onSelectSoul(mSoulBox);
|
||||
else
|
||||
return EffectEditorBase::onControllerButtonEvent(arg);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ namespace MWGui
|
|||
|
||||
MWMechanics::Enchanting mEnchanting;
|
||||
ESM::EffectList mEffectList;
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include <MyGUI_Button.h>
|
||||
#include <MyGUI_TextBox.h>
|
||||
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include "inventoryitemmodel.hpp"
|
||||
#include "itemview.hpp"
|
||||
#include "sortfilteritemmodel.hpp"
|
||||
|
|
@ -26,6 +28,9 @@ namespace MWGui
|
|||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked);
|
||||
|
||||
center();
|
||||
|
||||
mControllerButtons.a = "#{sSelect}";
|
||||
mControllerButtons.b = "#{sBack}";
|
||||
}
|
||||
|
||||
bool ItemSelectionDialog::exit()
|
||||
|
|
@ -40,6 +45,8 @@ namespace MWGui
|
|||
mSortModel = sortModel.get();
|
||||
mItemView->setModel(std::move(sortModel));
|
||||
mItemView->resetScrollBars();
|
||||
if (Settings::gui().mControllerMenus)
|
||||
mItemView->setActiveControllerWindow(true);
|
||||
}
|
||||
|
||||
void ItemSelectionDialog::setCategory(int category)
|
||||
|
|
@ -65,4 +72,13 @@ namespace MWGui
|
|||
exit();
|
||||
}
|
||||
|
||||
bool ItemSelectionDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
|
||||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
onCancelButtonClicked(nullptr);
|
||||
else
|
||||
mItemView->onControllerButtonEvent(arg.button);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ namespace MWGui
|
|||
void onSelectedItem(int index);
|
||||
|
||||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue