Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (578)
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 9076 times)
0 Members and 1 Guest are viewing this topic.
Offline Z-Man
« Reply #30 - Posted 2012-08-14 23: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
Offline ra4king

JGO Kernel


Medals: 353
Projects: 3
Exp: 5 years


I'm the King!


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

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

Offline Z-Man
« Reply #32 - Posted 2012-08-15 02: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!
Legends of Yore - The Casual Retro Roguelike
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #33 - Posted 2012-08-15 07: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 08: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
« Reply #35 - Posted 2012-08-15 09: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 11: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

JGO Kernel


Medals: 202



« Reply #37 - Posted 2012-08-15 15: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 15: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: 17



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

or use File.separator
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


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

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

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


Offline ra4king

JGO Kernel


Medals: 353
Projects: 3
Exp: 5 years


I'm the King!


« Reply #41 - Posted 2012-08-15 20: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.

 

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

The first screenshot will be displayed as a thumbnail.

DarkCart (14 views)
2014-10-31 21:44:48

DarkCart (17 views)
2014-10-31 21:43:57

TehJavaDev (40 views)
2014-10-27 03:28:38

TehJavaDev (30 views)
2014-10-27 03:27:51

DarkCart (44 views)
2014-10-26 19:37:11

Luminem (26 views)
2014-10-26 10:17:50

Luminem (30 views)
2014-10-26 10:14:04

theagentd (36 views)
2014-10-25 15:46:29

Longarmx (64 views)
2014-10-17 03:59:02

Norakomi (62 views)
2014-10-16 15:22:06
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!