From 7d2dc047b828ff5a0d84f4f0f781b04ef2ae77c6 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Sun, 5 Dec 2021 17:07:06 -0600 Subject: [PATCH 1/7] cleaning up the mumble link code --- burrito_link/gw2mumbleudp.c | 284 +++++++++++++++++++++--------------- 1 file changed, 169 insertions(+), 115 deletions(-) diff --git a/burrito_link/gw2mumbleudp.c b/burrito_link/gw2mumbleudp.c index 1181cfd1..2dafc435 100644 --- a/burrito_link/gw2mumbleudp.c +++ b/burrito_link/gw2mumbleudp.c @@ -6,26 +6,25 @@ // Do a rolling average on the player position because that seems to be // Roughly what the camera position is doing and doing this will remove // some weird jitter I hope -struct rolling_average_5 -{ +struct rolling_average_5 { UINT8 index; float points[5]; }; -float get_rolling_average(struct rolling_average_5 *points) -{ + + +float get_rolling_average(struct rolling_average_5 *points) { float sum = 0; - for (int i = 0; i < 5; i++) - { + for (int i = 0; i < 5; i++) { sum += points->points[i]; } return sum / 5.0; } -void replace_point_in_rolling_average(struct rolling_average_5 *points, float newvalue) -{ + + +void replace_point_in_rolling_average(struct rolling_average_5 *points, float newvalue) { points->points[points->index] = newvalue; points->index = points->index + 1; - if (points->index > 4) - { + if (points->index > 4) { points->index = 0; } } @@ -35,43 +34,115 @@ struct rolling_average_5 playerz_avg; float fAvatarAveragePosition[3]; +//////////////////////////////////////////////////////////////////////////////// +// LinkedMem struct +// +// This struct represents the Mumble Link shared memory datum that Guild Wars 2 +// uses to communicate live player and camera data, as well as some other +// bits of information that are useful for tools like burrito. +// // https://wiki.guildwars2.com/wiki/API:MumbleLink -struct LinkedMem -{ +// https://www.mumble.info/documentation/developer/positional-audio/link-plugin/ +//////////////////////////////////////////////////////////////////////////////// +struct LinkedMem { UINT32 uiVersion; + + // The current update tick DWORD uiTick; - float fAvatarPosition[3]; // The XYZ location of the player + + // The XYZ location of the player + float fAvatarPosition[3]; + + // A 3D unit vector representing the forward direction of the player character float fAvatarFront[3]; + + // A 3D unit vector representing the up direction of the player character float fAvatarTop[3]; - wchar_t name[256]; // The string "Guild Wars 2" [Ignored] - float fCameraPosition[3]; // The XYZ position of the camera - float fCameraFront[3]; // A unit vector extending out the front of the camera - float fCameraTop[3]; // A perpendicular vector to fCameraFront, used for calculating roll [Ignored] - wchar_t identity[256]; // A json string containing json data - UINT32 context_len; // A value that is always 48 [Ignored] - unsigned char context[256]; // See MumbleContext struct - wchar_t description[2048]; // Empty [Ignored] + + // The string "Guild Wars 2" + wchar_t name[256]; + + // The XYZ Position of the camera + float fCameraPosition[3]; + + // A 3D unit vector representing the forward direction of the camera + float fCameraFront[3]; + + // A 3D unit vector representing the up direction of the camera + float fCameraTop[3]; + + // A json string containing json data. See https://wiki.guildwars2.com/wiki/API:MumbleLink#identity + wchar_t identity[256]; + + // A value that is always 48 + UINT32 context_len; + + // A binary chunk containing another struct. See the MumbleContext struct below + unsigned char context[256]; + + // An Empty Array, this field is not used by guild wars 2 + wchar_t description[2048]; }; -struct MumbleContext -{ - unsigned char serverAddress[28]; // contains sockaddr_in or sockaddr_in6 // IGNORED + +//////////////////////////////////////////////////////////////////////////////// +// MumbleContext struct +// +// This struct represents the LinkedMem.context datum that is passed in +// LinkedMem. It is a struct that is entirely specific to Guild Wars 2 which +// is why it is seperated out from the more mumble-generic LinkedMem struct. +// +// https://wiki.guildwars2.com/wiki/API:MumbleLink#context +//////////////////////////////////////////////////////////////////////////////// +struct MumbleContext { + // The current address of the guild wars 2 server the player is connected to + // can be a ipv4 `sockaddr_in` or a ipv6 `sockaddr_in6` + unsigned char serverAddress[28]; + + // The Guild Wars 2 id for the map the player is currently in UINT32 mapId; + UINT32 mapType; UINT32 shardId; UINT32 instance; UINT32 buildId; - // Additional data beyond the 48 bytes Mumble uses for identification - UINT32 uiState; // Bitmask: Bit 1 = IsMapOpen, Bit 2 = IsCompassTopRight, Bit 3 = DoesCompassHaveRotationEnabled, Bit 4 = Game has focus, Bit 5 = Is in Competitive game mode, Bit 6 = Textbox has focus, Bit 7 = Is in Combat - UINT16 compassWidth; // pixels - UINT16 compassHeight; // pixels - float compassRotation; // radians - float playerX; // continentCoords - float playerY; // continentCoords - float mapCenterX; // continentCoords - float mapCenterY; // continentCoords + + // A bitmask of various boolean element of the UI state + // Bit 1 = IsMapOpen + // Bit 2 = IsCompassTopRight + // Bit 3 = DoesCompassHaveRotationEnabled + // Bit 4 = Game has focus + // Bit 5 = Is in Competitive game mode + // Bit 6 = Textbox has focus + // Bit 7 = Is in Combat + UINT32 uiState; + + // The width of the minimap in pixels + UINT16 compassWidth; + + // The height of the minimap in pixels + UINT16 compassHeight; + + // The rotation of the minimap contents in radians + float compassRotation; + + // The X location of the player in continentCoords + float playerX; + // The Y location of the player in continentCoords + float playerY; + + // The center X of the current map in continentCoords + float mapCenterX; + // The center Y of the current map in continentCoords + float mapCenterY; + + // The scale of how zoomed in the visible map or minimap is float mapScale; - UINT32 processId; // Windows process id + + // The windows process id of the Guild Wars 2 process + UINT32 processId; + + // An enum representing which mount is currenty being used by the player UINT8 mountIndex; }; @@ -89,9 +160,7 @@ HANDLE handle_lm; LPCTSTR mapped_lm; #endif -void initMumble() -{ - +void initMumble() { #ifdef _WIN32 // creates a shared memory IF it doesn't exist. otherwise, it returns the existing shared memory handle. // reference: https://docs.microsoft.com/en-us/windows/win32/memory/creating-named-shared-memory @@ -99,29 +168,28 @@ void initMumble() size_t BUF_SIZE = sizeof(struct LinkedMem); handle_lm = CreateFileMapping( - INVALID_HANDLE_VALUE, // use paging file - NULL, // default security - PAGE_READWRITE, // read/write access - 0, // maximum object size (high-order DWORD) - BUF_SIZE, // maximum object size (low-order DWORD) - "MumbleLink"); // name of mapping object - // createfilemapping returns NULL when it fails, we print the error code for debugging purposes. - - if (handle_lm == NULL) - { + INVALID_HANDLE_VALUE, // use paging file + NULL, // default security + PAGE_READWRITE, // read/write access + 0, // maximum object size (high-order DWORD) + BUF_SIZE, // maximum object size (low-order DWORD) + "MumbleLink"); // name of mapping object + // createfilemapping returns NULL when it fails, we print the error code for debugging purposes. + + if (handle_lm == NULL) { printf("Could not create file mapping object (%lu).\n", GetLastError()); return; } - mapped_lm = (LPTSTR)MapViewOfFile(handle_lm, // handle to map object - FILE_MAP_ALL_ACCESS, // read/write permission - 0, - 0, - BUF_SIZE); + mapped_lm = (LPTSTR)MapViewOfFile( + handle_lm, // handle to map object + FILE_MAP_ALL_ACCESS, // read/write permission + 0, + 0, + BUF_SIZE); - if (mapped_lm == NULL) - { + if (mapped_lm == NULL) { printf("Could not map view of file (%lu).\n", GetLastError()); @@ -135,19 +203,17 @@ void initMumble() printf("successfully opened mumble link shared memory..\n"); #else char memname[256]; - snprintf(memname, 256, "/MumbleLink.%d", getuid()); + snprintf(memname, sizeof(memname), "/MumbleLink.%d", getuid()); int shmfd = shm_open(memname, O_RDWR, S_IRUSR | S_IWUSR); - if (shmfd < 0) - { + if (shmfd < 0) { return; } lm = (struct LinkedMem *)(mmap(NULL, sizeof(struct LinkedMem), PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0)); - if (lm == (void *)(-1)) - { + if (lm == (void *)(-1)) { lm = NULL; return; } @@ -156,9 +222,16 @@ void initMumble() int last_map_id = 0; +// The max buffer size for data that is being sent to burriot over the UDP socket #define MaxBufferSize 1024 -int connect_and_or_send() -{ + +//////////////////////////////////////////////////////////////////////////////// +// connect_and_or_send() +// +// This function loops until termination, grabbing information from the shared +// memory block and sending the memory over to burrito over a UDP socket. +//////////////////////////////////////////////////////////////////////////////// +int connect_and_or_send() { WSADATA wsaData; SOCKET SendingSocket; SOCKADDR_IN ReceiverAddr, SrcInfo; @@ -168,9 +241,7 @@ int connect_and_or_send() int len; int TotalByteSent; - if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) - { - + if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { printf("Client: WSAStartup failed with error %d\n", WSAGetLastError()); // Clean up @@ -178,18 +249,14 @@ int connect_and_or_send() // Exit with error return -1; - } - else - { + } else { printf("Client: The Winsock DLL status is %s.\n", wsaData.szSystemStatus); } // Create a new socket to receive datagrams on. SendingSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (SendingSocket == INVALID_SOCKET) - { - + if (SendingSocket == INVALID_SOCKET) { // Print error message printf("Client: Error at socket(): %d\n", WSAGetLastError()); @@ -198,9 +265,7 @@ int connect_and_or_send() // Exit with error return -1; - } - else - { + } else { printf("Client: socket() is OK!\n"); } @@ -218,16 +283,12 @@ int connect_and_or_send() int count = 0; DWORD lastuitick = 0; // Send data packages to the receiver(Server). - do - { - - if (lm->uiTick == lastuitick) - { + do { + if (lm->uiTick == lastuitick) { Sleep(1); continue; } lastuitick = lm->uiTick; - //printf("%ld\n", lm->uiTick); replace_point_in_rolling_average(&playerx_avg, lm->fAvatarPosition[0]); replace_point_in_rolling_average(&playery_avg, lm->fAvatarPosition[1]); @@ -239,7 +300,8 @@ int connect_and_or_send() fAvatarAveragePosition[2] = get_rolling_average(&playerz_avg); BufLength = 1; - SendBuf[0] = 1; // Per Frame Updater + // Set the first byte of the packet to indicate this packet is a `Per Frame Updater` packet + SendBuf[0] = 1; memcpy(SendBuf + BufLength, lm->fCameraPosition, sizeof(lm->fCameraPosition)); BufLength += sizeof(lm->fCameraPosition); @@ -280,11 +342,15 @@ int connect_and_or_send() TotalByteSent = sendto(SendingSocket, SendBuf, BufLength, 0, (SOCKADDR *)&ReceiverAddr, sizeof(ReceiverAddr)); - if (count == 0 || lc->mapId != last_map_id) - { + + // After so many iterations have passed or under specific conditions + // we will send a larger packet that contains more information about + // the current state of the game. + if (count == 0 || lc->mapId != last_map_id) { last_map_id = lc->mapId; BufLength = 1; - SendBuf[0] = 2; // Heaver Context Updater + // Set the first byte of the packet to indicate this packet is a `Heaver Context Updater` packet + SendBuf[0] = 2; // printf("hello world\n"); // printf("%ls\n", lm->description); @@ -330,14 +396,12 @@ int connect_and_or_send() // Get and send the linux x server window id UINT32 x11_window_id = 0; - HWND window_handle=NULL; - BOOL CALLBACK EnumWindowsProcMy(HWND hwnd, LPARAM lParam) - { + HWND window_handle = NULL; + BOOL CALLBACK EnumWindowsProcMy(HWND hwnd, LPARAM lParam) { DWORD processId; GetWindowThreadProcessId(hwnd, &processId); - if(processId == lParam) - { - window_handle=hwnd; + if (processId == lParam) { + window_handle = hwnd; return FALSE; } return TRUE; @@ -384,11 +448,11 @@ int connect_and_or_send() // break; } - // Sleep(16); // Slightly faster then 60fps which would be 16.6666666...ms + // Update the count for the `Heaver Context Updater` packet and reset + // it to 0 when it hits a threshold value. count += 1; - if (count > 500) - { + if (count > 500) { count = 0; } @@ -423,13 +487,9 @@ int connect_and_or_send() printf("Client: Finished sending. Closing the sending socket...\n"); - if (closesocket(SendingSocket) != 0) - { - + if (closesocket(SendingSocket) != 0) { printf("Client: closesocket() failed! Error code: %d\n", WSAGetLastError()); - } - else - { + } else { printf("Server: closesocket() is OK\n"); } @@ -437,40 +497,34 @@ int connect_and_or_send() printf("Client: Cleaning up...\n"); - if (WSACleanup() != 0) - { + if (WSACleanup() != 0) { printf("Client: WSACleanup() failed! Error code: %d\n", WSAGetLastError()); - } - - else - { + } else { printf("Client: WSACleanup() is OK\n"); } + #ifdef _WIN32 // unmap the shared memory from our process address space. UnmapViewOfFile(mapped_lm); // close LinkedMemory handle CloseHandle(handle_lm); - #endif + // Back to the system return 0; } -int main(int argc, char **argv) -{ + +//////////////////////////////////////////////////////////////////////////////// +// The main function initializes some global variables and shared memory. Then +// calls the connect_and_or_send process which loops until termination. +//////////////////////////////////////////////////////////////////////////////// +int main(int argc, char **argv) { playerx_avg.index = 0; playery_avg.index = 0; playerz_avg.index = 0; - printf("hello world\n"); initMumble(); - // sockmain(argc, argv); - // initMumble(); - // for (int i = 0; i < 100; i++) { - // printf("%f\n", lm->fAvatarPosition[0]); - // Sleep(16); // Slightly faster then 60fps which would be 16.6666666...ms - // } connect_and_or_send(); -} \ No newline at end of file +} From 42b484b25b6b19859a7506d16bca9b74aae3d8b2 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Sun, 5 Dec 2021 22:38:44 -0600 Subject: [PATCH 2/7] adding a timeout for burrito link to allow it to exit if it is orphaned --- burrito_link/gw2mumbleudp.c | 80 +++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/burrito_link/gw2mumbleudp.c b/burrito_link/gw2mumbleudp.c index 2dafc435..e2fd78b0 100644 --- a/burrito_link/gw2mumbleudp.c +++ b/burrito_link/gw2mumbleudp.c @@ -2,6 +2,12 @@ #include #include #include +#include + +// Enumerations of the different packet types that can be sent +#define PACKET_FRAME 1 +#define PACKET_METADATA 2 +#define PACKET_LINK_TIMEOUT 3 // Do a rolling average on the player position because that seems to be // Roughly what the camera position is doing and doing this will remove @@ -151,6 +157,14 @@ struct MumbleContext { struct LinkedMem *lm = NULL; // mumble context pointer into the `lm` variable above. struct MumbleContext *lc = NULL; + +long program_timeout = 0; +long program_startime = 0; + + +time_t rawtime; + + #ifdef _WIN32 // handle to the shared memory of Mumble link . close at the end of program. windows will only release the shared memory once ALL handles are closed, @@ -234,11 +248,10 @@ int last_map_id = 0; int connect_and_or_send() { WSADATA wsaData; SOCKET SendingSocket; - SOCKADDR_IN ReceiverAddr, SrcInfo; + SOCKADDR_IN ReceiverAddr; int Port = 4242; int BufLength = 1024; char SendBuf[MaxBufferSize]; - int len; int TotalByteSent; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { @@ -284,6 +297,18 @@ int connect_and_or_send() { DWORD lastuitick = 0; // Send data packages to the receiver(Server). do { + if (program_timeout != 0 && clock()-program_startime > program_timeout) { + BufLength = 1; + // Set the first byte of the packet to indicate this packet is a `Heaver Context Updater` packet + SendBuf[0] = PACKET_LINK_TIMEOUT; + TotalByteSent = sendto(SendingSocket, SendBuf, BufLength, 0, (SOCKADDR *)&ReceiverAddr, sizeof(ReceiverAddr)); + if (TotalByteSent != BufLength) { + printf("Not all Bytes Sent"); + } + + printf("Breaking out due to timeout"); + break; + } if (lm->uiTick == lastuitick) { Sleep(1); continue; @@ -301,7 +326,7 @@ int connect_and_or_send() { BufLength = 1; // Set the first byte of the packet to indicate this packet is a `Per Frame Updater` packet - SendBuf[0] = 1; + SendBuf[0] = PACKET_FRAME; memcpy(SendBuf + BufLength, lm->fCameraPosition, sizeof(lm->fCameraPosition)); BufLength += sizeof(lm->fCameraPosition); @@ -341,7 +366,9 @@ int connect_and_or_send() { // printf("UI State: %i\n", lc->uiState); // Bitmask: Bit 1 = IsMapOpen, Bit 2 = IsCompassTopRight, Bit 3 = DoesCompassHaveRotationEnabled, Bit 4 = Game has focus, Bit 5 = Is in Competitive game mode, Bit 6 = Textbox has focus, Bit 7 = Is in Combat TotalByteSent = sendto(SendingSocket, SendBuf, BufLength, 0, (SOCKADDR *)&ReceiverAddr, sizeof(ReceiverAddr)); - + if (TotalByteSent != BufLength) { + printf("Not all Bytes Sent"); + } // After so many iterations have passed or under specific conditions // we will send a larger packet that contains more information about @@ -350,7 +377,7 @@ int connect_and_or_send() { last_map_id = lc->mapId; BufLength = 1; // Set the first byte of the packet to indicate this packet is a `Heaver Context Updater` packet - SendBuf[0] = 2; + SendBuf[0] = PACKET_METADATA; // printf("hello world\n"); // printf("%ls\n", lm->description); @@ -444,7 +471,9 @@ int connect_and_or_send() { BufLength += converted_size; TotalByteSent = sendto(SendingSocket, SendBuf, BufLength, 0, (SOCKADDR *)&ReceiverAddr, sizeof(ReceiverAddr)); - + if (TotalByteSent != BufLength) { + printf("Not all Bytes Sent"); + } // break; } @@ -455,37 +484,8 @@ int connect_and_or_send() { if (count > 500) { count = 0; } - - // TODO: Maybe make a way to break out of this loop beyond program termination } while (TRUE); - // Print some info on the receiver(Server) side... - - // Allocate the required resources - - memset(&SrcInfo, 0, sizeof(SrcInfo)); - - len = sizeof(SrcInfo); - - getsockname(SendingSocket, (SOCKADDR *)&SrcInfo, &len); - - printf("Client: Sending IP(s) used: %s\n", inet_ntoa(SrcInfo.sin_addr)); - - printf("Client: Sending port used: %d\n", htons(SrcInfo.sin_port)); - - // Print some info on the sender(Client) side... - - getpeername(SendingSocket, (SOCKADDR *)&ReceiverAddr, (int *)sizeof(ReceiverAddr)); - - printf("Client: Receiving IP used: %s\n", inet_ntoa(ReceiverAddr.sin_addr)); - - printf("Client: Receiving port used: %d\n", htons(ReceiverAddr.sin_port)); - - printf("Client: Total byte sent: %d\n", TotalByteSent); - - // When your application is finished receiving datagrams close the socket. - - printf("Client: Finished sending. Closing the sending socket...\n"); if (closesocket(SendingSocket) != 0) { printf("Client: closesocket() failed! Error code: %d\n", WSAGetLastError()); @@ -520,6 +520,16 @@ int connect_and_or_send() { // calls the connect_and_or_send process which loops until termination. //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { + + for (int i = 0; i < argc; i++) { + // If a timeout flag is passed in then set the timeout value + if (strcmp(argv[i], "--timeout") == 0) { + i = i+1; + program_timeout = atol(argv[i]) * CLOCKS_PER_SEC; + program_startime = clock(); + } + } + playerx_avg.index = 0; playery_avg.index = 0; playerz_avg.index = 0; From c01f8461530f5eb458f41ca48ac005342bf25963 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Sun, 5 Dec 2021 22:42:04 -0600 Subject: [PATCH 3/7] adding a method to allow for burrito link to be launched automatically --- Spatial.gd | 152 +++++++++++++++++++++++++++++++++++--------------- Spatial.tscn | 77 +++++++++++++++---------- project.godot | 4 +- 3 files changed, 155 insertions(+), 78 deletions(-) diff --git a/Spatial.gd b/Spatial.gd index 738b4d67..1de7f13c 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -27,7 +27,7 @@ var map_was_open = false var player_position := Vector3(0,0,0) # Player Position as accurate to Godot (z value sign is flipped) -var correct_player_position := Vector3(0,0,0) +var correct_player_position := Vector3(0,0,0) var compass_height: int = 0; var compass_width: int = 0; @@ -35,7 +35,7 @@ var compass_width: int = 0; # A temporary setting able to be configured by the user. It is used to allow # for faster trail mesh generation. The higher the value the fewer samples are -# taken for the MeshCSG leading to an overall lower number of polygons. +# taken for the MeshCSG leading to an overall lower number of polygons. var path_resolution = 1 # Variables that store opposit corners of the compass @@ -61,14 +61,67 @@ func _ready(): set_minimal_mouse_block() server.listen(4242) + if (Settings.burrito_link_auto_launch_enabled): + launch_burrito_link() + + +################################################################################ +# show_error +# +# This function prints a user error out. Currently it prints to stdout but may +# one day be shown to the user. +################################################################################ +func show_user_error(error_string: String): + print(error_string) + + +# The process id of burrito link if it is launched automatically by burrito +var burrito_link_process_id = 0 + +################################################################################ +# launch_burrito_link +# +# This function launches the burrito link binary using the values for it that +# are saved in "settings". +################################################################################ +func launch_burrito_link(): + for env_arg in Settings.burrito_link_env_args.split("\n"): + env_arg = env_arg.trim_prefix("export ") + var key_values = env_arg.split('=', true, 1) + + if len(key_values) != 2: + show_user_error("Invalid burrito_link environment arg: " + env_arg) + return + + var key = key_values[0] + var value = key_values[1].trim_prefix('"').trim_suffix('"') + OS.set_environment(key, value) + + # Launch burrito link with a 2 hour timeout + # If burrito crashes then burrito_link will automatically exit at the timeout. + # If burrito does not crash and the timeout expires then burrito will relaunch burrito_link automatically + burrito_link_process_id = OS.execute(Settings.burrito_link_wine_path, ["burrito_link/burrito_link.exe", "--timeout", "7200"], false) + +func close_burrito_link(): + if (burrito_link_process_id != 0): + OS.kill(burrito_link_process_id) + burrito_link_process_id = 0 + + +func exit_burrito(): + if Settings.burrito_link_auto_launch_enabled: + close_burrito_link() + get_tree().quit() + + func set_minimal_mouse_block(): var top_corner := Vector2(287, 0) var bottom_corner := Vector2(314, 32) - + if self.edit_panel_open: bottom_corner.y = 49 bottom_corner.x = 314+377 - + var clickthrough: PoolVector2Array = [ Vector2(top_corner.x ,top_corner.y), Vector2(bottom_corner.x, top_corner.y), @@ -84,7 +137,7 @@ func set_maximal_mouse_block(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): - #OS.window_position = Vector2(1920, 0) # TODO: This does not seem to work + #OS.window_position = Vector2(1920, 0) # TODO: This does not seem to work #OS.set_window_position(Vector2(1920,0)) #print(OS.window_position) server.poll() # Important @@ -105,7 +158,9 @@ func _process(delta): if packet_type == 1: decode_frame_packet(spb) elif packet_type == 2: - decode_context_packet(spb) + decode_context_packet(spb) + elif packet_type == 3: + decode_timeout_packet(spb) return @@ -116,14 +171,14 @@ func decode_frame_packet(spb: StreamPeerBuffer): spb.get_float(), spb.get_float() ) - + # Extract the rotation of the camera in the form of a normal vector var camera_facing = Vector3( spb.get_float(), spb.get_float(), spb.get_float() ) - + # Extract the position of the player's foot self.player_position = Vector3( spb.get_float(), @@ -131,10 +186,10 @@ func decode_frame_packet(spb: StreamPeerBuffer): spb.get_float() ) self.correct_player_position = Vector3(player_position.x, player_position.y, -player_position.z) - + if $Control/Position.visible: $Control/Position.text = "X " + str(player_position.x) + " Y " + str(player_position.y) + " Z " + str(-player_position.z) - + var map_offset = Vector2( spb.get_float(), spb.get_float() @@ -144,7 +199,7 @@ func decode_frame_packet(spb: StreamPeerBuffer): map_scale = 0.000001 var map_rotation: float = spb.get_float() var ui_flags: int = spb.get_32() - + map_is_open = (ui_flags & 0x01) == 0x01; compass_is_top_right = (ui_flags & 0x02) == 0x02; var compass_rotation_is_enabled: bool = (ui_flags & 0x04) == 0x04; @@ -167,7 +222,7 @@ func decode_frame_packet(spb: StreamPeerBuffer): $CameraMount.translation.x = camera_position.x $CameraMount.translation.y = camera_position.y $CameraMount.translation.z = -camera_position.z - + # Orent the camera in the same rotation as it is facing in game $CameraMount/Camera.rotation.x = asin(camera_facing.y) $CameraMount.rotation.y = -atan2(camera_facing.x, camera_facing.z) @@ -183,7 +238,7 @@ func decode_frame_packet(spb: StreamPeerBuffer): var map_size = get_viewport().size var map_corner = Vector2(0, 0) - + if (!map_is_open): map_size = Vector2(compass_width, compass_height) if !compass_is_top_right: @@ -203,16 +258,16 @@ func decode_frame_packet(spb: StreamPeerBuffer): var x = (cosTheta * (player_map_position.x - pivot.x) - sinTheta * (player_map_position.y - pivot.y) + pivot.x); var y = (sinTheta * (player_map_position.x - pivot.x) + cosTheta * (player_map_position.y - pivot.y) + pivot.y); - + delta_position = player_map_position - Vector2(x, y); - + #print(map_rotation) $Control/MiniMap.rotation = map_rotation else: $Control/MiniMap.rotation = 0 - + var map_midpoint = map_size/2 + map_corner; - + $Control/MiniMap.scale=Vector2(map_object_scaling, map_object_scaling) var map_translation = map_offset $Control/MiniMap.position = (map_translation / map_scale) + map_midpoint - player_map_position + delta_position @@ -242,7 +297,7 @@ func decode_context_packet(spb: StreamPeerBuffer): var identity_length: int = spb.get_32() var identity_str = spb.get_utf8_string(identity_length) var identity = JSON.parse(identity_str).result - + # FOV Calculations # The minimum value on the FOV slider gives a float value in this field of 0.436 # The maximum value on the FOV slider gives a float value in this field of 1.222 @@ -255,7 +310,7 @@ func decode_context_packet(spb: StreamPeerBuffer): if self.map_id != old_map_id: print("New Map") - + print("Saving Old Map") self.markerdata[str(old_map_id)] = data_from_renderview() print("Loading New Map") @@ -272,6 +327,13 @@ func decode_context_packet(spb: StreamPeerBuffer): reset_minimap_masks() +func decode_timeout_packet(spb: StreamPeerBuffer): + if Settings.burrito_link_auto_launch_enabled: + print("Link Timeout Reached, should restart link if started by burrito automatically") + close_burrito_link() + launch_burrito_link() + + func reset_minimap_masks(): var viewport_size = get_viewport().size compass_corner1 = Vector2(0, 0) @@ -282,7 +344,7 @@ func reset_minimap_masks(): elif !map_is_open && compass_is_top_right: compass_corner1 = viewport_size - Vector2(compass_width, compass_height) compass_corner2 = compass_corner1 + Vector2(compass_width, compass_height) - + for minimap_path in $Control/MiniMap.get_children(): minimap_path.material.set_shader_param("minimap_corner", compass_corner1) minimap_path.material.set_shader_param("minimap_corner2", compass_corner2) @@ -291,7 +353,7 @@ var markerdata = {} var marker_file_path = "" func load_taco_markers(marker_json_file): self.marker_file_path = marker_json_file - + if is_xml_file(marker_json_file): print("Loading XML file from path ", marker_json_file) var parsed_taco_tuple = taco_parser.parse_taco_xml(marker_json_file) @@ -306,7 +368,7 @@ func load_taco_markers(marker_json_file): file.open(marker_json_file, file.READ) var text = file.get_as_text() self.markerdata = JSON.parse(text).result - + relative_textures_to_absolute_textures(marker_file_path.get_base_dir()) gen_map_markers() @@ -396,8 +458,8 @@ func _unhandled_input(event): if is_instance_valid(self.last_hover) and self.last_hover.has_method("unhover"): self.last_hover.unhover() self.last_hover = null - - + + ################################################################################ # ################################################################################ @@ -427,13 +489,13 @@ func gen_map_markers(): gen_new_icon(position, icon["texture"]) func gen_new_path(points: Array, texture_path: String): - var points_2d: PoolVector2Array = [] + var points_2d: PoolVector2Array = [] # Create the texture to use from an image file # TODO: We want to be able to cache this data so that if a texture is used # by multiple objects we only need to keep ony copy of it in memory. #22. - # TODO: We want to have two copies of each texture in memory one for 2D + # TODO: We want to have two copies of each texture in memory one for 2D # which does not use srgb to render properly, and one for 3D which forces # srgb to render properly. Issue #23. var texture_file = File.new() @@ -460,31 +522,31 @@ func gen_new_path(points: Array, texture_path: String): # new_path.curve = new_curve new_route.texture_path = texture_path # Save the location of the image for later #path_3d_markers.append(new_path) - + var points_3d := PoolVector3Array() for point in points: points_3d.append(Vector3(point[0], point[1], -point[2])) - + new_route.create_mesh(points_3d) new_route.set_texture(texture) paths.add_child(new_route) - - - - - - - + + + + + + + for point in points: points_2d.append(Vector2(point[0], -point[2])) - - + + # Create a new 2D Path var new_2d_path = path2d_scene.instance() new_2d_path.points = points_2d new_2d_path.texture = texture minimap.add_child(new_2d_path) - + self.currently_active_path = new_route self.currently_active_path_2d = new_2d_path @@ -506,13 +568,13 @@ func gen_new_icon(position: Vector3, texture_path: String): func data_from_renderview(): var icons_data = [] var paths_data = [] - + for icon in $Icons.get_children(): icons_data.append({ "position": [icon.translation.x, icon.translation.y, -icon.translation.z], "texture": icon.texture_path }) - + for path in $Paths.get_children(): #print(path) var points = [] @@ -554,7 +616,7 @@ func gen_adjustment_nodes(): #var curve: Curve3D = path.curve for i in range(route.get_point_count()): var gizmo_position = route.get_point_position(i) - + # Simplistic cull to prevent nodes that are too far away to be # visible from being created. Additional work can be done here # if this is not enough of an optimization in the future. @@ -567,7 +629,7 @@ func gen_adjustment_nodes(): new_gizmo.connect("selected", self, "on_gizmo_selected") new_gizmo.connect("deselected", self, "on_gizmo_deselected") $Gizmos.add_child(new_gizmo) - + for index in range(self.icons.get_child_count()): var icon = self.icons.get_child(index) var new_gizmo = gizmo_scene.instance() @@ -737,14 +799,14 @@ func _on_NewNodeAfter_pressed(): if path.get_point_count() > index+1: var end = path.get_point_position(index+1) midpoint = ((start-end)/2) + end - + path.add_point(midpoint, index+1) path2d.add_point(Vector2(midpoint.x, midpoint.z), index+1) clear_adjustment_nodes() gen_adjustment_nodes() on_gizmo_deselected(self.currently_selected_node) - + func _on_XZSnapToPlayer_pressed(): self.currently_selected_node.translation.x = self.player_position.x self.currently_selected_node.translation.z = -self.player_position.z @@ -773,7 +835,7 @@ func _on_ReversePathDirection_pressed(): func _on_ExitButton_pressed(): - get_tree().quit() + exit_burrito() func _on_Settings_pressed(): diff --git a/Spatial.tscn b/Spatial.tscn index 825a6da9..6a08e7e4 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -193,6 +193,7 @@ __meta__ = { } [node name="MainMenu" type="WindowDialog" parent="Control/Dialogs"] +visible = true margin_left = 48.1808 margin_top = 88.7138 margin_right = 261.181 @@ -603,6 +604,7 @@ disabled = true text = "Reverse Path Direction" [node name="SettingsDialog" type="WindowDialog" parent="Control/Dialogs"] +visible = true margin_left = 592.0 margin_top = 146.0 margin_right = 981.0 @@ -627,24 +629,24 @@ __meta__ = { [node name="OverrideSizeLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] margin_top = 13.0 -margin_right = 102.0 +margin_right = 112.0 margin_bottom = 27.0 text = "Override Size" [node name="OverrideSize" type="CheckButton" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_left = 106.0 +margin_left = 116.0 margin_right = 369.0 margin_bottom = 40.0 size_flags_horizontal = 3 [node name="OverrideWidthLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] margin_top = 49.0 -margin_right = 102.0 +margin_right = 112.0 margin_bottom = 63.0 text = "Override Width" [node name="OverrideWidth" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_left = 106.0 +margin_left = 116.0 margin_top = 44.0 margin_right = 369.0 margin_bottom = 68.0 @@ -652,19 +654,18 @@ size_flags_horizontal = 3 [node name="OverrideHeightLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] margin_top = 77.0 -margin_right = 102.0 +margin_right = 112.0 margin_bottom = 91.0 text = "Override Height" [node name="OverrideHeight" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_left = 106.0 +margin_left = 116.0 margin_top = 72.0 margin_right = 369.0 margin_bottom = 96.0 size_flags_horizontal = 3 [node name="HSeparator" type="HSeparator" parent="Control/Dialogs/SettingsDialog/GridContainer"] -visible = false margin_top = 100.0 margin_right = 112.0 margin_bottom = 104.0 @@ -673,58 +674,72 @@ __meta__ = { } [node name="HSeparator2" type="HSeparator" parent="Control/Dialogs/SettingsDialog/GridContainer"] -visible = false +margin_left = 116.0 margin_top = 100.0 -margin_right = 182.0 -margin_bottom = 131.0 +margin_right = 369.0 +margin_bottom = 104.0 __meta__ = { "_edit_use_anchors_": false } [node name="AutoLaunchBurritoLinkLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -visible = false -margin_top = 104.0 +margin_top = 112.0 margin_right = 112.0 -margin_bottom = 135.0 +margin_bottom = 143.0 text = "Auto Launch Burrito Link" [node name="AutoLaunchBurritoLink" type="CheckButton" parent="Control/Dialogs/SettingsDialog/GridContainer"] -visible = false -margin_top = 100.0 -margin_right = 182.0 -margin_bottom = 140.0 +margin_left = 116.0 +margin_top = 108.0 +margin_right = 369.0 +margin_bottom = 148.0 size_flags_horizontal = 3 [node name="WinePathLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -visible = false -margin_top = 105.0 +margin_top = 157.0 margin_right = 112.0 -margin_bottom = 119.0 +margin_bottom = 171.0 text = "Wine Path" [node name="WinePath" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"] -visible = false -margin_top = 100.0 -margin_right = 182.0 -margin_bottom = 124.0 +margin_left = 116.0 +margin_top = 152.0 +margin_right = 369.0 +margin_bottom = 176.0 size_flags_horizontal = 3 [node name="EnvironmentVarsLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -visible = false -margin_top = 143.0 +margin_top = 223.0 margin_right = 112.0 -margin_bottom = 157.0 +margin_bottom = 237.0 text = "Environment Vars" [node name="EnvironmentVars" type="TextEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"] -visible = false -margin_top = 100.0 -margin_right = 182.0 -margin_bottom = 200.0 +margin_left = 116.0 +margin_top = 180.0 +margin_right = 369.0 +margin_bottom = 280.0 rect_min_size = Vector2( 0, 100 ) size_flags_horizontal = 3 +[node name="Spacer" type="Control" parent="Control/Dialogs/SettingsDialog/GridContainer"] +visible = false +margin_top = 284.0 +margin_right = 112.0 +margin_bottom = 284.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="LoadLutrisProfile" type="Button" parent="Control/Dialogs/SettingsDialog/GridContainer"] +visible = false +margin_left = 116.0 +margin_top = 284.0 +margin_right = 369.0 +margin_bottom = 304.0 +text = "Load Lutris Profile" + [node name="Border" type="Control" parent="Control"] visible = false anchor_right = 1.0 diff --git a/project.godot b/project.godot index 7cd22479..be568f6c 100644 --- a/project.godot +++ b/project.godot @@ -9,12 +9,12 @@ config_version=4 _global_script_classes=[ { -"base": "", +"base": "Node", "class": "TacoParser", "language": "NativeScript", "path": "res://tacoparser.gdns" }, { -"base": "", +"base": "Node", "class": "X11_FG", "language": "NativeScript", "path": "res://Spatial.gdns" From 49a070c59d8f94897d82e2739a8c39bdba54dbb4 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Sun, 5 Dec 2021 22:42:58 -0600 Subject: [PATCH 4/7] removing trailing whitespace from some gdscript files --- Gizmo/PointEdit.gd | 2 +- Route.gd | 4 ++-- Settings.gd | 6 +++--- SettingsDialog.gd | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gizmo/PointEdit.gd b/Gizmo/PointEdit.gd index ea6769ba..93ddfa5c 100644 --- a/Gizmo/PointEdit.gd +++ b/Gizmo/PointEdit.gd @@ -69,5 +69,5 @@ func _process(delta): ) $Plane.scale = new_scale $Pillar.scale = new_scale - + update_point() diff --git a/Route.gd b/Route.gd index f0132264..97aa155b 100644 --- a/Route.gd +++ b/Route.gd @@ -14,7 +14,7 @@ func refresh_mesh(): var tmpMesh = Mesh.new() var i = 0 var last_uv: float = 0.0 - for point_index in range(len(point_list)-1): + for point_index in range(len(point_list)-1): var point:Vector3 = point_list[point_index] var next_point:Vector3 = point_list[point_index+1] @@ -52,7 +52,7 @@ func refresh_mesh(): var st = SurfaceTool.new() st.begin(Mesh.PRIMITIVE_TRIANGLE_FAN) - for v in vertices.size(): + for v in vertices.size(): st.add_color(color) st.add_uv(UVs[v]) st.add_vertex(vertices[v]) diff --git a/Settings.gd b/Settings.gd index 2d315cbd..a6eadb8f 100644 --- a/Settings.gd +++ b/Settings.gd @@ -17,12 +17,12 @@ func _ready(): var file = File.new() file.open(CONFIG_PATH, file.READ) var text = file.get_as_text() - var datum = JSON.parse(text) + var datum = JSON.parse(text) self._config_data = JSON.parse(text).result if self._config_data == null: self._config_data = {} - + if "override_size_enabled" in self._config_data: self.override_size_enabled = self._config_data["override_size_enabled"] if "override_size_height" in self._config_data: @@ -46,7 +46,7 @@ func save(): "burrito_link_wine_path": burrito_link_wine_path, "burrito_link_env_args": burrito_link_env_args, } - + var file = File.new() file.open(CONFIG_PATH, File.WRITE) file.store_string(JSON.print(self._config_data)) diff --git a/SettingsDialog.gd b/SettingsDialog.gd index b79c0129..c3333e53 100644 --- a/SettingsDialog.gd +++ b/SettingsDialog.gd @@ -29,6 +29,6 @@ func save_settings(new_value=null): Settings.burrito_link_wine_path = wine_path.text var environment_vars: TextEdit = $GridContainer/EnvironmentVars Settings.burrito_link_env_args = environment_vars.text - + Settings.save() From 2be26b53b43bd9e35732abf9e3021ecc234d387a Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Mon, 6 Dec 2021 01:27:52 -0600 Subject: [PATCH 5/7] Adding a new setting that allows for a minimum size to be specified --- Settings.gd | 9 +++ SettingsDialog.gd | 34 ++++++---- Spatial.tscn | 170 ++++++++++++++++++++++++++++------------------ 3 files changed, 135 insertions(+), 78 deletions(-) diff --git a/Settings.gd b/Settings.gd index a6eadb8f..663f6e2f 100644 --- a/Settings.gd +++ b/Settings.gd @@ -4,6 +4,9 @@ const CONFIG_PATH = "user://settings.json" var _config_data = {} +var minimum_width: int = 800 +var minimum_height: int = 600 + var override_size_enabled: bool = false; var override_size_height: int = 1080 var override_size_width: int = 1920 @@ -23,6 +26,10 @@ func _ready(): if self._config_data == null: self._config_data = {} + if "minimum_width" in self._config_data: + self.minimum_width = self._config_data["minimum_width"] + if "minimum_height" in self._config_data: + self.minimum_height = self._config_data["minimum_height"] if "override_size_enabled" in self._config_data: self.override_size_enabled = self._config_data["override_size_enabled"] if "override_size_height" in self._config_data: @@ -39,6 +46,8 @@ func _ready(): func save(): _config_data = { + "minimum_width": minimum_width, + "minimum_height": minimum_height, "override_size_enabled": override_size_enabled, "override_size_height": override_size_height, "override_size_width": override_size_width, diff --git a/SettingsDialog.gd b/SettingsDialog.gd index c3333e53..a78b0458 100644 --- a/SettingsDialog.gd +++ b/SettingsDialog.gd @@ -1,33 +1,43 @@ extends WindowDialog func load_settings(): - var override_size: CheckButton = $GridContainer/OverrideSize + var minimum_width: LineEdit = $ScrollContainer/GridContainer/MinimumWidth + minimum_width.text = String(Settings.minimum_width) + var minimum_height: LineEdit = $ScrollContainer/GridContainer/MinimumHeight + minimum_height.text = String(Settings.minimum_height) + + var override_size: CheckButton = $ScrollContainer/GridContainer/OverrideSize override_size.pressed = Settings.override_size_enabled - var override_height: LineEdit = $GridContainer/OverrideHeight + var override_height: LineEdit = $ScrollContainer/GridContainer/OverrideHeight override_height.text = String(Settings.override_size_height) - var override_width: LineEdit = $GridContainer/OverrideWidth + var override_width: LineEdit = $ScrollContainer/GridContainer/OverrideWidth override_width.text = String(Settings.override_size_width) - var autolaunch_burrito_link: CheckButton = $GridContainer/AutoLaunchBurritoLink + var autolaunch_burrito_link: CheckButton = $ScrollContainer/GridContainer/AutoLaunchBurritoLink autolaunch_burrito_link.pressed = Settings.burrito_link_auto_launch_enabled - var wine_path: LineEdit = $GridContainer/WinePath + var wine_path: LineEdit = $ScrollContainer/GridContainer/WinePath wine_path.text = Settings.burrito_link_wine_path - var environment_vars: TextEdit = $GridContainer/EnvironmentVars + var environment_vars: TextEdit = $ScrollContainer/GridContainer/EnvironmentVars environment_vars.text = Settings.burrito_link_env_args func save_settings(new_value=null): - var override_size: CheckButton = $GridContainer/OverrideSize + var minimum_width: LineEdit = $ScrollContainer/GridContainer/MinimumWidth + Settings.minimum_width = int(minimum_width.text) + var minimum_height: LineEdit = $ScrollContainer/GridContainer/MinimumHeight + Settings.minimum_height = int(minimum_height.text) + + var override_size: CheckButton = $ScrollContainer/GridContainer/OverrideSize Settings.override_size_enabled = override_size.pressed - var override_height: LineEdit = $GridContainer/OverrideHeight + var override_height: LineEdit = $ScrollContainer/GridContainer/OverrideHeight Settings.override_size_height = int(override_height.text) - var override_width: LineEdit = $GridContainer/OverrideWidth + var override_width: LineEdit = $ScrollContainer/GridContainer/OverrideWidth Settings.override_size_width = int(override_width.text) - var autolaunch_burrito_link: CheckButton = $GridContainer/AutoLaunchBurritoLink + var autolaunch_burrito_link: CheckButton = $ScrollContainer/GridContainer/AutoLaunchBurritoLink Settings.burrito_link_auto_launch_enabled = autolaunch_burrito_link.pressed - var wine_path: LineEdit = $GridContainer/WinePath + var wine_path: LineEdit = $ScrollContainer/GridContainer/WinePath Settings.burrito_link_wine_path = wine_path.text - var environment_vars: TextEdit = $GridContainer/EnvironmentVars + var environment_vars: TextEdit = $ScrollContainer/GridContainer/EnvironmentVars Settings.burrito_link_env_args = environment_vars.text Settings.save() diff --git a/Spatial.tscn b/Spatial.tscn index 6a08e7e4..d54c654f 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -605,125 +605,161 @@ text = "Reverse Path Direction" [node name="SettingsDialog" type="WindowDialog" parent="Control/Dialogs"] visible = true -margin_left = 592.0 -margin_top = 146.0 -margin_right = 981.0 -margin_bottom = 575.0 +margin_left = 616.368 +margin_top = 40.0536 +margin_right = 1005.37 +margin_bottom = 469.054 window_title = "Settings" +resizable = true script = ExtResource( 12 ) __meta__ = { "_edit_use_anchors_": false } -[node name="GridContainer" type="GridContainer" parent="Control/Dialogs/SettingsDialog"] +[node name="ScrollContainer" type="ScrollContainer" parent="Control/Dialogs/SettingsDialog"] anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = 10.0 -margin_top = 10.0 -margin_right = -10.0 -margin_bottom = -10.0 +margin_left = 5.0 +margin_top = 5.0 +margin_bottom = -5.0 +scroll_horizontal_enabled = false +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="GridContainer" type="GridContainer" parent="Control/Dialogs/SettingsDialog/ScrollContainer"] +margin_right = 384.0 +margin_bottom = 419.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 columns = 2 __meta__ = { "_edit_use_anchors_": false } -[node name="OverrideSizeLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_top = 13.0 +[node name="MinimumWidthLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 5.0 +margin_right = 112.0 +margin_bottom = 19.0 +text = "Minimum Width" + +[node name="MinimumWidth" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_left = 116.0 +margin_right = 384.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 + +[node name="MinimumHeightLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 33.0 +margin_right = 112.0 +margin_bottom = 47.0 +text = "Minimum Height" + +[node name="MinimumHeight" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_left = 116.0 +margin_top = 28.0 +margin_right = 384.0 +margin_bottom = 52.0 +size_flags_horizontal = 3 + +[node name="OverrideSizeLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 69.0 margin_right = 112.0 -margin_bottom = 27.0 +margin_bottom = 83.0 text = "Override Size" -[node name="OverrideSize" type="CheckButton" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="OverrideSize" type="CheckButton" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 -margin_right = 369.0 -margin_bottom = 40.0 +margin_top = 56.0 +margin_right = 384.0 +margin_bottom = 96.0 size_flags_horizontal = 3 -[node name="OverrideWidthLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_top = 49.0 +[node name="OverrideWidthLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 105.0 margin_right = 112.0 -margin_bottom = 63.0 +margin_bottom = 119.0 text = "Override Width" -[node name="OverrideWidth" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="OverrideWidth" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 -margin_top = 44.0 -margin_right = 369.0 -margin_bottom = 68.0 +margin_top = 100.0 +margin_right = 384.0 +margin_bottom = 124.0 size_flags_horizontal = 3 -[node name="OverrideHeightLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_top = 77.0 +[node name="OverrideHeightLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 133.0 margin_right = 112.0 -margin_bottom = 91.0 +margin_bottom = 147.0 text = "Override Height" -[node name="OverrideHeight" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="OverrideHeight" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 -margin_top = 72.0 -margin_right = 369.0 -margin_bottom = 96.0 +margin_top = 128.0 +margin_right = 384.0 +margin_bottom = 152.0 size_flags_horizontal = 3 -[node name="HSeparator" type="HSeparator" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_top = 100.0 +[node name="HSeparator" type="HSeparator" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 156.0 margin_right = 112.0 -margin_bottom = 104.0 +margin_bottom = 160.0 __meta__ = { "_edit_use_anchors_": false } -[node name="HSeparator2" type="HSeparator" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="HSeparator2" type="HSeparator" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 -margin_top = 100.0 -margin_right = 369.0 -margin_bottom = 104.0 +margin_top = 156.0 +margin_right = 384.0 +margin_bottom = 160.0 __meta__ = { "_edit_use_anchors_": false } -[node name="AutoLaunchBurritoLinkLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_top = 112.0 +[node name="AutoLaunchBurritoLinkLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 168.0 margin_right = 112.0 -margin_bottom = 143.0 +margin_bottom = 199.0 text = "Auto Launch Burrito Link" -[node name="AutoLaunchBurritoLink" type="CheckButton" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="AutoLaunchBurritoLink" type="CheckButton" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 -margin_top = 108.0 -margin_right = 369.0 -margin_bottom = 148.0 +margin_top = 164.0 +margin_right = 384.0 +margin_bottom = 204.0 size_flags_horizontal = 3 -[node name="WinePathLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_top = 157.0 +[node name="WinePathLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 213.0 margin_right = 112.0 -margin_bottom = 171.0 +margin_bottom = 227.0 text = "Wine Path" -[node name="WinePath" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="WinePath" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 -margin_top = 152.0 -margin_right = 369.0 -margin_bottom = 176.0 +margin_top = 208.0 +margin_right = 384.0 +margin_bottom = 232.0 size_flags_horizontal = 3 -[node name="EnvironmentVarsLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"] -margin_top = 223.0 +[node name="EnvironmentVarsLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] +margin_top = 279.0 margin_right = 112.0 -margin_bottom = 237.0 +margin_bottom = 293.0 text = "Environment Vars" -[node name="EnvironmentVars" type="TextEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="EnvironmentVars" type="TextEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 -margin_top = 180.0 -margin_right = 369.0 -margin_bottom = 280.0 +margin_top = 236.0 +margin_right = 384.0 +margin_bottom = 336.0 rect_min_size = Vector2( 0, 100 ) size_flags_horizontal = 3 -[node name="Spacer" type="Control" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="Spacer" type="Control" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] visible = false margin_top = 284.0 margin_right = 112.0 @@ -732,11 +768,11 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="LoadLutrisProfile" type="Button" parent="Control/Dialogs/SettingsDialog/GridContainer"] +[node name="LoadLutrisProfile" type="Button" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] visible = false margin_left = 116.0 margin_top = 284.0 -margin_right = 369.0 +margin_right = 384.0 margin_bottom = 304.0 text = "Load Lutris Profile" @@ -863,9 +899,11 @@ material/0 = SubResource( 4 ) [connection signal="pressed" from="Control/Dialogs/NodeEditorDialog/ScrollContainer/VBoxContainer/SetActivePath" to="." method="_on_SetActivePath_pressed"] [connection signal="pressed" from="Control/Dialogs/NodeEditorDialog/ScrollContainer/VBoxContainer/ReversePathDirection" to="." method="_on_ReversePathDirection_pressed"] [connection signal="hide" from="Control/Dialogs/SettingsDialog" to="." method="_on_NodeEditorDialog_hide"] -[connection signal="pressed" from="Control/Dialogs/SettingsDialog/GridContainer/OverrideSize" to="Control/Dialogs/SettingsDialog" method="save_settings"] -[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/OverrideWidth" to="Control/Dialogs/SettingsDialog" method="save_settings"] -[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/OverrideHeight" to="Control/Dialogs/SettingsDialog" method="save_settings"] -[connection signal="pressed" from="Control/Dialogs/SettingsDialog/GridContainer/AutoLaunchBurritoLink" to="Control/Dialogs/SettingsDialog" method="save_settings"] -[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/WinePath" to="Control/Dialogs/SettingsDialog" method="save_settings"] -[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/EnvironmentVars" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/MinimumWidth" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/MinimumHeight" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="pressed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/OverrideSize" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/OverrideWidth" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/OverrideHeight" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="pressed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/AutoLaunchBurritoLink" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/WinePath" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/EnvironmentVars" to="Control/Dialogs/SettingsDialog" method="save_settings"] From c1d7cc05f951763d52cf4eec7ff1f0c54718ee85 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Mon, 6 Dec 2021 01:42:15 -0600 Subject: [PATCH 6/7] forcing minimum size value from settings when resizing window --- Spatial.gd | 6 ++++++ Spatial.tscn | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Spatial.gd b/Spatial.gd index 1de7f13c..7be06855 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -293,6 +293,12 @@ func decode_context_packet(spb: StreamPeerBuffer): var size_tuple = x11_fg.get_window_geometry(x11_window_id_gw2) size.x = size_tuple[0] size.y = size_tuple[1] + + if size.x < Settings.minimum_width: + size.x = Settings.minimum_width + if size.y < Settings.minimum_height: + size.y = Settings.minimum_height + OS.window_size = size var identity_length: int = spb.get_32() var identity_str = spb.get_utf8_string(identity_length) diff --git a/Spatial.tscn b/Spatial.tscn index d54c654f..825ab9a8 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -193,14 +193,14 @@ __meta__ = { } [node name="MainMenu" type="WindowDialog" parent="Control/Dialogs"] -visible = true -margin_left = 48.1808 -margin_top = 88.7138 -margin_right = 261.181 -margin_bottom = 714.714 +margin_left = 39.0 +margin_top = 71.0 +margin_right = 252.0 +margin_bottom = 583.0 window_title = "Main Menu" resizable = true __meta__ = { +"_edit_group_": true, "_edit_use_anchors_": false } @@ -604,15 +604,15 @@ disabled = true text = "Reverse Path Direction" [node name="SettingsDialog" type="WindowDialog" parent="Control/Dialogs"] -visible = true -margin_left = 616.368 -margin_top = 40.0536 -margin_right = 1005.37 -margin_bottom = 469.054 +margin_left = 319.718 +margin_top = 105.74 +margin_right = 708.72 +margin_bottom = 534.741 window_title = "Settings" resizable = true script = ExtResource( 12 ) __meta__ = { +"_edit_group_": true, "_edit_use_anchors_": false } @@ -628,7 +628,7 @@ __meta__ = { } [node name="GridContainer" type="GridContainer" parent="Control/Dialogs/SettingsDialog/ScrollContainer"] -margin_right = 384.0 +margin_right = 384.002 margin_bottom = 419.0 size_flags_horizontal = 3 size_flags_vertical = 3 From 72113184321c2082cdbdfff626ab6a6ddba6d52c Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Mon, 6 Dec 2021 01:50:35 -0600 Subject: [PATCH 7/7] making the size settings more intuitive to understand --- Spatial.gd | 16 ++++++++++------ Spatial.tscn | 10 +++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Spatial.gd b/Spatial.gd index 7be06855..fd3702c9 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -55,7 +55,11 @@ func _ready(): x11_window_id_burrito = OS.get_native_handle(OS.WINDOW_HANDLE) OS.window_maximized = false # Start off with a small size before GW2 client is up - OS.window_size = Vector2(800, 600) + + if Settings.override_size_enabled: + OS.window_size = Vector2(Settings.override_size_width, Settings.override_size_height) + else: + OS.window_size = Vector2(Settings.minimum_width, Settings.minimum_height) # Postion at top left corner OS.set_window_position(Vector2(0,0)) set_minimal_mouse_block() @@ -285,7 +289,7 @@ func decode_context_packet(spb: StreamPeerBuffer): if !is_transient: is_transient = x11_fg.set_transient_for(x11_window_id_burrito, x11_window_id_gw2) - var size = Vector2(800, 600) + var size = Vector2(Settings.minimum_width, Settings.minimum_height) if Settings.override_size_enabled: size.x = Settings.override_size_width size.y = Settings.override_size_height @@ -294,10 +298,10 @@ func decode_context_packet(spb: StreamPeerBuffer): size.x = size_tuple[0] size.y = size_tuple[1] - if size.x < Settings.minimum_width: - size.x = Settings.minimum_width - if size.y < Settings.minimum_height: - size.y = Settings.minimum_height + if size.x < Settings.minimum_width: + size.x = Settings.minimum_width + if size.y < Settings.minimum_height: + size.y = Settings.minimum_height OS.window_size = size var identity_length: int = spb.get_32() diff --git a/Spatial.tscn b/Spatial.tscn index 825ab9a8..5ea7f43e 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -604,6 +604,7 @@ disabled = true text = "Reverse Path Direction" [node name="SettingsDialog" type="WindowDialog" parent="Control/Dialogs"] +visible = true margin_left = 319.718 margin_top = 105.74 margin_right = 708.72 @@ -612,7 +613,6 @@ window_title = "Settings" resizable = true script = ExtResource( 12 ) __meta__ = { -"_edit_group_": true, "_edit_use_anchors_": false } @@ -629,7 +629,7 @@ __meta__ = { [node name="GridContainer" type="GridContainer" parent="Control/Dialogs/SettingsDialog/ScrollContainer"] margin_right = 384.002 -margin_bottom = 419.0 +margin_bottom = 419.001 size_flags_horizontal = 3 size_flags_vertical = 3 columns = 2 @@ -666,7 +666,7 @@ size_flags_horizontal = 3 margin_top = 69.0 margin_right = 112.0 margin_bottom = 83.0 -text = "Override Size" +text = "Use Fixed Size" [node name="OverrideSize" type="CheckButton" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 @@ -679,7 +679,7 @@ size_flags_horizontal = 3 margin_top = 105.0 margin_right = 112.0 margin_bottom = 119.0 -text = "Override Width" +text = "Fixed Width" [node name="OverrideWidth" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0 @@ -692,7 +692,7 @@ size_flags_horizontal = 3 margin_top = 133.0 margin_right = 112.0 margin_bottom = 147.0 -text = "Override Height" +text = "Fixed Height" [node name="OverrideHeight" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"] margin_left = 116.0