Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Core/GameEngine/Include/GameClient/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ class View : public Snapshot

Bool worldToScreen( const Coord3D *w, ICoord2D *s ) { return worldToScreenTriReturn( w, s ) == WTS_INSIDE_FRUSTUM; } ///< Transform world coordinate "w" into screen coordinate "s"
virtual WorldToScreenReturn worldToScreenTriReturn(const Coord3D *w, ICoord2D *s ) = 0; ///< Like worldToScreen(), but with a more informative return value
/// Like worldToScreenTriReturn(), but a point beyond the far clip plane still projects instead of
/// returning WTS_INVALID, so an off-screen indicator can still be placed for it. Such a point is
/// reported as WTS_OUTSIDE_FRUSTUM even when its x/y land on screen.
virtual WorldToScreenReturn worldToScreenTriReturnAllowFarClip(const Coord3D *w, ICoord2D *s ) { return worldToScreenTriReturn( w, s ); }

/// Transform screen point to the viewed world position on the 3D terrain. Returns true when intersection exists.
virtual Bool screenToTerrain( const ICoord2D *screen, Coord3D *world ) = 0;
Expand Down
18 changes: 18 additions & 0 deletions Core/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "GameClient/GameClient.h"
#include "GameClient/GameWindowManager.h"
#include "GameClient/GameText.h"
#include "GameClient/Keyboard.h"
#include "GameClient/ParticleSys.h"
#include "GameClient/GUICallbacks.h"
#include "GameClient/Shell.h"
Expand Down Expand Up @@ -89,6 +90,9 @@
#include "GameNetwork/GameInfo.h"
#include "GameNetwork/GameSpyOverlay.h"
#include "GameNetwork/GameSpy/BuddyThread.h"
#if defined(GENERALS_ONLINE)
#include "GameNetwork/GeneralsOnline/Plugins/PluginManager.h"
#endif

#include "WW3D2/ww3d.h"
#include "../OnlineServices_Init.h"
Expand Down Expand Up @@ -3934,6 +3938,20 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
disp = DESTROY_MESSAGE;
}

// Forwarded even when the engine already handled this key; plugin hotkeys are the
// plugin's own choice and are not expected to collide with F11/F10/F5/INS.
if (GOPluginManager::HasRenderHooks())
{
uint32_t modifierFlags = 0;
if (TheKeyboard != nullptr)
{
if (TheKeyboard->isCtrl()) modifierFlags |= 1;
if (TheKeyboard->isShift()) modifierFlags |= 2;
if (TheKeyboard->isAlt()) modifierFlags |= 4;
}
GOPluginManager::DispatchRawKeyUp((uint32_t)key, modifierFlags);
}

break;
}
#endif
Expand Down
70 changes: 70 additions & 0 deletions Core/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
#include "GameClient/WindowXlat.h"
#include "GameClient/Shell.h"
#include "GameClient/Display.h"
#include "GameClient/Keyboard.h"
#if defined(GENERALS_ONLINE)
#include "GameNetwork/GeneralsOnline/Plugins/PluginManager.h"
#endif


// DEFINES ////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -172,6 +176,72 @@ GameMessageDisposition WindowTranslator::translateGameMessage(const GameMessage
Bool forceKeepMessage = FALSE;
WinInputReturnCode returnCode = WIN_INPUT_NOT_USED;

#if defined(GENERALS_ONLINE)
// Deliberately ahead of the mouse-lock early return below.
if (GOPluginManager::HasRenderHooks())
{
// buttonIndex stays -1 for anything that is not a click.
Int buttonIndex = -1;
Bool buttonDown = FALSE;
Bool isMouseMove = FALSE;
switch (msg->getType())
{
case GameMessage::MSG_RAW_MOUSE_POSITION:
isMouseMove = TRUE;
break;
case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN:
case GameMessage::MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK:
buttonIndex = 0; buttonDown = TRUE;
break;
case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP:
buttonIndex = 0;
break;
case GameMessage::MSG_RAW_MOUSE_MIDDLE_BUTTON_DOWN:
case GameMessage::MSG_RAW_MOUSE_MIDDLE_DOUBLE_CLICK:
buttonIndex = 1; buttonDown = TRUE;
break;
case GameMessage::MSG_RAW_MOUSE_MIDDLE_BUTTON_UP:
buttonIndex = 1;
break;
case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN:
case GameMessage::MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK:
buttonIndex = 2; buttonDown = TRUE;
break;
case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP:
buttonIndex = 2;
break;
default:
break;
}

// Only the messages above carry a cursor position in argument 0.
if (isMouseMove || buttonIndex >= 0)
{
const ICoord2D& pos = msg->getArgument(0)->pixel;
if (isMouseMove)
{
GOPluginManager::DispatchMouseMove((int32_t)pos.x, (int32_t)pos.y);
}
else
{
// Bit order as documented by GORenderCallbacks.
uint32_t modifierFlags = 0;
if (TheKeyboard != nullptr)
{
if (TheKeyboard->isCtrl()) modifierFlags |= 1;
if (TheKeyboard->isShift()) modifierFlags |= 2;
if (TheKeyboard->isAlt()) modifierFlags |= 4;
}

if (buttonDown)
GOPluginManager::DispatchMouseButtonDown((uint8_t)buttonIndex, (int32_t)pos.x, (int32_t)pos.y, modifierFlags);
else
GOPluginManager::DispatchMouseButtonUp((uint8_t)buttonIndex, (int32_t)pos.x, (int32_t)pos.y, modifierFlags);
}
}
}
#endif

