Debian Codegraph @

examples/mobile/drawing_toy/code/gameinitialize.pas

raw
1 {
2 Copyright 2013-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 { Simple drawing toy. }
17 unit GameInitialize;
18
19 interface
20
21 implementation
22
23 uses SysUtils, Classes,
24 CastleWindow, CastleControls, CastleLog,
25 CastleFilesUtils, CastleKeysMouse, CastleVectors, CastleApplicationProperties
26 {$region 'Castle Initialization Uses'}
27 // The content here may be automatically updated by CGE editor.
28 , GameViewMain
29 {$endregion 'Castle Initialization Uses'};
30
31 var
32 Window: TCastleWindow;
33
34 { One-time initialization. }
35 procedure ApplicationInitialize;
36 begin
37 { Adjust container settings for a scalable UI (adjusts to any window size in a smart way). }
38 Window.Container.LoadSettings('castle-data:/CastleSettings.xml');
39
40 { Create views (see https://castle-engine.io/views ). }
41 {$region 'Castle View Creation'}
42 // The content here may be automatically updated by CGE editor.
43 ViewMain := TViewMain.Create(Application);
44 {$endregion 'Castle View Creation'}
45
46 Window.Container.View := ViewMain;
47 end;
48
49 initialization
50 { This initialization section configures:
51 - Application.OnInitialize
52 - Application.MainWindow
53 - determines initial window size
54
55 You should not need to do anything more in this initialization section.
56 Most of your actual application initialization (in particular, any file reading)
57 should happen inside ApplicationInitialize. }
58
59 Application.OnInitialize := @ApplicationInitialize;
60
61 Window := TCastleWindow.Create(Application);
62 Application.MainWindow := Window;
63
64 { Optionally, adjust window fullscreen state and size at this point.
65 Examples:
66
67 Run fullscreen:
68
69 Window.FullScreen := true;
70
71 Run in a 600x400 window:
72
73 Window.FullScreen := false; // default
74 Window.Width := 600;
75 Window.Height := 400;
76
77 Run in a window taking 2/3 of screen (width and height):
78
79 Window.FullScreen := false; // default
80 Window.Width := Application.ScreenWidth * 2 div 3;
81 Window.Height := Application.ScreenHeight * 2 div 3;
82
83 Note that some platforms (like mobile) ignore these window sizes.
84 }
85
86 { Handle command-line parameters like --fullscreen and --window.
87 By doing this last, you let user to override your fullscreen / mode setup. }
88 Window.ParseParameters;
89 end.