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