Etterna 0.75.1
Loading...
Searching...
No Matches
Core::Platform Namespace Reference

Classes

struct  Dimensions
 Platform-independent struct to store screen dimensions. More...

Functions

bool setConsoleEnabled (bool enable)
void init ()
std::string getSystem ()
 Determine the system name with the version number.
std::string getArchitecture ()
 Determine if the current system is 64bit or 32bit.
std::string getKernel ()
 Determine the current systems kernel type and version.
std::size_t getSystemMemory ()
 Determine the total amount of memory available on a system.
std::string getSystemCPU ()
 Get the system CPU information String should include CPU Manufacturer, Model, and Frequency.
std::string getSystemGPU ()
 Get the primary system GPU information String should include.
Dimensions getScreenDimensions ()
 Get the screen dimensions of the screen the game window is currently displayed on.
Dimensions getWindowDimensions ()
 Get the dimensions of the game window.
std::string getLanguage ()
 Get the users preferred language.
bool openWebsite (const std::string &url)
 Send a URL to be opened with the system's default web browser.
bool openFolder (const ghc::filesystem::path &path)
 Send a path to be opened with the system's default file browser.
std::string getClipboard ()
 Get contents of the system clipboard.
bool setClipboardText (std::string text)
 Set contents of sytem clipboard to provided text.
void setCursorVisible (bool value)
ghc::filesystem::path getExecutableDirectory ()
 Get the location of the binary.
ghc::filesystem::path getAppDirectory ()
 Get the base game directory. "The etterna folder".
bool isOtherInstanceRunning (int argc, char **argv)
bool boostPriority ()
bool unboostPriority ()
bool requestUserAttention ()

Detailed Description

This file is where functions which have a cross-platform implementation may be defined.

A namespace to hold all system specific tasks. Intended to be implemented once for each operating system/kernel.

All std::string types returned must be UTF-8.

Function Documentation

◆ getAppDirectory()

ghc::filesystem::path Core::Platform::getAppDirectory ( )

Get the base game directory. "The etterna folder".

This is the folder where the user chose to install the application. NOTE: This directory is retrieved based on the binary location.

  • Windows: Will return one directory up from binary location.
  • macOS and Linux: Will return same directory as getExecutableDirectory.

If the binary locations are changed, the functions and documentation must be changed accordingly.

Returns
A UTF-8 string of the directory containing the binary.

◆ getArchitecture()

std::string Core::Platform::getArchitecture ( )

Determine if the current system is 64bit or 32bit.

Returns
If 32bit, return "i386". If 64bit, return "x86".

◆ getClipboard()

std::string Core::Platform::getClipboard ( )

Get contents of the system clipboard.

Returns
UTF-8 clipboard contents, or an empty string if the the clipboard is a non-text type.

◆ getExecutableDirectory()

ghc::filesystem::path Core::Platform::getExecutableDirectory ( )

Get the location of the binary.

Returns
A UTF-8 string of the directory containing the binary.

◆ getKernel()

std::string Core::Platform::getKernel ( )

Determine the current systems kernel type and version.

  • Windows should return "Windows NT"
  • Linux should return "Linux Kernel <version number>"
  • Mac should return "Darwin"

◆ getLanguage()

std::string Core::Platform::getLanguage ( )

Get the users preferred language.

Returns
A 2-letter RFC-639 language code, using "en" as the default value.

◆ getScreenDimensions()

Dimensions Core::Platform::getScreenDimensions ( )

Get the screen dimensions of the screen the game window is currently displayed on.

Returns
A pair with the first being the width, and second, height

◆ getSystem()

std::string Core::Platform::getSystem ( )

Determine the system name with the version number.

  • Unix should return it's distributions name (Ubuntu 18.04, Debian 9, ArchLinux, Xubuntu...)
  • Windows should return "Windows 10"
  • Apple systems should return "macOS 10.15.4"

◆ getSystemGPU()

std::string Core::Platform::getSystemGPU ( )

Get the primary system GPU information String should include.

  • GPU Manufacturer
  • GPU Model
  • GPU Video RAM

◆ getSystemMemory()

std::size_t Core::Platform::getSystemMemory ( )

Determine the total amount of memory available on a system.

Returns
RAM in bytes

◆ getWindowDimensions()

Dimensions Core::Platform::getWindowDimensions ( )

Get the dimensions of the game window.

Returns
A pair with the first being the width, and second, height

◆ init()

void Core::Platform::init ( )

Run any desired initialization processes specific to a particular operating system.

◆ isOtherInstanceRunning()

bool Core::Platform::isOtherInstanceRunning ( int argc,
char ** argv )

Check if another instance of this application is already running

Parameters
argcargc from main
argvargv from main
Returns
True if other instance is running, False otherwise

◆ openFolder()

bool Core::Platform::openFolder ( const ghc::filesystem::path & path)

Send a path to be opened with the system's default file browser.

Parameters
pathPath to open
Returns
true if successful, false if unsuccessful.

◆ openWebsite()

bool Core::Platform::openWebsite ( const std::string & url)

Send a URL to be opened with the system's default web browser.

Parameters
urlURL to open
Returns
true if successful, false if unsuccessful.

◆ setClipboardText()

bool Core::Platform::setClipboardText ( std::string text)

Set contents of sytem clipboard to provided text.

Parameters
textText to set clipboard to
Returns
Whether the operation was performed succesfully

◆ setConsoleEnabled()

bool Core::Platform::setConsoleEnabled ( bool enable)

Enable or disable the system output console.

This is defined in Platform.cpp

Mac and Unix always have an associated console with the program, and can be seen depending on how the application is launched. This function is written for windows, which when linked with the /SUBSYSTEM:WINDOWS flag, needs a separate console to be allocated, and linked to the IO of this application.

Parameters
enableBoolean to enable or disable
Returns
True if successful.

◆ setCursorVisible()

void Core::Platform::setCursorVisible ( bool value)

Set if the mouse is visible or invisible

Parameters
valueTrue if visible mouse desired, false if not.