diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2013-03-24 00:03:37 +0100 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2013-03-24 12:00:12 +0100 |
commit | 195d6cded05f7ef5bde695ee047b341a0265eab3 (patch) | |
tree | af6ffa3622ae9bf7f2f5f065e269e86a019af854 /src/app/system_linux.cpp | |
parent | c211b001d2a4c9b36034a812650f1a2ac693ee54 (diff) | |
download | colobot-195d6cded05f7ef5bde695ee047b341a0265eab3.tar.gz colobot-195d6cded05f7ef5bde695ee047b341a0265eab3.tar.bz2 colobot-195d6cded05f7ef5bde695ee047b341a0265eab3.zip |
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
Diffstat (limited to 'src/app/system_linux.cpp')
-rw-r--r-- | src/app/system_linux.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/app/system_linux.cpp b/src/app/system_linux.cpp index cd785f8..619909d 100644 --- a/src/app/system_linux.cpp +++ b/src/app/system_linux.cpp @@ -17,11 +17,28 @@ #include "app/system_linux.h" +#include "common/logger.h" + #include <stdlib.h> -SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message) +void CSystemUtilsLinux::Init() { + m_zenityAvailable = true; + if (system("zenity --version") != 0) + { + m_zenityAvailable = false; + GetLogger()->Warn("Zenity not available, will fallback to console users dialogs.\n"); + } +} + +SystemDialogResult CSystemUtilsLinux::SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) +{ + if (!m_zenityAvailable) + { + return ConsoleSystemDialog(type, title, message); + } + std::string options = ""; switch (type) { @@ -62,17 +79,17 @@ SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& return result; } -void GetCurrentTimeStamp_Linux(SystemTimeStamp *stamp) +void CSystemUtilsLinux::GetCurrentTimeStamp(SystemTimeStamp *stamp) { clock_gettime(CLOCK_MONOTONIC_RAW, &stamp->clockTime); } -long long GetTimeStampExactResolution_Linux() +long long CSystemUtilsLinux::GetTimeStampExactResolution() { return 1ll; } -long long TimeStampExactDiff_Linux(SystemTimeStamp *before, SystemTimeStamp *after) +long long CSystemUtilsLinux::TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) { return (after->clockTime.tv_nsec - before->clockTime.tv_nsec) + (after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll; |