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: script pages' settings reachable, so switch view can take a button
Alan Saunders64abadcc604f
diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cppindex 718b832..3793faf 100644--- a/apps/openmw/mwgui/settingswindow.cpp+++ b/apps/openmw/mwgui/settingswindow.cpp@@ -25,6 +25,7 @@#include <components/files/configurationmanager.hpp>#include <components/l10n/manager.hpp>#include <components/lua_ui/scriptsettings.hpp>+#include <components/lua_ui/widget.hpp>#include <components/misc/constants.hpp>#include <components/misc/display.hpp>#include <components/misc/strings/algorithm.hpp>@@ -418,6 +419,8 @@ namespace MWGuimScriptFilter->eventEditTextChange += MyGUI::newDelegate(this, &SettingsWindow::onScriptFilterChange);mScriptList->eventListMouseItemActivate += MyGUI::newDelegate(this, &SettingsWindow::onScriptListSelection);+ // Isowind: the D-pad's left / right (or the arrow keys) on the list opens the page too+ mScriptList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onScriptListSelection);std::vector<std::string> availableLanguages;const VFS::Manager* vfs = MWBase::Environment::get().getResourceSystem()->getVFS();@@ -1207,6 +1210,13 @@ namespace MWGuireturn false;}+ // A widget of a script's settings page that a click works (a binding, a "Yes" / "No", the arrows, Reset)+ bool isScriptClickable(MyGUI::Widget* widget)+ {+ const LuaUi::WidgetExtension* lua = dynamic_cast<LuaUi::WidgetExtension*>(widget);+ return lua != nullptr && lua->hasCallback("mouseClick");+ }+void clickAtPointer(){MyGUI::InputManager& input = MyGUI::InputManager::getInstance();@@ -1216,8 +1226,8 @@ namespace MWGui}}- // The controls of the page: buttons (checkboxes among them), sliders, drop-down lists, lists, text boxes and- // inner tab bars (the outer tabs are the bumpers'), top to bottom+ // The controls of the page: buttons (checkboxes among them), sliders, drop-down lists, lists, text boxes, inner+ // tab bars (the outer tabs are the bumpers') and what a script's page has to click, top to bottomvoid SettingsWindow::collectControls(MyGUI::Widget* parent, std::vector<MyGUI::Widget*>& controls) const{MyGUI::EnumeratorWidgetPtr children = parent->getEnumerator();@@ -1226,7 +1236,10 @@ namespace MWGuiMyGUI::Widget* widget = children.current();if (!widget->getVisible() || !widget->getEnabled())continue;- if (MyGUI::TabControl* tabs = widget->castType<MyGUI::TabControl>(false))+ // Before the text boxes: a script's text is one+ if (isScriptClickable(widget))+ controls.push_back(widget);+ else if (MyGUI::TabControl* tabs = widget->castType<MyGUI::TabControl>(false)){if (tabs != mSettingsTab)controls.push_back(tabs);@@ -1279,17 +1292,19 @@ namespace MWGui{if (!control)return;- // A row of the controls list scrolls into view first- if (isInside(control, mControlsBox) && control != mControlsBox)+ // A row of the controls list, or a script's setting, scrolls into view first+ for (MyGUI::ScrollView* view : { mControlsBox, mScriptView }){- MyGUI::IntPoint offset = mControlsBox->getViewOffset();- const int viewHeight = mControlsBox->getViewCoord().height;- const int top = control->getTop() + offset.top;+ if (!isInside(control, view) || control == view)+ continue;+ MyGUI::IntPoint offset = view->getViewOffset();+ const MyGUI::IntCoord viewCoord = view->getViewCoord();+ const int top = control->getAbsoluteTop() - view->getAbsoluteTop() - viewCoord.top;if (top < 0)- offset.top = -control->getTop();- else if (top + control->getHeight() > viewHeight)- offset.top = viewHeight - control->getTop() - control->getHeight();- mControlsBox->setViewOffset(offset);+ offset.top -= top;+ else if (top + control->getHeight() > viewCoord.height)+ offset.top -= top + control->getHeight() - viewCoord.height;+ view->setViewOffset(offset);}// The middle of the control; an inner tab bar on the tabs themselves along its top, and a list on the row// it has chosen, if that is in view@@ -1320,10 +1335,12 @@ namespace MWGuiframeControl(control);}- // Morrowind's gold box frame around the control, drawn beside it in its own parent so it scrolls along+ // Morrowind's gold box frame around the control, drawn beside it in its own parent so it scrolls along. On a+ // script's page that is the page's adapter: the script rebuilds its own widgets, which would take the frame along.void SettingsWindow::frameControl(MyGUI::Widget* control){constexpr int margin = 3;+ const bool onScriptPage = control && isInside(control, mScriptAdapter);if (control != mFramedControl || !control){if (mControllerFrame)@@ -1334,13 +1351,16 @@ namespace MWGuimFramedControl = control;if (!control || !control->getParent())return;- mControllerFrame = control->getParent()->createWidget<MyGUI::Widget>(- "MW_Box_Overlay", MyGUI::IntCoord(), MyGUI::Align::Default);+ MyGUI::Widget* parent = onScriptPage ? mScriptAdapter : control->getParent();+ mControllerFrame+ = parent->createWidget<MyGUI::Widget>("MW_Box_Overlay", MyGUI::IntCoord(), MyGUI::Align::Default);mControllerFrame->setNeedMouseFocus(false);}if (mControllerFrame){MyGUI::IntCoord coord = control->getCoord();+ if (onScriptPage)+ coord = control->getAbsoluteCoord() - mScriptAdapter->getAbsolutePosition();mControllerFrame->setCoord(coord.left - margin, coord.top - margin, coord.width + 2 * margin, coord.height + 2 * margin);}@@ -1434,6 +1454,8 @@ namespace MWGuilist->setIndexSelected(index);list->beginToItemAt(index);list->eventListChangePosition(list, index);+ // The pointer goes along to the row, so that A there doesn't click the one it was on+ pointAt(list);}else if (MyGUI::TabControl* tabs = control->castType<MyGUI::TabControl>(false)){@@ -1461,9 +1483,9 @@ namespace MWGuiadjustControl(1);return;}- if (!control || control->castType<MyGUI::ListBox>(false))+ if (!control || isScriptClickable(control) || control->castType<MyGUI::ListBox>(false)){- // A row of a list, or something the page doesn't know (a script's own settings): a click there+ // A row of a list, a script's setting, or something the page doesn't know: a click thereclickAtPointer();}else if (MyGUI::EditBox* edit = control->castType<MyGUI::EditBox>(false))diff --git a/components/lua_ui/widget.hpp b/components/lua_ui/widget.hppindex 881be37..2d33037 100644--- a/components/lua_ui/widget.hpp+++ b/components/lua_ui/widget.hpp@@ -51,6 +51,8 @@ namespace LuaUivoid setCallback(const std::string&, const LuaUtil::Callback&);void clearCallbacks();+ // Isowind: whether a script handles this event on this widget (the Options window's controller navigation)+ bool hasCallback(std::string_view name) const { return mCallbacks.find(name) != mCallbacks.end(); }void setProperties(const sol::main_object& props);void setTemplateProperties(const sol::main_object& props) { mTemplateProperties = props; }diff --git a/files/data/scripts/omw/input/settings.lua b/files/data/scripts/omw/input/settings.luaindex 83a862b..cc8c032 100644--- a/files/data/scripts/omw/input/settings.lua+++ b/files/data/scripts/omw/input/settings.lua@@ -72,6 +72,16 @@ local controllerButtonNames = {[input.CONTROLLER_BUTTON.DPadRight] = "D-pad Right",}+-- Isowind: the controller buttons down at the moment (one of them may have clicked the binding, as A does in the+-- controller menus)+local function heldControllerButtons()+ local held = {}+ for button in pairs(controllerButtonNames) do+ if button >= 0 and input.isControllerButtonPressed(button) then held[button] = true end+ end+ return held+end+local function bindingLabel(recording, binding)if recording thenreturn interfaceL10n('N/A')@@ -134,6 +144,9 @@ I.Settings.registerRenderer('inputBinding', function(id, set, arg)id = id,arg = arg,refresh = function() set(id) end,+ -- Isowind: the press of a button that clicked this reaches the scripts after the click; it isn't+ -- the binding+ held = heldControllerButtons(),}recording.refresh()end),@@ -185,7 +198,14 @@ return {bindButton('mouse', button)end,onControllerButtonPress = function(id)+ if recording and recording.held[id] then+ recording.held[id] = nil+ return+ endbindButton('controller', id)end,+ onControllerButtonRelease = function(id)+ if recording then recording.held[id] = nil end+ end,}}diff --git a/isowind/README.txt b/isowind/README.txtindex ab9a2f6..a93cd6f 100644--- a/isowind/README.txt+++ b/isowind/README.txt@@ -116,7 +116,8 @@ F / R Ready weapon / ready magicTab InventoryMouse wheel Zoom, within the view you are in.F7 Switch view: top-down, then Morrowind's third person view, then first person. Change the- key, or add a controller button for it, in Options > Scripts > Isowind.+ key, or add a controller button for it, in Options > Scripts > Isowind (with a controller:+ the D-pad onto the second Switch view's binding, A, then the button to use).1 - 0 Quick keys, shown along the bottom of the screen. To set one, open the inventory (Tab),point at an item, spell or enchanted item and press the number. Right-click a slot forMorrowind's own quick key menu.@@ -136,13 +137,13 @@ side by side (the inventory screen, a chest, a shop) the bumpers switch betweenwhile the triggers switch the tabs within a window. The right stick pressed in shows an item's info, and inthe inventory and magic windows Y puts the item or spell on a quick key. In Options the bumpers switch tabs,the D-pad steps a pointer through the settings (up / down) and adjusts the one it is on (left / right), and A-works it. 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 note), move onto the box with-the D-pad - up from the top of the list or the buttons under it - and press X: a keyboard comes up on the-screen (never by itself). Start or Back puts it away when you are done; in a box of its own (your name, a-password, a save's name) Start also confirms it. Whether you get these menus or Morrowind's own is decided-as the game starts, from whether a controller is plugged in (Isowind.exe's launcher and isowind.sh's---controller flag decide too); the mouse works in them as well.+works it, on the Scripts tab's pages too. 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+note), move onto the box with the D-pad - up from the top of the list or the buttons under it - and press X:+a keyboard comes up on the screen (never by itself). Start or Back puts it away when you are done; in a box+of its own (your name, a password, a save's name) Start also confirms it. Whether you get these menus or+Morrowind's own is decided as the game starts, from whether a controller is plugged in (Isowind.exe's+launcher and isowind.sh's --controller flag decide too); the mouse works in them as well.The minimap turns so that up on it is up on the screen, and shows other players in multiplayer (asdoes the map). Zoom it with the mouse wheel over it while a menu is open, or in Options > Interface,diff --git a/isowind/mod/l10n/Isowind/en.yaml b/isowind/mod/l10n/Isowind/en.yamlindex 28829ee..9a14f9d 100644--- a/isowind/mod/l10n/Isowind/en.yaml+++ b/isowind/mod/l10n/Isowind/en.yaml@@ -6,5 +6,5 @@ settings_player_names_desc: "Always show the other players' names over them."settings_controls: "Controls"switch_view: "Switch view"switch_view_desc: "Top-down, then third person, then first person."-switch_view_key_desc: "Top-down, then third person, then first person (F7 unless changed). Click, then press a key or button."-switch_view_button_desc: "A second binding, for a controller button. Click, then press the button."+switch_view_key_desc: "Top-down, then third person, then first person (F7 unless changed). Click it (or A on it), then press a key or button."+switch_view_button_desc: "A second binding, for a controller button. Move onto it with the D-pad and press A (or click it), then press the button."