From 195d6cded05f7ef5bde695ee047b341a0265eab3 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 24 Mar 2013 00:03:37 +0100 Subject: Fixed timer functions on win32 * changed win32 implementation to QueryPerformaceTimer system function * refactored system utils code * proper tests for time utils and update event creation in application * should fix issue #134 --- src/app/system_other.cpp | 93 +++--------------------------------------------- 1 file changed, 5 insertions(+), 88 deletions(-) (limited to 'src/app/system_other.cpp') diff --git a/src/app/system_other.cpp b/src/app/system_other.cpp index 006bf6d..9fc1f95 100644 --- a/src/app/system_other.cpp +++ b/src/app/system_other.cpp @@ -18,105 +18,22 @@ #include "app/system_other.h" -SystemDialogResult SystemDialog_Other(SystemDialogType type, const std::string& title, const std::string& message) +SystemDialogResult CSystemUtilsOther::SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) { - switch (type) - { - case SDT_INFO: - std::cout << "INFO: "; - break; - case SDT_WARNING: - std::cout << "WARNING:"; - break; - case SDT_ERROR: - std::cout << "ERROR: "; - break; - case SDT_YES_NO: - case SDT_OK_CANCEL: - std::cout << "QUESTION: "; - break; - } - - std::cout << message << std::endl; - - std::string line; - - SystemDialogResult result = SDR_OK; - - bool done = false; - while (!done) - { - switch (type) - { - case SDT_INFO: - case SDT_WARNING: - case SDT_ERROR: - std::cout << "Press ENTER to continue"; - break; - - case SDT_YES_NO: - std::cout << "Type 'Y' for Yes or 'N' for No"; - break; - - case SDT_OK_CANCEL: - std::cout << "Type 'O' for OK or 'C' for Cancel"; - break; - } - - std::getline(std::cin, line); - - switch (type) - { - case SDT_INFO: - case SDT_WARNING: - case SDT_ERROR: - done = true; - break; - - case SDT_YES_NO: - if (line == "Y" || line == "y") - { - result = SDR_YES; - done = true; - } - else if (line == "N" || line == "n") - { - result = SDR_NO; - done = true; - } - break; - - case SDT_OK_CANCEL: - if (line == "O" || line == "o") - { - done = true; - result = SDR_OK; - } - else if (line == "C" || line == "c") - { - done = true; - result = SDR_CANCEL; - } - break; - } - } - - return result; + return ConsoleSystemDialog(type, title, message); } - - -void GetCurrentTimeStamp_Other(SystemTimeStamp *stamp) +void CSystemUtilsOther::GetCurrentTimeStamp(SystemTimeStamp* stamp) { stamp->sdlTicks = SDL_GetTicks(); } -long long GetTimeStampExactResolution_Other() +long long int CSystemUtilsOther::GetTimeStampExactResolution() { return 1000000ll; } -long long TimeStampExactDiff_Other(SystemTimeStamp *before, SystemTimeStamp *after) +long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, SystemTimeStamp* after) const { return (after->sdlTicks - before->sdlTicks) * 1000000ll; } -- cgit v1.2.3-1-g7c22