1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Use error dialog instead of individual erro dialogs for when removing palettes

This commit is contained in:
OverloadedOrama 2020-05-20 01:31:38 +03:00
parent 067f5a6109
commit 2ebdf51047
6 changed files with 10 additions and 32 deletions

1
.gitignore vendored
View file

@ -15,5 +15,4 @@ mono_crash.*.json
.directory .directory
*~ *~
Translations/Update Translations.bat Translations/Update Translations.bat
Scripts/Old/

View file

@ -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://assets/themes/dark/theme.tres" type="Theme" id=1]
[ext_resource path="res://src/Main.gd" type="Script" id=2] [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/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://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/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://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/HorizontalRuler.gd" type="Script" id=14]
[ext_resource path="res://src/UI/Rulers/VerticalRuler.gd" type="Script" id=15] [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/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/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://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/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/BrushButton.tscn" type="PackedScene" id=26]
[ext_resource path="res://src/UI/Dialogs/SplashDialog.tscn" type="PackedScene" id=27] [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 margin_bottom = 62.0
window_title = "Alarm!" 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="."] [node name="LeftCursor" type="Sprite" parent="."]
visible = false visible = false

View file

@ -273,19 +273,24 @@ func get_best_palette_file_location(looking_paths: Array, fname: String): # ->
func remove_palette(palette_name : String) -> void: func remove_palette(palette_name : String) -> void:
# Don't allow user to remove palette if there is no one left # Don't allow user to remove palette if there is no one left
if Global.palettes.size() < 2: 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 return
# Don't allow user to try to remove not existing palettes # Don't allow user to try to remove not existing palettes
if not palette_name in Global.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 return
Global.directory_module.ensure_xdg_user_dirs_exist() Global.directory_module.ensure_xdg_user_dirs_exist()
var palette = Global.palettes[palette_name] var palette = Global.palettes[palette_name]
var result = palette.remove_file() var result = palette.remove_file()
# Inform user if pallete hasn't been removed from disk because of an error # Inform user if pallete hasn't been removed from disk because of an error
if result != OK: if result != OK:
get_node('/root/Control/PaletteRemoveErrorDialog').dialog_text %= str(result) Global.error_dialog.set_text(tr("An error occured while removing the palette! Error code: %s") % str(result))
get_node('/root/Control/PaletteRemoveErrorDialog').popup_centered() Global.error_dialog.popup_centered()
Global.dialog_open(true)
# Remove palette in the program anyway, because if you don't do it # Remove palette in the program anyway, because if you don't do it
# then Pixelorama will crash # then Pixelorama will crash
Global.palettes.erase(palette_name) Global.palettes.erase(palette_name)

View file

@ -1,5 +0,0 @@
[gd_scene format=2]
[node name="CantRemoveMorePalettesDialog" type="AcceptDialog"]
window_title = "Alarm!"
dialog_text = "You can't remove more palettes!"

View file

@ -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!"

View file

@ -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"