Skip to content

Commit 2a5b03c

Browse files
Debug stuff (REMOVE BEFORE MERGE)
1 parent f0a8f2b commit 2a5b03c

4 files changed

Lines changed: 68 additions & 0 deletions

File tree

libs/s25main/Window.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,20 @@ void Window::DrawLine(DrawPoint pt1, DrawPoint pt2, unsigned short width, unsign
491491
VIDEODRIVER.GetRenderer()->DrawLine(pt1, pt2, width, color);
492492
}
493493

494+
// DEBUG REMOVE BEFORE MERGE
495+
void Window::DrawCross(DrawPoint pt, unsigned short length, unsigned short width, unsigned color)
496+
{
497+
auto* renderer = VIDEODRIVER.GetRenderer();
498+
499+
DrawPoint pt1 = pt - DrawPoint(-length, length);
500+
DrawPoint pt2 = pt - DrawPoint(length, -length);
501+
DrawPoint pt3 = pt - DrawPoint(length, length);
502+
DrawPoint pt4 = pt - DrawPoint(-length, -length);
503+
504+
renderer->DrawLine(pt1, pt2, width, color);
505+
renderer->DrawLine(pt3, pt4, width, color);
506+
}
507+
494508
void Window::Msg_PaintBefore()
495509
{
496510
animations_.update(VIDEODRIVER.GetTickCount());

libs/s25main/Window.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ class Window
201201
static void DrawRectangle(const Rect& rect, unsigned color);
202202
/// Zeichnet eine Linie
203203
static void DrawLine(DrawPoint pt1, DrawPoint pt2, unsigned short width, unsigned color);
204+
// DEBUG REMOVE BEFORE MERGE
205+
static void DrawCross(DrawPoint pt, unsigned short length, unsigned short width, unsigned color);
204206

205207
// GUI-Notify-Messages
206208

libs/s25main/desktops/dskGameInterface.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "dskGameInterface.h"
66
#include "CollisionDetection.h"
7+
#include "DrawPoint.h"
78
#include "EventManager.h"
89
#include "Game.h"
910
#include "GamePlayer.h"
@@ -82,6 +83,7 @@
8283
#include "gameData/TerrainDesc.h"
8384
#include "gameData/const_gui_ids.h"
8485
#include "liblobby/LobbyClient.h"
86+
#include "s25util/colors.h"
8587
#include <algorithm>
8688
#include <cstdio>
8789
#include <utility>
@@ -668,6 +670,10 @@ bool dskGameInterface::Msg_LeftDown(const MouseCoords& mc)
668670
actionwindow->Close();
669671
VIDEODRIVER.SetMousePos(mc.GetPos());
670672

673+
// DEBUG REMOVE BEFORE MERGE
674+
ClearDebugPoints();
675+
SetDebugPoint(0, mc.GetPos(), 8, 4, MakeColor(255, 0, 255, 255));
676+
671677
ShowActionWindow(action_tabs, cSel, mc.GetPos(), enable_military_buildings);
672678
}
673679

@@ -980,6 +986,14 @@ void dskGameInterface::Run()
980986
}
981987

982988
messenger.Draw();
989+
990+
// DEBUG REMOVE BEFORE MERGE
991+
for(const auto& debugPoint : debugPoints)
992+
{
993+
if(!debugPoint.valid)
994+
continue;
995+
DrawCross(debugPoint.pos, debugPoint.length, debugPoint.width, debugPoint.color);
996+
}
983997
}
984998

985999
void dskGameInterface::GI_StartRoadBuilding(const MapPoint startPt, bool waterRoad)
@@ -1391,3 +1405,23 @@ void dskGameInterface::GI_TeamWinner(const unsigned playerMask)
13911405
messenger.AddMessage("", 0, ChatDestination::System, text, COLOR_ORANGE);
13921406
WINDOWMANAGER.Show(std::make_unique<iwVictory>(winners));
13931407
}
1408+
1409+
// DEBUG REMOVE BEFORE MERGE
1410+
void dskGameInterface::SetDebugPoint(unsigned i, DrawPoint pos, unsigned short length, unsigned short width,
1411+
unsigned color)
1412+
{
1413+
unsigned minSize = i + 1;
1414+
if(debugPoints.size() < minSize)
1415+
debugPoints.resize(minSize);
1416+
1417+
debugPoints[i] = {true, pos, length, width, color};
1418+
}
1419+
1420+
// DEBUG REMOVE BEFORE MERGE
1421+
void dskGameInterface::ClearDebugPoints()
1422+
{
1423+
debugPoints.clear();
1424+
}
1425+
1426+
// DEBUG REMOVE BEFORE MERGE
1427+
std::vector<DebugPoint> dskGameInterface::debugPoints;

libs/s25main/desktops/dskGameInterface.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include "Desktop.h"
8+
#include "DrawPoint.h"
89
#include "GameInterface.h"
910
#include "IngameMinimap.h"
1011
#include "Messenger.h"
@@ -30,6 +31,16 @@ struct BuildingNote;
3031
struct KeyEvent;
3132
class NWFInfo;
3233

34+
// DEBUG REMOVE BEFORE MERGE
35+
struct DebugPoint
36+
{
37+
bool valid = false;
38+
DrawPoint pos;
39+
unsigned short length;
40+
unsigned short width;
41+
unsigned color;
42+
};
43+
3344
class dskGameInterface :
3445
public Desktop,
3546
public ClientInterface,
@@ -38,6 +49,10 @@ class dskGameInterface :
3849
public IChatCmdListener
3950
{
4051
public:
52+
// DEBUG REMOVE BEFORE MERGE
53+
static void SetDebugPoint(unsigned i, DrawPoint pos, unsigned short length, unsigned short width, unsigned color);
54+
static void ClearDebugPoints();
55+
4156
dskGameInterface(std::shared_ptr<Game> game, std::shared_ptr<const NWFInfo> nwfInfo, unsigned playerIdx,
4257
bool initOGL = true);
4358
~dskGameInterface() override;
@@ -164,4 +179,7 @@ class dskGameInterface :
164179
bool isCheatModeOn;
165180
std::string curCheatTxt;
166181
Subscription evBld;
182+
183+
// DEBUG REMOVE BEFORE MERGE
184+
static std::vector<DebugPoint> debugPoints;
167185
};

0 commit comments

Comments
 (0)