Page 1 of 1

On Exit Save!

Posted: June 6th, 2010, 3:51 pm
by Leo_V117
Hey guys... Its been a while since I sent you any code... My autosave code was a big Hit... but this one will be better...

Okay... Heres what you do... find your menus.cfg in the language folder... example: data/lang/en/menus.cfg

Locate this piece of code:

Code: Select all

main = [
	guilist [
		if (= $editing 1) [
			guilist [
				guibutton "Newmap"		"showgui newmap"
				guibutton "Savemap"		"showgui savemap"
				guibar
				guibutton "Test Map"		"edittoggle"
				guibar
	 			guibutton "New particle"	"showgui newparticles"
				guibutton "New light"		"showgui newlight"
				guibutton "New Mapmodel"	"showgui mapmodels"
				guibutton "Find Entities (F5)"	"showgui entfind"
				guibutton "Editing GUI"		"showgui editing"
				guibutton "Skybox menu (F4)"	"showgui skies"
				guibutton "Edit Materials"	"showgui materials"
				guibutton "Quickedit Menu (F3)"	"showquickgui"
				guibutton "Texture Menu (F2)"	"showtexgui"
			]
			guibar
		]
Directly below this part:

Code: Select all

				guibutton "Texture Menu (F2)"	"showtexgui"
add this:

Code: Select all

				guibutton "Quit"	[savemap $mapactionname; echo "Saving!"; sleep 4000 [echo "Saved!"]; sleep 5000 [quit]]	exit
Then save the file.

To test it. Open a new map and create a wall... then save it as "test_quit" and create another wall... select the new "quit" option directly below the "Texture Menu" option. Hopefully a message will show saying "Saving!" then, shortly afterwards... it will say "Saved!" and close the game...

Let me know what you think, it took a little tweaking here and there but it now works.

Inspired by GR1M.

Re: On Exit Save!

Posted: June 6th, 2010, 4:16 pm
by Runescapedj
srry, I haven't tested it yet, but can you make it so that it asks for overwriting (like when changing maps and forgot to save on another name before you quit, I can't see it in your code) and maybe you can make it automaticly overwrite when you save the same map as before, just only ask if you load a map or create a new map, so we don't have 2 much MB's of maps that're saved 2 much (I had a map with like 1000 saves, didn't overwrite, like 5 GB)
I really hope you get it and maybe you can change it,

Rune

Re: On Exit Save!

Posted: June 6th, 2010, 7:32 pm
by chocolatepie33
It's great, Leo. I was somewhat surprised, though, on how it just ended. Like when a program doesn't respond and it lags, then just quits, you know? But it's great.

Re: On Exit Save!

Posted: June 6th, 2010, 11:32 pm
by GR1M
Tear in my eye :') "Don't worry it's a happy tear".

Re: On Exit Save!

Posted: June 7th, 2010, 4:35 am
by Leo_V117
The "Lag" as you say is set to allow the map to save before the program quits. I tested it on a whole map, one that I didnt save since starting it... and it saved the entire thing before closing. So yeah... The "Lag" Is intentional. and as you said Runescapedj:
srry, I haven't tested it yet, but can you make it so that it asks for overwriting (like when changing maps and forgot to save on another name before you quit, I can't see it in your code) and maybe you can make it automaticly overwrite when you save the same map as before, just only ask if you load a map or create a new map, so we don't have 2 much MB's of maps that're saved 2 much (I had a map with like 1000 saves, didn't overwrite, like 5 GB)
I really hope you get it and maybe you can change it,
I can make it ask you whether you want to save it as what you set before it saves. just to prevent overwriting the map... although the large memory consumed isnt down to me... all you need to do is delete the *.BAK files. or even add them to a "Backup" folder in "packages/base/*new folder*".

But either way... Glad you like it.

Re: On Exit Save!

Posted: June 7th, 2010, 10:38 am
by Runescapedj
Yeah, maybe I should ask Mike, should I? (for 2.6)

Re: On Exit Save!

Posted: June 7th, 2010, 11:53 am
by Leo_V117
In addition to what RunescapeDJ said earlier...

Add this to the bottom of the "menus.cfg" in "data/lang/en":

Code: Select all

newgui Quit [
	guitext "Quit and Save Map with Current Settings?"
	guibutton (format "Save current map as %1" $mapactionname) [echo "Saving!"; savemap $mapactionname; sleep 4000 [echo "Saved!"]; sleep 5000 [quit]]	yes
	guibutton "No"	[showgui Save_Map]	exit
	guibar
	guibutton "Close"	[cleargui]	action
	]
]

newgui Save_Map [
	guitext "Save Map"
	guifield mapactionname -20
	guibar
	guibutton "Done!"	[showgui Quit]	action
	]
]
then replace this line:

Code: Select all

                guibutton "Quit"   [savemap $mapactionname; echo "Saving!"; sleep 4000 [echo "Saved!"]; sleep 5000 [quit]]   exit
With This:

Code: Select all

				guibutton "Quit"	[showgui Quit]	exit
Save it and test it.

Tell me what you think Now.

Re: On Exit Save!

Posted: June 7th, 2010, 12:15 pm
by arcones
I'll hopefully be trying out the first one today Leo! Tell ya what I think!