From: hgn Date: Wed, 12 Oct 2022 20:25:14 +0000 (+0100) Subject: dont remember X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;ds=sidebyside;h=19213f3309ec3c45e5b23ac2f0d91f26f3a8984f;p=carveJwlIkooP6JGAAIwe30JlM.git dont remember --- diff --git a/common.h b/common.h index a36dc0a..0abe446 100644 --- a/common.h +++ b/common.h @@ -9,6 +9,7 @@ #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 @@ -20,4 +21,69 @@ struct ray_hit 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> 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 */ diff --git a/main.c b/main.c index 3cee76a..6e61fa2 100644 --- a/main.c +++ b/main.c @@ -26,11 +26,13 @@ #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[] ) -{ +{ 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 ); } + + if( vg_get_button_down( "menu" ) ) + { + cl_menu = !cl_menu; + } } static void vg_update_fixed( int loaded ) @@ -232,6 +239,39 @@ void vg_render(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 ) { diff --git a/models_src/mp_dev.mdl b/models_src/mp_dev.mdl index 14a769b..2f5155e 100644 Binary files a/models_src/mp_dev.mdl and b/models_src/mp_dev.mdl differ diff --git a/network.h b/network.h index d7c9be0..2fe380f 100644 --- a/network.h +++ b/network.h @@ -14,7 +14,7 @@ /* * Interface */ -#define SR_USE_LOCALHOST +//#define SR_USE_LOCALHOST /* 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 ); - strcpy( nick.nickname, "Harry" ); + strncpy( nick.nickname, steam_username_at_startup, 9 ); SteamAPI_ISteamNetworkingSockets_SendMessageToConnection( hSteamNetworkingSockets, cremote, &nick, sizeof(netmsg_set_nickname), diff --git a/steam.h b/steam.h index 8720c08..0be3ff6 100644 --- 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_friends.h" /* * We only want to use steamworks if building for the networked version, @@ -23,6 +24,8 @@ * nothing. */ +static char steam_username_at_startup[128]; + 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) { + const char *username = NULL; + #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" ); + + ISteamFriends *hSteamFriends = SteamAPI_SteamFriends(); + username = SteamAPI_ISteamFriends_GetPersonaName( hSteamFriends ); #endif + /* TODO: On username update callback */ + str_utf8_collapse( username, steam_username_at_startup, + vg_list_size(steam_username_at_startup) ); + return 1; } diff --git a/textures_src/cement512.png b/textures_src/cement512.png deleted file mode 100644 index cd94f96..0000000 Binary files a/textures_src/cement512.png and /dev/null differ diff --git a/textures_src/graffitibox.png b/textures_src/graffitibox.png index 1b777e4..3f5521f 100644 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 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 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 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 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 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 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 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 index f0045e4..0000000 Binary files a/textures_src/water.png and /dev/null differ diff --git a/vg_config.h b/vg_config.h index e24699e..b812ef2 100644 --- a/vg_config.h +++ b/vg_config.h @@ -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 = "push", .bind = GLFW_KEY_T } + { .name = "push", .bind = GLFW_KEY_T }, + { .name = "menu", .bind = GLFW_KEY_ESCAPE } }; 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 }, - { "reset", GLFW_GAMEPAD_BUTTON_LEFT_BUMPER } + { "reset", GLFW_GAMEPAD_BUTTON_LEFT_BUMPER }, + { "menu", GLFW_GAMEPAD_BUTTON_BACK } }; static struct axis_binding vg_axis_binds[] =