Skip to content

Commit 2a9b144

Browse files
committed
Update project to be able to build.
Fix gitignore to build exe demo
1 parent 3075bb8 commit 2a9b144

13 files changed

+70
-70
lines changed

Source/Algorithm.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ namespace Se
66
{
77
struct ContainerRefGroup
88
{
9-
List<Element>& elements;
10-
List<Element>& elementsRestart;
11-
List<Element>& elementsReset;
9+
std::vector<Element>& elements;
10+
std::vector<Element>& elementsRestart;
11+
std::vector<Element>& elementsReset;
1212
};
1313

14-
Algorithm::Algorithm(String name) :
15-
_name(Move(name)),
14+
Algorithm::Algorithm(std::string name) :
15+
_name(std::move(name)),
1616
_sleepDelay(sf::seconds(0.01f)),
1717
_minorDelay(false),
1818
_minorDelayTimer(0),
@@ -144,7 +144,7 @@ void Algorithm::Start()
144144
{
145145
CollectSorter();
146146
_state = State::Sorting;
147-
_sorter = Thread([this]
147+
_sorter = std::thread([this]
148148
{
149149
SortThreadFn();
150150
});
@@ -230,7 +230,7 @@ void Algorithm::SoftResize(size_t size)
230230
_numberLineVA.resize(size * 4);
231231
}
232232

233-
void Algorithm::SetImage(const String& filepath)
233+
void Algorithm::SetImage(const std::string& filepath)
234234
{
235235
Reset();
236236
_image = ImageStore::Get(filepath);
@@ -244,7 +244,7 @@ void Algorithm::Shuffle(Random::Engine generator)
244244
_elements = _elementsRestart;
245245
}
246246

247-
auto Algorithm::Name() const -> const String& { return _name; }
247+
auto Algorithm::Name() const -> const std::string& { return _name; }
248248

249249
void Algorithm::SetSleepDelay(sf::Time delay)
250250
{
@@ -284,12 +284,12 @@ auto Algorithm::Elements() -> std::vector<Element>&
284284
return _elements;
285285
}
286286

287-
auto Algorithm::RestartElements() -> List<Element>&
287+
auto Algorithm::RestartElements() -> std::vector<Element>&
288288
{
289289
return _elementsRestart;
290290
}
291291

292-
auto Algorithm::ResetElements() -> List<Element>&
292+
auto Algorithm::ResetElements() -> std::vector<Element>&
293293
{
294294
return _elementsReset;
295295
}
@@ -356,7 +356,7 @@ void Algorithm::SleepDelay()
356356
}
357357
}
358358

