diff options
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/gc_menu.cpp | 9 | ||||
| -rw-r--r-- | src/game/client/gc_menu.h | 13 | ||||
| -rw-r--r-- | src/game/client/gc_render.cpp | 19 | ||||
| -rw-r--r-- | src/game/client/gc_render.h | 5 | ||||
| -rw-r--r-- | src/game/client/gc_render_map.cpp | 104 |
5 files changed, 105 insertions, 45 deletions
diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp index c82f1f6f..09c55d9c 100644 --- a/src/game/client/gc_menu.cpp +++ b/src/game/client/gc_menu.cpp @@ -70,15 +70,6 @@ enum PAGE_SYSTEM, }; -static void ui_draw_rect(const RECT *r, vec4 color, int corners, float rounding) -{ - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(color.r, color.g, color.b, color.a); - draw_round_rect_ext(r->x,r->y,r->w,r->h,rounding*ui_scale(), corners); - gfx_quads_end(); -} - static void ui_draw_browse_icon(int what, const RECT *r) { gfx_texture_set(data->images[IMAGE_BROWSEICONS].id); diff --git a/src/game/client/gc_menu.h b/src/game/client/gc_menu.h index bd6352de..ba12894c 100644 --- a/src/game/client/gc_menu.h +++ b/src/game/client/gc_menu.h @@ -1,16 +1,5 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #ifndef __MENU_H #define __MENU_H -/* -void draw_image_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra); -void draw_single_part_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra); -void draw_menu_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra); -void draw_teewars_button(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra); -int ui_do_key_reader(void *id, float x, float y, float w, float h, int key); -int ui_do_combo_box(void *id, float x, float y, float w, char *lines, int line_count, int selected_index); -int ui_do_edit_box(void *id, float x, float y, float w, float h, char *str, int str_size); -int ui_do_check_box(void *id, float x, float y, float w, float h, int value); -int do_scroll_bar_horiz(void *id, float x, float y, float width, int steps, int last_index); -int do_scroll_bar_vert(void *id, float x, float y, float height, int steps, int last_index); -*/ + #endif diff --git a/src/game/client/gc_render.cpp b/src/game/client/gc_render.cpp index 9f55ec5f..1999cb0a 100644 --- a/src/game/client/gc_render.cpp +++ b/src/game/client/gc_render.cpp @@ -125,6 +125,15 @@ void draw_round_rect(float x, float y, float w, float h, float r) draw_round_rect_ext(x,y,w,h,r,0xf); } +void ui_draw_rect(const RECT *r, vec4 color, int corners, float rounding) +{ + gfx_texture_set(-1); + gfx_quads_begin(); + gfx_setcolor(color.r, color.g, color.b, color.a); + draw_round_rect_ext(r->x,r->y,r->w,r->h,rounding*ui_scale(), corners); + gfx_quads_end(); +} + void render_tee(animstate *anim, tee_render_info *info, int emote, vec2 dir, vec2 pos) { vec2 direction = dir; @@ -246,6 +255,14 @@ static void mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *gr gfx_mapscreen(points[0], points[1], points[2], points[3]); } +static void envelope_eval(float time_offset, int env, float *channels) +{ + channels[0] = 0; + channels[1] = 0; + channels[2] = 0; + channels[3] = 0; +} + void render_layers(float center_x, float center_y, int pass) { bool passed_gamelayer = false; @@ -299,7 +316,7 @@ void render_layers(float center_x, float center_y, int pass) else gfx_texture_set(img_get(qlayer->image)); QUAD *quads = (QUAD *)map_get_data_swapped(qlayer->data); - render_quads(quads, qlayer->num_quads); + render_quads(quads, qlayer->num_quads, envelope_eval); } } } diff --git a/src/game/client/gc_render.h b/src/game/client/gc_render.h index feb04641..5294b89e 100644 --- a/src/game/client/gc_render.h +++ b/src/game/client/gc_render.h @@ -4,6 +4,7 @@ #include "../g_vmath.h" #include "../g_mapitems.h" +#include "gc_ui.h" struct tee_render_info { @@ -30,6 +31,7 @@ void draw_sprite(float x, float y, float size); // rects void draw_round_rect(float x, float y, float w, float h, float r); void draw_round_rect_ext(float x, float y, float w, float h, float r, int corners); +void ui_draw_rect(const RECT *r, vec4 color, int corners, float rounding); // larger rendering methods void menu_render(); @@ -49,7 +51,8 @@ void render_player( const struct obj_player_info *prev_info, const struct obj_player_info *player_info); // map render methods (gc_render_map.cpp) -void render_quads(QUAD *quads, int num_quads); +void render_eval_envelope(ENVPOINT *points, int num_points, int channels, float time, float *result); +void render_quads(QUAD *quads, int num_quads, void (*eval)(float time_offset, int env, float *channels)); void render_tilemap(TILE *tiles, int w, int h, float scale, int flags); // helpers diff --git a/src/game/client/gc_render_map.cpp b/src/game/client/gc_render_map.cpp index 4345aa03..931fdd18 100644 --- a/src/game/client/gc_render_map.cpp +++ b/src/game/client/gc_render_map.cpp @@ -3,6 +3,70 @@ #include "../g_math.h" #include "gc_client.h" +void render_eval_envelope(ENVPOINT *points, int num_points, int channels, float time, float *result) +{ + if(num_points == 0) + { + result[0] = 0; + result[1] = 0; + result[2] = 0; + result[3] = 0; + return; + } + + if(num_points == 1) + { + result[0] = fx2f(points[0].values[0]); + result[1] = fx2f(points[0].values[1]); + result[2] = fx2f(points[0].values[2]); + result[3] = fx2f(points[0].values[3]); + return; + } + + time = fmod(time, points[num_points-1].time/1000.0f)*1000.0f; + for(int i = 0; i < num_points-1; i++) + { + if(time >= points[i].time && time <= points[i+1].time) + { + float delta = points[i+1].time-points[i].time; + float a = (time-points[i].time)/delta; + + + if(points[i].curvetype == CURVETYPE_SMOOTH) + a = -2*a*a*a + 3*a*a; // second hermite basis + else if(points[i].curvetype == CURVETYPE_SLOW) + a = a*a*a; + else if(points[i].curvetype == CURVETYPE_FAST) + { + a = 1-a; + a = 1-a*a*a; + } + else if (points[i].curvetype == CURVETYPE_STEP) + a = 0; + else + { + // linear + } + + for(int c = 0; c < channels; c++) + { + float v0 = fx2f(points[i].values[c]); + float v1 = fx2f(points[i+1].values[c]); + result[c] = v0 + (v1-v0) * a; + } + + return; + } + } + + result[0] = fx2f(points[num_points-1].values[0]); + result[1] = fx2f(points[num_points-1].values[1]); + result[2] = fx2f(points[num_points-1].values[2]); + result[3] = fx2f(points[num_points-1].values[3]); + return; +} + + static void rotate(POINT *center, POINT *point, float rotation) { int x = point->x - center->x; @@ -11,7 +75,7 @@ static void rotate(POINT *center, POINT *point, float rotation) point->y = (int)(x * sinf(rotation) + y * cosf(rotation) + center->y); } -void render_quads(QUAD *quads, int num_quads) +void render_quads(QUAD *quads, int num_quads, void (*eval)(float time_offset, int env, float *channels)) { gfx_quads_begin(); float conv = 1/255.0f; @@ -31,29 +95,25 @@ void render_quads(QUAD *quads, int num_quads) float offset_y = 0; float rot = 0; - /* // TODO: fix this - if(editor.animate) + if(q->pos_env >= 0) { - if(q->pos_env >= 0 && q->pos_env < editor.map.envelopes.len()) - { - ENVELOPE *e = editor.map.envelopes[q->pos_env]; - float t = editor.animate_time+q->pos_env_offset/1000.0f; - offset_x = e->eval(t, 0); - offset_y = e->eval(t, 1); - rot = e->eval(t, 2); - } - - if(q->color_env >= 0 && q->color_env < editor.map.envelopes.len()) - { - ENVELOPE *e = editor.map.envelopes[q->color_env]; - float t = editor.animate_time+q->color_env_offset/1000.0f; - r = e->eval(t, 0); - g = e->eval(t, 1); - b = e->eval(t, 2); - a = e->eval(t, 3); - } - }*/ + float channels[4]; + eval(q->pos_env_offset/1000.0f, q->pos_env, channels); + offset_x = channels[0]; + offset_y = channels[1]; + rot = channels[2]; + } + + if(q->color_env >= 0) + { + float channels[4]; + eval(q->color_env_offset/1000.0f, q->color_env, channels); + r = channels[0]; + g = channels[1]; + b = channels[2]; + a = channels[3]; + } gfx_setcolorvertex(0, q->colors[0].r*conv*r, q->colors[0].g*conv*g, q->colors[0].b*conv*b, q->colors[0].a*conv*a); gfx_setcolorvertex(1, q->colors[1].r*conv*r, q->colors[1].g*conv*g, q->colors[1].b*conv*b, q->colors[1].a*conv*a); |