2014-02-10 09:10:30 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* dialogs.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 20:16:55 +08:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 09:10:30 +08:00
|
|
|
/*************************************************************************/
|
2020-01-01 18:16:22 +08:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 09:10:30 +08:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 07:50:27 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
#include "dialogs.h"
|
2020-03-07 01:00:16 +08:00
|
|
|
|
|
|
|
#include "core/os/keyboard.h"
|
2020-11-08 06:33:38 +08:00
|
|
|
#include "core/string/print_string.h"
|
|
|
|
#include "core/string/translation.h"
|
2014-02-10 09:10:30 +08:00
|
|
|
#include "line_edit.h"
|
|
|
|
|
2017-03-07 03:11:56 +08:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
#include "editor/editor_node.h"
|
2019-12-24 15:17:23 +08:00
|
|
|
#include "editor/editor_scale.h"
|
2020-03-04 09:51:12 +08:00
|
|
|
#include "scene/main/window.h" // Only used to check for more modals when dimming the editor.
|
2017-03-07 03:11:56 +08:00
|
|
|
#endif
|
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
// AcceptDialog
|
2017-05-03 04:13:12 +08:00
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
void AcceptDialog::_input_from_window(const Ref<InputEvent> &p_event) {
|
|
|
|
Ref<InputEventKey> key = p_event;
|
|
|
|
if (key.is_valid() && key->is_pressed() && key->get_keycode() == KEY_ESCAPE) {
|
|
|
|
_cancel_pressed();
|
2017-03-03 05:43:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
void AcceptDialog::_parent_focused() {
|
2020-07-01 01:01:10 +08:00
|
|
|
if (!is_exclusive()) {
|
|
|
|
_cancel_pressed();
|
|
|
|
}
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
void AcceptDialog::_notification(int p_what) {
|
|
|
|
switch (p_what) {
|
|
|
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
|
|
|
if (is_visible()) {
|
2020-12-15 02:37:30 +08:00
|
|
|
get_ok_button()->grab_focus();
|
2020-03-07 01:00:16 +08:00
|
|
|
_update_child_rects();
|
|
|
|
parent_visible = get_parent_visible_window();
|
|
|
|
if (parent_visible) {
|
|
|
|
parent_visible->connect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
|
2017-01-25 01:21:54 +08:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-07 01:00:16 +08:00
|
|
|
if (parent_visible) {
|
|
|
|
parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
|
2020-03-12 20:37:40 +08:00
|
|
|
parent_visible = nullptr;
|
2017-01-25 01:21:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
} break;
|
2019-08-05 00:42:46 +08:00
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
case NOTIFICATION_THEME_CHANGED: {
|
2020-03-12 20:37:40 +08:00
|
|
|
bg->add_theme_style_override("panel", bg->get_theme_stylebox("panel", "AcceptDialog"));
|
2017-03-07 03:11:56 +08:00
|
|
|
} break;
|
2019-08-05 00:42:46 +08:00
|
|
|
|
2020-03-12 20:37:40 +08:00
|
|
|
case NOTIFICATION_EXIT_TREE: {
|
|
|
|
if (parent_visible) {
|
|
|
|
parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
|
|
|
|
parent_visible = nullptr;
|
|
|
|
}
|
|
|
|
} break;
|
2020-03-07 01:00:16 +08:00
|
|
|
case NOTIFICATION_READY:
|
|
|
|
case NOTIFICATION_WM_SIZE_CHANGED: {
|
|
|
|
if (is_visible()) {
|
|
|
|
_update_child_rects();
|
2020-02-28 07:02:06 +08:00
|
|
|
}
|
2017-03-07 03:11:56 +08:00
|
|
|
} break;
|
2020-03-07 01:00:16 +08:00
|
|
|
case NOTIFICATION_WM_CLOSE_REQUEST: {
|
|
|
|
_cancel_pressed();
|
2019-08-05 00:42:46 +08:00
|
|
|
} break;
|
2016-03-09 07:00:52 +08:00
|
|
|
}
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
2020-02-28 05:49:16 +08:00
|
|
|
void AcceptDialog::_text_entered(const String &p_text) {
|
2014-02-10 09:10:30 +08:00
|
|
|
_ok_pressed();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AcceptDialog::_ok_pressed() {
|
2020-05-14 22:41:43 +08:00
|
|
|
if (hide_on_ok) {
|
2020-03-07 01:00:16 +08:00
|
|
|
set_visible(false);
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2014-02-10 09:10:30 +08:00
|
|
|
ok_pressed();
|
|
|
|
emit_signal("confirmed");
|
|
|
|
}
|
2020-02-28 05:49:16 +08:00
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
void AcceptDialog::_cancel_pressed() {
|
|
|
|
Window *parent_window = parent_visible;
|
|
|
|
if (parent_visible) {
|
|
|
|
parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
|
|
|
|
parent_visible = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
call_deferred("hide");
|
|
|
|
|
|
|
|
emit_signal("cancelled");
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
cancel_pressed();
|
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
if (parent_window) {
|
|
|
|
//parent_window->grab_focus();
|
|
|
|
}
|
2020-02-28 05:49:16 +08:00
|
|
|
}
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
String AcceptDialog::get_text() const {
|
|
|
|
return label->get_text();
|
|
|
|
}
|
2020-05-14 20:29:06 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void AcceptDialog::set_text(String p_text) {
|
|
|
|
label->set_text(p_text);
|
2020-03-07 01:00:16 +08:00
|
|
|
child_controls_changed();
|
|
|
|
if (is_visible()) {
|
|
|
|
_update_child_rects();
|
|
|
|
}
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AcceptDialog::set_hide_on_ok(bool p_hide) {
|
2017-03-05 23:44:50 +08:00
|
|
|
hide_on_ok = p_hide;
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
2020-05-14 20:29:06 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
bool AcceptDialog::get_hide_on_ok() const {
|
|
|
|
return hide_on_ok;
|
|
|
|
}
|
|
|
|
|
2019-03-25 07:21:32 +08:00
|
|
|
void AcceptDialog::set_autowrap(bool p_autowrap) {
|
|
|
|
label->set_autowrap(p_autowrap);
|
|
|
|
}
|
2020-05-14 20:29:06 +08:00
|
|
|
|
2019-03-25 07:21:32 +08:00
|
|
|
bool AcceptDialog::has_autowrap() {
|
|
|
|
return label->has_autowrap();
|
|
|
|
}
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void AcceptDialog::register_text_enter(Node *p_line_edit) {
|
|
|
|
ERR_FAIL_NULL(p_line_edit);
|
2019-12-27 19:08:49 +08:00
|
|
|
LineEdit *line_edit = Object::cast_to<LineEdit>(p_line_edit);
|
2020-05-14 22:41:43 +08:00
|
|
|
if (line_edit) {
|
2020-02-28 05:49:16 +08:00
|
|
|
line_edit->connect("text_entered", callable_mp(this, &AcceptDialog::_text_entered));
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
2017-01-10 12:49:55 +08:00
|
|
|
void AcceptDialog::_update_child_rects() {
|
2017-03-05 23:44:50 +08:00
|
|
|
Size2 label_size = label->get_minimum_size();
|
2016-10-31 02:42:30 +08:00
|
|
|
if (label->get_text().empty()) {
|
|
|
|
label_size.height = 0;
|
|
|
|
}
|
2020-03-12 20:37:40 +08:00
|
|
|
int margin = hbc->get_theme_constant("margin", "Dialogs");
|
2016-10-31 02:40:52 +08:00
|
|
|
Size2 size = get_size();
|
2016-05-30 11:28:29 +08:00
|
|
|
Size2 hminsize = hbc->get_combined_minimum_size();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Vector2 cpos(margin, margin + label_size.height);
|
|
|
|
Vector2 csize(size.x - margin * 2, size.y - margin * 3 - hminsize.y - label_size.height);
|
2016-05-30 11:28:29 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
for (int i = 0; i < get_child_count(); i++) {
|
2017-08-25 04:58:51 +08:00
|
|
|
Control *c = Object::cast_to<Control>(get_child(i));
|
2020-05-14 22:41:43 +08:00
|
|
|
if (!c) {
|
2017-01-10 12:49:55 +08:00
|
|
|
continue;
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2017-01-10 12:49:55 +08:00
|
|
|
|
2020-10-01 15:17:33 +08:00
|
|
|
if (c == hbc || c == label || c == bg || c->is_set_as_top_level()) {
|
2017-01-10 12:49:55 +08:00
|
|
|
continue;
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2017-01-10 12:49:55 +08:00
|
|
|
|
2017-03-29 23:29:38 +08:00
|
|
|
c->set_position(cpos);
|
2017-01-10 12:49:55 +08:00
|
|
|
c->set_size(csize);
|
2016-05-30 11:28:29 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
cpos.y += csize.y + margin;
|
|
|
|
csize.y = hminsize.y;
|
2016-05-30 11:28:29 +08:00
|
|
|
|
2017-03-29 23:29:38 +08:00
|
|
|
hbc->set_position(cpos);
|
2016-10-31 02:40:52 +08:00
|
|
|
hbc->set_size(csize);
|
2020-03-07 01:00:16 +08:00
|
|
|
|
|
|
|
bg->set_position(Point2());
|
|
|
|
bg->set_size(size);
|
2016-05-30 11:28:29 +08:00
|
|
|
}
|
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
Size2 AcceptDialog::_get_contents_minimum_size() const {
|
2020-03-12 20:37:40 +08:00
|
|
|
int margin = hbc->get_theme_constant("margin", "Dialogs");
|
2016-05-30 11:28:29 +08:00
|
|
|
Size2 minsize = label->get_combined_minimum_size();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
for (int i = 0; i < get_child_count(); i++) {
|
2017-08-25 04:58:51 +08:00
|
|
|
Control *c = Object::cast_to<Control>(get_child(i));
|
2020-05-14 22:41:43 +08:00
|
|
|
if (!c) {
|
2017-01-10 12:49:55 +08:00
|
|
|
continue;
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2017-01-10 12:49:55 +08:00
|
|
|
|
2020-10-01 15:17:33 +08:00
|
|
|
if (c == hbc || c == label || c->is_set_as_top_level()) {
|
2017-01-10 12:49:55 +08:00
|
|
|
continue;
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2017-01-10 12:49:55 +08:00
|
|
|
|
|
|
|
Size2 cminsize = c->get_combined_minimum_size();
|
2017-03-05 23:44:50 +08:00
|
|
|
minsize.x = MAX(cminsize.x, minsize.x);
|
|
|
|
minsize.y = MAX(cminsize.y, minsize.y);
|
2016-05-30 11:28:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Size2 hminsize = hbc->get_combined_minimum_size();
|
2017-03-05 23:44:50 +08:00
|
|
|
minsize.x = MAX(hminsize.x, minsize.x);
|
|
|
|
minsize.y += hminsize.y;
|
|
|
|
minsize.x += margin * 2;
|
|
|
|
minsize.y += margin * 3; //one as separation between hbc and child
|
2016-05-30 11:28:29 +08:00
|
|
|
|
2020-03-07 01:00:16 +08:00
|
|
|
Size2 wmsize = get_min_size();
|
2017-03-05 23:44:50 +08:00
|
|
|
minsize.x = MAX(wmsize.x, minsize.x);
|
2016-05-30 11:28:29 +08:00
|
|
|
return minsize;
|
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void AcceptDialog::_custom_action(const String &p_action) {
|
|
|
|
emit_signal("custom_action", p_action);
|
2014-02-10 09:10:30 +08:00
|
|
|
custom_action(p_action);
|
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Button *AcceptDialog::add_button(const String &p_text, bool p_right, const String &p_action) {
|
|
|
|
Button *button = memnew(Button);
|
2014-02-10 09:10:30 +08:00
|
|
|
button->set_text(p_text);
|
|
|
|
if (p_right) {
|
|
|
|
hbc->add_child(button);
|
|
|
|
hbc->add_spacer();
|
|
|
|
} else {
|
|
|
|
hbc->add_child(button);
|
2017-03-05 23:44:50 +08:00
|
|
|
hbc->move_child(button, 0);
|
2014-02-10 09:10:30 +08:00
|
|
|
hbc->add_spacer(true);
|
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
if (p_action != "") {
|
2020-02-22 01:28:45 +08:00
|
|
|
button->connect("pressed", callable_mp(this, &AcceptDialog::_custom_action), varray(p_action));
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
2020-12-15 02:37:30 +08:00
|
|
|
Button *AcceptDialog::add_cancel_button(const String &p_cancel) {
|
2014-02-10 09:10:30 +08:00
|
|
|
String c = p_cancel;
|
2020-05-14 22:41:43 +08:00
|
|
|
if (p_cancel == "") {
|
2017-03-05 23:44:50 +08:00
|
|
|
c = RTR("Cancel");
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2020-07-09 07:02:38 +08:00
|
|
|
Button *b = swap_cancel_ok ? add_button(c, true) : add_button(c);
|
2020-03-07 01:00:16 +08:00
|
|
|
b->connect("pressed", callable_mp(this, &AcceptDialog::_cancel_pressed));
|
2014-02-10 09:10:30 +08:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AcceptDialog::_bind_methods() {
|
2020-12-15 02:37:30 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("get_ok_button"), &AcceptDialog::get_ok_button);
|
2017-03-05 23:44:50 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("get_label"), &AcceptDialog::get_label);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_hide_on_ok", "enabled"), &AcceptDialog::set_hide_on_ok);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_hide_on_ok"), &AcceptDialog::get_hide_on_ok);
|
2017-08-09 19:19:41 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("add_button", "text", "right", "action"), &AcceptDialog::add_button, DEFVAL(false), DEFVAL(""));
|
2020-12-15 02:37:30 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("add_cancel_button", "name"), &AcceptDialog::add_cancel_button);
|
2017-08-09 19:19:41 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("register_text_enter", "line_edit"), &AcceptDialog::register_text_enter);
|
2017-03-05 23:44:50 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("set_text", "text"), &AcceptDialog::set_text);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_text"), &AcceptDialog::get_text);
|
2019-03-25 07:21:32 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("set_autowrap", "autowrap"), &AcceptDialog::set_autowrap);
|
|
|
|
ClassDB::bind_method(D_METHOD("has_autowrap"), &AcceptDialog::has_autowrap);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
ADD_SIGNAL(MethodInfo("confirmed"));
|
2020-03-07 01:00:16 +08:00
|
|
|
ADD_SIGNAL(MethodInfo("cancelled"));
|
2020-02-21 05:58:05 +08:00
|
|
|
ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING_NAME, "action")));
|
2015-11-21 05:25:01 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
ADD_GROUP("Dialog", "dialog");
|
2018-11-08 22:30:02 +08:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "dialog_text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text");
|
2017-03-05 23:44:50 +08:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"), "set_hide_on_ok", "get_hide_on_ok");
|
2019-03-25 07:21:32 +08:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_autowrap"), "set_autowrap", "has_autowrap");
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
2020-07-09 07:02:38 +08:00
|
|
|
bool AcceptDialog::swap_cancel_ok = false;
|
|
|
|
void AcceptDialog::set_swap_cancel_ok(bool p_swap) {
|
|
|
|
swap_cancel_ok = p_swap;
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
AcceptDialog::AcceptDialog() {
|
2020-03-07 01:00:16 +08:00
|
|
|
parent_visible = nullptr;
|
|
|
|
|
2020-03-12 20:37:40 +08:00
|
|
|
set_wrap_controls(true);
|
2020-03-07 01:00:16 +08:00
|
|
|
set_visible(false);
|
|
|
|
set_transient(true);
|
2020-07-01 01:01:10 +08:00
|
|
|
set_exclusive(true);
|
2020-07-01 23:39:42 +08:00
|
|
|
set_clamp_to_embedder(true);
|
2020-03-07 01:00:16 +08:00
|
|
|
|
|
|
|
bg = memnew(Panel);
|
|
|
|
add_child(bg);
|
|
|
|
|
|
|
|
hbc = memnew(HBoxContainer);
|
|
|
|
|
2020-03-12 20:37:40 +08:00
|
|
|
int margin = hbc->get_theme_constant("margin", "Dialogs");
|
|
|
|
int button_margin = hbc->get_theme_constant("button_margin", "Dialogs");
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
label = memnew(Label);
|
2020-03-07 01:00:16 +08:00
|
|
|
label->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
|
|
|
|
label->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END);
|
2017-03-05 23:44:50 +08:00
|
|
|
label->set_begin(Point2(margin, margin));
|
2017-07-06 15:16:27 +08:00
|
|
|
label->set_end(Point2(-margin, -button_margin - 10));
|
2014-02-10 09:10:30 +08:00
|
|
|
add_child(label);
|
|
|
|
|
|
|
|
add_child(hbc);
|
|
|
|
|
|
|
|
hbc->add_spacer();
|
2017-03-05 23:44:50 +08:00
|
|
|
ok = memnew(Button);
|
2016-05-30 17:01:56 +08:00
|
|
|
ok->set_text(RTR("OK"));
|
2014-02-10 09:10:30 +08:00
|
|
|
hbc->add_child(ok);
|
|
|
|
hbc->add_spacer();
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2020-02-22 01:28:45 +08:00
|
|
|
ok->connect("pressed", callable_mp(this, &AcceptDialog::_ok_pressed));
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
hide_on_ok = true;
|
2016-05-30 17:01:56 +08:00
|
|
|
set_title(RTR("Alert!"));
|
2020-03-07 01:00:16 +08:00
|
|
|
|
|
|
|
connect("window_input", callable_mp(this, &AcceptDialog::_input_from_window));
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
AcceptDialog::~AcceptDialog() {
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
2017-04-12 21:11:44 +08:00
|
|
|
// ConfirmationDialog
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void ConfirmationDialog::_bind_methods() {
|
2020-12-15 02:37:30 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("get_cancel_button"), &ConfirmationDialog::get_cancel_button);
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
2020-12-15 02:37:30 +08:00
|
|
|
Button *ConfirmationDialog::get_cancel_button() {
|
2014-02-10 09:10:30 +08:00
|
|
|
return cancel;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfirmationDialog::ConfirmationDialog() {
|
2016-05-30 17:01:56 +08:00
|
|
|
set_title(RTR("Please Confirm..."));
|
2017-07-19 03:35:37 +08:00
|
|
|
#ifdef TOOLS_ENABLED
|
2020-03-07 01:00:16 +08:00
|
|
|
set_min_size(Size2(200, 70) * EDSCALE);
|
2017-07-19 03:35:37 +08:00
|
|
|
#endif
|
2020-12-15 02:37:30 +08:00
|
|
|
cancel = add_cancel_button();
|
2014-02-10 09:10:30 +08:00
|
|
|
}
|