Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Saved games on Windows 7  (Read 4720 times)
0 Members and 1 Guest are viewing this topic.
Offline fletchergames

Senior Devvie





« Posted 2009-12-14 17:53:28 »

I just got a computer with Windows 7.  I skipped over Vista entirely.

Where should my programs be storing saved games?  I had them going to the {user}/Application Data/ directory on XP.  On 7, it seems to get redirected to {user}/AppData/Roaming/ .  I have a directory called {user}/Saved Games/ on my computer, and I'm wondering if I'm supposed to use that.

In any case, I would be creating the subdirectory {company name}/{game name}/ within the directory I mentioned.  And the {user} part comes from the user.home System property.

What about Windows Vista? I've never actually used it, but I suspect it would use the same folder as Windows 7.

I can differentiate between OS's using the os.name System property.  I believe the three relevant options are: windows xp, windows vista, and windows 7 (I'm not sure about the case, but I always convert the resulting String to lowercase before checking it anyways).
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #1 - Posted 2009-12-14 18:54:53 »

Can you just use System.getProperty("user.home") or does that not work on Windows 7? It seems like they just change Application Data to AppData, so why not save it there? As long as it remains consistent per user, there's no problem.

See my work:
OTC Software
Offline fletchergames

Senior Devvie





« Reply #2 - Posted 2009-12-15 18:12:16 »

System.getProperty("user.home") gives me  C:\Users\Steven, and I just have to add \AppData\Roaming\ to get the right directory.  Somehow, even if I add \Application Data\, it still windws up in \AppData\Roaming\.

I'm going to use the Saved Games directory.  I assume that's what it's for, and that's where Purble Place (a game that comes with Windows) stores its saved games.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BoBear2681

JGO Coder


Medals: 19



« Reply #3 - Posted 2009-12-15 23:11:08 »

FWIW, I believe there is an %APPDATA% environment variable on Windows.  At work our applications write their data to a subdirectory of it using System.getenv("APPDATA");
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #4 - Posted 2009-12-16 00:16:58 »

System.getProperty("user.home") gives me  C:\Users\Steven, and I just have to add \AppData\Roaming\ to get the right directory.  Somehow, even if I add \Application Data\, it still windws up in \AppData\Roaming\.
Isn't that the compatibility layer? I think Vista and Win7 do some magic under the hood so that older apps written with XP in mind and are hardcoded to write into /ApplicationData/ end up writing into the correct place.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline fletchergames

Senior Devvie





« Reply #5 - Posted 2009-12-20 04:00:06 »

Isn't that the compatibility layer? I think Vista and Win7 do some magic under the hood so that older apps written with XP in mind and are hardcoded to write into /ApplicationData/ end up writing into the correct place.
I guess so.  I don't know and don't really know how to find out.

It seems rather arbitrary to change the folder from "ApplicationData" to "AppData" and then redirect "ApplicationData" to "AppData\Roaming".  In fact, I think it's pretty stupid, but Microsoft didn't ask for my opinion.

In any case, I'm going to write to the "Saved Games" folder until I find out that's wrong.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2009-12-20 05:56:18 »

"I asked for more things to be done behind the scenes, and now more things are done behind the scenes.

I am so the best."
 Roll Eyes

