diff --git a/includes/csharp/time.hpp b/includes/csharp/time.hpp index 69c59f2..a522dd5 100644 --- a/includes/csharp/time.hpp +++ b/includes/csharp/time.hpp @@ -153,15 +153,15 @@ namespace csharp { return FromUnits(hours, TicksPerHour, MinHours, MaxHours); } - static constexpr TimeSpan FromMinutes(int32_t minutes) { + static constexpr TimeSpan FromMinutes(int64_t minutes) { return FromUnits(minutes, TicksPerMinute, MinMinutes, MaxMinutes); } - static constexpr TimeSpan FromSeconds(int32_t seconds) { + static constexpr TimeSpan FromSeconds(int64_t seconds) { return FromUnits(seconds, TicksPerSecond, MinSeconds, MaxSeconds); } - static constexpr TimeSpan FromMicroseconds(int32_t microseconds) { + static constexpr TimeSpan FromMicroseconds(int64_t microseconds) { return FromUnits(microseconds, TicksPerMicrosecond, MinMicroseconds, MaxMicroseconds); } diff --git a/includes/xna/audio/soundeffect.hpp b/includes/xna/audio/soundeffect.hpp index cdc9a39..5c08ff4 100644 --- a/includes/xna/audio/soundeffect.hpp +++ b/includes/xna/audio/soundeffect.hpp @@ -2,6 +2,7 @@ #define XNA_SOUND_SOUNDEFFECT_HPP #include "../default.hpp" +#include "csharp/time.hpp" namespace xna { struct SoundEffectInstance { @@ -31,7 +32,7 @@ namespace xna { std::vector const& data, Int loopStart, Int loopLength, - TimeSpan const& duration); + csharp::TimeSpan const& duration); ~SoundEffect(); void Play(); void Play(float volume, float pitch, float pan); diff --git a/includes/xna/content/readers/audio.hpp b/includes/xna/content/readers/audio.hpp index cc31952..df47ea7 100644 --- a/includes/xna/content/readers/audio.hpp +++ b/includes/xna/content/readers/audio.hpp @@ -2,7 +2,7 @@ #define XNA_CONTENT_READERS_AUDIO_HPP #include "../../audio/soundeffect.hpp" -#include "../../csharp/timespan.hpp" +#include "csharp/time.hpp" #include "../../csharp/type.hpp" #include "../manager.hpp" #include "../reader.hpp" @@ -23,7 +23,7 @@ namespace xna { const auto loopLength = input.ReadInt32(); const auto num = input.ReadInt32(); - auto sf = snew(format, data, loopStart, loopLength, TimeSpan::FromMilliseconds((double)num)); + auto sf = snew(format, data, loopStart, loopLength, csharp::TimeSpan::FromMilliseconds((double)num)); return sf; } }; diff --git a/includes/xna/content/readers/default.hpp b/includes/xna/content/readers/default.hpp index 6d05e32..29d41eb 100644 --- a/includes/xna/content/readers/default.hpp +++ b/includes/xna/content/readers/default.hpp @@ -3,7 +3,7 @@ #include "../../common/color.hpp" #include "../../common/numerics.hpp" -#include "../../csharp/timespan.hpp" +#include "csharp/time.hpp" #include "../../default.hpp" #include "../reader.hpp" @@ -156,12 +156,12 @@ namespace xna { } }; - class TimeSpanReader : public ContentTypeReaderT { + class TimeSpanReader : public ContentTypeReaderT { public: - TimeSpanReader() : ContentTypeReaderT(typeof()) {} + TimeSpanReader() : ContentTypeReaderT(typeof()) {} - TimeSpan Read(ContentReader& input, TimeSpan& existingInstance) override { - return TimeSpan::FromTicks(input.ReadInt64()); + csharp::TimeSpan Read(ContentReader& input, csharp::TimeSpan& existingInstance) override { + return csharp::TimeSpan::FromTicks(input.ReadInt64()); } }; diff --git a/includes/xna/content/readers/graphics.hpp b/includes/xna/content/readers/graphics.hpp index b9946c9..cdd9588 100644 --- a/includes/xna/content/readers/graphics.hpp +++ b/includes/xna/content/readers/graphics.hpp @@ -2,7 +2,6 @@ #define XNA_CONTENT_READERS_GRAPHICS_HPP #include "../../common/numerics.hpp" -#include "../../csharp/timespan.hpp" #include "../../csharp/type.hpp" #include "../../graphics/sprite.hpp" #include "../../graphics/texture.hpp" diff --git a/includes/xna/csharp/timespan.hpp b/includes/xna/csharp/timespan.hpp deleted file mode 100644 index fec1bd0..0000000 --- a/includes/xna/csharp/timespan.hpp +++ /dev/null @@ -1,341 +0,0 @@ -#ifndef XNA_CSHARP_TIMESPAN_HPP -#define XNA_CSHARP_TIMESPAN_HPP - -#include -#include -#include - -namespace xna { - //A port of the System.TimeSpan - //TimeSpan represents a duration of time.A TimeSpan can be negative or positive. - struct TimeSpan { - static constexpr int64_t NanosecondsPerTick = 100; - static constexpr int64_t TicksPerMicrosecond = 10; - static constexpr int64_t TicksPerMillisecond = TicksPerMicrosecond * 1000; - static constexpr int64_t TicksPerSecond = TicksPerMillisecond * 1000; - static constexpr int64_t TicksPerMinute = TicksPerSecond * 60; - static constexpr int64_t TicksPerHour = TicksPerMinute * 60; - static constexpr int64_t TicksPerDay = TicksPerHour * 24; - static constexpr int64_t MicrosecondsPerMillisecond = TicksPerMillisecond / TicksPerMicrosecond; - static constexpr int64_t MicrosecondsPerSecond = TicksPerSecond / TicksPerMicrosecond; - static constexpr int64_t MicrosecondsPerMinute = TicksPerMinute / TicksPerMicrosecond; - static constexpr int64_t MicrosecondsPerHour = TicksPerHour / TicksPerMicrosecond; - static constexpr int64_t MicrosecondsPerDay = TicksPerDay / TicksPerMicrosecond; - static constexpr int64_t MillisecondsPerSecond = TicksPerSecond / TicksPerMillisecond; - static constexpr int64_t MillisecondsPerMinute = TicksPerMinute / TicksPerMillisecond; - static constexpr int64_t MillisecondsPerHour = TicksPerHour / TicksPerMillisecond; - static constexpr int64_t MillisecondsPerDay = TicksPerDay / TicksPerMillisecond; - static constexpr int64_t SecondsPerMinute = TicksPerMinute / TicksPerSecond; - static constexpr int64_t SecondsPerHour = TicksPerHour / TicksPerSecond; - static constexpr int64_t SecondsPerDay = TicksPerDay / TicksPerSecond; - static constexpr int64_t MinutesPerHour = TicksPerHour / TicksPerMinute; - static constexpr int64_t MinutesPerDay = TicksPerDay / TicksPerMinute; - static constexpr int64_t HoursPerDay = TicksPerDay / TicksPerHour; - static constexpr int64_t MinTicks = (std::numeric_limits::min)(); - static constexpr int64_t MaxTicks = (std::numeric_limits::max)(); - static constexpr int64_t MinMicroseconds = MinTicks / TicksPerMicrosecond; - static constexpr int64_t MaxMicroseconds = MaxTicks / TicksPerMicrosecond; - static constexpr int64_t MinMilliseconds = MinTicks / TicksPerMillisecond; - static constexpr int64_t MaxMilliseconds = MaxTicks / TicksPerMillisecond; - static constexpr int64_t MinSeconds = MinTicks / TicksPerSecond; - static constexpr int64_t MaxSeconds = MaxTicks / TicksPerSecond; - static constexpr int64_t MinMinutes = MinTicks / TicksPerMinute; - static constexpr int64_t MaxMinutes = MaxTicks / TicksPerMinute; - static constexpr int64_t MinHours = MinTicks / TicksPerHour; - static constexpr int64_t MaxHours = MaxTicks / TicksPerHour; - static constexpr int64_t MinDays = MinTicks / TicksPerDay; - static constexpr int64_t MaxDays = MaxTicks / TicksPerDay; - static constexpr int64_t TicksPerTenthSecond = TicksPerMillisecond * 100; - - static constexpr TimeSpan Zero() { return TimeSpan(); } - static constexpr TimeSpan MaxValue() { return TimeSpan(MaxTicks); } - static constexpr TimeSpan MinValue() { return TimeSpan(MinTicks); } - - constexpr TimeSpan() = default; - constexpr TimeSpan(int64_t ticks) : _ticks(ticks) {} - constexpr TimeSpan(int32_t hours, int32_t minutes, int32_t seconds) { - _ticks = TimeToTicks(hours, minutes, seconds); - } - constexpr TimeSpan(int32_t days, int32_t hours, int32_t minutes, int32_t seconds, int32_t milliseconds, int32_t microseconds = 0) { - _ticks = TimeToTicks(days, hours, minutes, seconds, milliseconds, microseconds); - } - - constexpr int64_t Ticks() const { return _ticks; } - constexpr int32_t Days() const { return static_cast(_ticks / TicksPerDay); } - constexpr int32_t Hours() const { return static_cast(_ticks / TicksPerHour % HoursPerDay); } - constexpr int32_t Milliseconds() const { return static_cast(_ticks / TicksPerMillisecond % MillisecondsPerSecond); } - constexpr int32_t Microseconds() const { return static_cast(_ticks / TicksPerMicrosecond % MicrosecondsPerMillisecond); } - constexpr int32_t Nanoseconds() const { return static_cast(_ticks % TicksPerMicrosecond * NanosecondsPerTick); } - constexpr int32_t Minutes() const { return static_cast(_ticks / TicksPerMinute % MinutesPerHour); } - constexpr int32_t Seconds() const { return static_cast(_ticks / TicksPerSecond % SecondsPerMinute); } - constexpr double TotalDays() const { return static_cast(_ticks) / TicksPerDay; } - constexpr double TotalHours() const { return static_cast(_ticks) / TicksPerHour; } - - constexpr double TotalMilliseconds() const { - double temp = static_cast(_ticks) / TicksPerMillisecond; - - if (temp > MaxMilliseconds) { - return MaxMilliseconds; - } - - if (temp < MinMilliseconds) { - return MinMilliseconds; - } - return temp; - } - - constexpr double TotalMicroseconds() const { return static_cast(_ticks) / TicksPerMicrosecond; } - constexpr double TotalNanoseconds() const { return static_cast(_ticks) * NanosecondsPerTick; } - constexpr double TotalMinutes() const { return static_cast(_ticks) / TicksPerMinute; } - constexpr double TotalSeconds() const { return static_cast(_ticks) / TicksPerSecond; } - - constexpr TimeSpan Add(TimeSpan const& ts) const { - int64_t result = _ticks + ts._ticks; - int64_t t1Sign = _ticks >> 63; - - if ((t1Sign == (ts._ticks >> 63)) && (t1Sign != (result >> 63))) { - return TimeSpan::Zero(); - //exception - } - - return result; - } - - static TimeSpan FromDays(double value) { - return Interval(value, TicksPerDay); - } - - constexpr TimeSpan Duration() const { - if (_ticks == MinTicks) { - return TimeSpan::Zero(); - } - - return TimeSpan(_ticks >= 0 ? _ticks : -_ticks); - } - - static constexpr TimeSpan FromUnits(int64_t units, int64_t ticksPerUnit, int64_t minUnits, int64_t maxUnits) { - if (units > maxUnits || units < minUnits) { - return TimeSpan::Zero(); - } - - return TimeSpan::FromTicks(units * ticksPerUnit); - } - - static constexpr TimeSpan FromDays(int32_t days) { - return FromUnits(days, TicksPerDay, MinDays, MaxDays); - } - - //TODO: Not implemented. - //static constexpr TimeSpan FromDays(int32_t days, int32_t hours = 0, int64_t minutes = 0, int64_t seconds = 0, int64_t milliseconds = 0, int64_t microseconds = 0); - - static constexpr TimeSpan FromHours(int32_t hours) { - return FromUnits(hours, TicksPerHour, MinHours, MaxHours); - } - - //TODO: Not implemented. - //static constexpr TimeSpan FromHours(int32_t hours, int64_t minutes = 0, int64_t seconds = 0, int64_t milliseconds = 0, int64_t microseconds = 0); - - static constexpr TimeSpan FromMinutes(int64_t minutes) { - return FromUnits(minutes, TicksPerMinute, MinMinutes, MaxMinutes); - } - - //TODO: Not implemented. - //static constexpr TimeSpan FromMinutes(int64_t minutes, int64_t seconds = 0, int64_t milliseconds = 0, int64_t microseconds = 0); - static constexpr TimeSpan FromSeconds(int seconds) { - return FromSeconds(static_cast(seconds)); - } - - static constexpr TimeSpan FromSeconds(int64_t seconds) { - return FromUnits(seconds, TicksPerSecond, MinSeconds, MaxSeconds); - } - - //TODO: Not implemented. - //static constexpr TimeSpan FromSeconds(int64_t seconds, int64_t milliseconds = 0, int64_t microseconds = 0); - - //TODO: Not implemented. - //static constexpr TimeSpan FromMilliseconds(int64_t milliseconds, int64_t microseconds = 0); - - static constexpr TimeSpan FromMicroseconds(int64_t microseconds) { - return FromUnits(microseconds, TicksPerMicrosecond, MinMicroseconds, MaxMicroseconds); - } - - static TimeSpan FromHours(double value) { - return Interval(value, TicksPerHour); - } - - static constexpr int64_t TimeToTicks(int32_t hour, int32_t minute, int32_t second) { - int64_t totalSeconds = - (hour * SecondsPerHour) - + (minute * SecondsPerMinute) - + second; - - //exception - if (totalSeconds > MaxSeconds) { - return MaxValue()._ticks; - } - else if (totalSeconds < MinSeconds) { - return MinValue()._ticks; - } - - return totalSeconds * TicksPerSecond; - } - - static TimeSpan FromMilliseconds(double value) { - return Interval(value, TicksPerMillisecond); - } - - static TimeSpan FromMicroseconds(double value) { - return Interval(value, TicksPerMicrosecond); - } - - static TimeSpan FromMinutes(double value) { - return Interval(value, TicksPerMinute); - } - - constexpr TimeSpan Negate() const { - if (_ticks == MinTicks) { - return MinTicks; - } - - return -_ticks; - } - - static TimeSpan FromSeconds(double value) { - return Interval(value, TicksPerSecond); - } - - constexpr TimeSpan Subtract(TimeSpan const& ts) const { - int64_t result = _ticks - ts._ticks; - int64_t t1Sign = _ticks >> 63; - - if ((t1Sign != (ts._ticks >> 63)) && (t1Sign != (result >> 63))) { - return TimeSpan::Zero(); - //exception - } - - return result; - } - - TimeSpan Multiply(double factor) const { - if (isnan(factor)) { - return TimeSpan::Zero(); - //exception - } - - const auto ticks = std::round(_ticks * factor); - return IntervalFromDoubleTicks(ticks); - } - - TimeSpan Divide(double divisor) const { - if (isnan(divisor)) { - return TimeSpan::Zero(); - //exception - } - - const auto ticks = std::round(_ticks / divisor); - return IntervalFromDoubleTicks(ticks); - } - - constexpr double Divide(TimeSpan const& ts) const { - return _ticks / static_cast(ts._ticks); - } - - static constexpr TimeSpan FromTicks(int64_t value) { - return TimeSpan(value); - } - - static constexpr int64_t TimeToTicks(int32_t days, int32_t hours, int32_t minutes, int32_t seconds, int32_t milliseconds, int32_t microseconds) { - int64_t totalMicroseconds = - (days * MicrosecondsPerDay) - + (hours * MicrosecondsPerHour) - + (minutes * MicrosecondsPerMinute) - + (seconds * MicrosecondsPerSecond) - + (milliseconds * MicrosecondsPerMillisecond) - + microseconds; - - //exception - if (totalMicroseconds > MaxMicroseconds) { - return MaxValue()._ticks; - } - else if (totalMicroseconds < MinMicroseconds) { - return MinValue()._ticks; - } - - return totalMicroseconds * TicksPerMicrosecond; - } - - constexpr bool operator==(TimeSpan const& other) const { - return _ticks == other._ticks; - } - - constexpr TimeSpan operator-() const { - return Negate(); - } - - friend constexpr TimeSpan operator-(TimeSpan const& a, TimeSpan const& b) { - return a.Subtract(b); - } - - friend constexpr TimeSpan operator+(TimeSpan const& a, TimeSpan const& b) { - return a.Add(b); - } - - friend TimeSpan operator*(TimeSpan const& a, double factor) { - return a.Multiply(factor); - } - - friend TimeSpan operator*(double factor, TimeSpan const& b) { - return b.Multiply(factor); - } - - friend double operator/(TimeSpan const& a, TimeSpan const& b) { - return a.Divide(b); - } - - friend bool operator<(TimeSpan const& a, TimeSpan const& b) { - return a._ticks < b._ticks; - } - - friend bool operator<=(TimeSpan const& a, TimeSpan const& b) { - return a._ticks <= b._ticks; - } - - friend bool operator>(TimeSpan const& a, TimeSpan const& b) { - return a._ticks > b._ticks; - } - - friend bool operator>=(TimeSpan const& a, TimeSpan const& b) { - return a._ticks >= b._ticks; - } - - private: - int64_t _ticks{ 0 }; - - static TimeSpan Interval(double value, double scale) { - if (isnan(value)) { - //exception - return TimeSpan::Zero(); - } - - return IntervalFromDoubleTicks(value * scale); - } - - static constexpr TimeSpan IntervalFromDoubleTicks(double ticks) { - if ((ticks > MaxTicks) || (ticks < MinTicks) || isnan(ticks)) { - //exception - return TimeSpan::Zero(); - } - - if (ticks == MaxTicks) { - return MaxValue(); - } - - return TimeSpan(static_cast(ticks)); - } - - //TODO: Not implemented. - //static TimeSpan FromMicroseconds(__int128 microseconds); - }; -} - -#endif \ No newline at end of file diff --git a/includes/xna/framework.hpp b/includes/xna/framework.hpp index 1629ef1..5e98623 100644 --- a/includes/xna/framework.hpp +++ b/includes/xna/framework.hpp @@ -19,7 +19,6 @@ #include "content/typereadermanager.hpp" #include "csharp/buffer.hpp" #include "csharp/service.hpp" -#include "csharp/timespan.hpp" #include "csharp/type.hpp" #include "csharp/screen.hpp" #include "csharp/eventhandler.hpp" diff --git a/includes/xna/game/game.hpp b/includes/xna/game/game.hpp index 5cccc65..bfc499e 100644 --- a/includes/xna/game/game.hpp +++ b/includes/xna/game/game.hpp @@ -31,9 +31,9 @@ namespace xna { //Gets the GameServiceContainer holding all the service providers attached to the Game. sptr Services(); //Gets or sets the target time between calls to Update when IsFixedTimeStep is true. - constexpr TimeSpan TargetElapsedTime() const { return targetElapsedTime; } + constexpr csharp::TimeSpan TargetElapsedTime() const { return targetElapsedTime; } //Gets or sets the target time between calls to Update when IsFixedTimeStep is true. - void TargetElapsedTime(TimeSpan const& value); + void TargetElapsedTime(csharp::TimeSpan const& value); //Gets the underlying operating system window. sptr Window(); @@ -85,7 +85,7 @@ namespace xna { bool enabledGameComponents{ false }; GameTime currentGameTime{}; bool isFixedTimeStep{ true }; - TimeSpan targetElapsedTime{ TimeSpan::FromTicks(166667L) }; + csharp::TimeSpan targetElapsedTime{ csharp::TimeSpan::FromTicks(166667L) }; bool isRunning{ false }; sptr services = nullptr; sptr graphicsDevice = nullptr; diff --git a/includes/xna/game/time.hpp b/includes/xna/game/time.hpp index 72439e0..5e6cca9 100644 --- a/includes/xna/game/time.hpp +++ b/includes/xna/game/time.hpp @@ -2,7 +2,7 @@ #define XNA_GAME_TIME_HPP #include "../default.hpp" -#include "../csharp/timespan.hpp" +#include "csharp/time.hpp" namespace xna { //Snapshot of the game timing state expressed in values that can be used by variable-step (real time) or fixed-step (game time) games. @@ -10,17 +10,17 @@ namespace xna { public: constexpr GameTime() = default; - constexpr GameTime(const TimeSpan& elapsedGameTime, const TimeSpan& totalGameTime, bool isRunningSlowly) : + constexpr GameTime(const csharp::TimeSpan& elapsedGameTime, const csharp::TimeSpan& totalGameTime, bool isRunningSlowly) : ElapsedGameTime(elapsedGameTime), IsRunningSlowly(isRunningSlowly), TotalGameTime(totalGameTime) { } //The amount of elapsed game time since the last update. - TimeSpan ElapsedGameTime{ 0 }; + csharp::TimeSpan ElapsedGameTime{ 0 }; //Gets a value indicating that the game loop is taking longer than its TargetElapsedTime. In this case, the game loop can be considered to be running too slowly and should do something to "catch up." bool IsRunningSlowly{ false }; //The amount of game time since the start of the game. - TimeSpan TotalGameTime{ 0 }; + csharp::TimeSpan TotalGameTime{ 0 }; }; } diff --git a/samples/02_PlatfformerStarterKit/enemy.cpp b/samples/02_PlatfformerStarterKit/enemy.cpp index f19eca7..2f62c7d 100644 --- a/samples/02_PlatfformerStarterKit/enemy.cpp +++ b/samples/02_PlatfformerStarterKit/enemy.cpp @@ -65,7 +65,7 @@ namespace PlatformerStarterKit { { if (!level->Player()->IsAlive() || level->ReachedExit() || - level->TimeRemaining() == xna::TimeSpan::Zero() || + level->TimeRemaining() == csharp::TimeSpan::Zero() || waitTime > 0) { sprite.PlayAnimation(idleAnimation); } diff --git a/samples/02_PlatfformerStarterKit/game.cpp b/samples/02_PlatfformerStarterKit/game.cpp index 1d51833..366aa8b 100644 --- a/samples/02_PlatfformerStarterKit/game.cpp +++ b/samples/02_PlatfformerStarterKit/game.cpp @@ -84,7 +84,7 @@ namespace PlatformerStarterKit { if (!level->Player()->IsAlive()) { level->StartNewLife(); } - else if (level->TimeRemaining() == TimeSpan::Zero()) { + else if (level->TimeRemaining() == csharp::TimeSpan::Zero()) { if (level->ReachedExit()) LoadNextLevel(); else @@ -144,7 +144,7 @@ namespace PlatformerStarterKit { DrawShadowedString(*hudFont, "SCORE: " + to_string(level->Score()), hudLocation + Vector2(0.0f, timeHeight * 1.2f), Colors::Yellow); PTexture2D status = nullptr; - if (level->TimeRemaining() == TimeSpan::Zero()) + if (level->TimeRemaining() == csharp::TimeSpan::Zero()) { if (level->ReachedExit()) { status = winOverlay; @@ -179,7 +179,7 @@ namespace PlatformerStarterKit { int levelIndex = -1; sptr level = nullptr; bool wasContinuePressed = false; - TimeSpan WarningTime = TimeSpan::FromSeconds(30); + csharp::TimeSpan WarningTime = csharp::TimeSpan::FromSeconds(30.0); static constexpr int TargetFrameRate = 60; static constexpr Buttons ContinueButton = Buttons::A; }; diff --git a/samples/02_PlatfformerStarterKit/level.cpp b/samples/02_PlatfformerStarterKit/level.cpp index 9d08c28..99a2963 100644 --- a/samples/02_PlatfformerStarterKit/level.cpp +++ b/samples/02_PlatfformerStarterKit/level.cpp @@ -11,7 +11,7 @@ namespace PlatformerStarterKit { Level::Level(xna::sptr const& serviceProvider, xna::String const& path) : path(path) { content = xna::snew(serviceProvider, "Content"); - timeRemaining = xna::TimeSpan::FromMinutes(2.0); + timeRemaining = csharp::TimeSpan::FromMinutes(2.0); layers = std::vector(3); @@ -207,13 +207,13 @@ namespace PlatformerStarterKit { } void Level::Update(xna::GameTime const& gameTime) { - if (!player->IsAlive() || timeRemaining == xna::TimeSpan::Zero()) { + if (!player->IsAlive() || timeRemaining == csharp::TimeSpan::Zero()) { player->ApplyPhysics(gameTime); } else if (reachedExit) { auto seconds = static_cast(std::round(gameTime.ElapsedGameTime.TotalSeconds() * 100.0f)); seconds = std::min(seconds, static_cast(std::ceil(timeRemaining.TotalSeconds()))); - timeRemaining = timeRemaining - xna::TimeSpan::FromSeconds(seconds); + timeRemaining = timeRemaining - csharp::TimeSpan::FromSeconds(seconds); score += seconds * PointsPerSecond; } else { @@ -238,8 +238,8 @@ namespace PlatformerStarterKit { } } - if (timeRemaining < xna::TimeSpan::Zero()) - timeRemaining = xna::TimeSpan::Zero(); + if (timeRemaining < csharp::TimeSpan::Zero()) + timeRemaining = csharp::TimeSpan::Zero(); } void Level::Draw(xna::GameTime const& gameTime, xna::SpriteBatch& spriteBatch) diff --git a/samples/02_PlatfformerStarterKit/level.hpp b/samples/02_PlatfformerStarterKit/level.hpp index 7c84557..d2db6a1 100644 --- a/samples/02_PlatfformerStarterKit/level.hpp +++ b/samples/02_PlatfformerStarterKit/level.hpp @@ -3,6 +3,7 @@ #include "headers.hpp" #include "tile.hpp" +#include "csharp/time.hpp" namespace PlatformerStarterKit { @@ -30,7 +31,7 @@ namespace PlatformerStarterKit { return reachedExit; } - constexpr xna::TimeSpan TimeRemaining() const { + constexpr csharp::TimeSpan TimeRemaining() const { return timeRemaining; } @@ -79,7 +80,7 @@ namespace PlatformerStarterKit { xna::Point exit = InvalidPosition; int score = 0; bool reachedExit = false; - xna::TimeSpan timeRemaining{}; + csharp::TimeSpan timeRemaining{}; xna::sptr content = nullptr; xna::sptr exitReachedSound = nullptr; xna::String path; diff --git a/sources/framework-dx/game.cpp b/sources/framework-dx/game.cpp index 30fb565..f3ecd60 100644 --- a/sources/framework-dx/game.cpp +++ b/sources/framework-dx/game.cpp @@ -52,8 +52,8 @@ namespace xna { { const auto elapsed = impl->_stepTimer.GetElapsedSeconds(); const auto total = impl->_stepTimer.GetTotalSeconds(); - const auto elapsedTimeSpan = TimeSpan::FromSeconds(elapsed); - const auto totalTimeSpan = TimeSpan::FromSeconds(total); + const auto elapsedTimeSpan = csharp::TimeSpan::FromSeconds(elapsed); + const auto totalTimeSpan = csharp::TimeSpan::FromSeconds(total); currentGameTime.ElapsedGameTime = elapsedTimeSpan; currentGameTime.TotalGameTime = totalTimeSpan; Update(currentGameTime); @@ -209,7 +209,7 @@ namespace xna { Mouse::impl->_dxMouse->SetVisible(value); } - void Game::TargetElapsedTime(TimeSpan const& value) { + void Game::TargetElapsedTime(csharp::TimeSpan const& value) { if (!isFixedTimeStep) return; diff --git a/sources/framework-dx/soundeffect.cpp b/sources/framework-dx/soundeffect.cpp index a1b56d9..5fa7d20 100644 --- a/sources/framework-dx/soundeffect.cpp +++ b/sources/framework-dx/soundeffect.cpp @@ -30,7 +30,7 @@ namespace xna { Int loopStart, Int loopLength, //We must evaluate how to use the time duration - TimeSpan const& duration) { + csharp::TimeSpan const& duration) { if (!AudioEngine::impl || !AudioEngine::impl->_dxAudioEngine) return;