From 9e696510eb04ce60cbfb8fa88629c66a9384c0f2 Mon Sep 17 00:00:00 2001
From: tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>
Date: Tue, 12 Feb 2008 10:30:58 +0000
Subject: UVisualizer uses the system dependant default game-path now

git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@843 b956fd51-792f-4845-bead-9b4dfca2ff2c
---
 Game/Code/Classes/UMain.pas       |  4 +++-
 Game/Code/Classes/UVisualizer.pas | 35 +++++++++++++++++++++++++++--------
 2 files changed, 30 insertions(+), 9 deletions(-)

(limited to 'Game/Code')

diff --git a/Game/Code/Classes/UMain.pas b/Game/Code/Classes/UMain.pas
index 7b32857b..bbd4a5ee 100644
--- a/Game/Code/Classes/UMain.pas
+++ b/Game/Code/Classes/UMain.pas
@@ -92,6 +92,7 @@ var
   CoversPath:       string;
   LanguagesPath:    string;
   PluginPath:       string;
+  VisualsPath:      string;
   PlayListPath:     string;
 
   UserSongPath:     string = '';
@@ -1034,9 +1035,10 @@ begin
   initialize_path( LogPath         , Platform.GetLogPath                             );
   initialize_path( SoundPath       , Platform.GetGameSharedPath + 'Sounds'      + PathDelim );
   initialize_path( ThemePath       , Platform.GetGameSharedPath + 'Themes'      + PathDelim );
-  initialize_path( SkinsPath       , Platform.GetGameSharedPath + 'Skins'      + PathDelim );
+  initialize_path( SkinsPath       , Platform.GetGameSharedPath + 'Skins'       + PathDelim );
   initialize_path( LanguagesPath   , Platform.GetGameSharedPath + 'Languages'   + PathDelim );
   initialize_path( PluginPath      , Platform.GetGameSharedPath + 'Plugins'     + PathDelim );
+  initialize_path( VisualsPath     , Platform.GetGameSharedPath + 'Visuals'     + PathDelim );
 
   initialize_path( ScreenshotsPath , Platform.GetGameUserPath + 'Screenshots' + PathDelim );
 
diff --git a/Game/Code/Classes/UVisualizer.pas b/Game/Code/Classes/UVisualizer.pas
index 22c168a2..2f584299 100644
--- a/Game/Code/Classes/UVisualizer.pas
+++ b/Game/Code/Classes/UVisualizer.pas
@@ -36,6 +36,7 @@ implementation
 
 uses
   UGraphic,
+  UMain,
   ULog;
 
 var
@@ -46,10 +47,15 @@ const
   gy           = 24;
   fps          = 30;
   texsize      = 512;
-  visualsDir  = 'Visuals'; // TODO: move this to a place common for all visualizers
-  projectMDir = visualsDir+'/projectM';
-  presetsDir  = projectMDir+'/presets';
-  fontsDir    = projectMDir+'/fonts';
+  
+var
+  ProjectMPath : string;
+  presetsDir   : string;
+  fontsDir     : string;
+
+  // FIXME: dirty fix needed because the init method is not
+  //   called yet.
+  inited: boolean;
 
 type
   TVideoPlayback_ProjectM = class( TInterfacedObject, IVideoPlayback, IVideoVisualization )
@@ -78,8 +84,8 @@ type
       procedure RestoreOpenGLState();
 
     public
-      constructor create();
-      procedure   init();
+      constructor Create();
+      procedure   Init();
       function    GetName: String;
 
       function    Open( aFileName : string): boolean; // true if succeed
@@ -97,14 +103,22 @@ type
   end;
 
 
-constructor TVideoPlayback_ProjectM.create();
+constructor TVideoPlayback_ProjectM.Create();
 begin
   RndPCMcount := 0;
 end;
 
 
-procedure TVideoPlayback_ProjectM.init();
+procedure TVideoPlayback_ProjectM.Init();
 begin
+  // FIXME: dirty fix needed because the init method is not
+  //   called yet.
+  inited := true;
+
+  ProjectMPath := VisualsPath + 'projectM' + PathDelim;
+  presetsDir := ProjectMPath + 'presets';
+  fontsDir   := ProjectMPath + 'fonts';
+
   VisualizerStarted := False;
   VisualizerPaused  := False;
 
@@ -212,6 +226,11 @@ procedure TVideoPlayback_ProjectM.VisualizerStart;
 var
   initResult: Cardinal;
 begin
+  // FIXME: dirty fix needed because the init method is not
+  //   called yet.
+  if (not inited) then
+    Init();
+
   VisualizerStarted := True;
 
   pm := TProjectM.Create(gx, gy, fps, texsize, ScreenW, ScreenH,
-- 
cgit v1.2.3