Adds a popup on crash, wait for it to close to quit the game (#447)
This commit is contained in:
@@ -5,6 +5,10 @@ extends Node2D
|
||||
class_name ESCGame
|
||||
|
||||
|
||||
# Emitted when the user has confirmed the crash popup
|
||||
signal crash_popup_confirmed
|
||||
|
||||
|
||||
# Editor debug modes
|
||||
# NONE - No debugging
|
||||
# MOUSE_TOOLTIP_LIMITS - Visualize the tooltip limits
|
||||
@@ -303,3 +307,8 @@ func show_main_menu():
|
||||
# Hides the main menu. Reimplement to hide a specific UI.
|
||||
func hide_main_menu():
|
||||
pass
|
||||
|
||||
|
||||
# Shows the crash popup when a crash occurs
|
||||
func show_crash_popup() -> void:
|
||||
pass
|
||||
|
||||
@@ -105,15 +105,21 @@ func warning(string: String, args = []):
|
||||
if _get_log_level() >= LOG_WARNING and !crashed:
|
||||
var argsstr = str(args) if !args.empty() else ""
|
||||
_log("(W)\t" + string + " \t" + argsstr, true)
|
||||
|
||||
if ProjectSettings.get_setting("escoria/debug/terminate_on_warnings"):
|
||||
_perform_stack_trace_log()
|
||||
_log("%s\n- %s" % [
|
||||
ProjectSettings.get_setting("escoria/debug/crash_message"),
|
||||
log_file.get_path_absolute()
|
||||
])
|
||||
_perform_stack_trace_log()
|
||||
crashed = true
|
||||
escoria.quit()
|
||||
assert(false)
|
||||
|
||||
var files = "- %s" % log_file.get_path_absolute()
|
||||
var message = ProjectSettings.get_setting(
|
||||
"escoria/debug/crash_message"
|
||||
) % files
|
||||
|
||||
_log(message, true)
|
||||
|
||||
escoria.main.current_scene.game.show_crash_popup(
|
||||
[log_file.get_path_absolute()]
|
||||
)
|
||||
|
||||
|
||||
# Log an error message
|
||||
@@ -126,22 +132,28 @@ func error(string: String, args = [], do_savegame: bool = true):
|
||||
if _get_log_level() >= LOG_ERROR and !crashed:
|
||||
var argsstr = str(args) if !args.empty() else ""
|
||||
_log("(E)\t" + string + " \t" + argsstr, true)
|
||||
|
||||
if ProjectSettings.get_setting("escoria/debug/terminate_on_errors"):
|
||||
_perform_stack_trace_log()
|
||||
crashed = true
|
||||
if do_savegame:
|
||||
_perform_save_game_log()
|
||||
|
||||
_log("%s\n- %s\n- %s" % [
|
||||
ProjectSettings.get_setting("escoria/debug/crash_message"),
|
||||
|
||||
var files_to_send: Array = [
|
||||
log_file.get_path_absolute().get_base_dir().plus_file(
|
||||
escoria.save_manager.crash_savegame_filename.get_file()
|
||||
),
|
||||
log_file.get_path_absolute()
|
||||
])
|
||||
]
|
||||
|
||||
crashed = true
|
||||
escoria.quit()
|
||||
assert(false)
|
||||
var files = "- %s\n- %s" % files_to_send
|
||||
var message = ProjectSettings.get_setting(
|
||||
"escoria/debug/crash_message"
|
||||
) % files
|
||||
|
||||
_log(message, true)
|
||||
|
||||
escoria.main.current_scene.game.show_crash_popup(files_to_send)
|
||||
|
||||
|
||||
# Log a warning message about an ESC file
|
||||
|
||||
@@ -117,7 +117,7 @@ func _init():
|
||||
self.game_scene = resource_cache.get_resource(
|
||||
ProjectSettings.get_setting("escoria/ui/game_scene")
|
||||
).instance()
|
||||
|
||||
|
||||
|
||||
# Load settings
|
||||
func _ready():
|
||||
|
||||
@@ -40,11 +40,9 @@ func set_scene(p_scene: Node) -> void:
|
||||
if current_scene != null:
|
||||
clear_scene()
|
||||
|
||||
if p_scene.is_inside_tree() and p_scene.get_parent() != self:
|
||||
p_scene.get_parent().remove_child(p_scene)
|
||||
|
||||
add_child(p_scene)
|
||||
move_child(p_scene, 0)
|
||||
if not p_scene.is_inside_tree():
|
||||
add_child(p_scene)
|
||||
move_child(p_scene, 0)
|
||||
current_scene = p_scene
|
||||
check_game_scene_methods()
|
||||
|
||||
@@ -163,3 +161,4 @@ func check_game_scene_methods():
|
||||
assert(current_scene.game.has_method("show_ui"))
|
||||
assert(current_scene.game.has_method("_on_event_done"))
|
||||
|
||||
assert(current_scene.game.has_method("show_crash_popup"))
|
||||
|
||||
@@ -226,7 +226,7 @@ func set_escoria_debug_settings():
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/debug/crash_message",
|
||||
"We're sorry, but the game crashed. Please send us the " +
|
||||
"following files:\n"
|
||||
"following files:\n\n%s"
|
||||
)
|
||||
var property_info = {
|
||||
"name": "escoria/debug/crash_message",
|
||||
|
||||
@@ -226,9 +226,29 @@ func pause_game():
|
||||
escoria.main.current_scene.hide()
|
||||
escoria.set_game_paused(true)
|
||||
|
||||
|
||||
func _on_MenuButton_pressed() -> void:
|
||||
pause_game()
|
||||
|
||||
|
||||
func _on_action_finished() -> void:
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
|
||||
func show_crash_popup(files = []) -> void:
|
||||
connect("crash_popup_confirmed", escoria, "quit",
|
||||
[], CONNECT_ONESHOT)
|
||||
var crash_popup = AcceptDialog.new()
|
||||
crash_popup.popup_exclusive = true
|
||||
crash_popup.pause_mode = Node.PAUSE_MODE_PROCESS
|
||||
add_child(crash_popup)
|
||||
var files_to_send: String = ""
|
||||
for file in files:
|
||||
files_to_send += "- %s\n" % file
|
||||
crash_popup.dialog_text = tr(ProjectSettings.get_setting(
|
||||
"escoria/debug/crash_message")
|
||||
) % files_to_send
|
||||
crash_popup.popup_centered()
|
||||
escoria.set_game_paused(true)
|
||||
yield(crash_popup, "confirmed")
|
||||
emit_signal("crash_popup_confirmed")
|
||||
|
||||
@@ -209,3 +209,22 @@ func _on_action_finished():
|
||||
|
||||
func _on_MenuButton_pressed() -> void:
|
||||
pause_game()
|
||||
|
||||
|
||||
func show_crash_popup(files = []) -> void:
|
||||
connect("crash_popup_confirmed", escoria, "quit",
|
||||
[], CONNECT_ONESHOT)
|
||||
var crash_popup = AcceptDialog.new()
|
||||
crash_popup.popup_exclusive = true
|
||||
crash_popup.pause_mode = Node.PAUSE_MODE_PROCESS
|
||||
add_child(crash_popup)
|
||||
var files_to_send: String = ""
|
||||
for file in files:
|
||||
files_to_send += "- %s\n" % file
|
||||
crash_popup.dialog_text = tr(ProjectSettings.get_setting(
|
||||
"escoria/debug/crash_message")
|
||||
) % files_to_send
|
||||
crash_popup.popup_centered()
|
||||
escoria.set_game_paused(true)
|
||||
yield(crash_popup, "confirmed")
|
||||
emit_signal("crash_popup_confirmed")
|
||||
|
||||
Reference in New Issue
Block a user