Wipwork for updating the BaseUI

Adds ability to select an actionmap for a GuiInputCtrl which will push it onto the stack, so menus can enact an action map
Update of the MainMenuGUI to fit new style and have the logic needed for KBM and gamepad navigation
Very early wipwork of OptionsMenu overhaul for new standard
This commit is contained in:
Areloch 2023-12-06 19:50:51 -06:00
parent 97de2e6b60
commit 616d974212
12 changed files with 746 additions and 492 deletions

View file

@ -40,6 +40,7 @@
#include "gui/editor/editorFunctions.h"
#include "math/mEase.h"
#include "math/mathTypes.h"
#include "sim/actionMap.h"
//-----------------------------------------------------------------------------
@ -387,6 +388,44 @@ void GuiInspectorTypeGuiProfile::consoleInit()
ConsoleBaseType::getType( TYPEID< GuiControlProfile >() )->setInspectorFieldType("GuiInspectorTypeGuiProfile");
}
//-----------------------------------------------------------------------------
// GuiInspectorTypeActionMap
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(GuiInspectorTypeActionMap);
ConsoleDocClass(GuiInspectorTypeActionMap,
"@brief Inspector field type for ActionMap\n\n"
"Editor use only.\n\n"
"@internal"
);
void GuiInspectorTypeActionMap::_populateMenu(GuiPopUpMenuCtrl* menu)
{
// Add the action maps to the menu.
//First add a blank entry so you can clear the action map
menu->addEntry("", 0);
SimGroup* grp = Sim::getRootGroup();
SimSetIterator iter(grp);
for (; *iter; ++iter)
{
ActionMap* actionMap = dynamic_cast<ActionMap*>(*iter);
if (!actionMap)
continue;
menu->addEntry(actionMap->getName(), actionMap->getId());
}
menu->sort();
}
void GuiInspectorTypeActionMap::consoleInit()
{
Parent::consoleInit();
ConsoleBaseType::getType(TYPEID< ActionMap >())->setInspectorFieldType("GuiInspectorTypeActionMap");
}
//-----------------------------------------------------------------------------
// GuiInspectorTypeCheckBox
//-----------------------------------------------------------------------------

View file

@ -186,6 +186,20 @@ public:
virtual void _populateMenu( GuiPopUpMenuCtrl *menu );
};
//-----------------------------------------------------------------------------
// GuiInspectorTypeActionMap Class
//-----------------------------------------------------------------------------
class GuiInspectorTypeActionMap : public GuiInspectorTypeMenuBase
{
private:
typedef GuiInspectorTypeMenuBase Parent;
public:
DECLARE_CONOBJECT(GuiInspectorTypeActionMap);
static void consoleInit();
virtual void _populateMenu(GuiPopUpMenuCtrl* menu);
};
//-----------------------------------------------------------------------------
// GuiInspectorTypeCheckBox Class
//-----------------------------------------------------------------------------

View file

@ -64,6 +64,7 @@ GuiInputCtrl::GuiInputCtrl()
mSendModifierEvents(false),
mIgnoreMouseEvents(false)
{
mActionmap = nullptr;
}
//------------------------------------------------------------------------------
@ -80,6 +81,7 @@ void GuiInputCtrl::initPersistFields()
"If true, Make events will be sent for modifier keys (Default false).");
addField("ignoreMouseEvents", TypeBool, Offset(mIgnoreMouseEvents, GuiInputCtrl),
"If true, any events from mouse devices will be passed through.");
addField("actionMap", TYPEID<ActionMap>(), Offset(mActionmap, GuiInputCtrl), "The name of an action map to push/pop on the input stack alongside the wake/sleep of this control.");
endGroup("GuiInputCtrl");
Parent::initPersistFields();
@ -103,6 +105,12 @@ bool GuiInputCtrl::onWake()
if( !smDesignTime && !mIgnoreMouseEvents)
mouseLock();
if(mActionmap != nullptr)
{
SimSet* actionMapSet = Sim::getActiveActionMapSet();
actionMapSet->pushObject(mActionmap);
}
setFirstResponder();
@ -115,6 +123,13 @@ void GuiInputCtrl::onSleep()
{
Parent::onSleep();
mouseUnlock();
if (mActionmap != nullptr)
{
SimSet* actionMapSet = Sim::getActiveActionMapSet();
actionMapSet->removeObject(mActionmap);
}
clearFirstResponder();
}
@ -158,6 +173,9 @@ bool GuiInputCtrl::onInputEvent( const InputEventInfo &event )
if (mIgnoreMouseEvents && event.deviceType == MouseDeviceType)
return false;
if (mActionmap != nullptr)
return false;
char deviceString[32];
if ( event.action == SI_MAKE )
{

View file

@ -26,6 +26,7 @@
#ifndef _GUIMOUSEEVENTCTRL_H_
#include "gui/utility/guiMouseEventCtrl.h"
#endif
#include "sim/actionMap.h"
/// A control that locks the mouse and reports all keyboard input events
@ -38,6 +39,8 @@ protected:
bool mSendModifierEvents;
bool mIgnoreMouseEvents;
ActionMap* mActionmap;
public:
typedef GuiMouseEventCtrl Parent;