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()
|
||||
{
|
||||
$RPGClient::CamTickSched = 0;
|
||||
RPGClient_SyncInputStack();
|
||||
if (!isObject(ServerConnection) || !$RPGClient::CamTickOn)
|
||||
{
|
||||
return;
|
||||
@@ -255,6 +256,32 @@ function RPGClient_InPlay()
|
||||
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()
|
||||
{
|
||||
if (!isObject(ServerConnection))
|
||||
@@ -269,6 +296,7 @@ function RPGClient_BootPlay()
|
||||
{
|
||||
$RPGClient::Dist = 14;
|
||||
}
|
||||
RPGClient_StockMoveMapBinds();
|
||||
RPGClient_EnsureOverlay();
|
||||
RPGClient_BindKeys();
|
||||
RPGClient_StartCameraTick();
|
||||
@@ -282,6 +310,10 @@ function RPGClient_KeyMvForward(%val)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!RPGClient_CamInputAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
moveforward(%val);
|
||||
@@ -300,6 +332,10 @@ function RPGClient_KeyMvBackward(%val)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!RPGClient_CamInputAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
movebackward(%val);
|
||||
@@ -318,6 +354,10 @@ function RPGClient_KeyMvLeft(%val)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!RPGClient_CamInputAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
moveleft(%val);
|
||||
@@ -336,6 +376,10 @@ function RPGClient_KeyMvRight(%val)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!RPGClient_CamInputAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
moveright(%val);
|
||||
@@ -348,7 +392,7 @@ function RPGClient_KeyMvRight(%val)
|
||||
}
|
||||
}
|
||||
|
||||
function RPGClient_RestoreMoveMap()
|
||||
function RPGClient_StockMoveMapBinds()
|
||||
{
|
||||
if (!isObject(moveMap))
|
||||
{
|
||||
@@ -362,57 +406,37 @@ function RPGClient_RestoreMoveMap()
|
||||
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;
|
||||
}
|
||||
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;
|
||||
RPGClient_StockMoveMapBinds();
|
||||
if (RPGClient_TextTyping())
|
||||
{
|
||||
if ($RPGClient::KeyMapPushed && isObject(RPGClient_KeyMap))
|
||||
{
|
||||
RPGClient_KeyMap.pop();
|
||||
$RPGClient::KeyMapPushed = 0;
|
||||
}
|
||||
RPGClient_ClearGlobalKeys();
|
||||
return;
|
||||
}
|
||||
RPGClient_EnsureKeyMap();
|
||||
}
|
||||
|
||||
function RPGClient_EnsureGlobalKeys()
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -451,6 +475,15 @@ function RPGClient_EnsureKeyMap()
|
||||
RPGClient_KeyMap.bind(keyboard, 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)
|
||||
{
|
||||
RPGClient_KeyMap.pop();
|
||||
@@ -501,8 +534,7 @@ function RPGClient_EnsureOverlay()
|
||||
PlayGui.add(RPGClient_Mouse);
|
||||
PlayGui.pushToBack(RPGClient_Mouse);
|
||||
}
|
||||
RPGClient_EnsureKeyMap();
|
||||
RPGClient_EnsureGlobalKeys();
|
||||
RPGClient_SyncInputStack();
|
||||
$enableDirectInput = 1;
|
||||
activateDirectInput();
|
||||
$mvFreeLook = 0;
|
||||
@@ -641,6 +673,10 @@ function RPGClient_ScheduleCamera()
|
||||
|
||||
function RPGClient_YawLeft(%val)
|
||||
{
|
||||
if (!RPGClient_CamInputAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
invLeft(%val);
|
||||
@@ -655,6 +691,10 @@ function RPGClient_YawLeft(%val)
|
||||
|
||||
function RPGClient_YawRight(%val)
|
||||
{
|
||||
if (!RPGClient_CamInputAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
invRight(%val);
|
||||
@@ -669,6 +709,10 @@ function RPGClient_YawRight(%val)
|
||||
|
||||
function RPGClient_ZoomIn(%val)
|
||||
{
|
||||
if (!RPGClient_CamInputAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
return;
|
||||
@@ -682,6 +726,10 @@ function RPGClient_ZoomIn(%val)
|
||||
|
||||
function RPGClient_ZoomOut(%val)
|
||||
{
|
||||
if (!RPGClient_CamInputAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
return;
|
||||
@@ -1032,7 +1080,7 @@ package RPGClient_Input
|
||||
{
|
||||
function moveforward(%val)
|
||||
{
|
||||
if (RPGClient_InPlay())
|
||||
if (RPGClient_CamInputAllowed())
|
||||
{
|
||||
RPGClient_KeyMvForward(%val);
|
||||
return;
|
||||
@@ -1042,7 +1090,7 @@ package RPGClient_Input
|
||||
|
||||
function movebackward(%val)
|
||||
{
|
||||
if (RPGClient_InPlay())
|
||||
if (RPGClient_CamInputAllowed())
|
||||
{
|
||||
RPGClient_KeyMvBackward(%val);
|
||||
return;
|
||||
@@ -1052,7 +1100,7 @@ package RPGClient_Input
|
||||
|
||||
function moveleft(%val)
|
||||
{
|
||||
if (RPGClient_InPlay())
|
||||
if (RPGClient_CamInputAllowed())
|
||||
{
|
||||
RPGClient_KeyMvLeft(%val);
|
||||
return;
|
||||
@@ -1062,7 +1110,7 @@ package RPGClient_Input
|
||||
|
||||
function moveright(%val)
|
||||
{
|
||||
if (RPGClient_InPlay())
|
||||
if (RPGClient_CamInputAllowed())
|
||||
{
|
||||
RPGClient_KeyMvRight(%val);
|
||||
return;
|
||||
@@ -1072,7 +1120,7 @@ package RPGClient_Input
|
||||
|
||||
function invLeft(%val)
|
||||
{
|
||||
if (RPGClient_InPlay())
|
||||
if (RPGClient_CamInputAllowed())
|
||||
{
|
||||
RPGClient_YawLeft(%val);
|
||||
return;
|
||||
@@ -1082,7 +1130,7 @@ package RPGClient_Input
|
||||
|
||||
function invRight(%val)
|
||||
{
|
||||
if (RPGClient_InPlay())
|
||||
if (RPGClient_CamInputAllowed())
|
||||
{
|
||||
RPGClient_YawRight(%val);
|
||||
return;
|
||||
@@ -1092,7 +1140,7 @@ package RPGClient_Input
|
||||
|
||||
function scrollInventory(%val)
|
||||
{
|
||||
if ($RPGClient::CamTickOn && %val != 0)
|
||||
if (RPGClient_CamInputAllowed() && %val != 0)
|
||||
{
|
||||
if (%val > 0)
|
||||
{
|
||||
@@ -1110,7 +1158,7 @@ package RPGClient_Input
|
||||
|
||||
function yaw(%val)
|
||||
{
|
||||
if ($RPGClient::CamTickOn && %val != 0)
|
||||
if (RPGClient_CamInputAllowed() && %val != 0)
|
||||
{
|
||||
%sens = $pref::Input::MouseSensitivity;
|
||||
$RPGClient::Yaw = $RPGClient::Yaw + %val * %sens * 0.004;
|
||||
@@ -1231,4 +1279,28 @@ package 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 @ ")");
|
||||
Reference in new issue
Block a user