From 2ebdf510478adb9b7e8845aec0902a2966b941a7 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 20 May 2020 01:31:38 +0300 Subject: [PATCH] Use error dialog instead of individual erro dialogs for when removing palettes --- .gitignore | 1 - src/Main.tscn | 11 +---------- src/Palette/PaletteContainer.gd | 13 +++++++++---- src/UI/Dialogs/CantRemoveMorePalettesDialog.tscn | 5 ----- src/UI/Dialogs/PaletteDoesntExistDialog.tscn | 5 ----- src/UI/Dialogs/PaletteRemoveErrorDialog.tscn | 7 ------- 6 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 src/UI/Dialogs/CantRemoveMorePalettesDialog.tscn delete mode 100644 src/UI/Dialogs/PaletteDoesntExistDialog.tscn delete mode 100644 src/UI/Dialogs/PaletteRemoveErrorDialog.tscn diff --git a/.gitignore b/.gitignore index 44ef949b6..a77af6a13 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,4 @@ mono_crash.*.json .directory *~ Translations/Update Translations.bat -Scripts/Old/ diff --git a/src/Main.tscn b/src/Main.tscn index 820d0a888..625d60608 100644 --- a/src/Main.tscn +++ b/src/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=50 format=2] +[gd_scene load_steps=47 format=2] [ext_resource path="res://assets/themes/dark/theme.tres" type="Theme" id=1] [ext_resource path="res://src/Main.gd" type="Script" id=2] @@ -10,8 +10,6 @@ [ext_resource path="res://assets/graphics/dark_themes/tools/colorpicker.png" type="Texture" id=8] [ext_resource path="res://assets/graphics/dark_themes/tools/bucket.png" type="Texture" id=9] [ext_resource path="res://src/UI/ColorAndToolOptions.tscn" type="PackedScene" id=10] -[ext_resource path="res://src/UI/Dialogs/PaletteRemoveErrorDialog.tscn" type="PackedScene" id=11] -[ext_resource path="res://src/UI/Dialogs/PaletteDoesntExistDialog.tscn" type="PackedScene" id=12] [ext_resource path="res://assets/themes/dark/ruler_style.tres" type="StyleBox" id=13] [ext_resource path="res://src/UI/Rulers/HorizontalRuler.gd" type="Script" id=14] [ext_resource path="res://src/UI/Rulers/VerticalRuler.gd" type="Script" id=15] @@ -23,7 +21,6 @@ [ext_resource path="res://assets/graphics/dark_themes/palette/edit_palette.png" type="Texture" id=21] [ext_resource path="res://assets/graphics/dark_themes/palette/add_palette.png" type="Texture" id=22] [ext_resource path="res://assets/graphics/dark_themes/tools/zoom.png" type="Texture" id=23] -[ext_resource path="res://src/UI/Dialogs/CantRemoveMorePalettesDialog.tscn" type="PackedScene" id=24] [ext_resource path="res://src/Palette/PaletteContainer.gd" type="Script" id=25] [ext_resource path="res://src/UI/BrushButton.tscn" type="PackedScene" id=26] [ext_resource path="res://src/UI/Dialogs/SplashDialog.tscn" type="PackedScene" id=27] @@ -871,12 +868,6 @@ margin_bottom = 62.0 margin_bottom = 62.0 window_title = "Alarm!" -[node name="CantRemoveMorePalettesDialog" parent="." instance=ExtResource( 24 )] - -[node name="PaletteDoesntExistDialog" parent="." instance=ExtResource( 12 )] - -[node name="PaletteRemoveErrorDialog" parent="." instance=ExtResource( 11 )] - [node name="LeftCursor" type="Sprite" parent="."] visible = false diff --git a/src/Palette/PaletteContainer.gd b/src/Palette/PaletteContainer.gd index 7996d3c82..dd0ec0ec4 100644 --- a/src/Palette/PaletteContainer.gd +++ b/src/Palette/PaletteContainer.gd @@ -273,19 +273,24 @@ func get_best_palette_file_location(looking_paths: Array, fname: String): # -> func remove_palette(palette_name : String) -> void: # Don't allow user to remove palette if there is no one left if Global.palettes.size() < 2: - get_node('/root/Control/CantRemoveMorePalettesDialog').popup_centered() + Global.error_dialog.set_text("You can't remove more palettes!") + Global.error_dialog.popup_centered() + Global.dialog_open(true) return # Don't allow user to try to remove not existing palettes if not palette_name in Global.palettes: - get_node('/root/Control/PaletteDoesntExistDialog').popup_centered() + Global.error_dialog.set_text("Cannot remove the palette, because it doesn't exist!") + Global.error_dialog.popup_centered() + Global.dialog_open(true) return Global.directory_module.ensure_xdg_user_dirs_exist() var palette = Global.palettes[palette_name] var result = palette.remove_file() # Inform user if pallete hasn't been removed from disk because of an error if result != OK: - get_node('/root/Control/PaletteRemoveErrorDialog').dialog_text %= str(result) - get_node('/root/Control/PaletteRemoveErrorDialog').popup_centered() + Global.error_dialog.set_text(tr("An error occured while removing the palette! Error code: %s") % str(result)) + Global.error_dialog.popup_centered() + Global.dialog_open(true) # Remove palette in the program anyway, because if you don't do it # then Pixelorama will crash Global.palettes.erase(palette_name) diff --git a/src/UI/Dialogs/CantRemoveMorePalettesDialog.tscn b/src/UI/Dialogs/CantRemoveMorePalettesDialog.tscn deleted file mode 100644 index a83ba9c06..000000000 --- a/src/UI/Dialogs/CantRemoveMorePalettesDialog.tscn +++ /dev/null @@ -1,5 +0,0 @@ -[gd_scene format=2] - -[node name="CantRemoveMorePalettesDialog" type="AcceptDialog"] -window_title = "Alarm!" -dialog_text = "You can't remove more palettes!" diff --git a/src/UI/Dialogs/PaletteDoesntExistDialog.tscn b/src/UI/Dialogs/PaletteDoesntExistDialog.tscn deleted file mode 100644 index 360b41a47..000000000 --- a/src/UI/Dialogs/PaletteDoesntExistDialog.tscn +++ /dev/null @@ -1,5 +0,0 @@ -[gd_scene format=2] - -[node name="PaletteDoesntExistDialog" type="AcceptDialog"] -window_title = "Alarm!" -dialog_text = "Cannot remove the palette, because it doesn't exist!" diff --git a/src/UI/Dialogs/PaletteRemoveErrorDialog.tscn b/src/UI/Dialogs/PaletteRemoveErrorDialog.tscn deleted file mode 100644 index cb8cf9412..000000000 --- a/src/UI/Dialogs/PaletteRemoveErrorDialog.tscn +++ /dev/null @@ -1,7 +0,0 @@ -[gd_scene format=2] - -[node name="PaletteRemoveErrorDialog" type="AcceptDialog"] -margin_right = 90.0 -margin_bottom = 58.0 -window_title = "Alarm!" -dialog_text = "An error occured while removing the palette! Error code: %s"