forked from Mirrors/openclonk
reimplement object menu controls (#77)
parent
c3cb64d6ea
commit
feaa68cbe5
|
@ -368,6 +368,12 @@
|
|||
GUIDesc=Confirm in menus
|
||||
Action=MenuOK
|
||||
|
||||
[ControlDef]
|
||||
Identifier=MenuSelect
|
||||
GUIName=MenuSelect
|
||||
GUIDesc=Select specific item
|
||||
Action=MenuSelect
|
||||
|
||||
[ControlDef]
|
||||
Identifier=MenuCancel
|
||||
GUIName=Cancel
|
||||
|
@ -398,6 +404,54 @@
|
|||
GUIDesc=In the menu
|
||||
Action=MenuDown
|
||||
|
||||
[ControlDef]
|
||||
Identifier=ObjectMenuOK # hardcoded identifier called by engine mouse control - do not change!
|
||||
GUIName=OK
|
||||
GUIDesc=Confirm in menus
|
||||
Action=ObjectMenuOK
|
||||
|
||||
[ControlDef]
|
||||
Identifier=ObjectMenuOKAll # hardcoded identifier called by engine mouse control - do not change!
|
||||
GUIName=OK
|
||||
GUIDesc=Confirm in menus
|
||||
Action=ObjectMenuOKAll
|
||||
|
||||
[ControlDef]
|
||||
Identifier=ObjectMenuSelect # hardcoded identifier called by engine mouse control - do not change!
|
||||
GUIName=MenuSelect
|
||||
GUIDesc=Select specific item
|
||||
Action=ObjectMenuSelect
|
||||
|
||||
[ControlDef]
|
||||
Identifier=ObjectMenuCancel # hardcoded identifier called by engine mouse control - do not change!
|
||||
GUIName=Cancel
|
||||
GUIDesc=Cancel or close the menu
|
||||
Action=ObjectMenuCancel
|
||||
|
||||
[ControlDef]
|
||||
Identifier=ObjectMenuLeft
|
||||
GUIName=Left
|
||||
GUIDesc=In the menu
|
||||
Action=ObjectMenuLeft
|
||||
|
||||
[ControlDef]
|
||||
Identifier=ObjectMenuRight
|
||||
GUIName=Right
|
||||
GUIDesc=In the menu
|
||||
Action=ObjectMenuRight
|
||||
|
||||
[ControlDef]
|
||||
Identifier=ObjectMenuUp
|
||||
GUIName=Up
|
||||
GUIDesc=In the menu
|
||||
Action=ObjectMenuUp
|
||||
|
||||
[ControlDef]
|
||||
Identifier=ObjectMenuDown
|
||||
GUIName=Down
|
||||
GUIDesc=In the menu
|
||||
Action=ObjectMenuDown
|
||||
|
||||
# Extra buttons...
|
||||
|
||||
[ControlDef]
|
||||
|
@ -517,12 +571,44 @@
|
|||
|
||||
[Assignment]
|
||||
Key=Return
|
||||
Priority=100
|
||||
Control=MenuOK
|
||||
|
||||
[Assignment]
|
||||
Key=Back
|
||||
Priority=100
|
||||
Control=MenuCancel
|
||||
|
||||
[Assignment]
|
||||
Key=A
|
||||
Priority=90
|
||||
Control=ObjectMenuLeft
|
||||
|
||||
[Assignment]
|
||||
Key=D
|
||||
Priority=90
|
||||
Control=ObjectMenuRight
|
||||
|
||||
[Assignment]
|
||||
Key=S
|
||||
Priority=90
|
||||
Control=ObjectMenuDown
|
||||
|
||||
[Assignment]
|
||||
Key=W
|
||||
Priority=90
|
||||
Control=ObjectMenuUp
|
||||
|
||||
[Assignment]
|
||||
Key=Return
|
||||
Priority=90
|
||||
Control=ObjectMenuOK
|
||||
|
||||
[Assignment]
|
||||
Key=Back
|
||||
Priority=90
|
||||
Control=ObjectMenuCancel
|
||||
|
||||
[Assignment]
|
||||
Key=Space
|
||||
Priority=45
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "C4MouseControl.h"
|
||||
#include "C4GraphicsSystem.h"
|
||||
#include "C4Viewport.h"
|
||||
#include "C4Object.h"
|
||||
#include "C4ObjectMenu.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -56,6 +58,14 @@ void C4PlayerControlDef::CompileFunc(StdCompiler *pComp)
|
|||
{ "MenuUp", CDA_MenuUp },
|
||||
{ "MenuRight", CDA_MenuRight },
|
||||
{ "MenuDown", CDA_MenuDown },
|
||||
{ "ObjectMenuOK", CDA_ObjectMenuOK },
|
||||
{ "ObjectMenuOKAll", CDA_ObjectMenuOKAll },
|
||||
{ "ObjectMenuSelect",CDA_ObjectMenuSelect },
|
||||
{ "ObjectMenuCancel",CDA_ObjectMenuCancel },
|
||||
{ "ObjectMenuLeft", CDA_ObjectMenuLeft },
|
||||
{ "ObjectMenuUp", CDA_ObjectMenuUp },
|
||||
{ "ObjectMenuRight", CDA_ObjectMenuRight },
|
||||
{ "ObjectMenuDown", CDA_ObjectMenuDown },
|
||||
{ "ZoomIn", CDA_ZoomIn },
|
||||
{ "ZoomOut", CDA_ZoomOut },
|
||||
{ NULL, CDA_None } };
|
||||
|
@ -82,10 +92,10 @@ bool C4PlayerControlDef::operator ==(const C4PlayerControlDef &cmp) const
|
|||
|
||||
void C4PlayerControlDefs::UpdateInternalCons()
|
||||
{
|
||||
InternalCons.CON_MenuSelect = GetControlIndexByIdentifier("MenuSelect");
|
||||
InternalCons.CON_MenuEnter = GetControlIndexByIdentifier("MenuEnter");
|
||||
InternalCons.CON_MenuEnterAll = GetControlIndexByIdentifier("MenuEnterAll");
|
||||
InternalCons.CON_MenuClose = GetControlIndexByIdentifier("MenuClose");
|
||||
InternalCons.CON_ObjectMenuSelect = GetControlIndexByIdentifier("ObjectMenuSelect");
|
||||
InternalCons.CON_ObjectMenuOK = GetControlIndexByIdentifier("ObjectMenuOK");
|
||||
InternalCons.CON_ObjectMenuOKAll = GetControlIndexByIdentifier("ObjectMenuOKAll");
|
||||
InternalCons.CON_ObjectMenuCancel = GetControlIndexByIdentifier("ObjectMenuCancel");
|
||||
}
|
||||
|
||||
void C4PlayerControlDefs::Clear()
|
||||
|
@ -824,10 +834,14 @@ bool C4PlayerControl::ExecuteControlAction(int32_t iControl, C4PlayerControlDef:
|
|||
// get affected player
|
||||
C4Player *pPlr = NULL;
|
||||
C4Viewport *pVP;
|
||||
C4Object *pCursor = NULL;
|
||||
C4Menu *pCursorMenu = NULL;
|
||||
if (iPlr > -1)
|
||||
{
|
||||
pPlr = ::Players.Get(iPlr);
|
||||
if (!pPlr) return false;
|
||||
pCursor = pPlr->Cursor;
|
||||
if (pCursor && pCursor->Menu && pCursor->Menu->IsActive()) pCursorMenu = pCursor->Menu;
|
||||
}
|
||||
// exec action (on player)
|
||||
switch (eAction)
|
||||
|
@ -844,6 +858,15 @@ bool C4PlayerControl::ExecuteControlAction(int32_t iControl, C4PlayerControlDef:
|
|||
case C4PlayerControlDef::CDA_MenuUp: if (!pPlr || !pPlr->Menu.IsActive() || fUp) return false; pPlr->Menu.Control(COM_MenuUp ,0); return true; // navigate
|
||||
case C4PlayerControlDef::CDA_MenuRight: if (!pPlr || !pPlr->Menu.IsActive() || fUp) return false; pPlr->Menu.Control(COM_MenuRight,0); return true; // navigate
|
||||
case C4PlayerControlDef::CDA_MenuDown: if (!pPlr || !pPlr->Menu.IsActive() || fUp) return false; pPlr->Menu.Control(COM_MenuDown ,0); return true; // navigate
|
||||
|
||||
case C4PlayerControlDef::CDA_ObjectMenuOK: if (!pCursorMenu || fUp) return false; pCursorMenu->Control(COM_MenuEnter,0); return true; // ok on item
|
||||
case C4PlayerControlDef::CDA_ObjectMenuOKAll: if (!pCursorMenu || fUp) return false; pCursorMenu->Control(COM_MenuEnterAll,0); return true; // alt ok on item
|
||||
case C4PlayerControlDef::CDA_ObjectMenuSelect: if (!pCursorMenu || fUp) return false; pCursorMenu->Control(COM_MenuSelect,rKeyExtraData.iStrength); return true; // select an item directly
|
||||
case C4PlayerControlDef::CDA_ObjectMenuCancel: if (!pCursorMenu || fUp) return false; pCursorMenu->Control(COM_MenuClose,0); return true; // close menu
|
||||
case C4PlayerControlDef::CDA_ObjectMenuLeft: if (!pCursorMenu || fUp) return false; pCursorMenu->Control(COM_MenuLeft ,0); return true; // navigate
|
||||
case C4PlayerControlDef::CDA_ObjectMenuUp: if (!pCursorMenu || fUp) return false; pCursorMenu->Control(COM_MenuUp ,0); return true; // navigate
|
||||
case C4PlayerControlDef::CDA_ObjectMenuRight: if (!pCursorMenu || fUp) return false; pCursorMenu->Control(COM_MenuRight,0); return true; // navigate
|
||||
case C4PlayerControlDef::CDA_ObjectMenuDown: if (!pCursorMenu || fUp) return false; pCursorMenu->Control(COM_MenuDown ,0); return true; // navigate
|
||||
|
||||
case C4PlayerControlDef::CDA_ZoomIn: if (!pPlr || !(pVP = GraphicsSystem.GetViewport(iPlr))) return false; pVP->ChangeZoom(C4GFX_ZoomStep); return true; // viewport zoom
|
||||
case C4PlayerControlDef::CDA_ZoomOut: if (!pPlr || !(pVP = GraphicsSystem.GetViewport(iPlr))) return false; pVP->ChangeZoom(1.0f/C4GFX_ZoomStep); return true; // viewport zoom
|
||||
|
|
|
@ -45,6 +45,7 @@ class C4PlayerControlDef
|
|||
CDA_Script, // default: Script callback
|
||||
CDA_Menu, // open player menu (async)
|
||||
CDA_MenuOK, CDA_MenuCancel, CDA_MenuLeft, CDA_MenuUp, CDA_MenuRight, CDA_MenuDown, // player menu controls (async)
|
||||
CDA_ObjectMenuOK, CDA_ObjectMenuOKAll, CDA_ObjectMenuSelect, CDA_ObjectMenuCancel, CDA_ObjectMenuLeft, CDA_ObjectMenuUp, CDA_ObjectMenuRight, CDA_ObjectMenuDown, // object menu controls (sync)
|
||||
CDA_ZoomIn, CDA_ZoomOut // player viewport control (async)
|
||||
};
|
||||
private:
|
||||
|
@ -70,8 +71,9 @@ class C4PlayerControlDef
|
|||
bool operator ==(const C4PlayerControlDef &cmp) const;
|
||||
|
||||
bool Execute(bool fUp, const C4KeyEventData &rKeyExtraData); // key was triggered - execute and return if handled
|
||||
bool IsAsync() const { return eAction != CDA_None && eAction != CDA_Script; } // true if to be executed directly when triggered
|
||||
bool IsSync() const { return eAction == CDA_Script; } // true if to be executed via control queue
|
||||
bool IsObjectMenuControl() const { return eAction>=CDA_ObjectMenuOK && eAction<=CDA_ObjectMenuDown; }
|
||||
bool IsAsync() const { return eAction != CDA_None && eAction != CDA_Script && !IsObjectMenuControl(); } // true if to be executed directly when triggered
|
||||
bool IsSync() const { return eAction == CDA_Script || IsObjectMenuControl(); } // true if to be executed via control queue
|
||||
bool IsValid() const { return eAction != CDA_None; }
|
||||
};
|
||||
|
||||
|
@ -88,8 +90,8 @@ class C4PlayerControlDefs
|
|||
public:
|
||||
struct CInternalCons
|
||||
{
|
||||
int32_t CON_MenuSelect, CON_MenuEnterAll, CON_MenuEnter, CON_MenuClose;
|
||||
CInternalCons() : CON_MenuSelect(CON_None), CON_MenuEnterAll(CON_None), CON_MenuEnter(CON_None), CON_MenuClose(CON_None) {}
|
||||
int32_t CON_ObjectMenuSelect, CON_ObjectMenuOKAll, CON_ObjectMenuOK, CON_ObjectMenuCancel;
|
||||
CInternalCons() : CON_ObjectMenuSelect(CON_None), CON_ObjectMenuOKAll(CON_None), CON_ObjectMenuOK(CON_None), CON_ObjectMenuCancel(CON_None) {}
|
||||
} InternalCons;
|
||||
|
||||
void UpdateInternalCons();
|
||||
|
|
|
@ -345,19 +345,19 @@ void C4ObjectMenu::Execute()
|
|||
void C4ObjectMenu::OnUserSelectItem(int32_t Player, int32_t iIndex)
|
||||
{
|
||||
// queue.... 2do
|
||||
Game.Input.Add(CID_PlrControl, new C4ControlPlayerControl(Player,Game.PlayerControlDefs.InternalCons.CON_MenuSelect,iIndex | C4MN_AdjustPosition));
|
||||
Game.Input.Add(CID_PlrControl, new C4ControlPlayerControl(Player,Game.PlayerControlDefs.InternalCons.CON_ObjectMenuSelect,iIndex | C4MN_AdjustPosition));
|
||||
}
|
||||
|
||||
void C4ObjectMenu::OnUserEnter(int32_t Player, int32_t iIndex, bool fRight)
|
||||
{
|
||||
// object menu: Through queue 2do
|
||||
Game.Input.Add(CID_PlrControl, new C4ControlPlayerControl(Player,fRight ? Game.PlayerControlDefs.InternalCons.CON_MenuEnterAll : Game.PlayerControlDefs.InternalCons.CON_MenuEnter,iIndex));
|
||||
Game.Input.Add(CID_PlrControl, new C4ControlPlayerControl(Player,fRight ? Game.PlayerControlDefs.InternalCons.CON_ObjectMenuOKAll : Game.PlayerControlDefs.InternalCons.CON_ObjectMenuOK,iIndex));
|
||||
}
|
||||
|
||||
void C4ObjectMenu::OnUserClose()
|
||||
{
|
||||
// Queue 2do
|
||||
Game.Input.Add(CID_PlrControl, new C4ControlPlayerControl(::MouseControl.GetPlayer(),Game.PlayerControlDefs.InternalCons.CON_MenuClose,0));
|
||||
Game.Input.Add(CID_PlrControl, new C4ControlPlayerControl(::MouseControl.GetPlayer(),Game.PlayerControlDefs.InternalCons.CON_ObjectMenuCancel,0));
|
||||
}
|
||||
|
||||
bool C4ObjectMenu::IsReadOnly()
|
||||
|
|
Loading…
Reference in New Issue