dont remember
authorhgn <hgodden00@gmail.com>
Wed, 12 Oct 2022 20:25:14 +0000 (21:25 +0100)
committerhgn <hgodden00@gmail.com>
Wed, 12 Oct 2022 20:25:14 +0000 (21:25 +0100)
16 files changed:
common.h
main.c
models_src/mp_dev.mdl
network.h
steam.h
textures_src/cement512.png [deleted file]
textures_src/graffitibox.png
textures_src/grid.png [deleted file]
textures_src/grid_terrain.png [deleted file]
textures_src/norway_foliage.png [deleted file]
textures_src/norwey.png [deleted file]
textures_src/road.png [deleted file]
textures_src/sky.png [deleted file]
textures_src/subworld.png [deleted file]
textures_src/water.png [deleted file]
vg_config.h

index a36dc0a2460528ff70aad8c2fb1d9d7da0d9fd3e..0abe4469fd27b97d2107de2ee54834f289b3d9a6 100644 (file)
--- a/common.h
+++ b/common.h
@@ -9,6 +9,7 @@
 #define VG_3D
 #define VG_FRAMEBUFFER_RESIZE 1
 #include "vg/vg.h"
 #define VG_3D
 #define VG_FRAMEBUFFER_RESIZE 1
 #include "vg/vg.h"
+#include "anyascii/anyascii.h"
 
 typedef struct ray_hit ray_hit;
 struct ray_hit
 
 typedef struct ray_hit ray_hit;
 struct ray_hit
@@ -20,4 +21,69 @@ struct ray_hit
 
 static int network_scores_updated = 0;
 
 
 static int network_scores_updated = 0;
 
+static u32 utf8_byte0_byte_count( u8 char0 )
+{
+   for( u32 k=2; k<4; k++ )
+   {
+      if( !(char0 & (0x80 >> k)) )
+         return k;
+   }
+
+   return 0;
+}
+
+static void str_utf8_collapse( const char *str, char *buf, u32 length )
+{
+   if( length == 0 )
+   {
+      strncpy( buf, "User", length );
+      return;
+   }
+
+   u8 *ustr = (u8 *)str;
+   u32 utf32_code = 0x00000000;
+   u32 i=0, j=0, utf32_byte_ct=0;
+
+   for(;i < length-1;)
+   {
+      if( ustr[i] == 0x00 )
+         break;
+      
+      if( ustr[i] & 0x80 )
+      {
+         if( utf32_byte_ct )
+         {
+            utf32_byte_ct --;
+            utf32_code |= (ustr[i] & 0x3F) << (utf32_byte_ct*6);
+
+            if( !utf32_byte_ct )
+            {
+               const char *match;
+               size_t chars = anyascii( utf32_code, &match );
+
+               for( u32 k=0; k<VG_MIN(chars, length-1-j); k++ )
+               {
+                  buf[ j++ ] = (u8)match[k];
+               }
+            }
+         }
+         else
+         {
+            utf32_byte_ct = utf8_byte0_byte_count( ustr[i] )-1;
+            utf32_code = ustr[i] & (0x3F >> utf32_byte_ct);
+            utf32_code <<= utf32_byte_ct*6;
+         }
+      }
+      else
+      {
+         utf32_byte_ct = 0x00;
+         buf[j ++] = str[i];
+      }
+
+      i++;
+   }
+
+   buf[j] = 0x00;
+}
+
 #endif /* COMMON_H */
 #endif /* COMMON_H */
diff --git a/main.c b/main.c
index 3cee76a8ce99fb5ecd6e0275a3fecff3cbf5e578..6e61fa25cbf6b5f259f08c116270b84f2bed491c 100644 (file)
--- a/main.c
+++ b/main.c
 #include "audio.h"
 #include "world.h"
 #include "player.h"
 #include "audio.h"
 #include "world.h"
 #include "player.h"
+#include "network.h"
 
 
-static int cl_ui = 1;
+static int cl_ui     = 1,
+           cl_menu   = 0;
 
 int main( int argc, char *argv[] )
 
 int main( int argc, char *argv[] )
-{ 
+{
    vg_enter( argc, argv, "Voyager Game Engine" ); 
 }
 
    vg_enter( argc, argv, "Voyager Game Engine" ); 
 }
 
@@ -109,6 +111,11 @@ void vg_update( int loaded )
       player_update_pre();
       world_update( player.phys.rb.co );
    }
       player_update_pre();
       world_update( player.phys.rb.co );
    }
