~ubuntu-branches/ubuntu/trusty/teeworlds/trusty-updates

« back to all changes in this revision

Viewing changes to src/game/client/components/menus.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gonéri Le Bouder
  • Date: 2009-04-12 02:32:37 UTC
  • mfrom: (3.2.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090412023237-ufmf1xn0rkjmx6f3
Tags: 0.5.1-2
* Fix the ouput of teeworlds-server --help with /bin/sh ->
  /bin/bash (Closes: #511600)
* Standard version 3.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 
2
#include <stdio.h>
 
3
#include <math.h>
 
4
#include <string.h>
 
5
#include <stdlib.h>
 
6
 
 
7
#include <base/system.h>
 
8
#include <base/math.hpp>
 
9
#include <base/vmath.hpp>
 
10
 
 
11
#include "menus.hpp"
 
12
#include "skins.hpp"
 
13
 
 
14
#include <engine/e_client_interface.h>
 
15
 
 
16
extern "C" {
 
17
        #include <engine/client/ec_font.h>
 
18
}
 
19
 
 
20
#include <game/version.hpp>
 
21
#include <game/generated/g_protocol.hpp>
 
22
 
 
23
#include <game/generated/gc_data.hpp>
 
24
#include <game/client/gameclient.hpp>
 
25
#include <mastersrv/mastersrv.h>
 
26
 
 
27
vec4 MENUS::gui_color;
 
28
vec4 MENUS::color_tabbar_inactive_outgame;
 
29
vec4 MENUS::color_tabbar_active_outgame;
 
30
vec4 MENUS::color_tabbar_inactive;
 
31
vec4 MENUS::color_tabbar_active;
 
32
vec4 MENUS::color_tabbar_inactive_ingame;
 
33
vec4 MENUS::color_tabbar_active_ingame;
 
34
 
 
35
 
 
36
float MENUS::button_height = 25.0f;
 
37
float MENUS::listheader_height = 17.0f;
 
38
float MENUS::fontmod_height = 0.8f;
 
39
 
 
40
INPUT_EVENT MENUS::inputevents[MAX_INPUTEVENTS];
 
41
int MENUS::num_inputevents;
 
42
 
 
43
inline float hue_to_rgb(float v1, float v2, float h)
 
44
{
 
45
   if(h < 0) h += 1;
 
46
   if(h > 1) h -= 1;
 
47
   if((6 * h) < 1) return v1 + ( v2 - v1 ) * 6 * h;
 
48
   if((2 * h) < 1) return v2;
 
49
   if((3 * h) < 2) return v1 + ( v2 - v1 ) * ((2.0f/3.0f) - h) * 6;
 
50
   return v1;
 
51
}
 
52
 
 
53
inline vec3 hsl_to_rgb(vec3 in)
 
54
{
 
55
        float v1, v2;
 
56
        vec3 out;
 
57
 
 
58
        if(in.s == 0)
 
59
        {
 
60
                out.r = in.l;
 
61
                out.g = in.l;
 
62
                out.b = in.l;
 
63
        }
 
64
        else
 
65
        {
 
66
                if(in.l < 0.5f) 
 
67
                        v2 = in.l * (1 + in.s);
 
68
                else           
 
69
                        v2 = (in.l+in.s) - (in.s*in.l);
 
70
 
 
71
                v1 = 2 * in.l - v2;
 
72
 
 
73
                out.r = hue_to_rgb(v1, v2, in.h + (1.0f/3.0f));
 
74
                out.g = hue_to_rgb(v1, v2, in.h);
 
75
                out.b = hue_to_rgb(v1, v2, in.h - (1.0f/3.0f));
 
76
        } 
 
77
 
 
78
        return out;
 
79
}
 
80
 
 
81
 
 
82
MENUS::MENUS()
 
83
{
 
84
        popup = POPUP_NONE;
 
85
        active_page = PAGE_INTERNET;
 
86
        game_page = PAGE_GAME;
 
87
        
 
88
        need_restart = false;
 
89
        need_sendinfo = false;
 
90
        menu_active = true;
 
91
        
 
92
        escape_pressed = false;
 
93
        enter_pressed = false;
 
94
        num_inputevents = 0;
 
95
        
 
96
        demos = 0;
 
97
        num_demos = 0;
 
98
        
 
99
        last_input = time_get();
 
100
}
 
101
 
 
102
vec4 MENUS::button_color_mul(const void *id)
 
103
{
 
104
        if(ui_active_item() == id)
 
105
                return vec4(1,1,1,0.5f);
 
106
        else if(ui_hot_item() == id)
 
107
                return vec4(1,1,1,1.5f);
 
108
        return vec4(1,1,1,1);
 
109
}
 
110
 
 
111
void MENUS::ui_draw_browse_icon(int what, const RECT *r)
 
112
{
 
113
        gfx_texture_set(data->images[IMAGE_BROWSEICONS].id);
 
114
        gfx_quads_begin();
 
115
        select_sprite(what);
 
116
        gfx_quads_drawTL(r->x,r->y,r->w,r->h);
 
117
        gfx_quads_end();
 
118
}
 
119
 
 
120
 
 
121
void MENUS::ui_draw_menu_button(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 
122
{
 
123
        ui_draw_rect(r, vec4(1,1,1,0.5f)*button_color_mul(id), CORNER_ALL, 5.0f);
 
124
        ui_do_label(r, text, r->h*fontmod_height, 0);
 
125
}
 
126
 
 
127
void MENUS::ui_draw_keyselect_button(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 
128
{
 
129
        ui_draw_rect(r, vec4(1,1,1,0.5f)*button_color_mul(id), CORNER_ALL, 5.0f);
 
130
        ui_do_label(r, text, r->h*fontmod_height, 0);
 
131
}
 
132
 
 
133
void MENUS::ui_draw_menu_tab_button(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 
134
{
 
135
        int corners = CORNER_T;
 
136
        vec4 colormod(1,1,1,1);
 
137
        if(extra)
 
138
                corners = *(int *)extra;
 
139
        
 
140
        if(checked)
 
141
                ui_draw_rect(r, color_tabbar_active, corners, 10.0f);
 
142
        else
 
143
                ui_draw_rect(r, color_tabbar_inactive, corners, 10.0f);
 
144
        ui_do_label(r, text, r->h*fontmod_height, 0);
 
145
}
 
146
 
 
147
 
 
148
void MENUS::ui_draw_settings_tab_button(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 
149
{
 
150
        if(checked)
 
151
                ui_draw_rect(r, color_tabbar_active, CORNER_R, 10.0f);
 
152
        else
 
153
                ui_draw_rect(r, color_tabbar_inactive, CORNER_R, 10.0f);
 
154
        ui_do_label(r, text, r->h*fontmod_height, 0);
 
155
}
 
156
 
 
157
void MENUS::ui_draw_grid_header(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 
158
{
 
159
        if(checked)
 
160
                ui_draw_rect(r, vec4(1,1,1,0.5f), CORNER_T, 5.0f);
 
161
        RECT t;
 
162
        ui_vsplit_l(r, 5.0f, 0, &t);
 
163
        ui_do_label(&t, text, r->h*fontmod_height, -1);
 
164
}
 
165
 
 
166
void MENUS::ui_draw_list_row(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 
167
{
 
168
        if(checked)
 
169
        {
 
170
                RECT sr = *r;
 
171
                ui_margin(&sr, 1.5f, &sr);
 
172
                ui_draw_rect(&sr, vec4(1,1,1,0.5f), CORNER_ALL, 4.0f);
 
173
        }
 
174
        ui_do_label(r, text, r->h*fontmod_height, -1);
 
175
}
 
176
 
 
177
void MENUS::ui_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const RECT *r)
 
178
{
 
179
        RECT c = *r;
 
180
        RECT t = *r;
 
181
        c.w = c.h;
 
182
        t.x += c.w;
 
183
        t.w -= c.w;
 
184
        ui_vsplit_l(&t, 5.0f, 0, &t);
 
185
        
 
186
        ui_margin(&c, 2.0f, &c);
 
187
        ui_draw_rect(&c, vec4(1,1,1,0.25f)*button_color_mul(id), CORNER_ALL, 3.0f);
 
188
        c.y += 2;
 
189
        ui_do_label(&c, boxtext, r->h*fontmod_height*0.75f, 0);
 
190
        ui_do_label(&t, text, r->h*fontmod_height*0.8f, -1);
 
191
}
 
192
 
 
193
void MENUS::ui_draw_checkbox(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 
194
{
 
195
        ui_draw_checkbox_common(id, text, checked?"X":"", r);
 
196
}
 
197
 
 
198
 
 
199
void MENUS::ui_draw_checkbox_number(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 
200
{
 
201
        char buf[16];
 
202
        str_format(buf, sizeof(buf), "%d", checked);
 
203
        ui_draw_checkbox_common(id, text, buf, r);
 
204
}
 
205
 
 
206
int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, int str_size, float font_size, bool hidden)
 
207
{
 
208
    int inside = ui_mouse_inside(rect);
 
209
        int r = 0;
 
210
        static int at_index = 0;
 
211
 
 
212
        if(ui_last_active_item() == id)
 
213
        {
 
214
                int len = strlen(str);
 
215
                        
 
216
                if (inside && ui_mouse_button(0))
 
217
                {
 
218
                        int mx_rel = (int)(ui_mouse_x() - rect->x);
 
219
 
 
220
                        for (int i = 1; i <= len; i++)
 
221
                        {
 
222
                                if (gfx_text_width(0, font_size, str, i) + 10 > mx_rel)
 
223
                                {
 
224
                                        at_index = i - 1;
 
225
                                        break;
 
226
                                }
 
227
 
 
228
                                if (i == len)
 
229
                                        at_index = len;
 
230
                        }
 
231
                }
 
232
 
 
233
                for(int i = 0; i < num_inputevents; i++)
 
234
                {
 
235
                        len = strlen(str);
 
236
                        INPUT_EVENT e = inputevents[i];
 
237
                        char c = e.ch;
 
238
                        int k = e.key;
 
239
 
 
240
                        if (at_index > len)
 
241
                                at_index = len;
 
242
                        
 
243
                        if (!(c >= 0 && c < 32) && c != 127)
 
244
                        {
 
245
                                if (len < str_size - 1 && at_index < str_size - 1)
 
246
                                {
 
247
                                        memmove(str + at_index + 1, str + at_index, len - at_index + 1);
 
248
                                        str[at_index] = c;
 
249
                                        at_index++;
 
250
                                        r = 1;
 
251
                                }
 
252
                        }
 
253
                        
 
254
                        if(e.flags&INPFLAG_PRESS)
 
255
                        {
 
256
                                if (k == KEY_BACKSPACE && at_index > 0)
 
257
                                {
 
258
                                        memmove(str + at_index - 1, str + at_index, len - at_index + 1);
 
259
                                        at_index--;
 
260
                                        r = 1;
 
261
                                }
 
262
                                else if (k == KEY_DELETE && at_index < len)
 
263
                                {
 
264
                                        memmove(str + at_index, str + at_index + 1, len - at_index);
 
265
                                        r = 1;
 
266
                                }
 
267
                                else if (k == KEY_RETURN)
 
268
                                        ui_clear_last_active_item();
 
269
                                else if (k == KEY_LEFT && at_index > 0)
 
270
                                        at_index--;
 
271
                                else if (k == KEY_RIGHT && at_index < len)
 
272
                                        at_index++;
 
273
                                else if (k == KEY_HOME)
 
274
                                        at_index = 0;
 
275
                                else if (k == KEY_END)
 
276
                                        at_index = len;
 
277
                        }
 
278
                }
 
279
        }
 
280
 
 
281
        bool just_got_active = false;
 
282
        
 
283
        if(ui_active_item() == id)
 
284
        {
 
285
                if(!ui_mouse_button(0))
 
286
                        ui_set_active_item(0);
 
287
        }
 
288
        else if(ui_hot_item() == id)
 
289
        {
 
290
                if(ui_mouse_button(0))
 
291
                {
 
292
                        if (ui_last_active_item() != id)
 
293
                                just_got_active = true;
 
294
                        ui_set_active_item(id);
 
295
                }
 
296
        }
 
297
        
 
298
        if(inside)
 
299
                ui_set_hot_item(id);
 
300
 
 
301
        RECT textbox = *rect;
 
302
        ui_draw_rect(&textbox, vec4(1,1,1,0.5f), CORNER_ALL, 5.0f);
 
303
        ui_vmargin(&textbox, 5.0f, &textbox);
 
304
        
 
305
        const char *display_str = str;
 
306
        char stars[128];
 
307
        
 
308
        if(hidden)
 
309
        {
 
310
                unsigned s = strlen(str);
 
311
                if(s >= sizeof(stars))
 
312
                        s = sizeof(stars)-1;
 
313
                memset(stars, '*', s);
 
314
                stars[s] = 0;
 
315
                display_str = stars;
 
316
        }
 
317
 
 
318
        ui_do_label(&textbox, display_str, font_size, -1);
 
319
        
 
320
        if (ui_last_active_item() == id && !just_got_active)
 
321
        {
 
322
                float w = gfx_text_width(0, font_size, display_str, at_index);
 
323
                textbox.x += w*ui_scale();
 
324
                ui_do_label(&textbox, "_", font_size, -1);
 
325
        }
 
326
 
 
327
        return r;
 
328
}
 
329
 
 
330
float MENUS::ui_do_scrollbar_v(const void *id, const RECT *rect, float current)
 
331
{
 
332
        RECT handle;
 
333
        static float offset_y;
 
334
        ui_hsplit_t(rect, 33, &handle, 0);
 
335
 
 
336
        handle.y += (rect->h-handle.h)*current;
 
337
 
 
338
        /* logic */
 
339
    float ret = current;
 
340
    int inside = ui_mouse_inside(&handle);
 
341
 
 
342
        if(ui_active_item() == id)
 
343
        {
 
344
                if(!ui_mouse_button(0))
 
345
                        ui_set_active_item(0);
 
346
                
 
347
                float min = rect->y;
 
348
                float max = rect->h-handle.h;
 
349
                float cur = ui_mouse_y()-offset_y;
 
350
                ret = (cur-min)/max;
 
351
                if(ret < 0.0f) ret = 0.0f;
 
352
                if(ret > 1.0f) ret = 1.0f;
 
353
        }
 
354
        else if(ui_hot_item() == id)
 
355
        {
 
356
                if(ui_mouse_button(0))
 
357
                {
 
358
                        ui_set_active_item(id);
 
359
                        offset_y = ui_mouse_y()-handle.y;
 
360
                }
 
361
        }
 
362
        
 
363
        if(inside)
 
364
                ui_set_hot_item(id);
 
365
 
 
366
        // render
 
367
        RECT rail;
 
368
        ui_vmargin(rect, 5.0f, &rail);
 
369
        ui_draw_rect(&rail, vec4(1,1,1,0.25f), 0, 0.0f);
 
370
 
 
371
        RECT slider = handle;
 
372
        slider.w = rail.x-slider.x;
 
373
        ui_draw_rect(&slider, vec4(1,1,1,0.25f), CORNER_L, 2.5f);
 
374
        slider.x = rail.x+rail.w;
 
375
        ui_draw_rect(&slider, vec4(1,1,1,0.25f), CORNER_R, 2.5f);
 
376
 
 
377
        slider = handle;
 
378
        ui_margin(&slider, 5.0f, &slider);
 
379
        ui_draw_rect(&slider, vec4(1,1,1,0.25f)*button_color_mul(id), CORNER_ALL, 2.5f);
 
380
        
 
381
    return ret;
 
382
}
 
383
 
 
384
 
 
385
 
 
386
float MENUS::ui_do_scrollbar_h(const void *id, const RECT *rect, float current)
 
387
{
 
388
        RECT handle;
 
389
        static float offset_x;
 
390
        ui_vsplit_l(rect, 33, &handle, 0);
 
391
 
 
392
        handle.x += (rect->w-handle.w)*current;
 
393
 
 
394
        /* logic */
 
395
    float ret = current;
 
396
    int inside = ui_mouse_inside(&handle);
 
397
 
 
398
        if(ui_active_item() == id)
 
399
        {
 
400
                if(!ui_mouse_button(0))
 
401
                        ui_set_active_item(0);
 
402
                
 
403
                float min = rect->x;
 
404
                float max = rect->w-handle.w;
 
405
                float cur = ui_mouse_x()-offset_x;
 
406
                ret = (cur-min)/max;
 
407
                if(ret < 0.0f) ret = 0.0f;
 
408
                if(ret > 1.0f) ret = 1.0f;
 
409
        }
 
410
        else if(ui_hot_item() == id)
 
411
        {
 
412
                if(ui_mouse_button(0))
 
413
                {
 
414
                        ui_set_active_item(id);
 
415
                        offset_x = ui_mouse_x()-handle.x;
 
416
                }
 
417
        }
 
418
        
 
419
        if(inside)
 
420
                ui_set_hot_item(id);
 
421
 
 
422
        // render
 
423
        RECT rail;
 
424
        ui_hmargin(rect, 5.0f, &rail);
 
425
        ui_draw_rect(&rail, vec4(1,1,1,0.25f), 0, 0.0f);
 
426
 
 
427
        RECT slider = handle;
 
428
        slider.h = rail.y-slider.y;
 
429
        ui_draw_rect(&slider, vec4(1,1,1,0.25f), CORNER_T, 2.5f);
 
430
        slider.y = rail.y+rail.h;
 
431
        ui_draw_rect(&slider, vec4(1,1,1,0.25f), CORNER_B, 2.5f);
 
432
 
 
433
        slider = handle;
 
434
        ui_margin(&slider, 5.0f, &slider);
 
435
        ui_draw_rect(&slider, vec4(1,1,1,0.25f)*button_color_mul(id), CORNER_ALL, 2.5f);
 
436
        
 
437
    return ret;
 
438
}
 
439
 
 
440
int MENUS::ui_do_key_reader(void *id, const RECT *rect, int key)
 
441
{
 
442
        // process
 
443
        static void *grabbed_id = 0;
 
444
        static bool mouse_released = true;
 
445
        int inside = ui_mouse_inside(rect);
 
446
        int new_key = key;
 
447
        
 
448
        if(!ui_mouse_button(0) && grabbed_id == id)
 
449
                mouse_released = true;
 
450
 
 
451
        if(ui_active_item() == id)
 
452
        {
 
453
                if(binder.got_key)
 
454
                {
 
455
                        new_key = binder.key.key;
 
456
                        binder.got_key = false;
 
457
                        ui_set_active_item(0);
 
458
                        mouse_released = false;
 
459
                        grabbed_id = id;
 
460
                }
 
461
        }
 
462
        else if(ui_hot_item() == id)
 
463
        {
 
464
                if(ui_mouse_button(0) && mouse_released)
 
465
                {
 
466
                        binder.take_key = true;
 
467
                        binder.got_key = false;
 
468
                        ui_set_active_item(id);
 
469
                }
 
470
        }
 
471
        
 
472
        if(inside)
 
473
                ui_set_hot_item(id);
 
474
 
 
475
        // draw
 
476
        if (ui_active_item() == id)
 
477
                ui_draw_keyselect_button(id, "???", 0, rect, 0);
 
478
        else
 
479
        {
 
480
                if(key == 0)
 
481
                        ui_draw_keyselect_button(id, "", 0, rect, 0);
 
482
                else
 
483
                        ui_draw_keyselect_button(id, inp_key_name(key), 0, rect, 0);
 
484
        }
 
485
        return new_key;
 
486
}
 
487
 
 
488
 
 
489
int MENUS::render_menubar(RECT r)
 
490
{
 
491
        RECT box = r;
 
492
        RECT button;
 
493
        
 
494
        int active_page = config.ui_page;
 
495
        int new_page = -1;
 
496
        
 
497
        if(client_state() != CLIENTSTATE_OFFLINE)
 
498
                active_page = game_page;
 
499
        
 
500
        if(client_state() == CLIENTSTATE_OFFLINE)
 
501
        {
 
502
                /* offline menus */
 
503
                if(0) // this is not done yet
 
504
                {
 
505
                        ui_vsplit_l(&box, 90.0f, &button, &box);
 
506
                        static int news_button=0;
 
507
                        if (ui_do_button(&news_button, "News", active_page==PAGE_NEWS, &button, ui_draw_menu_tab_button, 0))
 
508
                                new_page = PAGE_NEWS;
 
509
                        ui_vsplit_l(&box, 30.0f, 0, &box); 
 
510
                }
 
511
 
 
512
                ui_vsplit_l(&box, 100.0f, &button, &box);
 
513
                static int internet_button=0;
 
514
                int corners = CORNER_TL;
 
515
                if (ui_do_button(&internet_button, "Internet", active_page==PAGE_INTERNET, &button, ui_draw_menu_tab_button, &corners))
 
516
                {
 
517
                        client_serverbrowse_refresh(BROWSETYPE_INTERNET);
 
518
                        new_page = PAGE_INTERNET;
 
519
                }
 
520
 
 
521
                //ui_vsplit_l(&box, 4.0f, 0, &box);
 
522
                ui_vsplit_l(&box, 80.0f, &button, &box);
 
523
                static int lan_button=0;
 
524
                corners = 0;
 
525
                if (ui_do_button(&lan_button, "LAN", active_page==PAGE_LAN, &button, ui_draw_menu_tab_button, &corners))
 
526
                {
 
527
                        client_serverbrowse_refresh(BROWSETYPE_LAN);
 
528
                        new_page = PAGE_LAN;
 
529
                }
 
530
 
 
531
                //ui_vsplit_l(&box, 4.0f, 0, &box);
 
532
                ui_vsplit_l(&box, 110.0f, &button, &box);
 
533
                static int favorites_button=0;
 
534
                corners = CORNER_TR;
 
535
                if (ui_do_button(&favorites_button, "Favorites", active_page==PAGE_FAVORITES, &button, ui_draw_menu_tab_button, &corners))
 
536
                {
 
537
                        client_serverbrowse_refresh(BROWSETYPE_FAVORITES);
 
538
                        new_page  = PAGE_FAVORITES;
 
539
                }
 
540
                
 
541
                ui_vsplit_l(&box, 4.0f*5, 0, &box);
 
542
                ui_vsplit_l(&box, 100.0f, &button, &box);
 
543
                static int demos_button=0;
 
544
                if (ui_do_button(&demos_button, "Demos", active_page==PAGE_DEMOS, &button, ui_draw_menu_tab_button, 0))
 
545
                {
 
546
                        demolist_populate();
 
547
                        new_page  = PAGE_DEMOS;
 
548
                }               
 
549
        }
 
550
        else
 
551
        {
 
552
                /* online menus */
 
553
                ui_vsplit_l(&box, 90.0f, &button, &box);
 
554
                static int game_button=0;
 
555
                if (ui_do_button(&game_button, "Game", active_page==PAGE_GAME, &button, ui_draw_menu_tab_button, 0))
 
556
                        new_page = PAGE_GAME;
 
557
 
 
558
                ui_vsplit_l(&box, 4.0f, 0, &box);
 
559
                ui_vsplit_l(&box, 140.0f, &button, &box);
 
560
                static int server_info_button=0;
 
561
                if (ui_do_button(&server_info_button, "Server Info", active_page==PAGE_SERVER_INFO, &button, ui_draw_menu_tab_button, 0))
 
562
                        new_page = PAGE_SERVER_INFO;
 
563
 
 
564
                ui_vsplit_l(&box, 4.0f, 0, &box);
 
565
                ui_vsplit_l(&box, 140.0f, &button, &box);
 
566
                static int callvote_button=0;
 
567
                if (ui_do_button(&callvote_button, "Call Vote", active_page==PAGE_CALLVOTE, &button, ui_draw_menu_tab_button, 0))
 
568
                        new_page = PAGE_CALLVOTE;
 
569
                        
 
570
                ui_vsplit_l(&box, 30.0f, 0, &box);
 
571
        }
 
572
                
 
573
        /*
 
574
        ui_vsplit_r(&box, 110.0f, &box, &button);
 
575
        static int system_button=0;
 
576
        if (ui_do_button(&system_button, "System", config.ui_page==PAGE_SYSTEM, &button, ui_draw_menu_tab_button, 0))
 
577
                config.ui_page = PAGE_SYSTEM;
 
578
                
 
579
        ui_vsplit_r(&box, 30.0f, &box, 0);
 
580
        */
 
581
        
 
582
        ui_vsplit_r(&box, 90.0f, &box, &button);
 
583
        static int quit_button=0;
 
584
        if (ui_do_button(&quit_button, "Quit", 0, &button, ui_draw_menu_tab_button, 0))
 
585
                popup = POPUP_QUIT;
 
586
 
 
587
        ui_vsplit_r(&box, 10.0f, &box, &button);
 
588
        ui_vsplit_r(&box, 120.0f, &box, &button);
 
589
        static int settings_button=0;
 
590
        if (ui_do_button(&settings_button, "Settings", active_page==PAGE_SETTINGS, &button, ui_draw_menu_tab_button, 0))
 
591
                new_page = PAGE_SETTINGS;
 
592
        
 
593
        if(new_page != -1)
 
594
        {
 
595
                if(client_state() == CLIENTSTATE_OFFLINE)
 
596
                        config.ui_page = new_page;
 
597
                else
 
598
                        game_page = new_page;
 
599
        }
 
600
                
 
601
        return 0;
 
602
}
 
603
 
 
604
void MENUS::render_loading(float percent)
 
605
{
 
606
        // need up date this here to get correct
 
607
        vec3 rgb = hsl_to_rgb(vec3(config.ui_color_hue/255.0f, config.ui_color_sat/255.0f, config.ui_color_lht/255.0f));
 
608
        gui_color = vec4(rgb.r, rgb.g, rgb.b, config.ui_color_alpha/255.0f);
 
609
        
 
610
    RECT screen = *ui_screen();
 
611
        gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
 
612
        
 
613
        render_background();
 
614
 
 
615
        float tw;
 
616
 
 
617
        float w = 700;
 
618
        float h = 200;
 
619
        float x = screen.w/2-w/2;
 
620
        float y = screen.h/2-h/2;
 
621
 
 
622
        gfx_blend_normal();
 
623
 
 
624
        gfx_texture_set(-1);
 
625
        gfx_quads_begin();
 
626
        gfx_setcolor(0,0,0,0.50f);
 
627
        draw_round_rect(x, y, w, h, 40.0f);
 
628
        gfx_quads_end();
 
629
 
 
630
 
 
631
        const char *caption = "Loading";
 
632
 
 
633
        tw = gfx_text_width(0, 48.0f, caption, -1);
 
634
        RECT r;
 
635
        r.x = x;
 
636
        r.y = y+20;
 
637
        r.w = w;
 
638
        r.h = h;
 
639
        ui_do_label(&r, caption, 48.0f, 0, -1);
 
640
 
 
641
        gfx_texture_set(-1);
 
642
        gfx_quads_begin();
 
643
        gfx_setcolor(1,1,1,0.75f);
 
644
        draw_round_rect(x+40, y+h-75, (w-80)*percent, 25, 5.0f);
 
645
        gfx_quads_end();
 
646
 
 
647
        gfx_swap();
 
648
}
 
649
 
 
650
void MENUS::render_news(RECT main_view)
 
651
{
 
652
        ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f);
 
653
}
 
654
 
 
655
void MENUS::init()
 
656
{
 
657
        if(config.cl_show_welcome)
 
658
                popup = POPUP_FIRST_LAUNCH;
 
659
        config.cl_show_welcome = 0;
 
660
}
 
661
 
 
662
int MENUS::render()
 
663
{
 
664
    RECT screen = *ui_screen();
 
665
        gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
 
666
 
 
667
        static bool first = true;
 
668
        if(first)
 
669
        {
 
670
                if(config.ui_page == PAGE_INTERNET)
 
671
                        client_serverbrowse_refresh(0);
 
672
                else if(config.ui_page == PAGE_LAN)
 
673
                        client_serverbrowse_refresh(1);
 
674
                first = false;
 
675
        }
 
676
        
 
677
        if(client_state() == CLIENTSTATE_ONLINE)
 
678
        {
 
679
                color_tabbar_inactive = color_tabbar_inactive_ingame;
 
680
                color_tabbar_active = color_tabbar_active_ingame;
 
681
        }
 
682
        else
 
683
        {
 
684
                render_background();
 
685
                color_tabbar_inactive = color_tabbar_inactive_outgame;
 
686
                color_tabbar_active = color_tabbar_active_outgame;
 
687
        }
 
688
        
 
689
        RECT tab_bar;
 
690
        RECT main_view;
 
691
 
 
692
        // some margin around the screen
 
693
        ui_margin(&screen, 10.0f, &screen);
 
694
        
 
695
        if(popup == POPUP_NONE)
 
696
        {
 
697
                // do tab bar
 
698
                ui_hsplit_t(&screen, 24.0f, &tab_bar, &main_view);
 
699
                ui_vmargin(&tab_bar, 20.0f, &tab_bar);
 
700
                render_menubar(tab_bar);
 
701
                
 
702
                // news is not implemented yet
 
703
                if(config.ui_page <= PAGE_NEWS || config.ui_page > PAGE_SETTINGS || (client_state() == CLIENTSTATE_OFFLINE && config.ui_page >= PAGE_GAME && config.ui_page <= PAGE_CALLVOTE))
 
704
                {
 
705
                        client_serverbrowse_refresh(BROWSETYPE_INTERNET);
 
706
                        config.ui_page = PAGE_INTERNET;
 
707
                }
 
708
                
 
709
                // render current page
 
710
                if(client_state() != CLIENTSTATE_OFFLINE)
 
711
                {
 
712
                        if(game_page == PAGE_GAME)
 
713
                                render_game(main_view);
 
714
                        else if(game_page == PAGE_SERVER_INFO)
 
715
                                render_serverinfo(main_view);
 
716
                        else if(game_page == PAGE_CALLVOTE)
 
717
                                render_servercontrol(main_view);
 
718
                        else if(game_page == PAGE_SETTINGS)
 
719
                                render_settings(main_view);
 
720
                }
 
721
                else if(config.ui_page == PAGE_NEWS)
 
722
                        render_news(main_view);
 
723
                else if(config.ui_page == PAGE_INTERNET)
 
724
                        render_serverbrowser(main_view);
 
725
                else if(config.ui_page == PAGE_LAN)
 
726
                        render_serverbrowser(main_view);
 
727
                else if(config.ui_page == PAGE_DEMOS)
 
728
                        render_demolist(main_view);
 
729
                else if(config.ui_page == PAGE_FAVORITES)
 
730
                        render_serverbrowser(main_view);
 
731
                else if(config.ui_page == PAGE_SETTINGS)
 
732
                        render_settings(main_view);
 
733
        }
 
734
        else
 
735
        {
 
736
                // make sure that other windows doesn't do anything funnay!
 
737
                //ui_set_hot_item(0);
 
738
                //ui_set_active_item(0);
 
739
                char buf[128];
 
740
                const char *title = "";
 
741
                const char *extra_text = "";
 
742
                const char *button_text = "";
 
743
                int extra_align = 0;
 
744
                
 
745
                if(popup == POPUP_CONNECTING)
 
746
                {
 
747
                        title = "Connecting to";
 
748
                        extra_text = config.ui_server_address;  // TODO: query the client about the address
 
749
                        button_text = "Abort";
 
750
                        if(client_mapdownload_totalsize() > 0)
 
751
                        {
 
752
                                title = "Downloading map";
 
753
                                str_format(buf, sizeof(buf), "%d/%d KiB", client_mapdownload_amount()/1024, client_mapdownload_totalsize()/1024);
 
754
                                extra_text = buf;
 
755
                        }
 
756
                }
 
757
                else if(popup == POPUP_DISCONNECTED)
 
758
                {
 
759
                        title = "Disconnected";
 
760
                        extra_text = client_error_string();
 
761
                        button_text = "Ok";
 
762
                        extra_align = -1;
 
763
                }
 
764
                else if(popup == POPUP_PURE)
 
765
                {
 
766
                        title = "Disconnected";
 
767
                        extra_text = "The server is running a non-standard tuning on a pure game mode.";
 
768
                        button_text = "Ok";
 
769
                        extra_align = -1;
 
770
                }
 
771
                else if(popup == POPUP_PASSWORD)
 
772
                {
 
773
                        title = "Password Error";
 
774
                        extra_text = client_error_string();
 
775
                        button_text = "Try Again";
 
776
                }
 
777
                else if(popup == POPUP_QUIT)
 
778
                {
 
779
                        title = "Quit";
 
780
                        extra_text = "Are you sure that you want to quit?";
 
781
                }
 
782
                else if(popup == POPUP_FIRST_LAUNCH)
 
783
                {
 
784
                        title = "Welcome to Teeworlds";
 
785
                        extra_text =
 
786
                        "As this is the first time you launch the game, please enter your nick name below. "
 
787
                        "It's recommended that you check the settings to adjust them to your liking "
 
788
                        "before joining a server.";
 
789
                        button_text = "Ok";
 
790
                        extra_align = -1;
 
791
                }
 
792
                
 
793
                RECT box, part;
 
794
                box = screen;
 
795
                ui_vmargin(&box, 150.0f, &box);
 
796
                ui_hmargin(&box, 150.0f, &box);
 
797
                
 
798
                // render the box
 
799
                ui_draw_rect(&box, vec4(0,0,0,0.5f), CORNER_ALL, 15.0f);
 
800
                 
 
801
                ui_hsplit_t(&box, 20.f, &part, &box);
 
802
                ui_hsplit_t(&box, 24.f, &part, &box);
 
803
                ui_do_label(&part, title, 24.f, 0);
 
804
                ui_hsplit_t(&box, 20.f, &part, &box);
 
805
                ui_hsplit_t(&box, 24.f, &part, &box);
 
806
                ui_vmargin(&part, 20.f, &part);
 
807
                
 
808
                if(extra_align == -1)
 
809
                        ui_do_label(&part, extra_text, 20.f, -1, (int)part.w);
 
810
                else
 
811
                        ui_do_label(&part, extra_text, 20.f, 0, -1);
 
812
 
 
813
                if(popup == POPUP_QUIT)
 
814
                {
 
815
                        RECT yes, no;
 
816
                        ui_hsplit_b(&box, 20.f, &box, &part);
 
817
                        ui_hsplit_b(&box, 24.f, &box, &part);
 
818
                        ui_vmargin(&part, 80.0f, &part);
 
819
                        
 
820
                        ui_vsplit_mid(&part, &no, &yes);
 
821
                        
 
822
                        ui_vmargin(&yes, 20.0f, &yes);
 
823
                        ui_vmargin(&no, 20.0f, &no);
 
824
 
 
825
                        static int button_abort = 0;
 
826
                        if(ui_do_button(&button_abort, "No", 0, &no, ui_draw_menu_button, 0) || escape_pressed)
 
827
                                popup = POPUP_NONE;
 
828
 
 
829
                        static int button_tryagain = 0;
 
830
                        if(ui_do_button(&button_tryagain, "Yes", 0, &yes, ui_draw_menu_button, 0) || enter_pressed)
 
831
                                client_quit();
 
832
                }
 
833
                else if(popup == POPUP_PASSWORD)
 
834
                {
 
835
                        RECT label, textbox, tryagain, abort;
 
836
                        
 
837
                        ui_hsplit_b(&box, 20.f, &box, &part);
 
838
                        ui_hsplit_b(&box, 24.f, &box, &part);
 
839
                        ui_vmargin(&part, 80.0f, &part);
 
840
                        
 
841
                        ui_vsplit_mid(&part, &abort, &tryagain);
 
842
                        
 
843
                        ui_vmargin(&tryagain, 20.0f, &tryagain);
 
844
                        ui_vmargin(&abort, 20.0f, &abort);
 
845
                        
 
846
                        static int button_abort = 0;
 
847
                        if(ui_do_button(&button_abort, "Abort", 0, &abort, ui_draw_menu_button, 0) || escape_pressed)
 
848
                                popup = POPUP_NONE;
 
849
 
 
850
                        static int button_tryagain = 0;
 
851
                        if(ui_do_button(&button_tryagain, "Try again", 0, &tryagain, ui_draw_menu_button, 0) || enter_pressed)
 
852
                        {
 
853
                                client_connect(config.ui_server_address);
 
854
                        }
 
855
                        
 
856
                        ui_hsplit_b(&box, 60.f, &box, &part);
 
857
                        ui_hsplit_b(&box, 24.f, &box, &part);
 
858
                        
 
859
                        ui_vsplit_l(&part, 60.0f, 0, &label);
 
860
                        ui_vsplit_l(&label, 100.0f, 0, &textbox);
 
861
                        ui_vsplit_l(&textbox, 20.0f, 0, &textbox);
 
862
                        ui_vsplit_r(&textbox, 60.0f, &textbox, 0);
 
863
                        ui_do_label(&label, "Password:", 20, -1);
 
864
                        ui_do_edit_box(&config.password, &textbox, config.password, sizeof(config.password), 14.0f, true);
 
865
                }
 
866
                else if(popup == POPUP_FIRST_LAUNCH)
 
867
                {
 
868
                        RECT label, textbox;
 
869
                        
 
870
                        ui_hsplit_b(&box, 20.f, &box, &part);
 
871
                        ui_hsplit_b(&box, 24.f, &box, &part);
 
872
                        ui_vmargin(&part, 80.0f, &part);
 
873
                        
 
874
                        static int enter_button = 0;
 
875
                        if(ui_do_button(&enter_button, "Enter", 0, &part, ui_draw_menu_button, 0) || enter_pressed)
 
876
                                popup = POPUP_NONE;
 
877
                        
 
878
                        ui_hsplit_b(&box, 40.f, &box, &part);
 
879
                        ui_hsplit_b(&box, 24.f, &box, &part);
 
880
                        
 
881
                        ui_vsplit_l(&part, 60.0f, 0, &label);
 
882
                        ui_vsplit_l(&label, 100.0f, 0, &textbox);
 
883
                        ui_vsplit_l(&textbox, 20.0f, 0, &textbox);
 
884
                        ui_vsplit_r(&textbox, 60.0f, &textbox, 0);
 
885
                        ui_do_label(&label, "Nickname:", 20, -1);
 
886
                        ui_do_edit_box(&config.player_name, &textbox, config.player_name, sizeof(config.player_name), 14.0f);
 
887
                }
 
888
                else
 
889
                {
 
890
                        ui_hsplit_b(&box, 20.f, &box, &part);
 
891
                        ui_hsplit_b(&box, 24.f, &box, &part);
 
892
                        ui_vmargin(&part, 120.0f, &part);
 
893
 
 
894
                        static int button = 0;
 
895
                        if(ui_do_button(&button, button_text, 0, &part, ui_draw_menu_button, 0) || escape_pressed || enter_pressed)
 
896
                        {
 
897
                                if(popup == POPUP_CONNECTING)
 
898
                                        client_disconnect();
 
899
                                popup = POPUP_NONE;
 
900
                        }
 
901
                }
 
902
        }
 
903
        
 
904
        return 0;
 
905
}
 
906
 
 
907
 
 
908
void MENUS::set_active(bool active)
 
909
{
 
910
        menu_active = active;
 
911
        if(!menu_active && need_sendinfo)
 
912
        {
 
913
                gameclient.send_info(false);
 
914
                need_sendinfo = false;
 
915
        }
 
916
}
 
917
 
 
918
void MENUS::on_reset()
 
919
{
 
920
}
 
921
 
 
922
bool MENUS::on_mousemove(float x, float y)
 
923
{
 
924
        last_input = time_get();
 
925
        
 
926
        if(!menu_active)
 
927
                return false;
 
928
                
 
929
        mouse_pos.x += x;
 
930
        mouse_pos.y += y;
 
931
        if(mouse_pos.x < 0) mouse_pos.x = 0;
 
932
        if(mouse_pos.y < 0) mouse_pos.y = 0;
 
933
        if(mouse_pos.x > gfx_screenwidth()) mouse_pos.x = gfx_screenwidth();
 
934
        if(mouse_pos.y > gfx_screenheight()) mouse_pos.y = gfx_screenheight();
 
935
        
 
936
        return true;
 
937
}
 
938
 
 
939
bool MENUS::on_input(INPUT_EVENT e)
 
940
{
 
941
        last_input = time_get();
 
942
        
 
943
        // special handle esc and enter for popup purposes
 
944
        if(e.flags&INPFLAG_PRESS)
 
945
        {
 
946
                if(e.key == KEY_ESCAPE)
 
947
                {
 
948
                        escape_pressed = true;
 
949
                        set_active(!is_active());
 
950
                        return true;
 
951
                }
 
952
        }
 
953
                
 
954
        if(is_active())
 
955
        {
 
956
                // special for popups
 
957
                if(e.flags&INPFLAG_PRESS && e.key == KEY_RETURN)
 
958
                        enter_pressed = true;
 
959
                
 
960
                if(num_inputevents < MAX_INPUTEVENTS)
 
961
                        inputevents[num_inputevents++] = e;
 
962
                return true;
 
963
        }
 
964
        return false;
 
965
}
 
966
 
 
967
void MENUS::on_statechange(int new_state, int old_state)
 
968
{
 
969
        if(new_state == CLIENTSTATE_OFFLINE)
 
970
        {
 
971
                popup = POPUP_NONE;
 
972
                if(client_error_string() && client_error_string()[0] != 0)
 
973
                {
 
974
                        if(strstr(client_error_string(), "password"))
 
975
                        {
 
976
                                popup = POPUP_PASSWORD;
 
977
                                ui_set_hot_item(&config.password);
 
978
                                ui_set_active_item(&config.password);
 
979
                        }
 
980
                        else
 
981
                                popup = POPUP_DISCONNECTED;
 
982
                }       }
 
983
        else if(new_state == CLIENTSTATE_LOADING)
 
984
        {
 
985
                popup = POPUP_CONNECTING;
 
986
                client_serverinfo_request();
 
987
        }
 
988
        else if(new_state == CLIENTSTATE_CONNECTING)
 
989
                popup = POPUP_CONNECTING;
 
990
        else if (new_state == CLIENTSTATE_ONLINE || new_state == CLIENTSTATE_DEMOPLAYBACK)
 
991
        {
 
992
                popup = POPUP_NONE;
 
993
                set_active(false);
 
994
        }
 
995
}
 
996
 
 
997
void MENUS::on_render()
 
998
{
 
999
        if(client_state() != CLIENTSTATE_ONLINE && client_state() != CLIENTSTATE_DEMOPLAYBACK)
 
1000
                set_active(true);
 
1001
 
 
1002
        if(client_state() == CLIENTSTATE_DEMOPLAYBACK)
 
1003
        {
 
1004
                RECT screen = *ui_screen();
 
1005
                gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
 
1006
                render_demoplayer(screen);
 
1007
        }
 
1008
        
 
1009
        if(client_state() == CLIENTSTATE_ONLINE && gameclient.servermode == gameclient.SERVERMODE_PUREMOD)
 
1010
        {
 
1011
                client_disconnect();
 
1012
                set_active(true);
 
1013
                popup = POPUP_PURE;
 
1014
        }
 
1015
        
 
1016
        if(!is_active())
 
1017
        {
 
1018
                escape_pressed = false;
 
1019
                enter_pressed = false;
 
1020
                num_inputevents = 0;
 
1021
                return;
 
1022
        }
 
1023
        
 
1024
        // update colors
 
1025
        vec3 rgb = hsl_to_rgb(vec3(config.ui_color_hue/255.0f, config.ui_color_sat/255.0f, config.ui_color_lht/255.0f));
 
1026
        gui_color = vec4(rgb.r, rgb.g, rgb.b, config.ui_color_alpha/255.0f);
 
1027
 
 
1028
        color_tabbar_inactive_outgame = vec4(0,0,0,0.25f);
 
1029
        color_tabbar_active_outgame = vec4(0,0,0,0.5f);
 
1030
 
 
1031
        float color_ingame_scale_i = 0.5f;
 
1032
        float color_ingame_scale_a = 0.2f;
 
1033
        color_tabbar_inactive_ingame = vec4(
 
1034
                gui_color.r*color_ingame_scale_i,
 
1035
                gui_color.g*color_ingame_scale_i,
 
1036
                gui_color.b*color_ingame_scale_i,
 
1037
                gui_color.a*0.8f);
 
1038
        
 
1039
        color_tabbar_active_ingame = vec4(
 
1040
                gui_color.r*color_ingame_scale_a,
 
1041
                gui_color.g*color_ingame_scale_a,
 
1042
                gui_color.b*color_ingame_scale_a,
 
1043
                gui_color.a);
 
1044
    
 
1045
        // update the ui
 
1046
        RECT *screen = ui_screen();
 
1047
        float mx = (mouse_pos.x/(float)gfx_screenwidth())*screen->w;
 
1048
        float my = (mouse_pos.y/(float)gfx_screenheight())*screen->h;
 
1049
                
 
1050
        int buttons = 0;
 
1051
        if(inp_key_pressed(KEY_MOUSE_1)) buttons |= 1;
 
1052
        if(inp_key_pressed(KEY_MOUSE_2)) buttons |= 2;
 
1053
        if(inp_key_pressed(KEY_MOUSE_3)) buttons |= 4;
 
1054
                
 
1055
        ui_update(mx,my,mx*3.0f,my*3.0f,buttons);
 
1056
    
 
1057
        // render
 
1058
        if(client_state() != CLIENTSTATE_DEMOPLAYBACK)
 
1059
                render();
 
1060
 
 
1061
        // render cursor
 
1062
        gfx_texture_set(data->images[IMAGE_CURSOR].id);
 
1063
        gfx_quads_begin();
 
1064
        gfx_setcolor(1,1,1,1);
 
1065
        gfx_quads_drawTL(mx,my,24,24);
 
1066
        gfx_quads_end();
 
1067
 
 
1068
        // render debug information
 
1069
        if(config.debug)
 
1070
        {
 
1071
                RECT screen = *ui_screen();
 
1072
                gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
 
1073
 
 
1074
                char buf[512];
 
1075
                str_format(buf, sizeof(buf), "%p %p %p", ui_hot_item(), ui_active_item(), ui_last_active_item());
 
1076
                TEXT_CURSOR cursor;
 
1077
                gfx_text_set_cursor(&cursor, 10, 10, 10, TEXTFLAG_RENDER);
 
1078
                gfx_text_ex(&cursor, buf, -1);
 
1079
        }
 
1080
 
 
1081
        escape_pressed = false;
 
1082
        enter_pressed = false;
 
1083
        num_inputevents = 0;
 
1084
}
 
1085
 
 
1086
static int texture_blob = -1;
 
1087
 
 
1088
void MENUS::render_background()
 
1089
{
 
1090
        //gfx_clear(1,1,1);
 
1091
        //render_sunrays(0,0);
 
1092
        if(texture_blob == -1)
 
1093
                texture_blob = gfx_load_texture("blob.png", IMG_AUTO, 0);
 
1094
 
 
1095
 
 
1096
        float sw = 300*gfx_screenaspect();
 
1097
        float sh = 300;
 
1098
        gfx_mapscreen(0, 0, sw, sh);
 
1099
 
 
1100
        RECT s = *ui_screen();
 
1101
 
 
1102
        // render background color
 
1103
        gfx_texture_set(-1);
 
1104
        gfx_quads_begin();
 
1105
                //vec4 bottom(gui_color.r*0.3f, gui_color.g*0.3f, gui_color.b*0.3f, 1.0f);
 
1106
                //vec4 bottom(0, 0, 0, 1.0f);
 
1107
                vec4 bottom(gui_color.r, gui_color.g, gui_color.b, 1.0f);
 
1108
                vec4 top(gui_color.r, gui_color.g, gui_color.b, 1.0f);
 
1109
                gfx_setcolorvertex(0, top.r, top.g, top.b, top.a);
 
1110
                gfx_setcolorvertex(1, top.r, top.g, top.b, top.a);
 
1111
                gfx_setcolorvertex(2, bottom.r, bottom.g, bottom.b, bottom.a);
 
1112
                gfx_setcolorvertex(3, bottom.r, bottom.g, bottom.b, bottom.a);
 
1113
                gfx_quads_drawTL(0, 0, sw, sh);
 
1114
        gfx_quads_end();
 
1115
        
 
1116
        // render the tiles
 
1117
        gfx_texture_set(-1);
 
1118
        gfx_quads_begin();
 
1119
                float size = 15.0f;
 
1120
                float offset_time = fmod(client_localtime()*0.15f, 2.0f);
 
1121
                for(int y = -2; y < (int)(sw/size); y++)
 
1122
                        for(int x = -2; x < (int)(sh/size); x++)
 
1123
                        {
 
1124
                                gfx_setcolor(0,0,0,0.045f);
 
1125
                                gfx_quads_drawTL((x-offset_time)*size*2+(y&1)*size, (y+offset_time)*size, size, size);
 
1126
                        }
 
1127
        gfx_quads_end();
 
1128
 
 
1129
        // render border fade
 
1130
        gfx_texture_set(texture_blob);
 
1131
        gfx_quads_begin();
 
1132
                gfx_setcolor(0,0,0,0.5f);
 
1133
                gfx_quads_drawTL(-100, -100, sw+200, sh+200);
 
1134
        gfx_quads_end();
 
1135
 
 
1136
        // restore screen       
 
1137
    {RECT screen = *ui_screen();
 
1138
        gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);} 
 
1139
}