aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-07-15 23:46:10 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-07-15 23:46:10 +0000
commit4dd9427bd27321e5ac8e9bff9a677f527294ac97 (patch)
tree228bf0f35d7e4e86e37477e14bf9d579010bb461 /Game
parent17298eb642931ea1eeeb733104a9e0f0432eb04d (diff)
downloadusdx-4dd9427bd27321e5ac8e9bff9a677f527294ac97.tar.gz
usdx-4dd9427bd27321e5ac8e9bff9a677f527294ac97.tar.xz
usdx-4dd9427bd27321e5ac8e9bff9a677f527294ac97.zip
New place for the Resources for Mac OS X: $HOME/Appliations Support/UltraStarDeluxe/Resources
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1201 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UMain.pas6
-rw-r--r--Game/Code/Classes/UPlatformMacOSX.pas60
-rw-r--r--Game/Code/MacOSX/Wrapper/UMacResources.pp1
-rw-r--r--Game/Code/UltraStar.dpr1
4 files changed, 53 insertions, 15 deletions
diff --git a/Game/Code/Classes/UMain.pas b/Game/Code/Classes/UMain.pas
index d9440144..a0bdbb94 100644
--- a/Game/Code/Classes/UMain.pas
+++ b/Game/Code/Classes/UMain.pas
@@ -20,6 +20,9 @@ uses
ULyrics,
UScreenSing,
USong,
+{$IFDEF DARWIN}
+ UMacResources,
+{$ENDIF}
gl;
type
@@ -149,6 +152,9 @@ procedure Main;
var
WndTitle: string;
begin
+{$IFDEF DARWIN}
+ UMacResources.init;
+{$ENDIF}
try
WndTitle := USDXVersionStr;
diff --git a/Game/Code/Classes/UPlatformMacOSX.pas b/Game/Code/Classes/UPlatformMacOSX.pas
index f12f5254..b6ced926 100644
--- a/Game/Code/Classes/UPlatformMacOSX.pas
+++ b/Game/Code/Classes/UPlatformMacOSX.pas
@@ -1,17 +1,40 @@
unit UPlatformMacOSX;
-// Note on directories (by eddie):
-// We use subfolders of the application directory on tha mac, because:
-// 1. Installation on the mac works as follows: Extract and copy an application
-// and if you don't like or need the application anymore you move the folder
-// to the trash - and you're done.
-// 2. If we would use subfolders of the home directory we would have to spread our
-// files to many directories - these directories are defined by Apple, but the
-// average user doesn't know them, beacuse he or she doesn't need to know them.
-// But for UltraStar the user must at least know the songs directory...
-//
-// Creating a subfolder directly under the home directory is not acceptable.
-//
+{
+ Note on directories (by eddie):
+ We use subfolders of the application directory on tha mac, because:
+ 1. Installation on the mac works as follows: Extract and copy an application
+ and if you don't like or need the application anymore you move the folder
+ to the trash - and you're done.
+ 2. If we would use subfolders of the home directory we would have to spread our
+ files to many directories - these directories are defined by Apple, but the
+ average user doesn't know them, beacuse he or she doesn't need to know them.
+ But for UltraStar the user must at least know the songs directory...
+
+ Creating a subfolder directly under the home directory is not acceptable.
+
+ More on this from KMS aka mischi
+
+ Handling of resources and folders should follow these lines.
+
+ Acceptable places for files are folders named UltraStarDeluxe either in
+ /Library/Application Support/
+ or
+ ~/Library/Application Support/
+
+ Then
+ GetGameSharedPath could return
+ /Library/Application Support/UltraStarDeluxe/Resources/
+ GetGameUserPath could return
+ ~/Library/Application Support/UltraStarDeluxe/Resources/
+
+ USDX checks, whether GetGameUserPath exists. If not, USDX creates its.
+ The existance of needed files is then checked and if a file is missing
+ it is copied to there from within the Resources folder in the Application
+ bundle, which contains the default files. USDX should not delete files or
+ folders in Application Support/UltraStarDeluxe automatically or without
+ user confirmation.
+}
interface
@@ -59,22 +82,29 @@ begin
end;
end;
+function GetApplicationSupportPath : WideString;
+const
+ PathName : string = '/Library/Application Support/UltraStarDeluxe/Resources';
+begin
+ Result := GetEnvironmentVariable('HOME') + PathName + '/';
+end;
+
function TPlatformMacOSX.GetLogPath : WideString;
begin
// eddie: Please read the note at the top of this file, why we use the application directory and not the user directory.
- Result := GetBundlePath + 'Contents/Resources/Logs';
+ Result := GetApplicationSupportPath + 'Logs';
end;
function TPlatformMacOSX.GetGameSharedPath : WideString;
begin
// eddie: Please read the note at the top of this file, why we use the application directory and not the user directory.
- Result := GetBundlePath + 'Contents/Resources/';
+ Result := GetApplicationSupportPath;
end;
function TPlatformMacOSX.GetGameUserPath : WideString;
begin
// eddie: Please read the note at the top of this file, why we use the application directory and not the user directory.
- Result := GetBundlePath + 'Contents/Resources/';
+ Result := GetApplicationSupportPath;
end;
function TPlatformMacOSX.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : boolean) : TDirectoryEntryArray;
diff --git a/Game/Code/MacOSX/Wrapper/UMacResources.pp b/Game/Code/MacOSX/Wrapper/UMacResources.pp
new file mode 100644
index 00000000..65c817fc
--- /dev/null
+++ b/Game/Code/MacOSX/Wrapper/UMacResources.pp
@@ -0,0 +1 @@
+unit UMacResources; interface procedure init; implementation uses SysUtils, Classes; procedure init; const PathName : string = '/Library/Application Support/UltraStarDeluxe/Resources'; var RelativePath, BaseDir, OldBaseDir : string; SearchInfo : TSearchRec; DirectoryList, FileList : TStringList; DirectoryIsFinished : longint; counter : longint; UserPathName : string; SourceFile, TargetFile : TFileStream; FileCopyBuffer : array [1..4096] of byte; NumberOfBytes : integer; begin getdir (0, OldBaseDir); BaseDir := OldBaseDir + '/UltraStarDeluxe.app/Contents/Resources'; chdir (BaseDir); UserPathName := GetEnvironmentVariable('HOME') + PathName; DirectoryIsFinished := 0; DirectoryList := TStringList.Create(); FileList := TStringList.Create(); DirectoryList.Add('.'); repeat RelativePath := DirectoryList[DirectoryIsFinished]; chdir (BaseDir + '/' + RelativePath); if (FindFirst('*', faAnyFile, SearchInfo) = 0) then repeat if DirectoryExists(SearchInfo.Name) then begin if (SearchInfo.Name <> '.') and (SearchInfo.Name <> '..') then DirectoryList.Add(RelativePath + '/' + SearchInfo.Name); end else Filelist.Add(RelativePath + '/' + SearchInfo.Name); until (FindNext(SearchInfo) <> 0); FindClose(SearchInfo); DirectoryIsFinished := succ(DirectoryIsFinished); until (DirectoryIsFinished = DirectoryList.Count); if not DirectoryExists(UserPathName) then mkdir (UserPathName); for counter := 0 to DirectoryList.Count-1 do if not DirectoryExists(UserPathName + '/' + DirectoryList[counter]) then mkdir (UserPathName + '/' + DirectoryList[counter]); DirectoryList.Free(); for counter := 0 to Filelist.Count-1 do if not FileExists(UserPathName + '/' + Filelist[counter]) then begin SourceFile := TFileStream.Create(BaseDir + '/' + Filelist[counter], fmOpenRead); TargetFile := TFileStream.Create(UserPathName + '/' + Filelist[counter], fmCreate); repeat NumberOfBytes := SourceFile.Read(FileCopyBuffer, SizeOf(FileCopyBuffer)); TargetFile.Write(FileCopyBuffer, NumberOfBytes); until (NumberOfBytes < SizeOf(FileCopyBuffer)); SourceFile.Free; TargetFile.Free; end; FileList.Free(); chdir (OldBaseDir); end; end. \ No newline at end of file
diff --git a/Game/Code/UltraStar.dpr b/Game/Code/UltraStar.dpr
index f021bc6a..c9a32a1d 100644
--- a/Game/Code/UltraStar.dpr
+++ b/Game/Code/UltraStar.dpr
@@ -59,6 +59,7 @@ uses
{$ENDIF}
{$IFDEF DARWIN}
PseudoThread in 'MacOSX/Wrapper/PseudoThread.pas',
+ UMacResources in 'MacOSX/Wrapper/UMacResources.pp',
{$ENDIF}
{$IFDEF UsePortaudio}
portaudio in 'lib\portaudio\delphi\portaudio.pas',