Make window.alert simpler
This commit is contained in:
@@ -569,7 +569,7 @@ namespace nme {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
value lime_window_alert (value type, value title, value message) {
|
value lime_window_alert (value message, value title) {
|
||||||
|
|
||||||
#ifdef NME_SDL2
|
#ifdef NME_SDL2
|
||||||
|
|
||||||
@@ -596,30 +596,9 @@ namespace nme {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!val_is_null (title) && !val_is_null (message)) {
|
if (!val_is_null (message)) {
|
||||||
|
|
||||||
int flags = 0;
|
SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, val_is_null (title) ? "" : val_string (title), val_string (message), sdlWindow);
|
||||||
|
|
||||||
switch (val_int (type)) {
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
|
|
||||||
flags = SDL_MESSAGEBOX_WARNING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
|
|
||||||
flags = SDL_MESSAGEBOX_ERROR;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
flags = SDL_MESSAGEBOX_INFORMATION;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_ShowSimpleMessageBox (flags, val_string (title), val_string (message), sdlWindow);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,7 +609,7 @@ namespace nme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DEFINE_PRIM (lime_window_alert, 3);
|
DEFINE_PRIM (lime_window_alert, 2);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import lime.graphics.Image;
|
|||||||
import lime.system.Display;
|
import lime.system.Display;
|
||||||
import lime.system.System;
|
import lime.system.System;
|
||||||
import lime.ui.Window;
|
import lime.ui.Window;
|
||||||
import lime.ui.WindowAlertType;
|
|
||||||
|
|
||||||
@:access(lime.app.Application)
|
@:access(lime.app.Application)
|
||||||
@:access(lime.ui.Window)
|
@:access(lime.ui.Window)
|
||||||
@@ -29,7 +28,7 @@ class FlashWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function alert (type:WindowAlertType, title:String, message:String):Void {
|
public function alert (message:String, title:String):Void {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import lime.system.Display;
|
|||||||
import lime.system.System;
|
import lime.system.System;
|
||||||
import lime.ui.Touch;
|
import lime.ui.Touch;
|
||||||
import lime.ui.Window;
|
import lime.ui.Window;
|
||||||
import lime.ui.WindowAlertType;
|
|
||||||
|
|
||||||
#if (haxe_ver < 3.2)
|
#if (haxe_ver < 3.2)
|
||||||
typedef FocusEvent = js.html.Event;
|
typedef FocusEvent = js.html.Event;
|
||||||
@@ -68,7 +67,7 @@ class HTML5Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function alert (type:WindowAlertType, title:String, message:String):Void {
|
public function alert (message:String, title:String):Void {
|
||||||
|
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import lime.math.Vector2;
|
|||||||
import lime.system.Display;
|
import lime.system.Display;
|
||||||
import lime.system.System;
|
import lime.system.System;
|
||||||
import lime.ui.Window;
|
import lime.ui.Window;
|
||||||
import lime.ui.WindowAlertType;
|
|
||||||
|
|
||||||
#if !macro
|
#if !macro
|
||||||
@:build(lime.system.CFFI.build())
|
@:build(lime.system.CFFI.build())
|
||||||
@@ -33,19 +32,11 @@ class NativeWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function alert (type:WindowAlertType, title:String, message:String):Void {
|
public function alert (message:String, title:String):Void {
|
||||||
|
|
||||||
if (handle != null) {
|
if (handle != null) {
|
||||||
|
|
||||||
var nativeType = switch (type) {
|
lime_window_alert (handle, message, title);
|
||||||
|
|
||||||
case WARN: 1;
|
|
||||||
case ERROR: 2;
|
|
||||||
default: 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lime_window_alert (handle, nativeType, title, message);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +245,7 @@ class NativeWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@:cffi private static function lime_window_alert (handle:Float, type:Int, title:String, message:String):Void;
|
@:cffi private static function lime_window_alert (handle:Float, message:String, title:String):Void;
|
||||||
@:cffi private static function lime_window_close (handle:Float):Void;
|
@:cffi private static function lime_window_close (handle:Float):Void;
|
||||||
@:cffi private static function lime_window_create (application:Float, width:Int, height:Int, flags:Int, title:String):Float;
|
@:cffi private static function lime_window_create (application:Float, width:Int, height:Int, flags:Int, title:String):Float;
|
||||||
@:cffi private static function lime_window_focus (handle:Float):Void;
|
@:cffi private static function lime_window_focus (handle:Float):Void;
|
||||||
|
|||||||
@@ -93,11 +93,9 @@ class Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function alert (type:WindowAlertType = null, title:String = null, message:String = null):Void {
|
public function alert (message:String = null, title:String = null):Void {
|
||||||
|
|
||||||
if (type == null) type = WindowAlertType.INFO;
|
backend.alert (message, title);
|
||||||
|
|
||||||
backend.alert (type, title, message);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package lime.ui;
|
|
||||||
|
|
||||||
|
|
||||||
enum WindowAlertType {
|
|
||||||
|
|
||||||
INFO;
|
|
||||||
WARN;
|
|
||||||
ERROR;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@ namespace lime {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void Alert (int type, const char* title, const char* message) = 0;
|
virtual void Alert (const char* message, const char* title) = 0;
|
||||||
virtual void Close () = 0;
|
virtual void Close () = 0;
|
||||||
virtual void Focus () = 0;
|
virtual void Focus () = 0;
|
||||||
virtual bool GetEnableTextEvents () = 0;
|
virtual bool GetEnableTextEvents () = 0;
|
||||||
|
|||||||
@@ -1075,10 +1075,10 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void lime_window_alert (double window, int type, HxString title, HxString message) {
|
void lime_window_alert (double window, HxString message, HxString title) {
|
||||||
|
|
||||||
Window* targetWindow = (Window*)(intptr_t)window;
|
Window* targetWindow = (Window*)(intptr_t)window;
|
||||||
targetWindow->Alert (type, title.__s, message.__s);
|
targetWindow->Alert (message.__s, title.__s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1304,7 +1304,7 @@ namespace lime {
|
|||||||
DEFINE_PRIME2v (lime_text_layout_set_language);
|
DEFINE_PRIME2v (lime_text_layout_set_language);
|
||||||
DEFINE_PRIME2v (lime_text_layout_set_script);
|
DEFINE_PRIME2v (lime_text_layout_set_script);
|
||||||
DEFINE_PRIME2v (lime_touch_event_manager_register);
|
DEFINE_PRIME2v (lime_touch_event_manager_register);
|
||||||
DEFINE_PRIME4v (lime_window_alert);
|
DEFINE_PRIME3v (lime_window_alert);
|
||||||
DEFINE_PRIME1v (lime_window_close);
|
DEFINE_PRIME1v (lime_window_close);
|
||||||
DEFINE_PRIME5 (lime_window_create);
|
DEFINE_PRIME5 (lime_window_create);
|
||||||
DEFINE_PRIME2v (lime_window_event_manager_register);
|
DEFINE_PRIME2v (lime_window_event_manager_register);
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SDLWindow::Alert (int type, const char* title, const char* message) {
|
void SDLWindow::Alert (const char* message, const char* title) {
|
||||||
|
|
||||||
#ifdef HX_WINDOWS
|
#ifdef HX_WINDOWS
|
||||||
|
|
||||||
@@ -127,30 +127,9 @@ namespace lime {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (title && message) {
|
if (message) {
|
||||||
|
|
||||||
int flags = 0;
|
SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, title, message, sdlWindow);
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
|
|
||||||
flags = SDL_MESSAGEBOX_WARNING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
|
|
||||||
flags = SDL_MESSAGEBOX_ERROR;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
flags = SDL_MESSAGEBOX_INFORMATION;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_ShowSimpleMessageBox (flags, title, message, sdlWindow);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace lime {
|
|||||||
SDLWindow (Application* application, int width, int height, int flags, const char* title);
|
SDLWindow (Application* application, int width, int height, int flags, const char* title);
|
||||||
~SDLWindow ();
|
~SDLWindow ();
|
||||||
|
|
||||||
virtual void Alert (int type, const char* title, const char* message);
|
virtual void Alert (const char* message, const char* title);
|
||||||
virtual void Close ();
|
virtual void Close ();
|
||||||
virtual void Focus ();
|
virtual void Focus ();
|
||||||
virtual bool GetEnableTextEvents ();
|
virtual bool GetEnableTextEvents ();
|
||||||
|
|||||||
Reference in New Issue
Block a user