mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 19:28:25 +02:00
implemented bmg patch operation by id
This commit is contained in:
parent
79b350faf7
commit
cf0f61d8ee
1 changed files with 11 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import re
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import IO
|
from typing import IO
|
||||||
|
@ -5,7 +6,7 @@ from typing import IO
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
from source.mkw.Patch import *
|
from source.mkw.Patch import *
|
||||||
from source.wt import img
|
from source.wt import img, bmg
|
||||||
|
|
||||||
|
|
||||||
class PatchOperation:
|
class PatchOperation:
|
||||||
|
@ -286,7 +287,15 @@ class PatchOperation:
|
||||||
self.template = template
|
self.template = template
|
||||||
|
|
||||||
def patch_bmg(self, patch: "Patch", file_content: IO) -> IO:
|
def patch_bmg(self, patch: "Patch", file_content: IO) -> IO:
|
||||||
return file_content
|
decoded_bmg = bmg.decode_data(file_content.read())
|
||||||
|
|
||||||
|
decoded_bmg += "\n" + ("\n".join(
|
||||||
|
[f" {id}\t= {replacement}" for id, replacement in self.template.items()]
|
||||||
|
)) + "\n"
|
||||||
|
# add new bmg definition at the end of the bmg file, overwritting old id.
|
||||||
|
|
||||||
|
patch_content = BytesIO(bmg.encode_data(decoded_bmg))
|
||||||
|
return patch_content
|
||||||
|
|
||||||
class RegexLayer(AbstractLayer):
|
class RegexLayer(AbstractLayer):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue