|  |  |  | @ -26,7 +26,6 @@ typedef struct EditorContextStruct { | 
		
	
		
			
				|  |  |  |  |   vec4 saved_colors[12]; | 
		
	
		
			
				|  |  |  |  |   vec4 current_color; | 
		
	
		
			
				|  |  |  |  |   vec4 color_string; | 
		
	
		
			
				|  |  |  |  |   bool selecting_color; | 
		
	
		
			
				|  |  |  |  | } EditorContext; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | typedef struct ClientContextStruct { | 
		
	
	
		
			
				
					|  |  |  | @ -35,9 +34,6 @@ typedef struct ClientContextStruct { | 
		
	
		
			
				|  |  |  |  |   UIContext* ui; | 
		
	
		
			
				|  |  |  |  |   HexContext* hex; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   uint32_t clicked_container; | 
		
	
		
			
				|  |  |  |  |   uint32_t clicked_element; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   double  cursor[2]; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   vec3    position; | 
		
	
	
		
			
				
					|  |  |  | @ -120,14 +116,14 @@ VkResult color_ui(ClientContext* context) { | 
		
	
		
			
				|  |  |  |  |       .color = {{0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 0.4}}, | 
		
	
		
			
				|  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |     { | 
		
	
		
			
				|  |  |  |  |       .type = 0x03, | 
		
	
		
			
				|  |  |  |  |       .type = DRAWABLE_TYPE_RECT_HSV, | 
		
	
		
			
				|  |  |  |  |       .pos = {2, 2}, | 
		
	
		
			
				|  |  |  |  |       .size = {130, 130}, | 
		
	
		
			
				|  |  |  |  |       .color = {{0, 0, 1, 1}, {0, 1, 1, 1}, {0, 0, 0, 1}, {0, 1, 0, 1}}, | 
		
	
		
			
				|  |  |  |  |       .id = 0x01, | 
		
	
		
			
				|  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |     { | 
		
	
		
			
				|  |  |  |  |       .type = 0x03, | 
		
	
		
			
				|  |  |  |  |       .type = DRAWABLE_TYPE_RECT_HSV, | 
		
	
		
			
				|  |  |  |  |       .pos = {134, 2}, | 
		
	
		
			
				|  |  |  |  |       .size = {10, 130}, | 
		
	
		
			
				|  |  |  |  |       .color = {{0, 1, 1, 1}, {0, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}, | 
		
	
	
		
			
				
					|  |  |  | @ -409,44 +405,44 @@ VkResult update_region_info_ui(ClientContext* context) { | 
		
	
		
			
				|  |  |  |  |   snprintf(temp, | 
		
	
		
			
				|  |  |  |  |       sizeof(temp), | 
		
	
		
			
				|  |  |  |  |       "Region %4d", context->editor.selected_region); | 
		
	
		
			
				|  |  |  |  |   VK_RESULT(update_ui_string(temp, 0, 0, 0, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |   VK_RESULT(update_ui_string(temp, 0x01, 0, 0, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   if(selected_region == NULL) { | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0, 0, 1, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x01, 0, 1, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0, 0, 2, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x01, 0, 2, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0, 0, 3, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x01, 0, 3, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |   } else { | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "Q: %4d", selected_region->data.q); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0, 0, 1, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x01, 0, 1, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "R: %4d", selected_region->data.r); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0, 0, 2, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x01, 0, 2, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "Y: %4d", selected_region->data.y); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0, 0, 3, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x01, 0, 3, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   return VK_SUCCESS; | 
		
	
	
		
			
				
					|  |  |  | @ -463,49 +459,49 @@ VkResult update_hex_info_ui(ClientContext* context) { | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 0, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 0, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 1, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 1, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 2, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 2, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 3, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 3, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 4, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 4, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 5, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 5, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 6, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 6, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         ""); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 7, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 7, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |   } else { | 
		
	
		
			
				|  |  |  |  |     GPUHex* hex = ®ion->data.hexes[context->hex->data.clicked_hex]; | 
		
	
		
			
				|  |  |  |  |     snprintf(temp, | 
		
	
	
		
			
				
					|  |  |  | @ -513,7 +509,7 @@ VkResult update_hex_info_ui(ClientContext* context) { | 
		
	
		
			
				|  |  |  |  |         "%d-%d", | 
		
	
		
			
				|  |  |  |  |         context->hex->data.clicked_region, | 
		
	
		
			
				|  |  |  |  |         context->hex->data.clicked_hex); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 0, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 0, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     int32_t hex_index = context->hex->data.clicked_hex; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -526,6 +522,7 @@ VkResult update_hex_info_ui(ClientContext* context) { | 
		
	
		
			
				|  |  |  |  |       side = floor(ring/radius); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     // TODO: fix, these are wrong lmao
 | 
		
	
		
			
				|  |  |  |  |     int32_t hex_q = hex_starts_qr[side][0]*radius + hex_directions_qr[side][0]*(ring-(radius*side)); | 
		
	
		
			
				|  |  |  |  |     int32_t hex_r = hex_starts_qr[side][1]*radius + hex_directions_qr[side][1]*(ring-(radius*side)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -540,49 +537,49 @@ VkResult update_hex_info_ui(ClientContext* context) { | 
		
	
		
			
				|  |  |  |  |         world_r, | 
		
	
		
			
				|  |  |  |  |         region->data.y, | 
		
	
		
			
				|  |  |  |  |         context->hex->data.clicked_vertex); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 1, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 1, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "%02.02f %02.02f %02.02f", | 
		
	
		
			
				|  |  |  |  |         hex->height[0], hex->height[1], hex->height[2]); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 2, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 2, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "%02.02f %02.02f %02.02f", | 
		
	
		
			
				|  |  |  |  |         hex->height[3], hex->height[4], hex->height[5]); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 3, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 3, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "%08X", | 
		
	
		
			
				|  |  |  |  |         hex->color[0]); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 4, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 4, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "%08X %08X", | 
		
	
		
			
				|  |  |  |  |         hex->color[1], hex->color[2]); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 5, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 5, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "%08X %08X", | 
		
	
		
			
				|  |  |  |  |         hex->color[3], hex->color[4]); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 6, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 6, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     snprintf( | 
		
	
		
			
				|  |  |  |  |         temp, | 
		
	
		
			
				|  |  |  |  |         sizeof(temp), | 
		
	
		
			
				|  |  |  |  |         "%08X %08X", | 
		
	
		
			
				|  |  |  |  |         hex->color[5], hex->color[6]); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 1, 0, 7, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |     VK_RESULT(update_ui_string(temp, 0x02, 0, 7, context->ui, context->render)); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   return VK_SUCCESS; | 
		
	
	
		
			
				
					|  |  |  | @ -602,8 +599,6 @@ VkResult main_thread(ClientContext* context) { | 
		
	
		
			
				|  |  |  |  |     double delta_time = (frame_time - last_frame_time); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     // Reset callback variables
 | 
		
	
		
			
				|  |  |  |  |     context->clicked_element   = 0x00000000; | 
		
	
		
			
				|  |  |  |  |     context->clicked_container = 0x00000000; | 
		
	
		
			
				|  |  |  |  |     context->zoom = 0; | 
		
	
		
			
				|  |  |  |  |     context->cur_spin[0] = 0; | 
		
	
		
			
				|  |  |  |  |     context->cur_spin[1] = 0; | 
		
	
	
		
			
				
					|  |  |  | @ -688,9 +683,13 @@ VkResult main_thread(ClientContext* context) { | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { | 
		
	
		
			
				|  |  |  |  |   ClientContext* context = (ClientContext*)glfwGetWindowUserPointer(window); | 
		
	
		
			
				|  |  |  |  |   (void)scancode; | 
		
	
		
			
				|  |  |  |  |   (void)mods; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   ClientContext* context = (ClientContext*)glfwGetWindowUserPointer(window); | 
		
	
		
			
				|  |  |  |  |   if(context->ui->active_captures & UI_EVENT_KEY) { | 
		
	
		
			
				|  |  |  |  |     // Pass key to active element
 | 
		
	
		
			
				|  |  |  |  |   } else { | 
		
	
		
			
				|  |  |  |  |     switch(key) { | 
		
	
		
			
				|  |  |  |  |       case GLFW_KEY_A: | 
		
	
		
			
				|  |  |  |  |         if(action == GLFW_PRESS) { | 
		
	
	
		
			
				
					|  |  |  | @ -920,29 +919,27 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         break; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | bool contains(double* point, GPUContainer* container, GPUDrawable* rect) { | 
		
	
		
			
				|  |  |  |  |   vec2 pos = { | 
		
	
		
			
				|  |  |  |  |     container->offset[0] + rect->pos[0], | 
		
	
		
			
				|  |  |  |  |     container->offset[1] + rect->pos[1], | 
		
	
		
			
				|  |  |  |  |   }; | 
		
	
		
			
				|  |  |  |  |   return (point[0] >= pos[0] && point[0] <= pos[0] + rect->size[0]) && | 
		
	
		
			
				|  |  |  |  |          (point[1] >= pos[1] && point[1] <= pos[1] + rect->size[1]) && | 
		
	
		
			
				|  |  |  |  |          (point[0] >= container->offset[0] && point[0] <= container->offset[0] + container->size[0]) && | 
		
	
		
			
				|  |  |  |  |          (point[1] >= container->offset[1] && point[1] <= container->offset[1] + container->size[1]); | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | void button_callback(GLFWwindow* window, int button, int action, int mods) { | 
		
	
		
			
				|  |  |  |  |   (void)mods; | 
		
	
		
			
				|  |  |  |  |   double cursor[2]; | 
		
	
		
			
				|  |  |  |  |   uint32_t container; | 
		
	
		
			
				|  |  |  |  |   uint32_t element; | 
		
	
		
			
				|  |  |  |  |   vec2 position; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { | 
		
	
		
			
				|  |  |  |  |   ClientContext* context = (ClientContext*)glfwGetWindowUserPointer(window); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   (void)mods; | 
		
	
		
			
				|  |  |  |  |   (void)context; | 
		
	
		
			
				|  |  |  |  |   double cursor[2]; | 
		
	
		
			
				|  |  |  |  |   glfwGetCursorPos(window, &cursor[0], &cursor[1]); | 
		
	
		
			
				|  |  |  |  |   switch(button) { | 
		
	
		
			
				|  |  |  |  |   // Handle camera hover
 | 
		
	
		
			
				|  |  |  |  |   case GLFW_MOUSE_BUTTON_RIGHT: | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   if(context->ui->active_captures & UI_EVENT_BUTTON) { | 
		
	
		
			
				|  |  |  |  |     // Pass button to active element
 | 
		
	
		
			
				|  |  |  |  |   } else if(ui_intersect(cursor, context->render, context->ui, &container, &element, position)) { | 
		
	
		
			
				|  |  |  |  |     // Pass button to active UI element
 | 
		
	
		
			
				|  |  |  |  |   } else { | 
		
	
		
			
				|  |  |  |  |     update_hex_click(cursor, context->hex, context->render); | 
		
	
		
			
				|  |  |  |  |     if(button == GLFW_MOUSE_BUTTON_MIDDLE) { | 
		
	
		
			
				|  |  |  |  |       if(action == GLFW_PRESS) { | 
		
	
		
			
				|  |  |  |  |         glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); | 
		
	
		
			
				|  |  |  |  |         context->camera_mode = true; | 
		
	
	
		
			
				
					|  |  |  | @ -950,57 +947,51 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) | 
		
	
		
			
				|  |  |  |  |         glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | 
		
	
		
			
				|  |  |  |  |         context->camera_mode = false; | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |     break; | 
		
	
		
			
				|  |  |  |  |   case GLFW_MOUSE_BUTTON_LEFT: | 
		
	
		
			
				|  |  |  |  |     if(action == GLFW_PRESS) { | 
		
	
		
			
				|  |  |  |  |       // Hex intersection
 | 
		
	
		
			
				|  |  |  |  |       update_hex_click(cursor, context->hex, context->render); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |       // UI intersections
 | 
		
	
		
			
				|  |  |  |  |       for(uint32_t c = 0; c < context->ui->max_containers; c++) { | 
		
	
		
			
				|  |  |  |  |         if(context->ui->containers[c].id == 0x00000000) { | 
		
	
		
			
				|  |  |  |  |           continue; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         for(uint32_t l = 0; l < context->ui->containers[c].layer_count; l++) { | 
		
	
		
			
				|  |  |  |  |           for(uint32_t d = 0; d < context->ui->containers[c].layers[l].data.num_drawables; d++) { | 
		
	
		
			
				|  |  |  |  |             if(context->ui->containers[c].layers[l].drawables_buffer[d].id == 0x00000000) { | 
		
	
		
			
				|  |  |  |  |               continue; | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |             if(contains( | 
		
	
		
			
				|  |  |  |  |                   cursor, | 
		
	
		
			
				|  |  |  |  |                   &context->ui->containers[c].data, | 
		
	
		
			
				|  |  |  |  |                   &context->ui->containers[c].layers[l].drawables_buffer[d])) { | 
		
	
		
			
				|  |  |  |  |               context->clicked_container = context->ui->containers[c].id; | 
		
	
		
			
				|  |  |  |  |               context->clicked_element = context->ui->containers[c].layers[l].drawables_buffer[d].id; | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |           } | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     break; | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { | 
		
	
		
			
				|  |  |  |  |   ClientContext* context = (ClientContext*)glfwGetWindowUserPointer(window); | 
		
	
		
			
				|  |  |  |  |   (void)xoffset; | 
		
	
		
			
				|  |  |  |  |   uint32_t container; | 
		
	
		
			
				|  |  |  |  |   uint32_t element; | 
		
	
		
			
				|  |  |  |  |   vec2 position; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   ClientContext* context = (ClientContext*)glfwGetWindowUserPointer(window); | 
		
	
		
			
				|  |  |  |  |   if(context->ui->active_captures & UI_EVENT_SCROLL) { | 
		
	
		
			
				|  |  |  |  |     // Pass scroll to active element
 | 
		
	
		
			
				|  |  |  |  |   } else if(ui_intersect(context->cursor, context->render, context->ui, &container, &element, position)) { | 
		
	
		
			
				|  |  |  |  |     // Pass scroll to hovered element
 | 
		
	
		
			
				|  |  |  |  |   } else { | 
		
	
		
			
				|  |  |  |  |     context->zoom = -yoffset; | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos) { | 
		
	
		
			
				|  |  |  |  | void cursor_callback(GLFWwindow* window, double xpos, double ypos) { | 
		
	
		
			
				|  |  |  |  |   ClientContext* context = (ClientContext*)glfwGetWindowUserPointer(window); | 
		
	
		
			
				|  |  |  |  |   if(context->camera_mode == true) { | 
		
	
		
			
				|  |  |  |  |     context->cur_spin[0] = (xpos - context->cursor[0])/context->render->swapchain_extent.width*-100; | 
		
	
		
			
				|  |  |  |  |     context->cur_spin[1] = (ypos - context->cursor[1])/context->render->swapchain_extent.height*100; | 
		
	
		
			
				|  |  |  |  |   uint32_t container; | 
		
	
		
			
				|  |  |  |  |   uint32_t element; | 
		
	
		
			
				|  |  |  |  |   vec2 position; | 
		
	
		
			
				|  |  |  |  |   vec2 last_cursor = { | 
		
	
		
			
				|  |  |  |  |     context->cursor[0], | 
		
	
		
			
				|  |  |  |  |     context->cursor[1], | 
		
	
		
			
				|  |  |  |  |   }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   context->cursor[0] = xpos; | 
		
	
		
			
				|  |  |  |  |   context->cursor[1] = ypos; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   if(context->camera_mode == true) { | 
		
	
		
			
				|  |  |  |  |     context->cur_spin[0] = (xpos - last_cursor[0])/context->render->swapchain_extent.width*-100; | 
		
	
		
			
				|  |  |  |  |     context->cur_spin[1] = (ypos - last_cursor[1])/context->render->swapchain_extent.height*100; | 
		
	
		
			
				|  |  |  |  |   } else { | 
		
	
		
			
				|  |  |  |  |     if(context->ui->active_captures & UI_EVENT_CURSOR) { | 
		
	
		
			
				|  |  |  |  |       // Pass cursor to active element
 | 
		
	
		
			
				|  |  |  |  |     } else if(ui_intersect(context->cursor, context->render, context->ui, &container, &element, position)) { | 
		
	
		
			
				|  |  |  |  |       // Pass cursor to hovered element
 | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |     context->cursor[0] = xpos; | 
		
	
		
			
				|  |  |  |  |     context->cursor[1] = ypos; | 
		
	
		
			
				|  |  |  |  |       update_hex_hover(context->cursor, context->hex, context->render); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | int main() { | 
		
	
	
		
			
				
					|  |  |  | @ -1035,9 +1026,9 @@ int main() { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   glfwSetWindowUserPointer(context.window, &context); | 
		
	
		
			
				|  |  |  |  |   glfwSetKeyCallback(context.window, key_callback); | 
		
	
		
			
				|  |  |  |  |   glfwSetMouseButtonCallback(context.window, mouse_button_callback); | 
		
	
		
			
				|  |  |  |  |   glfwSetMouseButtonCallback(context.window, button_callback); | 
		
	
		
			
				|  |  |  |  |   glfwSetScrollCallback(context.window, scroll_callback); | 
		
	
		
			
				|  |  |  |  |   glfwSetCursorPosCallback(context.window, cursor_pos_callback); | 
		
	
		
			
				|  |  |  |  |   glfwSetCursorPosCallback(context.window, cursor_callback); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   int error; | 
		
	
		
			
				|  |  |  |  |   VkResult result; | 
		
	
	
		
			
				
					|  |  |  | 
 |