359-
auto Algorithm::Generator() -> Function<long(size_t)>
359+
auto Algorithm::Generator() -> std::function<long(size_t)>
360360
{
361361
switch (_numberGeneratorType)
362362
{

Source/Algorithm.h

+19-19
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Algorithm
5757
};
5858

5959
public:
60-
explicit Algorithm(String name);
60+
explicit Algorithm(std::string name);
6161

6262
virtual ~Algorithm() = default;
6363

@@ -79,11 +79,11 @@ class Algorithm
7979
void Resize(size_t size);
8080
void SoftResize(size_t size);
8181

82-
void SetImage(const String& filepath);
82+
void SetImage(const std::string& filepath);
8383

8484
void Shuffle(Random::Engine generator);
8585

86-
auto Name() const -> const String&;
86+
auto Name() const -> const std::string&;
8787

8888
void SetSleepDelay(sf::Time delay);
8989
void SetVisType(VisType visType);
@@ -93,9 +93,9 @@ class Algorithm
9393
void SetPalette(Palette palette);
9494
auto PaletteImage() -> const sf::Image&;
9595

96-
auto Elements() -> List<Element>&;
97-
auto RestartElements() -> List<Element>&;
98-
auto ResetElements() -> List<Element>&;
96+
auto Elements() -> std::vector<Element>&;
97+
auto RestartElements() -> std::vector<Element>&;
98+
auto ResetElements() -> std::vector<Element>&;
9999

100100
protected:
101101
virtual void Sort() = 0;
@@ -115,7 +115,7 @@ class Algorithm
115115
void SleepDelay();
116116

117117
private:
118-
auto Generator() -> Function<long(size_t)>;
118+
auto Generator() -> std::function<long(size_t)>;
119119
auto HighestElementValue() -> long;
120120

121121
auto PixelCoord(size_t index) const -> sf::Vector2u;
@@ -141,11 +141,11 @@ class Algorithm
141141
auto VerifyElements() -> bool;
142142

143143
protected:
144-
String _name;
144+
std::string _name;
145145

146-
Thread _sorter;
146+
std::thread _sorter;
147147

148-
Shared<sf::Image> _image;
148+
std::shared_ptr<sf::Image> _image;
149149
sf::RenderTexture _imageRenderTexture;
150150

151151
sf::Time _sleepDelay;
@@ -155,35 +155,35 @@ class Algorithm
155155
State _state;
156156
bool _isActive;
157157

158-
Shared<sf::Font> _nameTextFont;
158+
std::shared_ptr<sf::Font> _nameTextFont;
159159
sf::Text _nameText;
160160
VisType _visType;
161161

162162
private:
163163
static constexpr int MaxElements = 10000;
164164
static constexpr int PaletteWidth = 2048;
165165

166-
List<Element> _elements;
167-
List<Element> _elementsRestart;
168-
List<Element> _elementsReset;
166+
std::vector<Element> _elements;
167+
std::vector<Element> _elementsRestart;
168+
std::vector<Element> _elementsReset;
169169

170170
NumberGeneratorType _numberGeneratorType = NumberGeneratorType::Linear;
171171

172172
// Shapes cache
173173
sf::VertexArray _barsVA;
174-
List<sf::CircleShape> _hoopsShapes;
174+
std::vector<sf::CircleShape> _hoopsShapes;
175175
sf::VertexArray _numberLineVA;
176-
List<sf::Text> _numberLineTextList;
176+
std::vector<sf::Text> _numberLineTextList;
177177

178178
// Palette
179179
sf::Texture _paletteTexture;
180180
Palette _desiredPalette = Palette::Rainbow;
181181
sf::Image _currentPalette;
182-
Array<TransitionColor, PaletteWidth> _colorsStart;
183-
Array<TransitionColor, PaletteWidth> _colorsCurrent;
182+
std::array<TransitionColor, PaletteWidth> _colorsStart;
183+
std::array<TransitionColor, PaletteWidth> _colorsCurrent;
184184
float _colorTransitionTimer;
185185
float _colorTransitionDuration;
186-
List<Shared<sf::Image>> _palettes;
186+
std::vector<std::shared_ptr<sf::Image>> _palettes;
187187
bool _usePalette = false;
188188
};
189189
}

