-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prompt when importing conflicting asset names #7177
Comments
I will begin implementing this addon today hopefully. |
"a textbox that is auto filled with what it would have been renamed to without the addon", this doesn't make sense when uploading multiple files. I suggest no textbox and instead there's just an option to rename. |
Here's my research notes on how everything works:
I really don't want the addon to do it's own check for duplicates, as that adds redundancy. If we can use the result of the VM's name duplication check directly it will be better. With this in mind, here's my idea: pseudo code: conflictQueue = []
// this called higher up and we don't want to pollute it
// for costume in costumes {
// file.onLoad(()=>createNewCostume(costume);
// }
function addCostumeAt(costume, choice=None) {
// Check for renames.
if (renameRequired && choice == None) {
const conflict = (args, (choice) =>{addCostumeAt(costume, choice)})
conflictQueue.push(conflict);
if(conflictQueue.length==1){
dequeueConflictModal();
}
return true;
} else if ( renameRequired){
switch (choice) {
case 'skip':
// Skip this costume
return;
case 'replace':
// Delete conflicting and proceed
break;
default:
pass;
}
}
// Rest of logic for costume creation
}
function dequeueConflictModal(callback) {
[args, callback] = conflictQueue.shift()
// Create and display modal using 'args' which calls 'callback' with choice when user submits dialog
if(conflictQueue){
dequeueConflictModal();
}
} |
This can also happen when importing sprites, and also when renaming any costumes. A much simpler way that wouldn't require overriding all those functions would be to override StringUtil.unusedName, but I don't think that that's accessible from the outside. |
Even we could pollute it, it's not enough. The very act of replacing requires us to delete an existing costume, or alternatively to change it's costume object instead of adding a new one but either way polluting this isn't going to solve that. I am not going to do this for importing sprites as it's too much work and not useful. Same goes for renaming. |
|
I don't think you understand what is required here. We must replace the costume/sound object. That is just a dumb util function to get the first unused name in a list of names. It's clearly the wrong function to pollute. |
Code is written, will begin debugging and hopefully testing tomorrow. |
Am I misunderstanding what this is about? Isn't this exactly about overriding |
The OP wants to be able to skip, replace or rename the asset. Overriding |
Ah, I see, sorry. |
The addon implementation is getting closer to done, but it's definitely far from easy like I first thought it would be. |
I just realized I need to be polluting vm.addCostume() and vm.addSound() instead of the lower level things since they'll break if they think a costume/sound has been added but it actually hasn't. Also I need to handle which costume to select if no costume was added, and when to call emitProjectChanged or emitTargetsUpdate |
Why this would be helpful
When importing a bunch of assets into a project the user might not want them to be renamed automatically.
How this addon works
The addon would prompt the user to cancel/skip, replace or rename the asset with a textbox that is auto filled with what it would have been renamed to without the addon. Importing multiple files would add a checkbox to apply to all.
Basically just a file manager conflict dialog.
Possible alternatives
No response
Additional context
Closed PR: #7168
The text was updated successfully, but these errors were encountered: