Don't use os, more mapmaker
This commit is contained in:
parent
a1b89c9f9d
commit
07b90c30a0
@ -1,6 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import os
|
|
||||||
import pathlib
|
import pathlib
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@ -38,11 +37,11 @@ class Conquest(commands.Cog):
|
|||||||
|
|
||||||
self.custom_map_folder = self.data_path / "custom_maps"
|
self.custom_map_folder = self.data_path / "custom_maps"
|
||||||
if not self.custom_map_folder.exists() or not self.custom_map_folder.is_dir():
|
if not self.custom_map_folder.exists() or not self.custom_map_folder.is_dir():
|
||||||
os.makedirs(self.custom_map_folder)
|
self.custom_map_folder.mkdir()
|
||||||
|
|
||||||
self.current_map_folder = self.data_path / "current_maps"
|
self.current_map_folder = self.data_path / "current_maps"
|
||||||
if not self.current_map_folder.exists() or not self.current_map_folder.is_dir():
|
if not self.current_map_folder.exists() or not self.current_map_folder.is_dir():
|
||||||
os.makedirs(self.current_map_folder)
|
self.current_map_folder.mkdir()
|
||||||
|
|
||||||
self.asset_path: Optional[pathlib.Path] = None
|
self.asset_path: Optional[pathlib.Path] = None
|
||||||
|
|
||||||
@ -171,8 +170,6 @@ class Conquest(commands.Cog):
|
|||||||
await ctx.send("Cancelled")
|
await ctx.send("Cancelled")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@mapmaker.command(name="upload")
|
@mapmaker.command(name="upload")
|
||||||
async def _mapmaker_upload(self, ctx: commands.Context, map_path=""):
|
async def _mapmaker_upload(self, ctx: commands.Context, map_path=""):
|
||||||
"""Load a map image to be modified. Upload one with this command or provide a path"""
|
"""Load a map image to be modified. Upload one with this command or provide a path"""
|
||||||
@ -194,10 +191,13 @@ class Conquest(commands.Cog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.mm_current_map["im"] = Image.open(map_path)
|
self.mm_current_map["im"] = Image.open(map_path)
|
||||||
|
self.mm_current_map["extension"] = map_path.suffix[1:]
|
||||||
|
|
||||||
if message.attachments:
|
if message.attachments:
|
||||||
attch: discord.Attachment = message.attachments[0]
|
attch: discord.Attachment = message.attachments[0]
|
||||||
self.mm_current_map["im"] = Image.frombytes("RGBA", (attch.width, attch.height), attch.read())
|
self.mm_current_map["im"] = Image.frombytes(
|
||||||
|
"RGBA", (attch.width, attch.height), attch.read()
|
||||||
|
)
|
||||||
|
|
||||||
@mapmaker.command(name="load")
|
@mapmaker.command(name="load")
|
||||||
async def _mapmaker_load(self, ctx: commands.Context, map_name=""):
|
async def _mapmaker_load(self, ctx: commands.Context, map_name=""):
|
||||||
@ -373,7 +373,7 @@ class Conquest(commands.Cog):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if not current_map_folder.exists():
|
if not current_map_folder.exists():
|
||||||
os.makedirs(current_map_folder)
|
current_map_folder.mkdir()
|
||||||
copyfile(self.asset_path / mapname / f"blank.{self.ext}", current_map)
|
copyfile(self.asset_path / mapname / f"blank.{self.ext}", current_map)
|
||||||
|
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import os
|
|
||||||
import pathlib
|
import pathlib
|
||||||
from PIL import Image, ImageColor, ImageFont, ImageOps, ImageDraw
|
|
||||||
|
from PIL import Image, ImageColor, ImageDraw, ImageFont
|
||||||
from PIL.ImageDraw import _color_diff
|
from PIL.ImageDraw import _color_diff
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class Regioner:
|
|||||||
masks_path = self.filepath / "masks"
|
masks_path = self.filepath / "masks"
|
||||||
|
|
||||||
if not masks_path.exists():
|
if not masks_path.exists():
|
||||||
os.makedirs(masks_path)
|
masks_path.mkdir()
|
||||||
|
|
||||||
black = ImageColor.getcolor("black", "L")
|
black = ImageColor.getcolor("black", "L")
|
||||||
white = ImageColor.getcolor("white", "L")
|
white = ImageColor.getcolor("white", "L")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user