1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-15 20:46:35 +00:00

Add option to show controller tooltips by default

This commit is contained in:
Andrew Lanzone 2025-07-04 02:40:52 -07:00
parent 088b2d1bbc
commit 8379c31f13
19 changed files with 142 additions and 42 deletions

View file

@ -304,7 +304,9 @@ bool Launcher::SettingsPage::loadSettings()
loadSettingBool(Settings::gui().mColorTopicEnable, *changeDialogTopicsCheckBox);
showOwnedComboBox->setCurrentIndex(Settings::game().mShowOwned);
loadSettingBool(Settings::gui().mStretchMenuBackground, *stretchBackgroundCheckBox);
connect(controllerMenusCheckBox, &QCheckBox::toggled, this, &SettingsPage::slotControllerMenusToggled);
loadSettingBool(Settings::gui().mControllerMenus, *controllerMenusCheckBox);
loadSettingBool(Settings::gui().mControllerTooltips, *controllerMenuTooltipsCheckBox);
loadSettingBool(Settings::map().mAllowZooming, *useZoomOnMapCheckBox);
loadSettingBool(Settings::game().mGraphicHerbalism, *graphicHerbalismCheckBox);
scalingSpinBox->setValue(Settings::gui().mScalingFactor);
@ -499,6 +501,7 @@ void Launcher::SettingsPage::saveSettings()
saveSettingInt(*showOwnedComboBox, Settings::game().mShowOwned);
saveSettingBool(*stretchBackgroundCheckBox, Settings::gui().mStretchMenuBackground);
saveSettingBool(*controllerMenusCheckBox, Settings::gui().mControllerMenus);
saveSettingBool(*controllerMenuTooltipsCheckBox, Settings::gui().mControllerTooltips);
saveSettingBool(*useZoomOnMapCheckBox, Settings::map().mAllowZooming);
saveSettingBool(*graphicHerbalismCheckBox, Settings::game().mGraphicHerbalism);
Settings::gui().mScalingFactor.set(scalingSpinBox->value());
@ -557,6 +560,11 @@ void Launcher::SettingsPage::slotAnimSourcesToggled(bool checked)
}
}
void Launcher::SettingsPage::slotControllerMenusToggled(bool checked)
{
controllerMenuTooltipsCheckBox->setEnabled(checked);
}
void Launcher::SettingsPage::slotPostProcessToggled(bool checked)
{
postprocessTransparentPostpassCheckBox->setEnabled(checked);

View file

@ -34,6 +34,7 @@ namespace Launcher
void slotSkyBlendingToggled(bool checked);
void slotShadowDistLimitToggled(bool checked);
void slotDistantLandToggled(bool checked);
void slotControllerMenusToggled(bool checked);
private:
Config::GameSettings& mGameSettings;

View file

@ -1408,6 +1408,19 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="controllerMenuTooltipsCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When using controller menus, make tooltips visible by default.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Show Controller Tooltips By Default</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="showOwnedLabel">
<property name="text">

View file

@ -21,6 +21,7 @@ namespace MWGui
ItemView::ItemView()
: mScrollView(nullptr)
, mControllerActiveWindow(false)
{
}
@ -189,12 +190,8 @@ namespace MWGui
{
mControllerActiveWindow = active;
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->getControllerTooltip())
{
winMgr->setCursorActive(false);
winMgr->setControllerTooltip(false);
}
MWBase::Environment::get().getWindowManager()->setControllerTooltip(
active && Settings::gui().mControllerTooltips);
if (active)
updateControllerFocus(-1, mControllerFocus);
@ -214,7 +211,6 @@ namespace MWGui
// Select the focused item, if any.
if (mControllerFocus >= 0 && mControllerFocus < mItemCount)
{
MWBase::Environment::get().getWindowManager()->setControllerTooltip(false);
MyGUI::Widget* dragArea = mScrollView->getChildAt(0);
onSelectedItem(dragArea->getChildAt(mControllerFocus));
}

View file

@ -149,11 +149,9 @@ namespace MWGui
mSpellButtons[0].first->setStateSelected(true);
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
winMgr->setControllerTooltip(Settings::gui().mControllerTooltips);
if (winMgr->getControllerTooltip())
{
winMgr->setCursorActive(false);
winMgr->setControllerTooltip(false);
}
MWBase::Environment::get().getInputManager()->warpMouseToWidget(mSpellButtons[0].first);
}
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the

View file

