diff --git a/MAGE/FPS/src/core/FPS.cpp b/MAGE/FPS/src/core/FPS.cpp
index fcf9c4d13..59310574f 100644
--- a/MAGE/FPS/src/core/FPS.cpp
+++ b/MAGE/FPS/src/core/FPS.cpp
@@ -77,7 +77,7 @@ class TestScene final : public Scene {
// Font
SharedPtr< SpriteFont > font = CreateFont(L"assets/fonts/calibri.spritefont", SpriteFontDescriptor());
// Text
- SharedPtr< SpriteText > text(new SpriteText("text", L"Hello World!", font));
+ SharedPtr< SpriteText > text(new NormalSpriteText("text", L"Hello World!", font));
GetWorld()->AddText(text);
// Texture
diff --git a/MAGE/FPS/src/core/stdafx.h b/MAGE/FPS/src/core/stdafx.h
index e09c377ac..2940248f0 100644
--- a/MAGE/FPS/src/core/stdafx.h
+++ b/MAGE/FPS/src/core/stdafx.h
@@ -13,7 +13,9 @@
#include "scripting\behavior_script.hpp"
#include "model\meshmodel.hpp"
#include "light\point_light.hpp"
-#include "text\sprite_text.hpp"
+#include "text\normal_sprite_text.hpp"
+#include "text\outline_sprite_text.hpp"
+#include "text\dropshadow_sprite_text.hpp"
#include "sprite\sprite_image.hpp"
#include "shader\lambertian_shader.hpp"
diff --git a/MAGE/MAGE.vcxproj b/MAGE/MAGE.vcxproj
index de7e424a9..b5af5202f 100644
--- a/MAGE/MAGE.vcxproj
+++ b/MAGE/MAGE.vcxproj
@@ -129,6 +129,9 @@
+
+
+
@@ -199,6 +202,10 @@
+
+
+
+
diff --git a/MAGE/MAGE.vcxproj.filters b/MAGE/MAGE.vcxproj.filters
index ce2e6096a..c49f501a4 100644
--- a/MAGE/MAGE.vcxproj.filters
+++ b/MAGE/MAGE.vcxproj.filters
@@ -205,6 +205,9 @@
{c6d373e4-d148-4ea4-8574-dcda34eb9f85}
+
+ {70445d7e-adf2-4861-815f-d860713f57c4}
+
@@ -558,6 +561,15 @@
Header Files\script
+
+ Header Files\text
+
+
+ Header Files\text
+
+
+ Header Files\text
+
@@ -758,6 +770,18 @@
Source Files\script
+
+ Source Files\text
+
+
+ Source Files\text
+
+
+ Source Files\text
+
+
+ Source Files\text
+
diff --git a/MAGE/MAGE/src/core/engine.cpp b/MAGE/MAGE/src/core/engine.cpp
index 3843e7a55..b18b03963 100644
--- a/MAGE/MAGE/src/core/engine.cpp
+++ b/MAGE/MAGE/src/core/engine.cpp
@@ -157,7 +157,7 @@ namespace mage {
}
else if (!m_deactive && m_scene) {
// Calculate the elapsed time.
- const double elapsed_time = timer.Time();
+ const double elapsed_time = timer.GetElapsedTime();
timer.Restart();
// Update the input manager.
diff --git a/MAGE/MAGE/src/logging/progress_reporter.cpp b/MAGE/MAGE/src/logging/progress_reporter.cpp
index 41ca0a0da..e7461405c 100644
--- a/MAGE/MAGE/src/logging/progress_reporter.cpp
+++ b/MAGE/MAGE/src/logging/progress_reporter.cpp
@@ -99,7 +99,7 @@ namespace mage {
// Write the buffer to the output file stream.
fputs(m_buffer, m_fout);
// Update elapsed time and estimated time to completion
- const float seconds = static_cast< float >(m_timer->Time());
+ const float seconds = static_cast< float >(m_timer->GetElapsedTime());
const float estimation_remaining = seconds / percent_done - seconds;
if (percent_done == 1.0f) {
// Writes the string format to the output file stream.
@@ -134,7 +134,7 @@ namespace mage {
// Write the buffer to the output file stream.
fputs(m_buffer, m_fout);
// Update elapsed time
- const float seconds = static_cast< float >(m_timer->Time());
+ const float seconds = static_cast< float >(m_timer->GetElapsedTime());
// Writes the string format to the output file stream.
fprintf(m_fout, " (%.1fs) \n", seconds);
diff --git a/MAGE/MAGE/src/logging/timer.cpp b/MAGE/MAGE/src/logging/timer.cpp
index b55901db9..e89b298a6 100644
--- a/MAGE/MAGE/src/logging/timer.cpp
+++ b/MAGE/MAGE/src/logging/timer.cpp
@@ -13,7 +13,8 @@
namespace mage {
Timer::Timer()
- : m_time0(0.0), m_elapsed(0.0), m_running(false) {
+ : m_initial_time(0.0), m_last_time(0.0),
+ m_elapsed_time(0.0), m_running(false) {
// Retrieve the frequency of the performance counter.
// The frequency of the performance counter is fixed at system boot
// and is consistent across all processors.
@@ -22,45 +23,66 @@ namespace mage {
m_performance_period = 1.0 / (static_cast< double >(m_performance_frequency.QuadPart));
}
- double Timer::time() {
- // Retrieve the current value of the performance counter,
- // which is a high resolution (< 1 µs) time stamp
- // that can be used for time-interval measurements.
- QueryPerformanceCounter(&m_performance_counter);
- return static_cast< double >(m_performance_counter.QuadPart * m_performance_period);
- }
-
void Timer::Start() {
if (m_running) {
return;
}
+
m_running = true;
- // Resets the initial time stamp.
- m_time0 = time();
+
+ // Set the initial time stamp.
+ m_initial_time = GetTime();
+ // Reset the elapsed time.
+ m_elapsed_time = 0.0;
+ // Reset the last time stamp.
+ m_last_time = m_initial_time;
}
void Timer::Stop() {
if (!m_running) {
return;
}
+
m_running = false;
+
// Set the elapsed time.
- m_elapsed += time() - m_time0;
+ m_elapsed_time = GetTime() - m_last_time;
+ // Set the last time stamp.
+ m_last_time = GetTime();
}
- void Timer::Reset() {
+ void Timer::Restart() {
m_running = false;
- // Resets the elapsed time.
- m_elapsed = 0;
+ Start();
}
- double Timer::Time() {
+ void Timer::Resume() {
+ if (m_running) {
+ return;
+ }
+
+ m_running = true;
+
+ // Set the last time stamp.
+ m_last_time = GetTime();
+ }
+
+ double Timer::GetElapsedTime() const {
if (m_running) {
// Set the elapsed time.
- m_elapsed += time() - m_time0;
- // Resets the initial time stamp.
- m_time0 = time();
+ m_elapsed_time = GetTime() - m_last_time;
+ // Set the last time stamp.
+ m_last_time = GetTime();
}
- return m_elapsed;
+
+ return m_elapsed_time;
+ }
+
+ double Timer::GetTime() const {
+ // Retrieve the current value of the performance counter,
+ // which is a high resolution (< 1 µs) time stamp
+ // that can be used for time-interval measurements.
+ QueryPerformanceCounter(&m_performance_counter);
+ return static_cast< double >(m_performance_counter.QuadPart * m_performance_period);
}
}
\ No newline at end of file
diff --git a/MAGE/MAGE/src/logging/timer.hpp b/MAGE/MAGE/src/logging/timer.hpp
index 509884e68..d5028f1f3 100644
--- a/MAGE/MAGE/src/logging/timer.hpp
+++ b/MAGE/MAGE/src/logging/timer.hpp
@@ -90,38 +90,28 @@ namespace mage {
void Stop();
/**
- Resets this timer.
+ Restarts this timer.
*/
- void Reset();
+ void Restart();
/**
- Restarts this timer.
+ Resumes this timer.
*/
- void Restart() {
- Reset();
- Start();
- }
+ void Resume();
/**
Returns the elapsed time of this timer.
@return The elapsed time of this timer.
*/
- double Time();
-
- protected:
-
- //---------------------------------------------------------------------
- // Member Methods
- //---------------------------------------------------------------------
+ double GetElapsedTime() const;
/**
Returns the time of this timer.
@return The time of this timer.
- @note This member method encapsulates the counter/frequency processing.
- */
- double time();
+ */
+ double GetTime() const;
private:
@@ -132,12 +122,17 @@ namespace mage {
/**
The initial time stamp of this timer.
*/
- double m_time0;
+ double m_initial_time;
+
+ /**
+ The last time stamp of this timer.
+ */
+ mutable double m_last_time;
/**
The elapsed time of this timer.
*/
- double m_elapsed;
+ mutable double m_elapsed_time;
/**
Flag indicating whether this timer is running.
@@ -147,7 +142,7 @@ namespace mage {
/**
The counter of this timer.
*/
- LARGE_INTEGER m_performance_counter;
+ mutable LARGE_INTEGER m_performance_counter;
/**
The frequency of this timer.
diff --git a/MAGE/MAGE/src/script/system_usage_script.cpp b/MAGE/MAGE/src/script/system_usage_script.cpp
index 247fd8564..2070d3438 100644
--- a/MAGE/MAGE/src/script/system_usage_script.cpp
+++ b/MAGE/MAGE/src/script/system_usage_script.cpp
@@ -18,13 +18,12 @@ namespace mage {
const double SystemUsageScript::resource_fetch_period = 0.25;
void SystemUsageScript::Update(double elapsed_time, const Scene &scene) {
- UNUSED(elapsed_time);
UNUSED(scene);
m_time += elapsed_time;
if (m_time > SystemUsageScript::resource_fetch_period) {
const uint32_t cpu_usage = static_cast(GetProcessorUsage());
- const uint32_t ram_usage = static_cast(GetPhysicalMemoryUsage() >> 20);
+ const uint32_t ram_usage = static_cast(GetVirtualMemoryUsage() >> 20);
m_cpu_usage = (cpu_usage) ? cpu_usage : m_cpu_usage;
m_ram_usage = (ram_usage) ? ram_usage : m_ram_usage;
diff --git a/MAGE/MAGE/src/system/system.cpp b/MAGE/MAGE/src/system/system.cpp
index 7c0b6cbc3..2866d12f0 100644
--- a/MAGE/MAGE/src/system/system.cpp
+++ b/MAGE/MAGE/src/system/system.cpp
@@ -24,16 +24,16 @@
namespace mage {
uint64_t GetVirtualMemoryUsage() {
- PROCESS_MEMORY_COUNTERS_EX memory_stats;
+ PROCESS_MEMORY_COUNTERS memory_stats;
ZeroMemory(&memory_stats, sizeof(memory_stats));
- const BOOL result = GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS *)&memory_stats, sizeof(memory_stats));
- return (result == 0) ? 0 : static_cast< uint64_t >(memory_stats.PrivateUsage);
+ const BOOL result = GetProcessMemoryInfo(GetCurrentProcess(), &memory_stats, sizeof(memory_stats));
+ return (result == 0) ? 0 : static_cast< uint64_t >(memory_stats.PagefileUsage);
}
uint64_t GetPhysicalMemoryUsage() {
- PROCESS_MEMORY_COUNTERS_EX memory_stats;
+ PROCESS_MEMORY_COUNTERS memory_stats;
ZeroMemory(&memory_stats, sizeof(memory_stats));
- const BOOL result = GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS *)&memory_stats, sizeof(memory_stats));
+ const BOOL result = GetProcessMemoryInfo(GetCurrentProcess(), &memory_stats, sizeof(memory_stats));
return (result == 0) ? 0 : static_cast< uint64_t >(memory_stats.WorkingSetSize);
}
@@ -97,7 +97,7 @@ namespace mage {
const double numerator = (kernel_mode_time.QuadPart - last_kernel_mode_time.QuadPart) +
(user_mode_time.QuadPart - last_user_mode_time.QuadPart);
const double denominator = (now_time.QuadPart - last_time.QuadPart) * NumberOfSystemCores();
- const double percentage = 100.0 * numerator / denominator;
+ const double percentage = 100.0 * numerator / denominator;
last_time = now_time;
last_kernel_mode_time = kernel_mode_time;
diff --git a/MAGE/MAGE/src/text/dropshadow_sprite_text.cpp b/MAGE/MAGE/src/text/dropshadow_sprite_text.cpp
new file mode 100644
index 000000000..1183ff3f3
--- /dev/null
+++ b/MAGE/MAGE/src/text/dropshadow_sprite_text.cpp
@@ -0,0 +1,26 @@
+//-----------------------------------------------------------------------------
+// Engine Includes
+//-----------------------------------------------------------------------------
+#pragma region
+
+#include "text\dropshadow_sprite_text.hpp"
+
+#pragma endregion
+
+//-----------------------------------------------------------------------------
+// Engine Definitions
+//-----------------------------------------------------------------------------
+namespace mage {
+
+ void DropshadowSpriteText::Draw(SpriteBatch &sprite_batch) const {
+ SpriteTransform transform(*GetTransform());
+ // +1, +1
+ transform.AddTranslation(XMFLOAT2(1.0f, 1.0f));
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), transform, m_shadow_color, GetSpriteEffects());
+ // -1, +1
+ transform.AddTranslationX(-2.0f);
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), transform, m_shadow_color, GetSpriteEffects());
+
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), transform, GetColorVector(), GetSpriteEffects());
+ }
+}
\ No newline at end of file
diff --git a/MAGE/MAGE/src/text/dropshadow_sprite_text.hpp b/MAGE/MAGE/src/text/dropshadow_sprite_text.hpp
new file mode 100644
index 000000000..891bcecf7
--- /dev/null
+++ b/MAGE/MAGE/src/text/dropshadow_sprite_text.hpp
@@ -0,0 +1,67 @@
+#pragma once
+
+//-----------------------------------------------------------------------------
+// Engine Includes
+//-----------------------------------------------------------------------------
+#pragma region
+
+#include "text\sprite_text.hpp"
+
+#pragma endregion
+
+//-----------------------------------------------------------------------------
+// Engine Declarations and Definitions
+//-----------------------------------------------------------------------------
+namespace mage {
+
+ class DropshadowSpriteText final : public SpriteText {
+
+ public:
+
+ //---------------------------------------------------------------------
+ // Constructors and Destructors
+ //---------------------------------------------------------------------
+
+ explicit DropshadowSpriteText(const string &name, const wstring &text, SharedPtr< SpriteFont > font,
+ const XMVECTOR &color = Colors::White, const XMVECTOR &shadow_color = Colors::Black,
+ SpriteEffect effects = SpriteEffect_None)
+ : SpriteText(name, text, font, color, effects),
+ m_shadow_color(shadow_color) {}
+ DropshadowSpriteText(const DropshadowSpriteText &sprite_text) = default;
+ DropshadowSpriteText(DropshadowSpriteText &&sprite_text) = default;
+ virtual ~DropshadowSpriteText() = default;
+
+ //---------------------------------------------------------------------
+ // Assignment Operators
+ //---------------------------------------------------------------------
+
+ DropshadowSpriteText &operator=(const DropshadowSpriteText &sprite_text) = default;
+ DropshadowSpriteText &operator=(DropshadowSpriteText &&sprite_text) = default;
+
+ //---------------------------------------------------------------------
+ // Member Methods
+ //---------------------------------------------------------------------
+
+ virtual DropshadowSpriteText *Clone() const override {
+ return new DropshadowSpriteText(*this);
+ }
+
+ virtual void Draw(SpriteBatch &sprite_batch) const override;
+
+ const Color GetShadowColor() const {
+ Color c;
+ XMStoreFloat4(&c, m_shadow_color);
+ return c;
+ }
+ void SetShadowColor(const Color &color) {
+ m_shadow_color = XMLoadFloat4(&color);
+ }
+ void SetShadowColor(const XMVECTOR &color) {
+ m_shadow_color = color;
+ }
+
+ private:
+
+ XMVECTOR m_shadow_color;
+ };
+}
\ No newline at end of file
diff --git a/MAGE/MAGE/src/text/normal_sprite_text.cpp b/MAGE/MAGE/src/text/normal_sprite_text.cpp
new file mode 100644
index 000000000..302121ba0
--- /dev/null
+++ b/MAGE/MAGE/src/text/normal_sprite_text.cpp
@@ -0,0 +1,18 @@
+//-----------------------------------------------------------------------------
+// Engine Includes
+//-----------------------------------------------------------------------------
+#pragma region
+
+#include "text\normal_sprite_text.hpp"
+
+#pragma endregion
+
+//-----------------------------------------------------------------------------
+// Engine Definitions
+//-----------------------------------------------------------------------------
+namespace mage {
+
+ void NormalSpriteText::Draw(SpriteBatch &sprite_batch) const {
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), *GetTransform(), GetColorVector(), GetSpriteEffects());
+ }
+}
\ No newline at end of file
diff --git a/MAGE/MAGE/src/text/normal_sprite_text.hpp b/MAGE/MAGE/src/text/normal_sprite_text.hpp
new file mode 100644
index 000000000..2e4b8e9b7
--- /dev/null
+++ b/MAGE/MAGE/src/text/normal_sprite_text.hpp
@@ -0,0 +1,49 @@
+#pragma once
+
+//-----------------------------------------------------------------------------
+// Engine Includes
+//-----------------------------------------------------------------------------
+#pragma region
+
+#include "text\sprite_text.hpp"
+
+#pragma endregion
+
+//-----------------------------------------------------------------------------
+// Engine Declarations and Definitions
+//-----------------------------------------------------------------------------
+namespace mage {
+
+ class NormalSpriteText final : public SpriteText {
+
+ public:
+
+ //---------------------------------------------------------------------
+ // Constructors and Destructors
+ //---------------------------------------------------------------------
+
+ explicit NormalSpriteText(const string &name, const wstring &text, SharedPtr< SpriteFont > font,
+ const XMVECTOR &color = Colors::White, SpriteEffect effects = SpriteEffect_None)
+ : SpriteText(name, text, font, color, effects) {}
+ NormalSpriteText(const NormalSpriteText &sprite_text) = default;
+ NormalSpriteText(NormalSpriteText &&sprite_text) = default;
+ virtual ~NormalSpriteText() = default;
+
+ //---------------------------------------------------------------------
+ // Assignment Operators
+ //---------------------------------------------------------------------
+
+ NormalSpriteText &operator=(const NormalSpriteText &sprite_text) = default;
+ NormalSpriteText &operator=(NormalSpriteText &&sprite_text) = default;
+
+ //---------------------------------------------------------------------
+ // Member Methods
+ //---------------------------------------------------------------------
+
+ virtual NormalSpriteText *Clone() const override {
+ return new NormalSpriteText(*this);
+ }
+
+ virtual void Draw(SpriteBatch &sprite_batch) const override;
+ };
+}
\ No newline at end of file
diff --git a/MAGE/MAGE/src/text/outline_sprite_text.cpp b/MAGE/MAGE/src/text/outline_sprite_text.cpp
new file mode 100644
index 000000000..f26f0137a
--- /dev/null
+++ b/MAGE/MAGE/src/text/outline_sprite_text.cpp
@@ -0,0 +1,32 @@
+//-----------------------------------------------------------------------------
+// Engine Includes
+//-----------------------------------------------------------------------------
+#pragma region
+
+#include "text\outline_sprite_text.hpp"
+
+#pragma endregion
+
+//-----------------------------------------------------------------------------
+// Engine Definitions
+//-----------------------------------------------------------------------------
+namespace mage {
+
+ void OutlineSpriteText::Draw(SpriteBatch &sprite_batch) const {
+ SpriteTransform transform(*GetTransform());
+ // +1, +1
+ transform.AddTranslation(XMFLOAT2(1.0f, 1.0f));
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), transform, m_border_color, GetSpriteEffects());
+ // -1, +1
+ transform.AddTranslationX(-2.0f);
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), transform, m_border_color, GetSpriteEffects());
+ // -1, -1
+ transform.AddTranslationY(-2.0f);
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), transform, m_border_color, GetSpriteEffects());
+ // +1, -1
+ transform.AddTranslationX(2.0f);
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), transform, m_border_color, GetSpriteEffects());
+
+ GetRawFont()->DrawString(sprite_batch, GetText().c_str(), *GetTransform(), GetColorVector(), GetSpriteEffects());
+ }
+}
\ No newline at end of file
diff --git a/MAGE/MAGE/src/text/outline_sprite_text.hpp b/MAGE/MAGE/src/text/outline_sprite_text.hpp
new file mode 100644
index 000000000..0c03e2f3e
--- /dev/null
+++ b/MAGE/MAGE/src/text/outline_sprite_text.hpp
@@ -0,0 +1,67 @@
+#pragma once
+
+//-----------------------------------------------------------------------------
+// Engine Includes
+//-----------------------------------------------------------------------------
+#pragma region
+
+#include "text\sprite_text.hpp"
+
+#pragma endregion
+
+//-----------------------------------------------------------------------------
+// Engine Declarations and Definitions
+//-----------------------------------------------------------------------------
+namespace mage {
+
+ class OutlineSpriteText final : public SpriteText {
+
+ public:
+
+ //---------------------------------------------------------------------
+ // Constructors and Destructors
+ //---------------------------------------------------------------------
+
+ explicit OutlineSpriteText(const string &name, const wstring &text, SharedPtr< SpriteFont > font,
+ const XMVECTOR &color = Colors::White, const XMVECTOR &border_color = Colors::Black,
+ SpriteEffect effects = SpriteEffect_None)
+ : SpriteText(name, text, font, color, effects),
+ m_border_color(border_color) {}
+ OutlineSpriteText(const OutlineSpriteText &sprite_text) = default;
+ OutlineSpriteText(OutlineSpriteText &&sprite_text) = default;
+ virtual ~OutlineSpriteText() = default;
+
+ //---------------------------------------------------------------------
+ // Assignment Operators
+ //---------------------------------------------------------------------
+
+ OutlineSpriteText &operator=(const OutlineSpriteText &sprite_text) = default;
+ OutlineSpriteText &operator=(OutlineSpriteText &&sprite_text) = default;
+
+ //---------------------------------------------------------------------
+ // Member Methods
+ //---------------------------------------------------------------------
+
+ virtual OutlineSpriteText *Clone() const override {
+ return new OutlineSpriteText(*this);
+ }
+
+ virtual void Draw(SpriteBatch &sprite_batch) const override;
+
+ const Color GetBorderColor() const {
+ Color c;
+ XMStoreFloat4(&c, m_border_color);
+ return c;
+ }
+ void SetBorderColor(const Color &color) {
+ m_border_color = XMLoadFloat4(&color);
+ }
+ void SetBorderColor(const XMVECTOR &color) {
+ m_border_color = color;
+ }
+
+ private:
+
+ XMVECTOR m_border_color;
+ };
+}
\ No newline at end of file
diff --git a/MAGE/MAGE/src/text/sprite_text.cpp b/MAGE/MAGE/src/text/sprite_text.cpp
new file mode 100644
index 000000000..043e2db85
--- /dev/null
+++ b/MAGE/MAGE/src/text/sprite_text.cpp
@@ -0,0 +1,35 @@
+//-----------------------------------------------------------------------------
+// Engine Includes
+//-----------------------------------------------------------------------------
+#pragma region
+
+#include "text\sprite_text.hpp"
+
+#pragma endregion
+
+//-----------------------------------------------------------------------------
+// Engine Declarations
+//-----------------------------------------------------------------------------
+namespace mage {
+
+ SpriteText::SpriteText(const string &name, const wstring &text, SharedPtr< SpriteFont > font,
+ const XMVECTOR &color, SpriteEffect effects)
+ : m_name(name), m_text(text), m_font(font),
+ m_color(color), m_effects(effects),
+ m_transform(new SpriteTransform()) {}
+
+ SpriteText::SpriteText(const SpriteText &sprite_text)
+ : m_name(sprite_text.m_name), m_text(sprite_text.m_text), m_font(sprite_text.m_font),
+ m_color(sprite_text.m_color), m_effects(sprite_text.m_effects),
+ m_transform(new SpriteTransform(*sprite_text.m_transform)) {}
+
+ SpriteText &SpriteText::operator=(const SpriteText &sprite_text) {
+ m_name = sprite_text.m_name;
+ m_text = sprite_text.m_text;
+ m_font = sprite_text.m_font;
+ m_color = sprite_text.m_color;
+ m_effects = sprite_text.m_effects;
+ m_transform.reset(new SpriteTransform(*sprite_text.m_transform));
+ return (*this);
+ }
+}
\ No newline at end of file
diff --git a/MAGE/MAGE/src/text/sprite_text.hpp b/MAGE/MAGE/src/text/sprite_text.hpp
index 5307fd100..96351dee5 100644
--- a/MAGE/MAGE/src/text/sprite_text.hpp
+++ b/MAGE/MAGE/src/text/sprite_text.hpp
@@ -10,7 +10,7 @@
#pragma endregion
//-----------------------------------------------------------------------------
-// Engine Declarations
+// Engine Declarations and Definitions
//-----------------------------------------------------------------------------
namespace mage {
@@ -19,32 +19,25 @@ namespace mage {
public:
//---------------------------------------------------------------------
- // Constructors and Destructors
+ // Destructors
//---------------------------------------------------------------------
- explicit SpriteText(const string &name, const wstring &text, SharedPtr< SpriteFont > font,
- const XMVECTOR &color = Colors::White, SpriteEffect effects = SpriteEffect_None)
- : m_name(name), m_text(text), m_font(font),
- m_color(color), m_effects(effects),
- m_transform(new SpriteTransform()) {}
- SpriteText(const SpriteText &sprite_text) = default;
- SpriteText(SpriteText &&sprite_text) = default;
virtual ~SpriteText() = default;
//---------------------------------------------------------------------
// Assignment Operators
//---------------------------------------------------------------------
- SpriteText &operator=(const SpriteText &sprite_text) = default;
+ SpriteText &operator=(const SpriteText &sprite_text);
SpriteText &operator=(SpriteText &&sprite_text) = default;
//---------------------------------------------------------------------
// Member Methods
//---------------------------------------------------------------------
- void Draw(SpriteBatch &sprite_batch) const {
- m_font->DrawString(sprite_batch, m_text.c_str(), *m_transform, m_color, m_effects);
- }
+ virtual SpriteText *Clone() const = 0;
+
+ virtual void Draw(SpriteBatch &sprite_batch) const = 0;
const string &GetName() const {
return m_name;
@@ -87,7 +80,29 @@ namespace mage {
const SpriteTransform *GetTransform() const {
return m_transform.get();
}
-
+
+ protected:
+
+ //---------------------------------------------------------------------
+ // Constructors
+ //---------------------------------------------------------------------
+
+ explicit SpriteText(const string &name, const wstring &text, SharedPtr< SpriteFont > font,
+ const XMVECTOR &color = Colors::White, SpriteEffect effects = SpriteEffect_None);
+ SpriteText(const SpriteText &sprite_text);
+ SpriteText(SpriteText &&sprite_text) = default;
+
+ //---------------------------------------------------------------------
+ // Member Methods
+ //---------------------------------------------------------------------
+
+ const XMVECTOR GetColorVector() const {
+ return m_color;
+ }
+ const SpriteFont *GetRawFont() const {
+ return m_font.get();
+ }
+
private:
//---------------------------------------------------------------------