Skip to content

Commit 2b6c729

Browse files
authored
feat(headless): Implement ViewDummy (#2246)
1 parent dd894c2 commit 2b6c729

7 files changed

Lines changed: 55 additions & 10 deletions

File tree

Core/GameEngine/Include/GameClient/View.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,5 +376,40 @@ class ViewLocation
376376
}
377377
};
378378

379+
// TheSuperHackers @feature bobtista 31/01/2026
380+
// View that does nothing. Used for Headless Mode.
381+
class ViewDummy : public View
382+
{
383+
public:
384+
virtual Drawable *pickDrawable( const ICoord2D *screen, Bool forceAttack, PickType pickType ) override
385+
{
386+
return nullptr;
387+
}
388+
virtual Int iterateDrawablesInRegion( IRegion2D *screenRegion, Bool (*callback)( Drawable *draw, void *userData ), void *userData ) override
389+
{
390+
return 0;
391+
}
392+
virtual void forceRedraw() override {}
393+
virtual const Coord3D& get3DCameraPosition() const override
394+
{
395+
static Coord3D zero = {0,0,0};
396+
return zero;
397+
}
398+
virtual WorldToScreenReturn worldToScreenTriReturn(const Coord3D *w, ICoord2D *s ) override
399+
{
400+
return WTS_INVALID;
401+
}
402+
virtual void screenToTerrain( const ICoord2D *screen, Coord3D *world ) override {}
403+
virtual void screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z ) override {}
404+
virtual void drawView( void ) override {}
405+
virtual void updateView(void) override {}
406+
virtual void stepView() override {}
407+
virtual void setGuardBandBias( const Coord2D *gb ) override {}
408+
virtual Bool isDoingScriptedCamera() override { return false; }
409+
virtual void stopDoingScriptedCamera() override {}
410+
411+
// Do not override View::xfer(). The base implementation must run to serialize valid view state for save file compatibility.
412+
};
413+
379414
// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
380415
extern View *TheTacticalView; ///< the main tactical interface to the game world

Generals/Code/GameEngine/Include/GameClient/InGameUI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ friend class Drawable; // for selection/deselection transactions
669669

670670
void incrementSelectCount() { ++m_selectCount; } ///< Increase by one the running total of "selected" drawables
671671
void decrementSelectCount() { --m_selectCount; } ///< Decrease by one the running total of "selected" drawables
672-
virtual View *createView() = 0; ///< Factory for Views
672+
virtual View *createView(bool dummy = false) = 0; ///< Factory for Views
673673
void evaluateSoloNexus( Drawable *newlyAddedDrawable = nullptr );
674674

675675
/// expire a hint from of the specified type at the hint index

Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,17 +1337,17 @@ void InGameUI::init()
13371337
been moved to where all the other translators are attached in game client */
13381338

13391339
// create the tactical view
1340-
if (TheDisplay)
1340+
TheTacticalView = createView(TheGlobalData->m_headless);
1341+
if (TheTacticalView && TheDisplay)
13411342
{
1342-
TheTacticalView = createView();
13431343
TheTacticalView->init();
13441344
TheDisplay->attachView( TheTacticalView );
13451345

13461346
// make the tactical display the full screen width and height
13471347
TheTacticalView->setWidth( TheDisplay->getWidth() );
13481348
TheTacticalView->setHeight( TheDisplay->getHeight() );
1349+
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
13491350
}
1350-
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
13511351

13521352
/** @todo this may be the wrong place to create the sidebar, but for now
13531353
this is where it lives */

Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ class W3DInGameUI : public InGameUI
6969
protected:
7070

7171
/// factory for views
72-
virtual View *createView() { return NEW W3DView; }
72+
virtual View *createView(bool dummy)
73+
{
74+
if (dummy)
75+
return NEW ViewDummy;
76+
return NEW W3DView;
77+
}
7378

7479
virtual void drawSelectionRegion(); ///< draw the selection region on screen
7580
virtual void drawMoveHints( View *view ); ///< draw move hint visual feedback

GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ friend class Drawable; // for selection/deselection transactions
689689

690690
void incrementSelectCount() { ++m_selectCount; } ///< Increase by one the running total of "selected" drawables
691691
void decrementSelectCount() { --m_selectCount; } ///< Decrease by one the running total of "selected" drawables
692-
virtual View *createView() = 0; ///< Factory for Views
692+
virtual View *createView(bool dummy = false) = 0; ///< Factory for Views
693693
void evaluateSoloNexus( Drawable *newlyAddedDrawable = nullptr );
694694

695695
/// expire a hint from of the specified type at the hint index

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,17 +1367,17 @@ void InGameUI::init()
13671367
been moved to where all the other translators are attached in game client */
13681368

13691369
// create the tactical view
1370-
if (TheDisplay)
1370+
TheTacticalView = createView(TheGlobalData->m_headless);
1371+
if (TheTacticalView && TheDisplay)
13711372
{
1372-
TheTacticalView = createView();
13731373
TheTacticalView->init();
13741374
TheDisplay->attachView( TheTacticalView );
13751375

13761376
// make the tactical display the full screen width and height
13771377
TheTacticalView->setWidth( TheDisplay->getWidth() );
13781378
TheTacticalView->setHeight( TheDisplay->getHeight() );
1379+
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
13791380
}
1380-
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
13811381

13821382
/** @todo this may be the wrong place to create the sidebar, but for now
13831383
this is where it lives */

GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ class W3DInGameUI : public InGameUI
6969
protected:
7070

7171
/// factory for views
72-
virtual View *createView() { return NEW W3DView; }
72+
virtual View *createView(bool dummy)
73+
{
74+
if (dummy)
75+
return NEW ViewDummy;
76+
return NEW W3DView;
77+
}
7378

7479
virtual void drawSelectionRegion(); ///< draw the selection region on screen
7580
virtual void drawMoveHints( View *view ); ///< draw move hint visual feedback

0 commit comments

Comments
 (0)