-
Notifications
You must be signed in to change notification settings - Fork 6
/
mmpGlobalState.pas
322 lines (275 loc) · 10.8 KB
/
mmpGlobalState.pas
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
{ MMP: Minimalist Media Player
Copyright (C) 2021-2024 Baz Cuda
https://github.com/BazzaCuda/MinimalistMediaPlayerX
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
}
{ MMP: Minimalist Media Player
Copyright (C) 2021-2024 Baz Cuda
https://github.com/BazzaCuda/MinimalistMediaPlayerX
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
}
unit mmpGlobalState;
interface
uses
winAPI.windows,
vcl.forms,
mmpNotify.notices, mmpNotify.notifier, mmpNotify.subscriber,
mmpConsts;
type
IGlobalState = interface
['{0DA7E51A-C0BC-4872-9A7E-9BD14E0DBB62}']
function getActiveTasks: integer;
function getAutoCenter: boolean;
function getIDD: integer;
function getImagesPaused: boolean;
function getMainForm: TForm;
function getMaxSize: boolean;
function getMediaType: TMediaType;
function getMPVScreenshotDirectory: string;
function getRepeatDelayMs: integer;
function getShowingAbout: boolean;
function getShowingHelp: boolean;
function getShowingPlaylist: boolean;
function getShowingStreamlist: boolean;
function getShowingThumbs: boolean;
function getShowingTimeline: boolean;
function getTimelineHeight: integer;
function getUserInput: boolean;
function getWidthHelp: integer;
function getWidthPlaylist: integer;
function getWidthStreamlist: integer;
procedure setMaxSize(const aValue: boolean);
function notify(const aNotice: INotice): INotice;
property activeTasks: integer read getActiveTasks;
property autoCenter: boolean read getAutoCenter;
property IDD: integer read getIDD;
property imagesPaused: boolean read getImagesPaused;
property mainForm: TForm read getMainForm;
property maxSize: boolean read getMaxSize;
property mediaType: TMediaType read getMediaType;
property repeatDelayMs: integer read getRepeatDelayMs;
property MPVScreenshotDirectory: string read getMPVScreenshotDirectory;
property showingAbout: boolean read getShowingAbout;
property showingHelp: boolean read getShowingHelp;
property showingPlaylist: boolean read getShowingPlaylist;
property showingStreamlist: boolean read getShowingStreamlist;
property showingThumbs: boolean read getShowingThumbs;
property showingTimeline: boolean read getShowingTimeline;
property timelineHeight: integer read getTimelineHeight;
property userInput: boolean read getUserInput;
property widthHelp: integer read getWidthHelp;
property widthPlaylist: integer read getWidthPlaylist;
property widthStreamlist: integer read getWidthStreamlist;
end;
function GS:IGlobalState;
implementation
uses
System.Generics.Collections,
_debugWindow;
type
TGlobalState = class(TInterfacedObject, IGlobalState)
strict private
FActiveTasks: integer;
FAutoCenter: boolean;
FIDD: integer;
FImagesPaused: boolean;
FMainForm: TForm;
FMaxSize: boolean;
FMediaType: TMediaType;
FMPVScreenshotDirectory: string;
FRepeatDelayMs: integer;
FShowingAbout: boolean;
FShowingHelp: boolean;
FShowingPlaylist: boolean;
FShowingStreamlist: boolean;
FShowingThumbs: boolean;
FShowingTimeline: boolean;
FWidthHelp: integer;
FWidthPlaylist: integer;
FWidthStreamlist: integer;
FSubscriber: ISubscriber;
FTimelineHeight: integer;
FUserInput: boolean;
private
function onNotify(const aNotice: INotice): INotice;
public
constructor create;
destructor Destroy; override;
function getActiveTasks: integer;
function getAutoCenter: boolean;
function getIDD: integer;
function getImagesPaused: boolean;
function getMainForm: TForm;
function getMaxSize: boolean;
function getMediaType: TMediaType;
function getMPVScreenshotDirectory: string;
function getRepeatDelayMs: integer;
function getShowingAbout: boolean;
function getShowingHelp: boolean;
function getShowingPlaylist: boolean;
function getShowingStreamlist: boolean;
function getShowingThumbs: boolean;
function getShowingTimeline: boolean;
function getTimelineHeight: integer;
function getUserInput: boolean;
function getWidthHelp: integer;
function getWidthPlaylist: integer;
function getWidthStreamlist: integer;
procedure setMaxSize(const aValue: boolean);
function notify(const aNotice: INotice): INotice;
end;
var gGS: IGlobalState = NIL;
function GS: IGlobalState;
begin
case gGS = NIL of TRUE: gGS := TGlobalState.create; end;
result := gGS;
end;
{ TGlobalState }
constructor TGlobalState.create;
begin
inherited;
FSubscriber := appNotifier.subscribe(newSubscriber(onNotify));
end;
destructor TGlobalState.Destroy;
begin
appNotifier.unsubscribe(FSubscriber);
inherited;
end;
function TGlobalState.getActiveTasks: integer;
begin
result := FActiveTasks;
end;
function TGlobalState.getAutoCenter: boolean;
begin
result := FAutoCenter;
end;
function TGlobalState.getIDD: integer;
begin
result := FIDD;
end;
function TGlobalState.getImagesPaused: boolean;
begin
result := FImagesPaused;
end;
function TGlobalState.getMainForm: TForm;
begin
result := FMainForm;
end;
function TGlobalState.getMaxSize: boolean;
begin
result := FMaxSize;
end;
function TGlobalState.getMediaType: TMediaType;
begin
result := FMediaType;
end;
function TGlobalState.getMPVScreenshotDirectory: string;
begin
result := FMPVScreenshotDirectory;
end;
function TGlobalState.getRepeatDelayMs: integer;
begin
result := FRepeatDelayMs;
end;
function TGlobalState.getShowingAbout: boolean;
begin
result := FShowingAbout;
end;
function TGlobalState.getShowingHelp: boolean;
begin
result := FShowingHelp;
end;
function TGlobalState.getShowingPlaylist: boolean;
begin
result := FShowingPlaylist;
end;
function TGlobalState.getShowingStreamlist: boolean;
begin
result := FShowingStreamlist;
end;
function TGlobalState.getShowingThumbs: boolean;
begin
result := FShowingThumbs;
end;
function TGlobalState.getShowingTimeline: boolean;
begin
result := FShowingTimeline;
end;
function TGlobalState.getTimelineHeight: integer;
begin
result := FTimelineHeight;
end;
function TGlobalState.getUserInput: boolean;
begin
result := FUserInput;
end;
function TGlobalState.getWidthHelp: integer;
begin
result := FWidthHelp;
end;
function TGlobalState.getWidthPlaylist: integer;
begin
result := FWidthPlaylist;
end;
function TGlobalState.getWidthStreamlist: integer;
begin
result := FWidthStreamlist;
end;
function TGlobalState.notify(const aNotice: INotice): INotice;
begin
result := onNotify(aNotice);
end;
function TGlobalState.onNotify(const aNotice: INotice): INotice;
begin
result := aNotice;
case aNotice = NIL of TRUE: EXIT; end;
case aNotice.event of
evGSActiveTasks: FActiveTasks := aNotice.integer;
evGSAutoCenter: FAutoCenter := aNotice.tf;
evGSIDD: FIDD := aNotice.integer;
evGSImagesPaused: FImagesPaused := aNotice.tf;
evGSMainForm: FMainForm := aNotice.component as TForm;
evGSMaxSize: FMaxSize := aNotice.tf;
evGSMediaType: FMediaType := aNotice.mediaType;
evGSMPVScreenshotDirectory: FMPVScreenshotDirectory := aNotice.text;
evGSRepeatDelayMs: FRepeatDelayMs := aNotice.integer;
evGSShowingAbout: FShowingAbout := aNotice.tf;
evGSShowingHelp: FShowingHelp := aNotice.tf;
evGSShowingPlaylist: FShowingPlaylist := aNotice.tf;
evGSShowingStreamlist: FShowingStreamlist := aNotice.tf;
evGSShowingThumbs: FShowingThumbs := aNotice.tf;
evGSShowingTimeline: FShowingTimeline := aNotice.tf;
evGSTimelineHeight: FTimelineHeight := aNotice.integer;
evGSUserInput: FUserInput := aNotice.tf;
evGSWidthHelp: FWidthHelp := aNotice.integer;
evGSWidthPlaylist: FWidthPlaylist := aNotice.integer;
evGSWidthStreamlist: FWidthStreamlist := aNotice.integer;
end;
end;
procedure TGlobalState.setMaxSize(const aValue: boolean);
begin
FMaxSize := aValue;
end;
initialization
GS;
end.