Skip to content

An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.

C++

Options with a controller: the triggers switch the tabs inside a tab, as Z / C do on the keyboard

Alan Saunders06a5e5abbc36
diff --git a/README.md b/README.md
index 44024d7..c434fe8 100644
--- a/README.md
+++ b/README.md
@@ -183,7 +183,7 @@ The defaults; Options > Controls rebinds them (and Options > Scripts > Isowind t
| Key | What it does |
|--------------------|-------------------------------------------------------------------------------------------------|
| Q / E | Previous / next page of the inventory screen (Map, Inventory, Magic, Stats), or tab in Options |
-| Z / C | Previous / next tab inside a window: the kinds of item in the inventory or a shop, a chest's containers opened together, the local or world map. With a chest or shop open, the window under the pointer |
+| Z / C | Previous / next tab inside a window: the kinds of item in the inventory or a shop, a chest's containers opened together, the local or world map, in Options the Video tab's (Detail Level, Water, Lights) and the Controls tab's mouse and keyboard / controller. With a chest or shop open, the window under the pointer |
| Click a tab | That page. The HUD's bars, weapon, spell and minimap go to theirs too |
| 1 - 0 | Over an item, spell or enchanted item: puts it on that quick key |
| Drag onto a slot | An item dragged onto a quick key slot along the bottom goes on that key |
@@ -221,7 +221,7 @@ Q / E and Z / C type as usual in a text box.
| D-pad, A | Choose |
| B | Back |
| Bumpers | The inventory screen's pages; with a chest or shop open, between its window and yours; Options' tabs |
-| Triggers | The tabs inside a window |
+| Triggers | The tabs inside a window, and in Options inside a tab (Video's; Controls' mouse and keyboard / controller) |
| Right stick in | An item's info |
| Y | In the inventory and magic pages: puts the item or spell on a quick key |
| X | On a text box (moved onto with the D-pad): a keyboard on the screen. Start or Back puts it away |
diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp
index c8d87d0..174ee55 100644
--- a/apps/openmw/mwgui/settingswindow.cpp
+++ b/apps/openmw/mwgui/settingswindow.cpp
@@ -154,6 +154,33 @@ namespace
textBox->setCaption(labelCaption);
}
}
+
+ // Isowind: the tab bar inside a page of Options (the Video page's), if it has one
+ MyGUI::TabControl* findTabControl(MyGUI::Widget* parent)
+ {
+ MyGUI::EnumeratorWidgetPtr children = parent->getEnumerator();
+ while (children.next())
+ {
+ MyGUI::Widget* widget = children.current();
+ if (!widget->getVisible())
+ continue;
+ if (MyGUI::TabControl* tabs = widget->castType<MyGUI::TabControl>(false))
+ return tabs;
+ if (MyGUI::TabControl* tabs = findTabControl(widget))
+ return tabs;
+ }
+ return nullptr;
+ }
+
+ // A tab's caption without the spaces it is padded with
+ std::string tabName(const MyGUI::UString& caption)
+ {
+ const std::string name = caption.asUTF8();
+ const size_t first = name.find_first_not_of(' ');
+ if (first == std::string::npos)
+ return {};
+ return name.substr(first, name.find_last_not_of(' ') - first + 1);
+ }
}
namespace MWGui
@@ -324,6 +351,11 @@ namespace MWGui
+= MyGUI::newDelegate(this, &SettingsWindow::onWindowResize);
mSettingsTab->eventTabChangeSelect += MyGUI::newDelegate(this, &SettingsWindow::onTabChanged);
+ for (size_t i = 0; i < mSettingsTab->getItemCount(); ++i)
+ {
+ if (MyGUI::TabControl* subTabs = findTabControl(mSettingsTab->getItemAt(i)))
+ subTabs->eventTabChangeSelect += MyGUI::newDelegate(this, &SettingsWindow::onSubTabChanged);
+ }
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
mTextureFilteringButton->eventComboChangePosition
+= MyGUI::newDelegate(this, &SettingsWindow::onTextureFilteringChanged);
@@ -486,6 +518,13 @@ namespace MWGui
void SettingsWindow::onTabChanged(MyGUI::TabControl* /*sender*/, size_t /*index*/)
{
resetScrollbars();
+ MWBase::Environment::get().getWindowManager()->updateControllerButtonsOverlay();
+ }
+
+ void SettingsWindow::onSubTabChanged(MyGUI::TabControl* /*sender*/, size_t /*index*/)
+ {
+ // The legend names the tabs the triggers go to
+ MWBase::Environment::get().getWindowManager()->updateControllerButtonsOverlay();
}
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* /*sender*/)
@@ -810,6 +849,7 @@ namespace MWGui
mControllerSwitch->setStateSelected(false);
updateControlsBox();
resetScrollbars();
+ MWBase::Environment::get().getWindowManager()->updateControllerButtonsOverlay();
}
void SettingsWindow::onControllerSwitchClicked(MyGUI::Widget* /*sender*/)
@@ -821,6 +861,7 @@ namespace MWGui
mControllerSwitch->setStateSelected(true);
updateControlsBox();
resetScrollbars();
+ MWBase::Environment::get().getWindowManager()->updateControllerButtonsOverlay();
}
void SettingsWindow::updateControlsBox()
@@ -1146,7 +1187,9 @@ namespace MWGui
bool SettingsWindow::stepTab(int delta)
{
mSettingsTab->setIndexSelected(wrap(mSettingsTab->getIndexSelected(), mSettingsTab->getItemCount(), delta));
- MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
+ MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
+ winMgr->playSound(ESM::RefId::stringRefId("Menu Click"));
+ winMgr->updateControllerButtonsOverlay();
return true;
}
@@ -1459,6 +1502,7 @@ namespace MWGui
if (tabs->getItemCount() == 0)
return;
tabs->setIndexSelected(wrap(tabs->getIndexSelected(), tabs->getItemCount(), delta));
+ onSubTabChanged(tabs, tabs->getIndexSelected());
pointAt(tabs);
}
else
@@ -1496,4 +1540,72 @@ namespace MWGui
winMgr->setCursorActive(true);
}
+ MyGUI::Widget* SettingsWindow::getShownPage() const
+ {
+ const size_t index = mSettingsTab->getIndexSelected();
+ return index != MyGUI::ITEM_NONE ? mSettingsTab->getItemAt(index) : nullptr;
+ }
+
+ MyGUI::TabControl* SettingsWindow::getSubTabs() const
+ {
+ MyGUI::Widget* page = getShownPage();
+ return page ? findTabControl(page) : nullptr;
+ }
+
+ bool SettingsWindow::stepSubTab(int delta)
+ {
+ if (isInside(mKeyboardSwitch, getShownPage()))
+ {
+ // Two of them: either way goes to the other
+ if (mKeyboardMode)
+ onControllerSwitchClicked(mControllerSwitch);
+ else
+ onKeyboardSwitchClicked(mKeyboardSwitch);
+ }
+ else if (MyGUI::TabControl* tabs = getSubTabs(); tabs && tabs->getItemCount() > 1)
+ {
+ tabs->setIndexSelected(wrap(tabs->getIndexSelected(), tabs->getItemCount(), delta));
+ onSubTabChanged(tabs, tabs->getIndexSelected());
+ }
+ else
+ return false;
+ MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
+ return true;
+ }
+
+ bool SettingsWindow::onControllerTrigger(int delta)
+ {
+ // The pointer starts on the tab as it does on a page the bumpers turn to. On a page without tabs inside the
+ // triggers do nothing, rather than go to the windows under Options.
+ if (stepSubTab(delta))
+ pointAtFirstControl();
+ return true;
+ }
+
+ ControllerButtons* SettingsWindow::getControllerButtons()
+ {
+ // The triggers, by the names of the tabs inside the page they go to: the one either side, or of two the
+ // other on its side
+ std::vector<std::string> names;
+ size_t shown = 0;
+ if (isInside(mKeyboardSwitch, getShownPage()))
+ {
+ names = { tabName(mKeyboardSwitch->getCaption()), tabName(mControllerSwitch->getCaption()) };
+ shown = mKeyboardMode ? 0 : 1;
+ }
+ else if (MyGUI::TabControl* tabs = getSubTabs(); tabs && tabs->getIndexSelected() != MyGUI::ITEM_NONE)
+ {
+ for (size_t i = 0; i < tabs->getItemCount(); ++i)
+ names.push_back(tabName(tabs->getItemNameAt(i)));
+ shown = tabs->getIndexSelected();
+ }
+ mControllerButtons.mL2.clear();
+ mControllerButtons.mR2.clear();
+ if (names.size() > 2 || (names.size() == 2 && shown == 1))
+ mControllerButtons.mL2 = names[wrap(shown, names.size(), -1)];
+ if (names.size() > 2 || (names.size() == 2 && shown == 0))
+ mControllerButtons.mR2 = names[wrap(shown, names.size(), 1)];
+ return &mControllerButtons;
+ }
+
}
diff --git a/apps/openmw/mwgui/settingswindow.hpp b/apps/openmw/mwgui/settingswindow.hpp
index f45451d..8a5d254 100644
--- a/apps/openmw/mwgui/settingswindow.hpp
+++ b/apps/openmw/mwgui/settingswindow.hpp
@@ -33,6 +33,11 @@ namespace MWGui
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
bool stepTab(int delta) override;
+ bool onControllerTrigger(int delta) override;
+ ControllerButtons* getControllerButtons() override;
+ /// Isowind: the tabs inside the page shown (the triggers, Z / C): the Video page's, the Controls page's mouse
+ /// and keyboard / controller; false if it has none
+ bool stepSubTab(int delta);
protected:
MyGUI::TabControl* mSettingsTab;
@@ -137,6 +142,9 @@ namespace MWGui
void stepControl(int delta);
void adjustControl(int delta);
void selectControl();
+ MyGUI::Widget* getShownPage() const;
+ MyGUI::TabControl* getSubTabs() const;
+ void onSubTabChanged(MyGUI::TabControl* sender, size_t index);
/// A frame around the control the pointer is on (nullptr: none)
void frameControl(MyGUI::Widget* control);
MyGUI::Widget* mControllerFrame = nullptr;
diff --git a/apps/openmw/mwgui/windowbase.hpp b/apps/openmw/mwgui/windowbase.hpp
index f67cd02..772000b 100644
--- a/apps/openmw/mwgui/windowbase.hpp
+++ b/apps/openmw/mwgui/windowbase.hpp
@@ -109,6 +109,9 @@ namespace MWGui
/// Isowind: the keyboard's keys for the tabs inside a window (Z / C, as a controller's triggers) step through
/// this window's tabs; false if it has none
virtual bool stepTab(int delta) { return false; }
+ /// Isowind: a controller's trigger pressed while this window has the controller (-1 the left, 1 the right);
+ /// false leaves it to what the triggers otherwise do (switch between the windows open)
+ virtual bool onControllerTrigger(int delta) { return false; }
protected:
virtual void onTitleDoubleClicked();
diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp
index 4f10dad..145d384 100644
--- a/apps/openmw/mwgui/windowmanagerimp.cpp
+++ b/apps/openmw/mwgui/windowmanagerimp.cpp
@@ -2825,8 +2825,13 @@ namespace MWGui
}
// The tabs inside a window, as the controller's triggers do: the window's under the pointer, or else the
- // first one open with tabs
- if (mGuiModes.empty() || isSettingsWindowVisible())
+ // first one open with tabs; in Options the page's (the pointer stays, as for Q / E)
+ if (isSettingsWindowVisible())
+ {
+ MWBase::Environment::get().getInputManager()->setJoystickLastUsed(false);
+ return mSettingsWindow->stepSubTab(delta);
+ }
+ if (mGuiModes.empty())
return false;
const std::vector<WindowBase*>& windows = mGuiModeStates[mGuiModes.back()].mWindows;
MyGUI::Widget* underPointer = MyGUI::InputManager::getInstance().getMouseFocusWidget();
diff --git a/apps/openmw/mwinput/controllermanager.cpp b/apps/openmw/mwinput/controllermanager.cpp
index c23ef56..c4912b6 100644
--- a/apps/openmw/mwinput/controllermanager.cpp
+++ b/apps/openmw/mwinput/controllermanager.cpp
@@ -253,6 +253,12 @@ namespace MWInput
if (mBindingsManager->isDetectingBindingState())
{
+ // Isowind: a trigger pulled to be bound is bound partway down; the rest of the pull isn't then a press in
+ // the menu (it would switch Options' tab under the bindings)
+ if (arg.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT)
+ mLeftTriggerGuiPressed = arg.value > 0;
+ else if (arg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
+ mRightTriggerGuiPressed = arg.value > 0;
mBindingsManager->controllerAxisMoved(deviceID, arg);
return;
}
@@ -490,6 +496,9 @@ namespace MWInput
if (winMgr->isOnScreenKeyboardVisible())
return;
MWGui::WindowBase* activeWin = winMgr->getActiveControllerWindow();
+ // A window may have its own use for them (Options: the tabs inside the page shown)
+ if (activeWin && activeWin->isVisible() && activeWin->onControllerTrigger(right ? 1 : -1))
+ return;
if (winMgr->controllerCyclesWindows() && activeWin && activeWin->isVisible())
{
SDL_ControllerButtonEvent bumper{};
diff --git a/isowind/README.txt b/isowind/README.txt
index 50b75c7..dda02f7 100644
--- a/isowind/README.txt
+++ b/isowind/README.txt
@@ -121,7 +121,8 @@ Q / E In the menus: the previous / next page of the inventory screen
Magic, Stats), or tab in Options. Click a page's tab along the top, or what it
stands for on the HUD (the bars, the weapon, the spell, the minimap), to go to it.
Z / C In the menus: the previous / next tab inside a window - the kinds of item in the
- inventory or a shop, a chest's containers opened together, the local or world map.
+ inventory or a shop, a chest's containers opened together, the local or world map,
+ in Options the Video tab's and the Controls tab's mouse and keyboard / controller.
With a chest or shop open, the window under the pointer.
Mouse wheel Zoom, within the view you are in.
F7 Switch view: top-down, then Morrowind's third person view, then first person. Change the
@@ -146,7 +147,8 @@ Menus are made for the controller: the D-pad and A choose, B goes back, the bump
screen's pages (Map, Inventory, Magic, Stats; one at a time, as with the mouse and keyboard) and, where two
windows are open side by side (a chest, a shop), between them, the one in use lit, while the triggers switch
the tabs within a window. The right stick pressed in shows an item's info, and in the inventory and magic
-windows Y puts the item or spell on a quick key. In Options the bumpers switch tabs,
+windows Y puts the item or spell on a quick key. In Options the bumpers switch tabs and the triggers the
+tabs inside one (Video's; Controls' mouse and keyboard / controller),
the D-pad steps a gold frame through the settings (up / down) and adjusts the one it is on (left / right), and A
works it, on the Scripts tab's pages too; the mouse pointer stays away until the mouse moves. The legend along the bottom of each menu says what the buttons do
there. To type something (your name, a server's password, a save's, potion's, spell's or class's name, a map