@ -103,7 +103,6 @@ namespace MWGui
mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sCancel}";
mControllerButtons.x = "#{sOk}";
mControllerButtons.r3 = "#{sInfo}";
}
}
@ -602,6 +601,7 @@ namespace MWGui
mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sCancel}";
mControllerButtons.x = "#{sBuy}";
mControllerButtons.r3 = "#{sInfo}";
}
}
@ -613,13 +613,6 @@ namespace MWGui
mPtr = actor;
mNameEdit->setCaption({});
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (Settings::gui().mControllerMenus && winMgr->getControllerTooltip())
{
winMgr->setCursorActive(false);
winMgr->setControllerTooltip(false);
}
startEditing();
}
@ -850,7 +843,11 @@ namespace MWGui
mEffectFocus = 0;
mRightColumn = false;
if (mAvailableButtons.size() > 0)
{
mAvailableButtons[0]->setStateSelected(true);
if (MWBase::Environment::get().getWindowManager()->getControllerTooltip())
MWBase::Environment::get().getInputManager()->warpMouseToWidget(mAvailableButtons[0]);
}
}
}
@ -1038,24 +1035,25 @@ namespace MWGui
bool EffectEditorBase::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
if (arg.button == SDL_CONTROLLER_BUTTON_A)
{
if (!mRightColumn && mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
{
onAvailableEffectClicked(mAvailableButtons[mAvailableFocus]);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
winMgr->playSound(ESM::RefId::stringRefId("Menu Click"));
}
else if (mRightColumn && mEffectFocus >= 0 && mEffectFocus < static_cast<int>(mEffectButtons.size()))
{
onEditEffect(mEffectButtons[mEffectFocus].second);
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
winMgr->playSound(ESM::RefId::stringRefId("Menu Click"));
}
}
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK)
{
// Toggle info tooltip
MWBase::Environment::get().getWindowManager()->setControllerTooltip(
!MWBase::Environment::get().getWindowManager()->getControllerTooltip());
winMgr->setControllerTooltip(!mRightColumn && !winMgr->getControllerTooltip());
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
{
@ -1098,6 +1096,8 @@ namespace MWGui
mEffectButtons[mEffectFocus].first->setStateSelected(false);
if (mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
mAvailableButtons[mAvailableFocus]->setStateSelected(true);
winMgr->setControllerTooltip(Settings::gui().mControllerTooltips);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mRightColumn && mEffectButtons.size() > 0)
{
@ -1106,6 +1106,8 @@ namespace MWGui
mAvailableButtons[mAvailableFocus]->setStateSelected(false);
if (mEffectFocus >= 0 && mEffectFocus < static_cast<int>(mEffectButtons.size()))
mEffectButtons[mEffectFocus].first->setStateSelected(true);
winMgr->setControllerTooltip(false);
}
// Scroll the list to keep the active item in view
@ -1120,7 +1122,7 @@ namespace MWGui
if (!mRightColumn && mAvailableFocus >= 0 && mAvailableFocus < static_cast<int>(mAvailableButtons.size()))
{
// Warp the mouse to the selected spell to show the tooltip
if (MWBase::Environment::get().getWindowManager()->getControllerTooltip())
if (winMgr->getControllerTooltip())
MWBase::Environment::get().getInputManager()->warpMouseToWidget(mAvailableButtons[mAvailableFocus]);
}

View file

@ -32,6 +32,8 @@ namespace MWGui
: mScrollView(nullptr)
, mShowCostColumn(true)
, mHighlightSelected(true)
, mControllerActiveWindow(false)
, mControllerFocus(0)
{
}
@ -94,7 +96,6 @@ namespace MWGui
mLines.clear();
mButtons.clear();
mGroupIndices.clear();
mControllerTooltip = false;
while (mScrollView->getChildCount())
MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0));
@ -231,6 +232,12 @@ namespace MWGui
height += lineHeight;
}
if (Settings::gui().mControllerMenus)
{
mControllerFocus = wrap(mControllerFocus, mButtons.size());
updateControllerFocus(-1, mControllerFocus);
}
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the
// scrollbar is hidden
mScrollView->setVisibleVScroll(false);
@ -329,6 +336,13 @@ namespace MWGui
mScrollView->setViewOffset(MyGUI::IntPoint(0, 0));
}
void SpellView::setActiveControllerWindow(bool active)
{
mControllerActiveWindow = active;
if (active)
update();
}
void SpellView::onControllerButton(const unsigned char button)
{
if (mButtons.empty())
@ -348,9 +362,8 @@ namespace MWGui
else if (button == SDL_CONTROLLER_BUTTON_RIGHTSTICK)
{
// Toggle info tooltip
mControllerTooltip = !mControllerTooltip;
if (mControllerTooltip && mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mButtons.size()))
MWBase::Environment::get().getInputManager()->warpMouseToWidget(mButtons[mControllerFocus].first);
MWBase::Environment::get().getWindowManager()->setControllerTooltip(
!MWBase::Environment::get().getWindowManager()->getControllerTooltip());
}
else if (button == SDL_CONTROLLER_BUTTON_DPAD_UP)
mControllerFocus--;
@ -390,6 +403,8 @@ namespace MWGui
if (prevFocus != mControllerFocus)
updateControllerFocus(prevFocus, mControllerFocus);
else
updateControllerFocus(-1, mControllerFocus);
}
void SpellView::updateControllerFocus(int prevFocus, int newFocus)
@ -404,7 +419,7 @@ namespace MWGui
prev->onMouseLostFocus(nullptr);
}
if (newFocus >= 0 && newFocus < static_cast<int>(mButtons.size()))
if (mControllerActiveWindow && newFocus >= 0 && newFocus < static_cast<int>(mButtons.size()))
{
Gui::SharedStateButton* focused = mButtons[newFocus].first;
if (focused)
@ -421,7 +436,7 @@ namespace MWGui
mScrollView->setViewOffset(MyGUI::IntPoint(0, -lineHeight * (line - 5)));
}
if (mControllerTooltip)
if (MWBase::Environment::get().getWindowManager()->getControllerTooltip())
MWBase::Environment::get().getInputManager()->warpMouseToWidget(focused);
}
}

