minetest / minetest

Minetest is an open source voxel game-creation platform with easy modding and game creation
https://www.minetest.net/
Other
10.64k stars 2.01k forks source link

Renaming worlds using menu #10147

Open BruceMustache opened 4 years ago

BruceMustache commented 4 years ago

Problem

Currently I have to go to my worlds folder and rename the map name folder and then restart minetest to change the name of a world ie: It's good to add a friendly way to rename a world so then most users can use it Ex: Renaming a world using GUI is much faster

Solutions

Add a graphical way to rename worlds

sirrobzeroone commented 4 years ago

Bruce, I had a play around with this and have adjusted dlg_config_world.lua for minetest 5.2 and 5.3 . I only have access to win10 to test but I think I've made the code os independent but I'll try and do some linux testing later. Anyways treat these as highly experimental and I'm only a beginner coder (hmm scripter might be better). I oblivioned one of my worlds mid-development so backup your worlds before testing this - mis-typed a metric fortunately it was a world i made for testing.

I retained all rules the create screen had which was basically none...so it will accept strange symbols. Access the name change functionality on the configure screen from the main menu. Edit - forgot to say the code also wont let you name a world an existing name or rather it shouldn't, you'll get a little error msg which I borrowed from the create screen.

If everything looks semi-okay from your view I'll see if I can raise a pull request and see if it's possible to get it officially merged. Please do check it out carefully at one point I think i changed a worlds name and update mod status and I thought the name remained unchanged but when I retried that case it worked so it may have been something else. More eyes and brains who do testing the better :)

EDIT Do not use these bugged see lower down - left for completeness dlg_config_world_5_2.txt dlg_config_world_5_3.txt

BruceMustache commented 4 years ago

Nice work @sirrobzeroone It's work well on my linux mint flatpak installation of minetest 5.3 All my building continues in the world

video: https://streamable.com/ycxaha

But if I press enter on text field a get a error messaged as you can see in the video I hope this get accepted to master

sirrobzeroone commented 4 years ago

Hey thanks for the video, I'll see if I can sort that enter issue. I get slightly different behavior when hitting enter but none the less odd and not very useful.

I think i see the issue - My suspicion is it's throwing the error as no mods are highlighted on the right and enter normally does an enable/disable event and I think I may have "stolen focus" at least for Linux I get something slightly different for windows10 but I think the fix is to put the initial load focus back onto the mods list.

I'll have a play around, thanks for checking it out so quickly :)

sirrobzeroone commented 4 years ago

Nasty little bug that one, although took me longer to get my virtual machine back up and running with latest ubuntu install and then muddle my way through the linux file structure, than to replicate, track and fix.

Explanation (for the record/interest as Ill forget myself :) ) I don't know why but on linux if a user has never clicked a mod on the configure screen then "selected_mod == 0". I am not sure why but on windows10 at least this never occurs as top mod in the list always seems selected. I also noted once I had clicked a mod in the right list the client then seemed happy rembering that value whatever that was. I think my code addition exposed this as I can only assume this has always happened its just that since there was no enable/disable tickbox present as no mod was selected to run the block of code to show them that then pressing enter did nothing. Were as by adding a txt field enter now registers as key press and triggers the above little crash/error. /Explanation

I added a small check around the on enter keypress which just checks that "selected_mod ~= 0". This fix's the immediate crash although Im not 100% happy with that solution as it would be better if on config screen load in the right hand sub-pane mod list the top mod is just selected similar to windows which would remove the issue and save the check.

Anyways new version of the dlg file attached which hopefully squashes the bug, now I know your using 5.3 Bruce I just did that dlg file :)

dlg_config_world_5_3.txt

BruceMustache commented 4 years ago

I test that and don't like the enter key behaviour video: https://streamable.com/cp5zq2 As you can see in the video if you select a mod and hit enter they will toggle selected mod Also if no mod is selected the enter key does nothing Can you make the behaviour of enter more like "save" button

sirrobzeroone commented 4 years ago

Hey Bruce, oddly I think thats the default normal behavior for enabled/disabled I find it a little strange myself but its definitely coded that way and what I get when testing without any of the adjustments I made - although it is very inconsistent in win10, if I don't click mod list pane it does nothing if I do click it enables/disables (Just checked Linux/MT and same behaviour). From what I can gather its best to keep PR's very tight so I think changing that would need to be a second PR, dont know Im only new and just what I gather from reading PR comments etc.

I trawled through the PR's last night as I was actually quiet surprised at the allowed character set for creating a worldname as that basically = folder name at the OS level and stumbled on this: https://github.com/minetest/minetest/pull/9432

Looks like it will be happening soon-ish I'd guess from were its at approval-wise. Don't know what that would mean for renaming as my changes above basically circumvent all that hardwork so I'm not sure how likely it is to get up but ill try it.

BruceMustache commented 4 years ago

In my opinion enter should have the same behaviour as "save" while space can toggle selected mod

paramat commented 4 years ago

Do users often change world names? Seems a fairly rare thing to do, and doing this manually in file system is not a problem. Just not sure this is worth doing =) (remember simplicity).

sirrobzeroone commented 4 years ago

Im easy, for me the challenge of the coding and figuring things out is the interesting bit.

v-rob commented 4 years ago

I've changed world names, e.g. when I make a test world with some random name and then decide that I like the landscape. Usually, I use the file manager, but this isn't ideal because a) newer or less technical users might not know how to do this and b) #9432 would make using the filesystem harder due to sanitized names.