1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-06 17:15:35 +00:00

Wrote a meta menu for accessibility on VR controllers with few keys.

This commit is contained in:
Mads Buvik Sandvei 2020-10-27 20:45:41 +01:00
parent 5ffd884b14
commit c1e6b05555
11 changed files with 350 additions and 83 deletions

View file

@ -249,7 +249,7 @@ if(BUILD_OPENMW_VR)
add_openmw_dir (mwvr
openxraction openxractionset openxrdebug openxrinput openxrmanager openxrmanagerimpl openxrswapchain openxrswapchainimpl
realisticcombat
vranimation vrcamera vrenvironment vrgui vrinputmanager vrinput vrsession vrframebuffer vrshadow vrtypes vrview vrviewer
vranimation vrcamera vrenvironment vrframebuffer vrgui vrinputmanager vrinput vrmetamenu vrsession vrshadow vrtypes vrview vrviewer
)
openmw_add_executable(openmw_vr

View file

@ -46,7 +46,8 @@ namespace MWGui
GM_LoadingWallpaper,
GM_Jail,
GM_QuickKeysMenu
GM_QuickKeysMenu,
GM_VrMetaMenu
};
// Windows shown in inventory mode

View file

@ -120,6 +120,7 @@
#include "resourceskin.hpp"
#ifdef USE_OPENXR
#include "../mwvr/vrmetamenu.hpp"
#include "../mwvr/vrenvironment.hpp"
#include "../mwvr/vrgui.hpp"
#endif
@ -447,6 +448,12 @@ namespace MWGui
mWindows.push_back(mJailScreen);
mGuiModeStates[GM_Jail] = GuiModeState(mJailScreen);
#ifdef USE_OPENXR
mVrMetaMenu = new MWVR::VrMetaMenu(w, h);
mWindows.push_back(mVrMetaMenu);
mGuiModeStates[GM_VrMetaMenu] = GuiModeState(mVrMetaMenu);
#endif
std::string werewolfFaderTex = "textures\\werewolfoverlay.dds";
if (mResourceSystem->getVFS()->exists(werewolfFaderTex))
{

View file

@ -88,6 +88,11 @@ namespace MWRender
class LocalMap;
}
namespace MWVR
{
class VrMetaMenu;
}
namespace MWGui
{
class WindowBase;
@ -440,6 +445,7 @@ namespace MWGui
ScreenFader* mScreenFader;
DebugWindow* mDebugWindow;
JailScreen* mJailScreen;
MWVR::VrMetaMenu* mVrMetaMenu;
std::vector<WindowBase*> mWindows;

View file

@ -55,6 +55,7 @@ namespace MWVR
// while staying true to openxr's binding system, so if the system i wrote for the oculus touch isn't a good fit for
// the vive/index, we might want to rewrite this to handle bindings ourselves.
createMWAction<ButtonPressAction>(MWInput::A_GameMenu, "game_menu", "Game Menu");
createMWAction<ButtonPressAction>(A_VrMetaMenu, "meta_menu", "Meta Menu");
createMWAction<ButtonLongPressAction>(A_Recenter, "reposition_menu", "Reposition Menu");
createMWAction<ButtonPressAction>(MWInput::A_Inventory, "inventory", "Inventory");
createMWAction<ButtonPressAction>(MWInput::A_Activate, "activate", "Activate");
@ -71,14 +72,14 @@ namespace MWVR
createMWAction<AxisAction>(MWInput::A_LookLeftRight, "look_left_right", "Look Left Right");
createMWAction<AxisAction>(MWInput::A_MoveForwardBackward, "move_forward_backward", "Move Forward Backward");
createMWAction<AxisAction>(MWInput::A_MoveLeftRight, "move_left_right", "Move Left Right");
createMWAction<ButtonLongPressAction>(MWInput::A_Journal, "journal_book", "Journal Book");
createMWAction<ButtonLongPressAction>(MWInput::A_QuickSave, "quick_save", "Quick Save");
createMWAction<ButtonPressAction>(MWInput::A_Journal, "journal_book", "Journal Book");
createMWAction<ButtonPressAction>(MWInput::A_QuickSave, "quick_save", "Quick Save");
createMWAction<ButtonPressAction>(MWInput::A_Rest, "rest", "Rest");
createMWAction<AxisAction>(A_ActivateTouch, "activate_touched", "Activate Touch");
createMWAction<ButtonPressAction>(MWInput::A_AlwaysRun, "always_run", "Always Run");
createMWAction<ButtonPressAction>(MWInput::A_AutoMove, "auto_move", "Auto Move");
createMWAction<ButtonLongPressAction>(MWInput::A_ToggleHUD, "toggle_hud", "Toggle HUD");
createMWAction<ButtonLongPressAction>(MWInput::A_ToggleDebug, "toggle_debug", "Toggle DEBUG");
createMWAction<ButtonPressAction>(MWInput::A_ToggleHUD, "toggle_hud", "Toggle HUD");
createMWAction<ButtonPressAction>(MWInput::A_ToggleDebug, "toggle_debug", "Toggle the debug hud");
createMWAction<AxisAction>(A_MenuUpDown, "menu_up_down", "Menu Up Down");
createMWAction<AxisAction>(A_MenuLeftRight, "menu_left_right", "Menu Left Right");
createMWAction<ButtonPressAction>(A_MenuSelect, "menu_select", "Menu Select");

View file

@ -12,6 +12,7 @@ namespace MWVR
enum VrActions
{
A_VrFirst = MWInput::A_Last + 1,
A_VrMetaMenu,
A_ActivateTouch,
A_HapticsLeft,
A_HapticsRight,

View file

@ -182,10 +182,10 @@ namespace MWVR
// In-game character controls
SuggestedBindings simpleGameplayBindings{
{MWInput::A_Use, "/user/hand/left/input/select/click"}, // Touch: X
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"}, // Touch: Y
{A_VrMetaMenu, "/user/hand/left/input/menu/click"}, // Touch: Y
{A_Recenter, "/user/hand/left/input/menu/click"}, // Touch: Y
{A_ActivateTouch, "/user/hand/right/input/select/click"}, // Touch: A
{MWInput::A_Inventory, "/user/hand/right/input/menu/click"}, // Touch: B
{MWInput::A_AutoMove, "/user/hand/right/input/menu/click"}, // Touch: B
};
// GUI controls
@ -206,25 +206,25 @@ namespace MWVR
// In-game character controls
SuggestedBindings gameplayBindings{
{A_ActivateTouch, "/user/hand/right/input/squeeze/value"},
{A_Recenter, "/user/hand/left/input/menu/click"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/value"},
{MWInput::A_AlwaysRun, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_AutoMove, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Inventory, "/user/hand/right/input/b/click"},
{MWInput::A_Journal, "/user/hand/right/input/b/click"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/thumbstick/x"},
{MWInput::A_MoveForwardBackward,"/user/hand/left/input/thumbstick/y"},
{MWInput::A_MoveLeftRight, "/user/hand/left/input/thumbstick/x"},
{MWInput::A_QuickSave, "/user/hand/left/input/y/click"},
{MWInput::A_Rest, "/user/hand/left/input/y/click"},
{A_VrMetaMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/value"},
{MWInput::A_ToggleDebug, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_ToggleHUD, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_MoveLeftRight, "/user/hand/left/input/thumbstick/x"},
{MWInput::A_MoveForwardBackward,"/user/hand/left/input/thumbstick/y"},
{MWInput::A_AlwaysRun, "/user/hand/left/input/thumbstick/click"},
//{MWInput::A_ToggleHUD, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_ToggleSpell, "/user/hand/left/input/x/click"},
//{MWInput::A_QuickSave, "/user/hand/left/input/y/click"},
{MWInput::A_Rest, "/user/hand/left/input/y/click"},
{MWInput::A_ToggleWeapon, "/user/hand/right/input/a/click"},
{MWInput::A_Inventory, "/user/hand/right/input/b/click"},
//{MWInput::A_Journal, "/user/hand/right/input/b/click"},
{A_ActivateTouch, "/user/hand/right/input/squeeze/value"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/value"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/thumbstick/x"},
{MWInput::A_AutoMove, "/user/hand/right/input/thumbstick/click"},
//{MWInput::A_ToggleDebug, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
};
@ -234,8 +234,8 @@ namespace MWVR
{A_MenuLeftRight, "/user/hand/right/input/thumbstick/x"},
{A_MenuSelect, "/user/hand/right/input/a/click"},
{A_MenuBack, "/user/hand/right/input/b/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{A_Recenter, "/user/hand/left/input/menu/click"},
};
@ -249,37 +249,37 @@ namespace MWVR
// In-game character controls
SuggestedBindings gameplayBindings{
{A_ActivateTouch, "/user/hand/right/input/squeeze/value"},
{A_Recenter, "/user/hand/left/input/menu/click"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/value"},
{MWInput::A_AlwaysRun, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_AutoMove, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Inventory, "/user/hand/right/input/b/click"},
{MWInput::A_Journal, "/user/hand/right/input/b/click"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/thumbstick/x"},
{A_VrMetaMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/value"},
{MWInput::A_MoveForwardBackward,"/user/hand/left/input/thumbstick/y"},
{MWInput::A_MoveLeftRight, "/user/hand/left/input/thumbstick/x"},
{MWInput::A_QuickSave, "/user/hand/left/input/y/click"},
{MWInput::A_Rest, "/user/hand/left/input/y/click"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/value"},
{MWInput::A_ToggleDebug, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_ToggleHUD, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_AlwaysRun, "/user/hand/left/input/thumbstick/click"},
//{MWInput::A_ToggleHUD, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_ToggleSpell, "/user/hand/left/input/x/click"},
//{MWInput::A_QuickSave, "/user/hand/left/input/y/click"},
{MWInput::A_Rest, "/user/hand/left/input/y/click"},
{MWInput::A_ToggleWeapon, "/user/hand/right/input/a/click"},
{MWInput::A_Inventory, "/user/hand/right/input/b/click"},
//{MWInput::A_Journal, "/user/hand/right/input/b/click"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/thumbstick/x"},
{MWInput::A_AutoMove, "/user/hand/right/input/thumbstick/click"},
//{MWInput::A_ToggleDebug, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{A_ActivateTouch, "/user/hand/right/input/squeeze/value"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/value"},
};
// GUI controls
SuggestedBindings GUIBindings{
{A_Recenter, "/user/hand/left/input/menu/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{A_MenuUpDown, "/user/hand/right/input/thumbstick/y"},
{A_MenuLeftRight, "/user/hand/right/input/thumbstick/x"},
{A_MenuSelect, "/user/hand/right/input/a/click"},
{A_MenuBack, "/user/hand/right/input/b/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{A_Recenter, "/user/hand/left/input/menu/click"},
};
mXRInput->suggestBindings(ActionSet::Gameplay, controllerProfilePath, gameplayBindings);
@ -298,33 +298,33 @@ namespace MWVR
//{MWInput::A_AutoMove, "/user/hand/right/input/thumbstick/click"},
//{MWInput::A_ToggleDebug, "/user/hand/right/input/thumbstick/click"},
//{MWInput::A_ToggleHUD, "/user/hand/left/input/thumbstick/click"},
{A_ActivateTouch, "/user/hand/right/input/squeeze/click"},
{A_Recenter, "/user/hand/left/input/menu/click"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Inventory, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_Journal, "/user/hand/right/input/thumbstick/click"},
{A_VrMetaMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/thumbstick/x"},
{MWInput::A_MoveForwardBackward,"/user/hand/left/input/thumbstick/y"},
{MWInput::A_MoveLeftRight, "/user/hand/left/input/thumbstick/x"},
{MWInput::A_QuickSave, "/user/hand/left/input/thumbstick/click"},
//{MWInput::A_QuickSave, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_Rest, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/click"},
{MWInput::A_ToggleSpell, "/user/hand/left/input/trackpad/click"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/click"},
{MWInput::A_Inventory, "/user/hand/right/input/thumbstick/click"},
//{MWInput::A_Journal, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/thumbstick/x"},
{MWInput::A_ToggleWeapon, "/user/hand/right/input/trackpad/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{A_ActivateTouch, "/user/hand/right/input/squeeze/click"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/click"},
};
// GUI controls
SuggestedBindings GUIBindings{
{A_MenuBack, "/user/hand/left/input/trackpad/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{A_Recenter, "/user/hand/left/input/menu/click"},
{A_MenuUpDown, "/user/hand/right/input/thumbstick/y"},
{A_MenuLeftRight, "/user/hand/right/input/thumbstick/x"},
{A_MenuSelect, "/user/hand/right/input/trackpad/click"},
{A_MenuBack, "/user/hand/left/input/trackpad/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{A_Recenter, "/user/hand/left/input/menu/click"},
};
mXRInput->suggestBindings(ActionSet::Gameplay, controllerProfilePath, gameplayBindings);
@ -336,37 +336,37 @@ namespace MWVR
std::string controllerProfilePath = "/interaction_profiles/valve/index_controller";
// In-game character controls
SuggestedBindings gameplayBindings{
{A_ActivateTouch, "/user/hand/right/input/squeeze/force"},
{A_Recenter, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/force"},
//{MWInput::A_AlwaysRun, "/user/hand/left/input/thumbstick/click"},
//{MWInput::A_AutoMove, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/trackpad/force"},
{MWInput::A_Inventory, "/user/hand/right/input/b/click"},
{MWInput::A_Journal, "/user/hand/right/input/b/click"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/thumbstick/x"},
{MWInput::A_ToggleSpell, "/user/hand/left/input/a/click"},
{MWInput::A_Rest, "/user/hand/left/input/b/click"},
//{MWInput::A_QuickSave, "/user/hand/left/input/b/click"},
{MWInput::A_MoveForwardBackward,"/user/hand/left/input/thumbstick/y"},
{MWInput::A_MoveLeftRight, "/user/hand/left/input/thumbstick/x"},
{MWInput::A_QuickSave, "/user/hand/left/input/b/click"},
{MWInput::A_Rest, "/user/hand/left/input/b/click"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/force"},
//{MWInput::A_ToggleDebug, "/user/hand/right/input/thumbstick/click"},
//{MWInput::A_ToggleHUD, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_ToggleSpell, "/user/hand/left/input/a/click"},
{A_Recenter, "/user/hand/left/input/trackpad/force"},
{A_VrMetaMenu, "/user/hand/left/input/trackpad/force"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/force"},
{MWInput::A_ToggleWeapon, "/user/hand/right/input/a/click"},
{MWInput::A_Inventory, "/user/hand/right/input/b/click"},
//{MWInput::A_Journal, "/user/hand/right/input/b/click"},
//{MWInput::A_AutoMove, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/thumbstick/x"},
//{MWInput::A_ToggleDebug, "/user/hand/right/input/thumbstick/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{A_ActivateTouch, "/user/hand/right/input/squeeze/force"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/force"},
};
// GUI controls
SuggestedBindings GUIBindings{
{A_MenuUpDown, "/user/hand/right/input/thumbstick/y"},
{A_MenuLeftRight, "/user/hand/right/input/thumbstick/x"},
{A_MenuSelect, "/user/hand/right/input/a/click"},
{A_MenuBack, "/user/hand/right/input/b/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/trackpad/force"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{A_Recenter, "/user/hand/left/input/thumbstick/click"},
{A_Recenter, "/user/hand/left/input/thumbstick/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/trackpad/force"},
{A_MenuSelect, "/user/hand/right/input/a/click"},
{A_MenuBack, "/user/hand/right/input/b/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{A_MenuUpDown, "/user/hand/right/input/thumbstick/y"},
{A_MenuLeftRight, "/user/hand/right/input/thumbstick/x"},
};
mXRInput->suggestBindings(ActionSet::Gameplay, controllerProfilePath, gameplayBindings);
@ -389,18 +389,18 @@ namespace MWVR
//{MWInput::A_Rest, "/user/hand/left/input/b/click"},
//{MWInput::A_ToggleDebug, "/user/hand/right/input/thumbstick/click"},
//{MWInput::A_ToggleHUD, "/user/hand/left/input/thumbstick/click"},
{A_ActivateTouch, "/user/hand/right/input/squeeze/click"},
{A_Recenter, "/user/hand/left/input/menu/click"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/click"},
{MWInput::A_GameMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/trackpad/x"},
{A_VrMetaMenu, "/user/hand/left/input/menu/click"},
{MWInput::A_MoveForwardBackward,"/user/hand/left/input/trackpad/y"},
{MWInput::A_MoveLeftRight, "/user/hand/left/input/trackpad/x"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/click"},
{MWInput::A_ToggleSpell, "/user/hand/left/input/trackpad/click"},
{MWInput::A_Jump, "/user/hand/left/input/trigger/value"},
{MWInput::A_Sneak, "/user/hand/left/input/squeeze/click"},
{MWInput::A_LookLeftRight, "/user/hand/right/input/trackpad/x"},
{MWInput::A_ToggleWeapon, "/user/hand/right/input/trackpad/click"},
{MWInput::A_Use, "/user/hand/right/input/trigger/value"},
{A_ActivateTouch, "/user/hand/right/input/squeeze/click"},
{MWInput::A_Activate, "/user/hand/right/input/squeeze/click"},
};
// GUI controls
@ -703,13 +703,14 @@ namespace MWVR
case MWInput::A_GameMenu:
mActionManager->toggleMainMenu();
break;
case A_VrMetaMenu:
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_VrMetaMenu);
break;
case MWInput::A_Screenshot:
mActionManager->screenshot();
break;
case MWInput::A_Inventory:
mActionManager->toggleInventory();
//injectMousePress(SDL_BUTTON_RIGHT, true);
//mBindingsManager->ics().getChannel(MWInput::A_Inventory)->setValue(0.f);
break;
case MWInput::A_Console:
mActionManager->toggleConsole();
@ -825,9 +826,6 @@ namespace MWVR
if (isToggleSneak)
mActionManager->toggleSneaking();
break;
case MWInput::A_Inventory:
//injectMousePress(SDL_BUTTON_RIGHT, false);
//mBindingsManager->ics().getChannel(MWInput::A_Inventory)->setValue(0.f);
default:
break;
}

View file

@ -0,0 +1,151 @@
#include "vrmetamenu.hpp"
#include <MyGUI_InputManager.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/statemanager.hpp"
#include "vrmetamenu.hpp"
namespace MWVR
{
VrMetaMenu::VrMetaMenu(int w, int h)
: WindowBase("openmw_vr_metamenu.layout")
, mWidth (w)
, mHeight (h)
, mButtonBox(0)
{
getWidget(mButtonBox, "ButtonBox");
updateMenu();
}
VrMetaMenu::~VrMetaMenu()
{
}
void VrMetaMenu::onResChange(int w, int h)
{
mWidth = w;
mHeight = h;
updateMenu();
}
void VrMetaMenu::setVisible (bool visible)
{
if (visible)
updateMenu();
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mButtons["return"]);
Layout::setVisible (visible);
}
void VrMetaMenu::onFrame(float dt)
{
}
void VrMetaMenu::onConsole()
{
if (MyGUI::InputManager::getInstance().isModalAny())
return;
MWBase::Environment::get().getWindowManager()->toggleConsole();
}
void VrMetaMenu::onGameMenu()
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_MainMenu);
}
void VrMetaMenu::onJournal()
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Journal);
}
void VrMetaMenu::onInventory()
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Inventory);
}
void VrMetaMenu::onRest()
{
if (!MWBase::Environment::get().getWindowManager()->getRestEnabled() || MWBase::Environment::get().getWindowManager()->isGuiMode())
return;
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Rest); //Open rest GUI
}
void VrMetaMenu::onQuickLoad()
{
if (!MyGUI::InputManager::getInstance().isModalAny())
MWBase::Environment::get().getStateManager()->quickLoad();
}
void VrMetaMenu::onQuickSave()
{
if (!MyGUI::InputManager::getInstance().isModalAny())
MWBase::Environment::get().getStateManager()->quickSave();
}
void VrMetaMenu::close()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_VrMetaMenu);
}
void VrMetaMenu::onButtonClicked(MyGUI::Widget *sender)
{
std::string name = *sender->getUserData<std::string>();
close();
if (name == "console")
onConsole();
else if (name == "gamemenu")
onGameMenu();
else if (name == "journal")
onJournal();
else if (name == "inventory")
onInventory();
else if (name == "rest")
onRest();
else if (name == "quickload")
onQuickLoad();
else if (name == "quicksave")
onQuickSave();
}
bool VrMetaMenu::exit()
{
return MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_Running;
}
void VrMetaMenu::updateMenu()
{
setCoord(0,0, mWidth, mHeight);
static std::vector<std::string> buttons{ "return", "quicksave", "quickload", "console", "inventory", "journal", "rest", "gamemenu" };
if(mButtons.empty())
for (std::string& buttonId : buttons)
{
MyGUI::Button* button = nullptr;
getWidget(button, buttonId);
if (!button)
throw std::logic_error( std::string() + "Unable to find button \"" + buttonId + "\"");
button->eventMouseButtonClick += MyGUI::newDelegate(this, &VrMetaMenu::onButtonClicked);
button->setUserData(std::string(buttonId));
button->setVisible(true);
mButtons[buttonId] = button;
}
int width = mButtonBox->getWidth();
int height = mButtonBox->getHeight();
mButtonBox->setCoord (mWidth/2 - width/2, mHeight/2 - height/2, width, height);
mButtonBox->setVisible(true);
}
}

View file

@ -0,0 +1,60 @@
#ifndef OPENMW_GAME_MWVR_VRMETAMENU_H
#define OPENMW_GAME_MWVR_VRMETAMENU_H
#include "../mwgui/windowbase.hpp"
#include <MyGUI_Button.h>
#include "components/widgets/box.hpp"
namespace Gui
{
class ImageButton;
}
namespace VFS
{
class Manager;
}
namespace MWVR
{
class VrMetaMenu : public MWGui::WindowBase
{
int mWidth;
int mHeight;
bool mHasAnimatedMenu;
public:
VrMetaMenu(int w, int h);
~VrMetaMenu();
void onResChange(int w, int h) override;
void setVisible (bool visible) override;
void onFrame(float dt) override;
bool exit() override;
private:
MyGUI::Widget* mButtonBox{ nullptr };
std::map<std::string, MyGUI::Button*> mButtons{};
void onButtonClicked (MyGUI::Widget* sender);
void onConsole();
void onJournal();
void onGameMenu();
void onInventory();
void onRest();
void onQuickLoad();
void onQuickSave();
void close();
void updateMenu();
};
}
#endif

View file

@ -61,6 +61,7 @@ set(MYGUI_FILES
openmw_list.skin.xml
openmw_loading_screen.layout
openmw_magicselection_dialog.layout
openmw_vr_metamenu.layout
openmw_mainmenu.layout
openmw_mainmenu.skin.xml
openmw_map_window.layout

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<!-- TODO: Multiple language support -->
<Widget type="Widget" layer="MainMenu" position="0 0 300 659" name="_Main" align="Center">
<Widget type="Widget" position="63 0 173 659" name="ButtonBox">
<Widget type="Button" skin="MW_Button" position="30 0 112 64" name="return">
<Property key="Caption" value="Return"/>
<Property key="FontHeight" value="32"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="4 85 164 64" name="quicksave">
<Property key="Caption" value="Quick Save"/>
<Property key="FontHeight" value="32"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="3 170 166 64" name="quickload">
<Property key="Caption" value="Quick Load"/>
<Property key="FontHeight" value="32"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="27 255 118 64" name="console">
<Property key="Caption" value="Console"/>
<Property key="FontHeight" value="32"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="14 340 145 64" name="inventory">
<Property key="Caption" value="Inventory"/>
<Property key="FontHeight" value="32"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="31 425 110 64" name="journal">
<Property key="Caption" value="Journal"/>
<Property key="FontHeight" value="32"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="46 510 80 64" name="rest">
<Property key="Caption" value="Rest"/>
<Property key="FontHeight" value="32"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="0 595 173 64" name="gamemenu">
<Property key="Caption" value="Game Menu"/>
<Property key="FontHeight" value="32"/>
</Widget>
</Widget>
</Widget>
</MyGUI>