mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-24 04:11:50 -04:00
Split onControllerButtonEvent into two; loop through ingredient slots
This commit is contained in:
parent
6114a01ad4
commit
b9ae89e032
@ -547,6 +547,32 @@ namespace MWGui
|
|||||||
mBrewCountEdit->setValue(currentCount - 1);
|
mBrewCountEdit->setValue(currentCount - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AlchemyWindow::filterListButtonHandler(const SDL_ControllerButtonEvent& arg)
|
||||||
|
{
|
||||||
|
if (arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_Y)
|
||||||
|
{
|
||||||
|
// Select the highlighted entry in the combo box and close it. List is closed by focusing on another
|
||||||
|
// widget.
|
||||||
|
size_t index = mFilterValue->getIndexSelected();
|
||||||
|
mFilterValue->setIndexSelected(index);
|
||||||
|
onFilterChanged(mFilterValue, index);
|
||||||
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mNameEdit);
|
||||||
|
|
||||||
|
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
|
||||||
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||||
|
{
|
||||||
|
// Close the list without selecting anything. List is closed by focusing on another widget.
|
||||||
|
mFilterValue->clearIndexSelected();
|
||||||
|
onFilterEdited(mFilterValue);
|
||||||
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mNameEdit);
|
||||||
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
|
||||||
|
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowUp, 0, false);
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||||
|
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
bool AlchemyWindow::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
|
bool AlchemyWindow::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
|
||||||
{
|
{
|
||||||
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||||
@ -556,71 +582,49 @@ namespace MWGui
|
|||||||
if (isFilterListOpen)
|
if (isFilterListOpen)
|
||||||
{
|
{
|
||||||
// When the filter list combo box is open, send all inputs to it.
|
// When the filter list combo box is open, send all inputs to it.
|
||||||
if (arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_Y)
|
filterListButtonHandler(arg);
|
||||||
{
|
return true;
|
||||||
// Select the highlighted entry in the combo box and close it. List is closed by focusing on another
|
}
|
||||||
// widget.
|
|
||||||
size_t index = mFilterValue->getIndexSelected();
|
|
||||||
mFilterValue->setIndexSelected(index);
|
|
||||||
onFilterChanged(mFilterValue, index);
|
|
||||||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mNameEdit);
|
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
|
if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||||
}
|
{
|
||||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
// Remove active ingredients or close the window, starting with right-most slot.
|
||||||
|
for (size_t i = mIngredients.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
// Close the list without selecting anything. List is closed by focusing on another widget.
|
if (mIngredients[i]->isUserString("ToolTipType"))
|
||||||
|
{
|
||||||
|
onIngredientSelected(mIngredients[i]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the ingredients list is empty, B closes the menu.
|
||||||
|
onCancelButtonClicked(mCancelButton);
|
||||||
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_X)
|
||||||
|
onCreateButtonClicked(mCreateButton);
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_Y && mFilterValue->getItemCount() > 0)
|
||||||
|
{
|
||||||
|
// Magical effects/ingredients filter
|
||||||
|
if (mFilterValue->getIndexSelected() != MyGUI::ITEM_NONE)
|
||||||
|
{
|
||||||
|
// Clear the active filter
|
||||||
mFilterValue->clearIndexSelected();
|
mFilterValue->clearIndexSelected();
|
||||||
onFilterEdited(mFilterValue);
|
onFilterEdited(mFilterValue);
|
||||||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mNameEdit);
|
|
||||||
}
|
}
|
||||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
|
|
||||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowUp, 0, false);
|
|
||||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
|
||||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
|
||||||
{
|
|
||||||
// Remove active ingredients or close the window
|
|
||||||
if (mIngredients[3]->isUserString("ToolTipType"))
|
|
||||||
onIngredientSelected(mIngredients[3]);
|
|
||||||
else if (mIngredients[2]->isUserString("ToolTipType"))
|
|
||||||
onIngredientSelected(mIngredients[2]);
|
|
||||||
else if (mIngredients[1]->isUserString("ToolTipType"))
|
|
||||||
onIngredientSelected(mIngredients[1]);
|
|
||||||
else if (mIngredients[0]->isUserString("ToolTipType"))
|
|
||||||
onIngredientSelected(mIngredients[0]);
|
|
||||||
else
|
|
||||||
onCancelButtonClicked(mCancelButton);
|
|
||||||
}
|
|
||||||
else if (arg.button == SDL_CONTROLLER_BUTTON_X)
|
|
||||||
onCreateButtonClicked(mCreateButton);
|
|
||||||
else if (arg.button == SDL_CONTROLLER_BUTTON_Y && mFilterValue->getItemCount() > 0)
|
|
||||||
{
|
|
||||||
// Magical effects/ingredients filter
|
|
||||||
if (mFilterValue->getIndexSelected() != MyGUI::ITEM_NONE)
|
|
||||||
{
|
|
||||||
// Clear the active filter
|
|
||||||
mFilterValue->clearIndexSelected();
|
|
||||||
onFilterEdited(mFilterValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Open the combo box to choose the a filter
|
|
||||||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mFilterValue);
|
|
||||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
|
||||||
}
|
|
||||||
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
|
|
||||||
}
|
|
||||||
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER)
|
|
||||||
onDecreaseButtonTriggered();
|
|
||||||
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
|
|
||||||
onIncreaseButtonTriggered();
|
|
||||||
else
|
else
|
||||||
mItemView->onControllerButton(arg.button);
|
{
|
||||||
|
// Open the combo box to choose the a filter
|
||||||
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mFilterValue);
|
||||||
|
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
||||||
|
}
|
||||||
|
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
|
||||||
}
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER)
|
||||||
|
onDecreaseButtonTriggered();
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
|
||||||
|
onIncreaseButtonTriggered();
|
||||||
|
else
|
||||||
|
mItemView->onControllerButton(arg.button);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ namespace MWGui
|
|||||||
std::vector<ItemWidget*> mIngredients;
|
std::vector<ItemWidget*> mIngredients;
|
||||||
|
|
||||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||||
|
void filterListButtonHandler(const SDL_ControllerButtonEvent& arg);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user