a mess but stable
[carveJwlIkooP6JGAAIwe30JlM.git] / gui.h
diff --git a/gui.h b/gui.h
index c60c51be00b975e6f001509b3bb01b8faf4f6f9f..3823c152156ed419e51ac68b64581f1a820cb7a0 100644 (file)
--- a/gui.h
+++ b/gui.h
@@ -2,7 +2,14 @@
 #include "font.h"
 #include "input.h"
 #include "player.h"
-#include "vg/vg_imgui.h"
+#include "vg/vg_engine.h"
+#include "vg/vg_ui/imgui.h"
+
+#define GUI_COL_DARK   ui_opacity( 0x00000000, 0.7f )
+#define GUI_COL_NORM   ui_opacity( 0x00101010, 0.7f )
+#define GUI_COL_ACTIVE ui_opacity( 0x00444444, 0.7f )
+#define GUI_COL_CLICK  ui_opacity( 0x00858585, 0.7f )
+#define GUI_COL_HI     ui_opacity( 0x00ffffff, 0.8f )
 
 enum gui_icon {
    k_gui_icon_tick    = 0,
@@ -19,6 +26,8 @@ enum gui_icon {
    k_gui_icon_rift_run_gold,
    k_gui_icon_rift_run_silver,
    k_gui_icon_glider,
+   k_gui_icon_spawn,
+   k_gui_icon_spawn_select,
 
    k_gui_icon_count,
 };
@@ -42,7 +51,7 @@ struct{
       v4f colour;
       int colour_changed;
    }
-   icon_draw_buffer[32];
+   icon_draw_buffer[64];
    u32 icon_draw_count;
    v4f cur_icon_colour;
    int colour_changed;
@@ -131,7 +140,7 @@ static void gui_render_icons(void)
    gui.icon_draw_count = 0;
 }
 
-static void gui_draw(void)
+static void gui_draw( ui_context *ctx )
 {
    if( gui.active_positional_helper && 
          (v3_dist2(localplayer.rb.co,gui.trick_co) > 2.0f) )
@@ -142,16 +151,11 @@ static void gui_draw(void)
 
    gui.factive = vg_lerpf( gui.factive, gui.helper_count?1.0f:0.0f,
                            vg.time_frame_delta*2.0f );
-
-   ui_font_face( &vgf_default_title );
-   ui_px height = vg_ui.font->ch + 16;
+   
+   ctx->font = &vgf_default_title;
+   ui_px height = ctx->font->ch + 16;
    ui_rect lwr = { 0, vg.window_y - height, vg.window_x, height };
 
-   if( gui.factive > 0.01f )
-   {
-      //ui_fill( lwr, ui_opacity( 0xff000000, gui.factive*0.8f ) );
-   }
-
    ui_px x = 0;
    for( u32 i=0; i<gui.helper_count; i++ )
    {
@@ -168,32 +172,33 @@ static void gui_draw(void)
       f32 opacity = 0.4f;
       if( helper->greyed ) 
       {
-         fg = ui_colour(k_ui_fg+2);
+         fg = ui_colour(ctx, k_ui_fg+2);
          opacity = 0.1f;
       }
 
-      struct ui_vert *bg = ui_fill( box, ui_opacity( 0x00000000, opacity ) );
+      struct ui_vert *bg = ui_fill( ctx, box, 
+                                    ui_opacity( GUI_COL_DARK, opacity ) );
 
       u32 w;
       box[0] += 16;
-      w = ui_text( box, buf, 1, k_ui_align_middle_left, fg );
-      w *= vg_ui.font->sx;
+      w = ui_text( ctx, box, buf, 1, k_ui_align_middle_left, fg );
+      w *= ctx->font->sx;
       bg[1].co[0] = x + w + 32;
       bg[2].co[0] = x + w + 32;
       x += w + 32;
 
       box[0] = x;
-      bg = ui_fill( box, ui_opacity( 0x00101010, opacity*0.7f ) );
+      bg = ui_fill( ctx, box, ui_opacity( GUI_COL_NORM, opacity*0.7f ) );
       box[0] += 8;
-      w = ui_text( box, helper->text, 1, k_ui_align_middle_left, fg );
-      w *= vg_ui.font->sx;
+      w = ui_text( ctx, box, helper->text, 1, k_ui_align_middle_left, fg );
+      w *= ctx->font->sx;
       bg[1].co[0] = box[0] + w + 16;
       bg[2].co[0] = box[0] + w + 16;
       x += w + 32;
    }
 
-   vg_ui.frosting = gui.factive*0.015f;
-   ui_flush( k_ui_shader_colour, vg.window_x, vg.window_y );
+   vg_ui.frosting = gui.factive*0.015f; 
+   ui_flush( ctx, k_ui_shader_colour, NULL );
    vg_ui.frosting = 0.0f;
 
 
@@ -204,24 +209,26 @@ static void gui_draw(void)
           o = 1.0f-t*t*(2.0f-t);
 
       ui_rect box = { 0, (vg.window_y*2)/3 - height/2, vg.window_x, height };
-      ui_fill( box, ui_opacity( 0x00101010, 0.5f ) );
-      ui_text( box, gui.location, 1, k_ui_align_middle_center, 0 );
+      ui_fill( ctx, box, ui_opacity( GUI_COL_NORM, 0.5f ) );
+      ui_text( ctx, box, gui.location, 1, k_ui_align_middle_center, 0 );
 
       vg_ui.colour[3] = o;
-      ui_flush( k_ui_shader_colour, vg.window_x, vg.window_y );
+      ui_flush( ctx, k_ui_shader_colour, NULL );
    }
 
    vg_ui.colour[3] = 1.0f;
