diff --git a/source/funkin/ui/debug/char/components/wizard/AddCharFilesDialog.hx b/source/funkin/ui/debug/char/components/wizard/AddCharFilesDialog.hx index dba55737ba..8374d8c059 100644 --- a/source/funkin/ui/debug/char/components/wizard/AddCharFilesDialog.hx +++ b/source/funkin/ui/debug/char/components/wizard/AddCharFilesDialog.hx @@ -82,7 +82,11 @@ class AddCharFilesDialog extends DefaultWizardDialog // check if the files even exist for (thingy in uploadBoxes) { - if (!FileUtil.doesFileExist(thingy.daField.text) && !openfl.Assets.exists(thingy.daField.text)) return false; + if (!FileUtil.doesFileExist(thingy.daField.text) && !openfl.Assets.exists(thingy.daField.text)) + { + CharCreatorUtil.error("Add Files", "Path: " + thingy.daField.text + " doesn't exist. Is the spelling correct?"); + return false; + } } // we do a little trollin @@ -101,12 +105,20 @@ class AddCharFilesDialog extends DefaultWizardDialog var xmlPath = uploadBox.daField.text.replace(".png", ".xml"); // checking if we even have the correct file types in the correct places - if (Path.extension(imgPath) != "png" || Path.extension(xmlPath) != "xml") return false; + if (Path.extension(imgPath) != "png" || Path.extension(xmlPath) != "xml") + { + CharCreatorUtil.error("Add Files", "The provided Path doesn't end with the supported format, (.png)."); + return false; + } // testing if we could actually use these var imgBytes = CharCreatorUtil.gimmeTheBytes(imgPath); var xmlBytes = CharCreatorUtil.gimmeTheBytes(xmlPath); - if (imgBytes == null || xmlBytes == null) return false; + if (imgBytes == null || xmlBytes == null) + { + CharCreatorUtil.error("Add Files", "Error retrieving Bytes from the given Path."); + return false; + } var tempSprite = new FlxSprite(); try @@ -116,6 +128,7 @@ class AddCharFilesDialog extends DefaultWizardDialog } catch (e) { + CharCreatorUtil.error("Add Files", "The provided Bytes cannot be used to make Character Frames."); tempSprite.destroy(); return false; } @@ -141,12 +154,20 @@ class AddCharFilesDialog extends DefaultWizardDialog var txtPath = uploadBoxes[0].daField.text.replace(".png", ".txt"); // checking if we even have the correct file types in the correct places - if (Path.extension(imgPath) != "png" || Path.extension(txtPath) != "txt") return false; + if (Path.extension(imgPath) != "png" || Path.extension(txtPath) != "txt") + { + CharCreatorUtil.error("Add Files", "The provided Path doesn't end with the supported format, (.png)."); + return false; + } // testing if we could actually use these var imgBytes = CharCreatorUtil.gimmeTheBytes(imgPath); var txtBytes = CharCreatorUtil.gimmeTheBytes(txtPath); - if (imgBytes == null || txtBytes == null) return false; + if (imgBytes == null || txtBytes == null) + { + CharCreatorUtil.error("Add Files", "Error retrieving Bytes from the given Path."); + return false; + } var tempSprite = new FlxSprite(); try @@ -156,6 +177,7 @@ class AddCharFilesDialog extends DefaultWizardDialog } catch (e) { + CharCreatorUtil.error("Add Files", "The provided Bytes cannot be used to make Character Frames."); tempSprite.destroy(); return false; } @@ -170,13 +192,25 @@ class AddCharFilesDialog extends DefaultWizardDialog var zipPath = uploadBoxes[0].daField.text; // checking if we even have the correct file types in the correct places - if (Path.extension(zipPath) != "zip") return false; + if (Path.extension(zipPath) != "zip") + { + CharCreatorUtil.error("Add Files", "The provided Path doesn't end with the supported format, (.zip)."); + return false; + } var zipBytes = CharCreatorUtil.gimmeTheBytes(zipPath); - if (zipBytes == null) return false; + if (zipBytes == null) + { + CharCreatorUtil.error("Add Files", "Error retrieving Bytes from the given Path."); + return false; + } var zipFiles = FileUtil.readZIPFromBytes(zipBytes); - if (zipFiles.length == 0) return false; + if (zipFiles.length == 0) + { + CharCreatorUtil.error("Add Files", "The provided .zip file has no content."); + return false; + } params.files = []; var hasAnimData:Bool = false; @@ -191,7 +225,11 @@ class AddCharFilesDialog extends DefaultWizardDialog { var fileData = entry.data.toString(); var animData:AnimAtlas = haxe.Json.parse(CharCreatorUtil.normalizeJSONText(fileData)); - if (animData == null) return false; + if (animData == null) + { + CharCreatorUtil.error("Add Files", "Error parsing the Animation.json File."); + return false; + } hasAnimData = true; } @@ -200,37 +238,41 @@ class AddCharFilesDialog extends DefaultWizardDialog { var fileData = entry.data.toString(); var spritemapData:AnimateAtlas = haxe.Json.parse(CharCreatorUtil.normalizeJSONText(fileData)); - if (spritemapData == null) return false; + if (spritemapData == null) + { + CharCreatorUtil.error("Add Files", "Error parsing the Spritemap.json File."); + return false; + } hasSpritemapData = true; } if (entry.fileName.startsWith("spritemap") && entry.fileName.endsWith(".png")) { - if (BitmapData.fromBytes(entry.data) == null) return false; + if (BitmapData.fromBytes(entry.data) == null) + { + CharCreatorUtil.error("Add Files", "Error parsing the Spritemap.png File."); + return false; + } hasImageData = true; } } if (hasAnimData && hasSpritemapData && hasImageData) params.files.push({name: zipPath, bytes: zipBytes}); - return hasAnimData && hasSpritemapData && hasImageData; + if (!(hasAnimData && hasSpritemapData && hasImageData)) + { + CharCreatorUtil.error("Add Files", "Insufficient amount of Files in the .zip File."); + return false; + } + + return true; default: return false; } return false; } - - function recursiveUploadBox():Void - { - var uploadBox = new UploadAssetsBox("Put the path to the Spritesheet Image here.", FileUtil.FILE_EXTENSION_INFO_PNG); - uploadBox.daField.onChange = _ -> { - uploadBox.daField.onChange = null; - recursiveUploadBox(); - }; - addAssetsBox.addComponent(uploadBox); - } } class AddAssetBox extends HBox diff --git a/source/funkin/ui/debug/char/components/wizard/ConfirmDialog.hx b/source/funkin/ui/debug/char/components/wizard/ConfirmDialog.hx index 8c6f0a4961..e2cfc6783e 100644 --- a/source/funkin/ui/debug/char/components/wizard/ConfirmDialog.hx +++ b/source/funkin/ui/debug/char/components/wizard/ConfirmDialog.hx @@ -27,5 +27,8 @@ class ConfirmDialog extends DefaultWizardDialog } override public function isNextStepAvailable() + { + CharCreatorUtil.info("Character Generating Wizard", "Generating Character based on the files..."); return true; + } } diff --git a/source/funkin/ui/debug/char/components/wizard/StartWizardDialog.hx b/source/funkin/ui/debug/char/components/wizard/StartWizardDialog.hx index 73626c486f..4b4f50b404 100644 --- a/source/funkin/ui/debug/char/components/wizard/StartWizardDialog.hx +++ b/source/funkin/ui/debug/char/components/wizard/StartWizardDialog.hx @@ -14,7 +14,19 @@ class StartWizardDialog extends DefaultWizardDialog override public function isNextStepAvailable() { - return ((params.generateCharacter || params.generatePlayerData) && params.characterID != ""); + if ((!params.generateCharacter || !params.generatePlayerData)) + { + CharCreatorUtil.error("Start", "Please choose to Generate at least one thing."); + return false; + } + + if (params.characterID == "") + { + CharCreatorUtil.error("Start", "Missing the Character ID."); + return false; + } + + return true; } override public function showDialog(modal:Bool = true) diff --git a/source/funkin/ui/debug/char/util/CharCreatorUtil.hx b/source/funkin/ui/debug/char/util/CharCreatorUtil.hx index bd6deaff9e..c74fe1df92 100644 --- a/source/funkin/ui/debug/char/util/CharCreatorUtil.hx +++ b/source/funkin/ui/debug/char/util/CharCreatorUtil.hx @@ -3,6 +3,8 @@ package funkin.ui.debug.char.util; import haxe.io.Path; import haxe.ui.core.Screen; import haxe.ui.focus.FocusManager; +import haxe.ui.notifications.NotificationType; +import haxe.ui.notifications.NotificationManager; class CharCreatorUtil { @@ -42,4 +44,24 @@ class CharCreatorUtil path = path.replace(cwd, ""); return !Path.isAbsolute(path) && path.indexOf(checkFor) != -1; } + + public static function error(title:String, body:String) + { + NotificationManager.instance.addNotification( + { + title: title, + body: body, + type: NotificationType.Error + }); + } + + public static function info(title:String, body:String) + { + NotificationManager.instance.addNotification( + { + title: title, + body: body, + type: NotificationType.Info + }); + } }