initial gui for remote players lobby
[carveJwlIkooP6JGAAIwe30JlM.git] / player_remote.c
index fac5ea7dbf8b6c94398b8fdd442c87ee063224e6..6358daa94afe2df6fa3c992a6571a714c6d531bb 100644 (file)
@@ -682,3 +682,75 @@ static void remote_sfx_pre_update(void){
       }
    }
 }
+
+enum remote_player_gui_type {
+   k_remote_player_gui_type_stranger,
+   k_remote_player_gui_type_you,
+   k_remote_player_gui_type_friend
+};
+
+static void remote_player_gui_info( ui_rect box, 
+                                    const char *username,
+                                    const char *activity, 
+                                    enum remote_player_gui_type type,
+                                    int in_world ){
+
+   f32 opacity = in_world? 0.6f: 0.3f;
+
+   if( type == k_remote_player_gui_type_you )
+      ui_fill( box, ui_opacity( 0xff555555, opacity ) );
+   else
+      ui_fill( box, ui_opacity( 0xff000000, opacity ) );
+
+   if( type == k_remote_player_gui_type_friend )
+      ui_outline( box, -1, ui_opacity( 0xff00c4f0, opacity ), 0 );
+
+   ui_rect top, bottom;
+   ui_split_ratio( box, k_ui_axis_h, 0.6666f, 1, top, bottom );
+
+   u32 fg = ui_colour( in_world? k_ui_fg: k_ui_fg+4 );
+
+   vg_ui.font = &vg_ui_font_big;
+   ui_text( top, username, 1, k_ui_align_middle_center, fg );
+   vg_ui.font = &vg_ui_font_small;
+
+   ui_text( bottom, activity, 1, k_ui_align_middle_center, fg );
+}
+
+static void remote_players_imgui(void){
+   /* TODO: or if respawning, override show this and disable input
+    *       if in menu dont render. */
+
+   if( button_down(k_srbind_lobby) )
+      netplayers.view_lobby ^= 0x1;
+
+   vg_slewf( &netplayers.fview_lobby, netplayers.view_lobby, 
+             vg.time_frame_delta / 0.5f );
+
+   ui_px y = 50, width = 200, height = 42, gap = 2,
+         x = vg.window_x - ((f32)width*netplayers.fview_lobby);
+
+   int type = vg.time,
+       in_world = vg.time / 3.0;
+
+
+   vg_ui.font = &vg_ui_font_big;
+   ui_text( (ui_rect){ x, 0, width, height }, 
+            "In World", 1, k_ui_align_middle_center, 0 );
+   vg_ui.font = &vg_ui_font_small;
+
+
+   ui_rect us = { x, y, width, height };
+   remote_player_gui_info( us, steam_username_at_startup, "1300 meters away",
+                           type % 3, in_world % 2 );
+   y += height + gap;
+
+   for( u32 i=0; i<NETWORK_MAX_PLAYERS; i ++ ){
+      struct network_player *player = &netplayers.list[i];
+      if( !player->active || !player->isfriend ) continue;
+      
+      ui_rect box = { x, y, width, height };
+      remote_player_gui_info( box, player->username, "", 0, 0 );
+      y += height + gap;
+   }
+}