-   ui_font_face( &vgf_default_small );
+   ctx->font = &vgf_default_small;
 }
 
 static int gui_location_print_ccmd( int argc, const char *argv[] )
 {
-   if( argc > 0 ){
+   if( argc > 0 )
+   {
       char new_loc[64];
       vg_str str;
       vg_strnull( &str, new_loc, 64 );
-      for( int i=0; i<argc; i++ ){
+      for( int i=0; i<argc; i++ )
+      {
          vg_strcat( &str, argv[i] );
          vg_strcat( &str, " " );
       }
@@ -232,8 +239,10 @@ static int gui_location_print_ccmd( int argc, const char *argv[] )
    return 0;
 }
 
-static int gui_showtrick_ccmd( int argc, const char *argv[] ){
-   if( argc == 1 ){
+static int gui_showtrick_ccmd( int argc, const char *argv[] )
+{
+   if( argc == 1 )
+   {
       gui_helper_clear();
       vg_str text;
 
@@ -272,7 +281,8 @@ static int gui_showtrick_ccmd( int argc, const char *argv[] ){
    return 1;
 }
 
-static void gui_draw_icon( enum gui_icon icon, v2f co, f32 size ){
+static void gui_draw_icon( enum gui_icon icon, v2f co, f32 size )
+{
    if( gui.icon_draw_count == vg_list_size(gui.icon_draw_buffer) )
       return;
 
@@ -305,7 +315,8 @@ static mdl_submesh *gui_find_icon( const char *name ){
    return NULL;
 }
 
-static void gui_init(void){
+static void gui_init(void)
+{
    font3d_load( &gui.font, "models/rs_font.mdl", vg_mem.rtmemory );
    vg_console_reg_cmd( "gui_location", gui_location_print_ccmd, NULL );
    vg_console_reg_cmd( "showtrick", gui_showtrick_ccmd, NULL );
@@ -327,6 +338,8 @@ static void gui_init(void){
    gui.icons[ k_gui_icon_friend ] = gui_find_icon( "icon_friend" );
    gui.icons[ k_gui_icon_player ] = gui_find_icon( "icon_player" );
    gui.icons[ k_gui_icon_glider ] = gui_find_icon( "icon_glider" );
+   gui.icons[ k_gui_icon_spawn ] = gui_find_icon( "icon_spawn" );
+   gui.icons[ k_gui_icon_spawn_select ] = gui_find_icon( "icon_spawn_select" );
    gui.icons[ k_gui_icon_rift_run_gold ] =
       gui_find_icon("icon_rift_run_medal_gold");
    gui.icons[ k_gui_icon_rift_run_silver]=