GlobalActionMap keys; boot on Welcome/HUD
This commit is contained in:
1 parent
a118214588
commit
dcdbdf8780
1 file changed
+134
-20
@@ -11,6 +11,8 @@ $RPGClient::OrbitInit = 0;
|
|||||||
$RPGClient::HudPlaced = 0;
|
$RPGClient::HudPlaced = 0;
|
||||||
$RPGClient::KeyMapPushed = 0;
|
$RPGClient::KeyMapPushed = 0;
|
||||||
$RPGClient::MoveHijacked = 0;
|
$RPGClient::MoveHijacked = 0;
|
||||||
|
$RPGClient::GlobalKeys = 0;
|
||||||
|
$RPGClient::PlayBooted = 0;
|
||||||
$RPGClient::PanX = 0;
|
$RPGClient::PanX = 0;
|
||||||
$RPGClient::PanY = 0;
|
$RPGClient::PanY = 0;
|
||||||
$RPGClient::PanMax = 48;
|
$RPGClient::PanMax = 48;
|
||||||
@@ -247,9 +249,39 @@ function RPGClient_StartCameraTick()
|
|||||||
$RPGClient::CamTickSched = schedule(32, 0, RPGClient_CameraTick);
|
$RPGClient::CamTickSched = schedule(32, 0, RPGClient_CameraTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function RPGClient_InPlay()
|
||||||
|
{
|
||||||
|
return isObject(ServerConnection) && ($RPGClient::Server || $RPGClient::Active);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RPGClient_BootPlay()
|
||||||
|
{
|
||||||
|
if (!isObject(ServerConnection))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($RPGClient::PlayBooted)
|
||||||
|
{
|
||||||
|
RPGClient_EnsureOverlay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$RPGClient::Server = 1;
|
||||||
|
$RPGClient::Active = 1;
|
||||||
|
$RPGClient::PlayBooted = 1;
|
||||||
|
if ($RPGClient::Dist < 6)
|
||||||
|
{
|
||||||
|
$RPGClient::Dist = 14;
|
||||||
|
}
|
||||||
|
RPGClient_EnsureOverlay();
|
||||||
|
RPGClient_BindKeys();
|
||||||
|
RPGClient_StartCameraTick();
|
||||||
|
RPGClient_ScheduleCamera();
|
||||||
|
RPGClient_EnsureCursor();
|
||||||
|
}
|
||||||
|
|
||||||
function RPGClient_KeyMvForward(%val)
|
function RPGClient_KeyMvForward(%val)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active)
|
if (!RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -258,7 +290,7 @@ function RPGClient_KeyMvForward(%val)
|
|||||||
|
|
||||||
function RPGClient_KeyMvBackward(%val)
|
function RPGClient_KeyMvBackward(%val)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active)
|
if (!RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -267,7 +299,7 @@ function RPGClient_KeyMvBackward(%val)
|
|||||||
|
|
||||||
function RPGClient_KeyMvLeft(%val)
|
function RPGClient_KeyMvLeft(%val)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active)
|
if (!RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -276,13 +308,67 @@ function RPGClient_KeyMvLeft(%val)
|
|||||||
|
|
||||||
function RPGClient_KeyMvRight(%val)
|
function RPGClient_KeyMvRight(%val)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active)
|
if (!RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$RPGClient::MvR = %val;
|
$RPGClient::MvR = %val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function RPGClient_EnsureGlobalKeys()
|
||||||
|
{
|
||||||
|
if ($RPGClient::GlobalKeys || !isObject(GlobalActionMap))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GlobalActionMap.bind(keyboard, w, RPGClient_KeyMvForward);
|
||||||
|
GlobalActionMap.bind(keyboard, s, RPGClient_KeyMvBackward);
|
||||||
|
GlobalActionMap.bind(keyboard, a, RPGClient_KeyMvLeft);
|
||||||
|
GlobalActionMap.bind(keyboard, d, RPGClient_KeyMvRight);
|
||||||
|
GlobalActionMap.bind(keyboard, left, RPGClient_YawLeft);
|
||||||
|
GlobalActionMap.bind(keyboard, right, RPGClient_YawRight);
|
||||||
|
GlobalActionMap.bind(keyboard, equals, RPGClient_ZoomIn);
|
||||||
|
GlobalActionMap.bind(keyboard, minus, RPGClient_ZoomOut);
|
||||||
|
GlobalActionMap.bind(keyboard, "[", RPGClient_ZoomIn);
|
||||||
|
GlobalActionMap.bind(keyboard, "]", RPGClient_ZoomOut);
|
||||||
|
GlobalActionMap.bind(keyboard0, w, RPGClient_KeyMvForward);
|
||||||
|
GlobalActionMap.bind(keyboard0, s, RPGClient_KeyMvBackward);
|
||||||
|
GlobalActionMap.bind(keyboard0, a, RPGClient_KeyMvLeft);
|
||||||
|
GlobalActionMap.bind(keyboard0, d, RPGClient_KeyMvRight);
|
||||||
|
GlobalActionMap.bind(keyboard0, left, RPGClient_YawLeft);
|
||||||
|
GlobalActionMap.bind(keyboard0, right, RPGClient_YawRight);
|
||||||
|
GlobalActionMap.bind(keyboard0, equals, RPGClient_ZoomIn);
|
||||||
|
GlobalActionMap.bind(keyboard0, minus, RPGClient_ZoomOut);
|
||||||
|
$RPGClient::GlobalKeys = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RPGClient_ClearGlobalKeys()
|
||||||
|
{
|
||||||
|
if (!$RPGClient::GlobalKeys || !isObject(GlobalActionMap))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GlobalActionMap.unbind(keyboard, w);
|
||||||
|
GlobalActionMap.unbind(keyboard, s);
|
||||||
|
GlobalActionMap.unbind(keyboard, a);
|
||||||
|
GlobalActionMap.unbind(keyboard, d);
|
||||||
|
GlobalActionMap.unbind(keyboard, left);
|
||||||
|
GlobalActionMap.unbind(keyboard, right);
|
||||||
|
GlobalActionMap.unbind(keyboard, equals);
|
||||||
|
GlobalActionMap.unbind(keyboard, minus);
|
||||||
|
GlobalActionMap.unbind(keyboard, "[");
|
||||||
|
GlobalActionMap.unbind(keyboard, "]");
|
||||||
|
GlobalActionMap.unbind(keyboard0, w);
|
||||||
|
GlobalActionMap.unbind(keyboard0, s);
|
||||||
|
GlobalActionMap.unbind(keyboard0, a);
|
||||||
|
GlobalActionMap.unbind(keyboard0, d);
|
||||||
|
GlobalActionMap.unbind(keyboard0, left);
|
||||||
|
GlobalActionMap.unbind(keyboard0, right);
|
||||||
|
GlobalActionMap.unbind(keyboard0, equals);
|
||||||
|
GlobalActionMap.unbind(keyboard0, minus);
|
||||||
|
$RPGClient::GlobalKeys = 0;
|
||||||
|
}
|
||||||
|
|
||||||
function RPGClient_SendClickFromCursor(%button)
|
function RPGClient_SendClickFromCursor(%button)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active || !isObject(Canvas))
|
if (!$RPGClient::Active || !isObject(Canvas))
|
||||||
@@ -370,6 +456,7 @@ function RPGClient_EnsureOverlay()
|
|||||||
}
|
}
|
||||||
RPGClient_EnsureKeyMap();
|
RPGClient_EnsureKeyMap();
|
||||||
RPGClient_HijackMoveMap();
|
RPGClient_HijackMoveMap();
|
||||||
|
RPGClient_EnsureGlobalKeys();
|
||||||
$enableDirectInput = 1;
|
$enableDirectInput = 1;
|
||||||
activateDirectInput();
|
activateDirectInput();
|
||||||
$mvFreeLook = 0;
|
$mvFreeLook = 0;
|
||||||
@@ -421,6 +508,8 @@ function RPGClient_DisableOverlay()
|
|||||||
$RPGClient::OrbitInit = 0;
|
$RPGClient::OrbitInit = 0;
|
||||||
$RPGClient::HudPlaced = 0;
|
$RPGClient::HudPlaced = 0;
|
||||||
$RPGClient::MoveHijacked = 0;
|
$RPGClient::MoveHijacked = 0;
|
||||||
|
$RPGClient::PlayBooted = 0;
|
||||||
|
RPGClient_ClearGlobalKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
function RPGClient_Hud_Place()
|
function RPGClient_Hud_Place()
|
||||||
@@ -511,7 +600,7 @@ function RPGClient_ScheduleCamera()
|
|||||||
|
|
||||||
function RPGClient_YawLeft(%val)
|
function RPGClient_YawLeft(%val)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active)
|
if (!RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -527,7 +616,7 @@ function RPGClient_YawLeft(%val)
|
|||||||
|
|
||||||
function RPGClient_YawRight(%val)
|
function RPGClient_YawRight(%val)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active)
|
if (!RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -543,7 +632,7 @@ function RPGClient_YawRight(%val)
|
|||||||
|
|
||||||
function RPGClient_ZoomIn(%val)
|
function RPGClient_ZoomIn(%val)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active)
|
if (!RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -556,7 +645,7 @@ function RPGClient_ZoomIn(%val)
|
|||||||
|
|
||||||
function RPGClient_ZoomOut(%val)
|
function RPGClient_ZoomOut(%val)
|
||||||
{
|
{
|
||||||
if (!$RPGClient::Active)
|
if (!RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -616,6 +705,8 @@ function clientCmdRPG_Welcome(%serverProto, %accepted)
|
|||||||
if (%accepted && %serverProto == $RPGClient::Version)
|
if (%accepted && %serverProto == $RPGClient::Version)
|
||||||
{
|
{
|
||||||
$RPGClient::HelloPending = 0;
|
$RPGClient::HelloPending = 0;
|
||||||
|
$RPGClient::Server = 1;
|
||||||
|
schedule(0, 0, RPGClient_BootPlay);
|
||||||
schedule(2500, 0, RPGClient_TopDownWatch);
|
schedule(2500, 0, RPGClient_TopDownWatch);
|
||||||
}
|
}
|
||||||
else if (!%accepted)
|
else if (!%accepted)
|
||||||
@@ -652,19 +743,33 @@ function RPGClient_EnsurePlayGui()
|
|||||||
|
|
||||||
function clientCmdRPG_TopDown(%on, %yaw, %dist)
|
function clientCmdRPG_TopDown(%on, %yaw, %dist)
|
||||||
{
|
{
|
||||||
if (%on && !RPGClient_EnsurePlayGui())
|
if (%on)
|
||||||
{
|
{
|
||||||
|
$RPGClient::Server = 1;
|
||||||
|
$RPGClient::Active = 1;
|
||||||
|
$RPGClient::PlayBooted = 1;
|
||||||
|
if (%dist > 0)
|
||||||
|
{
|
||||||
|
$RPGClient::Dist = %dist;
|
||||||
|
}
|
||||||
|
$RPGClient::Yaw = %yaw;
|
||||||
|
if (!RPGClient_EnsurePlayGui())
|
||||||
|
{
|
||||||
|
RPGClient_BootPlay();
|
||||||
schedule(200, 0, clientCmdRPG_TopDown, %on, %yaw, %dist);
|
schedule(200, 0, clientCmdRPG_TopDown, %on, %yaw, %dist);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (%on)
|
|
||||||
{
|
|
||||||
cancel($RPGClient::TopDownWatchSched);
|
cancel($RPGClient::TopDownWatchSched);
|
||||||
$RPGClient::TopDownWatchSched = 0;
|
$RPGClient::TopDownWatchSched = 0;
|
||||||
$RPGClient::Server = 1;
|
if (%dist > 0)
|
||||||
$RPGClient::Active = 1;
|
{
|
||||||
|
$RPGClient::Dist = %dist;
|
||||||
|
}
|
||||||
|
else if ($RPGClient::Dist < 6)
|
||||||
|
{
|
||||||
|
$RPGClient::Dist = 14;
|
||||||
|
}
|
||||||
$RPGClient::Yaw = %yaw;
|
$RPGClient::Yaw = %yaw;
|
||||||
$RPGClient::Dist = %dist > 0 ? %dist : 14;
|
|
||||||
$RPGClient::OrbitInit = 0;
|
$RPGClient::OrbitInit = 0;
|
||||||
$RPGClient::HudPlaced = 0;
|
$RPGClient::HudPlaced = 0;
|
||||||
RPGClient_EnsureOverlay();
|
RPGClient_EnsureOverlay();
|
||||||
@@ -678,6 +783,8 @@ function clientCmdRPG_TopDown(%on, %yaw, %dist)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$RPGClient::Server = 0;
|
||||||
|
$RPGClient::PlayBooted = 0;
|
||||||
RPGClient_DisableOverlay();
|
RPGClient_DisableOverlay();
|
||||||
RPGClient_UnbindKeys();
|
RPGClient_UnbindKeys();
|
||||||
}
|
}
|
||||||
@@ -685,6 +792,10 @@ function clientCmdRPG_TopDown(%on, %yaw, %dist)
|
|||||||
|
|
||||||
function clientCmdRPG_Hud(%hp, %maxHp, %silver, %load, %cap, %skillId, %skillValue, %blocking, %tHp, %tMax)
|
function clientCmdRPG_Hud(%hp, %maxHp, %silver, %load, %cap, %skillId, %skillValue, %blocking, %tHp, %tMax)
|
||||||
{
|
{
|
||||||
|
if (!RPGClient_InPlay())
|
||||||
|
{
|
||||||
|
RPGClient_BootPlay();
|
||||||
|
}
|
||||||
RPGClient_Hud_Update(%hp, %maxHp, %silver, %load, %cap, %skillId, %skillValue, %tHp, %tMax);
|
RPGClient_Hud_Update(%hp, %maxHp, %silver, %load, %cap, %skillId, %skillValue, %tHp, %tMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -860,7 +971,7 @@ package RPGClient_Input
|
|||||||
{
|
{
|
||||||
function moveforward(%val)
|
function moveforward(%val)
|
||||||
{
|
{
|
||||||
if ($RPGClient::Active)
|
if (RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
RPGClient_KeyMvForward(%val);
|
RPGClient_KeyMvForward(%val);
|
||||||
return;
|
return;
|
||||||
@@ -870,7 +981,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function movebackward(%val)
|
function movebackward(%val)
|
||||||
{
|
{
|
||||||
if ($RPGClient::Active)
|
if (RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
RPGClient_KeyMvBackward(%val);
|
RPGClient_KeyMvBackward(%val);
|
||||||
return;
|
return;
|
||||||
@@ -880,7 +991,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function moveleft(%val)
|
function moveleft(%val)
|
||||||
{
|
{
|
||||||
if ($RPGClient::Active)
|
if (RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
RPGClient_KeyMvLeft(%val);
|
RPGClient_KeyMvLeft(%val);
|
||||||
return;
|
return;
|
||||||
@@ -890,7 +1001,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function moveright(%val)
|
function moveright(%val)
|
||||||
{
|
{
|
||||||
if ($RPGClient::Active)
|
if (RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
RPGClient_KeyMvRight(%val);
|
RPGClient_KeyMvRight(%val);
|
||||||
return;
|
return;
|
||||||
@@ -900,7 +1011,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function invLeft(%val)
|
function invLeft(%val)
|
||||||
{
|
{
|
||||||
if ($RPGClient::Active)
|
if (RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
RPGClient_YawLeft(%val);
|
RPGClient_YawLeft(%val);
|
||||||
return;
|
return;
|
||||||
@@ -910,7 +1021,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function invRight(%val)
|
function invRight(%val)
|
||||||
{
|
{
|
||||||
if ($RPGClient::Active)
|
if (RPGClient_InPlay())
|
||||||
{
|
{
|
||||||
RPGClient_YawRight(%val);
|
RPGClient_YawRight(%val);
|
||||||
return;
|
return;
|
||||||
@@ -1009,6 +1120,9 @@ package RPGClient_Cleanup
|
|||||||
$RPGClient::HelloLast = "";
|
$RPGClient::HelloLast = "";
|
||||||
cancel($RPGClient::TopDownWatchSched);
|
cancel($RPGClient::TopDownWatchSched);
|
||||||
$RPGClient::TopDownWatchSched = 0;
|
$RPGClient::TopDownWatchSched = 0;
|
||||||
|
$RPGClient::Server = 0;
|
||||||
|
$RPGClient::PlayBooted = 0;
|
||||||
|
RPGClient_ClearGlobalKeys();
|
||||||
Parent::disconnectedCleanup(%doReconnect);
|
Parent::disconnectedCleanup(%doReconnect);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user