Mac70
|
 |
«
Posted
2012-12-26 20:07:02 » |
|
Like in topic. Is there any way to make universal file loading and saving system that will work on any platform? I want to introduce save/load system for my game, but can't find any solution how to make it platform independent.
|
|
|
|
cylab
|
 |
«
Reply #1 - Posted
2012-12-26 20:20:34 » |
|
Google ObjectOutputStream, ObjectInputStream (java standard) or YAMLBeans and XSTREAM (Kryo might be worth a look, too) for third party solutions.
If you dont have local file access, you need to write a webapp that can handle a http-post request and writes the post data to a database like mysql. You can then use a UrlConnection and one of the above classes/libs to save and load your data.
|
Mathias - I Know What [you] Did Last Summer!
|
|
|
tyeeeee1
|
 |
«
Reply #2 - Posted
2012-12-26 20:27:23 » |
|
Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
HeroesGraveDev
|
 |
«
Reply #3 - Posted
2012-12-26 20:31:53 » |
|
Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Except you change the extension to keep out the n00b gremlins. 
|
|
|
|
HeroesGraveDev
|
 |
«
Reply #4 - Posted
2012-12-26 20:33:23 » |
|
Like in topic. Is there any way to make universal file loading and saving system that will work on any platform? I want to introduce save/load system for my game, but can't find any solution how to make it platform independent.
Maybe you should read the Java Tutorials again.
|
|
|
|
cylab
|
 |
«
Reply #5 - Posted
2012-12-26 20:45:56 » |
|
Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Dont use the game directory, since writing to it might get blocked on some OSes, create a subfolder under System.getProperty("user.home") and save there.
|
Mathias - I Know What [you] Did Last Summer!
|
|
|
HeroesGraveDev
|
 |
«
Reply #6 - Posted
2012-12-26 20:55:16 » |
|
Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Dont use the game directory, since writing to it might get blocked on some OSes, create a subfolder under System.getProperty("user.home") and save there. Depends where you put the game. If it is anywhere under your user folder, it will be fine. If it is in program files etc. it may fail.
|
|
|
|
theagentd
|
 |
«
Reply #7 - Posted
2012-12-26 21:10:12 » |
|
Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Dont use the game directory, since writing to it might get blocked on some OSes, create a subfolder under System.getProperty("user.home") and save there. Don't do that please. I hate when games pollute my user directory. It also makes it a huge pain in the ass to change custom settings or move save files between computers. -_-' I've seen some programs feature a "portable" mode. When off it uses the user home directory for storing settings and stuff, and with it on it stores settings in the same folder, making it "portable" by allowing you to move it onto a USB stick or so.
|
Myomyomyo.
|
|
|
sproingie
|
 |
«
Reply #8 - Posted
2012-12-26 21:23:19 » |
|
On windows, you put things in %APPDATA%, on Linux you use $XDG_DATA_HOME, which might not even be set and defaults to $HOME/.local/share. On OSX, no idea, and on Android there's a whole wealth of different options depending on whether it's cache, persistent, a database, etc which are explained here. There may be portable APIs for accessing files, but you're out of luck as far as portable conventions for where to put them.
|
|
|
|
Cero
|
 |
«
Reply #9 - Posted
2012-12-26 21:32:46 » |
|
Well if it's for a game then why don't just just save everything to a text file in the game directory, then for loading you could just load whatever is in the text file. That's how I'd do it anyway.
Dont use the game directory, since writing to it might get blocked on some OSes, create a subfolder under System.getProperty("user.home") and save there. Don't do that please. I hate when games pollute my user directory. It also makes it a huge pain in the ass to change custom settings or move save files between computers. -_-' I've seen some programs feature a "portable" mode. When off it uses the user home directory for storing settings and stuff, and with it on it stores settings in the same folder, making it "portable" by allowing you to move it onto a USB stick or so. There is no choice: Since Windows Vista you cannot write savefiles or other data to C, when typically your game is installed in program files; you HAVE to use APPDATA / user.home ...
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Longarmx
|
 |
«
Reply #10 - Posted
2012-12-26 22:21:15 » |
|
On OSX, no idea
OSX is Library/Application Support/
|
|
|
|
OttoMeier
|
 |
«
Reply #11 - Posted
2012-12-27 00:23:08 » |
|
|
|
|
|
BoBear2681
|
 |
«
Reply #12 - Posted
2012-12-27 02:35:59 » |
|
For desktop games, I'd second cylab's suggestion of looking into yamlbeans, or jsonbeans, or some other library that automatically serializes your objects into a concise, readable format (Externalizable and other XML solutions don't meet this requirement!). It'll prove invaluable when debugging. If you're concerned about the people hacking your save states (don't be), just gzip the output and give the file some extension like ".dat".
|
|
|
|
ReBirth
|
 |
«
Reply #13 - Posted
2012-12-27 02:43:13 » |
|
If you ask me. For desktop: same place as jar. For android: SD card.
|
|
|
|
HeroesGraveDev
|
 |
«
Reply #14 - Posted
2012-12-27 02:43:19 » |
|
Or you could hide a md5 checksum of the save file and if it doesn't match then warn the player that their save file is corrupted.
If it is corrupted, then it won't screw up the game for them (apart from losing their data) If it has been hacked, rhen they will most likely think they did something wrong and try again until they give up.
The again, who would bother implementing that just for this particular situation. Personally, I'd only do that if I was bored and had nothing better to do.
|
|
|
|
|