Debian Codegraph @

src/window/deprecated_units/castlewindowprogress.pas

raw
1 {
2 Copyright 2002-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 { @deprecated This displays nothing now.
17 It used to be: Progress bar displayed in a TCastleWindow.
18
19 Simply set @code(WindowProgressInterface.Window) to your TCastleWindow
20 instance, and assign
21
22 @longCode(# Progress.UserInterface := WindowProgressInterface;#)
23
24 Between Progress.Init and Fini you shouldn't do anything with
25 window set as @code(WindowProgressInterface.Window).
26 It's callbacks will be temporarily swapped and it will be used
27 to render progress bar.
28
29 As usual, remember to always call Progress.Fini if you called
30 Progress.Init. Progress.Fini restores original callbacks and OpenGL
31 state of your window. Usually it's best and safest to use try..finally
32 block like
33
34 @longCode(# Progress.Init; try.....finally Progress.Fini; end; #) }
35
36
37 unit CastleWindowProgress
38 deprecated 'use TCastleView and WaitForRenderAndCall to display progress of loading operations';
39
40 {$I castleconf.inc}
41
42 interface
43
44 {$warnings off} // using deprecated CastleProgress in deprecated
45 uses CastleWindow, CastleProgress, CastleInternalWindowModes,
46 CastleImages, CastleGLImages, CastleUIControls, CastleControls;
47 {$warnings on}
48
49 type
50 { Progress bar rendered on OpenGL context (TCastleWindow).
51 Uses Application.MainWindow to render the progress bar,
52 so be sure to assign it.
53 If the Application.MainWindow is not assigned, or not open,
54 when progress bar starts --- we gracefully avoid showing any progress. }
55 TWindowProgressInterface = class(TProgressUserInterface)
56 private
57 { Window used to render the progress bar, or nil if none.
58 Assign this before doing Init. Don't change this when we are
59 between Init and Fini. }
60 {$ifdef FPC}
61 function GetWindow: TCastleWindow;
62 procedure SetWindow(const Value: TCastleWindow);
63 {$endif}
64 public
65 {$ifdef FPC}
66 { @deprecated Using this is deprecated, you should rather assign to
67 Application.MainWindow. }
68 property Window: TCastleWindow read GetWindow write SetWindow; deprecated;
69 {$endif}
70
71 procedure Init(Progress: TProgress); override;
72 procedure Update(Progress: TProgress); override;
73 procedure Fini(Progress: TProgress); override;
74 end;
75
76 var
77 { Assign this to Progress.UserInterface to use progress bar
78 drawn on TCastleWindow.
79 This instance is created in initialization, freed in finalization. }
80 WindowProgressInterface: TWindowProgressInterface;
81
82 implementation
83
84 uses SysUtils, CastleUtils, CastleKeysMouse;
85
86 { TWindowProgressInterface ------------------------------------------------ }
87
88 {$ifdef FPC}
89 function TWindowProgressInterface.GetWindow: TCastleWindow;
90 begin
91 Result := Application.MainWindow;
92 end;
93
94 procedure TWindowProgressInterface.SetWindow(const Value: TCastleWindow);
95 begin
96 Application.MainWindow := Value;
97 end;
98 {$endif}
99
100 procedure TWindowProgressInterface.Init(Progress: TProgress);
101 begin
102 end;
103
104 procedure TWindowProgressInterface.Update(Progress: TProgress);
105 begin
106 end;
107
108 procedure TWindowProgressInterface.Fini(Progress: TProgress);
109 begin
110 end;
111
112 initialization
113 WindowProgressInterface := TWindowProgressInterface.Create;
114 finalization
115 FreeAndNil(WindowProgressInterface);
116 end.