Add System.allowScreenTimeout

This commit is contained in:
Joshua Granick
2015-09-30 12:46:14 -07:00
parent f4438d85ac
commit a069328efb
4 changed files with 67 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ import sys.io.Process;
class System { class System {
public static var allowScreenTimeout (get, set):Bool;
public static var applicationDirectory (get, null):String; public static var applicationDirectory (get, null):String;
public static var applicationStorageDirectory (get, null):String; public static var applicationStorageDirectory (get, null):String;
public static var desktopDirectory (get, null):String; public static var desktopDirectory (get, null):String;
@@ -227,6 +228,28 @@ class System {
private static function get_allowScreenTimeout ():Bool {
#if ((cpp || neko || nodejs) && !macro)
return lime_system_get_allow_screen_timeout ();
#else
return true;
#end
}
private static function set_allowScreenTimeout (value:Bool):Bool {
#if ((cpp || neko || nodejs) && !macro)
return lime_system_set_allow_screen_timeout (value);
#else
return true;
#end
}
private static function get_applicationDirectory ():String { private static function get_applicationDirectory ():String {
#if ((cpp || neko || nodejs) && !macro) #if ((cpp || neko || nodejs) && !macro)
@@ -394,6 +417,8 @@ class System {
#if ((cpp || neko || nodejs) && !macro) #if ((cpp || neko || nodejs) && !macro)
@:cffi private static function lime_system_get_allow_screen_timeout ():Bool;
@:cffi private static function lime_system_set_allow_screen_timeout (value:Bool):Bool;
@:cffi private static function lime_system_get_directory (type:Int, company:String, title:String):Dynamic; @:cffi private static function lime_system_get_directory (type:Int, company:String, title:String):Dynamic;
@:cffi private static function lime_system_get_display (index:Int):Dynamic; @:cffi private static function lime_system_get_display (index:Int):Dynamic;
@:cffi private static function lime_system_get_num_displays ():Int; @:cffi private static function lime_system_get_num_displays ():Int;

View File

@@ -25,10 +25,12 @@ namespace lime {
public: public:
static bool GetAllowScreenTimeout ();
static const char* GetDirectory (SystemDirectory type, const char* company, const char* title); static const char* GetDirectory (SystemDirectory type, const char* company, const char* title);
static value GetDisplay (int id); static value GetDisplay (int id);
static int GetNumDisplays (); static int GetNumDisplays ();
static double GetTimer (); static double GetTimer ();
static bool SetAllowScreenTimeout (bool allow);
}; };

View File

@@ -1029,6 +1029,13 @@ namespace lime {
} }
bool lime_system_get_allow_screen_timeout () {
return System::GetAllowScreenTimeout ();
}
value lime_system_get_directory (int type, HxString company, HxString title) { value lime_system_get_directory (int type, HxString company, HxString title) {
const char* path = System::GetDirectory ((SystemDirectory)type, company.__s, title.__s); const char* path = System::GetDirectory ((SystemDirectory)type, company.__s, title.__s);
@@ -1058,6 +1065,13 @@ namespace lime {
} }
bool lime_system_set_allow_screen_timeout (bool allow) {
return System::SetAllowScreenTimeout (allow);
}
void lime_text_event_manager_register (value callback, value eventObject) { void lime_text_event_manager_register (value callback, value eventObject) {
TextEvent::callback = new AutoGCRoot (callback); TextEvent::callback = new AutoGCRoot (callback);
@@ -1359,10 +1373,12 @@ namespace lime {
DEFINE_PRIME1v (lime_renderer_unlock); DEFINE_PRIME1v (lime_renderer_unlock);
DEFINE_PRIME2v (lime_render_event_manager_register); DEFINE_PRIME2v (lime_render_event_manager_register);
DEFINE_PRIME2v (lime_sensor_event_manager_register); DEFINE_PRIME2v (lime_sensor_event_manager_register);
DEFINE_PRIME0 (lime_system_get_allow_screen_timeout);
DEFINE_PRIME3 (lime_system_get_directory); DEFINE_PRIME3 (lime_system_get_directory);
DEFINE_PRIME1 (lime_system_get_display); DEFINE_PRIME1 (lime_system_get_display);
DEFINE_PRIME0 (lime_system_get_num_displays); DEFINE_PRIME0 (lime_system_get_num_displays);
DEFINE_PRIME0 (lime_system_get_timer); DEFINE_PRIME0 (lime_system_get_timer);
DEFINE_PRIME1 (lime_system_set_allow_screen_timeout);
DEFINE_PRIME2v (lime_text_event_manager_register); DEFINE_PRIME2v (lime_text_event_manager_register);
DEFINE_PRIME3 (lime_text_layout_create); DEFINE_PRIME3 (lime_text_layout_create);
DEFINE_PRIME5 (lime_text_layout_position); DEFINE_PRIME5 (lime_text_layout_position);

View File

@@ -80,6 +80,13 @@ namespace lime {
} }
bool System::GetAllowScreenTimeout () {
return SDL_IsScreenSaverEnabled ();
}
const char* System::GetDirectory (SystemDirectory type, const char* company, const char* title) { const char* System::GetDirectory (SystemDirectory type, const char* company, const char* title) {
switch (type) { switch (type) {
@@ -312,6 +319,23 @@ namespace lime {
} }
bool System::SetAllowScreenTimeout (bool allow) {
if (allow) {
SDL_EnableScreenSaver ();
} else {
SDL_DisableScreenSaver ();
}
return allow;
}
FILE* FILE_HANDLE::getFile () { FILE* FILE_HANDLE::getFile () {
#ifndef HX_WINDOWS #ifndef HX_WINDOWS