Skip to content

Commit 91af57f

Browse files
Debug stuff (REMOVE BEFORE MERGE)
1 parent f0a8f2b commit 91af57f

4 files changed

Lines changed: 65 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: 32 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,13 @@ 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) continue;
994+
DrawCross(debugPoint.pos, debugPoint.length, debugPoint.width, debugPoint.color);
995+
}
983996
}
984997

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

libs/s25main/desktops/dskGameInterface.h

Lines changed: 17 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,15 @@ struct BuildingNote;
3031
struct KeyEvent;
3132
class NWFInfo;
3233

34+
// DEBUG REMOVE BEFORE MERGE
35+
struct DebugPoint {
36+
bool valid = false;
37+
DrawPoint pos;
38+
unsigned short length;
39+
unsigned short width;
40+
unsigned color;
41+
};
42+
3343
class dskGameInterface :
3444
public Desktop,
3545
public ClientInterface,
@@ -38,6 +48,10 @@ class dskGameInterface :
3848
public IChatCmdListener
3949
{
4050
public:
51+
// DEBUG REMOVE BEFORE MERGE
52+
static void SetDebugPoint(unsigned i, DrawPoint pos, unsigned short length, unsigned short width, unsigned color);
53+
static void ClearDebugPoints();
54+
4155
dskGameInterface(std::shared_ptr<Game> game, std::shared_ptr<const NWFInfo> nwfInfo, unsigned playerIdx,
4256
bool initOGL = true);
4357
~dskGameInterface() override;
@@ -164,4 +178,7 @@ class dskGameInterface :
164178
bool isCheatModeOn;
165179
std::string curCheatTxt;
166180
Subscription evBld;
181+
182+
// DEBUG REMOVE BEFORE MERGE
183+
static std::vector<DebugPoint> debugPoints;
167184
};

0 commit comments

Comments
 (0)