Chat: restore WASD in chat; stock moveMap; drop global hijack
This commit is contained in:
1 parent
ac9815ed79
commit
98d701c0b0
1 file changed
+126
-54
@@ -183,6 +183,7 @@ function RPGClient_EnsureCursor()
|
|||||||
function RPGClient_CameraTick()
|
function RPGClient_CameraTick()
|
||||||
{
|
{
|
||||||
$RPGClient::CamTickSched = 0;
|
$RPGClient::CamTickSched = 0;
|
||||||
|
RPGClient_SyncInputStack();
|
||||||
if (!isObject(ServerConnection) || !$RPGClient::CamTickOn)
|
if (!isObject(ServerConnection) || !$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -255,6 +256,32 @@ function RPGClient_InPlay()
|
|||||||
return isObject(ServerConnection) && ($RPGClient::Server || $RPGClient::Active);
|
return isObject(ServerConnection) && ($RPGClient::Server || $RPGClient::Active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function RPGClient_TextTyping()
|
||||||
|
{
|
||||||
|
if (isObject(Canvas))
|
||||||
|
{
|
||||||
|
%fg = Canvas.getFirstResponder();
|
||||||
|
if (isObject(%fg))
|
||||||
|
{
|
||||||
|
%cn = %fg.getClassName();
|
||||||
|
if (%cn $= "GuiTextEditCtrl" || %cn $= "GuiMLTextEditCtrl")
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isObject(newChatText) && newChatText.isAwake())
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RPGClient_CamInputAllowed()
|
||||||
|
{
|
||||||
|
return $RPGClient::CamTickOn && $RPGClient::Active && !RPGClient_TextTyping();
|
||||||
|
}
|
||||||
|
|
||||||
function RPGClient_BootPlay()
|
function RPGClient_BootPlay()
|
||||||
{
|
{
|
||||||
if (!isObject(ServerConnection))
|
if (!isObject(ServerConnection))
|
||||||
@@ -269,6 +296,7 @@ function RPGClient_BootPlay()
|
|||||||
{
|
{
|
||||||
$RPGClient::Dist = 14;
|
$RPGClient::Dist = 14;
|
||||||
}
|
}
|
||||||
|
RPGClient_StockMoveMapBinds();
|
||||||
RPGClient_EnsureOverlay();
|
RPGClient_EnsureOverlay();
|
||||||
RPGClient_BindKeys();
|
RPGClient_BindKeys();
|
||||||
RPGClient_StartCameraTick();
|
RPGClient_StartCameraTick();
|
||||||
@@ -282,6 +310,10 @@ function RPGClient_KeyMvForward(%val)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!RPGClient_CamInputAllowed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$RPGClient::CamTickOn)
|
if (!$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
moveforward(%val);
|
moveforward(%val);
|
||||||
@@ -300,6 +332,10 @@ function RPGClient_KeyMvBackward(%val)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!RPGClient_CamInputAllowed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$RPGClient::CamTickOn)
|
if (!$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
movebackward(%val);
|
movebackward(%val);
|
||||||
@@ -318,6 +354,10 @@ function RPGClient_KeyMvLeft(%val)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!RPGClient_CamInputAllowed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$RPGClient::CamTickOn)
|
if (!$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
moveleft(%val);
|
moveleft(%val);
|
||||||
@@ -336,6 +376,10 @@ function RPGClient_KeyMvRight(%val)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!RPGClient_CamInputAllowed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$RPGClient::CamTickOn)
|
if (!$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
moveright(%val);
|
moveright(%val);
|
||||||
@@ -348,7 +392,7 @@ function RPGClient_KeyMvRight(%val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function RPGClient_RestoreMoveMap()
|
function RPGClient_StockMoveMapBinds()
|
||||||
{
|
{
|
||||||
if (!isObject(moveMap))
|
if (!isObject(moveMap))
|
||||||
{
|
{
|
||||||
@@ -362,57 +406,37 @@ function RPGClient_RestoreMoveMap()
|
|||||||
moveMap.bind(keyboard, right, invRight);
|
moveMap.bind(keyboard, right, invRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
function RPGClient_EnsureGlobalKeys()
|
function RPGClient_RestoreMoveMap()
|
||||||
{
|
{
|
||||||
if ($RPGClient::GlobalKeys || !isObject(GlobalActionMap))
|
RPGClient_StockMoveMapBinds();
|
||||||
|
}
|
||||||
|
|
||||||
|
function RPGClient_SyncInputStack()
|
||||||
|
{
|
||||||
|
if (!$RPGClient::Active)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GlobalActionMap.bind(keyboard, w, RPGClient_KeyMvForward);
|
RPGClient_StockMoveMapBinds();
|
||||||
GlobalActionMap.bind(keyboard, s, RPGClient_KeyMvBackward);
|
if (RPGClient_TextTyping())
|
||||||
GlobalActionMap.bind(keyboard, a, RPGClient_KeyMvLeft);
|
{
|
||||||
GlobalActionMap.bind(keyboard, d, RPGClient_KeyMvRight);
|
if ($RPGClient::KeyMapPushed && isObject(RPGClient_KeyMap))
|
||||||
GlobalActionMap.bind(keyboard, left, RPGClient_YawLeft);
|
{
|
||||||
GlobalActionMap.bind(keyboard, right, RPGClient_YawRight);
|
RPGClient_KeyMap.pop();
|
||||||
GlobalActionMap.bind(keyboard, equals, RPGClient_ZoomIn);
|
$RPGClient::KeyMapPushed = 0;
|
||||||
GlobalActionMap.bind(keyboard, minus, RPGClient_ZoomOut);
|
}
|
||||||
GlobalActionMap.bind(keyboard, "[", RPGClient_ZoomIn);
|
RPGClient_ClearGlobalKeys();
|
||||||
GlobalActionMap.bind(keyboard, "]", RPGClient_ZoomOut);
|
return;
|
||||||
GlobalActionMap.bind(keyboard0, w, RPGClient_KeyMvForward);
|
}
|
||||||
GlobalActionMap.bind(keyboard0, s, RPGClient_KeyMvBackward);
|
RPGClient_EnsureKeyMap();
|
||||||
GlobalActionMap.bind(keyboard0, a, RPGClient_KeyMvLeft);
|
}
|
||||||
GlobalActionMap.bind(keyboard0, d, RPGClient_KeyMvRight);
|
|
||||||
GlobalActionMap.bind(keyboard0, left, RPGClient_YawLeft);
|
function RPGClient_EnsureGlobalKeys()
|
||||||
GlobalActionMap.bind(keyboard0, right, RPGClient_YawRight);
|
{
|
||||||
GlobalActionMap.bind(keyboard0, equals, RPGClient_ZoomIn);
|
|
||||||
GlobalActionMap.bind(keyboard0, minus, RPGClient_ZoomOut);
|
|
||||||
$RPGClient::GlobalKeys = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function RPGClient_ClearGlobalKeys()
|
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;
|
$RPGClient::GlobalKeys = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,6 +475,15 @@ function RPGClient_EnsureKeyMap()
|
|||||||
RPGClient_KeyMap.bind(keyboard, m, RPGClient_ToggleCursor);
|
RPGClient_KeyMap.bind(keyboard, m, RPGClient_ToggleCursor);
|
||||||
RPGClient_KeyMap.bind(keyboard0, m, RPGClient_ToggleCursor);
|
RPGClient_KeyMap.bind(keyboard0, m, RPGClient_ToggleCursor);
|
||||||
}
|
}
|
||||||
|
if (RPGClient_TextTyping())
|
||||||
|
{
|
||||||
|
if ($RPGClient::KeyMapPushed)
|
||||||
|
{
|
||||||
|
RPGClient_KeyMap.pop();
|
||||||
|
$RPGClient::KeyMapPushed = 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ($RPGClient::KeyMapPushed)
|
if ($RPGClient::KeyMapPushed)
|
||||||
{
|
{
|
||||||
RPGClient_KeyMap.pop();
|
RPGClient_KeyMap.pop();
|
||||||
@@ -501,8 +534,7 @@ function RPGClient_EnsureOverlay()
|
|||||||
PlayGui.add(RPGClient_Mouse);
|
PlayGui.add(RPGClient_Mouse);
|
||||||
PlayGui.pushToBack(RPGClient_Mouse);
|
PlayGui.pushToBack(RPGClient_Mouse);
|
||||||
}
|
}
|
||||||
RPGClient_EnsureKeyMap();
|
RPGClient_SyncInputStack();
|
||||||
RPGClient_EnsureGlobalKeys();
|
|
||||||
$enableDirectInput = 1;
|
$enableDirectInput = 1;
|
||||||
activateDirectInput();
|
activateDirectInput();
|
||||||
$mvFreeLook = 0;
|
$mvFreeLook = 0;
|
||||||
@@ -641,6 +673,10 @@ function RPGClient_ScheduleCamera()
|
|||||||
|
|
||||||
function RPGClient_YawLeft(%val)
|
function RPGClient_YawLeft(%val)
|
||||||
{
|
{
|
||||||
|
if (!RPGClient_CamInputAllowed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$RPGClient::CamTickOn)
|
if (!$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
invLeft(%val);
|
invLeft(%val);
|
||||||
@@ -655,6 +691,10 @@ function RPGClient_YawLeft(%val)
|
|||||||
|
|
||||||
function RPGClient_YawRight(%val)
|
function RPGClient_YawRight(%val)
|
||||||
{
|
{
|
||||||
|
if (!RPGClient_CamInputAllowed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$RPGClient::CamTickOn)
|
if (!$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
invRight(%val);
|
invRight(%val);
|
||||||
@@ -669,6 +709,10 @@ function RPGClient_YawRight(%val)
|
|||||||
|
|
||||||
function RPGClient_ZoomIn(%val)
|
function RPGClient_ZoomIn(%val)
|
||||||
{
|
{
|
||||||
|
if (!RPGClient_CamInputAllowed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$RPGClient::CamTickOn)
|
if (!$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -682,6 +726,10 @@ function RPGClient_ZoomIn(%val)
|
|||||||
|
|
||||||
function RPGClient_ZoomOut(%val)
|
function RPGClient_ZoomOut(%val)
|
||||||
{
|
{
|
||||||
|
if (!RPGClient_CamInputAllowed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$RPGClient::CamTickOn)
|
if (!$RPGClient::CamTickOn)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -1032,7 +1080,7 @@ package RPGClient_Input
|
|||||||
{
|
{
|
||||||
function moveforward(%val)
|
function moveforward(%val)
|
||||||
{
|
{
|
||||||
if (RPGClient_InPlay())
|
if (RPGClient_CamInputAllowed())
|
||||||
{
|
{
|
||||||
RPGClient_KeyMvForward(%val);
|
RPGClient_KeyMvForward(%val);
|
||||||
return;
|
return;
|
||||||
@@ -1042,7 +1090,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function movebackward(%val)
|
function movebackward(%val)
|
||||||
{
|
{
|
||||||
if (RPGClient_InPlay())
|
if (RPGClient_CamInputAllowed())
|
||||||
{
|
{
|
||||||
RPGClient_KeyMvBackward(%val);
|
RPGClient_KeyMvBackward(%val);
|
||||||
return;
|
return;
|
||||||
@@ -1052,7 +1100,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function moveleft(%val)
|
function moveleft(%val)
|
||||||
{
|
{
|
||||||
if (RPGClient_InPlay())
|
if (RPGClient_CamInputAllowed())
|
||||||
{
|
{
|
||||||
RPGClient_KeyMvLeft(%val);
|
RPGClient_KeyMvLeft(%val);
|
||||||
return;
|
return;
|
||||||
@@ -1062,7 +1110,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function moveright(%val)
|
function moveright(%val)
|
||||||
{
|
{
|
||||||
if (RPGClient_InPlay())
|
if (RPGClient_CamInputAllowed())
|
||||||
{
|
{
|
||||||
RPGClient_KeyMvRight(%val);
|
RPGClient_KeyMvRight(%val);
|
||||||
return;
|
return;
|
||||||
@@ -1072,7 +1120,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function invLeft(%val)
|
function invLeft(%val)
|
||||||
{
|
{
|
||||||
if (RPGClient_InPlay())
|
if (RPGClient_CamInputAllowed())
|
||||||
{
|
{
|
||||||
RPGClient_YawLeft(%val);
|
RPGClient_YawLeft(%val);
|
||||||
return;
|
return;
|
||||||
@@ -1082,7 +1130,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function invRight(%val)
|
function invRight(%val)
|
||||||
{
|
{
|
||||||
if (RPGClient_InPlay())
|
if (RPGClient_CamInputAllowed())
|
||||||
{
|
{
|
||||||
RPGClient_YawRight(%val);
|
RPGClient_YawRight(%val);
|
||||||
return;
|
return;
|
||||||
@@ -1092,7 +1140,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function scrollInventory(%val)
|
function scrollInventory(%val)
|
||||||
{
|
{
|
||||||
if ($RPGClient::CamTickOn && %val != 0)
|
if (RPGClient_CamInputAllowed() && %val != 0)
|
||||||
{
|
{
|
||||||
if (%val > 0)
|
if (%val > 0)
|
||||||
{
|
{
|
||||||
@@ -1110,7 +1158,7 @@ package RPGClient_Input
|
|||||||
|
|
||||||
function yaw(%val)
|
function yaw(%val)
|
||||||
{
|
{
|
||||||
if ($RPGClient::CamTickOn && %val != 0)
|
if (RPGClient_CamInputAllowed() && %val != 0)
|
||||||
{
|
{
|
||||||
%sens = $pref::Input::MouseSensitivity;
|
%sens = $pref::Input::MouseSensitivity;
|
||||||
$RPGClient::Yaw = $RPGClient::Yaw + %val * %sens * 0.004;
|
$RPGClient::Yaw = $RPGClient::Yaw + %val * %sens * 0.004;
|
||||||
@@ -1231,4 +1279,28 @@ package RPGClient_Mission
|
|||||||
};
|
};
|
||||||
activatePackage(RPGClient_Mission);
|
activatePackage(RPGClient_Mission);
|
||||||
|
|
||||||
|
package RPGClient_ChatKeys
|
||||||
|
{
|
||||||
|
function GlobalChat(%val)
|
||||||
|
{
|
||||||
|
Parent::GlobalChat(%val);
|
||||||
|
if ($RPGClient::Active)
|
||||||
|
{
|
||||||
|
schedule(0, 0, RPGClient_SyncInputStack);
|
||||||
|
schedule(50, 0, RPGClient_SyncInputStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function TeamChat(%val)
|
||||||
|
{
|
||||||
|
Parent::TeamChat(%val);
|
||||||
|
if ($RPGClient::Active)
|
||||||
|
{
|
||||||
|
schedule(0, 0, RPGClient_SyncInputStack);
|
||||||
|
schedule(50, 0, RPGClient_SyncInputStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
activatePackage(RPGClient_ChatKeys);
|
||||||
|
|
||||||
echo("Client_RPG loaded (protocol " @ $RPGClient::Version @ ")");
|
echo("Client_RPG loaded (protocol " @ $RPGClient::Version @ ")");
|
||||||
Reference in new issue
Block a user