Make window.alert simpler

This commit is contained in:
Joshua Granick
2015-09-02 17:59:30 -07:00
parent dc919adccc
commit f618c4648a
10 changed files with 19 additions and 84 deletions

View File

@@ -569,7 +569,7 @@ namespace nme {
#endif
value lime_window_alert (value type, value title, value message) {
value lime_window_alert (value message, value title) {
#ifdef NME_SDL2
@@ -596,30 +596,9 @@ namespace nme {
#endif
if (!val_is_null (title) && !val_is_null (message)) {
if (!val_is_null (message)) {
int flags = 0;
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);
SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, val_is_null (title) ? "" : 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);
}

View File

@@ -9,7 +9,6 @@ import lime.graphics.Image;
import lime.system.Display;
import lime.system.System;
import lime.ui.Window;
import lime.ui.WindowAlertType;
@:access(lime.app.Application)
@: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 {

View File

@@ -21,7 +21,6 @@ import lime.system.Display;
import lime.system.System;
import lime.ui.Touch;
import lime.ui.Window;
import lime.ui.WindowAlertType;
#if (haxe_ver < 3.2)
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) {

View File

@@ -8,7 +8,6 @@ import lime.math.Vector2;
import lime.system.Display;
import lime.system.System;
import lime.ui.Window;
import lime.ui.WindowAlertType;
#if !macro
@: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) {
var nativeType = switch (type) {
case WARN: 1;
case ERROR: 2;
default: 0;
}
lime_window_alert (handle, nativeType, title, message);
lime_window_alert (handle, message, title);
}
@@ -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_create (application:Float, width:Int, height:Int, flags:Int, title:String):Float;
@:cffi private static function lime_window_focus (handle:Float):Void;

View File

@@ -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 (type, title, message);
backend.alert (message, title);
}

View File

@@ -1,10 +0,0 @@
package lime.ui;
enum WindowAlertType {
INFO;
WARN;
ERROR;
}

View File

@@ -19,7 +19,7 @@ namespace lime {
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 Focus () = 0;
virtual bool GetEnableTextEvents () = 0;

View File

@@ -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;
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_script);
DEFINE_PRIME2v (lime_touch_event_manager_register);
DEFINE_PRIME4v (lime_window_alert);
DEFINE_PRIME3v (lime_window_alert);
DEFINE_PRIME1v (lime_window_close);
DEFINE_PRIME5 (lime_window_create);
DEFINE_PRIME2v (lime_window_event_manager_register);

View File

@@ -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
@@ -127,30 +127,9 @@ namespace lime {
#endif
if (title && message) {
if (message) {
int flags = 0;
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);
SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, title, message, sdlWindow);
}

View File

@@ -17,7 +17,7 @@ namespace lime {
SDLWindow (Application* application, int width, int height, int flags, const char* title);
~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 Focus ();
virtual bool GetEnableTextEvents ();