diff options
Diffstat (limited to 'src/game/client/components')
28 files changed, 1473 insertions, 1319 deletions
diff --git a/src/game/client/components/broadcast.cpp b/src/game/client/components/broadcast.cpp index 960b004c..b86ed658 100644 --- a/src/game/client/components/broadcast.cpp +++ b/src/game/client/components/broadcast.cpp @@ -1,5 +1,6 @@ #include <engine/e_client_interface.h> #include <engine/e_config.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -14,12 +15,12 @@ void BROADCAST::on_reset() void BROADCAST::on_render() { - gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300); + Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300); if(time_get() < broadcast_time) { float w = gfx_text_width(0, 14, broadcast_text, -1); - gfx_text(0, 150*gfx_screenaspect()-w/2, 35, 14, broadcast_text, -1); + gfx_text(0, 150*Graphics()->ScreenAspect()-w/2, 35, 14, broadcast_text, -1); } } diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 37015337..fdf1d21b 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -1,6 +1,7 @@ #include <string.h> // strcmp #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -133,7 +134,7 @@ void CHAT::add_line(int client_id, int team, const char *line) void CHAT::on_render() { - gfx_mapscreen(0,0,300*gfx_screenaspect(),300); + Graphics()->MapScreen(0,0,300*Graphics()->ScreenAspect(),300); float x = 10.0f; float y = 300.0f-20.0f; if(mode != MODE_NONE) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 7b806b36..382cb134 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -6,10 +6,9 @@ #include <base/system.h> #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> -extern "C" { - #include <engine/e_ringbuffer.h> -} +#include <engine/e_ringbuffer.h> #include <cstring> #include <cstdio> @@ -34,8 +33,8 @@ enum CONSOLE::INSTANCE::INSTANCE(int t) { // init ringbuffers - history = ringbuf_init(history_data, sizeof(history_data), RINGBUF_FLAG_RECYCLE); - backlog = ringbuf_init(backlog_data, sizeof(backlog_data), RINGBUF_FLAG_RECYCLE); + //history = ringbuf_init(history_data, sizeof(history_data), RINGBUF_FLAG_RECYCLE); + //backlog = ringbuf_init(backlog_data, sizeof(backlog_data), RINGBUF_FLAG_RECYCLE); history_entry = 0x0; @@ -83,7 +82,7 @@ void CONSOLE::INSTANCE::on_input(INPUT_EVENT e) { if(input.get_string()[0]) { - char *entry = (char *)ringbuf_allocate(history, input.get_length()+1); + char *entry = history.Allocate(input.get_length()+1); mem_copy(entry, input.get_string(), input.get_length()+1); execute_line(input.get_string()); @@ -97,13 +96,13 @@ void CONSOLE::INSTANCE::on_input(INPUT_EVENT e) { if (history_entry) { - char *test = (char *)ringbuf_prev(history, history_entry); + char *test = history.Prev(history_entry); if (test) history_entry = test; } else - history_entry = (char *)ringbuf_last(history); + history_entry = history.Last(); if (history_entry) { @@ -116,7 +115,7 @@ void CONSOLE::INSTANCE::on_input(INPUT_EVENT e) else if (e.key == KEY_DOWN) { if (history_entry) - history_entry = (char *)ringbuf_next(history, history_entry); + history_entry = history.Next(history_entry); if (history_entry) { @@ -173,7 +172,7 @@ void CONSOLE::INSTANCE::print_line(const char *line) if (len > 255) len = 255; - char *entry = (char *)ringbuf_allocate(backlog, len+1); + char *entry = backlog.Allocate(len+1); mem_copy(entry, line, len+1); } @@ -212,6 +211,7 @@ static float console_scale_func(float t) struct RENDERINFO { + CONSOLE *self; TEXT_CURSOR cursor; const char *current_cmd; int wanted_completion; @@ -225,11 +225,11 @@ void CONSOLE::possible_commands_render_callback(const char *str, void *user) if(info->enum_count == info->wanted_completion) { float tw = gfx_text_width(info->cursor.font, info->cursor.font_size, str, -1); - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f); - draw_round_rect(info->cursor.x-3, info->cursor.y, tw+5, info->cursor.font_size+4, info->cursor.font_size/3); - gfx_quads_end(); + info->self->Graphics()->TextureSet(-1); + info->self->Graphics()->QuadsBegin(); + info->self->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f); + info->self->RenderTools()->draw_round_rect(info->cursor.x-3, info->cursor.y, tw+5, info->cursor.font_size+4, info->cursor.font_size/3); + info->self->Graphics()->QuadsEnd(); gfx_text_color(0.05f, 0.05f, 0.05f,1); gfx_text_ex(&info->cursor, str, -1); @@ -260,7 +260,7 @@ void CONSOLE::possible_commands_render_callback(const char *str, void *user) void CONSOLE::on_render() { - RECT screen = *ui_screen(); + CUIRect screen = *UI()->Screen(); float console_max_height = screen.h*3/5.0f; float console_height; @@ -296,45 +296,45 @@ void CONSOLE::on_render() console_height = console_height_scale*console_max_height; - gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); + Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h); // do console shadow - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolorvertex(0, 0,0,0, 0.5f); - gfx_setcolorvertex(1, 0,0,0, 0.5f); - gfx_setcolorvertex(2, 0,0,0, 0.0f); - gfx_setcolorvertex(3, 0,0,0, 0.0f); - gfx_quads_drawTL(0,console_height,screen.w,10.0f); - gfx_quads_end(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColorVertex(0, 0,0,0, 0.5f); + Graphics()->SetColorVertex(1, 0,0,0, 0.5f); + Graphics()->SetColorVertex(2, 0,0,0, 0.0f); + Graphics()->SetColorVertex(3, 0,0,0, 0.0f); + Graphics()->QuadsDrawTL(0,console_height,screen.w,10.0f); + Graphics()->QuadsEnd(); // do background - gfx_texture_set(data->images[IMAGE_CONSOLE_BG].id); - gfx_quads_begin(); - gfx_setcolor(0.2f, 0.2f, 0.2f,0.9f); + Graphics()->TextureSet(data->images[IMAGE_CONSOLE_BG].id); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0.2f, 0.2f, 0.2f,0.9f); if(console_type != 0) - gfx_setcolor(0.4f, 0.2f, 0.2f,0.9f); - gfx_quads_setsubset(0,-console_height*0.075f,screen.w*0.075f*0.5f,0); - gfx_quads_drawTL(0,0,screen.w,console_height); - gfx_quads_end(); + Graphics()->SetColor(0.4f, 0.2f, 0.2f,0.9f); + Graphics()->QuadsSetSubset(0,-console_height*0.075f,screen.w*0.075f*0.5f,0); + Graphics()->QuadsDrawTL(0,0,screen.w,console_height); + Graphics()->QuadsEnd(); // do small bar shadow - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolorvertex(0, 0,0,0, 0.0f); - gfx_setcolorvertex(1, 0,0,0, 0.0f); - gfx_setcolorvertex(2, 0,0,0, 0.25f); - gfx_setcolorvertex(3, 0,0,0, 0.25f); - gfx_quads_drawTL(0,console_height-20,screen.w,10); - gfx_quads_end(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColorVertex(0, 0,0,0, 0.0f); + Graphics()->SetColorVertex(1, 0,0,0, 0.0f); + Graphics()->SetColorVertex(2, 0,0,0, 0.25f); + Graphics()->SetColorVertex(3, 0,0,0, 0.25f); + Graphics()->QuadsDrawTL(0,console_height-20,screen.w,10); + Graphics()->QuadsEnd(); // do the lower bar - gfx_texture_set(data->images[IMAGE_CONSOLE_BAR].id); - gfx_quads_begin(); - gfx_setcolor(1.0f, 1.0f, 1.0f, 0.9f); - gfx_quads_setsubset(0,0.1f,screen.w*0.015f,1-0.1f); - gfx_quads_drawTL(0,console_height-10.0f,screen.w,10.0f); - gfx_quads_end(); + Graphics()->TextureSet(data->images[IMAGE_CONSOLE_BAR].id); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.9f); + Graphics()->QuadsSetSubset(0,0.1f,screen.w*0.015f,1-0.1f); + Graphics()->QuadsDrawTL(0,console_height-10.0f,screen.w,10.0f); + Graphics()->QuadsEnd(); console_height -= 22.0f; @@ -351,6 +351,7 @@ void CONSOLE::on_render() gfx_text_set_cursor(&cursor, x, y, font_size, TEXTFLAG_RENDER); RENDERINFO info; + info.self = this; info.wanted_completion = console->completion_chosen; info.enum_count = 0; info.current_cmd = console->completion_buffer; @@ -407,13 +408,13 @@ void CONSOLE::on_render() // render log y -= row_height; - char *entry = (char *)ringbuf_last(console->backlog); + char *entry = console->backlog.Last(); while (y > 0.0f && entry) { gfx_text(0, x, y, font_size, entry, -1); y -= row_height; - entry = (char *)ringbuf_prev(console->backlog, entry); + entry = console->backlog.Prev(entry); } } } diff --git a/src/game/client/components/console.hpp b/src/game/client/components/console.hpp index 0a4adbda..78da98b8 100644 --- a/src/game/client/components/console.hpp +++ b/src/game/client/components/console.hpp @@ -1,4 +1,5 @@ #include <engine/e_client_interface.h> +#include <engine/e_ringbuffer.h> #include <game/client/component.hpp> #include <game/client/lineinput.hpp> @@ -7,12 +8,9 @@ class CONSOLE : public COMPONENT class INSTANCE { public: - char history_data[65536]; - struct RINGBUFFER *history; + TStaticRingBuffer<char, 64*1024, CRingBufferBase::FLAG_RECYCLE> backlog; + TStaticRingBuffer<char, 64*1024, CRingBufferBase::FLAG_RECYCLE> history; char *history_entry; - - char backlog_data[65536]; - struct RINGBUFFER *backlog; LINEINPUT input; diff --git a/src/game/client/components/damageind.cpp b/src/game/client/components/damageind.cpp index f585e4d3..7f1991dc 100644 --- a/src/game/client/components/damageind.cpp +++ b/src/game/client/components/damageind.cpp @@ -1,4 +1,5 @@ #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -44,8 +45,8 @@ void DAMAGEIND::create(vec2 pos, vec2 dir) void DAMAGEIND::on_render() { - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); for(int i = 0; i < num_items;) { vec2 pos = mix(items[i].pos+items[i].dir*75.0f, items[i].pos, clamp((items[i].life-0.60f)/0.15f, 0.0f, 1.0f)); @@ -55,12 +56,12 @@ void DAMAGEIND::on_render() destroy_i(&items[i]); else { - gfx_setcolor(1.0f,1.0f,1.0f, items[i].life/0.1f); - gfx_quads_setrotation(items[i].startangle + items[i].life * 2.0f); - select_sprite(SPRITE_STAR1); - draw_sprite(pos.x, pos.y, 48.0f); + Graphics()->SetColor(1.0f,1.0f,1.0f, items[i].life/0.1f); + Graphics()->QuadsSetRotation(items[i].startangle + items[i].life * 2.0f); + RenderTools()->select_sprite(SPRITE_STAR1); + RenderTools()->draw_sprite(pos.x, pos.y, 48.0f); i++; } } - gfx_quads_end(); + Graphics()->QuadsEnd(); } diff --git a/src/game/client/components/debughud.cpp b/src/game/client/components/debughud.cpp index ada006ea..c7cc559b 100644 --- a/src/game/client/components/debughud.cpp +++ b/src/game/client/components/debughud.cpp @@ -5,6 +5,7 @@ extern "C" { } #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -23,7 +24,7 @@ void DEBUGHUD::render_netcorrections() if(!config.debug || !gameclient.snap.local_character || !gameclient.snap.local_prev_character) return; - gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300); + Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300); /*float speed = distance(vec2(netobjects.local_prev_character->x, netobjects.local_prev_character->y), vec2(netobjects.local_character->x, netobjects.local_character->y));*/ @@ -50,7 +51,7 @@ void DEBUGHUD::render_tuning() TUNING_PARAMS standard_tuning; - gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300); + Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300); float y = 50.0f; int count = 0; @@ -87,9 +88,9 @@ void DEBUGHUD::render_tuning() y = y+count*6; - gfx_texture_set(-1); - gfx_blend_normal(); - gfx_lines_begin(); + Graphics()->TextureSet(-1); + Graphics()->BlendNormal(); + Graphics()->LinesBegin(); float height = 50.0f; float pv = 1; for(int i = 0; i < 100; i++) @@ -97,11 +98,11 @@ void DEBUGHUD::render_tuning() float speed = i/100.0f * 3000; float ramp = velocity_ramp(speed, gameclient.tuning.velramp_start, gameclient.tuning.velramp_range, gameclient.tuning.velramp_curvature); float rampedspeed = (speed * ramp)/1000.0f; - gfx_lines_draw((i-1)*2, y+height-pv*height, i*2, y+height-rampedspeed*height); - //gfx_lines_draw((i-1)*2, 200, i*2, 200); + Graphics()->LinesDraw((i-1)*2, y+height-pv*height, i*2, y+height-rampedspeed*height); + //Graphics()->LinesDraw((i-1)*2, 200, i*2, 200); pv = rampedspeed; } - gfx_lines_end(); + Graphics()->LinesEnd(); gfx_text_color(1,1,1,1); } diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index 934b2fcf..8001a306 100644 --- a/src/game/client/components/emoticon.cpp +++ b/src/game/client/components/emoticon.cpp @@ -1,4 +1,5 @@ #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -70,7 +71,7 @@ void EMOTICON::draw_circle(float x, float y, float r, int segments) float sa2 = sinf(a2); float sa3 = sinf(a3); - gfx_quads_draw_freeform( + client->Graphics()->QuadsDrawFreeform( x, y, x+ca1*r, y+sa1*r, x+ca3*r, y+sa3*r, @@ -107,20 +108,20 @@ void EMOTICON::on_render() if (length(selector_mouse) > 100) selected_emote = (int)(selected_angle / (2*pi) * 12.0f); - RECT screen = *ui_screen(); + CUIRect screen = *UI()->Screen(); - gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); + Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h); - gfx_blend_normal(); + Graphics()->BlendNormal(); - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.3f); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.3f); draw_circle(screen.w/2, screen.h/2, 160, 64); - gfx_quads_end(); + Graphics()->QuadsEnd(); - gfx_texture_set(data->images[IMAGE_EMOTICONS].id); - gfx_quads_begin(); + Graphics()->TextureSet(data->images[IMAGE_EMOTICONS].id); + Graphics()->QuadsBegin(); for (int i = 0; i < 12; i++) { @@ -134,17 +135,17 @@ void EMOTICON::on_render() float nudge_x = 120 * cos(angle); float nudge_y = 120 * sin(angle); - select_sprite(SPRITE_OOP + i); - gfx_quads_draw(screen.w/2 + nudge_x, screen.h/2 + nudge_y, size, size); + RenderTools()->select_sprite(SPRITE_OOP + i); + Graphics()->QuadsDraw(screen.w/2 + nudge_x, screen.h/2 + nudge_y, size, size); } - gfx_quads_end(); + Graphics()->QuadsEnd(); - gfx_texture_set(data->images[IMAGE_CURSOR].id); - gfx_quads_begin(); - gfx_setcolor(1,1,1,1); - gfx_quads_drawTL(selector_mouse.x+screen.w/2,selector_mouse.y+screen.h/2,24,24); - gfx_quads_end(); + Graphics()->TextureSet(data->images[IMAGE_CURSOR].id); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1,1,1,1); + Graphics()->QuadsDrawTL(selector_mouse.x+screen.w/2,selector_mouse.y+screen.h/2,24,24); + Graphics()->QuadsEnd(); } void EMOTICON::emote(int emoticon) diff --git a/src/game/client/components/flow.cpp b/src/game/client/components/flow.cpp index b2f983e6..9ecd4b5c 100644 --- a/src/game/client/components/flow.cpp +++ b/src/game/client/components/flow.cpp @@ -1,3 +1,4 @@ +#include <engine/client/graphics.h> #include <game/mapitems.hpp> #include <game/layers.hpp> #include "flow.hpp" @@ -15,17 +16,17 @@ void FLOW::dbg_render() if(!cells) return; - gfx_texture_set(-1); - gfx_lines_begin(); + Graphics()->TextureSet(-1); + Graphics()->LinesBegin(); for(int y = 0; y < height; y++) for(int x = 0; x < width; x++) { vec2 pos(x*spacing, y*spacing); vec2 vel = cells[y*width+x].vel * 0.01f; - gfx_lines_draw(pos.x, pos.y, pos.x+vel.x, pos.y+vel.y); + Graphics()->LinesDraw(pos.x, pos.y, pos.x+vel.x, pos.y+vel.y); } - gfx_lines_end(); + Graphics()->LinesEnd(); } void FLOW::init() diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index b1926ab4..837322fb 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -1,6 +1,7 @@ #include <memory.h> // memcmp #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -35,11 +36,11 @@ void HUD::render_goals() int gameflags = gameclient.snap.gameobj->flags; - float whole = 300*gfx_screenaspect(); + float whole = 300*Graphics()->ScreenAspect(); float half = whole/2.0f; - gfx_mapscreen(0,0,300*gfx_screenaspect(),300); + Graphics()->MapScreen(0,0,300*Graphics()->ScreenAspect(),300); if(!gameclient.snap.gameobj->sudden_death) { char buf[32]; @@ -71,15 +72,15 @@ void HUD::render_goals() { for(int t = 0; t < 2; t++) { - gfx_blend_normal(); - gfx_texture_set(-1); - gfx_quads_begin(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); if(t == 0) - gfx_setcolor(1,0,0,0.25f); + Graphics()->SetColor(1,0,0,0.25f); else - gfx_setcolor(0,0,1,0.25f); - draw_round_rect(whole-40, 300-40-15+t*20, 50, 18, 5.0f); - gfx_quads_end(); + Graphics()->SetColor(0,0,1,0.25f); + RenderTools()->draw_round_rect(whole-40, 300-40-15+t*20, 50, 18, 5.0f); + Graphics()->QuadsEnd(); char buf[32]; str_format(buf, sizeof(buf), "%d", t?gameclient.snap.gameobj->teamscore_blue:gameclient.snap.gameobj->teamscore_red); @@ -92,16 +93,16 @@ void HUD::render_goals() { if(gameclient.snap.flags[t]->carried_by == -2 || (gameclient.snap.flags[t]->carried_by == -1 && ((client_tick()/10)&1))) { - gfx_blend_normal(); - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); - if(t == 0) select_sprite(SPRITE_FLAG_RED); - else select_sprite(SPRITE_FLAG_BLUE); + if(t == 0) RenderTools()->select_sprite(SPRITE_FLAG_RED); + else RenderTools()->select_sprite(SPRITE_FLAG_BLUE); float size = 16; - gfx_quads_drawTL(whole-40+5, 300-40-15+t*20+1, size/2, size); - gfx_quads_end(); + Graphics()->QuadsDrawTL(whole-40+5, 300-40-15+t*20+1, size/2, size); + Graphics()->QuadsEnd(); } else if(gameclient.snap.flags[t]->carried_by >= 0) { @@ -112,7 +113,7 @@ void HUD::render_goals() TEE_RENDER_INFO info = gameclient.clients[id].render_info; info.size = 18.0f; - render_tee(ANIMSTATE::get_idle(), &info, EMOTE_NORMAL, vec2(1,0), + RenderTools()->RenderTee(ANIMSTATE::get_idle(), &info, EMOTE_NORMAL, vec2(1,0), vec2(whole-40+10, 300-40-15+9+t*20+1)); } } @@ -127,7 +128,7 @@ void HUD::render_goals() { char buf[256]; float w = gfx_text_width(0, 24, "Warmup", -1); - gfx_text(0, 150*gfx_screenaspect()+-w/2, 50, 24, "Warmup", -1); + gfx_text(0, 150*Graphics()->ScreenAspect()+-w/2, 50, 24, "Warmup", -1); int seconds = gameclient.snap.gameobj->warmup/SERVER_TICK_SPEED; if(seconds < 5) @@ -135,16 +136,16 @@ void HUD::render_goals() else str_format(buf, sizeof(buf), "%d", seconds); w = gfx_text_width(0, 24, buf, -1); - gfx_text(0, 150*gfx_screenaspect()+-w/2, 75, 24, buf, -1); + gfx_text(0, 150*Graphics()->ScreenAspect()+-w/2, 75, 24, buf, -1); } } -static void mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *group) +void HUD::mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *group) { float points[4]; - mapscreen_to_world(center_x, center_y, group->parallax_x/100.0f, group->parallax_y/100.0f, - group->offset_x, group->offset_y, gfx_screenaspect(), 1.0f, points); - gfx_mapscreen(points[0], points[1], points[2], points[3]); + RenderTools()->mapscreen_to_world(center_x, center_y, group->parallax_x/100.0f, group->parallax_y/100.0f, + group->offset_x, group->offset_y, Graphics()->ScreenAspect(), 1.0f, points); + Graphics()->MapScreen(points[0], points[1], points[2], points[3]); } void HUD::render_fps() @@ -163,7 +164,7 @@ void HUD::render_connectionwarning() { const char *text = "Connection Problems..."; float w = gfx_text_width(0, 24, text, -1); - gfx_text(0, 150*gfx_screenaspect()-w/2, 50, 24, text, -1); + gfx_text(0, 150*Graphics()->ScreenAspect()-w/2, 50, 24, text, -1); } } @@ -192,11 +193,11 @@ void HUD::render_voting() if(!gameclient.voting->is_voting()) return; - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.40f); - draw_round_rect(-10, 60-2, 100+10+4+5, 28, 5.0f); - gfx_quads_end(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.40f); + RenderTools()->draw_round_rect(-10, 60-2, 100+10+4+5, 28, 5.0f); + Graphics()->QuadsEnd(); gfx_text_color(1,1,1,1); @@ -208,17 +209,17 @@ void HUD::render_voting() gfx_text(0x0, 5+100-tw, 60, 6, buf, -1); - RECT base = {5, 70, 100, 4}; + CUIRect base = {5, 70, 100, 4}; gameclient.voting->render_bars(base, false); const char *yes_key = gameclient.binds->get_key("vote yes"); const char *no_key = gameclient.binds->get_key("vote no"); str_format(buf, sizeof(buf), "%s - Vote Yes", yes_key); base.y += base.h+1; - ui_do_label(&base, buf, 6.0f, -1); + UI()->DoLabel(&base, buf, 6.0f, -1); str_format(buf, sizeof(buf), "Vote No - %s", no_key); - ui_do_label(&base, buf, 6.0f, 1); + UI()->DoLabel(&base, buf, 6.0f, 1); } void HUD::render_cursor() @@ -227,14 +228,14 @@ void HUD::render_cursor() return; mapscreen_to_group(gameclient.camera->center.x, gameclient.camera->center.y, layers_game_group()); - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); // render cursor - select_sprite(data->weapons.id[gameclient.snap.local_character->weapon%NUM_WEAPONS].sprite_cursor); + RenderTools()->select_sprite(data->weapons.id[gameclient.snap.local_character->weapon%NUM_WEAPONS].sprite_cursor); float cursorsize = 64; - draw_sprite(gameclient.controls->target_pos.x, gameclient.controls->target_pos.y, cursorsize); - gfx_quads_end(); + RenderTools()->draw_sprite(gameclient.controls->target_pos.x, gameclient.controls->target_pos.y, cursorsize); + Graphics()->QuadsEnd(); } void HUD::render_healthandammo() @@ -247,40 +248,40 @@ void HUD::render_healthandammo() // render ammo count // render gui stuff - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_mapscreen(0,0,width,300); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->MapScreen(0,0,width,300); - gfx_quads_begin(); + Graphics()->QuadsBegin(); // if weaponstage is active, put a "glow" around the stage ammo - select_sprite(data->weapons.id[gameclient.snap.local_character->weapon%NUM_WEAPONS].sprite_proj); + RenderTools()->select_sprite(data->weapons.id[gameclient.snap.local_character->weapon%NUM_WEAPONS].sprite_proj); for (int i = 0; i < min(gameclient.snap.local_character->ammocount, 10); i++) - gfx_quads_drawTL(x+i*12,y+24,10,10); + Graphics()->QuadsDrawTL(x+i*12,y+24,10,10); - gfx_quads_end(); + Graphics()->QuadsEnd(); - gfx_quads_begin(); + Graphics()->QuadsBegin(); int h = 0; // render health - select_sprite(SPRITE_HEALTH_FULL); + RenderTools()->select_sprite(SPRITE_HEALTH_FULL); for(; h < gameclient.snap.local_character->health; h++) - gfx_quads_drawTL(x+h*12,y,10,10); + Graphics()->QuadsDrawTL(x+h*12,y,10,10); - select_sprite(SPRITE_HEALTH_EMPTY); + RenderTools()->select_sprite(SPRITE_HEALTH_EMPTY); for(; h < 10; h++) - gfx_quads_drawTL(x+h*12,y,10,10); + Graphics()->QuadsDrawTL(x+h*12,y,10,10); // render armor meter h = 0; - select_sprite(SPRITE_ARMOR_FULL); + RenderTools()->select_sprite(SPRITE_ARMOR_FULL); for(; h < gameclient.snap.local_character->armor; h++) - gfx_quads_drawTL(x+h*12,y+12,10,10); + Graphics()->QuadsDrawTL(x+h*12,y+12,10,10); - select_sprite(SPRITE_ARMOR_EMPTY); + RenderTools()->select_sprite(SPRITE_ARMOR_EMPTY); for(; h < 10; h++) - gfx_quads_drawTL(x+h*12,y+12,10,10); - gfx_quads_end(); + Graphics()->QuadsDrawTL(x+h*12,y+12,10,10); + Graphics()->QuadsEnd(); } void HUD::on_render() @@ -288,7 +289,7 @@ void HUD::on_render() if(!gameclient.snap.gameobj) return; - width = 300*gfx_screenaspect(); + width = 300*Graphics()->ScreenAspect(); bool spectate = false; if(gameclient.snap.local_info && gameclient.snap.local_info->team == -1) diff --git a/src/game/client/components/hud.hpp b/src/game/client/components/hud.hpp index 41fa0ff2..92ff0122 100644 --- a/src/game/client/components/hud.hpp +++ b/src/game/client/components/hud.hpp @@ -13,6 +13,8 @@ class HUD : public COMPONENT void render_healthandammo(); void render_goals(); + + void mapscreen_to_group(float center_x, float center_y, struct MAPITEM_GROUP *group); public: HUD(); diff --git a/src/game/client/components/items.cpp b/src/game/client/components/items.cpp index 1d579619..3c9e1b79 100644 --- a/src/game/client/components/items.cpp +++ b/src/game/client/components/items.cpp @@ -1,4 +1,5 @@ #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -44,10 +45,10 @@ void ITEMS::render_projectile(const NETOBJ_PROJECTILE *current, int itemid) vec2 prevpos = calc_pos(startpos, startvel, curvature, speed, ct-0.001f); - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); - select_sprite(data->weapons.id[clamp(current->type, 0, NUM_WEAPONS-1)].sprite_proj); + RenderTools()->select_sprite(data->weapons.id[clamp(current->type, 0, NUM_WEAPONS-1)].sprite_proj); vec2 vel = pos-prevpos; //vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick()); @@ -57,7 +58,7 @@ void ITEMS::render_projectile(const NETOBJ_PROJECTILE *current, int itemid) { gameclient.effects->smoketrail(pos, vel*-1); gameclient.flow->add(pos, vel*1000*client_frametime(), 10.0f); - gfx_quads_setrotation(client_localtime()*pi*2*2 + itemid); + Graphics()->QuadsSetRotation(client_localtime()*pi*2*2 + itemid); } else { @@ -65,28 +66,28 @@ void ITEMS::render_projectile(const NETOBJ_PROJECTILE *current, int itemid) gameclient.flow->add(pos, vel*1000*client_frametime(), 10.0f); if(length(vel) > 0.00001f) - gfx_quads_setrotation(get_angle(vel)); + Graphics()->QuadsSetRotation(get_angle(vel)); else - gfx_quads_setrotation(0); + Graphics()->QuadsSetRotation(0); } - gfx_quads_draw(pos.x, pos.y, 32, 32); - gfx_quads_setrotation(0); - gfx_quads_end(); + Graphics()->QuadsDraw(pos.x, pos.y, 32, 32); + Graphics()->QuadsSetRotation(0); + Graphics()->QuadsEnd(); } void ITEMS::render_pickup(const NETOBJ_PICKUP *prev, const NETOBJ_PICKUP *current) { - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick()); float angle = 0.0f; float size = 64.0f; if (current->type == POWERUP_WEAPON) { angle = 0; //-pi/6;//-0.25f * pi * 2.0f; - select_sprite(data->weapons.id[clamp(current->subtype, 0, NUM_WEAPONS-1)].sprite_body); + RenderTools()->select_sprite(data->weapons.id[clamp(current->subtype, 0, NUM_WEAPONS-1)].sprite_body); size = data->weapons.id[clamp(current->subtype, 0, NUM_WEAPONS-1)].visual_size; } else @@ -97,7 +98,7 @@ void ITEMS::render_pickup(const NETOBJ_PICKUP *prev, const NETOBJ_PICKUP *curren SPRITE_PICKUP_WEAPON, SPRITE_PICKUP_NINJA }; - select_sprite(c[current->type]); + RenderTools()->select_sprite(c[current->type]); if(c[current->type] == SPRITE_PICKUP_NINJA) { @@ -107,13 +108,13 @@ void ITEMS::render_pickup(const NETOBJ_PICKUP *prev, const NETOBJ_PICKUP *curren } } - gfx_quads_setrotation(angle); + Graphics()->QuadsSetRotation(angle); float offset = pos.y/32.0f + pos.x/32.0f; pos.x += cosf(client_localtime()*2.0f+offset)*2.5f; pos.y += sinf(client_localtime()*2.0f+offset)*2.5f; - draw_sprite(pos.x, pos.y, size); - gfx_quads_end(); + RenderTools()->draw_sprite(pos.x, pos.y, size); + Graphics()->QuadsEnd(); } void ITEMS::render_flag(const NETOBJ_FLAG *prev, const NETOBJ_FLAG *current) @@ -121,16 +122,16 @@ void ITEMS::render_flag(const NETOBJ_FLAG *prev, const NETOBJ_FLAG *current) float angle = 0.0f; float size = 42.0f; - gfx_blend_normal(); - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); if(current->team == 0) // red team - select_sprite(SPRITE_FLAG_RED); + RenderTools()->select_sprite(SPRITE_FLAG_RED); else - select_sprite(SPRITE_FLAG_BLUE); + RenderTools()->select_sprite(SPRITE_FLAG_BLUE); - gfx_quads_setrotation(angle); + Graphics()->QuadsSetRotation(angle); vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick()); @@ -142,8 +143,8 @@ void ITEMS::render_flag(const NETOBJ_FLAG *prev, const NETOBJ_FLAG *current) if(gameclient.snap.local_info && current->carried_by == gameclient.snap.local_info->cid) pos = gameclient.local_character_pos; - gfx_quads_draw(pos.x, pos.y-size*0.75f, size, size*2); - gfx_quads_end(); + Graphics()->QuadsDraw(pos.x, pos.y-size*0.75f, size, size*2); + Graphics()->QuadsEnd(); } @@ -161,19 +162,19 @@ void ITEMS::render_laser(const struct NETOBJ_LASER *current) vec2 out, border; - gfx_blend_normal(); - gfx_texture_set(-1); - gfx_quads_begin(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); //vec4 inner_color(0.15f,0.35f,0.75f,1.0f); //vec4 outer_color(0.65f,0.85f,1.0f,1.0f); // do outline vec4 outer_color(0.075f,0.075f,0.25f,1.0f); - gfx_setcolor(outer_color.r,outer_color.g,outer_color.b,1.0f); + Graphics()->SetColor(outer_color.r,outer_color.g,outer_color.b,1.0f); out = vec2(dir.y, -dir.x) * (7.0f*ia); - gfx_quads_draw_freeform( + Graphics()->QuadsDrawFreeform( from.x-out.x, from.y-out.y, from.x+out.x, from.y+out.y, pos.x-out.x, pos.y-out.y, @@ -183,34 +184,34 @@ void ITEMS::render_laser(const struct NETOBJ_LASER *current) // do inner vec4 inner_color(0.5f,0.5f,1.0f,1.0f); out = vec2(dir.y, -dir.x) * (5.0f*ia); - gfx_setcolor(inner_color.r, inner_color.g, inner_color.b, 1.0f); // center + Graphics()->SetColor(inner_color.r, inner_color.g, inner_color.b, 1.0f); // center - gfx_quads_draw_freeform( + Graphics()->QuadsDrawFreeform( from.x-out.x, from.y-out.y, from.x+out.x, from.y+out.y, pos.x-out.x, pos.y-out.y, pos.x+out.x, pos.y+out.y ); - gfx_quads_end(); + Graphics()->QuadsEnd(); // render head { - gfx_blend_normal(); - gfx_texture_set(data->images[IMAGE_PARTICLES].id); - gfx_quads_begin(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(data->images[IMAGE_PARTICLES].id); + Graphics()->QuadsBegin(); int sprites[] = {SPRITE_PART_SPLAT01, SPRITE_PART_SPLAT02, SPRITE_PART_SPLAT03}; - select_sprite(sprites[client_tick()%3]); - gfx_quads_setrotation(client_tick()); - gfx_setcolor(outer_color.r,outer_color.g,outer_color.b,1.0f); - gfx_quads_draw(pos.x, pos.y, 24,24); - gfx_setcolor(inner_color.r, inner_color.g, inner_color.b, 1.0f); - gfx_quads_draw(pos.x, pos.y, 20,20); - gfx_quads_end(); + RenderTools()->select_sprite(sprites[client_tick()%3]); + Graphics()->QuadsSetRotation(client_tick()); + Graphics()->SetColor(outer_color.r,outer_color.g,outer_color.b,1.0f); + Graphics()->QuadsDraw(pos.x, pos.y, 24,24); + Graphics()->SetColor(inner_color.r, inner_color.g, inner_color.b, 1.0f); + Graphics()->QuadsDraw(pos.x, pos.y, 20,20); + Graphics()->QuadsEnd(); } - gfx_blend_normal(); + Graphics()->BlendNormal(); } void ITEMS::on_render() diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index 410f2c3d..e6232b7d 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -1,4 +1,5 @@ #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -35,10 +36,10 @@ void KILLMESSAGES::on_message(int msgtype, void *rawmsg) void KILLMESSAGES::on_render() { - float width = 400*3.0f*gfx_screenaspect(); + float width = 400*3.0f*Graphics()->ScreenAspect(); float height = 400*3.0f; - gfx_mapscreen(0, 0, width*1.5f, height*1.5f); + Graphics()->MapScreen(0, 0, width*1.5f, height*1.5f); float startx = width*1.5f-10.0f; float y = 20.0f; @@ -66,31 +67,31 @@ void KILLMESSAGES::on_render() { if(killmsgs[r].mode_special&1) { - gfx_blend_normal(); - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); - if(gameclient.clients[killmsgs[r].victim].team == 0) select_sprite(SPRITE_FLAG_BLUE); - else select_sprite(SPRITE_FLAG_RED); + if(gameclient.clients[killmsgs[r].victim].team == 0) RenderTools()->select_sprite(SPRITE_FLAG_BLUE); + else RenderTools()->select_sprite(SPRITE_FLAG_RED); float size = 56.0f; - gfx_quads_drawTL(x, y-16, size/2, size); - gfx_quads_end(); + Graphics()->QuadsDrawTL(x, y-16, size/2, size); + Graphics()->QuadsEnd(); } } - render_tee(ANIMSTATE::get_idle(), &gameclient.clients[killmsgs[r].victim].render_info, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28)); + RenderTools()->RenderTee(ANIMSTATE::get_idle(), &gameclient.clients[killmsgs[r].victim].render_info, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28)); x -= 32.0f; // render weapon x -= 44.0f; if (killmsgs[r].weapon >= 0) { - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); - select_sprite(data->weapons.id[killmsgs[r].weapon].sprite_body); - draw_sprite(x, y+28, 96); - gfx_quads_end(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); + RenderTools()->select_sprite(data->weapons.id[killmsgs[r].weapon].sprite_body); + RenderTools()->draw_sprite(x, y+28, 96); + Graphics()->QuadsEnd(); } x -= 52.0f; @@ -100,22 +101,22 @@ void KILLMESSAGES::on_render() { if(killmsgs[r].mode_special&2) { - gfx_blend_normal(); - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); - if(gameclient.clients[killmsgs[r].killer].team == 0) select_sprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); - else select_sprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); + if(gameclient.clients[killmsgs[r].killer].team == 0) RenderTools()->select_sprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); + else RenderTools()->select_sprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); float size = 56.0f; - gfx_quads_drawTL(x-56, y-16, size/2, size); - gfx_quads_end(); + Graphics()->QuadsDrawTL(x-56, y-16, size/2, size); + Graphics()->QuadsEnd(); } } // render killer tee x -= 24.0f; - render_tee(ANIMSTATE::get_idle(), &gameclient.clients[killmsgs[r].killer].render_info, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28)); + RenderTools()->RenderTee(ANIMSTATE::get_idle(), &gameclient.clients[killmsgs[r].killer].render_info, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28)); x -= 32.0f; // render killer name diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index 7f839da0..51194853 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -1,3 +1,4 @@ +#include <engine/client/graphics.h> #include <game/client/component.hpp> #include <game/mapitems.hpp> @@ -13,7 +14,7 @@ void MAPIMAGES::on_mapload() // unload all textures for(int i = 0; i < count; i++) { - gfx_unload_texture(textures[i]); + Graphics()->UnloadTexture(textures[i]); textures[i] = -1; } count = 0; @@ -32,12 +33,12 @@ void MAPIMAGES::on_mapload() char buf[256]; char *name = (char *)map_get_data(img->image_name); str_format(buf, sizeof(buf), "mapres/%s.png", name); - textures[i] = gfx_load_texture(buf, IMG_AUTO, 0); + textures[i] = Graphics()->LoadTexture(buf, IMG_AUTO, 0); } else { void *data = map_get_data(img->image_data); - textures[i] = gfx_load_texture_raw(img->width, img->height, IMG_RGBA, data, IMG_RGBA, 0); + textures[i] = Graphics()->LoadTextureRaw(img->width, img->height, IMG_RGBA, data, IMG_RGBA, 0); map_unload_data(img->image_data); } } diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 847350e6..75f91521 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -1,3 +1,5 @@ +#include <engine/client/graphics.h> + #include <game/layers.hpp> #include <game/client/gameclient.hpp> #include <game/client/component.hpp> @@ -6,6 +8,7 @@ #include <game/client/components/camera.hpp> #include <game/client/components/mapimages.hpp> + #include "maplayers.hpp" MAPLAYERS::MAPLAYERS(int t) @@ -14,16 +17,17 @@ MAPLAYERS::MAPLAYERS(int t) } -static void mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *group) +void MAPLAYERS::mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *group) { float points[4]; - mapscreen_to_world(center_x, center_y, group->parallax_x/100.0f, group->parallax_y/100.0f, - group->offset_x, group->offset_y, gfx_screenaspect(), 1.0f, points); - gfx_mapscreen(points[0], points[1], points[2], points[3]); + RenderTools()->mapscreen_to_world(center_x, center_y, group->parallax_x/100.0f, group->parallax_y/100.0f, + group->offset_x, group->offset_y, Graphics()->ScreenAspect(), 1.0f, points); + Graphics()->MapScreen(points[0], points[1], points[2], points[3]); } -static void envelope_eval(float time_offset, int env, float *channels) +void MAPLAYERS::envelope_eval(float time_offset, int env, float *channels, void *user) { + MAPLAYERS *pThis = (MAPLAYERS *)user; channels[0] = 0; channels[1] = 0; channels[2] = 0; @@ -45,7 +49,7 @@ static void envelope_eval(float time_offset, int env, float *channels) return; MAPITEM_ENVELOPE *item = (MAPITEM_ENVELOPE *)map_get_item(start+env, 0, 0); - render_eval_envelope(points+item->start_point, item->num_points, 4, client_localtime()+time_offset, channels); + pThis->RenderTools()->render_eval_envelope(points+item->start_point, item->num_points, 4, client_localtime()+time_offset, channels); } void MAPLAYERS::on_render() @@ -53,8 +57,8 @@ void MAPLAYERS::on_render() if(client_state() != CLIENTSTATE_ONLINE && client_state() != CLIENTSTATE_DEMOPLAYBACK) return; - RECT screen; - gfx_getscreen(&screen.x, &screen.y, &screen.w, &screen.h); + CUIRect screen; + Graphics()->GetScreen(&screen.x, &screen.y, &screen.w, &screen.h); vec2 center = gameclient.camera->center; //float center_x = gameclient.camera->center.x; @@ -71,14 +75,14 @@ void MAPLAYERS::on_render() // set clipping float points[4]; mapscreen_to_group(center.x, center.y, layers_game_group()); - gfx_getscreen(&points[0], &points[1], &points[2], &points[3]); + Graphics()->GetScreen(&points[0], &points[1], &points[2], &points[3]); float x0 = (group->clip_x - points[0]) / (points[2]-points[0]); float y0 = (group->clip_y - points[1]) / (points[3]-points[1]); float x1 = ((group->clip_x+group->clip_w) - points[0]) / (points[2]-points[0]); float y1 = ((group->clip_y+group->clip_h) - points[1]) / (points[3]-points[1]); - gfx_clip_enable((int)(x0*gfx_screenwidth()), (int)(y0*gfx_screenheight()), - (int)((x1-x0)*gfx_screenwidth()), (int)((y1-y0)*gfx_screenheight())); + Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()), + (int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight())); } mapscreen_to_group(center.x, center.y, group); @@ -121,43 +125,43 @@ void MAPLAYERS::on_render() { MAPITEM_LAYER_TILEMAP *tmap = (MAPITEM_LAYER_TILEMAP *)layer; if(tmap->image == -1) - gfx_texture_set(-1); + Graphics()->TextureSet(-1); else - gfx_texture_set(gameclient.mapimages->get(tmap->image)); + Graphics()->TextureSet(gameclient.mapimages->get(tmap->image)); TILE *tiles = (TILE *)map_get_data(tmap->data); - gfx_blend_none(); - render_tilemap(tiles, tmap->width, tmap->height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE); - gfx_blend_normal(); - render_tilemap(tiles, tmap->width, tmap->height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT); + Graphics()->BlendNone(); + RenderTools()->render_tilemap(tiles, tmap->width, tmap->height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE); + Graphics()->BlendNormal(); + RenderTools()->render_tilemap(tiles, tmap->width, tmap->height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT); } else if(layer->type == LAYERTYPE_QUADS) { MAPITEM_LAYER_QUADS *qlayer = (MAPITEM_LAYER_QUADS *)layer; if(qlayer->image == -1) - gfx_texture_set(-1); + Graphics()->TextureSet(-1); else - gfx_texture_set(gameclient.mapimages->get(qlayer->image)); + Graphics()->TextureSet(gameclient.mapimages->get(qlayer->image)); QUAD *quads = (QUAD *)map_get_data_swapped(qlayer->data); - gfx_blend_none(); - render_quads(quads, qlayer->num_quads, envelope_eval, LAYERRENDERFLAG_OPAQUE); - gfx_blend_normal(); - render_quads(quads, qlayer->num_quads, envelope_eval, LAYERRENDERFLAG_TRANSPARENT); + Graphics()->BlendNone(); + RenderTools()->render_quads(quads, qlayer->num_quads, LAYERRENDERFLAG_OPAQUE, envelope_eval, this); + Graphics()->BlendNormal(); + RenderTools()->render_quads(quads, qlayer->num_quads, LAYERRENDERFLAG_TRANSPARENT, envelope_eval, this); } //layershot_end(); } } if(!config.gfx_noclip) - gfx_clip_disable(); + Graphics()->ClipDisable(); } if(!config.gfx_noclip) - gfx_clip_disable(); + Graphics()->ClipDisable(); // reset the screen like it was before - gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); + Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h); } diff --git a/src/game/client/components/maplayers.hpp b/src/game/client/components/maplayers.hpp index c2919f08..c8b154b2 100644 --- a/src/game/client/components/maplayers.hpp +++ b/src/game/client/components/maplayers.hpp @@ -3,6 +3,9 @@ class MAPLAYERS : public COMPONENT { int type; + + void mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *group); + static void envelope_eval(float time_offset, int env, float *channels, void *user); public: enum { diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 168c514d..5f1bbf42 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -12,6 +12,7 @@ #include "skins.hpp" #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/version.hpp> #include <game/generated/g_protocol.hpp> @@ -94,356 +95,366 @@ MENUS::MENUS() last_input = time_get(); } -vec4 MENUS::button_color_mul(const void *id) +vec4 MENUS::button_color_mul(const void *pID) { - if(ui_active_item() == id) + if(UI()->ActiveItem() == pID) return vec4(1,1,1,0.5f); - else if(ui_hot_item() == id) + else if(UI()->HotItem() == pID) return vec4(1,1,1,1.5f); return vec4(1,1,1,1); } -void MENUS::ui_draw_browse_icon(int what, const RECT *r) +int MENUS::DoButton_BrowseIcon(int What, const CUIRect *pRect) { - gfx_texture_set(data->images[IMAGE_BROWSEICONS].id); - gfx_quads_begin(); - select_sprite(what); - gfx_quads_drawTL(r->x,r->y,r->w,r->h); - gfx_quads_end(); + Graphics()->TextureSet(data->images[IMAGE_BROWSEICONS].id); + + Graphics()->QuadsBegin(); + RenderTools()->select_sprite(What); + Graphics()->QuadsDrawTL(pRect->x, pRect->y, pRect->w, pRect->h); + Graphics()->QuadsEnd(); + + return 0; } -void MENUS::ui_draw_menu_button(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { - ui_draw_rect(r, vec4(1,1,1,0.5f)*button_color_mul(id), CORNER_ALL, 5.0f); - ui_do_label(r, text, r->h*fontmod_height, 0); + RenderTools()->DrawUIRect(pRect, vec4(1,1,1,0.5f)*button_color_mul(pID), CUI::CORNER_ALL, 5.0f); + UI()->DoLabel(pRect, pText, pRect->h*fontmod_height, 0); + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } -void MENUS::ui_draw_keyselect_button(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { - ui_draw_rect(r, vec4(1,1,1,0.5f)*button_color_mul(id), CORNER_ALL, 5.0f); - ui_do_label(r, text, r->h*fontmod_height, 0); + RenderTools()->DrawUIRect(pRect, vec4(1,1,1,0.5f)*button_color_mul(pID), CUI::CORNER_ALL, 5.0f); + UI()->DoLabel(pRect, pText, pRect->h*fontmod_height, 0); + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } -void MENUS::ui_draw_menu_tab_button(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners) { - int corners = CORNER_T; - vec4 colormod(1,1,1,1); - if(extra) - corners = *(int *)extra; + vec4 ColorMod(1,1,1,1); - if(checked) - ui_draw_rect(r, color_tabbar_active, corners, 10.0f); + if(Checked) + RenderTools()->DrawUIRect(pRect, color_tabbar_active, Corners, 10.0f); else - ui_draw_rect(r, color_tabbar_inactive, corners, 10.0f); - ui_do_label(r, text, r->h*fontmod_height, 0); + RenderTools()->DrawUIRect(pRect, color_tabbar_inactive, Corners, 10.0f); + UI()->DoLabel(pRect, pText, pRect->h*fontmod_height, 0); + + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } -void MENUS::ui_draw_settings_tab_button(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_SettingsTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { - if(checked) - ui_draw_rect(r, color_tabbar_active, CORNER_R, 10.0f); + if(Checked) + RenderTools()->DrawUIRect(pRect, color_tabbar_active, CUI::CORNER_R, 10.0f); else - ui_draw_rect(r, color_tabbar_inactive, CORNER_R, 10.0f); - ui_do_label(r, text, r->h*fontmod_height, 0); + RenderTools()->DrawUIRect(pRect, color_tabbar_inactive, CUI::CORNER_R, 10.0f); + UI()->DoLabel(pRect, pText, pRect->h*fontmod_height, 0); + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } -void MENUS::ui_draw_grid_header(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect) +//void MENUS::ui_draw_grid_header(const void *id, const char *text, int checked, const CUIRect *r, const void *extra) { - if(checked) - ui_draw_rect(r, vec4(1,1,1,0.5f), CORNER_T, 5.0f); - RECT t; - ui_vsplit_l(r, 5.0f, 0, &t); - ui_do_label(&t, text, r->h*fontmod_height, -1); + if(Checked) + RenderTools()->DrawUIRect(pRect, vec4(1,1,1,0.5f), CUI::CORNER_T, 5.0f); + CUIRect t; + pRect->VSplitLeft(5.0f, 0, &t); + UI()->DoLabel(&t, pText, pRect->h*fontmod_height, -1); + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } -void MENUS::ui_draw_list_row(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_ListRow(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { - if(checked) + if(Checked) { - RECT sr = *r; - ui_margin(&sr, 1.5f, &sr); - ui_draw_rect(&sr, vec4(1,1,1,0.5f), CORNER_ALL, 4.0f); + CUIRect sr = *pRect; + sr.Margin(1.5f, &sr); + RenderTools()->DrawUIRect(&sr, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 4.0f); } - ui_do_label(r, text, r->h*fontmod_height, -1); + UI()->DoLabel(pRect, pText, pRect->h*fontmod_height, -1); + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } -void MENUS::ui_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const RECT *r) +int MENUS::DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect) +//void MENUS::ui_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const CUIRect *r, const void *extra) { - RECT c = *r; - RECT t = *r; + CUIRect c = *pRect; + CUIRect t = *pRect; c.w = c.h; t.x += c.w; t.w -= c.w; - ui_vsplit_l(&t, 5.0f, 0, &t); + t.VSplitLeft(5.0f, 0, &t); - ui_margin(&c, 2.0f, &c); - ui_draw_rect(&c, vec4(1,1,1,0.25f)*button_color_mul(id), CORNER_ALL, 3.0f); + c.Margin(2.0f, &c); + RenderTools()->DrawUIRect(&c, vec4(1,1,1,0.25f)*button_color_mul(pID), CUI::CORNER_ALL, 3.0f); c.y += 2; - ui_do_label(&c, boxtext, r->h*fontmod_height*0.6f, 0); - ui_do_label(&t, text, r->h*fontmod_height*0.8f, -1); + UI()->DoLabel(&c, pBoxText, pRect->h*fontmod_height*0.6f, 0); + UI()->DoLabel(&t, pText, pRect->h*fontmod_height*0.8f, -1); + return UI()->DoButtonLogic(pID, pText, 0, pRect); } -void MENUS::ui_draw_checkbox(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { - ui_draw_checkbox_common(id, text, checked?"X":"", r); + return DoButton_CheckBox_Common(pID, pText, Checked?"X":"", pRect); } -void MENUS::ui_draw_checkbox_number(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { char buf[16]; - str_format(buf, sizeof(buf), "%d", checked); - ui_draw_checkbox_common(id, text, buf, r); + str_format(buf, sizeof(buf), "%d", Checked); + return DoButton_CheckBox_Common(pID, pText, buf, pRect); } -int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, unsigned str_size, float font_size, bool hidden) +int MENUS::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, bool Hidden) { - int inside = ui_mouse_inside(rect); - int r = 0; - static int at_index = 0; + int Inside = UI()->MouseInside(pRect); + int ReturnValue = 0; + static int AtIndex = 0; - if(ui_last_active_item() == id) + if(UI()->LastActiveItem() == pID) { - int len = strlen(str); + int Len = strlen(pStr); - if (inside && ui_mouse_button(0)) + if(Inside && UI()->MouseButton(0)) { - int mx_rel = (int)(ui_mouse_x() - rect->x); + int mx_rel = (int)(UI()->MouseX() - pRect->x); - for (int i = 1; i <= len; i++) + for (int i = 1; i <= Len; i++) { - if (gfx_text_width(0, font_size, str, i) + 10 > mx_rel) + if (gfx_text_width(0, FontSize, pStr, i) + 10 > mx_rel) { - at_index = i - 1; + AtIndex = i - 1; break; } - if (i == len) - at_index = len; + if (i == Len) + AtIndex = Len; } } for(int i = 0; i < num_inputevents; i++) { - len = strlen(str); - LINEINPUT::manipulate(inputevents[i], str, str_size, &len, &at_index); + Len = strlen(pStr); + LINEINPUT::manipulate(inputevents[i], pStr, StrSize, &Len, &AtIndex); } } - bool just_got_active = false; + bool JustGotActive = false; - if(ui_active_item() == id) + if(UI()->ActiveItem() == pID) { - if(!ui_mouse_button(0)) - ui_set_active_item(0); + if(!UI()->MouseButton(0)) + UI()->SetActiveItem(0); } - else if(ui_hot_item() == id) + else if(UI()->HotItem() == pID) { - if(ui_mouse_button(0)) + if(UI()->MouseButton(0)) { - if (ui_last_active_item() != id) - just_got_active = true; - ui_set_active_item(id); + if (UI()->LastActiveItem() != pID) + JustGotActive = true; + UI()->SetActiveItem(pID); } } - if(inside) - ui_set_hot_item(id); + if(Inside) + UI()->SetHotItem(pID); - RECT textbox = *rect; - ui_draw_rect(&textbox, vec4(1,1,1,0.5f), CORNER_ALL, 5.0f); - ui_vmargin(&textbox, 5.0f, &textbox); + CUIRect Textbox = *pRect; + RenderTools()->DrawUIRect(&Textbox, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 5.0f); + Textbox.VMargin(5.0f, &Textbox); - const char *display_str = str; - char stars[128]; + const char *pDisplayStr = pStr; + char aStars[128]; - if(hidden) + if(Hidden) { - unsigned s = strlen(str); - if(s >= sizeof(stars)) - s = sizeof(stars)-1; - memset(stars, '*', s); - stars[s] = 0; - display_str = stars; + unsigned s = strlen(pStr); + if(s >= sizeof(aStars)) + s = sizeof(aStars)-1; + memset(aStars, '*', s); + aStars[s] = 0; + pDisplayStr = aStars; } - ui_do_label(&textbox, display_str, font_size, -1); + UI()->DoLabel(&Textbox, pDisplayStr, FontSize, -1); - if (ui_last_active_item() == id && !just_got_active) + if (UI()->LastActiveItem() == pID && !JustGotActive) { - float w = gfx_text_width(0, font_size, display_str, at_index); - textbox.x += w*ui_scale(); - ui_do_label(&textbox, "_", font_size, -1); + float w = gfx_text_width(0, FontSize, pDisplayStr, AtIndex); + Textbox.x += w*UI()->Scale(); + UI()->DoLabel(&Textbox, "_", FontSize, -1); } - return r; + return ReturnValue; } -float MENUS::ui_do_scrollbar_v(const void *id, const RECT *rect, float current) +float MENUS::DoScrollbarV(const void *pID, const CUIRect *pRect, float Current) { - RECT handle; - static float offset_y; - ui_hsplit_t(rect, 33, &handle, 0); + CUIRect Handle; + static float OffsetY; + pRect->HSplitTop(33, &Handle, 0); - handle.y += (rect->h-handle.h)*current; + Handle.y += (pRect->h-Handle.h)*Current; /* logic */ - float ret = current; - int inside = ui_mouse_inside(&handle); + float ReturnValue = Current; + int Inside = UI()->MouseInside(&Handle); - if(ui_active_item() == id) + if(UI()->ActiveItem() == pID) { - if(!ui_mouse_button(0)) - ui_set_active_item(0); + if(!UI()->MouseButton(0)) + UI()->SetActiveItem(0); - float min = rect->y; - float max = rect->h-handle.h; - float cur = ui_mouse_y()-offset_y; - ret = (cur-min)/max; - if(ret < 0.0f) ret = 0.0f; - if(ret > 1.0f) ret = 1.0f; + float min = pRect->y; + float max = pRect->h-Handle.h; + float cur = UI()->MouseY()-OffsetY; + ReturnValue = (cur-min)/max; + if(ReturnValue < 0.0f) ReturnValue = 0.0f; + if(ReturnValue > 1.0f) ReturnValue = 1.0f; } - else if(ui_hot_item() == id) + else if(UI()->HotItem() == pID) { - if(ui_mouse_button(0)) + if(UI()->MouseButton(0)) { - ui_set_active_item(id); - offset_y = ui_mouse_y()-handle.y; + UI()->SetActiveItem(pID); + OffsetY = UI()->MouseY()-Handle.y; } } - if(inside) - ui_set_hot_item(id); + if(Inside) + UI()->SetHotItem(pID); // render - RECT rail; - ui_vmargin(rect, 5.0f, &rail); - ui_draw_rect(&rail, vec4(1,1,1,0.25f), 0, 0.0f); - - RECT slider = handle; - slider.w = rail.x-slider.x; - ui_draw_rect(&slider, vec4(1,1,1,0.25f), CORNER_L, 2.5f); - slider.x = rail.x+rail.w; - ui_draw_rect(&slider, vec4(1,1,1,0.25f), CORNER_R, 2.5f); - - slider = handle; - ui_margin(&slider, 5.0f, &slider); - ui_draw_rect(&slider, vec4(1,1,1,0.25f)*button_color_mul(id), CORNER_ALL, 2.5f); + CUIRect Rail; + pRect->VMargin(5.0f, &Rail); + RenderTools()->DrawUIRect(&Rail, vec4(1,1,1,0.25f), 0, 0.0f); + + CUIRect Slider = Handle; + Slider.w = Rail.x-Slider.x; + RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f), CUI::CORNER_L, 2.5f); + Slider.x = Rail.x+Rail.w; + RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f), CUI::CORNER_R, 2.5f); + + Slider = Handle; + Slider.Margin(5.0f, &Slider); + RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f)*button_color_mul(pID), CUI::CORNER_ALL, 2.5f); - return ret; + return ReturnValue; } -float MENUS::ui_do_scrollbar_h(const void *id, const RECT *rect, float current) +float MENUS::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current) { - RECT handle; - static float offset_x; - ui_vsplit_l(rect, 33, &handle, 0); + CUIRect Handle; + static float OffsetX; + pRect->VSplitLeft(33, &Handle, 0); - handle.x += (rect->w-handle.w)*current; + Handle.x += (pRect->w-Handle.w)*Current; /* logic */ - float ret = current; - int inside = ui_mouse_inside(&handle); + float ReturnValue = Current; + int Inside = UI()->MouseInside(&Handle); - if(ui_active_item() == id) + if(UI()->ActiveItem() == pID) { - if(!ui_mouse_button(0)) - ui_set_active_item(0); + if(!UI()->MouseButton(0)) + UI()->SetActiveItem(0); - float min = rect->x; - float max = rect->w-handle.w; - float cur = ui_mouse_x()-offset_x; - ret = (cur-min)/max; - if(ret < 0.0f) ret = 0.0f; - if(ret > 1.0f) ret = 1.0f; + float min = pRect->x; + float max = pRect->w-Handle.w; + float cur = UI()->MouseX()-OffsetX; + ReturnValue = (cur-min)/max; + if(ReturnValue < 0.0f) ReturnValue = 0.0f; + if(ReturnValue > 1.0f) ReturnValue = 1.0f; } - else if(ui_hot_item() == id) + else if(UI()->HotItem() == pID) { - if(ui_mouse_button(0)) + if(UI()->MouseButton(0)) { - ui_set_active_item(id); - offset_x = ui_mouse_x()-handle.x; + UI()->SetActiveItem(pID); + OffsetX = UI()->MouseX()-Handle.x; } } - if(inside) - ui_set_hot_item(id); + if(Inside) + UI()->SetHotItem(pID); // render - RECT rail; - ui_hmargin(rect, 5.0f, &rail); - ui_draw_rect(&rail, vec4(1,1,1,0.25f), 0, 0.0f); - - RECT slider = handle; - slider.h = rail.y-slider.y; - ui_draw_rect(&slider, vec4(1,1,1,0.25f), CORNER_T, 2.5f); - slider.y = rail.y+rail.h; - ui_draw_rect(&slider, vec4(1,1,1,0.25f), CORNER_B, 2.5f); - - slider = handle; - ui_margin(&slider, 5.0f, &slider); - ui_draw_rect(&slider, vec4(1,1,1,0.25f)*button_color_mul(id), CORNER_ALL, 2.5f); + CUIRect Rail; + pRect->HMargin(5.0f, &Rail); + RenderTools()->DrawUIRect(&Rail, vec4(1,1,1,0.25f), 0, 0.0f); + + CUIRect Slider = Handle; + Slider.h = Rail.y-Slider.y; + RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f), CUI::CORNER_T, 2.5f); + Slider.y = Rail.y+Rail.h; + RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f), CUI::CORNER_B, 2.5f); + + Slider = Handle; + Slider.Margin(5.0f, &Slider); + RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f)*button_color_mul(pID), CUI::CORNER_ALL, 2.5f); - return ret; + return ReturnValue; } -int MENUS::ui_do_key_reader(void *id, const RECT *rect, int key) +int MENUS::DoKeyReader(void *pID, const CUIRect *pRect, int Key) { // process - static void *grabbed_id = 0; - static bool mouse_released = true; - int inside = ui_mouse_inside(rect); - int new_key = key; + static void *pGrabbedID = 0; + static bool MouseReleased = true; + int Inside = UI()->MouseInside(pRect); + int NewKey = Key; - if(!ui_mouse_button(0) && grabbed_id == id) - mouse_released = true; + if(!UI()->MouseButton(0) && pGrabbedID == pID) + MouseReleased = true; - if(ui_active_item() == id) + if(UI()->ActiveItem() == pID) { if(binder.got_key) { - new_key = binder.key.key; + NewKey = binder.key.key; binder.got_key = false; - ui_set_active_item(0); - mouse_released = false; - grabbed_id = id; + UI()->SetActiveItem(0); + MouseReleased = false; + pGrabbedID = pID; } } - else if(ui_hot_item() == id) + else if(UI()->HotItem() == pID) { - if(ui_mouse_button(0) && mouse_released) + if(UI()->MouseButton(0) && MouseReleased) { binder.take_key = true; binder.got_key = false; - ui_set_active_item(id); + UI()->SetActiveItem(pID); } } - if(inside) - ui_set_hot_item(id); + if(Inside) + UI()->SetHotItem(pID); // draw - if (ui_active_item() == id) - ui_draw_keyselect_button(id, "???", 0, rect, 0); + if (UI()->ActiveItem() == pID) + DoButton_KeySelect(pID, "???", 0, pRect); else { - if(key == 0) - ui_draw_keyselect_button(id, "", 0, rect, 0); + if(Key == 0) + DoButton_KeySelect(pID, "", 0, pRect); else - ui_draw_keyselect_button(id, inp_key_name(key), 0, rect, 0); + DoButton_KeySelect(pID, inp_key_name(Key), 0, pRect); } - return new_key; + return NewKey; } -int MENUS::render_menubar(RECT r) +int MENUS::render_menubar(CUIRect r) { - RECT box = r; - RECT button; + CUIRect box = r; + CUIRect button; int active_page = config.ui_page; int new_page = -1; @@ -456,46 +467,43 @@ int MENUS::render_menubar(RECT r) /* offline menus */ if(0) // this is not done yet { - ui_vsplit_l(&box, 90.0f, &button, &box); + box.VSplitLeft(90.0f, &button, &box); static int news_button=0; - if (ui_do_button(&news_button, localize("News"), active_page==PAGE_NEWS, &button, ui_draw_menu_tab_button, 0)) + if (DoButton_MenuTab(&news_button, localize("News"), active_page==PAGE_NEWS, &button, 0)) new_page = PAGE_NEWS; - ui_vsplit_l(&box, 30.0f, 0, &box); + box.VSplitLeft(30.0f, 0, &box); } - ui_vsplit_l(&box, 100.0f, &button, &box); + box.VSplitLeft(100.0f, &button, &box); static int internet_button=0; - int corners = CORNER_TL; - if (ui_do_button(&internet_button, localize("Internet"), active_page==PAGE_INTERNET, &button, ui_draw_menu_tab_button, &corners)) + if(DoButton_MenuTab(&internet_button, localize("Internet"), active_page==PAGE_INTERNET, &button, CUI::CORNER_TL)) { client_serverbrowse_refresh(BROWSETYPE_INTERNET); new_page = PAGE_INTERNET; } - //ui_vsplit_l(&box, 4.0f, 0, &box); - ui_vsplit_l(&box, 80.0f, &button, &box); + //box.VSplitLeft(4.0f, 0, &box); + box.VSplitLeft(80.0f, &button, &box); static int lan_button=0; - corners = 0; - if (ui_do_button(&lan_button, localize("LAN"), active_page==PAGE_LAN, &button, ui_draw_menu_tab_button, &corners)) + if(DoButton_MenuTab(&lan_button, localize("LAN"), active_page==PAGE_LAN, &button, 0)) { client_serverbrowse_refresh(BROWSETYPE_LAN); new_page = PAGE_LAN; } - //ui_vsplit_l(&box, 4.0f, 0, &box); - ui_vsplit_l(&box, 110.0f, &button, &box); + //box.VSplitLeft(4.0f, 0, &box); + box.VSplitLeft(110.0f, &button, &box); static int favorites_button=0; - corners = CORNER_TR; - if (ui_do_button(&favorites_button, localize("Favorites"), active_page==PAGE_FAVORITES, &button, ui_draw_menu_tab_button, &corners)) + if(DoButton_MenuTab(&favorites_button, localize("Favorites"), active_page==PAGE_FAVORITES, &button, CUI::CORNER_TR)) { client_serverbrowse_refresh(BROWSETYPE_FAVORITES); new_page = PAGE_FAVORITES; } - ui_vsplit_l(&box, 4.0f*5, 0, &box); - ui_vsplit_l(&box, 100.0f, &button, &box); + box.VSplitLeft(4.0f*5, 0, &box); + box.VSplitLeft(100.0f, &button, &box); static int demos_button=0; - if (ui_do_button(&demos_button, localize("Demos"), active_page==PAGE_DEMOS, &button, ui_draw_menu_tab_button, 0)) + if(DoButton_MenuTab(&demos_button, localize("Demos"), active_page==PAGE_DEMOS, &button, 0)) { demolist_populate(); new_page = PAGE_DEMOS; @@ -504,44 +512,44 @@ int MENUS::render_menubar(RECT r) else { /* online menus */ - ui_vsplit_l(&box, 90.0f, &button, &box); + box.VSplitLeft(90.0f, &button, &box); static int game_button=0; - if (ui_do_button(&game_button, localize("Game"), active_page==PAGE_GAME, &button, ui_draw_menu_tab_button, 0)) + if(DoButton_MenuTab(&game_button, localize("Game"), active_page==PAGE_GAME, &button, 0)) new_page = PAGE_GAME; - ui_vsplit_l(&box, 4.0f, 0, &box); - ui_vsplit_l(&box, 140.0f, &button, &box); + box.VSplitLeft(4.0f, 0, &box); + box.VSplitLeft(140.0f, &button, &box); static int server_info_button=0; - if (ui_do_button(&server_info_button, localize("Server info"), active_page==PAGE_SERVER_INFO, &button, ui_draw_menu_tab_button, 0)) + if(DoButton_MenuTab(&server_info_button, localize("Server info"), active_page==PAGE_SERVER_INFO, &button, 0)) new_page = PAGE_SERVER_INFO; - ui_vsplit_l(&box, 4.0f, 0, &box); - ui_vsplit_l(&box, 140.0f, &button, &box); + box.VSplitLeft(4.0f, 0, &box); + box.VSplitLeft(140.0f, &button, &box); static int callvote_button=0; - if (ui_do_button(&callvote_button, localize("Call vote"), active_page==PAGE_CALLVOTE, &button, ui_draw_menu_tab_button, 0)) + if(DoButton_MenuTab(&callvote_button, localize("Call vote"), active_page==PAGE_CALLVOTE, &button, 0)) new_page = PAGE_CALLVOTE; - ui_vsplit_l(&box, 30.0f, 0, &box); + box.VSplitLeft(30.0f, 0, &box); } /* - ui_vsplit_r(&box, 110.0f, &box, &button); + box.VSplitRight(110.0f, &box, &button); static int system_button=0; - if (ui_do_button(&system_button, "System", config.ui_page==PAGE_SYSTEM, &button, ui_draw_menu_tab_button, 0)) + if (UI()->DoButton(&system_button, "System", config.ui_page==PAGE_SYSTEM, &button)) config.ui_page = PAGE_SYSTEM; - ui_vsplit_r(&box, 30.0f, &box, 0); + box.VSplitRight(30.0f, &box, 0); */ - ui_vsplit_r(&box, 90.0f, &box, &button); + box.VSplitRight(90.0f, &box, &button); static int quit_button=0; - if (ui_do_button(&quit_button, localize("Quit"), 0, &button, ui_draw_menu_tab_button, 0)) + if(DoButton_MenuTab(&quit_button, localize("Quit"), 0, &button, 0)) popup = POPUP_QUIT; - ui_vsplit_r(&box, 10.0f, &box, &button); - ui_vsplit_r(&box, 130.0f, &box, &button); + box.VSplitRight(10.0f, &box, &button); + box.VSplitRight(130.0f, &box, &button); static int settings_button=0; - if (ui_do_button(&settings_button, localize("Settings"), active_page==PAGE_SETTINGS, &button, ui_draw_menu_tab_button, 0)) + if(DoButton_MenuTab(&settings_button, localize("Settings"), active_page==PAGE_SETTINGS, &button, 0)) new_page = PAGE_SETTINGS; if(new_page != -1) @@ -570,8 +578,8 @@ void MENUS::render_loading(float percent) vec3 rgb = hsl_to_rgb(vec3(config.ui_color_hue/255.0f, config.ui_color_sat/255.0f, config.ui_color_lht/255.0f)); gui_color = vec4(rgb.r, rgb.g, rgb.b, config.ui_color_alpha/255.0f); - RECT screen = *ui_screen(); - gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); + CUIRect screen = *UI()->Screen(); + Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h); render_background(); @@ -582,37 +590,37 @@ void MENUS::render_loading(float percent) float x = screen.w/2-w/2; float y = screen.h/2-h/2; - gfx_blend_normal(); + Graphics()->BlendNormal(); - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.50f); - draw_round_rect(x, y, w, h, 40.0f); - gfx_quads_end(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.50f); + RenderTools()->draw_round_rect(x, y, w, h, 40.0f); + Graphics()->QuadsEnd(); const char *caption = localize("Loading"); tw = gfx_text_width(0, 48.0f, caption, -1); - RECT r; + CUIRect r; r.x = x; r.y = y+20; r.w = w; r.h = h; - ui_do_label(&r, caption, 48.0f, 0, -1); + UI()->DoLabel(&r, caption, 48.0f, 0, -1); - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(1,1,1,0.75f); - draw_round_rect(x+40, y+h-75, (w-80)*percent, 25, 5.0f); - gfx_quads_end(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1,1,1,0.75f); + RenderTools()->draw_round_rect(x+40, y+h-75, (w-80)*percent, 25, 5.0f); + Graphics()->QuadsEnd(); gfx_swap(); } -void MENUS::render_news(RECT main_view) +void MENUS::render_news(CUIRect main_view) { - ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f); + RenderTools()->DrawUIRect(&main_view, color_tabbar_active, CUI::CORNER_ALL, 10.0f); } void MENUS::on_init() @@ -677,8 +685,8 @@ void MENUS::popup_message(const char *topic, const char *body, const char *butto int MENUS::render() { - RECT screen = *ui_screen(); - gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); + CUIRect screen = *UI()->Screen(); + Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h); static bool first = true; if(first) @@ -702,17 +710,17 @@ int MENUS::render() color_tabbar_active = color_tabbar_active_outgame; } - RECT tab_bar; - RECT main_view; + CUIRect tab_bar; + CUIRect main_view; // some margin around the screen - ui_margin(&screen, 10.0f, &screen); + screen.Margin(10.0f, &screen); if(popup == POPUP_NONE) { // do tab bar - ui_hsplit_t(&screen, 24.0f, &tab_bar, &main_view); - ui_vmargin(&tab_bar, 20.0f, &tab_bar); + screen.HSplitTop(24.0f, &tab_bar, &main_view); + tab_bar.VMargin(20.0f, &tab_bar); render_menubar(tab_bar); // news is not implemented yet @@ -750,8 +758,8 @@ int MENUS::render() else { // make sure that other windows doesn't do anything funnay! - //ui_set_hot_item(0); - //ui_set_active_item(0); + //UI()->SetHotItem(0); + //UI()->SetActiveItem(0); char buf[128]; const char *title = ""; const char *extra_text = ""; @@ -809,109 +817,109 @@ int MENUS::render() extra_align = -1; } - RECT box, part; + CUIRect box, part; box = screen; - ui_vmargin(&box, 150.0f, &box); - ui_hmargin(&box, 150.0f, &box); + box.VMargin(150.0f, &box); + box.HMargin(150.0f, &box); // render the box - ui_draw_rect(&box, vec4(0,0,0,0.5f), CORNER_ALL, 15.0f); + RenderTools()->DrawUIRect(&box, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 15.0f); - ui_hsplit_t(&box, 20.f, &part, &box); - ui_hsplit_t(&box, 24.f, &part, &box); - ui_do_label(&part, title, 24.f, 0); - ui_hsplit_t(&box, 20.f, &part, &box); - ui_hsplit_t(&box, 24.f, &part, &box); - ui_vmargin(&part, 20.f, &part); + box.HSplitTop(20.f, &part, &box); + box.HSplitTop(24.f, &part, &box); + UI()->DoLabel(&part, title, 24.f, 0); + box.HSplitTop(20.f, &part, &box); + box.HSplitTop(24.f, &part, &box); + part.VMargin(20.f, &part); if(extra_align == -1) - ui_do_label(&part, extra_text, 20.f, -1, (int)part.w); + UI()->DoLabel(&part, extra_text, 20.f, -1, (int)part.w); else - ui_do_label(&part, extra_text, 20.f, 0, -1); + UI()->DoLabel(&part, extra_text, 20.f, 0, -1); if(popup == POPUP_QUIT) { - RECT yes, no; - ui_hsplit_b(&box, 20.f, &box, &part); - ui_hsplit_b(&box, 24.f, &box, &part); - ui_vmargin(&part, 80.0f, &part); + CUIRect yes, no; + box.HSplitBottom(20.f, &box, &part); + box.HSplitBottom(24.f, &box, &part); + part.VMargin(80.0f, &part); - ui_vsplit_mid(&part, &no, &yes); + part.VSplitMid(&no, &yes); - ui_vmargin(&yes, 20.0f, &yes); - ui_vmargin(&no, 20.0f, &no); + yes.VMargin(20.0f, &yes); + no.VMargin(20.0f, &no); static int button_abort = 0; - if(ui_do_button(&button_abort, localize("No"), 0, &no, ui_draw_menu_button, 0) || escape_pressed) + if(DoButton_Menu(&button_abort, localize("No"), 0, &no) || escape_pressed) popup = POPUP_NONE; static int button_tryagain = 0; - if(ui_do_button(&button_tryagain, localize("Yes"), 0, &yes, ui_draw_menu_button, 0) || enter_pressed) + if(DoButton_Menu(&button_tryagain, localize("Yes"), 0, &yes) || enter_pressed) client_quit(); } else if(popup == POPUP_PASSWORD) { - RECT label, textbox, tryagain, abort; + CUIRect label, textbox, tryagain, abort; - ui_hsplit_b(&box, 20.f, &box, &part); - ui_hsplit_b(&box, 24.f, &box, &part); - ui_vmargin(&part, 80.0f, &part); + box.HSplitBottom(20.f, &box, &part); + box.HSplitBottom(24.f, &box, &part); + part.VMargin(80.0f, &part); - ui_vsplit_mid(&part, &abort, &tryagain); + part.VSplitMid(&abort, &tryagain); - ui_vmargin(&tryagain, 20.0f, &tryagain); - ui_vmargin(&abort, 20.0f, &abort); + tryagain.VMargin(20.0f, &tryagain); + abort.VMargin(20.0f, &abort); static int button_abort = 0; - if(ui_do_button(&button_abort, localize("Abort"), 0, &abort, ui_draw_menu_button, 0) || escape_pressed) + if(DoButton_Menu(&button_abort, localize("Abort"), 0, &abort) || escape_pressed) popup = POPUP_NONE; static int button_tryagain = 0; - if(ui_do_button(&button_tryagain, localize("Try again"), 0, &tryagain, ui_draw_menu_button, 0) || enter_pressed) + if(DoButton_Menu(&button_tryagain, localize("Try again"), 0, &tryagain) || enter_pressed) { client_connect(config.ui_server_address); } - ui_hsplit_b(&box, 60.f, &box, &part); - ui_hsplit_b(&box, 24.f, &box, &part); + box.HSplitBottom(60.f, &box, &part); + box.HSplitBottom(24.f, &box, &part); - ui_vsplit_l(&part, 60.0f, 0, &label); - ui_vsplit_l(&label, 100.0f, 0, &textbox); - ui_vsplit_l(&textbox, 20.0f, 0, &textbox); - ui_vsplit_r(&textbox, 60.0f, &textbox, 0); - ui_do_label(&label, localize("Password"), 20, -1); - ui_do_edit_box(&config.password, &textbox, config.password, sizeof(config.password), 14.0f, true); + part.VSplitLeft(60.0f, 0, &label); + label.VSplitLeft(100.0f, 0, &textbox); + textbox.VSplitLeft(20.0f, 0, &textbox); + textbox.VSplitRight(60.0f, &textbox, 0); + UI()->DoLabel(&label, localize("Password"), 20, -1); + DoEditBox(&config.password, &textbox, config.password, sizeof(config.password), 14.0f, true); } else if(popup == POPUP_FIRST_LAUNCH) { - RECT label, textbox; + CUIRect label, textbox; - ui_hsplit_b(&box, 20.f, &box, &part); - ui_hsplit_b(&box, 24.f, &box, &part); - ui_vmargin(&part, 80.0f, &part); + box.HSplitBottom(20.f, &box, &part); + box.HSplitBottom(24.f, &box, &part); + part.VMargin(80.0f, &part); static int enter_button = 0; - if(ui_do_button(&enter_button, localize("Enter"), 0, &part, ui_draw_menu_button, 0) || enter_pressed) + if(DoButton_Menu(&enter_button, localize("Enter"), 0, &part) || enter_pressed) popup = POPUP_NONE; - ui_hsplit_b(&box, 40.f, &box, &part); - ui_hsplit_b(&box, 24.f, &box, &part); + box.HSplitBottom(40.f, &box, &part); + box.HSplitBottom(24.f, &box, &part); - ui_vsplit_l(&part, 60.0f, 0, &label); - ui_vsplit_l(&label, 100.0f, 0, &textbox); - ui_vsplit_l(&textbox, 20.0f, 0, &textbox); - ui_vsplit_r(&textbox, 60.0f, &textbox, 0); - ui_do_label(&label, localize("Nickname"), 20, -1); - ui_do_edit_box(&config.player_name, &textbox, config.player_name, sizeof(config.player_name), 14.0f); + part.VSplitLeft(60.0f, 0, &label); + label.VSplitLeft(100.0f, 0, &textbox); + textbox.VSplitLeft(20.0f, 0, &textbox); + textbox.VSplitRight(60.0f, &textbox, 0); + UI()->DoLabel(&label, localize("Nickname"), 20, -1); + DoEditBox(&config.player_name, &textbox, config.player_name, sizeof(config.player_name), 14.0f); } else { - ui_hsplit_b(&box, 20.f, &box, &part); - ui_hsplit_b(&box, 24.f, &box, &part); - ui_vmargin(&part, 120.0f, &part); + box.HSplitBottom(20.f, &box, &part); + box.HSplitBottom(24.f, &box, &part); + part.VMargin(120.0f, &part); static int button = 0; - if(ui_do_button(&button, button_text, 0, &part, ui_draw_menu_button, 0) || escape_pressed || enter_pressed) + if(DoButton_Menu(&button, button_text, 0, &part) || escape_pressed || enter_pressed) { if(popup == POPUP_CONNECTING) client_disconnect(); @@ -949,8 +957,8 @@ bool MENUS::on_mousemove(float x, float y) mouse_pos.y += y; if(mouse_pos.x < 0) mouse_pos.x = 0; if(mouse_pos.y < 0) mouse_pos.y = 0; - if(mouse_pos.x > gfx_screenwidth()) mouse_pos.x = gfx_screenwidth(); - if(mouse_pos.y > gfx_screenheight()) mouse_pos.y = gfx_screenheight(); + if(mouse_pos.x > Graphics()->ScreenWidth()) mouse_pos.x = Graphics()->ScreenWidth(); + if(mouse_pos.y > Graphics()->ScreenHeight()) mouse_pos.y = Graphics()->ScreenHeight(); return true; } @@ -993,8 +1001,8 @@ void MENUS::on_statechange(int new_state, int old_state) if(strstr(client_error_string(), "password")) { popup = POPUP_PASSWORD; - ui_set_hot_item(&config.password); - ui_set_active_item(&config.password); + UI()->SetHotItem(&config.password); + UI()->SetActiveItem(&config.password); } else popup = POPUP_DISCONNECTED; @@ -1028,10 +1036,10 @@ void MENUS::on_render() gfx_text_set_cursor(&cursor, 10, 30, 15, TEXTFLAG_RENDER); gfx_text_ex(&cursor, "ようこそ - ガイド", -1); - //gfx_texture_set(-1); - gfx_quads_begin(); - gfx_quads_drawTL(60, 60, 5000, 5000); - gfx_quads_end(); + //Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->QuadsDrawTL(60, 60, 5000, 5000); + Graphics()->QuadsEnd(); return;*/ if(client_state() != CLIENTSTATE_ONLINE && client_state() != CLIENTSTATE_DEMOPLAYBACK) @@ -1039,8 +1047,8 @@ void MENUS::on_render() if(client_state() == CLIENTSTATE_DEMOPLAYBACK) { - RECT screen = *ui_screen(); - gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); + CUIRect screen = *UI()->Screen(); + Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h); render_demoplayer(screen); } @@ -1081,36 +1089,36 @@ void MENUS::on_render() gui_color.a); // update the ui - RECT *screen = ui_screen(); - float mx = (mouse_pos.x/(float)gfx_screenwidth())*screen->w; - float my = (mouse_pos.y/(float)gfx_screenheight())*screen->h; + CUIRect *screen = UI()->Screen(); + float mx = (mouse_pos.x/(float)Graphics()->ScreenWidth())*screen->w; + float my = (mouse_pos.y/(float)Graphics()->ScreenHeight())*screen->h; int buttons = 0; if(inp_key_pressed(KEY_MOUSE_1)) buttons |= 1; if(inp_key_pressed(KEY_MOUSE_2)) buttons |= 2; if(inp_key_pressed(KEY_MOUSE_3)) buttons |= 4; - ui_update(mx,my,mx*3.0f,my*3.0f,buttons); + UI()->Update(mx,my,mx*3.0f,my*3.0f,buttons); // render if(client_state() != CLIENTSTATE_DEMOPLAYBACK) render(); // render cursor - gfx_texture_set(data->images[IMAGE_CURSOR].id); - gfx_quads_begin(); - gfx_setcolor(1,1,1,1); - gfx_quads_drawTL(mx,my,24,24); - gfx_quads_end(); + Graphics()->TextureSet(data->images[IMAGE_CURSOR].id); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1,1,1,1); + Graphics()->QuadsDrawTL(mx,my,24,24); + Graphics()->QuadsEnd(); // render debug information if(config.debug) { - RECT screen = *ui_screen(); - gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); + CUIRect screen = *UI()->Screen(); + Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h); char buf[512]; - str_format(buf, sizeof(buf), "%p %p %p", ui_hot_item(), ui_active_item(), ui_last_active_item()); + str_format(buf, sizeof(buf), "%p %p %p", UI()->HotItem(), UI()->ActiveItem(), UI()->LastActiveItem()); TEXT_CURSOR cursor; gfx_text_set_cursor(&cursor, 10, 10, 10, TEXTFLAG_RENDER); gfx_text_ex(&cursor, buf, -1); @@ -1125,53 +1133,53 @@ static int texture_blob = -1; void MENUS::render_background() { - //gfx_clear(1,1,1); + //Graphics()->Clear(1,1,1); //render_sunrays(0,0); if(texture_blob == -1) - texture_blob = gfx_load_texture("blob.png", IMG_AUTO, 0); + texture_blob = Graphics()->LoadTexture("blob.png", IMG_AUTO, 0); - float sw = 300*gfx_screenaspect(); + float sw = 300*Graphics()->ScreenAspect(); float sh = 300; - gfx_mapscreen(0, 0, sw, sh); + Graphics()->MapScreen(0, 0, sw, sh); - RECT s = *ui_screen(); + CUIRect s = *UI()->Screen(); // render background color - gfx_texture_set(-1); - gfx_quads_begin(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); //vec4 bottom(gui_color.r*0.3f, gui_color.g*0.3f, gui_color.b*0.3f, 1.0f); //vec4 bottom(0, 0, 0, 1.0f); vec4 bottom(gui_color.r, gui_color.g, gui_color.b, 1.0f); vec4 top(gui_color.r, gui_color.g, gui_color.b, 1.0f); - gfx_setcolorvertex(0, top.r, top.g, top.b, top.a); - gfx_setcolorvertex(1, top.r, top.g, top.b, top.a); - gfx_setcolorvertex(2, bottom.r, bottom.g, bottom.b, bottom.a); - gfx_setcolorvertex(3, bottom.r, bottom.g, bottom.b, bottom.a); - gfx_quads_drawTL(0, 0, sw, sh); - gfx_quads_end(); + Graphics()->SetColorVertex(0, top.r, top.g, top.b, top.a); + Graphics()->SetColorVertex(1, top.r, top.g, top.b, top.a); + Graphics()->SetColorVertex(2, bottom.r, bottom.g, bottom.b, bottom.a); + Graphics()->SetColorVertex(3, bottom.r, bottom.g, bottom.b, bottom.a); + Graphics()->QuadsDrawTL(0, 0, sw, sh); + Graphics()->QuadsEnd(); // render the tiles - gfx_texture_set(-1); - gfx_quads_begin(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); float size = 15.0f; float offset_time = fmod(client_localtime()*0.15f, 2.0f); for(int y = -2; y < (int)(sw/size); y++) for(int x = -2; x < (int)(sh/size); x++) { - gfx_setcolor(0,0,0,0.045f); - gfx_quads_drawTL((x-offset_time)*size*2+(y&1)*size, (y+offset_time)*size, size, size); + Graphics()->SetColor(0,0,0,0.045f); + Graphics()->QuadsDrawTL((x-offset_time)*size*2+(y&1)*size, (y+offset_time)*size, size, size); } - gfx_quads_end(); + Graphics()->QuadsEnd(); // render border fade - gfx_texture_set(texture_blob); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.5f); - gfx_quads_drawTL(-100, -100, sw+200, sh+200); - gfx_quads_end(); + Graphics()->TextureSet(texture_blob); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.5f); + Graphics()->QuadsDrawTL(-100, -100, sw+200, sh+200); + Graphics()->QuadsEnd(); // restore screen - {RECT screen = *ui_screen(); - gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);} + {CUIRect screen = *UI()->Screen(); + Graphics()->MapScreen(screen.x, screen.y, screen.w, screen.h);} } diff --git a/src/game/client/components/menus.hpp b/src/game/client/components/menus.hpp index 15369dbc..02759403 100644 --- a/src/game/client/components/menus.hpp +++ b/src/game/client/components/menus.hpp @@ -26,39 +26,58 @@ class MENUS : public COMPONENT static vec4 color_tabbar_inactive; static vec4 color_tabbar_active; - static vec4 button_color_mul(const void *id); + vec4 button_color_mul(const void *pID); - static void ui_draw_demoplayer_button(const void *id, const char *text, int checked, const RECT *r, const void *extra); + int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect); + int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect); + int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners); + int DoButton_SettingsTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect); - static void ui_draw_browse_icon(int what, const RECT *r); - static void ui_draw_menu_button(const void *id, const char *text, int checked, const RECT *r, const void *extra); - static void ui_draw_keyselect_button(const void *id, const char *text, int checked, const RECT *r, const void *extra); - static void ui_draw_menu_tab_button(const void *id, const char *text, int checked, const RECT *r, const void *extra); - static void ui_draw_settings_tab_button(const void *id, const char *text, int checked, const RECT *r, const void *extra); - static void ui_draw_grid_header(const void *id, const char *text, int checked, const RECT *r, const void *extra); - static void ui_draw_list_row(const void *id, const char *text, int checked, const RECT *r, const void *extra); - static void ui_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const RECT *r); - static void ui_draw_checkbox(const void *id, const char *text, int checked, const RECT *r, const void *extra); - static void ui_draw_checkbox_number(const void *id, const char *text, int checked, const RECT *r, const void *extra); - static int ui_do_edit_box(void *id, const RECT *rect, char *str, unsigned str_size, float font_size, bool hidden=false); + int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); + int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect); + int DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect); - static float ui_do_scrollbar_v(const void *id, const RECT *rect, float current); - static float ui_do_scrollbar_h(const void *id, const RECT *rect, float current); + /*static void ui_draw_menu_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); + static void ui_draw_keyselect_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); + static void ui_draw_menu_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); + static void ui_draw_settings_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); + */ - static int ui_do_key_reader(void *id, const RECT *rect, int key); - static void ui_do_getbuttons(int start, int stop, RECT view); + int DoButton_BrowseIcon(int Checked, const CUIRect *pRect); + int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect); + int DoButton_ListRow(const void *pID, const char *pText, int Checked, const CUIRect *pRect); + + //static void ui_draw_browse_icon(int what, const CUIRect *r); + //static void ui_draw_grid_header(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); + + /*static void ui_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const CUIRect *r, const void *extra); + static void ui_draw_checkbox(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); + static void ui_draw_checkbox_number(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); + */ + int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, bool Hidden=false); + //static int ui_do_edit_box(void *id, const CUIRect *rect, char *str, unsigned str_size, float font_size, bool hidden=false); + + float DoScrollbarV(const void *pID, const CUIRect *pRect, float Current); + float DoScrollbarH(const void *pID, const CUIRect *pRect, float Current); + int DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect); + int DoKeyReader(void *pID, const CUIRect *pRect, int Key); + + //static int ui_do_key_reader(void *id, const CUIRect *rect, int key); + void ui_do_getbuttons(int start, int stop, CUIRect view); struct LISTBOXITEM { int visible; int selected; - RECT rect; + CUIRect rect; + CUIRect hitrect; }; - static void ui_do_listbox_start(void *id, const RECT *rect, float row_height, const char *title, int num_items, int selected_index); - static LISTBOXITEM ui_do_listbox_nextitem(void *id); - static int ui_do_listbox_end(); + void ui_do_listbox_start(void *id, const CUIRect *rect, float row_height, const char *title, int num_items, int selected_index); + LISTBOXITEM ui_do_listbox_nextitem(void *id); + static LISTBOXITEM ui_do_listbox_nextrow(); + int ui_do_listbox_end(); //static void demolist_listdir_callback(const char *name, int is_dir, void *user); //static void demolist_list_callback(const RECT *rect, int index, void *user); @@ -143,39 +162,42 @@ class MENUS : public COMPONENT // found in menus.cpp int render(); - void render_background(); + //void render_background(); //void render_loading(float percent); - int render_menubar(RECT r); - void render_news(RECT main_view); + int render_menubar(CUIRect r); + void render_news(CUIRect main_view); // found in menus_demo.cpp - void render_demoplayer(RECT main_view); - void render_demolist(RECT main_view); + void render_demoplayer(CUIRect main_view); + void render_demolist(CUIRect main_view); // found in menus_ingame.cpp - void render_game(RECT main_view); - void render_serverinfo(RECT main_view); - void render_servercontrol(RECT main_view); - void render_servercontrol_kick(RECT main_view); - void render_servercontrol_server(RECT main_view); + void render_game(CUIRect main_view); + void render_serverinfo(CUIRect main_view); + void render_servercontrol(CUIRect main_view); + void render_servercontrol_kick(CUIRect main_view); + void render_servercontrol_server(CUIRect main_view); // found in menus_browser.cpp int selected_index; - void render_serverbrowser_serverlist(RECT view); - void render_serverbrowser_serverdetail(RECT view); - void render_serverbrowser_filters(RECT view); - void render_serverbrowser(RECT main_view); + void render_serverbrowser_serverlist(CUIRect view); + void render_serverbrowser_serverdetail(CUIRect view); + void render_serverbrowser_filters(CUIRect view); + void render_serverbrowser(CUIRect main_view); // found in menus_settings.cpp - void render_settings_general(RECT main_view); - void render_settings_player(RECT main_view); - void render_settings_controls(RECT main_view); - void render_settings_graphics(RECT main_view); - void render_settings_sound(RECT main_view); - void render_settings(RECT main_view); + void render_settings_general(CUIRect main_view); + void render_settings_player(CUIRect main_view); + void render_settings_controls(CUIRect main_view); + void render_settings_graphics(CUIRect main_view); + void render_settings_sound(CUIRect main_view); + void render_settings(CUIRect main_view); void set_active(bool active); public: + void render_background(); + + static MENUS_KEYBINDER binder; MENUS(); diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index a7f21084..dcf68f8d 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -12,17 +12,17 @@ #include <game/localization.hpp> #include <game/version.hpp> -void MENUS::render_serverbrowser_serverlist(RECT view) +void MENUS::render_serverbrowser_serverlist(CUIRect view) { - RECT headers; - RECT status; + CUIRect headers; + CUIRect status; - ui_hsplit_t(&view, listheader_height, &headers, &view); - ui_hsplit_b(&view, 28.0f, &view, &status); + view.HSplitTop(listheader_height, &headers, &view); + view.HSplitBottom(28.0f, &view, &status); // split of the scrollbar - ui_draw_rect(&headers, vec4(1,1,1,0.25f), CORNER_T, 5.0f); - ui_vsplit_r(&headers, 20.0f, &headers, 0); + RenderTools()->DrawUIRect(&headers, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f); + headers.VSplitRight(20.0f, &headers, 0); struct column { @@ -32,8 +32,8 @@ void MENUS::render_serverbrowser_serverlist(RECT view) int direction; float width; int flags; - RECT rect; - RECT spacer; + CUIRect rect; + CUIRect spacer; }; enum @@ -72,12 +72,12 @@ void MENUS::render_serverbrowser_serverlist(RECT view) { if(cols[i].direction == -1) { - ui_vsplit_l(&headers, cols[i].width, &cols[i].rect, &headers); + headers.VSplitLeft(cols[i].width, &cols[i].rect, &headers); if(i+1 < num_cols) { //cols[i].flags |= SPACER; - ui_vsplit_l(&headers, 2, &cols[i].spacer, &headers); + headers.VSplitLeft(2, &cols[i].spacer, &headers); } } } @@ -86,8 +86,8 @@ void MENUS::render_serverbrowser_serverlist(RECT view) { if(cols[i].direction == 1) { - ui_vsplit_r(&headers, cols[i].width, &headers, &cols[i].rect); - ui_vsplit_r(&headers, 2, &headers, &cols[i].spacer); + headers.VSplitRight(cols[i].width, &headers, &cols[i].rect); + headers.VSplitRight(2, &headers, &cols[i].spacer); } } @@ -100,7 +100,7 @@ void MENUS::render_serverbrowser_serverlist(RECT view) // do headers for(int i = 0; i < num_cols; i++) { - if(ui_do_button(cols[i].caption, cols[i].caption, config.b_sort == cols[i].sort, &cols[i].rect, ui_draw_grid_header, 0)) + if(DoButton_GridHeader(cols[i].caption, cols[i].caption, config.b_sort == cols[i].sort, &cols[i].rect)) { if(cols[i].sort != -1) { @@ -113,33 +113,33 @@ void MENUS::render_serverbrowser_serverlist(RECT view) } } - ui_draw_rect(&view, vec4(0,0,0,0.15f), 0, 0); + RenderTools()->DrawUIRect(&view, vec4(0,0,0,0.15f), 0, 0); - RECT scroll; - ui_vsplit_r(&view, 15, &view, &scroll); + CUIRect scroll; + view.VSplitRight(15, &view, &scroll); int num_servers = client_serverbrowse_sorted_num(); // display important messages in the middle of the screen so no // users misses it { - RECT msgbox = view; + CUIRect msgbox = view; msgbox.y += view.h/3; if(active_page == PAGE_INTERNET && client_serverbrowse_refreshingmasters()) - ui_do_label(&msgbox, localize("Refreshing master servers"), 16.0f, 0); + UI()->DoLabel(&msgbox, localize("Refreshing master servers"), 16.0f, 0); else if(!client_serverbrowse_num()) - ui_do_label(&msgbox, localize("No servers found"), 16.0f, 0); + UI()->DoLabel(&msgbox, localize("No servers found"), 16.0f, 0); else if(client_serverbrowse_num() && !num_servers) - ui_do_label(&msgbox, localize("No servers match your filter criteria"), 16.0f, 0); + UI()->DoLabel(&msgbox, localize("No servers match your filter criteria"), 16.0f, 0); } int num = (int)(view.h/cols[0].rect.h); static int scrollbar = 0; static float scrollvalue = 0; //static int selected_index = -1; - ui_hmargin(&scroll, 5.0f, &scroll); - scrollvalue = ui_do_scrollbar_v(&scrollbar, &scroll, scrollvalue); + scroll.HMargin(5.0f, &scroll); + scrollvalue = DoScrollbarV(&scrollbar, &scroll, scrollvalue); int scrollnum = num_servers-num+10; if(scrollnum > 0) @@ -156,13 +156,13 @@ void MENUS::render_serverbrowser_serverlist(RECT view) scrollnum = 0; // set clipping - ui_clip_enable(&view); + UI()->ClipEnable(&view); int start = (int)(scrollnum*scrollvalue); if(start < 0) start = 0; - RECT original_view = view; + CUIRect original_view = view; view.y -= scrollvalue*scrollnum*cols[0].rect.h; int new_selected = -1; @@ -180,20 +180,20 @@ void MENUS::render_serverbrowser_serverlist(RECT view) { int item_index = i; SERVER_INFO *item = client_serverbrowse_sorted_get(item_index); - RECT row; - RECT select_hit_box; + CUIRect row; + CUIRect select_hit_box; int selected = strcmp(item->address, config.ui_server_address) == 0; //selected_index==item_index; - ui_hsplit_t(&view, 17.0f, &row, &view); + view.HSplitTop(17.0f, &row, &view); select_hit_box = row; if(selected) { selected_index = i; - RECT r = row; - ui_margin(&r, 1.5f, &r); - ui_draw_rect(&r, vec4(1,1,1,0.5f), CORNER_ALL, 4.0f); + CUIRect r = row; + r.Margin(1.5f, &r); + RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 4.0f); } @@ -206,7 +206,7 @@ void MENUS::render_serverbrowser_serverlist(RECT view) select_hit_box.y = original_view.y; } - if(ui_do_button(item, "", selected, &select_hit_box, 0, 0)) + if(UI()->DoButtonLogic(item, "", selected, &select_hit_box)) { new_selected = item_index; } @@ -218,7 +218,7 @@ void MENUS::render_serverbrowser_serverlist(RECT view) for(int c = 0; c < num_cols; c++) { - RECT button; + CUIRect button; char temp[64]; button.x = cols[c].rect.x; button.y = row.y; @@ -228,12 +228,12 @@ void MENUS::render_serverbrowser_serverlist(RECT view) //int s = 0; int id = cols[c].id; - //s = ui_do_button(item, "L", l, &button, ui_draw_browse_icon, 0); + //s = UI()->DoButton(item, "L", l, &button, ui_draw_browse_icon, 0); if(id == COL_FLAG_LOCK) { if(item->flags & SRVFLAG_PASSWORD) - ui_draw_browse_icon(SPRITE_BROWSE_LOCK, &button); + DoButton_BrowseIcon(SPRITE_BROWSE_LOCK, &button); } else if(id == COL_FLAG_PURE) { @@ -244,13 +244,13 @@ void MENUS::render_serverbrowser_serverlist(RECT view) else { // unpure - ui_draw_browse_icon(SPRITE_BROWSE_UNPURE, &button); + DoButton_BrowseIcon(SPRITE_BROWSE_UNPURE, &button); } } else if(id == COL_FLAG_FAV) { if(item->favorite) - ui_draw_browse_icon(SPRITE_BROWSE_HEART, &button); + DoButton_BrowseIcon(SPRITE_BROWSE_HEART, &button); } else if(id == COL_NAME) { @@ -277,36 +277,36 @@ void MENUS::render_serverbrowser_serverlist(RECT view) gfx_text_ex(&cursor, item->name, -1); } else if(id == COL_MAP) - ui_do_label(&button, item->map, 12.0f, -1); + UI()->DoLabel(&button, item->map, 12.0f, -1); else if(id == COL_PLAYERS) { str_format(temp, sizeof(temp), "%i/%i", item->num_players, item->max_players); if(config.b_filter_string[0] && (item->quicksearch_hit&BROWSEQUICK_PLAYERNAME)) gfx_text_color(0.4f,0.4f,1.0f,1); - ui_do_label(&button, temp, 12.0f, 1); + UI()->DoLabel(&button, temp, 12.0f, 1); gfx_text_color(1,1,1,1); } else if(id == COL_PING) { str_format(temp, sizeof(temp), "%i", item->latency); - ui_do_label(&button, temp, 12.0f, 1); + UI()->DoLabel(&button, temp, 12.0f, 1); } else if(id == COL_VERSION) { const char *version = item->version; if(strcmp(version, "0.3 e2d7973c6647a13c") == 0) // TODO: remove me later on version = "0.3.0"; - ui_do_label(&button, version, 12.0f, 1); + UI()->DoLabel(&button, version, 12.0f, 1); } else if(id == COL_GAMETYPE) { - ui_do_label(&button, item->gametype, 12.0f, 0); + UI()->DoLabel(&button, item->gametype, 12.0f, 0); } } } - ui_clip_disable(); + UI()->ClipDisable(); if(new_selected != -1) { @@ -317,84 +317,84 @@ void MENUS::render_serverbrowser_serverlist(RECT view) client_connect(config.ui_server_address); } - ui_draw_rect(&status, vec4(1,1,1,0.25f), CORNER_B, 5.0f); - ui_margin(&status, 5.0f, &status); + RenderTools()->DrawUIRect(&status, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f); + status.Margin(5.0f, &status); // render quick search - RECT quicksearch; - ui_vsplit_l(&status, 250.0f, &quicksearch, &status); + CUIRect quicksearch; + status.VSplitLeft(250.0f, &quicksearch, &status); const char *label = localize("Quick search"); - ui_do_label(&quicksearch, label, 14.0f, -1); - ui_vsplit_l(&quicksearch, gfx_text_width(0, 14.0f, label, -1), 0, &quicksearch); - ui_vsplit_l(&quicksearch, 5, 0, &quicksearch); - ui_do_edit_box(&config.b_filter_string, &quicksearch, config.b_filter_string, sizeof(config.b_filter_string), 14.0f); + UI()->DoLabel(&quicksearch, label, 14.0f, -1); + quicksearch.VSplitLeft(gfx_text_width(0, 14.0f, label, -1), 0, &quicksearch); + quicksearch.VSplitLeft(5, 0, &quicksearch); + DoEditBox(&config.b_filter_string, &quicksearch, config.b_filter_string, sizeof(config.b_filter_string), 14.0f); // render status char buf[128]; str_format(buf, sizeof(buf), localize("%d of %d servers, %d players"), client_serverbrowse_sorted_num(), client_serverbrowse_num(), num_players); - ui_vsplit_r(&status, gfx_text_width(0, 14.0f, buf, -1), 0, &status); - ui_do_label(&status, buf, 14.0f, -1); + status.VSplitRight(gfx_text_width(0, 14.0f, buf, -1), 0, &status); + UI()->DoLabel(&status, buf, 14.0f, -1); } -void MENUS::render_serverbrowser_filters(RECT view) +void MENUS::render_serverbrowser_filters(CUIRect view) { // filters - RECT button; + CUIRect button; - ui_hsplit_t(&view, 5.0f, 0, &view); - ui_vsplit_l(&view, 5.0f, 0, &view); - ui_vsplit_r(&view, 5.0f, &view, 0); - ui_hsplit_b(&view, 5.0f, &view, 0); + view.HSplitTop(5.0f, 0, &view); + view.VSplitLeft(5.0f, 0, &view); + view.VSplitRight(5.0f, &view, 0); + view.HSplitBottom(5.0f, &view, 0); // render filters - ui_hsplit_t(&view, 20.0f, &button, &view); - if (ui_do_button(&config.b_filter_empty, localize("Has people playing"), config.b_filter_empty, &button, ui_draw_checkbox, 0)) + view.HSplitTop(20.0f, &button, &view); + if (DoButton_CheckBox(&config.b_filter_empty, localize("Has people playing"), config.b_filter_empty, &button)) config.b_filter_empty ^= 1; - ui_hsplit_t(&view, 20.0f, &button, &view); - if (ui_do_button(&config.b_filter_full, localize("Server not full"), config.b_filter_full, &button, ui_draw_checkbox, 0)) + view.HSplitTop(20.0f, &button, &view); + if (DoButton_CheckBox(&config.b_filter_full, localize("Server not full"), config.b_filter_full, &button)) config.b_filter_full ^= 1; - ui_hsplit_t(&view, 20.0f, &button, &view); - if (ui_do_button(&config.b_filter_pw, localize("No password"), config.b_filter_pw, &button, ui_draw_checkbox, 0)) + view.HSplitTop(20.0f, &button, &view); + if (DoButton_CheckBox(&config.b_filter_pw, localize("No password"), config.b_filter_pw, &button)) config.b_filter_pw ^= 1; - ui_hsplit_t(&view, 20.0f, &button, &view); - if (ui_do_button((char *)&config.b_filter_compatversion, localize("Compatible version"), config.b_filter_compatversion, &button, ui_draw_checkbox, 0)) + view.HSplitTop(20.0f, &button, &view); + if (DoButton_CheckBox((char *)&config.b_filter_compatversion, localize("Compatible version"), config.b_filter_compatversion, &button)) config.b_filter_compatversion ^= 1; - ui_hsplit_t(&view, 20.0f, &button, &view); - if (ui_do_button((char *)&config.b_filter_pure, localize("Standard gametype"), config.b_filter_pure, &button, ui_draw_checkbox, 0)) + view.HSplitTop(20.0f, &button, &view); + if (DoButton_CheckBox((char *)&config.b_filter_pure, localize("Standard gametype"), config.b_filter_pure, &button)) config.b_filter_pure ^= 1; - ui_hsplit_t(&view, 20.0f, &button, &view); - /*ui_vsplit_l(&button, 20.0f, 0, &button);*/ - if (ui_do_button((char *)&config.b_filter_pure_map, localize("Standard map"), config.b_filter_pure_map, &button, ui_draw_checkbox, 0)) + view.HSplitTop(20.0f, &button, &view); + /*button.VSplitLeft(20.0f, 0, &button);*/ + if (DoButton_CheckBox((char *)&config.b_filter_pure_map, localize("Standard map"), config.b_filter_pure_map, &button)) config.b_filter_pure_map ^= 1; - ui_hsplit_t(&view, 20.0f, &button, &view); - ui_do_label(&button, localize("Game types"), 14.0f, -1); - ui_vsplit_l(&button, 95.0f, 0, &button); - ui_margin(&button, 1.0f, &button); - ui_do_edit_box(&config.b_filter_gametype, &button, config.b_filter_gametype, sizeof(config.b_filter_gametype), 14.0f); + view.HSplitTop(20.0f, &button, &view); + UI()->DoLabel(&button, localize("Game types"), 14.0f, -1); + button.VSplitLeft(95.0f, 0, &button); + button.Margin(1.0f, &button); + DoEditBox(&config.b_filter_gametype, &button, config.b_filter_gametype, sizeof(config.b_filter_gametype), 14.0f); { - ui_hsplit_t(&view, 20.0f, &button, &view); - RECT editbox; - ui_vsplit_l(&button, 40.0f, &editbox, &button); - ui_vsplit_l(&button, 5.0f, &button, &button); + view.HSplitTop(20.0f, &button, &view); + CUIRect editbox; + button.VSplitLeft(40.0f, &editbox, &button); + button.VSplitLeft(5.0f, &button, &button); char buf[8]; str_format(buf, sizeof(buf), "%d", config.b_filter_ping); - ui_do_edit_box(&config.b_filter_ping, &editbox, buf, sizeof(buf), 14.0f); + DoEditBox(&config.b_filter_ping, &editbox, buf, sizeof(buf), 14.0f); config.b_filter_ping = atoi(buf); - ui_do_label(&button, localize("Maximum ping"), 14.0f, -1); + UI()->DoLabel(&button, localize("Maximum ping"), 14.0f, -1); } - ui_hsplit_b(&view, button_height, &view, &button); + view.HSplitBottom(button_height, &view, &button); static int clear_button = 0; - if(ui_do_button(&clear_button, localize("Reset filter"), 0, &button, ui_draw_menu_button, 0)) + if(DoButton_Menu(&clear_button, localize("Reset filter"), 0, &button)) { config.b_filter_full = 0; config.b_filter_empty = 0; @@ -407,48 +407,48 @@ void MENUS::render_serverbrowser_filters(RECT view) } } -void MENUS::render_serverbrowser_serverdetail(RECT view) +void MENUS::render_serverbrowser_serverdetail(CUIRect view) { - RECT server_details = view; - RECT server_scoreboard, server_header; + CUIRect server_details = view; + CUIRect server_scoreboard, server_header; SERVER_INFO *selected_server = client_serverbrowse_sorted_get(selected_index); - //ui_vsplit_l(&server_details, 10.0f, 0x0, &server_details); + //server_details.VSplitLeft(10.0f, 0x0, &server_details); // split off a piece to use for scoreboard - ui_hsplit_t(&server_details, 140.0f, &server_details, &server_scoreboard); - ui_hsplit_b(&server_details, 10.0f, &server_details, 0x0); + server_details.HSplitTop(140.0f, &server_details, &server_scoreboard); + server_details.HSplitBottom(10.0f, &server_details, 0x0); // server details const float font_size = 12.0f; - ui_hsplit_t(&server_details, 20.0f, &server_header, &server_details); - ui_draw_rect(&server_header, vec4(1,1,1,0.25f), CORNER_T, 4.0f); - ui_draw_rect(&server_details, vec4(0,0,0,0.15f), CORNER_B, 4.0f); - ui_vsplit_l(&server_header, 8.0f, 0x0, &server_header); - ui_do_label(&server_header, localize("Server details"), font_size+2.0f, -1); + server_details.HSplitTop(20.0f, &server_header, &server_details); + RenderTools()->DrawUIRect(&server_header, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f); + RenderTools()->DrawUIRect(&server_details, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f); + server_header.VSplitLeft(8.0f, 0x0, &server_header); + UI()->DoLabel(&server_header, localize("Server details"), font_size+2.0f, -1); - ui_vsplit_l(&server_details, 5.0f, 0x0, &server_details); + server_details.VSplitLeft(5.0f, 0x0, &server_details); - ui_margin(&server_details, 3.0f, &server_details); + server_details.Margin(3.0f, &server_details); if (selected_server) { - RECT row; + CUIRect row; static LOC_CONSTSTRING labels[] = { localize("Version"), localize("Game type"), localize("Ping")}; - RECT left_column; - RECT right_column; + CUIRect left_column; + CUIRect right_column; // { - RECT button; - ui_hsplit_b(&server_details, 20.0f, &server_details, &button); + CUIRect button; + server_details.HSplitBottom(20.0f, &server_details, &button); static int add_fav_button = 0; - if (ui_do_button(&add_fav_button, localize("Favorite"), selected_server->favorite, &button, ui_draw_checkbox, 0)) + if(DoButton_CheckBox(&add_fav_button, localize("Favorite"), selected_server->favorite, &button)) { if(selected_server->favorite) client_serverbrowse_removefavorite(selected_server->netaddr); @@ -456,55 +456,55 @@ void MENUS::render_serverbrowser_serverdetail(RECT view) client_serverbrowse_addfavorite(selected_server->netaddr); } } - //ui_do_label(&row, temp, font_size, -1); + //UI()->DoLabel(&row, temp, font_size, -1); - ui_vsplit_l(&server_details, 5.0f, 0x0, &server_details); - ui_vsplit_l(&server_details, 80.0f, &left_column, &right_column); + server_details.VSplitLeft(5.0f, 0x0, &server_details); + server_details.VSplitLeft(80.0f, &left_column, &right_column); for (unsigned int i = 0; i < sizeof(labels) / sizeof(labels[0]); i++) { - ui_hsplit_t(&left_column, 15.0f, &row, &left_column); - ui_do_label(&row, labels[i], font_size, -1); + left_column.HSplitTop(15.0f, &row, &left_column); + UI()->DoLabel(&row, labels[i], font_size, -1); } - ui_hsplit_t(&right_column, 15.0f, &row, &right_column); - ui_do_label(&row, selected_server->version, font_size, -1); + right_column.HSplitTop(15.0f, &row, &right_column); + UI()->DoLabel(&row, selected_server->version, font_size, -1); - ui_hsplit_t(&right_column, 15.0f, &row, &right_column); - ui_do_label(&row, selected_server->gametype, font_size, -1); + right_column.HSplitTop(15.0f, &row, &right_column); + UI()->DoLabel(&row, selected_server->gametype, font_size, -1); char temp[16]; str_format(temp, sizeof(temp), "%d", selected_server->latency); - ui_hsplit_t(&right_column, 15.0f, &row, &right_column); - ui_do_label(&row, temp, font_size, -1); + right_column.HSplitTop(15.0f, &row, &right_column); + UI()->DoLabel(&row, temp, font_size, -1); } // server scoreboard - ui_hsplit_b(&server_scoreboard, 10.0f, &server_scoreboard, 0x0); - ui_hsplit_t(&server_scoreboard, 20.0f, &server_header, &server_scoreboard); - ui_draw_rect(&server_header, vec4(1,1,1,0.25f), CORNER_T, 4.0f); - ui_draw_rect(&server_scoreboard, vec4(0,0,0,0.15f), CORNER_B, 4.0f); - ui_vsplit_l(&server_header, 8.0f, 0x0, &server_header); - ui_do_label(&server_header, localize("Scoreboard"), font_size+2.0f, -1); + server_scoreboard.HSplitBottom(10.0f, &server_scoreboard, 0x0); + server_scoreboard.HSplitTop(20.0f, &server_header, &server_scoreboard); + RenderTools()->DrawUIRect(&server_header, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f); + RenderTools()->DrawUIRect(&server_scoreboard, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f); + server_header.VSplitLeft(8.0f, 0x0, &server_header); + UI()->DoLabel(&server_header, localize("Scoreboard"), font_size+2.0f, -1); - ui_vsplit_l(&server_scoreboard, 5.0f, 0x0, &server_scoreboard); + server_scoreboard.VSplitLeft(5.0f, 0x0, &server_scoreboard); - ui_margin(&server_scoreboard, 3.0f, &server_scoreboard); + server_scoreboard.Margin(3.0f, &server_scoreboard); if (selected_server) { for (int i = 0; i < selected_server->num_players; i++) { - RECT row; + CUIRect row; char temp[16]; - ui_hsplit_t(&server_scoreboard, 16.0f, &row, &server_scoreboard); + server_scoreboard.HSplitTop(16.0f, &row, &server_scoreboard); str_format(temp, sizeof(temp), "%d", selected_server->players[i].score); - ui_do_label(&row, temp, font_size, -1); + UI()->DoLabel(&row, temp, font_size, -1); - ui_vsplit_l(&row, 25.0f, 0x0, &row); + row.VSplitLeft(25.0f, 0x0, &row); TEXT_CURSOR cursor; gfx_text_set_cursor(&cursor, row.x, row.y, 12.0f, TEXTFLAG_RENDER); @@ -532,12 +532,12 @@ void MENUS::render_serverbrowser_serverdetail(RECT view) } } -void MENUS::render_serverbrowser(RECT main_view) +void MENUS::render_serverbrowser(CUIRect main_view) { - ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f); + RenderTools()->DrawUIRect(&main_view, color_tabbar_active, CUI::CORNER_ALL, 10.0f); - RECT view; - ui_margin(&main_view, 10.0f, &view); + CUIRect view; + main_view.Margin(10.0f, &view); /* +-----------------+ +------+ @@ -551,44 +551,44 @@ void MENUS::render_serverbrowser(RECT main_view) */ - //RECT filters; - RECT status_toolbar; - RECT toolbox; - RECT button_box; + //CUIRect filters; + CUIRect status_toolbar; + CUIRect toolbox; + CUIRect button_box; // split off a piece for filters, details and scoreboard - ui_vsplit_r(&view, 200.0f, &view, &toolbox); - ui_hsplit_b(&toolbox, 80.0f, &toolbox, &button_box); - ui_hsplit_b(&view, button_height+5.0f, &view, &status_toolbar); + view.VSplitRight(200.0f, &view, &toolbox); + toolbox.HSplitBottom(80.0f, &toolbox, &button_box); + view.HSplitBottom(button_height+5.0f, &view, &status_toolbar); render_serverbrowser_serverlist(view); static int toolbox_page = 0; - ui_vsplit_l(&toolbox, 5.0f, 0, &toolbox); + toolbox.VSplitLeft(5.0f, 0, &toolbox); // do tabbar { - RECT tab_bar; - RECT tabbutton0, tabbutton1; - ui_hsplit_t(&toolbox, 22.0f, &tab_bar, &toolbox); + CUIRect tab_bar; + CUIRect tabbutton0, tabbutton1; + toolbox.HSplitTop(22.0f, &tab_bar, &toolbox); - ui_vsplit_mid(&tab_bar, &tabbutton0, &tabbutton1); - ui_vsplit_r(&tabbutton0, 5.0f, &tabbutton0, 0); - ui_vsplit_l(&tabbutton1, 5.0f, 0, &tabbutton1); + tab_bar.VSplitMid(&tabbutton0, &tabbutton1); + tabbutton0.VSplitRight(5.0f, &tabbutton0, 0); + tabbutton1.VSplitLeft(5.0f, 0, &tabbutton1); static int filters_tab = 0; - if (ui_do_button(&filters_tab, localize("Filter"), toolbox_page==0, &tabbutton0, ui_draw_menu_tab_button, 0)) + if (DoButton_MenuTab(&filters_tab, localize("Filter"), toolbox_page==0, &tabbutton0, 0)) toolbox_page = 0; static int info_tab = 0; - if (ui_do_button(&info_tab, localize("Info"), toolbox_page==1, &tabbutton1, ui_draw_menu_tab_button, 0)) + if (DoButton_MenuTab(&info_tab, localize("Info"), toolbox_page==1, &tabbutton1, 0)) toolbox_page = 1; } - ui_draw_rect(&toolbox, vec4(0,0,0,0.15f), 0, 0); + RenderTools()->DrawUIRect(&toolbox, vec4(0,0,0,0.15f), 0, 0); - ui_hsplit_t(&toolbox, 5.0f, 0, &toolbox); + toolbox.HSplitTop(5.0f, 0, &toolbox); if(toolbox_page == 0) render_serverbrowser_filters(toolbox); @@ -596,14 +596,14 @@ void MENUS::render_serverbrowser(RECT main_view) render_serverbrowser_serverdetail(toolbox); { - ui_hsplit_t(&status_toolbar, 5.0f, 0, &status_toolbar); + status_toolbar.HSplitTop(5.0f, 0, &status_toolbar); - RECT button; - //ui_vsplit_r(&buttons, 20.0f, &buttons, &button); - ui_vsplit_r(&status_toolbar, 110.0f, &status_toolbar, &button); - ui_vmargin(&button, 2.0f, &button); + CUIRect button; + //buttons.VSplitRight(20.0f, &buttons, &button); + status_toolbar.VSplitRight(110.0f, &status_toolbar, &button); + button.VMargin(2.0f, &button); static int refresh_button = 0; - if(ui_do_button(&refresh_button, localize("Refresh"), 0, &button, ui_draw_menu_button, 0)) + if(DoButton_Menu(&refresh_button, localize("Refresh"), 0, &button)) { if(config.ui_page == PAGE_INTERNET) client_serverbrowse_refresh(BROWSETYPE_INTERNET); @@ -618,31 +618,31 @@ void MENUS::render_serverbrowser(RECT main_view) str_format(buf, sizeof(buf), localize("Teeworlds %s is out! Download it at www.teeworlds.com!"), client_latestversion()); else str_format(buf, sizeof(buf), localize("Current version: %s"), GAME_VERSION); - ui_do_label(&status_toolbar, buf, 14.0f, -1); + UI()->DoLabel(&status_toolbar, buf, 14.0f, -1); } // do the button box { - ui_vsplit_l(&button_box, 5.0f, 0, &button_box); - ui_vsplit_r(&button_box, 5.0f, &button_box, 0); + button_box.VSplitLeft(5.0f, 0, &button_box); + button_box.VSplitRight(5.0f, &button_box, 0); - RECT button; - ui_hsplit_b(&button_box, button_height, &button_box, &button); - ui_vsplit_r(&button, 120.0f, 0, &button); - ui_vmargin(&button, 2.0f, &button); - //ui_vmargin(&button, 2.0f, &button); + CUIRect button; + button_box.HSplitBottom(button_height, &button_box, &button); + button.VSplitRight(120.0f, 0, &button); + button.VMargin(2.0f, &button); + //button.VMargin(2.0f, &button); static int join_button = 0; - if(ui_do_button(&join_button, localize("Connect"), 0, &button, ui_draw_menu_button, 0) || enter_pressed) + if(DoButton_Menu(&join_button, localize("Connect"), 0, &button) || enter_pressed) { client_connect(config.ui_server_address); enter_pressed = false; } - ui_hsplit_b(&button_box, 5.0f, &button_box, &button); - ui_hsplit_b(&button_box, 20.0f, &button_box, &button); - ui_do_edit_box(&config.ui_server_address, &button, config.ui_server_address, sizeof(config.ui_server_address), 14.0f); - ui_hsplit_b(&button_box, 20.0f, &button_box, &button); - ui_do_label(&button, localize("Host address"), 14.0f, -1); + button_box.HSplitBottom(5.0f, &button_box, &button); + button_box.HSplitBottom(20.0f, &button_box, &button); + DoEditBox(&config.ui_server_address, &button, config.ui_server_address, sizeof(config.ui_server_address), 14.0f); + button_box.HSplitBottom(20.0f, &button_box, &button); + UI()->DoLabel(&button, localize("Host address"), 14.0f, -1); } } diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 594ee3df..07019d46 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -17,13 +17,14 @@ #include "menus.hpp" -void MENUS::ui_draw_demoplayer_button(const void *id, const char *text, int checked, const RECT *r, const void *extra) +int MENUS::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { - ui_draw_rect(r, vec4(1,1,1, checked ? 0.10f : 0.5f)*button_color_mul(id), CORNER_ALL, 5.0f); - ui_do_label(r, text, 14.0f, 0); + RenderTools()->DrawUIRect(pRect, vec4(1,1,1, Checked ? 0.10f : 0.5f)*button_color_mul(pID), CUI::CORNER_ALL, 5.0f); + UI()->DoLabel(pRect, pText, 14.0f, 0); + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } -void MENUS::render_demoplayer(RECT main_view) +void MENUS::render_demoplayer(CUIRect main_view) { const DEMOPLAYBACK_INFO *info = client_demoplayer_getinfo(); @@ -37,20 +38,20 @@ void MENUS::render_demoplayer(RECT main_view) else total_height = seekbar_height+margins*2; - ui_hsplit_b(&main_view, total_height, 0, &main_view); - ui_vsplit_l(&main_view, 250.0f, 0, &main_view); - ui_vsplit_r(&main_view, 250.0f, &main_view, 0); + main_view.HSplitBottom(total_height, 0, &main_view); + main_view.VSplitLeft(250.0f, 0, &main_view); + main_view.VSplitRight(250.0f, &main_view, 0); - ui_draw_rect(&main_view, color_tabbar_active, CORNER_T, 10.0f); + RenderTools()->DrawUIRect(&main_view, color_tabbar_active, CUI::CORNER_T, 10.0f); - ui_margin(&main_view, 5.0f, &main_view); + main_view.Margin(5.0f, &main_view); - RECT seekbar, buttonbar; + CUIRect seekbar, buttonbar; if(menu_active) { - ui_hsplit_t(&main_view, seekbar_height, &seekbar, &buttonbar); - ui_hsplit_t(&buttonbar, margins, 0, &buttonbar); + main_view.HSplitTop(seekbar_height, &seekbar, &buttonbar); + buttonbar.HSplitTop(margins, 0, &buttonbar); } else seekbar = main_view; @@ -61,33 +62,33 @@ void MENUS::render_demoplayer(RECT main_view) void *id = &seekbar_id; char buffer[128]; - ui_draw_rect(&seekbar, vec4(0,0,0,0.5f), CORNER_ALL, 5.0f); + RenderTools()->DrawUIRect(&seekbar, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 5.0f); int current_tick = info->current_tick - info->first_tick; int total_ticks = info->last_tick - info->first_tick; float amount = current_tick/(float)total_ticks; - RECT filledbar = seekbar; + CUIRect filledbar = seekbar; filledbar.w = 10.0f + (filledbar.w-10.0f)*amount; - ui_draw_rect(&filledbar, vec4(1,1,1,0.5f), CORNER_ALL, 5.0f); + RenderTools()->DrawUIRect(&filledbar, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 5.0f); str_format(buffer, sizeof(buffer), "%d:%02d / %d:%02d", current_tick/SERVER_TICK_SPEED/60, (current_tick/SERVER_TICK_SPEED)%60, total_ticks/SERVER_TICK_SPEED/60, (total_ticks/SERVER_TICK_SPEED)%60); - ui_do_label(&seekbar, buffer, seekbar.h*0.70f, 0); + UI()->DoLabel(&seekbar, buffer, seekbar.h*0.70f, 0); // do the logic - int inside = ui_mouse_inside(&seekbar); + int inside = UI()->MouseInside(&seekbar); - if(ui_active_item() == id) + if(UI()->ActiveItem() == id) { - if(!ui_mouse_button(0)) - ui_set_active_item(0); + if(!UI()->MouseButton(0)) + UI()->SetActiveItem(0); else { - float amount = (ui_mouse_x()-seekbar.x)/(float)seekbar.w; + float amount = (UI()->MouseX()-seekbar.x)/(float)seekbar.w; if(amount > 0 && amount < 1.0f) { gameclient.on_reset(); @@ -97,43 +98,43 @@ void MENUS::render_demoplayer(RECT main_view) } } } - else if(ui_hot_item() == id) + else if(UI()->HotItem() == id) { - if(ui_mouse_button(0)) - ui_set_active_item(id); + if(UI()->MouseButton(0)) + UI()->SetActiveItem(id); } if(inside) - ui_set_hot_item(id); + UI()->SetHotItem(id); } if(menu_active) { // do buttons - RECT button; + CUIRect button; // pause button - ui_vsplit_l(&buttonbar, buttonbar_height, &button, &buttonbar); + buttonbar.VSplitLeft(buttonbar_height, &button, &buttonbar); static int pause_button = 0; - if(ui_do_button(&pause_button, "| |", info->paused, &button, ui_draw_demoplayer_button, 0)) + if(DoButton_DemoPlayer(&pause_button, "| |", info->paused, &button)) client_demoplayer_setpause(!info->paused); // play button - ui_vsplit_l(&buttonbar, margins, 0, &buttonbar); - ui_vsplit_l(&buttonbar, buttonbar_height, &button, &buttonbar); + buttonbar.VSplitLeft(margins, 0, &buttonbar); + buttonbar.VSplitLeft(buttonbar_height, &button, &buttonbar); static int play_button = 0; - if(ui_do_button(&play_button, ">", !info->paused, &button, ui_draw_demoplayer_button, 0)) + if(DoButton_DemoPlayer(&play_button, ">", !info->paused, &button)) { client_demoplayer_setpause(0); client_demoplayer_setspeed(1.0f); } // slowdown - ui_vsplit_l(&buttonbar, margins, 0, &buttonbar); - ui_vsplit_l(&buttonbar, buttonbar_height, &button, &buttonbar); + buttonbar.VSplitLeft(margins, 0, &buttonbar); + buttonbar.VSplitLeft(buttonbar_height, &button, &buttonbar); static int slowdown_button = 0; - if(ui_do_button(&slowdown_button, "<<", 0, &button, ui_draw_demoplayer_button, 0)) + if(DoButton_DemoPlayer(&slowdown_button, "<<", 0, &button)) { if(info->speed > 4.0f) client_demoplayer_setspeed(4.0f); else if(info->speed > 2.0f) client_demoplayer_setspeed(2.0f); @@ -143,10 +144,10 @@ void MENUS::render_demoplayer(RECT main_view) } // fastforward - ui_vsplit_l(&buttonbar, margins, 0, &buttonbar); - ui_vsplit_l(&buttonbar, buttonbar_height, &button, &buttonbar); + buttonbar.VSplitLeft(margins, 0, &buttonbar); + buttonbar.VSplitLeft(buttonbar_height, &button, &buttonbar); static int fastforward_button = 0; - if(ui_do_button(&fastforward_button, ">>", 0, &button, ui_draw_demoplayer_button, 0)) + if(DoButton_DemoPlayer(&fastforward_button, ">>", 0, &button)) { if(info->speed < 0.5f) client_demoplayer_setspeed(0.5f); else if(info->speed < 1.0f) client_demoplayer_setspeed(1.0f); @@ -156,24 +157,24 @@ void MENUS::render_demoplayer(RECT main_view) } // speed meter - ui_vsplit_l(&buttonbar, margins*3, 0, &buttonbar); + buttonbar.VSplitLeft(margins*3, 0, &buttonbar); char buffer[64]; if(info->speed >= 1.0f) str_format(buffer, sizeof(buffer), "x%.0f", info->speed); else str_format(buffer, sizeof(buffer), "x%.1f", info->speed); - ui_do_label(&buttonbar, buffer, button.h*0.7f, -1); + UI()->DoLabel(&buttonbar, buffer, button.h*0.7f, -1); // close button - ui_vsplit_r(&buttonbar, buttonbar_height*3, &buttonbar, &button); + buttonbar.VSplitRight(buttonbar_height*3, &buttonbar, &button); static int exit_button = 0; - if(ui_do_button(&exit_button, localize("Close"), 0, &button, ui_draw_demoplayer_button, 0)) + if(DoButton_DemoPlayer(&exit_button, localize("Close"), 0, &button)) client_disconnect(); } } -static RECT listbox_originalview; -static RECT listbox_view; +static CUIRect listbox_originalview; +static CUIRect listbox_view; static float listbox_rowheight; static int listbox_itemindex; static int listbox_selected_index; @@ -181,27 +182,27 @@ static int listbox_new_selected; static int listbox_doneevents; static int listbox_numitems; -void MENUS::ui_do_listbox_start(void *id, const RECT *rect, float row_height, const char *title, int num_items, int selected_index) +void MENUS::ui_do_listbox_start(void *id, const CUIRect *rect, float row_height, const char *title, int num_items, int selected_index) { - RECT scroll, row; - RECT view = *rect; - RECT header, footer; + CUIRect scroll, row; + CUIRect view = *rect; + CUIRect header, footer; // draw header - ui_hsplit_t(&view, listheader_height, &header, &view); - ui_draw_rect(&header, vec4(1,1,1,0.25f), CORNER_T, 5.0f); - ui_do_label(&header, title, header.h*fontmod_height, 0); + view.HSplitTop(listheader_height, &header, &view); + RenderTools()->DrawUIRect(&header, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f); + UI()->DoLabel(&header, title, header.h*fontmod_height, 0); // draw footers - ui_hsplit_b(&view, listheader_height, &view, &footer); - ui_draw_rect(&footer, vec4(1,1,1,0.25f), CORNER_B, 5.0f); - ui_vsplit_l(&footer, 10.0f, 0, &footer); + view.HSplitBottom(listheader_height, &view, &footer); + RenderTools()->DrawUIRect(&footer, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f); + footer.VSplitLeft(10.0f, 0, &footer); // background - ui_draw_rect(&view, vec4(0,0,0,0.15f), 0, 0); + RenderTools()->DrawUIRect(&view, vec4(0,0,0,0.15f), 0, 0); // prepare the scroll - ui_vsplit_r(&view, 15, &view, &scroll); + view.VSplitRight(15, &view, &scroll); // setup the variables listbox_originalview = view; @@ -215,7 +216,7 @@ void MENUS::ui_do_listbox_start(void *id, const RECT *rect, float row_height, co // do the scrollbar - ui_hsplit_t(&view, listbox_rowheight, &row, 0); + view.HSplitTop(listbox_rowheight, &row, 0); int num_viewable = (int)(listbox_originalview.h/row.h) + 1; int num = num_items-num_viewable+1; @@ -223,8 +224,8 @@ void MENUS::ui_do_listbox_start(void *id, const RECT *rect, float row_height, co num = 0; static float scrollvalue = 0; - ui_hmargin(&scroll, 5.0f, &scroll); - scrollvalue = ui_do_scrollbar_v(id, &scroll, scrollvalue); + scroll.HMargin(5.0f, &scroll); + scrollvalue = DoScrollbarV(id, &scroll, scrollvalue); int start = (int)(num*scrollvalue); if(start < 0) @@ -232,19 +233,62 @@ void MENUS::ui_do_listbox_start(void *id, const RECT *rect, float row_height, co // the list listbox_view = listbox_originalview; - ui_vmargin(&listbox_view, 5.0f, &listbox_view); - ui_clip_enable(&listbox_view); + listbox_view.VMargin(5.0f, &listbox_view); + UI()->ClipEnable(&listbox_view); listbox_view.y -= scrollvalue*num*row.h; } -MENUS::LISTBOXITEM MENUS::ui_do_listbox_nextitem(void *id) +MENUS::LISTBOXITEM MENUS::ui_do_listbox_nextrow() { - RECT row; LISTBOXITEM item = {0}; - ui_hsplit_t(&listbox_view, listbox_rowheight /*-2.0f*/, &row, &listbox_view); - //ui_hsplit_t(&listbox_view, 2.0f, 0, &listbox_view); + listbox_view.HSplitTop(listbox_rowheight /*-2.0f*/, &item.rect, &listbox_view); + item.visible = 1; + //item.rect = row; + + item.hitrect = item.rect; + + //CUIRect select_hit_box = item.rect; + + if(listbox_selected_index == listbox_itemindex) + item.selected = 1; + + // make sure that only those in view can be selected + if(item.rect.y+item.rect.h > listbox_originalview.y) + { + + if(item.hitrect.y < item.hitrect.y) // clip the selection + { + item.hitrect.h -= listbox_originalview.y-item.hitrect.y; + item.hitrect.y = listbox_originalview.y; + } + + } + else + item.visible = 0; - RECT select_hit_box = row; + // check if we need to do more + if(item.rect.y > listbox_originalview.y+listbox_originalview.h) + item.visible = 0; + + listbox_itemindex++; + return item; +} + +MENUS::LISTBOXITEM MENUS::ui_do_listbox_nextitem(void *id) +{ + int this_itemindex = listbox_itemindex; + + LISTBOXITEM item = ui_do_listbox_nextrow(); + + if(UI()->DoButtonLogic(id, "", listbox_selected_index == listbox_itemindex, &item.hitrect)) + listbox_new_selected = listbox_itemindex; + + //CUIRect row; + //LISTBOXITEM item = {0}; + //listbox_view.HSplitTop(listbox_rowheight /*-2.0f*/, &row, &listbox_view); + //listbox_view.HSplitTop(2.0f, 0, &listbox_view); + /* + CUIRect select_hit_box = row; item.visible = 1; if(listbox_selected_index == listbox_itemindex) @@ -260,19 +304,17 @@ MENUS::LISTBOXITEM MENUS::ui_do_listbox_nextitem(void *id) select_hit_box.y = listbox_originalview.y; } - if(ui_do_button(id, "", listbox_selected_index==listbox_itemindex, &select_hit_box, 0, 0)) + if(UI()->DoButton(id, "", listbox_selected_index==listbox_itemindex, &select_hit_box, 0, 0)) listbox_new_selected = listbox_itemindex; } else item.visible = 0; item.rect = row; + */ - // check if we need to do more - if(row.y > listbox_originalview.y+listbox_originalview.h) - item.visible = 0; - if(listbox_selected_index==listbox_itemindex) + if(listbox_selected_index == this_itemindex) { if(!listbox_doneevents) { @@ -294,21 +336,18 @@ MENUS::LISTBOXITEM MENUS::ui_do_listbox_nextitem(void *id) } //selected_index = i; - RECT r = row; - ui_margin(&r, 1.5f, &r); - ui_draw_rect(&r, vec4(1,1,1,0.5f), CORNER_ALL, 4.0f); + CUIRect r = item.rect; + r.Margin(1.5f, &r); + RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 4.0f); } - listbox_itemindex++; - - ui_vmargin(&item.rect, 5.0f, &item.rect); - + //listbox_itemindex++; return item; } int MENUS::ui_do_listbox_end() { - ui_clip_disable(); + UI()->ClipDisable(); return listbox_new_selected; } @@ -346,7 +385,7 @@ void MENUS::demolist_populate() } -void MENUS::render_demolist(RECT main_view) +void MENUS::render_demolist(CUIRect main_view) { static int inited = 0; if(!inited) @@ -354,12 +393,12 @@ void MENUS::render_demolist(RECT main_view) inited = 1; // render background - ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f); - ui_margin(&main_view, 10.0f, &main_view); + RenderTools()->DrawUIRect(&main_view, color_tabbar_active, CUI::CORNER_ALL, 10.0f); + main_view.Margin(10.0f, &main_view); - RECT buttonbar; - ui_hsplit_b(&main_view, button_height+5.0f, &main_view, &buttonbar); - ui_hsplit_t(&buttonbar, 5.0f, 0, &buttonbar); + CUIRect buttonbar; + main_view.HSplitBottom(button_height+5.0f, &main_view, &buttonbar); + buttonbar.HSplitTop(5.0f, 0, &buttonbar); static int selected_item = -1; static int demolist_id = 0; @@ -370,23 +409,23 @@ void MENUS::render_demolist(RECT main_view) { LISTBOXITEM item = ui_do_listbox_nextitem((void*)(&r.front())); if(item.visible) - ui_do_label(&item.rect, r.front().name, item.rect.h*fontmod_height, -1); + UI()->DoLabel(&item.rect, r.front().name, item.rect.h*fontmod_height, -1); } selected_item = ui_do_listbox_end(); - RECT refresh_rect, play_rect; - ui_vsplit_r(&buttonbar, 250.0f, &buttonbar, &refresh_rect); - ui_vsplit_r(&refresh_rect, 130.0f, &refresh_rect, &play_rect); - ui_vsplit_r(&play_rect, 120.0f, 0x0, &play_rect); + CUIRect refresh_rect, play_rect; + buttonbar.VSplitRight(250.0f, &buttonbar, &refresh_rect); + refresh_rect.VSplitRight(130.0f, &refresh_rect, &play_rect); + play_rect.VSplitRight(120.0f, 0x0, &play_rect); static int refresh_button = 0; - if(ui_do_button(&refresh_button, localize("Refresh"), 0, &refresh_rect, ui_draw_menu_button, 0)) + if(DoButton_Menu(&refresh_button, localize("Refresh"), 0, &refresh_rect)) { demolist_populate(); } static int play_button = 0; - if(ui_do_button(&play_button, localize("Play"), 0, &play_rect, ui_draw_menu_button, 0)) + if(DoButton_Menu(&play_button, localize("Play"), 0, &play_rect)) { if(selected_item >= 0 && selected_item < demos.size()) { diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 83673631..d31a15bd 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -17,30 +17,30 @@ #include "motd.hpp" #include "voting.hpp" -void MENUS::render_game(RECT main_view) +void MENUS::render_game(CUIRect main_view) { - RECT button; - //RECT votearea; - ui_hsplit_t(&main_view, 45.0f, &main_view, 0); - ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f); - - ui_hsplit_t(&main_view, 10.0f, 0, &main_view); - ui_hsplit_t(&main_view, 25.0f, &main_view, 0); - ui_vmargin(&main_view, 10.0f, &main_view); + CUIRect button; + //CUIRect votearea; + main_view.HSplitTop(45.0f, &main_view, 0); + RenderTools()->DrawUIRect(&main_view, color_tabbar_active, CUI::CORNER_ALL, 10.0f); + + main_view.HSplitTop(10.0f, 0, &main_view); + main_view.HSplitTop(25.0f, &main_view, 0); + main_view.VMargin(10.0f, &main_view); - ui_vsplit_r(&main_view, 120.0f, &main_view, &button); + main_view.VSplitRight(120.0f, &main_view, &button); static int disconnect_button = 0; - if(ui_do_button(&disconnect_button, localize("Disconnect"), 0, &button, ui_draw_menu_button, 0)) + if(DoButton_Menu(&disconnect_button, localize("Disconnect"), 0, &button)) client_disconnect(); if(gameclient.snap.local_info && gameclient.snap.gameobj) { if(gameclient.snap.local_info->team != -1) { - ui_vsplit_l(&main_view, 10.0f, &button, &main_view); - ui_vsplit_l(&main_view, 120.0f, &button, &main_view); + main_view.VSplitLeft(10.0f, &button, &main_view); + main_view.VSplitLeft(120.0f, &button, &main_view); static int spectate_button = 0; - if(ui_do_button(&spectate_button, localize("Spectate"), 0, &button, ui_draw_menu_button, 0)) + if(DoButton_Menu(&spectate_button, localize("Spectate"), 0, &button)) { gameclient.send_switch_team(-1); set_active(false); @@ -51,10 +51,10 @@ void MENUS::render_game(RECT main_view) { if(gameclient.snap.local_info->team != 0) { - ui_vsplit_l(&main_view, 10.0f, &button, &main_view); - ui_vsplit_l(&main_view, 120.0f, &button, &main_view); + main_view.VSplitLeft(10.0f, &button, &main_view); + main_view.VSplitLeft(120.0f, &button, &main_view); static int spectate_button = 0; - if(ui_do_button(&spectate_button, localize("Join red"), 0, &button, ui_draw_menu_button, 0)) + if(DoButton_Menu(&spectate_button, localize("Join red"), 0, &button)) { gameclient.send_switch_team(0); set_active(false); @@ -63,10 +63,10 @@ void MENUS::render_game(RECT main_view) if(gameclient.snap.local_info->team != 1) { - ui_vsplit_l(&main_view, 10.0f, &button, &main_view); - ui_vsplit_l(&main_view, 120.0f, &button, &main_view); + main_view.VSplitLeft(10.0f, &button, &main_view); + main_view.VSplitLeft(120.0f, &button, &main_view); static int spectate_button = 0; - if(ui_do_button(&spectate_button, localize("Join blue"), 0, &button, ui_draw_menu_button, 0)) + if(DoButton_Menu(&spectate_button, localize("Join blue"), 0, &button)) { gameclient.send_switch_team(1); set_active(false); @@ -77,10 +77,10 @@ void MENUS::render_game(RECT main_view) { if(gameclient.snap.local_info->team != 0) { - ui_vsplit_l(&main_view, 10.0f, &button, &main_view); - ui_vsplit_l(&main_view, 120.0f, &button, &main_view); + main_view.VSplitLeft(10.0f, &button, &main_view); + main_view.VSplitLeft(120.0f, &button, &main_view); static int spectate_button = 0; - if(ui_do_button(&spectate_button, localize("Join game"), 0, &button, ui_draw_menu_button, 0)) + if(DoButton_Menu(&spectate_button, localize("Join game"), 0, &button)) { gameclient.send_switch_team(0); set_active(false); @@ -90,58 +90,58 @@ void MENUS::render_game(RECT main_view) } /* - RECT bars; - ui_hsplit_t(&votearea, 10.0f, 0, &votearea); - ui_hsplit_t(&votearea, 25.0f + 10.0f*3 + 25.0f, &votearea, &bars); + CUIRect bars; + votearea.HSplitTop(10.0f, 0, &votearea); + votearea.HSplitTop(25.0f + 10.0f*3 + 25.0f, &votearea, &bars); - ui_draw_rect(&votearea, color_tabbar_active, CORNER_ALL, 10.0f); + RenderTools()->DrawUIRect(&votearea, color_tabbar_active, CUI::CORNER_ALL, 10.0f); - ui_vmargin(&votearea, 20.0f, &votearea); - ui_hmargin(&votearea, 10.0f, &votearea); + votearea.VMargin(20.0f, &votearea); + votearea.HMargin(10.0f, &votearea); - ui_hsplit_b(&votearea, 35.0f, &votearea, &bars); + votearea.HSplitBottom(35.0f, &votearea, &bars); if(gameclient.voting->is_voting()) { // do yes button - ui_vsplit_l(&votearea, 50.0f, &button, &votearea); + votearea.VSplitLeft(50.0f, &button, &votearea); static int yes_button = 0; - if(ui_do_button(&yes_button, "Yes", 0, &button, ui_draw_menu_button, 0)) + if(UI()->DoButton(&yes_button, "Yes", 0, &button, ui_draw_menu_button, 0)) gameclient.voting->vote(1); // do no button - ui_vsplit_l(&votearea, 5.0f, 0, &votearea); - ui_vsplit_l(&votearea, 50.0f, &button, &votearea); + votearea.VSplitLeft(5.0f, 0, &votearea); + votearea.VSplitLeft(50.0f, &button, &votearea); static int no_button = 0; - if(ui_do_button(&no_button, "No", 0, &button, ui_draw_menu_button, 0)) + if(UI()->DoButton(&no_button, "No", 0, &button, ui_draw_menu_button, 0)) gameclient.voting->vote(-1); // do time left - ui_vsplit_r(&votearea, 50.0f, &votearea, &button); + votearea.VSplitRight(50.0f, &votearea, &button); char buf[256]; str_format(buf, sizeof(buf), "%d", gameclient.voting->seconds_left()); - ui_do_label(&button, buf, 24.0f, 0); + UI()->DoLabel(&button, buf, 24.0f, 0); // do description and command - ui_vsplit_l(&votearea, 5.0f, 0, &votearea); - ui_do_label(&votearea, gameclient.voting->vote_description(), 14.0f, -1); - ui_hsplit_t(&votearea, 16.0f, 0, &votearea); - ui_do_label(&votearea, gameclient.voting->vote_command(), 10.0f, -1); + votearea.VSplitLeft(5.0f, 0, &votearea); + UI()->DoLabel(&votearea, gameclient.voting->vote_description(), 14.0f, -1); + votearea.HSplitTop(16.0f, 0, &votearea); + UI()->DoLabel(&votearea, gameclient.voting->vote_command(), 10.0f, -1); // do bars - ui_hsplit_t(&bars, 10.0f, 0, &bars); - ui_hmargin(&bars, 5.0f, &bars); + bars.HSplitTop(10.0f, 0, &bars); + bars.HMargin(5.0f, &bars); gameclient.voting->render_bars(bars, true); } else { - ui_do_label(&votearea, "No vote in progress", 18.0f, -1); + UI()->DoLabel(&votearea, "No vote in progress", 18.0f, -1); }*/ } -void MENUS::render_serverinfo(RECT main_view) +void MENUS::render_serverinfo(CUIRect main_view) { // fetch server info SERVER_INFO current_server_info; @@ -164,9 +164,9 @@ void MENUS::render_serverinfo(RECT main_view) } // render background - ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f); + RenderTools()->DrawUIRect(&main_view, color_tabbar_active, CUI::CORNER_ALL, 10.0f); - RECT view, serverinfo, gameinfo, motd; + CUIRect view, serverinfo, gameinfo, motd; float x = 0.0f; float y = 0.0f; @@ -174,14 +174,14 @@ void MENUS::render_serverinfo(RECT main_view) char buf[1024]; // set view to use for all sub-modules - ui_margin(&main_view, 10.0f, &view); + main_view.Margin(10.0f, &view); /* serverinfo */ - ui_hsplit_t(&view, view.h/2-5.0f, &serverinfo, &motd); - ui_vsplit_l(&serverinfo, view.w/2-5.0f, &serverinfo, &gameinfo); - ui_draw_rect(&serverinfo, vec4(1,1,1,0.25f), CORNER_ALL, 10.0f); + view.HSplitTop(view.h/2-5.0f, &serverinfo, &motd); + serverinfo.VSplitLeft(view.w/2-5.0f, &serverinfo, &gameinfo); + RenderTools()->DrawUIRect(&serverinfo, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); - ui_margin(&serverinfo, 5.0f, &serverinfo); + serverinfo.Margin(5.0f, &serverinfo); x = 5.0f; y = 0.0f; @@ -208,11 +208,11 @@ void MENUS::render_serverinfo(RECT main_view) gfx_text(0, serverinfo.x+x, serverinfo.y+y, 20, buf, 250); { - RECT button; + CUIRect button; int is_favorite = client_serverbrowse_isfavorite(current_server_info.netaddr); - ui_hsplit_b(&serverinfo, 20.0f, &serverinfo, &button); + serverinfo.HSplitBottom(20.0f, &serverinfo, &button); static int add_fav_button = 0; - if (ui_do_button(&add_fav_button, localize("Favorite"), is_favorite, &button, ui_draw_checkbox, 0)) + if(DoButton_CheckBox(&add_fav_button, localize("Favorite"), is_favorite, &button)) { if(is_favorite) client_serverbrowse_removefavorite(current_server_info.netaddr); @@ -222,10 +222,10 @@ void MENUS::render_serverinfo(RECT main_view) } /* gameinfo */ - ui_vsplit_l(&gameinfo, 10.0f, 0x0, &gameinfo); - ui_draw_rect(&gameinfo, vec4(1,1,1,0.25f), CORNER_ALL, 10.0f); + gameinfo.VSplitLeft(10.0f, 0x0, &gameinfo); + RenderTools()->DrawUIRect(&gameinfo, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); - ui_margin(&gameinfo, 5.0f, &gameinfo); + gameinfo.Margin(5.0f, &gameinfo); x = 5.0f; y = 0.0f; @@ -253,9 +253,9 @@ void MENUS::render_serverinfo(RECT main_view) gfx_text(0, gameinfo.x+x, gameinfo.y+y, 20, buf, 250); /* motd */ - ui_hsplit_t(&motd, 10.0f, 0, &motd); - ui_draw_rect(&motd, vec4(1,1,1,0.25f), CORNER_ALL, 10.0f); - ui_margin(&motd, 5.0f, &motd); + motd.HSplitTop(10.0f, 0, &motd); + RenderTools()->DrawUIRect(&motd, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); + motd.Margin(5.0f, &motd); y = 0.0f; x = 5.0f; gfx_text(0, motd.x+x, motd.y+y, 32, localize("MOTD"), -1); @@ -268,14 +268,14 @@ static const char *format_command(const char *cmd) return cmd; } -void MENUS::render_servercontrol_server(RECT main_view) +void MENUS::render_servercontrol_server(CUIRect main_view) { int num_options = 0; for(VOTING::VOTEOPTION *option = gameclient.voting->first; option; option = option->next) num_options++; static int votelist = 0; - RECT list = main_view; + CUIRect list = main_view; ui_do_listbox_start(&votelist, &list, 24.0f, localize("Settings"), num_options, callvote_selectedoption); for(VOTING::VOTEOPTION *option = gameclient.voting->first; option; option = option->next) @@ -283,62 +283,62 @@ void MENUS::render_servercontrol_server(RECT main_view) LISTBOXITEM item = ui_do_listbox_nextitem(option); if(item.visible) - ui_do_label(&item.rect, format_command(option->command), 16.0f, -1); + UI()->DoLabel(&item.rect, format_command(option->command), 16.0f, -1); } callvote_selectedoption = ui_do_listbox_end(); } -void MENUS::render_servercontrol_kick(RECT main_view) +void MENUS::render_servercontrol_kick(CUIRect main_view) { // draw header - RECT header, footer; - ui_hsplit_t(&main_view, 20, &header, &main_view); - ui_draw_rect(&header, vec4(1,1,1,0.25f), CORNER_T, 5.0f); - ui_do_label(&header, localize("Players"), 18.0f, 0); + CUIRect header, footer; + main_view.HSplitTop(20, &header, &main_view); + RenderTools()->DrawUIRect(&header, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f); + UI()->DoLabel(&header, localize("Players"), 18.0f, 0); // draw footers - ui_hsplit_b(&main_view, 20, &main_view, &footer); - ui_draw_rect(&footer, vec4(1,1,1,0.25f), CORNER_B, 5.0f); - ui_vsplit_l(&footer, 10.0f, 0, &footer); + main_view.HSplitBottom(20, &main_view, &footer); + RenderTools()->DrawUIRect(&footer, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f); + footer.VSplitLeft(10.0f, 0, &footer); // players - ui_draw_rect(&main_view, vec4(0,0,0,0.15f), 0, 0); - RECT list = main_view; + RenderTools()->DrawUIRect(&main_view, vec4(0,0,0,0.15f), 0, 0); + CUIRect list = main_view; for(int i = 0; i < MAX_CLIENTS; i++) { if(!gameclient.snap.player_infos[i]) continue; - RECT button; - ui_hsplit_t(&list, button_height, &button, &list); + CUIRect button; + list.HSplitTop(button_height, &button, &list); - if(ui_do_button((char *)&gameclient.snap+i, "", callvote_selectedplayer == i, &button, ui_draw_list_row, 0)) + if(DoButton_ListRow((char *)&gameclient.snap+i, "", callvote_selectedplayer == i, &button)) callvote_selectedplayer = i; TEE_RENDER_INFO info = gameclient.clients[i].render_info; info.size = button.h; - render_tee(ANIMSTATE::get_idle(), &info, EMOTE_NORMAL, vec2(1,0), vec2(button.x+button.h/2, button.y+button.h/2)); + RenderTools()->RenderTee(ANIMSTATE::get_idle(), &info, EMOTE_NORMAL, vec2(1,0), vec2(button.x+button.h/2, button.y+button.h/2)); button.x += button.h; - ui_do_label(&button, gameclient.clients[i].name, 18.0f, -1); + UI()->DoLabel(&button, gameclient.clients[i].name, 18.0f, -1); } } -void MENUS::render_servercontrol(RECT main_view) +void MENUS::render_servercontrol(CUIRect main_view) { static int control_page = 0; // render background - RECT temp, tabbar; - ui_vsplit_r(&main_view, 120.0f, &main_view, &tabbar); - ui_draw_rect(&main_view, color_tabbar_active, CORNER_B|CORNER_TL, 10.0f); - ui_hsplit_t(&tabbar, 50.0f, &temp, &tabbar); - ui_draw_rect(&temp, color_tabbar_active, CORNER_R, 10.0f); + CUIRect temp, tabbar; + main_view.VSplitRight(120.0f, &main_view, &tabbar); + RenderTools()->DrawUIRect(&main_view, color_tabbar_active, CUI::CORNER_B|CUI::CORNER_TL, 10.0f); + tabbar.HSplitTop(50.0f, &temp, &tabbar); + RenderTools()->DrawUIRect(&temp, color_tabbar_active, CUI::CORNER_R, 10.0f); - ui_hsplit_t(&main_view, 10.0f, 0, &main_view); + main_view.HSplitTop(10.0f, 0, &main_view); - RECT button; + CUIRect button; const char *tabs[] = { localize("Settings"), @@ -347,9 +347,9 @@ void MENUS::render_servercontrol(RECT main_view) for(int i = 0; i < num_tabs; i++) { - ui_hsplit_t(&tabbar, 10, &button, &tabbar); - ui_hsplit_t(&tabbar, 26, &button, &tabbar); - if(ui_do_button(tabs[i], tabs[i], control_page == i, &button, ui_draw_settings_tab_button, 0)) + tabbar.HSplitTop(10, &button, &tabbar); + tabbar.HSplitTop(26, &button, &tabbar); + if(DoButton_SettingsTab(tabs[i], tabs[i], control_page == i, &button)) { control_page = i; callvote_selectedplayer = -1; @@ -357,10 +357,10 @@ void MENUS::render_servercontrol(RECT main_view) } } - ui_margin(&main_view, 10.0f, &main_view); - RECT bottom; - ui_hsplit_b(&main_view, button_height + 5*2, &main_view, &bottom); - ui_hmargin(&bottom, 5.0f, &bottom); + main_view.Margin(10.0f, &main_view); + CUIRect bottom; + main_view.HSplitBottom(button_height + 5*2, &main_view, &bottom); + bottom.HMargin(5.0f, &bottom); // render page if(control_page == 0) @@ -370,11 +370,11 @@ void MENUS::render_servercontrol(RECT main_view) { - RECT button; - ui_vsplit_r(&bottom, 120.0f, &bottom, &button); + CUIRect button; + bottom.VSplitRight(120.0f, &bottom, &button); static int callvote_button = 0; - if(ui_do_button(&callvote_button, localize("Call vote"), 0, &button, ui_draw_menu_button, 0)) + if(DoButton_Menu(&callvote_button, localize("Call vote"), 0, &button)) { if(control_page == 0) { diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 86325ab9..05b4d047 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -5,6 +5,7 @@ #include <stdlib.h> // atoi #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -43,33 +44,31 @@ bool MENUS_KEYBINDER::on_input(INPUT_EVENT e) return false; } -void MENUS::render_settings_player(RECT main_view) +void MENUS::render_settings_player(CUIRect main_view) { - RECT button; - RECT skinselection; - ui_vsplit_l(&main_view, 300.0f, &main_view, &skinselection); - - - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); + CUIRect button; + CUIRect othersection; + main_view.VSplitLeft(300.0f, &main_view, &othersection); + main_view.HSplitTop(20.0f, &button, &main_view); // render settings { char buf[128]; - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); + main_view.HSplitTop(20.0f, &button, &main_view); str_format(buf, sizeof(buf), "%s:", localize("Name")); - ui_do_label(&button, buf, 14.0, -1); - ui_vsplit_l(&button, 80.0f, 0, &button); - ui_vsplit_l(&button, 180.0f, &button, 0); - if(ui_do_edit_box(config.player_name, &button, config.player_name, sizeof(config.player_name), 14.0f)) + UI()->DoLabel(&button, buf, 14.0, -1); + button.VSplitLeft(80.0f, 0, &button); + button.VSplitLeft(180.0f, &button, 0); + if(DoEditBox(config.player_name, &button, config.player_name, sizeof(config.player_name), 14.0f)) need_sendinfo = true; // extra spacing - ui_hsplit_t(&main_view, 10.0f, 0, &main_view); + main_view.HSplitTop(10.0f, 0, &main_view); static int dynamic_camera_button = 0; - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if(ui_do_button(&dynamic_camera_button, localize("Dynamic Camera"), config.cl_mouse_deadzone != 0, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&dynamic_camera_button, localize("Dynamic Camera"), config.cl_mouse_deadzone != 0, &button)) { if(config.cl_mouse_deadzone) @@ -86,26 +85,26 @@ void MENUS::render_settings_player(RECT main_view) } } - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.cl_autoswitch_weapons, localize("Switch weapon on pickup"), config.cl_autoswitch_weapons, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.cl_autoswitch_weapons, localize("Switch weapon on pickup"), config.cl_autoswitch_weapons, &button)) config.cl_autoswitch_weapons ^= 1; - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.cl_nameplates, localize("Show name plates"), config.cl_nameplates, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.cl_nameplates, localize("Show name plates"), config.cl_nameplates, &button)) config.cl_nameplates ^= 1; //if(config.cl_nameplates) { - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - ui_vsplit_l(&button, 15.0f, 0, &button); - if (ui_do_button(&config.cl_nameplates_always, localize("Always show name plates"), config.cl_nameplates_always, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + button.VSplitLeft(15.0f, 0, &button); + if(DoButton_CheckBox(&config.cl_nameplates_always, localize("Always show name plates"), config.cl_nameplates_always, &button)) config.cl_nameplates_always ^= 1; } - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); + main_view.HSplitTop(20.0f, &button, &main_view); - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.player_color_body, localize("Custom colors"), config.player_use_custom_color, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.player_color_body, localize("Custom colors"), config.player_use_custom_color, &button)) { config.player_use_custom_color = config.player_use_custom_color?0:1; need_sendinfo = true; @@ -129,27 +128,27 @@ void MENUS::render_settings_player(RECT main_view) for(int i = 0; i < 2; i++) { - RECT text; - ui_hsplit_t(&main_view, 20.0f, &text, &main_view); - ui_vsplit_l(&text, 15.0f, 0, &text); - ui_do_label(&text, parts[i], 14.0f, -1); + CUIRect text; + main_view.HSplitTop(20.0f, &text, &main_view); + text.VSplitLeft(15.0f, 0, &text); + UI()->DoLabel(&text, parts[i], 14.0f, -1); int prevcolor = *colors[i]; int color = 0; for(int s = 0; s < 3; s++) { - RECT text; - ui_hsplit_t(&main_view, 19.0f, &button, &main_view); - ui_vsplit_l(&button, 30.0f, 0, &button); - ui_vsplit_l(&button, 70.0f, &text, &button); - ui_vsplit_r(&button, 5.0f, &button, 0); - ui_hsplit_t(&button, 4.0f, 0, &button); + CUIRect text; + main_view.HSplitTop(19.0f, &button, &main_view); + button.VSplitLeft(30.0f, 0, &button); + button.VSplitLeft(70.0f, &text, &button); + button.VSplitRight(5.0f, &button, 0); + button.HSplitTop(4.0f, 0, &button); float k = ((prevcolor>>((2-s)*8))&0xff) / 255.0f; - k = ui_do_scrollbar_h(&color_slider[i][s], &button, k); + k = DoScrollbarH(&color_slider[i][s], &button, k); color <<= 8; color += clamp((int)(k*255), 0, 255); - ui_do_label(&text, labels[s], 15.0f, -1); + UI()->DoLabel(&text, labels[s], 15.0f, -1); } @@ -157,35 +156,103 @@ void MENUS::render_settings_player(RECT main_view) need_sendinfo = true; *colors[i] = color; - ui_hsplit_t(&main_view, 5.0f, 0, &main_view); + main_view.HSplitTop(5.0f, 0, &main_view); } } + + // render skinselector + static int skinselector_id = 0; + ui_do_listbox_start(&skinselector_id, &main_view, 50, localize("Skins"), (gameclient.skins->num()+3)/4, 0); + + for(int skin_id = 0; skin_id < gameclient.skins->num(); ) + { + LISTBOXITEM item = ui_do_listbox_nextrow(); + CUIRect boxes[4]; + CUIRect first_half, second_half; + item.rect.VSplitMid(&first_half, &second_half); + first_half.VSplitMid(&boxes[0], &boxes[1]); + second_half.VSplitMid(&boxes[2], &boxes[3]); + + for(int i = 0; i < 4 && skin_id < gameclient.skins->num(); i++, skin_id++) + { + //CUIRect r = item. + const SKINS::SKIN *s = gameclient.skins->get(skin_id); + + TEE_RENDER_INFO info; + info.texture = s->org_texture; + info.color_body = vec4(1,1,1,1); + info.color_feet = vec4(1,1,1,1); + if(config.player_use_custom_color) + { + info.color_body = gameclient.skins->get_color(config.player_color_body); + info.color_feet = gameclient.skins->get_color(config.player_color_feet); + info.texture = s->color_texture; + } + + info.size = UI()->Scale()*50.0f; + + CUIRect icon = boxes[i]; //item.rect; + //button.VSplitLeft(50.0f, &icon, &text); + + /*if(UI()->DoButton(s, "", selected, &button, ui_draw_list_row, 0)) + { + config_set_player_skin(&config, s->name); + need_sendinfo = true; + }*/ + + //text.HSplitTop(12.0f, 0, &text); // some margin from the top + //UI()->DoLabel(&text, buf, 18.0f, 0); + + icon.HSplitTop(5.0f, 0, &icon); // some margin from the top + RenderTools()->RenderTee(ANIMSTATE::get_idle(), &info, 0, vec2(1, 0), vec2(icon.x+icon.w/2, icon.y+icon.h/2)); + + if(config.debug) + { + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(s->blood_color.r, s->blood_color.g, s->blood_color.b, 1.0f); + Graphics()->QuadsDrawTL(icon.x, icon.y, 12, 12); + Graphics()->QuadsEnd(); + } + } + } + + int new_selection = ui_do_listbox_end(); + (void)new_selection; + //main_view + } + + // render skinselector + /* + { + + //othersection } // draw header - RECT header, footer; - ui_hsplit_t(&skinselection, 20, &header, &skinselection); - ui_draw_rect(&header, vec4(1,1,1,0.25f), CORNER_T, 5.0f); - ui_do_label(&header, localize("Skins"), 18.0f, 0); + CUIRect header, footer; + skinselection.HSplitTop(20, &header, &skinselection); + RenderTools()->DrawUIRect(&header, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f); + UI()->DoLabel(&header, localize("Skins"), 18.0f, 0); // draw footers - ui_hsplit_b(&skinselection, 20, &skinselection, &footer); - ui_draw_rect(&footer, vec4(1,1,1,0.25f), CORNER_B, 5.0f); - ui_vsplit_l(&footer, 10.0f, 0, &footer); + skinselection.HSplitBottom(20, &skinselection, &footer); + RenderTools()->DrawUIRect(&footer, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f); + footer.VSplitLeft(10.0f, 0, &footer); // modes - ui_draw_rect(&skinselection, vec4(0,0,0,0.15f), 0, 0); + RenderTools()->DrawUIRect(&skinselection, vec4(0,0,0,0.15f), 0, 0); - RECT scroll; - ui_vsplit_r(&skinselection, 15, &skinselection, &scroll); + CUIRect scroll; + skinselection.VSplitRight(15, &skinselection, &scroll); - RECT list = skinselection; - ui_hsplit_t(&list, 50, &button, &list); + CUIRect list = skinselection; + list.HSplitTop(50, &button, &list); int num = (int)(skinselection.h/button.h); static float scrollvalue = 0; static int scrollbar = 0; - ui_hmargin(&scroll, 5.0f, &scroll); + scroll.HMargin(5.0f, &scroll); scrollvalue = ui_do_scrollbar_v(&scrollbar, &scroll, scrollvalue); int start = (int)((gameclient.skins->num()-num)*scrollvalue); @@ -220,35 +287,35 @@ void MENUS::render_settings_player(RECT main_view) info.texture = s->color_texture; } - info.size = ui_scale()*50.0f; + info.size = UI()->Scale()*50.0f; - RECT icon; - RECT text; - ui_vsplit_l(&button, 50.0f, &icon, &text); + CUIRect icon; + CUIRect text; + button.VSplitLeft(50.0f, &icon, &text); - if(ui_do_button(s, "", selected, &button, ui_draw_list_row, 0)) + if(UI()->DoButton(s, "", selected, &button, ui_draw_list_row, 0)) { config_set_player_skin(&config, s->name); need_sendinfo = true; } - ui_hsplit_t(&text, 12.0f, 0, &text); // some margin from the top - ui_do_label(&text, buf, 18.0f, 0); + text.HSplitTop(12.0f, 0, &text); // some margin from the top + UI()->DoLabel(&text, buf, 18.0f, 0); - ui_hsplit_t(&icon, 5.0f, 0, &icon); // some margin from the top - render_tee(ANIMSTATE::get_idle(), &info, 0, vec2(1, 0), vec2(icon.x+icon.w/2, icon.y+icon.h/2)); + icon.HSplitTop(5.0f, 0, &icon); // some margin from the top + RenderTools()->RenderTee(ANIMSTATE::get_idle(), &info, 0, vec2(1, 0), vec2(icon.x+icon.w/2, icon.y+icon.h/2)); if(config.debug) { - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(s->blood_color.r, s->blood_color.g, s->blood_color.b, 1.0f); - gfx_quads_drawTL(icon.x, icon.y, 12, 12); - gfx_quads_end(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(s->blood_color.r, s->blood_color.g, s->blood_color.b, 1.0f); + Graphics()->QuadsDrawTL(icon.x, icon.y, 12, 12); + Graphics()->QuadsEnd(); } - ui_hsplit_t(&list, 50, &button, &list); - } + list.HSplitTop(50, &button, &list); + }*/ } typedef void (*assign_func_callback)(CONFIGURATION *config, int value); @@ -288,31 +355,31 @@ static KEYINFO keys[] = const int key_count = sizeof(keys) / sizeof(KEYINFO); -void MENUS::ui_do_getbuttons(int start, int stop, RECT view) +void MENUS::ui_do_getbuttons(int start, int stop, CUIRect view) { for (int i = start; i < stop; i++) { KEYINFO &key = keys[i]; - RECT button, label; - ui_hsplit_t(&view, 20.0f, &button, &view); - ui_vsplit_l(&button, 130.0f, &label, &button); + CUIRect button, label; + view.HSplitTop(20.0f, &button, &view); + button.VSplitLeft(130.0f, &label, &button); char buf[64]; str_format(buf, sizeof(buf), "%s:", (const char *)key.name); - ui_do_label(&label, key.name, 14.0f, -1); + UI()->DoLabel(&label, key.name, 14.0f, -1); int oldid = key.keyid; - int newid = ui_do_key_reader((void *)&keys[i].name, &button, oldid); + int newid = DoKeyReader((void *)&keys[i].name, &button, oldid); if(newid != oldid) { gameclient.binds->bind(oldid, ""); gameclient.binds->bind(newid, keys[i].command); } - ui_hsplit_t(&view, 5.0f, 0, &view); + view.HSplitTop(5.0f, 0, &view); } } -void MENUS::render_settings_controls(RECT main_view) +void MENUS::render_settings_controls(CUIRect main_view) { // this is kinda slow, but whatever for(int i = 0; i < key_count; i++) @@ -332,28 +399,28 @@ void MENUS::render_settings_controls(RECT main_view) } } - RECT movement_settings, weapon_settings, voting_settings, chat_settings, misc_settings, reset_button; - ui_vsplit_l(&main_view, main_view.w/2-5.0f, &movement_settings, &voting_settings); + CUIRect movement_settings, weapon_settings, voting_settings, chat_settings, misc_settings, reset_button; + main_view.VSplitLeft(main_view.w/2-5.0f, &movement_settings, &voting_settings); /* movement settings */ { - ui_hsplit_t(&movement_settings, main_view.h/2-5.0f, &movement_settings, &weapon_settings); - ui_draw_rect(&movement_settings, vec4(1,1,1,0.25f), CORNER_ALL, 10.0f); - ui_margin(&movement_settings, 10.0f, &movement_settings); + movement_settings.HSplitTop(main_view.h/2-5.0f, &movement_settings, &weapon_settings); + RenderTools()->DrawUIRect(&movement_settings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); + movement_settings.Margin(10.0f, &movement_settings); gfx_text(0, movement_settings.x, movement_settings.y, 14, localize("Movement"), -1); - ui_hsplit_t(&movement_settings, 14.0f+5.0f+10.0f, 0, &movement_settings); + movement_settings.HSplitTop(14.0f+5.0f+10.0f, 0, &movement_settings); { - RECT button, label; - ui_hsplit_t(&movement_settings, 20.0f, &button, &movement_settings); - ui_vsplit_l(&button, 130.0f, &label, &button); - ui_do_label(&label, localize("Mouse sens."), 14.0f, -1); - ui_hmargin(&button, 2.0f, &button); - config.inp_mousesens = (int)(ui_do_scrollbar_h(&config.inp_mousesens, &button, (config.inp_mousesens-5)/500.0f)*500.0f)+5; + CUIRect button, label; + movement_settings.HSplitTop(20.0f, &button, &movement_settings); + button.VSplitLeft(130.0f, &label, &button); + UI()->DoLabel(&label, localize("Mouse sens."), 14.0f, -1); + button.HMargin(2.0f, &button); + config.inp_mousesens = (int)(DoScrollbarV(&config.inp_mousesens, &button, (config.inp_mousesens-5)/500.0f)*500.0f)+5; //*key.key = ui_do_key_reader(key.key, &button, *key.key); - ui_hsplit_t(&movement_settings, 20.0f, 0, &movement_settings); + movement_settings.HSplitTop(20.0f, 0, &movement_settings); } ui_do_getbuttons(0, 5, movement_settings); @@ -362,65 +429,65 @@ void MENUS::render_settings_controls(RECT main_view) /* weapon settings */ { - ui_hsplit_t(&weapon_settings, 10.0f, 0, &weapon_settings); - ui_draw_rect(&weapon_settings, vec4(1,1,1,0.25f), CORNER_ALL, 10.0f); - ui_margin(&weapon_settings, 10.0f, &weapon_settings); + weapon_settings.HSplitTop(10.0f, 0, &weapon_settings); + RenderTools()->DrawUIRect(&weapon_settings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); + weapon_settings.Margin(10.0f, &weapon_settings); gfx_text(0, weapon_settings.x, weapon_settings.y, 14, localize("Weapon"), -1); - ui_hsplit_t(&weapon_settings, 14.0f+5.0f+10.0f, 0, &weapon_settings); + weapon_settings.HSplitTop(14.0f+5.0f+10.0f, 0, &weapon_settings); ui_do_getbuttons(5, 12, weapon_settings); } /* voting settings */ { - ui_vsplit_l(&voting_settings, 10.0f, 0, &voting_settings); - ui_hsplit_t(&voting_settings, main_view.h/4-5.0f, &voting_settings, &chat_settings); - ui_draw_rect(&voting_settings, vec4(1,1,1,0.25f), CORNER_ALL, 10.0f); - ui_margin(&voting_settings, 10.0f, &voting_settings); + voting_settings.VSplitLeft(10.0f, 0, &voting_settings); + voting_settings.HSplitTop(main_view.h/4-5.0f, &voting_settings, &chat_settings); + RenderTools()->DrawUIRect(&voting_settings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); + voting_settings.Margin(10.0f, &voting_settings); gfx_text(0, voting_settings.x, voting_settings.y, 14, localize("Voting"), -1); - ui_hsplit_t(&voting_settings, 14.0f+5.0f+10.0f, 0, &voting_settings); + voting_settings.HSplitTop(14.0f+5.0f+10.0f, 0, &voting_settings); ui_do_getbuttons(12, 14, voting_settings); } /* chat settings */ { - ui_hsplit_t(&chat_settings, 10.0f, 0, &chat_settings); - ui_hsplit_t(&chat_settings, main_view.h/4-10.0f, &chat_settings, &misc_settings); - ui_draw_rect(&chat_settings, vec4(1,1,1,0.25f), CORNER_ALL, 10.0f); - ui_margin(&chat_settings, 10.0f, &chat_settings); + chat_settings.HSplitTop(10.0f, 0, &chat_settings); + chat_settings.HSplitTop(main_view.h/4-10.0f, &chat_settings, &misc_settings); + RenderTools()->DrawUIRect(&chat_settings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); + chat_settings.Margin(10.0f, &chat_settings); gfx_text(0, chat_settings.x, chat_settings.y, 14, localize("Chat"), -1); - ui_hsplit_t(&chat_settings, 14.0f+5.0f+10.0f, 0, &chat_settings); + chat_settings.HSplitTop(14.0f+5.0f+10.0f, 0, &chat_settings); ui_do_getbuttons(14, 16, chat_settings); } /* misc settings */ { - ui_hsplit_t(&misc_settings, 10.0f, 0, &misc_settings); - ui_hsplit_t(&misc_settings, main_view.h/2-5.0f-45.0f, &misc_settings, &reset_button); - ui_draw_rect(&misc_settings, vec4(1,1,1,0.25f), CORNER_ALL, 10.0f); - ui_margin(&misc_settings, 10.0f, &misc_settings); + misc_settings.HSplitTop(10.0f, 0, &misc_settings); + misc_settings.HSplitTop(main_view.h/2-5.0f-45.0f, &misc_settings, &reset_button); + RenderTools()->DrawUIRect(&misc_settings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); + misc_settings.Margin(10.0f, &misc_settings); gfx_text(0, misc_settings.x, misc_settings.y, 14, localize("Miscellaneous"), -1); - ui_hsplit_t(&misc_settings, 14.0f+5.0f+10.0f, 0, &misc_settings); + misc_settings.HSplitTop(14.0f+5.0f+10.0f, 0, &misc_settings); ui_do_getbuttons(16, 21, misc_settings); } // defaults - ui_hsplit_t(&reset_button, 10.0f, 0, &reset_button); + reset_button.HSplitTop(10.0f, 0, &reset_button); static int default_button = 0; - if (ui_do_button((void*)&default_button, localize("Reset to defaults"), 0, &reset_button, ui_draw_menu_button, 0)) + if(DoButton_Menu((void*)&default_button, localize("Reset to defaults"), 0, &reset_button)) gameclient.binds->set_defaults(); } -void MENUS::render_settings_graphics(RECT main_view) +void MENUS::render_settings_graphics(CUIRect main_view) { - RECT button; + CUIRect button; char buf[128]; static const int MAX_RESOLUTIONS = 256; @@ -430,44 +497,44 @@ void MENUS::render_settings_graphics(RECT main_view) if(num_modes == -1) num_modes = gfx_get_video_modes(modes, MAX_RESOLUTIONS); - RECT modelist; - ui_vsplit_l(&main_view, 300.0f, &main_view, &modelist); + CUIRect modelist; + main_view.VSplitLeft(300.0f, &main_view, &modelist); // draw allmodes switch - RECT header, footer; - ui_hsplit_t(&modelist, 20, &button, &modelist); - if (ui_do_button(&config.gfx_display_all_modes, localize("Show only supported"), config.gfx_display_all_modes^1, &button, ui_draw_checkbox, 0)) + CUIRect header, footer; + modelist.HSplitTop(20, &button, &modelist); + if(DoButton_CheckBox(&config.gfx_display_all_modes, localize("Show only supported"), config.gfx_display_all_modes^1, &button)) { config.gfx_display_all_modes ^= 1; num_modes = gfx_get_video_modes(modes, MAX_RESOLUTIONS); } // draw header - ui_hsplit_t(&modelist, 20, &header, &modelist); - ui_draw_rect(&header, vec4(1,1,1,0.25f), CORNER_T, 5.0f); - ui_do_label(&header, localize("Display Modes"), 14.0f, 0); + modelist.HSplitTop(20, &header, &modelist); + RenderTools()->DrawUIRect(&header, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f); + UI()->DoLabel(&header, localize("Display Modes"), 14.0f, 0); // draw footers - ui_hsplit_b(&modelist, 20, &modelist, &footer); + modelist.HSplitBottom(20, &modelist, &footer); str_format(buf, sizeof(buf), "%s: %dx%d %d bit", localize("Current"), config.gfx_screen_width, config.gfx_screen_height, config.gfx_color_depth); - ui_draw_rect(&footer, vec4(1,1,1,0.25f), CORNER_B, 5.0f); - ui_vsplit_l(&footer, 10.0f, 0, &footer); - ui_do_label(&footer, buf, 14.0f, -1); + RenderTools()->DrawUIRect(&footer, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f); + footer.VSplitLeft(10.0f, 0, &footer); + UI()->DoLabel(&footer, buf, 14.0f, -1); // modes - ui_draw_rect(&modelist, vec4(0,0,0,0.15f), 0, 0); + RenderTools()->DrawUIRect(&modelist, vec4(0,0,0,0.15f), 0, 0); - RECT scroll; - ui_vsplit_r(&modelist, 15, &modelist, &scroll); + CUIRect scroll; + modelist.VSplitRight(15, &modelist, &scroll); - RECT list = modelist; - ui_hsplit_t(&list, 20, &button, &list); + CUIRect list = modelist; + list.HSplitTop(20, &button, &list); int num = (int)(modelist.h/button.h); static float scrollvalue = 0; static int scrollbar = 0; - ui_hmargin(&scroll, 5.0f, &scroll); - scrollvalue = ui_do_scrollbar_v(&scrollbar, &scroll, scrollvalue); + scroll.HMargin(5.0f, &scroll); + scrollvalue = DoScrollbarV(&scrollbar, &scroll, scrollvalue); int start = (int)((num_modes-num)*scrollvalue); if(start < 0) @@ -490,7 +557,7 @@ void MENUS::render_settings_graphics(RECT main_view) } str_format(buf, sizeof(buf), " %dx%d %d bit", modes[i].width, modes[i].height, depth); - if(ui_do_button(&modes[i], buf, selected, &button, ui_draw_list_row, 0)) + if(DoButton_ListRow(&modes[i], buf, selected, &button)) { config.gfx_color_depth = depth; config.gfx_screen_width = modes[i].width; @@ -499,58 +566,58 @@ void MENUS::render_settings_graphics(RECT main_view) need_restart = true; } - ui_hsplit_t(&list, 20, &button, &list); + list.HSplitTop(20, &button, &list); } // switches - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.gfx_fullscreen, localize("Fullscreen"), config.gfx_fullscreen, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.gfx_fullscreen, localize("Fullscreen"), config.gfx_fullscreen, &button)) { config.gfx_fullscreen ^= 1; need_restart = true; } - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.gfx_vsync, localize("V-Sync"), config.gfx_vsync, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.gfx_vsync, localize("V-Sync"), config.gfx_vsync, &button)) { config.gfx_vsync ^= 1; need_restart = true; } - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.gfx_fsaa_samples, localize("FSAA samples"), config.gfx_fsaa_samples, &button, ui_draw_checkbox_number, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox_Number(&config.gfx_fsaa_samples, localize("FSAA samples"), config.gfx_fsaa_samples, &button)) { config.gfx_fsaa_samples = (config.gfx_fsaa_samples+1)%17; need_restart = true; } - ui_hsplit_t(&main_view, 40.0f, &button, &main_view); - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.gfx_texture_quality, localize("Quality Textures"), config.gfx_texture_quality, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(40.0f, &button, &main_view); + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.gfx_texture_quality, localize("Quality Textures"), config.gfx_texture_quality, &button)) { config.gfx_texture_quality ^= 1; need_restart = true; } - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.gfx_texture_compression, localize("Texture Compression"), config.gfx_texture_compression, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.gfx_texture_compression, localize("Texture Compression"), config.gfx_texture_compression, &button)) { config.gfx_texture_compression ^= 1; need_restart = true; } - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.gfx_high_detail, localize("High Detail"), config.gfx_high_detail, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.gfx_high_detail, localize("High Detail"), config.gfx_high_detail, &button)) config.gfx_high_detail ^= 1; // - RECT text; - ui_hsplit_t(&main_view, 20.0f, 0, &main_view); - ui_hsplit_t(&main_view, 20.0f, &text, &main_view); - //ui_vsplit_l(&text, 15.0f, 0, &text); - ui_do_label(&text, localize("UI Color"), 14.0f, -1); + CUIRect text; + main_view.HSplitTop(20.0f, 0, &main_view); + main_view.HSplitTop(20.0f, &text, &main_view); + //text.VSplitLeft(15.0f, 0, &text); + UI()->DoLabel(&text, localize("UI Color"), 14.0f, -1); const char *labels[] = { localize("Hue"), @@ -560,27 +627,27 @@ void MENUS::render_settings_graphics(RECT main_view) int *color_slider[4] = {&config.ui_color_hue, &config.ui_color_sat, &config.ui_color_lht, &config.ui_color_alpha}; for(int s = 0; s < 4; s++) { - RECT text; - ui_hsplit_t(&main_view, 19.0f, &button, &main_view); - ui_vmargin(&button, 15.0f, &button); - ui_vsplit_l(&button, 50.0f, &text, &button); - ui_vsplit_r(&button, 5.0f, &button, 0); - ui_hsplit_t(&button, 4.0f, 0, &button); + CUIRect text; + main_view.HSplitTop(19.0f, &button, &main_view); + button.VMargin(15.0f, &button); + button.VSplitLeft(50.0f, &text, &button); + button.VSplitRight(5.0f, &button, 0); + button.HSplitTop(4.0f, 0, &button); float k = (*color_slider[s]) / 255.0f; - k = ui_do_scrollbar_h(color_slider[s], &button, k); + k = DoScrollbarH(color_slider[s], &button, k); *color_slider[s] = (int)(k*255.0f); - ui_do_label(&text, labels[s], 15.0f, -1); + UI()->DoLabel(&text, labels[s], 15.0f, -1); } } -void MENUS::render_settings_sound(RECT main_view) +void MENUS::render_settings_sound(CUIRect main_view) { - RECT button; - ui_vsplit_l(&main_view, 300.0f, &main_view, 0); + CUIRect button; + main_view.VSplitLeft(300.0f, &main_view, 0); - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.snd_enable, localize("Use sounds"), config.snd_enable, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.snd_enable, localize("Use sounds"), config.snd_enable, &button)) { config.snd_enable ^= 1; need_restart = true; @@ -589,19 +656,19 @@ void MENUS::render_settings_sound(RECT main_view) if(!config.snd_enable) return; - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - if (ui_do_button(&config.snd_nonactive_mute, localize("Mute when not active"), config.snd_nonactive_mute, &button, ui_draw_checkbox, 0)) + main_view.HSplitTop(20.0f, &button, &main_view); + if(DoButton_CheckBox(&config.snd_nonactive_mute, localize("Mute when not active"), config.snd_nonactive_mute, &button)) config.snd_nonactive_mute ^= 1; // sample rate box { char buf[64]; str_format(buf, sizeof(buf), "%d", config.snd_rate); - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - ui_do_label(&button, localize("Sample rate"), 14.0f, -1); - ui_vsplit_l(&button, 110.0f, 0, &button); - ui_vsplit_l(&button, 180.0f, &button, 0); - ui_do_edit_box(&config.snd_rate, &button, buf, sizeof(buf), 14.0f); + main_view.HSplitTop(20.0f, &button, &main_view); + UI()->DoLabel(&button, localize("Sample rate"), 14.0f, -1); + button.VSplitLeft(110.0f, 0, &button); + button.VSplitLeft(180.0f, &button, 0); + DoEditBox(&config.snd_rate, &button, buf, sizeof(buf), 14.0f); int before = config.snd_rate; config.snd_rate = atoi(buf); @@ -614,14 +681,14 @@ void MENUS::render_settings_sound(RECT main_view) // volume slider { - RECT button, label; - ui_hsplit_t(&main_view, 5.0f, &button, &main_view); - ui_hsplit_t(&main_view, 20.0f, &button, &main_view); - ui_vsplit_l(&button, 110.0f, &label, &button); - ui_hmargin(&button, 2.0f, &button); - ui_do_label(&label, localize("Sound volume"), 14.0f, -1); - config.snd_volume = (int)(ui_do_scrollbar_h(&config.snd_volume, &button, config.snd_volume/100.0f)*100.0f); - ui_hsplit_t(&main_view, 20.0f, 0, &main_view); + CUIRect button, label; + main_view.HSplitTop(5.0f, &button, &main_view); + main_view.HSplitTop(20.0f, &button, &main_view); + button.VSplitLeft(110.0f, &label, &button); + button.HMargin(2.0f, &button); + UI()->DoLabel(&label, localize("Sound volume"), 14.0f, -1); + config.snd_volume = (int)(DoScrollbarH(&config.snd_volume, &button, config.snd_volume/100.0f)*100.0f); + main_view.HSplitTop(20.0f, 0, &main_view); } } @@ -660,7 +727,7 @@ void gather_languages(const char *name, int is_dir, void *user) languages.add(LANGUAGE(nicename, filename)); } -void MENUS::render_settings_general(RECT main_view) +void MENUS::render_settings_general(CUIRect main_view) { static int lanuagelist = 0; static int selected_language = 0; @@ -680,7 +747,7 @@ void MENUS::render_settings_general(RECT main_view) int old_selected = selected_language; - RECT list = main_view; + CUIRect list = main_view; ui_do_listbox_start(&lanuagelist, &list, 24.0f, localize("Language"), languages.size(), selected_language); for(sorted_array<LANGUAGE>::range r = languages.all(); !r.empty(); r.pop_front()) @@ -688,7 +755,7 @@ void MENUS::render_settings_general(RECT main_view) LISTBOXITEM item = ui_do_listbox_nextitem(&r.front()); if(item.visible) - ui_do_label(&item.rect, r.front().name, 16.0f, -1); + UI()->DoLabel(&item.rect, r.front().name, 16.0f, -1); } selected_language = ui_do_listbox_end(); @@ -700,20 +767,20 @@ void MENUS::render_settings_general(RECT main_view) } } -void MENUS::render_settings(RECT main_view) +void MENUS::render_settings(CUIRect main_view) { static int settings_page = 0; // render background - RECT temp, tabbar; - ui_vsplit_r(&main_view, 120.0f, &main_view, &tabbar); - ui_draw_rect(&main_view, color_tabbar_active, CORNER_B|CORNER_TL, 10.0f); - ui_hsplit_t(&tabbar, 50.0f, &temp, &tabbar); - ui_draw_rect(&temp, color_tabbar_active, CORNER_R, 10.0f); + CUIRect temp, tabbar; + main_view.VSplitRight(120.0f, &main_view, &tabbar); + RenderTools()->DrawUIRect(&main_view, color_tabbar_active, CUI::CORNER_B|CUI::CORNER_TL, 10.0f); + tabbar.HSplitTop(50.0f, &temp, &tabbar); + RenderTools()->DrawUIRect(&temp, color_tabbar_active, CUI::CORNER_R, 10.0f); - ui_hsplit_t(&main_view, 10.0f, 0, &main_view); + main_view.HSplitTop(10.0f, 0, &main_view); - RECT button; + CUIRect button; const char *tabs[] = { localize("General"), @@ -721,17 +788,18 @@ void MENUS::render_settings(RECT main_view) localize("Controls"), localize("Graphics"), localize("Sound")}; + int num_tabs = (int)(sizeof(tabs)/sizeof(*tabs)); for(int i = 0; i < num_tabs; i++) { - ui_hsplit_t(&tabbar, 10, &button, &tabbar); - ui_hsplit_t(&tabbar, 26, &button, &tabbar); - if(ui_do_button(tabs[i], tabs[i], settings_page == i, &button, ui_draw_settings_tab_button, 0)) + tabbar.HSplitTop(10, &button, &tabbar); + tabbar.HSplitTop(26, &button, &tabbar); + if(DoButton_SettingsTab(tabs[i], tabs[i], settings_page == i, &button)) settings_page = i; } - ui_margin(&main_view, 10.0f, &main_view); + main_view.Margin(10.0f, &main_view); if(settings_page == 0) render_settings_general(main_view); @@ -746,8 +814,8 @@ void MENUS::render_settings(RECT main_view) if(need_restart) { - RECT restart_warning; - ui_hsplit_b(&main_view, 40, &main_view, &restart_warning); - ui_do_label(&restart_warning, localize("You must restart the game for all settings to take effect."), 15.0f, -1, 220); + CUIRect restart_warning; + main_view.HSplitBottom(40, &main_view, &restart_warning); + UI()->DoLabel(&restart_warning, localize("You must restart the game for all settings to take effect."), 15.0f, -1, 220); } } diff --git a/src/game/client/components/motd.cpp b/src/game/client/components/motd.cpp index 0d1eacba..ba85f7f8 100644 --- a/src/game/client/components/motd.cpp +++ b/src/game/client/components/motd.cpp @@ -1,4 +1,5 @@ #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <engine/e_config.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -28,22 +29,22 @@ void MOTD::on_render() if(!is_active()) return; - float width = 400*3.0f*gfx_screenaspect(); + float width = 400*3.0f*Graphics()->ScreenAspect(); float height = 400*3.0f; - gfx_mapscreen(0, 0, width, height); + Graphics()->MapScreen(0, 0, width, height); float h = 800.0f; float w = 650.0f; float x = width/2 - w/2; float y = 150.0f; - gfx_blend_normal(); - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.5f); - draw_round_rect(x, y, w, h, 40.0f); - gfx_quads_end(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.5f); + RenderTools()->draw_round_rect(x, y, w, h, 40.0f); + Graphics()->QuadsEnd(); gfx_text(0, x+40.0f, y+40.0f, 32.0f, server_motd, (int)(w-80.0f)); } diff --git a/src/game/client/components/particles.cpp b/src/game/client/components/particles.cpp index ef6dbbe9..61fcf738 100644 --- a/src/game/client/components/particles.cpp +++ b/src/game/client/components/particles.cpp @@ -1,4 +1,6 @@ #include <base/math.hpp> +#include <engine/client/graphics.h> + #include <game/generated/gc_data.hpp> #include <game/client/render.hpp> #include <game/gamecore.hpp> @@ -124,31 +126,31 @@ void PARTICLES::on_render() void PARTICLES::render_group(int group) { - gfx_blend_normal(); + Graphics()->BlendNormal(); //gfx_blend_additive(); - gfx_texture_set(data->images[IMAGE_PARTICLES].id); - gfx_quads_begin(); + Graphics()->TextureSet(data->images[IMAGE_PARTICLES].id); + Graphics()->QuadsBegin(); int i = first_part[group]; while(i != -1) { - select_sprite(particles[i].spr); + RenderTools()->select_sprite(particles[i].spr); float a = particles[i].life / particles[i].life_span; vec2 p = particles[i].pos; float size = mix(particles[i].start_size, particles[i].end_size, a); - gfx_quads_setrotation(particles[i].rot); + Graphics()->QuadsSetRotation(particles[i].rot); - gfx_setcolor( + Graphics()->SetColor( particles[i].color.r, particles[i].color.g, particles[i].color.b, particles[i].color.a); // pow(a, 0.75f) * - gfx_quads_draw(p.x, p.y, size, size); + Graphics()->QuadsDraw(p.x, p.y, size, size); i = particles[i].next_part; } - gfx_quads_end(); - gfx_blend_normal(); + Graphics()->QuadsEnd(); + Graphics()->BlendNormal(); } diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 6d6bcc37..e1fee3e8 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -1,4 +1,5 @@ #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> @@ -40,23 +41,23 @@ void PLAYERS::render_hand(TEE_RENDER_INFO *info, vec2 center_pos, vec2 dir, floa hand_pos += dirx * post_rot_offset.x; hand_pos += diry * post_rot_offset.y; - //gfx_texture_set(data->images[IMAGE_CHAR_DEFAULT].id); - gfx_texture_set(info->texture); - gfx_quads_begin(); - gfx_setcolor(info->color_body.r, info->color_body.g, info->color_body.b, info->color_body.a); + //Graphics()->TextureSet(data->images[IMAGE_CHAR_DEFAULT].id); + Graphics()->TextureSet(info->texture); + Graphics()->QuadsBegin(); + Graphics()->SetColor(info->color_body.r, info->color_body.g, info->color_body.b, info->color_body.a); // two passes for (int i = 0; i < 2; i++) { bool outline = i == 0; - select_sprite(outline?SPRITE_TEE_HAND_OUTLINE:SPRITE_TEE_HAND, 0, 0, 0); - gfx_quads_setrotation(angle); - gfx_quads_draw(hand_pos.x, hand_pos.y, 2*basesize, 2*basesize); + RenderTools()->select_sprite(outline?SPRITE_TEE_HAND_OUTLINE:SPRITE_TEE_HAND, 0, 0, 0); + Graphics()->QuadsSetRotation(angle); + Graphics()->QuadsDraw(hand_pos.x, hand_pos.y, 2*basesize, 2*basesize); } - gfx_quads_setrotation(0); - gfx_quads_end(); + Graphics()->QuadsSetRotation(0); + Graphics()->QuadsEnd(); } inline float normalize_angular(float f) @@ -237,9 +238,9 @@ void PLAYERS::render_player( // draw hook if (prev.hook_state>0 && player.hook_state>0) { - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); - //gfx_quads_begin(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); + //Graphics()->QuadsBegin(); vec2 pos = position; vec2 hook_pos; @@ -260,36 +261,36 @@ void PLAYERS::render_player( float d = distance(pos, hook_pos); vec2 dir = normalize(pos-hook_pos); - gfx_quads_setrotation(get_angle(dir)+pi); + Graphics()->QuadsSetRotation(get_angle(dir)+pi); // render head - select_sprite(SPRITE_HOOK_HEAD); - gfx_quads_draw(hook_pos.x, hook_pos.y, 24,16); + RenderTools()->select_sprite(SPRITE_HOOK_HEAD); + Graphics()->QuadsDraw(hook_pos.x, hook_pos.y, 24,16); // render chain - select_sprite(SPRITE_HOOK_CHAIN); + RenderTools()->select_sprite(SPRITE_HOOK_CHAIN); int i = 0; for(float f = 24; f < d && i < 1024; f += 24, i++) { vec2 p = hook_pos + dir*f; - gfx_quads_draw(p.x, p.y,24,16); + Graphics()->QuadsDraw(p.x, p.y,24,16); } - gfx_quads_setrotation(0); - gfx_quads_end(); + Graphics()->QuadsSetRotation(0); + Graphics()->QuadsEnd(); render_hand(&render_info, position, normalize(hook_pos-pos), -pi/2, vec2(20, 0)); } // draw gun { - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); - gfx_quads_setrotation(state.attach.angle*pi*2+angle); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); + Graphics()->QuadsSetRotation(state.attach.angle*pi*2+angle); // normal weapons int iw = clamp(player.weapon, 0, NUM_WEAPONS-1); - select_sprite(data->weapons.id[iw].sprite_body, direction.x < 0 ? SPRITE_FLAG_FLIP_Y : 0); + RenderTools()->select_sprite(data->weapons.id[iw].sprite_body, direction.x < 0 ? SPRITE_FLAG_FLIP_Y : 0); vec2 dir = direction; float recoil = 0.0f; @@ -302,14 +303,14 @@ void PLAYERS::render_player( // if attack is under way, bash stuffs if(direction.x < 0) { - gfx_quads_setrotation(-pi/2-state.attach.angle*pi*2); + Graphics()->QuadsSetRotation(-pi/2-state.attach.angle*pi*2); p.x -= data->weapons.id[iw].offsetx; } else { - gfx_quads_setrotation(-pi/2+state.attach.angle*pi*2); + Graphics()->QuadsSetRotation(-pi/2+state.attach.angle*pi*2); } - draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); + RenderTools()->draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); } else if (player.weapon == WEAPON_NINJA) { @@ -318,16 +319,16 @@ void PLAYERS::render_player( if(direction.x < 0) { - gfx_quads_setrotation(-pi/2-state.attach.angle*pi*2); + Graphics()->QuadsSetRotation(-pi/2-state.attach.angle*pi*2); p.x -= data->weapons.id[iw].offsetx; gameclient.effects->powerupshine(p+vec2(32,0), vec2(32,12)); } else { - gfx_quads_setrotation(-pi/2+state.attach.angle*pi*2); + Graphics()->QuadsSetRotation(-pi/2+state.attach.angle*pi*2); gameclient.effects->powerupshine(p-vec2(32,0), vec2(32,12)); } - draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); + RenderTools()->draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); // HADOKEN if ((client_tick()-player.attacktick) <= (SERVER_TICK_SPEED / 6) && data->weapons.id[iw].num_sprite_muzzles) @@ -339,14 +340,14 @@ void PLAYERS::render_player( vec2 dir = vec2(player_char->x,player_char->y) - vec2(prev_char->x, prev_char->y); dir = normalize(dir); float hadokenangle = get_angle(dir); - gfx_quads_setrotation(hadokenangle); + Graphics()->QuadsSetRotation(hadokenangle); //float offsety = -data->weapons[iw].muzzleoffsety; - select_sprite(data->weapons.id[iw].sprite_muzzles[itex], 0); + RenderTools()->select_sprite(data->weapons.id[iw].sprite_muzzles[itex], 0); vec2 diry(-dir.y,dir.x); p = position; float offsetx = data->weapons.id[iw].muzzleoffsetx; p -= dir * offsetx; - draw_sprite(p.x, p.y, 160.0f); + RenderTools()->draw_sprite(p.x, p.y, 160.0f); } } } @@ -359,7 +360,7 @@ void PLAYERS::render_player( recoil = sinf(a*pi); p = position + dir * data->weapons.id[iw].offsetx - dir*recoil*10.0f; p.y += data->weapons.id[iw].offsety; - draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); + RenderTools()->draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); } if (player.weapon == WEAPON_GUN || player.weapon == WEAPON_SHOTGUN) @@ -379,18 +380,18 @@ void PLAYERS::render_player( if (alpha > 0.0f && data->weapons.id[iw].sprite_muzzles[itex]) { float offsety = -data->weapons.id[iw].muzzleoffsety; - select_sprite(data->weapons.id[iw].sprite_muzzles[itex], direction.x < 0 ? SPRITE_FLAG_FLIP_Y : 0); + RenderTools()->select_sprite(data->weapons.id[iw].sprite_muzzles[itex], direction.x < 0 ? SPRITE_FLAG_FLIP_Y : 0); if(direction.x < 0) offsety = -offsety; vec2 diry(-dir.y,dir.x); vec2 muzzlepos = p + dir * data->weapons.id[iw].muzzleoffsetx + diry * offsety; - draw_sprite(muzzlepos.x, muzzlepos.y, data->weapons.id[iw].visual_size); + RenderTools()->draw_sprite(muzzlepos.x, muzzlepos.y, data->weapons.id[iw].visual_size); } } } - gfx_quads_end(); + Graphics()->QuadsEnd(); switch (player.weapon) { @@ -408,27 +409,27 @@ void PLAYERS::render_player( TEE_RENDER_INFO ghost = render_info; ghost.color_body.a = 0.5f; ghost.color_feet.a = 0.5f; - render_tee(&state, &ghost, player.emote, direction, ghost_position); // render ghost + RenderTools()->RenderTee(&state, &ghost, player.emote, direction, ghost_position); // render ghost } render_info.size = 64.0f; // force some settings render_info.color_body.a = 1.0f; render_info.color_feet.a = 1.0f; - render_tee(&state, &render_info, player.emote, direction, position); + RenderTools()->RenderTee(&state, &render_info, player.emote, direction, position); if(player.player_state == PLAYERSTATE_CHATTING) { - gfx_texture_set(data->images[IMAGE_EMOTICONS].id); - gfx_quads_begin(); - select_sprite(SPRITE_DOTDOT); - gfx_quads_draw(position.x + 24, position.y - 40, 64,64); - gfx_quads_end(); + Graphics()->TextureSet(data->images[IMAGE_EMOTICONS].id); + Graphics()->QuadsBegin(); + RenderTools()->select_sprite(SPRITE_DOTDOT); + Graphics()->QuadsDraw(position.x + 24, position.y - 40, 64,64); + Graphics()->QuadsEnd(); } if (gameclient.clients[info.cid].emoticon_start != -1 && gameclient.clients[info.cid].emoticon_start + 2 * client_tickspeed() > client_tick()) { - gfx_texture_set(data->images[IMAGE_EMOTICONS].id); - gfx_quads_begin(); + Graphics()->TextureSet(data->images[IMAGE_EMOTICONS].id); + Graphics()->QuadsBegin(); int since_start = client_tick() - gameclient.clients[info.cid].emoticon_start; int from_end = gameclient.clients[info.cid].emoticon_start + 2 * client_tickspeed() - client_tick(); @@ -448,13 +449,13 @@ void PLAYERS::render_player( float wiggle_angle = sin(5*wiggle); - gfx_quads_setrotation(pi/6*wiggle_angle); + Graphics()->QuadsSetRotation(pi/6*wiggle_angle); - gfx_setcolor(1.0f,1.0f,1.0f,a); + Graphics()->SetColor(1.0f,1.0f,1.0f,a); // client_datas::emoticon is an offset from the first emoticon - select_sprite(SPRITE_OOP + gameclient.clients[info.cid].emoticon); - gfx_quads_draw(position.x, position.y - 23 - 32*h, 64, 64*h); - gfx_quads_end(); + RenderTools()->select_sprite(SPRITE_OOP + gameclient.clients[info.cid].emoticon); + Graphics()->QuadsDraw(position.x, position.y - 23 - 32*h, 64, 64*h); + Graphics()->QuadsEnd(); } } diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 2978eff9..e8db1aed 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -1,5 +1,6 @@ #include <string.h> #include <engine/e_client_interface.h> +#include <engine/client/graphics.h> #include <game/generated/g_protocol.hpp> #include <game/generated/gc_data.hpp> #include <game/client/gameclient.hpp> @@ -33,12 +34,12 @@ void SCOREBOARD::render_goals(float x, float y, float w) { float h = 50.0f; - gfx_blend_normal(); - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.5f); - draw_round_rect(x-10.f, y-10.f, w, h, 10.0f); - gfx_quads_end(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.5f); + RenderTools()->draw_round_rect(x-10.f, y-10.f, w, h, 10.0f); + Graphics()->QuadsEnd(); // render goals //y = ystart+h-54; @@ -76,12 +77,12 @@ void SCOREBOARD::render_spectators(float x, float y, float w) str_format(buffer, sizeof(buffer), "%s: ", localize("Spectators")); - gfx_blend_normal(); - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.5f); - draw_round_rect(x-10.f, y-10.f, w, h, 10.0f); - gfx_quads_end(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.5f); + RenderTools()->draw_round_rect(x-10.f, y-10.f, w, h, 10.0f); + Graphics()->QuadsEnd(); for(int i = 0; i < snap_num_items(SNAP_CURRENT); i++) { @@ -109,12 +110,12 @@ void SCOREBOARD::render_scoreboard(float x, float y, float w, int team, const ch //float ystart = y; float h = 750.0f; - gfx_blend_normal(); - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.5f); - draw_round_rect(x-10.f, y-10.f, w, h, 17.0f); - gfx_quads_end(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.5f); + RenderTools()->draw_round_rect(x-10.f, y-10.f, w, h, 17.0f); + Graphics()->QuadsEnd(); // render title if(!title) @@ -210,11 +211,11 @@ void SCOREBOARD::render_scoreboard(float x, float y, float w, int team, const ch if(info->local) { // background so it's easy to find the local player - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(1,1,1,0.25f); - draw_round_rect(x, y, w-20, line_height*0.95f, 17.0f); - gfx_quads_end(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1,1,1,0.25f); + RenderTools()->draw_round_rect(x, y, w-20, line_height*0.95f, 17.0f); + Graphics()->QuadsEnd(); } str_format(buf, sizeof(buf), "%4d", info->score); @@ -230,21 +231,21 @@ void SCOREBOARD::render_scoreboard(float x, float y, float w, int team, const ch if((gameclient.snap.flags[0] && gameclient.snap.flags[0]->carried_by == info->cid) || (gameclient.snap.flags[1] && gameclient.snap.flags[1]->carried_by == info->cid)) { - gfx_blend_normal(); - gfx_texture_set(data->images[IMAGE_GAME].id); - gfx_quads_begin(); + Graphics()->BlendNormal(); + Graphics()->TextureSet(data->images[IMAGE_GAME].id); + Graphics()->QuadsBegin(); - if(info->team == 0) select_sprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); - else select_sprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); + if(info->team == 0) RenderTools()->select_sprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); + else RenderTools()->select_sprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); float size = 64.0f; - gfx_quads_drawTL(x+55, y-15, size/2, size); - gfx_quads_end(); + Graphics()->QuadsDrawTL(x+55, y-15, size/2, size); + Graphics()->QuadsEnd(); } TEE_RENDER_INFO teeinfo = gameclient.clients[info->cid].render_info; teeinfo.size *= tee_sizemod; - render_tee(ANIMSTATE::get_idle(), &teeinfo, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28+tee_offset)); + RenderTools()->RenderTee(ANIMSTATE::get_idle(), &teeinfo, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28+tee_offset)); y += line_height; @@ -278,10 +279,10 @@ void SCOREBOARD::on_render() gameclient.motd->clear(); - float width = 400*3.0f*gfx_screenaspect(); + float width = 400*3.0f*Graphics()->ScreenAspect(); float height = 400*3.0f; - gfx_mapscreen(0, 0, width, height); + Graphics()->MapScreen(0, 0, width, height); float w = 650.0f; diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index 451a77f3..ad3607a1 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -6,12 +6,10 @@ #include <base/system.h> #include <base/math.hpp> +#include <engine/client/graphics.h> #include <engine/e_client_interface.h> -extern "C" -{ - #include <engine/e_engine.h> -} +#include <engine/e_engine.h> #include "skins.hpp" @@ -32,13 +30,13 @@ void SKINS::skinscan(const char *name, int is_dir, void *user) char buf[512]; str_format(buf, sizeof(buf), "skins/%s", name); IMAGE_INFO info; - if(!gfx_load_png(&info, buf)) + if(!self->Graphics()->LoadPNG(&info, buf)) { dbg_msg("game", "failed to load skin from %s", name); return; } - self->skins[self->num_skins].org_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data, info.format, 0); + self->skins[self->num_skins].org_texture = self->Graphics()->LoadTextureRaw(info.width, info.height, info.format, info.data, info.format, 0); int body_size = 96; // body size unsigned char *d = (unsigned char *)info.data; @@ -111,7 +109,7 @@ void SKINS::skinscan(const char *name, int is_dir, void *user) } } - self->skins[self->num_skins].color_texture = gfx_load_texture_raw(info.width, info.height, info.format, info.data, info.format, 0); + self->skins[self->num_skins].color_texture = self->Graphics()->LoadTextureRaw(info.width, info.height, info.format, info.data, info.format, 0); mem_free(info.data); // set skin data diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index 190ba224..dcf5c954 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -143,30 +143,30 @@ void VOTING::on_render() } -void VOTING::render_bars(RECT bars, bool text) +void VOTING::render_bars(CUIRect bars, bool text) { - ui_draw_rect(&bars, vec4(0.8f,0.8f,0.8f,0.5f), CORNER_ALL, bars.h/3); + RenderTools()->DrawUIRect(&bars, vec4(0.8f,0.8f,0.8f,0.5f), CUI::CORNER_ALL, bars.h/3); - RECT splitter = bars; + CUIRect splitter = bars; splitter.x = splitter.x+splitter.w/2; splitter.w = splitter.h/2.0f; splitter.x -= splitter.w/2; - ui_draw_rect(&splitter, vec4(0.4f,0.4f,0.4f,0.5f), CORNER_ALL, splitter.h/4); + RenderTools()->DrawUIRect(&splitter, vec4(0.4f,0.4f,0.4f,0.5f), CUI::CORNER_ALL, splitter.h/4); if(total) { - RECT pass_area = bars; + CUIRect pass_area = bars; if(yes) { - RECT yes_area = bars; + CUIRect yes_area = bars; yes_area.w *= yes/(float)total; - ui_draw_rect(&yes_area, vec4(0.2f,0.9f,0.2f,0.85f), CORNER_ALL, bars.h/3); + RenderTools()->DrawUIRect(&yes_area, vec4(0.2f,0.9f,0.2f,0.85f), CUI::CORNER_ALL, bars.h/3); if(text) { char buf[256]; str_format(buf, sizeof(buf), "%d", yes); - ui_do_label(&yes_area, buf, bars.h*0.75f, 0); + UI()->DoLabel(&yes_area, buf, bars.h*0.75f, 0); } pass_area.x += yes_area.w; @@ -175,16 +175,16 @@ void VOTING::render_bars(RECT bars, bool text) if(no) { - RECT no_area = bars; + CUIRect no_area = bars; no_area.w *= no/(float)total; no_area.x = (bars.x + bars.w)-no_area.w; - ui_draw_rect(&no_area, vec4(0.9f,0.2f,0.2f,0.85f), CORNER_ALL, bars.h/3); + RenderTools()->DrawUIRect(&no_area, vec4(0.9f,0.2f,0.2f,0.85f), CUI::CORNER_ALL, bars.h/3); if(text) { char buf[256]; str_format(buf, sizeof(buf), "%d", no); - ui_do_label(&no_area, buf, bars.h*0.75f, 0); + UI()->DoLabel(&no_area, buf, bars.h*0.75f, 0); } pass_area.w -= no_area.w; @@ -194,7 +194,7 @@ void VOTING::render_bars(RECT bars, bool text) { char buf[256]; str_format(buf, sizeof(buf), "%d", pass); - ui_do_label(&pass_area, buf, bars.h*0.75f, 0); + UI()->DoLabel(&pass_area, buf, bars.h*0.75f, 0); } } } diff --git a/src/game/client/components/voting.hpp b/src/game/client/components/voting.hpp index 3341edea..e04e1840 100644 --- a/src/game/client/components/voting.hpp +++ b/src/game/client/components/voting.hpp @@ -1,10 +1,6 @@ #include <game/client/component.hpp> #include <game/client/ui.hpp> - -extern "C" -{ - #include <engine/e_memheap.h> -} +#include <engine/e_memheap.h> class VOTING : public COMPONENT { @@ -38,7 +34,7 @@ public: virtual void on_message(int msgtype, void *rawmsg); virtual void on_render(); - void render_bars(RECT bars, bool text); + void render_bars(CUIRect bars, bool text); void callvote_kick(int client_id); void callvote_option(int option); |