9 #include "net_multiplayer.h"
11 #include "interface.h"
12 #include "saveDialog.h"
19 #include "widget_label.h"
20 #include "widget_button.h"
21 #include "widget_textfield.h"
23 static image_t
*g_background
;
24 static bool_t activeSaveDialog
;
26 static widget_t
*widgetLabelMsg
;
27 static widget_t
*widgetTextFieldName
;
29 static widget_t
*widgetButtonSave
;
30 static widget_t
*widgetButtonBack
;
32 static void switchTerm()
34 if (activeSaveDialog
== TRUE
) {
35 activeSaveDialog
= FALSE
;
36 hot_key_unregister(SDLK_ESCAPE
);
38 activeSaveDialog
= TRUE
;
39 hot_key_register(SDLK_ESCAPE
, switchTerm
);
43 static void eventWidget(void *p
)
47 button
= (widget_t
*) p
;
49 if (button
== widgetButtonSave
) {
50 save_arena(text_field_get_text(widgetTextFieldName
), arena_get_current());
54 if (button
== widgetButtonBack
) {
59 static void hotkey_saveDialog()
64 void save_dialog_init()
66 activeSaveDialog
= FALSE
;
68 g_background
= image_get(IMAGE_GROUP_BASE
, "screen_main");
70 widgetLabelMsg
= label_new(_("Save as:"), SAVE_DIALOG_LOCATIN_X
+ 20,
71 SAVE_DIALOG_LOCATIN_Y
+ 20,
74 widgetTextFieldName
= text_field_new("", WIDGET_TEXTFIELD_FILTER_ALPHANUM
,
75 widgetLabelMsg
->x
+ widgetLabelMsg
->w
+ 10,
78 widgetButtonSave
= button_new(_("Save"), SAVE_DIALOG_LOCATIN_X
+ 20,
79 SAVE_DIALOG_LOCATIN_Y
+ 60,
82 widgetButtonBack
= button_new(_("Back"), SAVE_DIALOG_LOCATIN_X
+ 20 +
83 WIDGET_BUTTON_WIDTH
+ 20,
84 SAVE_DIALOG_LOCATIN_Y
+ 60,
87 hot_key_register(SDLK_F2
, hotkey_saveDialog
);
90 bool_t
save_dialog_is_active()
92 return activeSaveDialog
;
95 void save_dialog_draw()
97 if (activeSaveDialog
== FALSE
) {
101 image_draw(g_background
, SAVE_DIALOG_LOCATIN_X
,
102 SAVE_DIALOG_LOCATIN_Y
,
103 SAVE_DIALOG_LOCATIN_X
,
104 SAVE_DIALOG_LOCATIN_Y
,
108 label_draw(widgetLabelMsg
);
109 text_field_draw(widgetTextFieldName
);
110 button_draw(widgetButtonSave
);
111 button_draw(widgetButtonBack
);
114 void save_dialog_event()
116 if (activeSaveDialog
== FALSE
) {
120 text_field_event(widgetTextFieldName
);
121 button_event(widgetButtonSave
);
122 button_event(widgetButtonBack
);
126 void save_dialog_quit()
128 hot_key_unregister(SDLK_F2
);
130 label_destroy(widgetLabelMsg
);
131 text_field_destroy(widgetTextFieldName
);
132 button_destroy(widgetButtonSave
);
133 button_destroy(widgetButtonBack
);