More zoom WIP
This commit is contained in:
		
							parent
							
								
									25e90c350f
								
							
						
					
					
						commit
						d987018664
					
				| @ -58,7 +58,7 @@ class Conquest(commands.Cog): | |||||||
| 
 | 
 | ||||||
|         self.asset_path: Optional[pathlib.Path] = None |         self.asset_path: Optional[pathlib.Path] = None | ||||||
| 
 | 
 | ||||||
|         self.current_games: Dict[int, Optional[ConquestGame]] = defaultdict(lambda: None)  # key, value = guild.id, game_name |         self.current_games: Dict[int, Optional[ConquestGame]] = defaultdict(lambda: None)  # key: guild_id | ||||||
|         self.map_data = {}  # key, value = guild.id, ConquestGame |         self.map_data = {}  # key, value = guild.id, ConquestGame | ||||||
| 
 | 
 | ||||||
|         self.mm: Optional[MapMaker] = None |         self.mm: Optional[MapMaker] = None | ||||||
| @ -462,10 +462,7 @@ class Conquest(commands.Cog): | |||||||
|             await ctx.send_help() |             await ctx.send_help() | ||||||
|             return |             return | ||||||
| 
 | 
 | ||||||
|         map_folder = await self._get_current_map_folder(ctx.guild) |         zoomed_path = await self.current_games[ctx.guild.id].create_zoomed_map(x, y, zoom, out_of_date=True) | ||||||
|         zoomed_path = await self._create_zoomed_map( |  | ||||||
|             map_folder, map_folder / f"current.{self.ext}", x, y, zoom |  | ||||||
|         ) |  | ||||||
| 
 | 
 | ||||||
|         await ctx.send(file=discord.File(fp=zoomed_path, filename=f"current_zoomed.{self.ext}")) |         await ctx.send(file=discord.File(fp=zoomed_path, filename=f"current_zoomed.{self.ext}")) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -45,9 +45,6 @@ class ConquestGame: | |||||||
|         self.zoom_is_out_of_date = True |         self.zoom_is_out_of_date = True | ||||||
| 
 | 
 | ||||||
|     async def create_zoomed_map(self, x, y, zoom, **kwargs): |     async def create_zoomed_map(self, x, y, zoom, **kwargs): | ||||||
|         if not self.zoom_is_out_of_date: |  | ||||||
|             return self.zoomed_map |  | ||||||
| 
 |  | ||||||
|         current_map = Image.open(self.current_map_folder) |         current_map = Image.open(self.current_map_folder) | ||||||
| 
 | 
 | ||||||
|         w, h = current_map.size |         w, h = current_map.size | ||||||
| @ -67,8 +64,10 @@ class ConquestGame: | |||||||
| 
 | 
 | ||||||
|         map_path = self.current_map |         map_path = self.current_map | ||||||
| 
 | 
 | ||||||
|         if zoom_data["enabled"]: |         if zoom_data["enabled"]:  # Send zoomed map instead of current map | ||||||
|             map_path = await self.create_zoomed_map(**zoom_data)  # Send zoomed map instead of current map |             map_path = self.zoomed_map | ||||||
|  |             if self.zoom_is_out_of_date: | ||||||
|  |                 await self.create_zoomed_map(**zoom_data) | ||||||
| 
 | 
 | ||||||
|         return discord.File(fp=map_path, filename=filename) |         return discord.File(fp=map_path, filename=filename) | ||||||
| 
 | 
 | ||||||
| @ -79,6 +78,8 @@ class ConquestGame: | |||||||
|         with self.settings_json.open("w+") as zoom_json: |         with self.settings_json.open("w+") as zoom_json: | ||||||
|             json.dump({"enabled": False}, zoom_json, sort_keys=True, indent=4) |             json.dump({"enabled": False}, zoom_json, sort_keys=True, indent=4) | ||||||
| 
 | 
 | ||||||
|  |         self.zoom_is_out_of_date = True | ||||||
|  | 
 | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
|     async def set_zoom(self, x, y, zoom): |     async def set_zoom(self, x, y, zoom): | ||||||
| @ -89,6 +90,8 @@ class ConquestGame: | |||||||
|         zoom_data["y"] = y |         zoom_data["y"] = y | ||||||
|         zoom_data["zoom"] = zoom |         zoom_data["zoom"] = zoom | ||||||
| 
 | 
 | ||||||
|  |         self.zoom_is_out_of_date = True | ||||||
|  | 
 | ||||||
|         with self.settings_json.open("w+") as zoom_json: |         with self.settings_json.open("w+") as zoom_json: | ||||||
|             json.dump(zoom_data, zoom_json, sort_keys=True, indent=4) |             json.dump(zoom_data, zoom_json, sort_keys=True, indent=4) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 bobloy
						bobloy