|  |  | @ -16,14 +16,23 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <math.h> |  |  |  | #include <math.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <stdlib.h> |  |  |  | #include <stdlib.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct EditorContextStruct {  |  |  |  | typedef struct EditorDataStruct {  | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   uint32_t selected_region; |  |  |  |   uint32_t selected_region; | 
			
		
	
		
		
			
				
					
					|  |  |  |   uint32_t last_selected_region; |  |  |  |   uint32_t last_selected_region; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   uint32_t last_clicked_region; |  |  |  |   uint32_t last_clicked_region; | 
			
		
	
		
		
			
				
					
					|  |  |  |   uint32_t last_clicked_hex; |  |  |  |   uint32_t last_clicked_hex; | 
			
		
	
		
		
			
				
					
					|  |  |  |   uint32_t last_clicked_vertex; |  |  |  |   uint32_t last_clicked_vertex; | 
			
		
	
		
		
			
				
					
					|  |  |  | } EditorContext; |  |  |  | } EditorData; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #define COLOR_PICK_CONTAINER_ID 0x03 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | typedef struct ColorUIDataStruct { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   double current_hsv[3]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   vec4 current; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   vec4 saved[12]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   char string[10]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   int string_len; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } ColorUIData; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct ClientContextStruct { |  |  |  | typedef struct ClientContextStruct { | 
			
		
	
		
		
			
				
					
					|  |  |  |   GLFWwindow* window; |  |  |  |   GLFWwindow* window; | 
			
		
	
	
		
		
			
				
					|  |  | @ -48,7 +57,8 @@ typedef struct ClientContextStruct { | 
			
		
	
		
		
			
				
					
					|  |  |  |   float   zoom_speed; |  |  |  |   float   zoom_speed; | 
			
		
	
		
		
			
				
					
					|  |  |  |   float   move_speed; |  |  |  |   float   move_speed; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   EditorContext editor; |  |  |  |   EditorData editor; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   ColorUIData color; | 
			
		
	
		
		
			
				
					
					|  |  |  | } ClientContext; |  |  |  | } ClientContext; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void* network_thread(void* data) { |  |  |  | void* network_thread(void* data) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -58,6 +68,11 @@ void* network_thread(void* data) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   return NULL; |  |  |  |   return NULL; | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | uint32_t hex_color(vec4 color) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   // TODO: implement vec4 -> uint32 color conversion
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   return 0x0000000; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | uint32_t add_hex_region(ClientContext* context) { |  |  |  | uint32_t add_hex_region(ClientContext* context) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   HexRegion* region; |  |  |  |   HexRegion* region; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -92,15 +107,6 @@ uint32_t add_hex_region(ClientContext* context) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   return i; |  |  |  |   return i; | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | #define COLOR_PICK_CONTAINER_ID 0x03 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct ColorUIDataStruct { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   double current_hsv[3]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   vec4 current; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   vec4 saved[12]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   char string[10]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   int string_len; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } ColorUIData; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | void update_hex_string(UIContext* ui, RenderContext* gpu, ColorUIData* data) { |  |  |  | void update_hex_string(UIContext* ui, RenderContext* gpu, ColorUIData* data) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   snprintf(data->string, 10, "#%02X%02X%02X%02X", |  |  |  |   snprintf(data->string, 10, "#%02X%02X%02X%02X", | 
			
		
	
		
		
			
				
					
					|  |  |  |       (uint)rintf(data->current[0]*255), |  |  |  |       (uint)rintf(data->current[0]*255), | 
			
		
	
	
		
		
			
				
					|  |  | @ -607,7 +613,7 @@ VkResult color_ui(ClientContext* context) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     .num_drawables = sizeof(drawables)/sizeof(GPUDrawable), |  |  |  |     .num_drawables = sizeof(drawables)/sizeof(GPUDrawable), | 
			
		
	
		
		
			
				
					
					|  |  |  |   }; |  |  |  |   }; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   ColorUIData* data = malloc(sizeof(ColorUIData)); |  |  |  |   ColorUIData* data = &context->color; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   data->string_len = 8; |  |  |  |   data->string_len = 8; | 
			
		
	
		
		
			
				
					
					|  |  |  |   data->string[0] = '#'; |  |  |  |   data->string[0] = '#'; | 
			
		
	
		
		
			
				
					
					|  |  |  |   data->string[1] = '0'; |  |  |  |   data->string[1] = '0'; | 
			
		
	
	
		
		
			
				
					|  |  | @ -1382,6 +1388,26 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |       break; |  |  |  |       break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     case GLFW_KEY_E: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       if(action == GLFW_PRESS) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         HexRegion* region = context->hex->regions[context->hex->data.clicked_region]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if(region != NULL) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           region->data.hexes[context->hex->data.clicked_hex].color[context->hex->data.clicked_vertex] = hex_color(context->color.current);  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           add_transfer( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               ®ion->data.hexes[context->hex->data.clicked_hex].color[context->hex->data.clicked_vertex], | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               region->region, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               offsetof(GPUHexRegion, hexes) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               + sizeof(GPUHex)*context->hex->data.clicked_hex | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               + offsetof(GPUHex, color) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               + sizeof(uint32_t)*(context->hex->data.clicked_vertex), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               sizeof(uint32_t), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               context->render->current_frame, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               context->render); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           update_hex_info_ui(context); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       break; | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |