mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-05 06:14:36 +00:00
a1da5a5758
* Rewrite crash log file to contain more information * Detect host platform. * Suppress shouldHandleCursor spam * Fix bug where previous song's vocals are kept on new songs * Fix an issue where note snapping could go negative. --------- Co-authored-by: Cameron Taylor <cameron.taylor.ninja@gmail.com>
62 lines
1.3 KiB
Haxe
62 lines
1.3 KiB
Haxe
package funkin.util;
|
|
|
|
/**
|
|
* Utility functions related to specific platforms.
|
|
*/
|
|
class PlatformUtil
|
|
{
|
|
/**
|
|
* Returns true if the current platform is MacOS.
|
|
*
|
|
* NOTE: Only use this for choosing modifier keys for shortcut hints.
|
|
* @return Whether the current platform is MacOS, or HTML5 running on MacOS.
|
|
*/
|
|
public static function isMacOS():Bool
|
|
{
|
|
#if mac
|
|
return true;
|
|
#elseif html5
|
|
return js.Browser.window.navigator.platform.startsWith("Mac")
|
|
|| js.Browser.window.navigator.platform.startsWith("iPad")
|
|
|| js.Browser.window.navigator.platform.startsWith("iPhone");
|
|
#else
|
|
return false;
|
|
#end
|
|
}
|
|
|
|
/**
|
|
* Detects and returns the current host platform.
|
|
* Always returns `HTML5` on web, regardless of the computer running that browser.
|
|
* Returns `null` if the platform could not be detected.
|
|
*/
|
|
public static function detectHostPlatform():Null<HostPlatform>
|
|
{
|
|
#if html5
|
|
return HTML5;
|
|
#else
|
|
switch (Sys.systemName())
|
|
{
|
|
case ~/window/i.match(_) => true:
|
|
return WINDOWS;
|
|
case ~/linux/i.match(_) => true:
|
|
return LINUX;
|
|
case ~/mac/i.match(_) => true:
|
|
return MAC;
|
|
default:
|
|
return null;
|
|
}
|
|
#end
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Represents a host platform.
|
|
*/
|
|
enum HostPlatform
|
|
{
|
|
WINDOWS;
|
|
LINUX;
|
|
MAC;
|
|
HTML5;
|
|
}
|