From 025bedecfb2c264b1f3d6a04de72160001173cc1 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Tue, 19 Mar 2013 23:07:39 +0100 Subject: Refactored platform-specific code Moved functions from .h to .cpp files --- src/app/system_linux.h | 71 ++++---------------------------------------------- 1 file changed, 5 insertions(+), 66 deletions(-) (limited to 'src/app/system_linux.h') diff --git a/src/app/system_linux.h b/src/app/system_linux.h index 69893de..bc07c31 100644 --- a/src/app/system_linux.h +++ b/src/app/system_linux.h @@ -20,20 +20,11 @@ * \brief Linux-specific implementation of system functions */ -/* NOTE: code is contained in this header; - * there is no separate .cpp module for simplicity */ +#include "app/system.h" #include -#include -#include -SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message); - -void GetCurrentTimeStamp_Linux(SystemTimeStamp *stamp); -long long GetTimeStampExactResolution_Linux(); -long long TimeStampExactDiff_Linux(SystemTimeStamp *before, SystemTimeStamp *after); - struct SystemTimeStamp { timespec clockTime; @@ -45,60 +36,8 @@ struct SystemTimeStamp }; -SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message) -{ - std::string options = ""; - switch (type) - { - case SDT_INFO: - default: - options = "--info"; - break; - case SDT_WARNING: - options = "--warning"; - break; - case SDT_ERROR: - options = "--error"; - break; - case SDT_YES_NO: - options = "--question --ok-label=\"Yes\" --cancel-label=\"No\""; - break; - case SDT_OK_CANCEL: - options = "--question --ok-label=\"OK\" --cancel-label=\"Cancel\""; - break; - } - - std::string command = "zenity " + options + " --text=\"" + message + "\" --title=\"" + title + "\""; - int code = system(command.c_str()); - - SystemDialogResult result = SDR_OK; - switch (type) - { - case SDT_YES_NO: - result = code ? SDR_NO : SDR_YES; - break; - case SDT_OK_CANCEL: - result = code ? SDR_CANCEL : SDR_OK; - break; - default: - break; - } - - return result; -} - -void GetCurrentTimeStamp_Linux(SystemTimeStamp *stamp) -{ - clock_gettime(CLOCK_MONOTONIC, &stamp->clockTime); -} - -long long GetTimeStampExactResolution_Linux() -{ - return 1ll; -} +SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message); -long long TimeStampExactDiff_Linux(SystemTimeStamp *before, SystemTimeStamp *after) -{ - return (after->clockTime.tv_nsec - before->clockTime.tv_nsec) + - (after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll; -} +void GetCurrentTimeStamp_Linux(SystemTimeStamp *stamp); +long long GetTimeStampExactResolution_Linux(); +long long TimeStampExactDiff_Linux(SystemTimeStamp *before, SystemTimeStamp *after); -- cgit v1.2.3-1-g7c22 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_linux.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/app/system_linux.h') diff --git a/src/app/system_linux.h b/src/app/system_linux.h index bc07c31..ba0d8cd 100644 --- a/src/app/system_linux.h +++ b/src/app/system_linux.h @@ -35,9 +35,17 @@ struct SystemTimeStamp } }; +class CSystemUtilsLinux : public CSystemUtils +{ +public: + virtual void Init() override; + + virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override; -SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message); + virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override; + virtual long long GetTimeStampExactResolution() override; + virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override; -void GetCurrentTimeStamp_Linux(SystemTimeStamp *stamp); -long long GetTimeStampExactResolution_Linux(); -long long TimeStampExactDiff_Linux(SystemTimeStamp *before, SystemTimeStamp *after); +private: + bool m_zenityAvailable; +}; -- cgit v1.2.3-1-g7c22 From 4c1a7057bbd24b4a57ba1ebfc72813d2f605479f Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Wed, 27 Mar 2013 10:28:06 +0100 Subject: Add Linux-specific savegame and profile settings according to the XDG Base Directory Specification http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html --- src/app/system_linux.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/app/system_linux.h') diff --git a/src/app/system_linux.h b/src/app/system_linux.h index ba0d8cd..a9a5a52 100644 --- a/src/app/system_linux.h +++ b/src/app/system_linux.h @@ -46,6 +46,9 @@ public: virtual long long GetTimeStampExactResolution() override; virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override; + virtual std::string profileFileLocation() override; + virtual std::string savegameDirectoryLocation() override; + private: bool m_zenityAvailable; }; -- cgit v1.2.3-1-g7c22