aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/UltraStar.dpr
blob: efdb9017c1b9930279e1f8dab72d5f8f1268aab2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
program UltraStar;

{$DEFINE TRANSLATE}

{$R 'UltraStar.res' 'UltraStar.rc'}

uses
  acinerella in 'lib\acinerella\acinerella.pas',
  UCaptureWDM in 'lib\DSPack\UCaptureWDM.pas',
  UWebCam in 'classes\UWebCam.pas',
  UMergeSort in 'classes\UMergeSort.pas',
  SDL in 'lib\JEDI-SDLv1.0\SDL\Pas\SDL.pas',
  moduleloader in 'lib\JEDI-SDLv1.0\SDL\Pas\moduleloader.pas',
  sdlutils in 'lib\JEDI-SDLv1.0\SDL\Pas\sdlutils.pas',
  sdl_image in 'lib\JEDI-SDLv1.0\SDL_Image\Pas\sdl_image.pas',
  gl in 'lib\JEDI-SDLv1.0\OpenGL\Pas\gl.pas',
  glu in 'lib\JEDI-SDLv1.0\OpenGL\Pas\glu.pas',
  glext in 'lib\JEDI-SDLv1.0\OpenGL\Pas\glext.pas',
  sdl_ttf in 'lib\JEDI-SDLv1.0\SDL_ttf\Pas\sdl_ttf.pas',
  bass in 'lib\bass\delphi\bass.pas',
  PNGImage in 'lib\PNGImage\PNGImage.pas',
  PNGzLib in 'lib\PNGImage\PNGzLib.pas',
  pnglang in 'lib\PNGImage\pnglang.pas',
  midiout in 'lib\midi\midiout.pas',
  midiin in 'lib\midi\midiin.pas',
  CIRCBUF in 'lib\midi\CIRCBUF.PAS',
  MidiType in 'lib\midi\MidiType.PAS',
  MidiDefs in 'lib\midi\MidiDefs.PAS',
  MidiCons in 'lib\midi\MidiCons.PAS',
  MidiFile in 'lib\midi\MidiFile.PAS',
  Delphmcb in 'lib\midi\Delphmcb.PAS',
  zlportio in 'lib\zlportio\zlportio.pas',
  ddkint in 'lib\zlportio\ddkint.pas',
  SQLiteTable3 in 'lib\SQLite\SQLiteTable3.pas',
  SQLite3 in 'lib\SQLite\SQLite3.pas',
  UDisplay in 'Menu\UDisplay.pas',
  UMenu in 'Menu\UMenu.pas',
  UMenuStatic in 'Menu\UMenuStatic.pas',
  UMenuText in 'Menu\UMenuText.pas',
  UMenuButton in 'Menu\UMenuButton.pas',
  UMenuInteract in 'Menu\UMenuInteract.pas',
  UMenuSelect in 'Menu\UMenuSelect.pas',
  UMenuSelectSlide in 'Menu\UMenuSelectSlide.pas',
  UDrawTexture in 'Menu\UDrawTexture.pas',
  UMenuButtonCollection in 'Menu\UMenuButtonCollection.pas',
  UGraphic in 'Classes\UGraphic.pas',
  UTexture in 'Classes\UTexture.pas',
  UMusic in 'Classes\UMusic.pas',
  ULanguage in 'Classes\ULanguage.pas',
  UMain in 'Classes\UMain.pas',
  UDraw in 'Classes\UDraw.pas',
  URecord in 'Classes\URecord.pas',
  UTime in 'Classes\UTime.pas',
  TextGL in 'Classes\TextGL.pas',
  USongs in 'Classes\USongs.pas',
  UIni in 'Classes\UIni.pas',
  UHelp in 'Classes\UHelp.pas',
  ULyrics in 'Classes\ULyrics.pas',
  USkins in 'Classes\USkins.pas',
  UThemes in 'Classes\UThemes.pas',
  ULog in 'Classes\ULog.pas',
  UDataBase in 'Classes\UDataBase.pas',
  UCovers in 'Classes\UCovers.pas',
  UCatCovers in 'Classes\UCatCovers.pas',
  UFiles in 'Classes\UFiles.pas',
  UGraphicClasses in 'Classes\UGraphicClasses.pas',


  UDLLManager in 'Classes\UDLLManager.pas',
  UParty in 'Classes\UParty.pas',
  UPartyM2 in 'Classes\UPartyM2.pas',  //Party M2-MOD

  UPlaylist in 'Classes\UPlaylist.pas',
  UCommandLine in 'Classes\UCommandLine.pas',


  UScreenLoading in 'Screens\UScreenLoading.pas',
  UScreenWelcome in 'Screens\UScreenWelcome.pas',
  UScreenMain in 'Screens\UScreenMain.pas',
  UScreenName in 'Screens\UScreenName.pas',
  UScreenLevel in 'Screens\UScreenLevel.pas',
  UScreenSong in 'Screens\UScreenSong.pas',
  UScreenSing in 'Screens\UScreenSing.pas',
  UScreenScore in 'Screens\UScreenScore.pas',
  UScreenOptions in 'Screens\UScreenOptions.pas',
  UScreenOptionsGame in 'Screens\UScreenOptionsGame.pas',
  UScreenOptionsGraphics in 'Screens\UScreenOptionsGraphics.pas',
  UScreenOptionsSound in 'Screens\UScreenOptionsSound.pas',
  UScreenOptionsLyrics in 'Screens\UScreenOptionsLyrics.pas',
  UScreenOptionsThemes in 'Screens\UScreenOptionsThemes.pas',
  UScreenOptionsRecord in 'Screens\UScreenOptionsRecord.pas',
  UScreenOptionsAdvanced in 'Screens\UScreenOptionsAdvanced.pas',
  UScreenEditSub in 'Screens\UScreenEditSub.pas',
  UScreenEdit in 'Screens\UScreenEdit.pas',
  UScreenEditConvert in 'Screens\UScreenEditConvert.pas',
  UScreenEditHeader in 'Screens\UScreenEditHeader.pas',
  UScreenOpen in 'Screens\UScreenOpen.pas',
  UScreenTop in 'Screens\UScreenTop.pas',
  UScreenSongMenu in 'Screens\UScreenSongMenu.pas',
  UScreenSongJumpto in 'Screens\UScreenSongJumpto.pas',
  UScreenStatMain in 'Screens\UScreenStatMain.pas',
  UScreenStatDetail in 'Screens\UScreenStatDetail.pas',
  UScreenCredits in 'Screens\UScreenCredits.pas',
  UScreenPopup in 'Screens\UScreenPopup.pas',

  UScreenSingModi in 'Screens\UScreenSingModi.pas',
  UScreenPartyNewRound in 'Screens\UScreenPartyNewRound.pas',
  UScreenPartyScore in 'Screens\UScreenPartyScore.pas',
  UScreenPartyPlayer in 'Screens\UScreenPartyPlayer.pas',
  UScreenPartyOptions in 'Screens\UScreenPartyOptions.pas',
  UScreenPartyWin in 'Screens\UScreenPartyWin.pas',

  UScreenPartyNewRoundM2 in 'Screens\UScreenPartyNewRoundM2.pas',
  UScreenPartyPlayerM2 in 'Screens\UScreenPartyPlayerM2.pas',
  UScreenPartyOptionsM2 in 'Screens\UScreenPartyOptionsM2.pas',

  ModiSDK in '..\..\Modis\SDK\ModiSDK.pas',


  Windows,
  SysUtils,
  UVideo in 'Classes\UVideo.pas';

