1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-11-08 17:46:40 +00:00

Fix several minor issues with controller inventory menus

This commit is contained in:
Andrew Lanzone 2025-05-24 20:56:43 -07:00
parent 3eec24b2a6
commit cf26020ed6
6 changed files with 39 additions and 6 deletions

View file

@ -1384,20 +1384,42 @@ namespace MWGui
if (arg.button == SDL_CONTROLLER_BUTTON_B)
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
else if (arg.button == SDL_CONTROLLER_BUTTON_X)
{
onWorldButtonClicked(mButton);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
}
else if (arg.button == SDL_CONTROLLER_BUTTON_Y)
{
centerView();
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
shiftMap(0, 100);
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
shiftMap(0, -100);
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
shiftMap(100, 0);
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
shiftMap(-100, 0);
return true;
}
bool MapWindow::onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg)
{
int dx = arg.axis == SDL_CONTROLLER_AXIS_RIGHTX ? -10.0f * arg.value / 32767 : 0;
int dy = arg.axis == SDL_CONTROLLER_AXIS_RIGHTY ? -10.0f * arg.value / 32767 : 0;
int dx = arg.axis == SDL_CONTROLLER_AXIS_RIGHTX ? -30.0f * arg.value / 32767 : 0;
int dy = arg.axis == SDL_CONTROLLER_AXIS_RIGHTY ? -30.0f * arg.value / 32767 : 0;
shiftMap(dx, dy);
return true;
}
void MapWindow::shiftMap(int dx, int dy)
{
if (dx == 0 && dy == 0)
return true;
else if (!Settings::map().mGlobal)
return;
if (!Settings::map().mGlobal)
{
mNeedDoorMarkersUpdate = true;
mLocalMap->setViewOffset(
@ -1410,7 +1432,6 @@ namespace MWGui
MyGUI::IntPoint(
mGlobalMap->getViewOffset().left + dx, mGlobalMap->getViewOffset().top + dy));
}
return true;
}
void MapWindow::setActiveControllerWindow(bool active)

View file

@ -288,6 +288,7 @@ namespace MWGui
void setGlobalMapMarkerTooltip(MyGUI::Widget* widget, int x, int y);
float getMarkerSize(size_t agregatedWeight) const;
void resizeGlobalMap();
void shiftMap(int dx, int dy);
void worldPosToGlobalMapImageSpace(float x, float z, float& imageX, float& imageY) const;
MyGUI::IntCoord createMarkerCoords(float x, float y, float agregatedWeight) const;
MyGUI::Widget* createMarker(const std::string& name, float x, float y, float agregatedWeight);

View file

@ -11,6 +11,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "tooltips.hpp"
@ -337,7 +338,10 @@ namespace MWGui
{
// Select the focused item, if any.
if (mControllerFocus >= 0 && mControllerFocus < mButtons.size())
{
onSpellSelected(mButtons.at(mControllerFocus));
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
}
}
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK)
{

View file

@ -292,6 +292,9 @@ namespace MWGui
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>();
window->setCoord(x, active ? y : viewSize.height + 1, width, height);
if (active)
mSpellView->update();
WindowBase::setActiveControllerWindow(active);
}
}

View file

@ -83,6 +83,8 @@ namespace MWGui
if (Settings::gui().mControllerMenus)
{
mControllerButtons.lStick = "#{sInfo}";
mControllerButtons.rStick = "#{sScrolldown}";
mControllerButtons.b = "#{sBack}";
}
@ -751,7 +753,8 @@ namespace MWGui
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>();
window->setCoord(x, active ? y : viewSize.height + 1, width, height);
onWindowResize(window);
if (active)
onWindowResize(window);
WindowBase::setActiveControllerWindow(active);
}

View file

@ -957,6 +957,7 @@ namespace MWGui
mGuiModeStates[mode].mWindows[i]->setActiveControllerWindow(i == activeIndex);
updateControllerButtonsOverlay();
setCursorActive(false);
if (winCount > 1)
playSound(ESM::RefId::stringRefId("Menu Size"));