+
+   if( vg_get_button_down( "menu" ) )
+   {
+      cl_menu = !cl_menu;
+   }
 }
 
 static void vg_update_fixed( int loaded )
 }
 
 static void vg_update_fixed( int loaded )
@@ -232,6 +239,39 @@ void vg_render(void)
 
 void vg_ui(void)
 {
 
 void vg_ui(void)
 {
+   if( cl_menu )
+   {
+      ui_rect menu =
+      {
+         vg.window_x / 2 - 150,
+         vg.window_y / 2 - 50,
+         300,
+         130
+      };
+
+      ui_fill_rect( &ui_global_ctx, menu, 0xa0000000 );
+
+      ui_text( &ui_global_ctx, (ui_rect){ menu[0]+menu[2]/2,menu[1]+6, 0, 0 },
+                               steam_username_at_startup, 
+                               1, k_text_align_center );
+      menu[1] += 24;
+      menu[3] -= 30;
+
+      ui_rect_pad( menu, 8 );
+      ui_fill_rect( &ui_global_ctx, menu, 0x90ffffff );
+      ui_rect_pad( menu, 2 );
+      ui_fill_rect( &ui_global_ctx, menu, 0xa0000000 );
+
+      menu[1] += 32;
+      ui_text( &ui_global_ctx, (ui_rect){ menu[0]+menu[2]/2,menu[1], 0, 0 },
+                               "Exit", 2, k_text_align_center );
+
+      if( vg_get_button_down( "jump" ) )
+      {
+         glfwSetWindowShouldClose( vg.window, 1 );
+      }
+   }
+   
 #if 0
    if( lightedit )
    {
 #if 0
    if( lightedit )
    {
index 14a769bfe3939a5be51e261ce2fcc031544cf099..2f5155e592c84ebb838bbf593aaa227cd747b4a3 100644 (file)
Binary files a/models_src/mp_dev.mdl and b/models_src/mp_dev.mdl differ
index d7c9be0ad713b3c41de6b197b46c3502fe32b5d0..2fe380f8d1c68a29ccf5b042b9bcea11f73fd885 100644 (file)
--- a/network.h
+++ b/network.h
@@ -14,7 +14,7 @@
 /* 
  * Interface
  */
 /* 
  * Interface
  */
-#define SR_USE_LOCALHOST
+//#define SR_USE_LOCALHOST
 
 /* Call it at start; Connects us to the gameserver */
 static void network_init(void);
 
 /* Call it at start; Connects us to the gameserver */
 static void network_init(void);
@@ -172,7 +172,7 @@ static void send_nickname(void)
    nick.inetmsg_id = k_inetmsg_set_nickname;
 
    memset( nick.nickname, 0, 10 );
    nick.inetmsg_id = k_inetmsg_set_nickname;
 
    memset( nick.nickname, 0, 10 );
-   strcpy( nick.nickname, "Harry" );
+   strncpy( nick.nickname, steam_username_at_startup, 9 );
    
    SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
          hSteamNetworkingSockets, cremote, &nick, sizeof(netmsg_set_nickname),
    
    SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
          hSteamNetworkingSockets, cremote, &nick, sizeof(netmsg_set_nickname),
diff --git a/steam.h b/steam.h
index 8720c08aef8314c6dfc924781958a6af9dd0ac7e..0be3ff64045ee3efadd110eb7b6ac8549c325d52 100644 (file)
--- a/steam.h
+++ b/steam.h
@@ -11,6 +11,7 @@
 #include "vg/vg_steam_networking.h"
 #include "vg/vg_steam_auth.h"
 #include "vg/vg_steam_http.h"
 #include "vg/vg_steam_networking.h"
 #include "vg/vg_steam_auth.h"
 #include "vg/vg_steam_http.h"
+#include "vg/vg_steam_friends.h"
 
 /*
  * We only want to use steamworks if building for the networked version,
 
 /*
  * We only want to use steamworks if building for the networked version,
@@ -23,6 +24,8 @@
  * nothing.
  */
 
  * nothing.
  */
 
+static char steam_username_at_startup[128];
+
 static void recv_steam_warning( int severity, const char *msg )
 {
    if( severity == 0 )
 static void recv_steam_warning( int severity, const char *msg )
 {
    if( severity == 0 )
@@ -39,6 +42,8 @@ static HSteamPipe hSteamClientPipe;
 
 static int steam_init(void)
 {
 
 static int steam_init(void)
 {
+   const char *username = NULL;
+
 #ifdef SR_NETWORKED
    vg_info( "Initializing steamworks\n" );
 
 #ifdef SR_NETWORKED
    vg_info( "Initializing steamworks\n" );
 
@@ -63,8 +68,15 @@ static int steam_init(void)
 
    printf("\n");
    vg_success( "\nSteamworks API running\n" );
 
    printf("\n");
    vg_success( "\nSteamworks API running\n" );
+
+   ISteamFriends *hSteamFriends = SteamAPI_SteamFriends();
+   username = SteamAPI_ISteamFriends_GetPersonaName( hSteamFriends );
 #endif
 
 #endif
 
+   /* TODO: On username update callback */
+   str_utf8_collapse( username, steam_username_at_startup, 
+                        vg_list_size(steam_username_at_startup) );
+
    return 1;
 }
 
    return 1;
 }
 
diff --git a/textures_src/cement512.png b/textures_src/cement512.png
deleted file mode 100644 (file)
index cd94f96..0000000
Binary files a/textures_src/cement512.png and /dev/null differ
index 1b777e498843580aaf1970f07c180d2a13c7e460..3f5521f9da01da80cf9fc21485884a86a3091441 100644 (file)
Binary files a/textures_src/graffitibox.png and b/textures_src/graffitibox.png differ
diff --git a/textures_src/grid.png b/textures_src/grid.png
deleted file mode 100644 (file)
index 3b9d99d..0000000
Binary files a/textures_src/grid.png and /dev/null differ
diff --git a/textures_src/grid_terrain.png b/textures_src/grid_terrain.png
deleted file mode 100644 (file)
index f88b759..0000000
Binary files a/textures_src/grid_terrain.png and /dev/null differ
diff --git a/textures_src/norway_foliage.png b/textures_src/norway_foliage.png
deleted file mode 100644 (file)
index 6ca93f8..0000000
Binary files a/textures_src/norway_foliage.png and /dev/null differ
diff --git a/textures_src/norwey.png b/textures_src/norwey.png
deleted file mode 100644 (file)
index 9ac01ff..0000000
Binary files a/textures_src/norwey.png and /dev/null differ
diff --git a/textures_src/road.png b/textures_src/road.png
deleted file mode 100644 (file)
index 06c95cc..0000000
Binary files a/textures_src/road.png and /dev/null differ
diff --git a/textures_src/sky.png b/textures_src/sky.png
deleted file mode 100644 (file)
index f9cdae4..0000000
Binary files a/textures_src/sky.png and /dev/null differ
diff --git a/textures_src/subworld.png b/textures_src/subworld.png
deleted file mode 100644 (file)
index 01eccb1..0000000
Binary files a/textures_src/subworld.png and /dev/null differ
diff --git a/textures_src/water.png b/textures_src/water.png
deleted file mode 100644 (file)
index f0045e4..0000000
Binary files a/textures_src/water.png and /dev/null differ
index e24699e5a25f894f5147a00cb8a0e565f1d773f6..b812ef20a7ed24f92340af86742ced7ea10c9dc5 100644 (file)
@@ -17,7 +17,8 @@ static struct button_binding vg_button_binds[] =
    { .name = "down", .bind = GLFW_KEY_F },
    { .name = "yawl", .bind = GLFW_KEY_Q },
    { .name = "yawr", .bind = GLFW_KEY_E },
    { .name = "down", .bind = GLFW_KEY_F },
    { .name = "yawl", .bind = GLFW_KEY_Q },
    { .name = "yawr", .bind = GLFW_KEY_E },
-   { .name = "push", .bind = GLFW_KEY_T }
+   { .name = "push", .bind = GLFW_KEY_T },
+   { .name = "menu", .bind = GLFW_KEY_ESCAPE }
 };
 
 static struct button_binding vg_controller_binds[] = 
 };
 
 static struct button_binding vg_controller_binds[] = 
@@ -25,7 +26,8 @@ static struct button_binding vg_controller_binds[] =
    { "jump",         GLFW_GAMEPAD_BUTTON_A },
    { "break",        GLFW_GAMEPAD_BUTTON_B },
    { "switchmode",   GLFW_GAMEPAD_BUTTON_Y },
    { "jump",         GLFW_GAMEPAD_BUTTON_A },
    { "break",        GLFW_GAMEPAD_BUTTON_B },
    { "switchmode",   GLFW_GAMEPAD_BUTTON_Y },
-   { "reset",        GLFW_GAMEPAD_BUTTON_LEFT_BUMPER }
+   { "reset",        GLFW_GAMEPAD_BUTTON_LEFT_BUMPER },
+   { "menu",         GLFW_GAMEPAD_BUTTON_BACK }
 };
 
 static struct axis_binding vg_axis_binds[] = 
 };
 
 static struct axis_binding vg_axis_binds[] =