fna-workbench

fna-workbench Commit Details


Date:2016-01-13 13:54:19 (9 years 7 months ago)
Author:Ethan Lee
Branch:master
Commit:64a5c503d34d6fdb9bd4f7f6c31b7b3a3c00a3d8
Parents: 4cdcfa49d2e36ab060e1e53545c78f0559435458
Message:Moving some things into GamePlatform...

Changes:

File differences

src/GamePlatform.cs
307307
308308
309309
310
311
312
313
310314
311315
312316
internal abstract Keys GetKeyFromScancode(Keys scancode);
internal abstract string GetStorageRoot();
internal abstract bool IsStoragePathConnected(string path);
#endregion
#region Private Methods
src/SDL2/SDL2_GamePlatform.cs
861861
862862
863863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
864926
865927
866928
return SDL2_KeyboardUtil.KeyFromScancode(scancode);
}
internal override string GetStorageRoot()
{
if (OSVersion.Equals("Windows"))
{
return Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"SavedGames"
);
}
if (OSVersion.Equals("Mac OS X"))
{
string osConfigDir = Environment.GetEnvironmentVariable("HOME");
if (String.IsNullOrEmpty(osConfigDir))
{
return "."; // Oh well.
}
osConfigDir += "/Library/Application Support";
return osConfigDir;
}
if (OSVersion.Equals("Linux"))
{
// Assuming a non-OSX Unix platform will follow the XDG. Which it should.
string osConfigDir = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
if (String.IsNullOrEmpty(osConfigDir))
{
osConfigDir = Environment.GetEnvironmentVariable("HOME");
if (String.IsNullOrEmpty(osConfigDir))
{
return ".";// Oh well.
}
osConfigDir += "/.local/share";
}
return osConfigDir;
}
throw new Exception("StorageDevice: Platform.OSVersion not handled!");
}
internal override bool IsStoragePathConnected(string path)
{
if (OSVersion.Equals("Linux") ||
OSVersion.Equals("Mac OS X"))
{
/* Linux and Mac use locally connected storage in the user's
* home location, which should always be "connected".
*/
return true;
}
if (OSVersion.Equals("Windows"))
{
try
{
return new DriveInfo(path).IsReady;
}
catch
{
// The storageRoot path is invalid / has been removed.
return false;
}
}
throw new Exception("StorageDevice: Platform.OSVersion not handled!");
}
#endregion
#region Protected GamePlatform Methods
src/Storage/StorageDevice.cs
5555
5656
5757
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
58
7959
8060
8161
......
11393
11494
11595
116
96
11797
11898
11999
......
371351
372352
373353
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415354
416355
{
get
{
if (Game.Instance.Platform.OSVersion.Equals("Linux") ||
Game.Instance.Platform.OSVersion.Equals("Mac OS X"))
{
/* Linux and Mac use locally connected storage in the user's
* home location, which should always be "connected".
*/
return true;
}
else if (Game.Instance.Platform.OSVersion.Equals("Windows"))
{
try
{
return new DriveInfo(storageRoot).IsReady;
}
catch
{
// The storageRoot path is invalid / has been removed.
return false;
}
}
throw new Exception("StorageDevice: Platform.OSVersion not handled!");
return Game.Instance.Platform.IsStoragePathConnected(storageRoot);
}
}
#region Private Static Variables
private static readonly string storageRoot = GetStorageRoot();
private static readonly string storageRoot = Game.Instance.Platform.GetStorageRoot();
#endregion
}
#endregion
#region Private Static OS User Directory Path Method
private static string GetStorageRoot()
{
if (Game.Instance.Platform.OSVersion.Equals("Windows"))
{
return Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"SavedGames"
);
}
if (Game.Instance.Platform.OSVersion.Equals("Mac OS X"))
{
string osConfigDir = Environment.GetEnvironmentVariable("HOME");
if (String.IsNullOrEmpty(osConfigDir))
{
return "."; // Oh well.
}
osConfigDir += "/Library/Application Support";
return osConfigDir;
}
if (Game.Instance.Platform.OSVersion.Equals("Linux"))
{
// Assuming a non-OSX Unix platform will follow the XDG. Which it should.
string osConfigDir = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
if (String.IsNullOrEmpty(osConfigDir))
{
osConfigDir = Environment.GetEnvironmentVariable("HOME");
if (String.IsNullOrEmpty(osConfigDir))
{
return ".";// Oh well.
}
osConfigDir += "/.local/share";
}
return osConfigDir;
}
throw new Exception("StorageDevice: Platform.OSVersion not handled!");
}
#endregion
}
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.80925s using 13 queries.