Skip to content

Commit 2eccadf

Browse files
committed
Minor changes
Tested on another project, finded bugs, fixed part with new project settings
1 parent 5b918a8 commit 2eccadf

File tree

10 files changed

+60
-29
lines changed

10 files changed

+60
-29
lines changed

src/GUI/baseGUI.hpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,6 @@ namespace GUI {
4242
};
4343

4444

45-
// Class of slider bar with point on it to control need parameter
46-
class Slider : public TextureTemplate {
47-
private:
48-
SDL_Texture *textureButton; // Texture of line (upper part of slider)
49-
SDL_FRect buttonRect; // Place for rendering upper part
50-
const unsigned maxValue; // Maximal value of state
51-
52-
public:
53-
// Create slide with need line and button images
54-
Slider(const Window& window, float X, float Y, float width, unsigned startValue,
55-
Textures lineImage = Textures::SliderLine, Textures buttonImage = Textures::SliderButton, unsigned max = 255);
56-
unsigned setValue(float mouseX); // Setting new state from mouse position
57-
unsigned scroll(float wheelY); // Checking mouse wheel action
58-
void blit() const override; // Drawing slider with need button position
59-
};
60-
61-
6245
// Class of rounded backplate for better understability
6346
class RoundedBackplate : public TextureTemplate {
6447
public:
@@ -83,6 +66,23 @@ namespace GUI {
8366

8467
// Textures
8568
#if (USE_SDL_IMAGE) && (PRELOAD_TEXTURES)
69+
// Class of slider bar with point on it to control need parameter
70+
class Slider : public TextureTemplate {
71+
private:
72+
SDL_Texture *textureButton; // Texture of line (upper part of slider)
73+
SDL_FRect buttonRect; // Place for rendering upper part
74+
const unsigned maxValue; // Maximal value of state
75+
76+
public:
77+
// Create slide with need line and button images
78+
Slider(const Window& window, float X, float Y, float width, unsigned startValue,
79+
Textures lineImage = Textures::SliderLine, Textures buttonImage = Textures::SliderButton, unsigned max = 255);
80+
unsigned setValue(float mouseX); // Setting new state from mouse position
81+
unsigned scroll(float wheelY); // Checking mouse wheel action
82+
void blit() const override; // Drawing slider with need button position
83+
};
84+
85+
8686
// Class of buttons with image on it
8787
class ImageButton : public TextureTemplate {
8888
public:

src/GUI/slider.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "baseGUI.hpp"
77

88

9+
#if (USE_SDL_IMAGE) && (PRELOAD_TEXTURES)
10+
911
GUI::Slider::Slider(const Window& _window, float _X, float _Y, float _width, unsigned _startValue,
1012
Textures _lineImage, Textures _buttonImage, unsigned _max)
1113
: TextureTemplate(_window),
@@ -52,3 +54,5 @@ unsigned GUI::Slider::scroll(float _wheelY) {
5254
}
5355
return 0;
5456
}
57+
58+
#endif // (USE_SDL_IMAGE) && (PRELOAD_TEXTURES)

src/data/initFile.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
// Check if has initfile
1414
#if USE_SETTING_FILE
15+
#include <string>
16+
1517

1618
// Class for load/save settings to/from game
1719
class InitFile {

src/data/libraries.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
* <nik.kazankov.05@mail.ru>
44
*/
55

6+
#include "libraries.hpp"
7+
// External libraries for initialisation
68
#include <SDL3/SDL.h>
7-
#include <SDL3_mixer/SDL_mixer.h>
9+
#if (USE_SDL_FONT)
810
#include <SDL3_ttf/SDL_ttf.h>
9-
#include "libraries.hpp"
11+
#endif
12+
#if (USE_SDL_MIXER)
13+
#include <SDL3_mixer/SDL_mixer.h>
14+
#endif
15+
#if (CHECK_CORRECTION)
1016
#include "exceptions.hpp"
17+
#endif
1118

1219

1320
Libraries::Libraries() {
@@ -18,13 +25,13 @@ Libraries::Libraries() {
1825
throw LibararyLoadException("Main library: " + std::string(SDL_GetError()));
1926
}
2027
// Initialasing font library
21-
#if USE_SDL_FONT
28+
#if (USE_SDL_FONT)
2229
if (!TTF_Init()) {
2330
throw LibararyLoadException("Font library: " + std::string(SDL_GetError()));
2431
}
2532
#endif
2633
// Initialasing audio library
27-
#if USE_SDL_MIXER
34+
#if (USE_SDL_MIXER)
2835
if (!Mix_Init(MIX_INIT_MP3 | MIX_INIT_WAVPACK)) {
2936
throw LibararyLoadException("Mixer library: " + std::string(SDL_GetError()));
3037
}
@@ -41,10 +48,10 @@ Libraries::Libraries() {
4148
logAdditional("Libraries load correctly");
4249
#else // (CHECK_CORRECTION)
4350
SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO);
44-
#if USE_SDL_FONT
51+
#if (USE_SDL_FONT)
4552
TTF_Init();
4653
#endif
47-
#if USE_SDL_MIXER
54+
#if (USE_SDL_MIXER)
4855
Mix_Init(MIX_INIT_MP3 | MIX_INIT_WAVPACK);
4956
audioDeviceID = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, NULL);
5057
Mix_OpenAudio(audioDeviceID, NULL);
@@ -54,16 +61,16 @@ Libraries::Libraries() {
5461

5562
Libraries::~Libraries() noexcept {
5663
// Closing audio device
57-
#if USE_SDL_MIXER
64+
#if (USE_SDL_MIXER)
5865
Mix_CloseAudio();
5966
SDL_CloseAudioDevice(audioDeviceID);
6067
#endif
6168

6269
// Closing all library reversed
63-
#if USE_SDL_MIXER
70+
#if (USE_SDL_MIXER)
6471
Mix_CloseAudio();
6572
#endif
66-
#if USE_SDL_FONT
73+
#if (USE_SDL_FONT)
6774
TTF_Quit();
6875
#endif
6976
SDL_Quit();

src/data/libraries.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55

66
#pragma once
77

8+
#include "../define.hpp"
9+
// Check, if use audio in project
10+
#if (USE_SDL_MIXER)
811
#include <SDL3/SDL_audio.h>
12+
#endif
913

1014

1115
// Class for load and close needed libraries
1216
class Libraries {
1317
private:
18+
#if (USE_SDL_MIXER)
1419
SDL_AudioDeviceID audioDeviceID = 0;
20+
#endif
1521

1622
public:
1723
Libraries();

src/data/preloaded/textures.hpp

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

1010
// Check, if can load images and preload it
1111
#if (USE_SDL_IMAGE) && (PRELOAD_TEXTURES)
12-
1312
#include <SDL3/SDL_render.h>
1413

1514

src/data/window.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#pragma once
77

8+
#include <SDL3/SDL_render.h>
89
#include "colors.hpp"
910
#include "time.hpp"
1011
#include "preloaded/textures.hpp"
@@ -97,8 +98,19 @@ class Window {
9798
SDL_Texture* createTexture(TTF_Font* font, const char* text, Color color) const;
9899
#endif
99100

101+
// Draw raw text without TTF library
102+
template <typename ...Args>
103+
void drawDebugText(float X, float Y, const char* text, const Args& ...args) const;
104+
100105
// Work with window
101106
void startTextInput() const;
102107
void stopTextInput() const;
103108
void updateTitle() const;
104109
};
110+
111+
112+
// Temlates realisation
113+
template <typename ...Args>
114+
void Window::drawDebugText(float _X, float _Y, const char* _text, const Args& ..._args) const {
115+
SDL_RenderDebugTextFormat(renderer, _X, _Y, _text, _args...);
116+
}

src/internet/indexesArray.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include "indexesArray.hpp"
7+
#include "../data/logger.hpp"
78

89

910
template <unsigned length>

src/internet/indexesArray.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#pragma once
77

8-
#include "connection.hpp"
8+
#include <SDL3/SDL_stdinc.h>
99

1010

1111
// Class for work with indexes of last get message

src/testing.hpp

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

88
// File for setting flags for all test for program
99
// Debuging modifiers
10-
#define DEBUG true
10+
#define DEBUG false
1111
// Logging important information
1212
#define CHECK_CORRECTION DEBUG
1313
// Logging all actions (including minor)

0 commit comments

Comments
 (0)