Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Creating a cross-platform launcher  (Read 4569 times)
0 Members and 1 Guest are viewing this topic.
Offline Z-Man

Senior Member


Medals: 8



« Reply #30 - Posted 2012-08-15 01:20:07 »

I don't know about XP but on Windows 7 this works great:
1  
2  
3  
if(os.startsWith("Win")) {
    saveFolder = System.getenv("AppData") + "\" gameName + "\";
}

Oh wow I didn't know there was a 'getenv' method. That's basically doing %APPDATA% which resolves to the correct location for XP, Vista and 7.

Exactly Grin I managed to track down something like this for Linux-based OSes through some googlefu. Unfortunately, I didn't have any luck with OSX. For Linux you'd do something like this:
1  
2  
3  
4  
5  
6  
7  
if(os.contains("Linux")) // Can someone on a Linux distro test this part?
{
   saveFolder = System.getenv("XDG_DATA_HOME");
   if(saveFolder == null)
      saveFolder = System.getProperty("user.home") + "/.local/share";
   saveFolder += "/" + gameName + "/";
}

Apparently Linux splits config (options) and data (saves) into two separate locations, i.e. $XDG_CONFIG_HOME and $XDG_DATA_HOME. I'd probably just pick one or the other out of laziness Tongue
Online ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #31 - Posted 2012-08-15 03:17:02 »

For Linux and Mac OS X, the user.home + ".<name>" is all you need.

Offline Z-Man

Senior Member


Medals: 8



« Reply #32 - Posted 2012-08-15 04:21:40 »

For Linux and Mac OS X, the user.home + ".<name>" is all you need.
The point isn't "all you need", the point is trying to follow the standards for whatever OS your program is running on. You could put your save in C:\Users\ZMan\GameName\player1.sv and call it good, but instead we put it in %AppData%\GameName\player1.sv because it's cleaner and is what is expected on Windows. If you don't care about that then ya, user.home + gameName works just fine. I was just looking for an AppData equivalent on Linux/OSX.
Games published by our own members! Check 'em out!
Try the Free Demo of Revenge of the Titans
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #33 - Posted 2012-08-15 09:36:14 »

For Linux and Mac OS X, the user.home + ".<name>" is all you need.
The point isn't "all you need", the point is trying to follow the standards for whatever OS your program is running on. You could put your save in C:\Users\ZMan\GameName\player1.sv and call it good, but instead we put it in %AppData%\GameName\player1.sv because it's cleaner and is what is expected on Windows. If you don't care about that then ya, user.home + gameName works just fine. I was just looking for an AppData equivalent on Linux/OSX.

While we're on the topic of standards, and expected behaviour; there's one that I *hate*.

<rant>

When games/applications put binary data (usually some sort of save file) in the designated documents folder. My Documents on XP, Documents on Vista/7/8, user.home/Documents on linux. And you can't even relocate the data half the time without breaking the associated app. Its a super irritating habit that too many devs have. Thats what the %appdata% folder is *for* !!!

</rant>

Offline Damocles
« Reply #34 - Posted 2012-08-15 10:26:02 »

for cross platform applications, always determine the file-seperator!
1  
String fileSeperator = System.getProperty("file.separator");


dont just use " / " or " \" thingies for pathnames.

Offline gouessej

JGO Ninja


Medals: 33
Projects: 1


TUER


« Reply #35 - Posted 2012-08-15 11:10:13 »

I don't know about XP but on Windows 7 this works great:
1  
2  
3  
if(os.startsWith("Win")) {
    saveFolder = System.getenv("AppData") + "\" gameName + "\";
}

Oh wow I didn't know there was a 'getenv' method. That's basically doing %APPDATA% which resolves to the correct location for XP, Vista and 7.

Exactly Grin I managed to track down something like this for Linux-based OSes through some googlefu. Unfortunately, I didn't have any luck with OSX. For Linux you'd do something like this:
1  
2  
3  
4  
5  
6  
7  
if(os.contains("Linux")) // Can someone on a Linux distro test this part?
{
   saveFolder = System.getenv("XDG_DATA_HOME");
   if(saveFolder == null)
      saveFolder = System.getProperty("user.home") + "/.local/share";
   saveFolder += "/" + gameName + "/";
}

Apparently Linux splits config (options) and data (saves) into two separate locations, i.e. $XDG_CONFIG_HOME and $XDG_DATA_HOME. I'd probably just pick one or the other out of laziness Tongue
XDG_DATA_HOME and XDG_CONFIG_HOME are not correctly defined on all Linux distros, it depends on the window manager.

Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #36 - Posted 2012-08-15 13:25:35 »

for cross platform applications, always determine the file-seperator!
1  
String fileSeperator = System.getProperty("file.separator");


dont just use " / " or " \" thingies for pathnames.


Ooooh, thats a great little tidbit!

Offline sproingie
« Reply #37 - Posted 2012-08-15 17:34:57 »

Forward slash works as a separator on every single interesting platform that Java runs on, including every version of windows.  You only need the separator if you're generating names that will go into a .bat file or sent to explorer.exe or something else that deliberately doesn't understand forward slashes.

Offline Cero
« Reply #38 - Posted 2012-08-15 17:36:54 »

Forward slash works as a separator on every single interesting platform that Java runs on, including every version of windows.  You only need the separator if you're generating names that will go into a .bat file or sent to explorer.exe or something else that deliberately doesn't understand forward slashes.

yeah System.getProperty("file.separator") is pretty useless, I always just use /

Offline loom_weaver

JGO Coder


Medals: 16



« Reply #39 - Posted 2012-08-15 18:13:50 »

or use File.separator
Games published by our own members! Check 'em out!
Try the Free Demo of Titan Attacks
Offline noblemaster

JGO Ninja


Medals: 15
Projects: 7


Age of Conquest makes your day!


« Reply #40 - Posted 2012-08-15 18:22:11 »

It's under ~/.config/<package-name> on Ubuntu.

Ubuntu App Developer Guide:
http://developer.ubuntu.com/publish/my-apps-packages/


Online ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #41 - Posted 2012-08-15 22:47:58 »

Yeah, there's no point in using File.separator or that getProperty one, just use forward slash everything.

Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (35 views)
2013-05-17 21:29:12

alaslipknot (44 views)
2013-05-16 21:24:48

gouessej (73 views)
2013-05-16 00:53:38

gouessej (73 views)
2013-05-16 00:17:58

theagentd (81 views)
2013-05-15 15:01:13

theagentd (75 views)
2013-05-15 15:00:54

StreetDoggy (117 views)
2013-05-14 15:56:26

kutucuk (141 views)
2013-05-12 17:10:36

kutucuk (141 views)
2013-05-12 15:36:09

UnluckyDevil (151 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.169 seconds with 21 queries.