-
Notifications
You must be signed in to change notification settings - Fork 0
/
uielement.h
780 lines (656 loc) · 20.1 KB
/
uielement.h
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
//========================================================================
//
// RK-HUD/RK-UI framework
// specific wrath version, but can be easily adapted to any DP/FTE project
//
// Copyright (C) 2023 - 2024 Samuel "Reki" Piper
//
// This code is free software; you can redistribute it and/or modify
// it under the terms of the GNU GPL (General Public License); either
// version 2 of the License, or (at your option) any later version.
//
//========================================================================
#pragma once
enum UITYPE:float {
EMPTY,
LIST,
TEXT,
PICTURE,
};
enumflags UIFLAG:float {
STRETCH,
HIDE,
CLICKABLE,
SELECTABLE,
KEEPSELECT,
HIGHLIGHT,
FORCECURSOR,
CLIP,
INIT,
SETALPHA,
MULTALPHA,
};
class uielement_c;
#define CONVERT_TO_DP_SHITTY_COLOR(color) ((color - '0.5 0.5 0.5') * 2)
#define CONVERT_FROM_DP_SHITTY_COLOR(color) ((color / 2) + '0.5 0.5 0.5')
#define INBOUNDS(point, mins, maxs) ((point[0] >= mins[0] && point[0] <= maxs[0]) && (point[1] >= mins[1] && point[1] <= maxs[1]))
vector ui_clipstart;
vector ui_clipsize;
vector ui_mouseposition;
vector ui_position;
vector ui_scale;
float ui_alpha;
uielement_c ui_selected;
uielement_c ui_hover;
uielement_c ui_oldhover;
uielement_c ui_screen_queue; // ui elements without an owner, aka parented to the screen overall
float ui_usemouse;
float ui_oldusemouse;
float ui_renderframe;
#ifdef CSQC
uielement_c ui_hud;
vector autocvar_scr_hudborder;
float autocvar_scr_hudscale;
#endif
#ifdef CSQC
#define frametime clframetime
#elif defined(MENU)
#define frametime clframetime
#endif
//////// UI Element classes //////////////////////////////////
// this replaces the original hardcoded ui system. //
// each element is an entity, and should be initialized //
// at load time as this system is not optimized for adding //
// or removing elements on the fly //
//////////////////////////////////////////////////////////////
class uielement_c
{
float type;
UIFLAG flags;
float drawflags;
vector origin;
vector anchor;
vector justify;
vector size;
vector color;
float alpha;
float mod_col;
float mod_alp;
uielement_c _list; // elements that I "own"
uielement_c owner; // element that owns me, if any
uielement_c _next; // the element after me in my owner's list
uielement_c partner; // elements that I want to reference
uielement_c partner2;
uielement_c partner3;
uielement_c partner4;
uielement_c partner5;
uielement_c partner6;
uielement_c partner7;
uielement_c partner8;
uielement_c partner9;
// generic linked list
nonvirtual void() link_to_owner {
if (!owner) // link to screen render queue
{
if (!ui_screen_queue)
{
ui_screen_queue = this;
return;
}
uielement_c h, e;
for(e = ui_screen_queue; e; h = e, e = e._next); // find end of list
h._next = this; // link into list at end
this._next = __NULL__;
return;
}
if (!owner._list) // if owner list is __NULL__, we're the head of the list
{
owner._list = this;
return;
}
uielement_c h, e;
for(e = owner._list; e; h = e, e = e._next); // find end of list
h._next = this; // link into list at end
this._next = __NULL__;
};
// constructor
nonvirtual void() uielement_c {
if (flags & UIFLAG::INIT)
return;
flags |= UIFLAG::INIT;
if (!color)
color = '1 1 1';
if (!alpha)
alpha = 1.0;
mod_col = 1;
mod_alp = 1;
link_to_owner();
};
// totalsize
virtual vector() totalsize {
return [size[0] * ui_scale[0], size[1] * ui_scale[1]];
};
var virtual void(uielement_c this, __inout vector position) preloop; // called before looping
var virtual void(uielement_c this, __inout vector position) loopthrough; // called when looping through children for rendering
// if present, returns true if we should draw
var virtual float(uielement_c this) active_condition;
// mouse is over button
var virtual void(uielement_c this) m_over {
if !(flags & UIFLAG::CLICKABLE)
return;
if (flags & UIFLAG::HIGHLIGHT)
{
mod_col = 1.2;
mod_alp = 1.1;
}
};
// mouse was over button, but now has moved
var virtual void(uielement_c this) m_leave {
if (flags & UIFLAG::HIGHLIGHT)
{
mod_col = 1;
mod_alp = 1;
}
};
// mouse clicked on the button
var virtual void(uielement_c this) m_click;
var virtual void(uielement_c this) m_unclick;
// general input entrypoint
var virtual float(uielement_c this, float nkey, float ascii, float released) input;
// render our element
virtual void() render {
return; // stub
};
};
////////////////
// List Element
////////////////
class uilist_c : uielement_c
{
vector separation;
float scroll;
float scroll_count;
float elements;
float elements_temp;
// preloop
nonvirtual void(uielement_c this, __inout vector position) list_preloop {
elements = elements_temp;
elements_temp = 0;
vector scaled_sep = [separation[0] * ui_scale[0], separation[1] * ui_scale[1]];
if (separation[0])
scroll_count = floor(size[0] / separation[0]);
else if (separation[1])
scroll_count = floor(size[1] / separation[1]);
if (elements > scroll_count)
{
scroll = bound(0, scroll, elements - scroll_count);
position += scaled_sep * -scroll;
}
else
{
scroll = 0;
}
};
// loopthrough
nonvirtual void(uielement_c this, __inout vector position) list_loopthrough {
vector scaled_sep = [separation[0] * ui_scale[0], separation[1] * ui_scale[1]];
position += scaled_sep;
elements_temp++;
};
// constructor
nonvirtual void() uilist_c {
type = UITYPE::LIST;
if (preloop == __NULL__)
preloop = list_preloop;
if (loopthrough == __NULL__)
loopthrough = list_loopthrough;
};
};
class uismoothlist_c : uilist_c
{
float scroll_smooth;
float smoothspeed;
// preloop
nonvirtual void(uielement_c this, __inout vector position) list_preloop_smooth {
elements = elements_temp;
elements_temp = 0;
vector scaled_sep = [separation[0] * ui_scale[0], separation[1] * ui_scale[1]];
if (separation[0])
scroll_count = floor(size[0] / separation[0]);
else if (separation[1])
scroll_count = floor(size[1] / separation[1]);
if (elements > scroll_count)
{
scroll = bound(0, scroll, elements - scroll_count);
}
else
{
scroll = 0;
}
position += scaled_sep * -scroll_smooth;
};
virtual void() render {
if (scroll_smooth > scroll)
scroll_smooth = max(scroll, scroll_smooth - (smoothspeed * frametime));
else if (scroll_smooth < scroll)
scroll_smooth = min(scroll, scroll_smooth + (smoothspeed * frametime));
};
// constructor
nonvirtual void() uismoothlist_c {
type = UITYPE::LIST;
if (!smoothspeed)
smoothspeed = 20;
preloop = list_preloop_smooth;
};
};
////////////////
// Image Element
////////////////
class uipicture_c : uielement_c
{
string image;
string image2;
#ifdef CSQC
float angle;
#endif
// constructor
nonvirtual void() uipicture_c {
type = UITYPE::PICTURE;
if (image)
precache_pic(image);
if (image2)
precache_pic(image2);
};
var virtual void(uipicture_c this, __inout string img_to_render) prerender;
// rendering for fill or pictures
virtual void() render {
vector final_color = color * mod_col; //
float final_alpha = alpha * mod_alp * ui_alpha; // handle hightlighting
vector final_origin = ui_position;
vector final_size = [size[0] * ui_scale[0], size[1] * ui_scale[1]];
string final_img = image;
if (prerender)
prerender(this, final_img);
if (final_img != __NULL__ && final_alpha > 0)
{
#ifdef CSQC
if (!angle)
{
#endif
drawpic(final_origin, final_img, final_size, final_color, final_alpha, drawflags);
#ifdef CSQC
}
else
{
vector slength = final_size / 2;
vector tl = final_origin + slength;
vector tr = final_origin + slength;
vector br = final_origin + slength;
vector bl = final_origin + slength;
float a = (angle + 180) * DEG2RAD;
float a2 = (angle + 270) * DEG2RAD;
tl += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle) * DEG2RAD;
float a2 = (angle + 270) * DEG2RAD;
tr += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle + 180) * DEG2RAD;
float a2 = (angle + 90) * DEG2RAD;
bl += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle) * DEG2RAD;
float a2 = (angle + 90) * DEG2RAD;
br += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
R_BeginPolygon(final_img, drawflags, 1);
R_PolygonVertex(tl, '0 0', final_color, final_alpha);
R_PolygonVertex(tr, '1 0', final_color, final_alpha);
R_PolygonVertex(br, '1 1', final_color, final_alpha);
R_PolygonVertex(bl, '0 1', final_color, final_alpha);
R_EndPolygon();
}
#endif
}
};
};
class uilocpicture_c : uipicture_c
{
string fallback_txt;
vector fallback_sz;
vector fallback_ofs;
vector fallback_color;
float fallback;
float fallback_font;
nonvirtual void() uilocpicture_c {
fallback = (this.image == __NULL__);
if (!fallback_font)
fallback_font = FONT_MENU;
if (!fallback_color)
fallback_color = this.color;
if (fallback)
{
float o_font = drawfont;
drawfont = this.fallback_font;
if (!fallback_sz)
{
float max_width = this.size[0];
float fsize = bound(6, min(this.size[0] * 0.4, this.size[1] * 0.7), 48);
this.fallback_sz = [fsize, fsize];
}
float strwidth = stringwidth(fallback_txt, TRUE, this.fallback_sz);
strwidth = max(strwidth, 16);
if (strwidth > this.size[0])
{
float scaler = (this.size[0] / strwidth);
this.fallback_sz[0] *= scaler;
strwidth *= scaler;
}
this.fallback_ofs[0] += (this.size[0] - stringwidth(fallback_txt, TRUE, this.fallback_sz)) * 0.5;
this.fallback_ofs[1] += (this.size[1] - this.fallback_sz[1]) * 0.5;
drawfont = o_font;
}
};
// totalsize
virtual vector() totalsize {
if (fallback && 0)
{
float o_drawfont = drawfont;
drawfont = fallback_font;
if (!fallback_txt)
return '0 0';
float txt_width = stringwidth(fallback_txt, TRUE, [fallback_sz[0] * ui_scale[0], fallback_sz[1] * ui_scale[1]]);
drawfont = o_drawfont;
vector sz = [txt_width, fallback_sz[1] * ui_scale[1]];
return sz;
}
else
{
return [size[0] * ui_scale[0], size[1] * ui_scale[1]];
}
};
var virtual void(uilocpicture_c this, __inout string txt_to_render, __inout vector color_to_render, __inout float alpha_to_render) prerender_text;
virtual void() render {
if (fallback)
{
float o_drawfont = drawfont;
drawfont = fallback_font;
vector final_color = fallback_color * mod_col; //
float final_alpha = alpha * mod_alp * ui_alpha; // handle hightlighting
vector final_origin = ui_position;
final_origin += [fallback_ofs[0] * ui_scale[0], fallback_ofs[1] * ui_scale[1]];
//final_origin += [padding[0] * ui_scale[0], padding[1] * ui_scale[1]] * 0.5;
vector final_size = [fallback_sz[0] * ui_scale[0], fallback_sz[1] * ui_scale[1]];
string final_text = fallback_txt;
if (prerender_text)
prerender_text(this, final_text, final_color, final_alpha);
if (final_size[0] <= 0 || final_size[1] <= 0 || final_alpha <= 0 || !final_text || !strcmp(final_text, ""))
return;
drawstring(final_origin, final_text, final_size, final_color, final_alpha, drawflags);
drawfont = o_drawfont;
}
else
{
vector final_color = color * mod_col; //
float final_alpha = alpha * mod_alp * ui_alpha; // handle hightlighting
vector final_origin = ui_position;
vector final_size = [size[0] * ui_scale[0], size[1] * ui_scale[1]];
string final_img = image;
if (prerender)
prerender(this, final_img);
if (final_img != __NULL__ && final_alpha > 0)
{
#ifdef CSQC
if (!angle)
{
#endif
drawpic(final_origin, final_img, final_size, final_color, final_alpha, drawflags);
#ifdef CSQC
}
else
{
vector slength = final_size / 2;
vector tl = final_origin + slength;
vector tr = final_origin + slength;
vector br = final_origin + slength;
vector bl = final_origin + slength;
float a = (angle + 180) * DEG2RAD;
float a2 = (angle + 270) * DEG2RAD;
tl += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle) * DEG2RAD;
float a2 = (angle + 270) * DEG2RAD;
tr += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle + 180) * DEG2RAD;
float a2 = (angle + 90) * DEG2RAD;
bl += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle) * DEG2RAD;
float a2 = (angle + 90) * DEG2RAD;
br += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
R_BeginPolygon(final_img, drawflags, 1);
R_PolygonVertex(tl, '0 0', final_color, final_alpha);
R_PolygonVertex(tr, '1 0', final_color, final_alpha);
R_PolygonVertex(br, '1 1', final_color, final_alpha);
R_PolygonVertex(bl, '0 1', final_color, final_alpha);
R_EndPolygon();
}
#endif
}
}
};
};
float autocvar_joy_x360_preset;
class uiglyph_c : uipicture_c
{
string bind_cmd;
CONTROLLER last_controllerType;
float last_joyPreset;
virtual void() render {
if (input_mode != IN_MODE_GAMEPAD)
return;
if (last_controllerType != controllerType || last_joyPreset != autocvar_joy_x360_preset)
{
string code = bind_cmd;
if (code != "rs" && code != "ls")
{
float argc = tokenize(findkeysforcommand(bind_cmd, 0));
float keynum = -1;
for(float j = 0; j < argc; j++)
{
float num = stof(argv(j));
float btype = bind_gettype(num);
if (btype == INPUT_TYPE::XBOX)
{
keynum = num;
break;
}
}
if (keynum < 0)
return;
code = ftos(keynum);
}
if (image)
strunzone(image);
image = strzone(Controller_GetGlyph(code));
last_controllerType = controllerType;
last_joyPreset = autocvar_joy_x360_preset;
}
string final_img = image;
vector final_color = color * mod_col; //
float final_alpha = alpha * mod_alp * ui_alpha; // handle hightlighting
vector final_origin = ui_position;
vector final_size = [size[0] * ui_scale[0], size[1] * ui_scale[1]];
if (prerender)
prerender(this, final_img);
if (final_img != __NULL__ && final_alpha > 0)
{
#ifdef CSQC
if (!angle)
{
#endif
drawpic(final_origin, final_img, final_size, final_color, final_alpha, drawflags);
#ifdef CSQC
}
else
{
vector slength = final_size / 2;
vector tl = final_origin + slength;
vector tr = final_origin + slength;
vector br = final_origin + slength;
vector bl = final_origin + slength;
float a = (angle + 180) * DEG2RAD;
float a2 = (angle + 270) * DEG2RAD;
tl += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle) * DEG2RAD;
float a2 = (angle + 270) * DEG2RAD;
tr += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle + 180) * DEG2RAD;
float a2 = (angle + 90) * DEG2RAD;
bl += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
float a = (angle) * DEG2RAD;
float a2 = (angle + 90) * DEG2RAD;
br += [(cos(a) * slength[0]) + (cos(a2) * slength[1]), (sin(a) * slength[0]) + (sin(a2) * slength[1])];
R_BeginPolygon(final_img, drawflags, 1);
R_PolygonVertex(tl, '0 0', final_color, final_alpha);
R_PolygonVertex(tr, '1 0', final_color, final_alpha);
R_PolygonVertex(br, '1 1', final_color, final_alpha);
R_PolygonVertex(bl, '0 1', final_color, final_alpha);
R_EndPolygon();
}
#endif
}
};
};
class uispritesheet_c : uielement_c
{
string image;
string image2;
vector sprite;
vector sheet_size;
// constructor
nonvirtual void() uispritesheet_c {
type = UITYPE::PICTURE;
if (image)
precache_pic(image);
if (image2)
precache_pic(image2);
};
var virtual void(uispritesheet_c this, __inout string img_to_render, __inout vector sprite_to_render) prerender;
virtual void() render {
vector final_color = color * mod_col; //
float final_alpha = alpha * mod_alp * ui_alpha; // handle hightlighting
vector final_origin = ui_position;
vector final_size = [size[0] * ui_scale[0], size[1] * ui_scale[1]];
string final_img = image;
vector final_sprite = sprite;
if (prerender)
prerender(this, final_img, final_sprite);
if (final_img && final_alpha > 0)
{
#ifdef CSQC
final_sprite[0] = floor(final_sprite[0]);
final_sprite[1] = floor(final_sprite[1]);
vector tc_u = '0 0';
vector tc_v = '1 1';
tc_v[0] /= sheet_size[0];
tc_v[1] /= sheet_size[1];
tc_u[0] += tc_v[0] * final_sprite[0];
tc_u[1] += tc_v[1] * final_sprite[1];
tc_v[0] += tc_v[0] * final_sprite[0];
tc_v[1] += tc_v[1] * final_sprite[1];
R_BeginPolygon(final_img, drawflags, 1);
R_PolygonVertex(final_origin, [tc_u[0], tc_u[1]], final_color, final_alpha);
R_PolygonVertex(final_origin + [final_size[0], 0], [tc_v[0], tc_u[1]], final_color, final_alpha);
R_PolygonVertex(final_origin + final_size, [tc_v[0], tc_v[1]], final_color, final_alpha);
R_PolygonVertex(final_origin + [0, final_size[1]], [tc_u[0], tc_v[1]], final_color, final_alpha);
R_EndPolygon();
#endif
}
};
};
class uifill_c : uielement_c
{
var virtual void(uifill_c this, __inout vector color_to_render, __inout float alpha_to_render) prerender;
nonvirtual void() uifill_c {
type = UITYPE::PICTURE;
};
// rendering for fill or pictures
virtual void() render {
vector final_color = color * mod_col; //
float final_alpha = alpha * mod_alp * ui_alpha; // handle hightlighting
vector final_origin = ui_position;
vector final_size = [size[0] * ui_scale[0], size[1] * ui_scale[1]];
if (prerender)
prerender(this, final_color, final_alpha);
if (final_alpha > 0)
{
drawfill(final_origin, final_size, final_color, final_alpha, drawflags);
}
};
};
////////////////
// Text Element
////////////////
class uitext_c : uielement_c
{
string text;
float font;
vector padding;
// constructor
nonvirtual void() uitext_c {
if (!text)
text = "NULL TEXT";
if (!font)
#ifdef MENU
font = FONT_MENU;
#else
font = FONT_USER7;
#endif
type = UITYPE::TEXT;
};
// totalsize
virtual vector() totalsize {
float o_drawfont = drawfont;
drawfont = font;
if (!text)
return '0 0';
float txt_width = stringwidth(text, TRUE, [size[0] * ui_scale[0], size[1] * ui_scale[1]]);
drawfont = o_drawfont;
vector sz = [txt_width, size[1] * ui_scale[1]];
sz += [padding[0] * ui_scale[0], padding[1] * ui_scale[1]];
return sz;
};
var virtual void(uitext_c this, __inout string txt_to_render, __inout vector color_to_render, __inout float alpha_to_render) prerender;
// rendering our text
virtual void() render {
float o_drawfont = drawfont;
drawfont = font;
vector final_color = color * mod_col; //
float final_alpha = alpha * mod_alp * ui_alpha; // handle hightlighting
vector final_origin = ui_position;
final_origin += [padding[0] * ui_scale[0], padding[1] * ui_scale[1]] * 0.5;
vector final_size = [size[0] * ui_scale[0], size[1] * ui_scale[1]];
string final_text = text;
if (prerender)
prerender(this, final_text, final_color, final_alpha);
if (final_size[0] <= 0 || final_size[1] <= 0 || final_alpha <= 0 || !text || !strcmp(text, ""))
return;
drawstring(final_origin, final_text, final_size, final_color, final_alpha, drawflags);
drawfont = o_drawfont;
};
};
void UI_RenderElements(uielement_c chain);
void UI_CheckClick(uielement_c chain);
float UI_CheckInput(uielement_c chain, float nkey, float ascii, float released);
float lastsoundjournal;
void Journal_Sound(void)
{
float r = floor(random() *7) + 1;
if (r == lastsoundjournal)
r += 1;
if (r > 7)
r = 1;
lastsoundjournal = r;
string rsound = ftos(r);
#ifdef MENU
localsound(strcat("sound/ui/journal/journal_page", rsound, ".ogg"));
#else
localcmd(strcat("play2 sound/ui/journal/journal_page", rsound, ".ogg\n"));
#endif
}
#undef frametime