View file

@ -57,6 +57,7 @@ namespace MWGui
void resetScrollbars();
void setActiveControllerWindow(bool active);
void onControllerButton(const unsigned char button);
private:
@ -99,8 +100,8 @@ namespace MWGui
/// Keep a list of group offsets for controller navigation
std::vector<int> mGroupIndices;
bool mControllerActiveWindow;
int mControllerFocus;
bool mControllerTooltip;
void updateControllerFocus(int prevFocus, int newFocus);
void onSpellSelected(MyGUI::Widget* _sender);

View file

@ -323,10 +323,12 @@ namespace MWGui
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>();
window->setCoord(x, active ? y : viewSize.height + 1, width, height);
MWBase::Environment::get().getWindowManager()->setControllerTooltip(
active && Settings::gui().mControllerTooltips);
}
if (active)
mSpellView->update();
mSpellView->setActiveControllerWindow(active);
WindowBase::setActiveControllerWindow(active);
}

View file

@ -949,10 +949,16 @@ namespace MWGui
if (winCount == 0)
return;
mActiveControllerWindows[mode] = std::clamp(activeIndex, 0, winCount - 1);
activeIndex = std::clamp(activeIndex, 0, winCount - 1);
mActiveControllerWindows[mode] = activeIndex;
// Set active window last so inactive windows don't stomp on changes it makes, e.g. to tooltips.
for (int i = 0; i < winCount; i++)
mGuiModeStates[mode].mWindows[i]->setActiveControllerWindow(i == activeIndex);
{
if (i != activeIndex)
mGuiModeStates[mode].mWindows[i]->setActiveControllerWindow(false);
}
mGuiModeStates[mode].mWindows[activeIndex]->setActiveControllerWindow(true);
MWBase::Environment::get().getInputManager()->setGamepadGuiCursorEnabled(
mGuiModeStates[mode].mWindows[activeIndex]->isGamepadCursorAllowed());
@ -1468,13 +1474,23 @@ namespace MWGui
if (mConsole && mConsole->isVisible())
mConsole->onOpen();
if (Settings::gui().mControllerMenus && !mGuiModes.empty())
if (Settings::gui().mControllerMenus)
{
// Re-apply any controller-specific window changes.
const GuiMode mode = mGuiModes.back();
int winCount = mGuiModeStates[mode].mWindows.size();
for (int i = 0; i < winCount; i++)
mGuiModeStates[mode].mWindows[i]->setActiveControllerWindow(i == mActiveControllerWindows[mode]);
if (mGuiModes.empty())
setControllerTooltip(false);
else
{
// Re-apply any controller-specific window changes.
const GuiMode mode = mGuiModes.back();
int winCount = mGuiModeStates[mode].mWindows.size();
for (int i = 0; i < winCount; i++)
{
if (i != mActiveControllerWindows[mode])
mGuiModeStates[mode].mWindows[i]->setActiveControllerWindow(false);
}
mGuiModeStates[mode].mWindows[mActiveControllerWindows[mode]]->setActiveControllerWindow(true);
}
}
}

