Skip to content

Commit 8aa535c

Browse files
delete dead code
1 parent e20253d commit 8aa535c

10 files changed

Lines changed: 2 additions & 248 deletions

File tree

CIO/CControlContainer.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,6 @@ bool CControlContainer::delText(CFont* TextToDelete)
111111
return eraseElement(texts, TextToDelete);
112112
}
113113

114-
CPicture* CControlContainer::addPicture(void callback(int), int clickedParam, Position pos, int picture)
115-
{
116-
pos = pos + Position(border.left, border.top);
117-
118-
pictures.emplace_back(std::make_unique<CPicture>(callback, clickedParam, pos, picture));
119-
return pictures.back().get();
120-
}
121-
122114
CPicture* CControlContainer::addPicture(void callback(int), int clickedParam, Position pos, ArchiveID archive,
123115
int localIndex)
124116
{
@@ -133,17 +125,6 @@ bool CControlContainer::delPicture(CPicture* PictureToDelete)
133125
return eraseElement(pictures, PictureToDelete);
134126
}
135127

136-
int CControlContainer::addStaticPicture(Position pos, int picture)
137-
{
138-
if(picture < 0)
139-
return -1;
140-
pos = pos + Position(border.left, border.top);
141-
142-
unsigned id = static_pictures.empty() ? 0u : static_pictures.back().id + 1u;
143-
static_pictures.emplace_back(Picture{pos, ArchiveID::Io, picture, id});
144-
return id;
145-
}
146-
147128
int CControlContainer::addStaticPicture(Position pos, ArchiveID archive, int localIndex)
148129
{
149130
if(localIndex < 0)

CIO/CControlContainer.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,8 @@ class CControlContainer
8888
bool delButton(CButton* ButtonToDelete);
8989
CFont* addText(std::string string, Position pos, FontSize fontsize, FontColor color = FontColor::Yellow);
9090
bool delText(CFont* TextToDelete);
91-
CPicture* addPicture(void callback(int), int clickedParam, Position pos, int picture);
9291
CPicture* addPicture(void callback(int), int clickedParam, Position pos, ArchiveID archive, int localIndex);
9392
bool delPicture(CPicture* PictureToDelete);
94-
/// Add a static picture from the legacy flat archive.
95-
int addStaticPicture(Position pos, int picture);
96-
/// Add a static picture from a typed archive.
9793
int addStaticPicture(Position pos, ArchiveID archive, int localIndex);
9894
bool delStaticPicture(int picId);
9995
CTextfield* addTextfield(Position pos = {0, 0}, Uint16 cols = 10, Uint16 rows = 1,

CIO/CFont.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "../CSurface.h"
99
#include "../Texture.h"
1010
#include "../globals.h"
11-
#include "../include/SdlSurface.h"
1211
#include "CollisionDetection.h"
1312
#include <libsiedler2/ArchivItem_Bitmap.h>
1413
#include <libsiedler2/ArchivItem_Bitmap_Player.h>
@@ -272,19 +271,6 @@ void CFont::draw(const std::string& string, Position pos, FontSize fontsize, Fon
272271
glEnd();
273272
}
274273

275-
bool CFont::writeText(SDL_Surface* Surf_Dest, const std::string& string, unsigned x, unsigned y, FontSize fontsize,
276-
FontColor color, FontAlign align)
277-
{
278-
(void)Surf_Dest;
279-
(void)string;
280-
(void)x;
281-
(void)y;
282-
(void)fontsize;
283-
(void)color;
284-
(void)align;
285-
return true;
286-
}
287-
288274
unsigned CFont::getTextWidth(const std::string& string, FontSize fontsize)
289275
{
290276
unsigned w = 0;

CIO/CFont.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,7 @@ class CFont
6666
}
6767

6868
/// Static helper: draw text onto an SDL surface (for terrain / minimap rendering).
69-
static bool writeText(SDL_Surface* Surf_Dest, const std::string& string, unsigned x = 0, unsigned y = 0,
70-
FontSize fontsize = FontSize::Small, FontColor color = FontColor::Yellow,
71-
FontAlign align = FontAlign::Left);
72-
static bool writeText(SdlSurface& Surf_Dest, const std::string& string, Position pos,
73-
FontSize fontsize = FontSize::Small, FontColor color = FontColor::Yellow,
74-
FontAlign align = FontAlign::Left)
75-
{
76-
return writeText(Surf_Dest.get(), string, pos.x, pos.y, fontsize, color, align);
77-
}
69+
7870

7971
/// Compute the pixel width of a string without drawing it.
8072
static unsigned getTextWidth(const std::string& string, FontSize fontsize);

CIO/CPicture.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,6 @@
1010
#include <libsiedler2/Archiv.h>
1111
#include <libsiedler2/ArchivItem_Bitmap.h>
1212

13-
CPicture::CPicture(void callback(int), int clickedParam, Position pos, int picture) : pos_(pos), archive_(ArchiveID::Io)
14-
{
15-
marked = false;
16-
clicked = false;
17-
if(picture >= 0)
18-
this->picture_ = picture;
19-
else
20-
this->picture_ = 0;
21-
// Get size from the typed archive (defaults to Io)
22-
auto& archiv = global::typedArchives[ArchiveID::Io];
23-
if(auto* bmp = dynamic_cast<const libsiedler2::baseArchivItem_Bitmap*>(archiv.get(picture_)))
24-
size_ = Extent(bmp->getWidth(), bmp->getHeight());
25-
this->callback = callback;
26-
this->clickedParam = clickedParam;
27-
motionEntryParam = -1;
28-
motionLeaveParam = -1;
29-
}
30-
3113
CPicture::CPicture(void callback(int), int clickedParam, Position pos, ArchiveID archive, int picture)
3214
: pos_(pos), archive_(archive), picture_(picture >= 0 ? picture : 0)
3315
{

CIO/CPicture.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ class CPicture
2626
int motionLeaveParam;
2727

2828
public:
29-
/// Old constructor — uses int index (archive defaults to Io).
30-
CPicture(void callback(int), int clickedParam, Position pos = {0, 0}, int picture = -1);
31-
/// Typed constructor — looks up from a named archive.
3229
CPicture(void callback(int), int clickedParam, Position pos, ArchiveID archive, int picture);
3330
// Access
3431
int getX() const { return pos_.x; };

CSurface.cpp

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -82,111 +82,6 @@ static void DrawFadedTexturedTrigon(const Point16& p1, const Point16& p2, const
8282

8383
bool CSurface::drawTextures = false;
8484

85-
bool CSurface::Draw(SDL_Surface* Surf_Dest, SDL_Surface* Surf_Src, int X, int Y)
86-
{
87-
if(!Surf_Dest || !Surf_Src)
88-
return false;
89-
90-
SDL_Rect DestR;
91-
92-
DestR.x = X;
93-
DestR.y = Y;
94-
95-
SDL_BlitSurface(Surf_Src, nullptr, Surf_Dest, &DestR);
96-
97-
return true;
98-
}
99-
100-
bool CSurface::Draw(SDL_Surface* Surf_Dest, SdlSurface& Surf_Src, int X, int Y)
101-
{
102-
return Draw(Surf_Dest, Surf_Src.get(), X, Y);
103-
}
104-
105-
bool CSurface::Draw(SdlSurface& Surf_Dest, SdlSurface& Surf_Src, Position pos)
106-
{
107-
return Draw(Surf_Dest.get(), Surf_Src.get(), pos.x, pos.y);
108-
}
109-
110-
bool CSurface::Draw(SdlSurface& Surf_Dest, SDL_Surface* Surf_Src, int X, int Y)
111-
{
112-
return Draw(Surf_Dest.get(), Surf_Src, X, Y);
113-
}
114-
115-
bool CSurface::Draw(SDL_Surface* Surf_Dest, SDL_Surface* Surf_Src, Position dest, Position srcOffset, Extent srcSize)
116-
{
117-
if(!Surf_Dest || !Surf_Src)
118-
return false;
119-
120-
SDL_Rect DestR;
121-
122-
DestR.x = dest.x;
123-
DestR.y = dest.y;
124-
125-
SDL_Rect SrcR;
126-
127-
SrcR.x = srcOffset.x;
128-
SrcR.y = srcOffset.y;
129-
SrcR.w = static_cast<int>(srcSize.x);
130-
SrcR.h = static_cast<int>(srcSize.y);
131-
132-
SDL_BlitSurface(Surf_Src, &SrcR, Surf_Dest, &DestR);
133-
134-
return true;
135-
}
136-
137-
bool CSurface::Draw(SDL_Surface* Surf_Dest, SdlSurface& Surf_Src, Position dest, Position srcOffset, Extent srcSize)
138-
{
139-
return Draw(Surf_Dest, Surf_Src.get(), dest, srcOffset, srcSize);
140-
}
141-
142-
// this is the example function from the SDL-documentation to draw pixels
143-
void CSurface::DrawPixel_Color(SDL_Surface* screen, Position pos, Uint32 color)
144-
{
145-
int bpp = screen->format->BytesPerPixel;
146-
/* Here p is the address to the pixel we want to retrieve */
147-
Uint8* p = (Uint8*)screen->pixels + static_cast<int>(pos.y) * screen->pitch + static_cast<int>(pos.x) * bpp;
148-
149-
if(SDL_MUSTLOCK(screen))
150-
SDL_LockSurface(screen);
151-
152-
switch(bpp)
153-
{
154-
case 1: *p = color; break;
155-
156-
case 2: *(Uint16*)p = color; break;
157-
158-
case 3:
159-
if((SDL_BYTEORDER) == SDL_LIL_ENDIAN)
160-
{
161-
p[0] = color;
162-
p[1] = color >> 8;
163-
p[2] = color >> 16;
164-
} else
165-
{
166-
p[2] = color;
167-
p[1] = color >> 8;
168-
p[0] = color >> 16;
169-
}
170-
break;
171-
172-
case 4: *(Uint32*)p = color; break;
173-
}
174-
175-
if(SDL_MUSTLOCK(screen))
176-
SDL_UnlockSurface(screen);
177-
}
178-
179-
// this is the example function from the sdl-documentation to draw pixels
180-
void CSurface::DrawPixel_RGB(SDL_Surface* screen, Position pos, Uint8 R, Uint8 G, Uint8 B)
181-
{
182-
DrawPixel_Color(screen, pos, SDL_MapRGB(screen->format, R, G, B));
183-
}
184-
185-
void CSurface::DrawPixel_RGBA(SDL_Surface* screen, Position pos, Uint8 R, Uint8 G, Uint8 B, Uint8 A)
186-
{
187-
DrawPixel_Color(screen, pos, SDL_MapRGBA(screen->format, R, G, B, A));
188-
}
189-
19085
void CSurface::DrawTriangleField(const DisplayRectangle& displayRect, const bobMAP& myMap)
19186
{
19287
Uint16 width = myMap.width;

CSurface.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,12 @@
66
#pragma once
77

88
#include "defines.h"
9-
#include <SDL.h>
109

1110
struct vector;
1211

1312
class CSurface
1413
{
15-
friend class CDebug;
16-
1714
public:
18-
// blits from source on destination to position X,Y
19-
static bool Draw(SDL_Surface* Surf_Dest, SDL_Surface* Surf_Src, int X, int Y);
20-
static bool Draw(SDL_Surface* Surf_Dest, SdlSurface& Surf_Src, int X, int Y);
21-
static bool Draw(SdlSurface& Surf_Dest, SdlSurface& Surf_Src, Position pos = {0, 0});
22-
static bool Draw(SdlSurface& Surf_Dest, SDL_Surface* Surf_Src, int X = 0, int Y = 0);
23-
24-
// blits rectangle from source on destination
25-
static bool Draw(SDL_Surface* Surf_Dest, SDL_Surface* Surf_Src, Position dest, Position srcOffset, Extent srcSize);
26-
static bool Draw(SDL_Surface* Surf_Dest, SdlSurface& Surf_Src, Position dest, Position srcOffset, Extent srcSize);
27-
static bool Draw(SdlSurface& Surf_Dest, SdlSurface& Surf_Src, Position dest, Position srcOffset, Extent srcSize)
28-
{
29-
return Draw(Surf_Dest.get(), Surf_Src.get(), dest, srcOffset, srcSize);
30-
}
31-
// convenience overload for non-UI callers
32-
static bool Draw(SDL_Surface* Surf_Dest, SDL_Surface* Surf_Src, int X, int Y, int X2, int Y2, int W, int H)
33-
{
34-
return Draw(Surf_Dest, Surf_Src, Position(X, Y), Position(X2, Y2),
35-
Extent(static_cast<unsigned>(W), static_cast<unsigned>(H)));
36-
}
37-
static bool Draw(SDL_Surface* Surf_Dest, SdlSurface& Surf_Src, int X, int Y, int X2, int Y2, int W, int H)
38-
{
39-
return Draw(Surf_Dest, Surf_Src.get(), X, Y, X2, Y2, W, H);
40-
}
41-
static bool Draw(SdlSurface& Surf_Dest, SdlSurface& Surf_Src, int X, int Y, int X2, int Y2, int W, int H)
42-
{
43-
return Draw(Surf_Dest.get(), Surf_Src.get(), X, Y, X2, Y2, W, H);
44-
}
45-
static void DrawPixel_Color(SDL_Surface* screen, Position pos, Uint32 color);
46-
static void DrawPixel_RGB(SDL_Surface* screen, Position pos, Uint8 R, Uint8 G, Uint8 B);
47-
static void DrawPixel_RGB(SdlSurface& screen, Position pos, Uint8 R, Uint8 G, Uint8 B)
48-
{
49-
DrawPixel_RGB(screen.get(), pos, R, G, B);
50-
}
51-
static void DrawPixel_RGBA(SDL_Surface* screen, Position pos, Uint8 R, Uint8 G, Uint8 B, Uint8 A);
52-
5315
/// Render terrain into the current GL framebuffer.
5416
/// displayRect specifies the visible area in map-pixel coordinates.
5517
static void DrawTriangleField(const DisplayRectangle& displayRect, const bobMAP& myMap);

include/SdlSurface.h

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,14 @@
1-
// Copyright (C) 2009 - 2021 Marc Vester (XaserLE)
2-
// Copyright (C) 2009 - 2021 Settlers Freaks <sf-team at siedler25.org>
1+
// Copyright (C) 2009 - 2025 Settlers Freaks <sf-team at siedler25.org>
32
//
43
// SPDX-License-Identifier: GPL-3.0-or-later
54

65
#pragma once
76

87
#include <SDL.h>
9-
#include <array>
108
#include <memory>
119

12-
struct SdlSurfaceDeleter
13-
{
14-
void operator()(SDL_Surface* p) { SDL_FreeSurface(p); }
15-
};
16-
struct SdlTextureDeleter
17-
{
18-
void operator()(SDL_Texture* p) { SDL_DestroyTexture(p); }
19-
};
2010
struct SDLWindowDestroyer
2111
{
2212
void operator()(SDL_Window* p) const { SDL_DestroyWindow(p); }
2313
};
24-
struct SDLRendererDestroyer
25-
{
26-
void operator()(SDL_Renderer* p) const { SDL_DestroyRenderer(p); }
27-
};
28-
29-
using SdlRenderer = std::unique_ptr<SDL_Renderer, SDLRendererDestroyer>;
3014
using SdlWindow = std::unique_ptr<SDL_Window, SDLWindowDestroyer>;
31-
using SdlSurface = std::unique_ptr<SDL_Surface, SdlSurfaceDeleter>;
32-
using SdlTexture = std::unique_ptr<SDL_Texture, SdlTextureDeleter>;
33-
34-
inline SdlSurface makeRGBSurface(unsigned width, unsigned height, bool withAlpha = false)
35-
{
36-
return SdlSurface(SDL_CreateRGBSurface(0, static_cast<int>(width), static_cast<int>(height), 32, 0xFF0000, 0xFF00,
37-
0xFF, withAlpha ? 0xFF000000 : 0));
38-
}
39-
inline SdlSurface makePalSurface(unsigned width, unsigned height, const std::array<SDL_Color, 256>& palette)
40-
{
41-
auto surf = SdlSurface(SDL_CreateRGBSurface(0, static_cast<int>(width), static_cast<int>(height), 8, 0, 0, 0, 0));
42-
if(surf)
43-
SDL_SetPaletteColors(surf->format->palette, palette.data(), 0, palette.size());
44-
return surf;
45-
}
46-
47-
inline SdlTexture makeSdlTexture(const SdlRenderer& renderer, Uint32 format, int access, int w, int h)
48-
{
49-
return SdlTexture(SDL_CreateTexture(renderer.get(), format, access, w, h));
50-
}

include/defines.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "Point.h"
99
#include "Rect.h"
10-
#include "SdlSurface.h"
1110
#include "gameData/DescIdx.h"
1211
#include <SDL.h>
1312
#include <array>

0 commit comments

Comments
 (0)