Debian Codegraph @

examples/network/asynchronous_download/code/gameinitialize.pas

raw
1 {
2 Copyright 2020-2023 Michalis Kamburelis.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 { Game initialization.
17 This unit is cross-platform.
18 It will be used by the platform-specific program or library file. }
19 unit GameInitialize;
20
21 interface
22
23 implementation
24
25 uses CastleWindow, CastleLog, CastleApplicationProperties,
26 GameViewMain;
27
28 var
29 Window: TCastleWindow;
30
31 { One-time initialization of resources. }
32 procedure ApplicationInitialize;
33 begin
34 { Adjust container settings for a scalable UI (adjusts to any window size in a smart way). }
35 Window.Container.LoadSettings('castle-data:/CastleSettings.xml');
36
37 ViewMain := TViewMain.Create(Application);
38 Window.Container.View := ViewMain;
39 end;
40
41 initialization
42 { This initialization section configures:
43 - Application.OnInitialize
44 - Application.MainWindow
45 - determines initial window size
46
47 You should not need to do anything more in this initialization section.
48 Most of your actual application initialization (in particular, any file reading)
49 should happen inside ApplicationInitialize. }
50
51 Application.OnInitialize := @ApplicationInitialize;
52
53 Window := TCastleWindow.Create(Application);
54 Application.MainWindow := Window;
55
56 { Optionally, adjust window fullscreen state and size at this point.
57 Examples:
58
59 Run fullscreen:
60
61 Window.FullScreen := true;
62
63 Run in a 600x400 window:
64
65 Window.FullScreen := false; // default
66 Window.Width := 600;
67 Window.Height := 400;
68
69 Run in a window taking 2/3 of screen (width and height):
70
71 Window.FullScreen := false; // default
72 Window.Width := Application.ScreenWidth * 2 div 3;
73 Window.Height := Application.ScreenHeight * 2 div 3;
74
75 Note that some platforms (like mobile) ignore these window sizes.
76 }
77
78 { Handle command-line parameters like --fullscreen and --window.
79 By doing this last, you let user to override your fullscreen / mode setup. }
80 Window.ParseParameters;
81 end.