Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OSystem Struct Reference

#include <OSystem.hxx>

+ Collaboration diagram for OSystem:

Public Types

enum  Type {
  Type::unknown, Type::windows, Type::unix, Type::linux,
  Type::macos, Type::bsd, Type::haiku, Type::beos,
  Type::android
}
 

Static Public Member Functions

static void error (const std::string &title, const std::string &text)
 
static void openUrl (const std::string &url, const std::string &prefix="")
 
static void openDir (const std::string &path, const std::string &prefix="")
 
static bool is (Type type)
 
static bool isAndroid ()
 
static bool isLinux ()
 
static bool isUnix ()
 
static bool isMac ()
 
static bool isWindows ()
 

Detailed Description

Definition at line 6 of file OSystem.hxx.

Member Enumeration Documentation

◆ Type

enum OSystem::Type
strong
Enumerator
unknown 
windows 
unix 
linux 
macos 
bsd 
haiku 
beos 
android 

Definition at line 8 of file OSystem.hxx.

9  {
10  unknown,
11  windows,
12  unix,
13  linux,
14  macos,
15  bsd,
16  haiku,
17  beos,
18  android
19  };

Member Function Documentation

◆ error()

void OSystem::error ( const std::string title,
const std::string text 
)
static

Definition at line 34 of file OSystem.cxx.

35 {
36 #if defined(CYTOPIA_PLATFORM_LINUX)
37  const char *dialogCommand = getDialogCommand();
38  if (dialogCommand)
39  {
40  std::string command = dialogCommand;
41  command += " --title \"" + title + "\" --msgbox \"" + text + "\"";
42  int syserror = ::system(command.c_str());
43  if (syserror)
44  {
45  LOG(LOG_DEBUG) << "WARNING: Cant execute command " << command;
46  }
47  }
48 
49  // fail-safe method here, using stdio perhaps, depends on your application
50 #elif defined(CYTOPIA_PLATFORM_WIN)
51  MessageBox(nullptr, text.c_str(), title.c_str(), MB_OK | MB_ICONERROR);
52 #endif
53 }

◆ is()

bool OSystem::is ( OSystem::Type  type)
static

Definition at line 88 of file OSystem.cxx.

89 {
90 #define RETURN_TRUE(t) \
91  if (type == t) \
92  return true;
93 
94 #ifdef CYTOPIA_PLATFORM_WIN
96 #endif
97 
98 #ifdef CYTOPIA_PLATFORM_LINUX
100 #endif
101 
102 #ifdef CYTOPIA_PLATFORM_UNIX
104 #endif
105 
106 #ifdef CYTOPIA_PLATFORM_ANDROID
108 #endif
109 
110 #ifdef CYTOPIA_PLATFORM_MACOSX
112 #endif
113 
114 #ifdef CYTOPIA_PLATFORM_XBSD
116 #endif
117 
118 #ifdef CYTOPIA_PLATFORM_HAIKU
120 #endif
121 
122 #ifdef CYTOPIA_PLATFORM_BEOS
124 #endif
125 
126  return false;
127 }
+ Here is the caller graph for this function:

◆ isAndroid()

bool OSystem::isAndroid ( )
static

Definition at line 129 of file OSystem.cxx.

129 { return is(Type::android); }
+ Here is the call graph for this function:

◆ isLinux()

bool OSystem::isLinux ( )
static

Definition at line 130 of file OSystem.cxx.

130 { return is(Type::linux); }
+ Here is the call graph for this function:

◆ isMac()

bool OSystem::isMac ( )
static

Definition at line 132 of file OSystem.cxx.

132 { return is(Type::macos); }
+ Here is the call graph for this function:

◆ isUnix()

bool OSystem::isUnix ( )
static

Definition at line 131 of file OSystem.cxx.

131 { return is(Type::unix); }
+ Here is the call graph for this function:

◆ isWindows()

bool OSystem::isWindows ( )
static

Definition at line 133 of file OSystem.cxx.

133 { return is(Type::windows); }
+ Here is the call graph for this function:

◆ openDir()

void OSystem::openDir ( const std::string path,
const std::string prefix = "" 
)
static

Definition at line 71 of file OSystem.cxx.

72 {
73  std::string command;
74 
75 #ifdef CYTOPIA_PLATFORM_LINUX
76  command = prefix + "nautilus '" + path + "' &";
77  ::system(command.c_str());
78 #elif defined(CYTOPIA_PLATFORM_WIN)
79  ShellExecute(GetDesktopWindow(), "open", path.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
80 
81 #elif defined(CYTOPIA_PLATFORM_MACOSX)
82  command = "open \"" + path + "\" &";
83  ::system(command.c_str());
84 
85 #endif
86 }
+ Here is the caller graph for this function:

◆ openUrl()

void OSystem::openUrl ( const std::string url,
const std::string prefix = "" 
)
static

Definition at line 55 of file OSystem.cxx.

56 {
57 #ifdef CYTOPIA_PLATFORM_LINUX
58  std::string command = prefix + "xdg-open '" + url + "'";
59  LOG(LOG_DEBUG) << command;
60  ::system(command.c_str());
61 
62 #elif defined(CYTOPIA_PLATFORM_WIN)
63  ShellExecuteA(0, "Open", url.c_str(), 0, 0, SW_SHOW);
64 
65 #elif defined(CYTOPIA_PLATFORM_MACOSX)
66  std::string command = "open \"" + url + "\" &";
67  ::system(command.c_str());
68 #endif
69 }

The documentation for this struct was generated from the following files:
RETURN_TRUE
#define RETURN_TRUE(t)
OSystem::is
static bool is(Type type)
Definition: OSystem.cxx:88
LOG
Definition: LOG.hxx:32
OSystem::Type::macos
@ macos
OSystem::Type::android
@ android
OSystem::Type::bsd
@ bsd
LOG_DEBUG
@ LOG_DEBUG
Definition: LOG.hxx:26
OSystem::Type::beos
@ beos
OSystem::Type::unix
@ unix
OSystem::Type::windows
@ windows
OSystem::Type::linux
@ linux
OSystem::Type::haiku
@ haiku
string
std::string string
Definition: AudioConfig.hxx:14