Fix click overlay, cursor M toggle, block fly WASD
This commit is contained in:
1 parent
8f4623a55a
commit
5140a9156e
1 file changed
+52
-26
@@ -39,6 +39,7 @@ $RPGClient::TopDownWatchSched = 0;
|
||||
$RPGClient::CamSched = 0;
|
||||
$RPGClient::LastClickTime = 0;
|
||||
$RPGClient::ChatOpen = 0;
|
||||
$RPGClient::WantCursor = 1;
|
||||
|
||||
function RPGClient_NormScreenPos(%pos)
|
||||
{
|
||||
@@ -58,7 +59,7 @@ function RPGClient_NormScreenPos(%pos)
|
||||
%h = 1;
|
||||
}
|
||||
%x = getWord(%pos, 0) / %w;
|
||||
%y = 1 - getWord(%pos, 1) / %h;
|
||||
%y = getWord(%pos, 1) / %h;
|
||||
return RPGClient_ClampNorm(%x, %y);
|
||||
}
|
||||
|
||||
@@ -244,7 +245,7 @@ function RPGClient_PickGround(%nx, %ny)
|
||||
return (%ex + getWord(%dir, 0) * %t) @ " " @ (%ey + getWord(%dir, 1) * %t) @ " " @ %refZ;
|
||||
}
|
||||
|
||||
function RPGClient_SendClick(%button, %pos)
|
||||
function RPGClient_SendClick(%button, %pos, %guiNorm)
|
||||
{
|
||||
if (!isObject(ServerConnection))
|
||||
{
|
||||
@@ -256,7 +257,7 @@ function RPGClient_SendClick(%button, %pos)
|
||||
return;
|
||||
}
|
||||
$RPGClient::LastClickTime = %now;
|
||||
%norm = RPGClient_NormScreenPos(%pos);
|
||||
%norm = %guiNorm ? RPGClient_NormPos(RPGClient_Mouse, %pos) : RPGClient_NormScreenPos(%pos);
|
||||
%nx = getWord(%norm, 0);
|
||||
%ny = getWord(%norm, 1);
|
||||
commandToServer('RPG_Click', %button, %nx, %ny, RPGClient_Aspect(), $RPGClient::Yaw, $RPGClient::Dist, $RPGClient::Pitch, $RPGClient::PanX, $RPGClient::PanY);
|
||||
@@ -276,7 +277,7 @@ function RPGClient_Mouse::onMouseDown(%this, %mod, %pos, %clicks)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RPGClient_SendClick(0, %pos);
|
||||
RPGClient_SendClick(0, %pos, 1);
|
||||
}
|
||||
|
||||
function RPGClient_Mouse::onRightMouseDown(%this, %mod, %pos, %clicks)
|
||||
@@ -285,7 +286,7 @@ function RPGClient_Mouse::onRightMouseDown(%this, %mod, %pos, %clicks)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RPGClient_SendClick(1, %pos);
|
||||
RPGClient_SendClick(1, %pos, 1);
|
||||
}
|
||||
|
||||
function RPGClient_Mouse::onWake(%this)
|
||||
@@ -339,7 +340,7 @@ function RPGClient_ViewTransform(%body, %yaw, %dist, %panX, %panY)
|
||||
|
||||
function RPGClient_EnsureCursor()
|
||||
{
|
||||
if (!$RPGClient::Active || !isObject(Canvas))
|
||||
if (!$RPGClient::Active || !isObject(Canvas) || !$RPGClient::WantCursor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -351,6 +352,15 @@ function RPGClient_EnsureCursor()
|
||||
cursorOn();
|
||||
}
|
||||
|
||||
function RPGClient_RaiseMouseOverlay()
|
||||
{
|
||||
if (!isObject(RPGClient_Mouse) || !isObject(PlayGui))
|
||||
{
|
||||
return;
|
||||
}
|
||||
PlayGui.pushToFront(RPGClient_Mouse);
|
||||
}
|
||||
|
||||
function RPGClient_NetCam()
|
||||
{
|
||||
return $RPGClient::Active && isObject(ServerConnection);
|
||||
@@ -480,8 +490,8 @@ function RPGClient_KeyMvForward(%val)
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
moveforward(%val);
|
||||
return;
|
||||
$RPGClient::CamTickOn = 1;
|
||||
RPGClient_StartCameraTick();
|
||||
}
|
||||
$RPGClient::MvF = %val;
|
||||
}
|
||||
@@ -498,8 +508,8 @@ function RPGClient_KeyMvBackward(%val)
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
movebackward(%val);
|
||||
return;
|
||||
$RPGClient::CamTickOn = 1;
|
||||
RPGClient_StartCameraTick();
|
||||
}
|
||||
$RPGClient::MvB = %val;
|
||||
}
|
||||
@@ -516,8 +526,8 @@ function RPGClient_KeyMvLeft(%val)
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
moveleft(%val);
|
||||
return;
|
||||
$RPGClient::CamTickOn = 1;
|
||||
RPGClient_StartCameraTick();
|
||||
}
|
||||
$RPGClient::MvL = %val;
|
||||
}
|
||||
@@ -534,8 +544,8 @@ function RPGClient_KeyMvRight(%val)
|
||||
}
|
||||
if (!$RPGClient::CamTickOn)
|
||||
{
|
||||
moveright(%val);
|
||||
return;
|
||||
$RPGClient::CamTickOn = 1;
|
||||
RPGClient_StartCameraTick();
|
||||
}
|
||||
$RPGClient::MvR = %val;
|
||||
}
|
||||
@@ -569,7 +579,7 @@ function RPGClient_SendClickFromCursor(%button)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RPGClient_SendClick(%button, Canvas.getCursorPos());
|
||||
RPGClient_SendClick(%button, Canvas.getCursorPos(), 0);
|
||||
}
|
||||
|
||||
function RPGClient_EnsureOverlay()
|
||||
@@ -593,8 +603,8 @@ function RPGClient_EnsureOverlay()
|
||||
modal = "0";
|
||||
};
|
||||
PlayGui.add(RPGClient_Mouse);
|
||||
PlayGui.pushToBack(RPGClient_Mouse);
|
||||
}
|
||||
RPGClient_RaiseMouseOverlay();
|
||||
if (isObject(RPGClient_Mouse) && isObject(Canvas))
|
||||
{
|
||||
%ext = Canvas.getExtent();
|
||||
@@ -608,7 +618,7 @@ function RPGClient_EnsureOverlay()
|
||||
activateDirectInput();
|
||||
$mvFreeLook = 0;
|
||||
$firstPerson = 0;
|
||||
if (isObject(Canvas) && !Canvas.isCursorOn())
|
||||
if (isObject(Canvas) && $RPGClient::WantCursor && !Canvas.isCursorOn())
|
||||
{
|
||||
Canvas.cursorOn();
|
||||
}
|
||||
@@ -630,6 +640,14 @@ function RPGClient_ToggleCursor(%val)
|
||||
return;
|
||||
}
|
||||
ToggleCursor(%val);
|
||||
if (isObject(Canvas))
|
||||
{
|
||||
$RPGClient::WantCursor = Canvas.isCursorOn();
|
||||
if ($RPGClient::WantCursor)
|
||||
{
|
||||
RPGClient_RaiseMouseOverlay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function RPGClient_DisableOverlay()
|
||||
@@ -917,6 +935,11 @@ function clientCmdRPG_Camera(%yaw, %dist, %pitch)
|
||||
{
|
||||
$RPGClient::Pitch = %pitch;
|
||||
}
|
||||
$RPGClient::PanX = 0;
|
||||
$RPGClient::PanY = 0;
|
||||
$RPGClient::CamTickOn = 1;
|
||||
RPGClient_StartCameraTick();
|
||||
RPGClient_ApplyCamera(1);
|
||||
}
|
||||
|
||||
function clientCmdRPG_TopDown(%on, %yaw, %dist)
|
||||
@@ -1146,7 +1169,7 @@ package RPGClient_Input
|
||||
{
|
||||
function moveforward(%val)
|
||||
{
|
||||
if (RPGClient_CamInputAllowed())
|
||||
if ($RPGClient::Active)
|
||||
{
|
||||
RPGClient_KeyMvForward(%val);
|
||||
return;
|
||||
@@ -1156,7 +1179,7 @@ package RPGClient_Input
|
||||
|
||||
function movebackward(%val)
|
||||
{
|
||||
if (RPGClient_CamInputAllowed())
|
||||
if ($RPGClient::Active)
|
||||
{
|
||||
RPGClient_KeyMvBackward(%val);
|
||||
return;
|
||||
@@ -1166,7 +1189,7 @@ package RPGClient_Input
|
||||
|
||||
function moveleft(%val)
|
||||
{
|
||||
if (RPGClient_CamInputAllowed())
|
||||
if ($RPGClient::Active)
|
||||
{
|
||||
RPGClient_KeyMvLeft(%val);
|
||||
return;
|
||||
@@ -1176,7 +1199,7 @@ package RPGClient_Input
|
||||
|
||||
function moveright(%val)
|
||||
{
|
||||
if (RPGClient_CamInputAllowed())
|
||||
if ($RPGClient::Active)
|
||||
{
|
||||
RPGClient_KeyMvRight(%val);
|
||||
return;
|
||||
@@ -1275,13 +1298,16 @@ activatePackage(RPGClient_MapStack);
|
||||
|
||||
package RPGClient_Cursor
|
||||
{
|
||||
function GuiCanvas::checkCursor(%this)
|
||||
function ToggleCursor(%val)
|
||||
{
|
||||
Parent::checkCursor(%this);
|
||||
if ($RPGClient::Active && !%this.isCursorOn())
|
||||
Parent::ToggleCursor(%val);
|
||||
if ($RPGClient::Active && isObject(Canvas))
|
||||
{
|
||||
lockMouse(0);
|
||||
%this.cursorOn();
|
||||
$RPGClient::WantCursor = Canvas.isCursorOn();
|
||||
if ($RPGClient::WantCursor)
|
||||
{
|
||||
RPGClient_RaiseMouseOverlay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user