View file

@ -32,6 +32,7 @@ namespace MWInput
, mGamepadGuiCursorEnabled(true)
, mGuiCursorEnabled(true)
, mJoystickLastUsed(false)
, mGamepadMousePressed(false)
{
if (!controllerBindingsFile.empty())
{
@ -142,6 +143,7 @@ namespace MWInput
if (arg.button == SDL_CONTROLLER_BUTTON_A) // We'll pretend that A is left click.
{
bool mousePressSuccess = mMouseManager->injectMouseButtonPress(SDL_BUTTON_LEFT);
mGamepadMousePressed = true;
if (MyGUI::InputManager::getInstance().getMouseFocusWidget())
{
MyGUI::Button* b
@ -186,12 +188,13 @@ namespace MWInput
mJoystickLastUsed = true;
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
{
if (mGamepadGuiCursorEnabled)
if (mGamepadGuiCursorEnabled && (!Settings::gui().mControllerMenus || mGamepadMousePressed))
{
// Temporary mouse binding until keyboard controls are available:
if (arg.button == SDL_CONTROLLER_BUTTON_A) // We'll pretend that A is left click.
{
bool mousePressSuccess = mMouseManager->injectMouseButtonRelease(SDL_BUTTON_LEFT);
mGamepadMousePressed = false;
if (mBindingsManager->isDetectingBindingState()) // If the player just triggered binding, don't let
// button release bind.
return;

View file

@ -62,6 +62,7 @@ namespace MWInput
bool mGamepadGuiCursorEnabled;
bool mGuiCursorEnabled;
bool mJoystickLastUsed;
bool mGamepadMousePressed;
};
}
#endif

View file

@ -26,6 +26,7 @@ namespace Settings
SettingValue<float> mTooltipDelay{ mIndex, "GUI", "tooltip delay", makeMaxSanitizerFloat(0) };
SettingValue<bool> mStretchMenuBackground{ mIndex, "GUI", "stretch menu background" };
SettingValue<bool> mControllerMenus{ mIndex, "GUI", "controller menus" };
SettingValue<bool> mControllerTooltips{ mIndex, "GUI", "controller tooltips" };
SettingValue<bool> mSubtitles{ mIndex, "GUI", "subtitles" };
SettingValue<bool> mHitFader{ mIndex, "GUI", "hit fader" };
SettingValue<bool> mWerewolfOverlay{ mIndex, "GUI", "werewolf overlay" };

View file

@ -1455,5 +1455,13 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov
<source>Enable Controller Menus</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When using controller menus, make tooltips visible by default.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show Controller Tooltips By Default</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -1455,5 +1455,13 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov
<source>Enable Controller Menus</source>
<translation></translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When using controller menus, make tooltips visible by default.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation></translation>
</message>
<message>
<source>Show Controller Tooltips By Default</source>
<translation></translation>
</message>
</context>
</TS>

View file

@ -1458,5 +1458,13 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Make it easier to use game menus with a controller.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Faciliter l&apos;utilisation des menus de jeu avec une manette.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When using controller menus, make tooltips visible by default.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Lorsque vous utilisez les menus du contrôleur, rendez les info-bulles visibles par défaut.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>Show Controller Tooltips By Default</source>
<translation>Afficher les info-bulles du contrôleur par défaut</translation>
</message>
</context>
</TS>

View file

@ -1470,5 +1470,13 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov
<source>Enable Controller Menus</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When using controller menus, make tooltips visible by default.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show Controller Tooltips By Default</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -1474,5 +1474,13 @@ de ordinarie fonterna i Morrowind. Bocka denna ruta om du ändå föredrar ordin
<source>Enable Controller Menus</source>
<translation>Aktivera handkontrollmenyer</translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When using controller menus, make tooltips visible by default.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;När du använder kontrollmenyer, synliggör verktygstips som standard.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>Show Controller Tooltips By Default</source>
<translation>Visa verktygstips för kontrollenheter som standard</translation>
</message>
</context>
</TS>

View file

@ -204,6 +204,9 @@ stretch menu background = false
# Make menus easier to navigate with a controller.
controller menus = false
# When true, you do not need to press R3 to show tooltips.
controller tooltips = false
# Subtitles for NPC spoken dialog and some sound effects.
subtitles = false