summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--atari/Makefile.target2
-rwxr-xr-xatari/misc.c8
-rw-r--r--atari/msgbox.c84
-rw-r--r--atari/msgbox.h10
4 files changed, 101 insertions, 3 deletions
diff --git a/atari/Makefile.target b/atari/Makefile.target
index 575610cac..ad908075b 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -81,7 +81,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
redrawslots.c encoding.c \
browser_win.c toolbar.c statusbar.c browser.c \
global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c
+ ctxmenu.c settings.c msgbox.c
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
diff --git a/atari/misc.c b/atari/misc.c
index 55b96120d..8b745fd2f 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -42,6 +42,7 @@
#include "atari/browser.h"
#include "atari/misc.h"
#include "atari/encoding.h"
+#include "atari/msgbox.h"
#include "cflib.h"
extern void * h_gem_rsrc;
@@ -57,12 +58,15 @@ void warn_user(const char *warning, const char *detail)
0) + ((detail != 0) ? strlen(detail) : 0);
char message[len];
snprintf(message, len, messages_get(warning), detail);
- printf("%s\n", message);
+
+ printf("%s\n", message);
+ msg_box_show(MSG_BOX_ALERT, message);
}
void die(const char *error)
-{
+{
printf("%s\n", error);
+ msg_box_show(MSG_BOX_ALERT, error);
exit(1);
}
diff --git a/atari/msgbox.c b/atari/msgbox.c
new file mode 100644
index 000000000..a9de5d299
--- /dev/null
+++ b/atari/msgbox.c
@@ -0,0 +1,84 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gem.h>
+#include "atari/msgbox.h"
+
+#ifndef min
+# define min(x,y) ((x<y) ? x : y )
+#endif
+
+short msg_box_show(short type, char * msg)
+{
+ #define MSG_BOX_STR_SIZE 256
+ short retval=0, i=0, z=0, l=0;
+ char c;
+ int len_msg = strlen(msg);
+
+ // TODO: localize strings
+ const char *str_yes = "Yes";
+ const char *str_no = "No";
+ const char *str_ok = "OK";
+ char msg_box_str[MSG_BOX_STR_SIZE];
+ char *dst = msg_box_str;
+
+ memset(msg_box_str, 0, MSG_BOX_STR_SIZE);
+
+ strncat(msg_box_str, "[1]", MSG_BOX_STR_SIZE);
+ strncat(msg_box_str, "[", MSG_BOX_STR_SIZE);
+
+ dst = msg_box_str + strlen(msg_box_str);
+
+ for (i=0; i<min(len_msg,40*5); i++) {
+
+ c = msg[i];
+
+ if(c==0)
+ break;
+
+ if (z==40) {
+ if(l==4){
+ break;
+ }
+ z = 0;
+ l++;
+ *dst = (char)'|';
+ dst++;
+ }
+
+ if ((c=='\r' || c=='\n') && *dst != '|') {
+ if(l==4){
+ break;
+ }
+ z = 0;
+ l++;
+ *dst = '|';
+ dst++;
+ }
+ else {
+ z++;
+ *dst = c;
+ dst++;
+ }
+ }
+ strncat(msg_box_str, "][", MSG_BOX_STR_SIZE);
+
+ if(type == MSG_BOX_CONFIRM){
+ strncat(msg_box_str, str_yes, MSG_BOX_STR_SIZE);
+ strncat(msg_box_str, "|", MSG_BOX_STR_SIZE);
+ strncat(msg_box_str, str_no, MSG_BOX_STR_SIZE);
+ } else {
+ strncat(msg_box_str, str_ok, MSG_BOX_STR_SIZE);
+ }
+ strncat(msg_box_str, "]", MSG_BOX_STR_SIZE);
+
+ retval = form_alert(type, msg_box_str);
+ if(type == MSG_BOX_CONFIRM){
+ if(retval != 1){
+ retval = 0;
+ }
+ }
+ return(retval);
+
+ #undef MSG_BOX_STR_SIZE
+}
diff --git a/atari/msgbox.h b/atari/msgbox.h
new file mode 100644
index 000000000..204a49050
--- /dev/null
+++ b/atari/msgbox.h
@@ -0,0 +1,10 @@
+#ifndef GUIMSG_H_INCLUDED
+#define GUIMSG_H_INCLUDED
+
+#define MSG_BOX_ALERT 1
+#define MSG_BOX_CONFIRM 2
+
+short msg_box_show(short type, char * msg);
+
+
+#endif // GUIMSG_H_INCLUDED