if (TheTacticalView && TheTacticalView->isMouseLocked())
{
//Kris: Aug 15, 2003
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class W3DView : public View, public SubsystemInterface
virtual void setFieldOfView( Real angle ) override; ///< Set the horizontal field of view angle

virtual WorldToScreenReturn worldToScreenTriReturn( const Coord3D *w, ICoord2D *s ) override; ///< Transform world coordinate "w" into screen coordinate "s"
virtual WorldToScreenReturn worldToScreenTriReturnAllowFarClip( const Coord3D *w, ICoord2D *s ) override; ///< As above, but a point beyond the far clip plane still projects
virtual Bool screenToTerrain( const ICoord2D *screen, Coord3D *world ) override;
virtual PlaneClass::IntersectionResType screenToWorldAtZ( const ICoord2D *screen, Coord3D *world, Real z ) override;

Expand Down
35 changes: 35 additions & 0 deletions Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,41 @@ View::WorldToScreenReturn W3DView::worldToScreenTriReturn( const Coord3D *w, ICo
return WTS_INVALID;
}

//-------------------------------------------------------------------------------------------------
/** As worldToScreenTriReturn, but a point beyond the far clip plane still yields a usable screen
position. CameraClass::Project only zeroes its output for OUTSIDE_NEAR_CLIP; past the far plane
it has already written the perspective-divided position before it returns. */
//-------------------------------------------------------------------------------------------------
View::WorldToScreenReturn W3DView::worldToScreenTriReturnAllowFarClip( const Coord3D *w, ICoord2D *s )
{
// sanity
if( w == nullptr || s == nullptr || m_3DCamera == nullptr )
return WTS_INVALID;

Vector3 world;
Vector3 screen;

world.Set( w->x, w->y, w->z );
enum CameraClass::ProjectionResType projection = m_3DCamera->Project( screen, world );
if( projection == CameraClass::OUTSIDE_NEAR_CLIP )
{
s->x = 0;
s->y = 0;
return WTS_INVALID;
}

W3DLogicalScreenToPixelScreen( screen.X, screen.Y,
&s->x, &s->y,
getWidth(), getHeight());
s->x += m_originX; //convert viewport coordinates to full screen coordinates
s->y += m_originY;

if( projection != CameraClass::INSIDE_FRUSTUM )
return WTS_OUTSIDE_FRUSTUM;

return WTS_INSIDE_FRUSTUM;
}

//-------------------------------------------------------------------------------------------------
/** all the drawables in the view, that fall within the 2D screen region
* will call the callback function. The number of drawables that passed
Expand Down
3 changes: 3 additions & 0 deletions GeneralsMD/Code/GameEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,8 @@ set(GAMEENGINE_SRC
Include/GameNetwork/GeneralsOnline/HTTP/HTTPRequest.h
Include/GameNetwork/GeneralsOnline/NextGenTransport.h
Include/GameNetwork/GeneralsOnline/PluginInterfaces.h
Include/GameNetwork/GeneralsOnline/Plugins/PluginABI.h
Include/GameNetwork/GeneralsOnline/Plugins/PluginManager.h
Include/GameNetwork/GeneralsOnline/Vendor/ValveNetworkingSockets/steam/isteamnetworkingmessages.h
Include/GameNetwork/GeneralsOnline/Vendor/ValveNetworkingSockets/steam/isteamnetworkingsockets.h
Include/GameNetwork/GeneralsOnline/Vendor/ValveNetworkingSockets/steam/isteamnetworkingutils.h
Expand Down Expand Up @@ -1202,6 +1204,7 @@ set(GAMEENGINE_SRC
Source/GameNetwork/GeneralsOnline/NextGenTransport.cpp
Source/GameNetwork/GeneralsOnline/NetworkBitstream.cpp
Source/GameNetwork/GeneralsOnline/PluginInterfaces.cpp
Source/GameNetwork/GeneralsOnline/Plugins/PluginManager.cpp
)

if(RTS_GAMEMEMORY_ENABLE)
Expand Down
6 changes: 6 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,12 @@ class InGameUI : public SubsystemInterface, public Snapshot
virtual void postDraw(); ///< Logic which needs to occur after the UI renders
virtual void postWindowDraw(); ///< Logic which needs to occur after the WindowManager has repainted the menus

// Text primitives backing GOPluginHostAPI (see PluginABI.h); here rather than in the plugin
// framework because they need the message font members below. Only ever called from within
// DispatchDrawOverlay(), i.e. during postWindowDraw() where 2D drawing is already set up.
void drawPluginText2D(Int x, Int y, const char* asciiText, Color color);
void drawPluginText2DScaled(Int x, Int y, const char* asciiText, Color color, Real sizeScale, Bool bold);

/// Ingame video playback
virtual void playMovie(const AsciiString& movieName);
virtual void stopMovie();
Expand Down
Loading