(PS if you don't get that then just look up the latest Windows 7 marketing angle)

See my work:
OTC Software
Offline Mr. Gol

Senior Devvie


Medals: 1



« Reply #7 - Posted 2009-12-20 11:31:14 »

FWIW, I believe there is an %APPDATA% environment variable on Windows.  At work our applications write their data to a subdirectory of it using System.getenv("APPDATA");

Correct, and this will point to the correct location on any version of Windows.
Offline bosun

Senior Newbie





« Reply #8 - Posted 2009-12-20 22:10:52 »

Writing to the "Saved Games" folder might not work too well on non-English versions of Windows. It might be better to go with appdata or the documents folder.

I suppose you can get at the "Saved Games" folder using native code if you think it's worth it.
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #9 - Posted 2009-12-21 07:27:14 »

On Vista:
1  
2  
3  
APPDATA=C:\Users\Alan\AppData\Roaming
LOCALAPPDATA=C:\Users\Alan\AppData\Local
TEMP=C:\Users\Alan\AppData\Local\Temp

I think the Roaming bit, probably defines what gets copied across on your roaming profile, using a windows network.  Most of the main players are saving data in here, including some of my pre-Vista legacy applications.  I also have the Saved Games Directory (not hidden unlike AppData).

Time flies like a bird. Fruit flies like a banana.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline fletchergames

Senior Devvie





« Reply #10 - Posted 2009-12-21 15:10:05 »

Writing to the "Saved Games" folder might not work too well on non-English versions of Windows. It might be better to go with appdata or the documents folder.

I suppose you can get at the "Saved Games" folder using native code if you think it's worth it.
http://en.wikipedia.org/wiki/Special_Folders seems to indicate that non-English versions have different names for all the folders.  It says something about this in the header above the table of special folders.  It doesn't explicitly say that all the folders have different names, but it seems like it would.
Offline Wrist Radar

Junior Newbie





« Reply #11 - Posted 2009-12-21 17:11:51 »

http://en.wikipedia.org/wiki/Special_Folders seems to indicate that non-English versions have different names for all the folders.  It says something about this in the header above the table of special folders.  It doesn't explicitly say that all the folders have different names, but it seems like it would.
correct: never use hard-coded paths because well-known paths change from one version of the operating system to another and they are internationalized as well; moreover, on Windows Vista and 7 well-known paths can be redirected to other directories.
when doing Win32 programming you should use the proper API functions to retrieve the actual paths, in Java you can use system properties such as "user.home"; you can also use environment variables hard-coded in your paths, but this wouldn't be system-portable (environment variable names are different on Linux, for instance).
Offline bosun

Senior Newbie





« Reply #12 - Posted 2009-12-21 19:59:49 »

And you can get the documents folder with

javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory()

(Does anyone know of a pure java way that doesn't include swing?)

The documents folder would be my choice for settings and savegames. -Not because I like that solution, but it seems to be the de-facto standard. At least every game I've ever installed seems to have thrown its stuff in there. Personally I would prefer to have savegames in a subfolder of the game such as c:\games\MyGame\savegames, so the ideal solution as far as I'm concerned is to give the user an option to choose where stuff goes.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #13 - Posted 2009-12-21 23:10:41 »

And you can get the documents folder with

javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory()

(Does anyone know of a pure java way that doesn't include swing?)

The documents folder would be my choice for settings and savegames. -Not because I like that solution, but it seems to be the de-facto standard. At least every game I've ever installed seems to have thrown its stuff in there. Personally I would prefer to have savegames in a subfolder of the game such as c:\games\MyGame\savegames, so the ideal solution as far as I'm concerned is to give the user an option to choose where stuff goes.

At least on Mac it makes more sense a lot of the time to put save games in user/Library/Application Support/ so that the user doesn't have to see that stuff. I personally get very annoyed when games put stuff in my Documents directory (or any app), because I use that as, well, my documents directory. Folders like Work, Games, Code Projects, etc. go in there. I hate it when it becomes populated by tens of folders for things I have no desire to ever go in. 99% of the time you only want to access a save game from within the application, and because of that it makes the most sense to keep it hidden unless the user asks for it.

And if they ask for it, you should either make it easy to find (put it in an expected place) or make it revealable from within the game. I am not a fan of people using "." directories for saves, because then I can't back up save files or delete data I no longer need.

See my work:
OTC Software
Offline bosun

Senior Newbie





« Reply #14 - Posted 2009-12-22 00:10:36 »

I agree it's annoying, and I too would prefer to have it more out of the way. But to me it's even more annoying to have stuff scattered across appdata/local, appdata/roaming, my home directory, my documents folder, documents/my games and god knows where else. At that point I find it more convenient to have any one location where I can find the savegames and settings or whatever else I need to back up or mess with. With appdata being hidden, subdivided and less used (by games) I feel documents is a better choice.

The documents folder isn't what I would have chosen as a dump location for games had it been my choice. But it wasn't, and for whatever reason most games seem to have appropriated the documents folder for their own use. It may be a suboptimal solution, but it seems best to go with what is currently common practice as default. -Though it would be nice if Sun would give us an easy way to get at the windows "known folders".

I'm not sure what you mean by "." directories.

But anyway, what is common practice regarding settings and savegames on Mac and Linux? And how do you get at those folders? Is user/Library/Application Support/  what you get with System.getenv("APPDATA") for instance?
Offline tom
« Reply #15 - Posted 2009-12-22 07:37:39 »

It's not possible to create folders in My Documents and related folders on windows from Java. Doesn't matter that much for save games. But is annoying if you create an application where you want the user decide where to put his files. Feel like the the Carol Beer character on Little Britain.

...computer says no!

Offline fletchergames

Senior Devvie





« Reply #16 - Posted 2009-12-22 16:47:31 »

It's not possible to create folders in My Documents and related folders on windows from Java. Doesn't matter that much for save games. But is annoying if you create an application where you want the user decide where to put his files. Feel like the the Carol Beer character on Little Britain.

...computer says no!
Strange, I've never had any problems creating folders there in Java.  Then again, I'm always running my programs as an administrator.  Maybe I should try running them as a guest.
Offline BoBear2681

JGO Coder


Medals: 19



« Reply #17 - Posted 2009-12-22 19:24:37 »

Quote
It's not possible to create folders in My Documents and related folders on windows from Java.

I'm pretty sure a standard user can write to their own "My Documents" folder from a Java application, but not to that of another user (which is true for all applications, not just Java-based ones).
Offline tom
« Reply #18 - Posted 2009-12-22 20:29:23 »

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4847375
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4939819

The problem is that windows tags the folders as special by making the folders read only. So not really Java's fault.

Offline BoBear2681

JGO Coder


Medals: 19



« Reply #19 - Posted 2009-12-22 21:21:04 »

Wow, I wasn't aware of that bug.  But I just tested to be sure and it appears that you actually can write to My Documents, it's just that File.canWrite() returns false.  So your app could just (rightly) assume it can write there and write its save file.  Smiley
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (28 views)
2014-12-15 09:26:44

Mr.CodeIt (19 views)
2014-12-14 19:50:38

BurntPizza (35 views)
2014-12-09 22:41:13

BurntPizza (70 views)
2014-12-08 04:46:31

JscottyBieshaar (32 views)
2014-12-05 12:39:02

SHC (44 views)
2014-12-03 16:27:13

CopyableCougar4 (40 views)
2014-11-29 21:32:03

toopeicgaming1999 (108 views)
2014-11-26 15:22:04

toopeicgaming1999 (94 views)
2014-11-26 15:20:36

toopeicgaming1999 (29 views)
2014-11-26 15:20:08
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!