Source/AlgorithmManager.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ AlgorithmManager::AlgorithmManager() :
88
_numberGeneratorTypeComboBoxNames({"Linear", "Quadratic", "Random"}),
99
_gnomeSound(SoundStore::Get("gnomed.wav", false))
1010
{
11-
Add(CreateUnique<BubbleSort>());
12-
Add(CreateUnique<SelectionSort>());
13-
Add(CreateUnique<InsertionSort>());
14-
Add(CreateUnique<GnomeSort>());
15-
Add(CreateUnique<ShellSort>());
16-
Add(CreateUnique<MergeSort>());
17-
Add(CreateUnique<HeapSort>());
18-
Add(CreateUnique<QuickSort>());
19-
Add(CreateUnique<RadixSort>());
11+
Add(std::make_unique<BubbleSort>());
12+
Add(std::make_unique<SelectionSort>());
13+
Add(std::make_unique<InsertionSort>());
14+
Add(std::make_unique<GnomeSort>());
15+
Add(std::make_unique<ShellSort>());
16+
Add(std::make_unique<MergeSort>());
17+
Add(std::make_unique<HeapSort>());
18+
Add(std::make_unique<QuickSort>());
19+
Add(std::make_unique<RadixSort>());
2020

2121
for (const auto& algorithm : _algorithms)
2222
{
@@ -209,21 +209,21 @@ void AlgorithmManager::OnViewportResize(const sf::Vector2f& size)
209209
_wantNewDrawContainers = true;
210210
}
211211

212-
void AlgorithmManager::Add(Unique<Algorithm> algorithm)
212+
void AlgorithmManager::Add(std::unique_ptr<Algorithm> algorithm)
213213
{
214-
_algorithms.emplace_back(Move(algorithm));
214+
_algorithms.emplace_back(std::move(algorithm));
215215
_algorithms.back()->Activate();
216216
}
217217

218-
void AlgorithmManager::Activate(const Unique<Algorithm>& algorithm)
218+
void AlgorithmManager::Activate(const std::unique_ptr<Algorithm>& algorithm)
219219
{
220220
algorithm->Activate();
221221
_wantNewDrawContainers = true;
222222

223223
OnAlgorithmStateChange();
224224
}
225225

226-
void AlgorithmManager::Deactivate(const Unique<Algorithm>& algorithm)
226+
void AlgorithmManager::Deactivate(const std::unique_ptr<Algorithm>& algorithm)
227227
{
228228
algorithm->Deactivate();
229229
_wantNewDrawContainers = true;
@@ -311,7 +311,7 @@ void AlgorithmManager::Shuffle()
311311
void AlgorithmManager::CustomShuffle(int degree)
312312
{
313313
_algorithms.front()->Reset();
314-
List<Element>& newElements = _algorithms.front()->RestartElements();
314+
std::vector<Element>& newElements = _algorithms.front()->RestartElements();
315315

316316
const auto degreePecentage = static_cast<float>(degree) / 100.0f;
317317
const int noElements = newElements.size();
@@ -380,7 +380,7 @@ void AlgorithmManager::SetNumberGeneratorType(Algorithm::NumberGeneratorType num
380380
}
381381
}
382382

383-
auto AlgorithmManager::Algorithms() const -> const List<Unique<Algorithm>>& { return _algorithms; }
383+
auto AlgorithmManager::Algorithms() const -> const std::vector<std::unique_ptr<Algorithm>>& { return _algorithms; }
384384

385385
void AlgorithmManager::GenerateDrawContainers(const Scene& scene)
386386
{

Source/AlgorithmManager.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class AlgorithmManager
3131
void OnGuiRender();
3232
void OnViewportResize(const sf::Vector2f& size);
3333

34-
void Add(Unique<Algorithm> algorithm);
34+
void Add(std::unique_ptr<Algorithm> algorithm);
3535

36-
void Activate(const Unique<Algorithm>& algorithm);
37-
void Deactivate(const Unique<Algorithm>& algorithm);
36+
void Activate(const std::unique_ptr<Algorithm>& algorithm);
37+
void Deactivate(const std::unique_ptr<Algorithm>& algorithm);
3838

3939
void UsePalette(bool use);
4040

@@ -57,7 +57,7 @@ class AlgorithmManager
5757
void SetPalette(Algorithm::Palette palette);
5858
void SetNumberGeneratorType(Algorithm::NumberGeneratorType numberGeneratorType);
5959

60-
auto Algorithms() const -> const List<Unique<Algorithm>>&;
60+
auto Algorithms() const -> const std::vector<std::unique_ptr<Algorithm>>&;
6161

6262
private:
6363
void GenerateDrawContainers(const Scene& scene);
@@ -67,8 +67,8 @@ class AlgorithmManager
6767
void OnAlgorithmStateChange();
6868

6969
private:
70-
List<Unique<Algorithm>> _algorithms;
71-
List<sf::FloatRect> _drawContainers;
70+
std::vector<std::unique_ptr<Algorithm>> _algorithms;
71+
std::vector<sf::FloatRect> _drawContainers;
7272

7373
// A cache used for getter
7474
Algorithm::VisType _visType;
@@ -81,17 +81,17 @@ class AlgorithmManager
8181
float _sleepDelayMicroseconds = 10000.0f;
8282
bool _usePalette = false;
8383
int _activeVisTypeIndex = static_cast<int>(Algorithm::VisType::Bars);
84-
List<const char*> _visTypeNames;
85-
List<const char*> _algorithmNames;
84+
std::vector<const char*> _visTypeNames;
85+
std::vector<const char*> _algorithmNames;
8686
int _customShuffleDegree = 10;
8787

88-
List<const char*> _paletteComboBoxNames;
88+
std::vector<const char*> _paletteComboBoxNames;
8989
int _activePaletteInt = static_cast<int>(Algorithm::Palette::Rainbow);
9090

91-
List<const char*> _numberGeneratorTypeComboBoxNames;
91+
std::vector<const char*> _numberGeneratorTypeComboBoxNames;
9292
int _numberGeneratorTypeInt = static_cast<int>(Algorithm::NumberGeneratorType::Linear);
9393

9494
bool _gnomeActive = false;
95-
Shared<sf::Sound> _gnomeSound;
95+
std::shared_ptr<sf::Sound> _gnomeSound;
9696
};
9797
}

Source/Algorithms/MergeSort.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void MergeSort::Split(size_t iStart, size_t iEnd)
2525

2626
void MergeSort::Merge(size_t iLeftStart, size_t iLeftEnd, size_t iRightStart, size_t iRightEnd)
2727
{
28-
List<long> sorted;
28+
std::vector<long> sorted;
2929

3030
size_t iCurrLeft = iLeftStart;
3131
size_t iCurrRight = iRightStart;

Source/Algorithms/RadixSort.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void RadixSort::Sort()
1515

1616
void RadixSort::CountSort(size_t exponent)
1717
{
18-
List<Element> outBucket(Elements().size());
18+
std::vector<Element> outBucket(Elements().size());
1919
std::array<size_t, 10> count = {0};
2020

2121
// Store count of occurrences in count[]

Source/Layers/BaseLayer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ BaseLayer::BaseLayer() :
88
{
99
}
1010

11-
void BaseLayer::OnAttach(Shared<Batch>& batch)
11+
void BaseLayer::OnAttach(std::shared_ptr<Batch>& batch)
1212
{
1313
_scene.ViewportPane().Resized += SE_EV_ACTION(BaseLayer::OnWantRenderTargetResize);
1414
RenderTargetManager::Add(&_controllableRenderTexture);

Source/Layers/BaseLayer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class BaseLayer : public Layer
99
public:
1010
BaseLayer();
1111

12-
void OnAttach(Shared<Batch>& batch) override;
12+
void OnAttach(std::shared_ptr<Batch>& batch) override;
1313
void OnDetach() override;
1414

1515
void OnPreFrame() override;
@@ -25,7 +25,7 @@ class BaseLayer : public Layer
2525
void OnWantRenderTargetResize(const sf::Vector2f &newSize);
2626

2727
public:
28-
EventSubscriberList<const sf::Vector2f &> RenderTargetResized;
28+
SubscriberList<const sf::Vector2f &> RenderTargetResized;
2929

3030
protected:
3131
ControllableRenderTexture _controllableRenderTexture;

Source/Layers/ProjectLayer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Se
44
{
5-
void ProjectLayer::OnAttach(Shared<Batch>& batch)
5+
void ProjectLayer::OnAttach(std::shared_ptr<Batch>& batch)
66
{
77
BaseLayer::OnAttach(batch);
88

9-
_algorithmManager = CreateShared<AlgorithmManager>();
9+
_algorithmManager = std::make_shared<AlgorithmManager>();
1010
}
1111

1212
void ProjectLayer::OnDetach()

Source/Layers/ProjectLayer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Se
99
class ProjectLayer : public BaseLayer
1010
{
1111
public:
12-
void OnAttach(Shared<Batch>& batch) override;
12+
void OnAttach(std::shared_ptr<Batch>& batch) override;
1313
void OnDetach() override;
1414

1515
void OnUpdate() override;
@@ -18,6 +18,6 @@ class ProjectLayer : public BaseLayer
1818
void OnRenderTargetResize(const sf::Vector2f& newSize) override;
1919

2020
private:
21-
Shared<AlgorithmManager> _algorithmManager;
21+
std::shared_ptr<AlgorithmManager> _algorithmManager;
2222
};
2323
}

Source/ProjectApp.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
namespace Se
55
{
6-
auto CreateApplication() -> Unique<App>
6+
auto CreateApplication() -> std::unique_ptr<App>
77
{
8-
return CreateUnique<ProjectApp>(AppProperties::CreateFullscreen("Algorithms"));
8+
return std::make_unique<ProjectApp>(AppProperties::CreateFullscreen("Algorithms"));
99
}
1010

1111
ProjectApp::ProjectApp(const AppProperties& properties) :
1212
App(properties),
13-
_projectLayer(CreateShared<ProjectLayer>())
13+
_projectLayer(std::make_shared<ProjectLayer>())
1414
{
1515
}
1616

0 commit comments

Comments
 (0)