const
  VersionName = 'UltraStar Deluxe Challenge, Medley & Duet Edition';
  VersionNumber = 'r9.9';

var
  WndTitle:       string;
  hWnd:           THandle;
  I:              Integer;
  VersionString:  string;

begin
  VersionString := VersionName + ' ' + VersionNumber;
  WndTitle := VersionString;

  //------------------------------
  //Start more than One Time Prevention
  //------------------------------
  hWnd:= FindWindow(nil, PChar(WndTitle));
  //Programm already started
  if (hWnd <> 0) then
  begin
    I := Messagebox(0, PChar('Another Instance of Ultrastar is already running. Continue ?'), PChar(WndTitle), MB_ICONWARNING or MB_YESNO);
    if (I = IDYes) then
    begin
      I := 1;
      repeat
        Inc(I);
        hWnd := FindWindow(nil, PChar(WndTitle + ' Instance ' + InttoStr(I)));
      until (hWnd = 0);

      WndTitle := WndTitle + ' Instance ' + InttoStr(I);
    end
    else
      Exit;
  end;

  //------------------------------
  //StartUp - Create Classes and Load Files
  //------------------------------
  USTime := TTime.Create;

  // Commandline Parameter Parser
  Params := TCMDParams.Create;

  // Log + Benchmark
  Log := TLog.Create;
  PerfLog := TPerformanceLog.Create;
  Log.Title := WndTitle;
  Log.Enabled := Not Params.NoLog;
  Log.BenchmarkStart(0);

  // Language
  Log.BenchmarkStart(1);
  Log.LogStatus('Initialize Paths', 'Initialization');        InitializePaths;
  Log.LogStatus('Load Language', 'Initialization');           Language := TLanguage.Create;
  //Add Const Values:
  Language.AddConst('US_VERSION', VersionString);
  Language.AddConst('US_VERSION_NUMBER', VersionNumber);

  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Language', 1);

  // SDL
  Log.BenchmarkStart(1);
  Log.LogStatus('Initialize SDL', 'Initialization');
  SDL_Init(SDL_INIT_VIDEO or SDL_INIT_TIMER);
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Initializing SDL', 1);

   // Skin
  Log.BenchmarkStart(1);
  Log.LogStatus('Loading Skin List', 'Initialization');             Skin := TSkin.Create;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Skin List', 1);

  // Sound Card List
  Log.BenchmarkStart(1);
  Log.LogStatus('Loading Soundcard list', 'Initialization');
  Recording := TRecord.Create;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Soundcard list', 1);

  // Ini + Paths
  Log.BenchmarkStart(1);
  Log.LogStatus('Load Ini', 'Initialization');                Ini := TIni.Create;
                                                              Ini.Load;

  // Help
  Log.BenchmarkStart(1);
  Log.LogStatus('Load Help', 'Initialization');               Help := THelp.Create; 

  //Load Languagefile
  if (Params.Language <> -1) then
  begin
    Language.ChangeLanguage(ILanguage[Params.Language]);
    Help.ChangeLanguage(ILanguage[Params.Language]);
  end else
  begin
    Language.ChangeLanguage(ILanguage[Ini.Language]);
    Help.ChangeLanguage(ILanguage[Ini.Language]);
  end;

  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Ini', 1);

  // Theme
  Log.BenchmarkStart(1);
  Log.LogStatus('Load Themes', 'Initialization');             Theme := TTheme.Create('Themes\' + ITheme[Ini.Theme] + '.ini', Ini.Color);
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Themes', 1);

  // Covers Cache
  Log.BenchmarkStart(1);
  Log.LogStatus('Creating Covers Cache', 'Initialization');   Covers := TCovers.Create;
  Log.LogBenchmark('Loading Covers Cache Array', 1);
  Log.BenchmarkStart(1);

  // Category Covers
  Log.BenchmarkStart(1);
  Log.LogStatus('Creating Category Covers Array', 'Initialization');
  CatCovers:= TCatCovers.Create;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Category Covers Array', 1);

  // PluginManager
  Log.BenchmarkStart(1);
  Log.LogStatus('PluginManager', 'Initialization');
  DLLMan := TDLLMan.Create;   //Load PluginList
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading PluginManager', 1);

  // Party Mode Manager
  Log.BenchmarkStart(1);
  Log.LogStatus('PartySession Manager', 'Initialization');
  PartySession := TParty_Session.Create;   //Load PartySession
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading PartySession Manager', 1);

  // Party M2 Mode Manager
  Log.BenchmarkStart(1);
  Log.LogStatus('PartySessionM2 Manager', 'Initialization');
  PartySessionM2 := TPartySessionM2.Create;   //Load PartySessionM2
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading PartySessionM2 Manager', 1);

  // Graphics
  Log.BenchmarkStart(1);
  Log.LogStatus('Initialize 3D', 'Initialization');           Initialize3D(WndTitle);
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Initializing 3D', 1);

  // Songs
  Log.BenchmarkStart(1);
  Log.LogStatus('Creating Song Array', 'Initialization');     Songs := TSongs.Create;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Song Array', 1);

  Log.BenchmarkStart(1);
  Songs.LoadSongList;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Song List', 1);

  Log.BenchmarkStart(1);
  Log.LogStatus('Creating 2nd Song Array', 'Initialization'); CatSongs := TCatSongs.Create;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Song Cats', 1);

  // Refresh ScreenSong
  Log.BenchmarkStart(1);
  ScreenSong.Refresh(true);
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Song Refresh', 1);

  // Sound
  Log.BenchmarkStart(1);
  Log.LogStatus('Initialize Sound', 'Initialization');
  Log.LogStatus('Creating Music', 'InitializeSound');         Music := TMusic.Create;
  InitializeSound;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Initializing Sound', 1);

  // Score Saving System
  Log.BenchmarkStart(1);
  Log.LogStatus('DataBase System', 'Initialization');
  DataBase := TDataBaseSystem.Create;

  if (Params.ScoreFile = '') then
    DataBase.Init ('Ultrastar.db')
  else
    DataBase.Init (Params.ScoreFile);

  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading DataBase System', 1);

  //Playlist Manager
  Log.BenchmarkStart(1);
  Log.LogStatus('Playlist Manager', 'Initialization');
  PlaylistMan := TPlaylistManager.Create;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Playlist Manager', 1);

  //GoldenStarsTwinkleMod
  Log.BenchmarkStart(1);
  Log.LogStatus('Effect Manager', 'Initialization');
  GoldenRec := TEffectManager.Create;
  Log.BenchmarkEnd(1);
  Log.LogBenchmark('Loading Particel System', 1);

  Log.BenchmarkEnd(0);
  Log.LogBenchmark('Loading Time', 0);

  //Create/Save Ini
  Ini.Save;

  //------------------------------
  //Start- Mainloop
  //------------------------------

  Log.LogStatus('Main Loop', 'Initialization');               MainLoop;

  //------------------------------
  //Finish Application
  //------------------------------

  Log.Free;
end.