Skip to content

Commit

Permalink
pyupgrade 3.10+
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Aug 6, 2024
1 parent 5c25725 commit e944ad6
Show file tree
Hide file tree
Showing 27 changed files with 283 additions and 310 deletions.
10 changes: 8 additions & 2 deletions skytemple_rust/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
from range_typed_integers import u16


class TilemapEntry:
idx: int
flip_x: bool
flip_y: bool
pal_idx: int

def __init__(self, idx: int, flip_x: bool, flip_y: bool, pal_idx: int, ignore_too_large: bool = False): ...
def __init__(
self,
idx: int,
flip_x: bool,
flip_y: bool,
pal_idx: int,
ignore_too_large: bool = False,
): ...
def to_int(self) -> u16: ...
@classmethod
def from_int(cls, entry: u16) -> TilemapEntry: ...
12 changes: 1 addition & 11 deletions skytemple_rust/pmd_wan.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,20 @@ class WanImage:
sprite_type: SpriteType
unk2: int


class FragmentBytesStore:
fragment_bytes: List[FragmentBytes]


class FragmentBytes:
mixed_pixels: List[int]
z_index: int

def decode_fragment(self, resolution: FragmentResolution) -> List[int]: ...

def to_image(self, palette: Palette, fragment: Fragment) -> List[int]: ...


class FrameStore:
frames: List[Frame]
max_fragment_alloc_count: int


class Fragment:
unk1: int
unk3_4: Optional[Tuple[bool, bool]]
Expand Down Expand Up @@ -76,16 +71,13 @@ class FragmentResolution:
x: int
y: int


class AnimationStore:
copied_on_previous: Optional[List[bool]]
anim_groups: List[List[Animation]]


class Animation:
frames: List[AnimationFrame]


class AnimationFrame:
duration: int
flag: int
Expand All @@ -95,16 +87,14 @@ class AnimationFrame:
shadow_offset_x: int
shadow_offset_y: int


class Palette:
palette: List[int]


class SpriteType:
PropsUI: SpriteType
Chara: SpriteType
Unknown: SpriteType
name: str
value: int

def encode_image_to_static_wan_file(image: Image) -> bytes: ...
def encode_image_to_static_wan_file(image: Image) -> bytes: ...
2 changes: 1 addition & 1 deletion skytemple_rust/st_at3px.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class At3px:
@classmethod
def cont_size(cls, data: bytes, byte_offset=0): ...
@classmethod
def compress(cls, data: bytes) -> 'At3px': ...
def compress(cls, data: bytes) -> "At3px": ...
2 changes: 1 addition & 1 deletion skytemple_rust/st_at4pn.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class At4pn:
@classmethod
def cont_size(cls, data: bytes, byte_offset=0): ...
@classmethod
def compress(cls, data: bytes) -> 'At4pn': ...
def compress(cls, data: bytes) -> "At4pn": ...
2 changes: 1 addition & 1 deletion skytemple_rust/st_at4px.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class At4px:
@classmethod
def cont_size(cls, data: bytes, byte_offset=0): ...
@classmethod
def compress(cls, data: bytes) -> 'At4px': ...
def compress(cls, data: bytes) -> "At4px": ...
2 changes: 1 addition & 1 deletion skytemple_rust/st_atupx.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class Atupx:
@classmethod
def cont_size(cls, data: bytes, byte_offset=0): ...
@classmethod
def compress(cls, data: bytes) -> 'Atupx': ...
def compress(cls, data: bytes) -> "Atupx": ...
30 changes: 22 additions & 8 deletions skytemple_rust/st_bg_list_dat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,36 @@ from skytemple_rust.st_bpa import Bpa
from skytemple_rust.st_bpc import Bpc
from skytemple_rust.st_bpl import Bpl


class RomFileProviderProtocol(Protocol):
def getFileByName(self, filename: str) -> bytes: ...


class BgListEntry:
bpl_name: str
bpc_name: str
bma_name: str
bpa_names: Sequence[Optional[str]]
def __init__(self, bpl_name: str, bpc_name: str, bma_name: str, bpa_names: List[Optional[str]]): ...
def get_bpl(self, rom_or_directory_root: Union[str, RomFileProviderProtocol]) -> Bpl: ...
def get_bpc(self, rom_or_directory_root: Union[str, RomFileProviderProtocol], bpc_tiling_width: int = 3, bpc_tiling_height: int = 3) -> Bpc: ...
def get_bma(self, rom_or_directory_root: Union[str, RomFileProviderProtocol]) -> Bma: ...
def get_bpas(self, rom_or_directory_root: Union[str, RomFileProviderProtocol]) -> List[Optional[Bpa]]: ...

def __init__(
self,
bpl_name: str,
bpc_name: str,
bma_name: str,
bpa_names: List[Optional[str]],
): ...
def get_bpl(
self, rom_or_directory_root: Union[str, RomFileProviderProtocol]
) -> Bpl: ...
def get_bpc(
self,
rom_or_directory_root: Union[str, RomFileProviderProtocol],
bpc_tiling_width: int = 3,
bpc_tiling_height: int = 3,
) -> Bpc: ...
def get_bma(
self, rom_or_directory_root: Union[str, RomFileProviderProtocol]
) -> Bma: ...
def get_bpas(
self, rom_or_directory_root: Union[str, RomFileProviderProtocol]
) -> List[Optional[Bpa]]: ...

class BgList(BgListEntry):
level: Sequence[BgListEntry]
Expand Down
7 changes: 1 addition & 6 deletions skytemple_rust/st_bgp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,20 @@
#
# You should have received a copy of the GNU General Public License
# along with SkyTemple. If not, see <https://www.gnu.org/licenses/>.
from typing import Sequence, List

from PIL import Image
from typing import Sequence

from skytemple_rust import TilemapEntry


class Bgp:
palettes: Sequence[Sequence[int]] = []
tiles: Sequence[bytearray] = []
tilemap: Sequence[TilemapEntry] = []

def __init__(self, data: bytes): ...

def to_pil(self, ignore_flip_bits=False) -> Image.Image: ...

def from_pil(self, pil: Image.Image, force_import=False) -> None: ...


class BgpWriter:
def __new__(cls): ...
def write(self, model: Bgp) -> bytes: ...
46 changes: 34 additions & 12 deletions skytemple_rust/st_bma.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
#
# You should have received a copy of the GNU General Public License
# along with SkyTemple. If not, see <https://www.gnu.org/licenses/>.
from typing import List, Optional, Sequence

from PIL import Image
from range_typed_integers import u8, u16
from typing import List, Optional, Sequence

from skytemple_rust.st_bpa import Bpa
from skytemple_rust.st_bpc import Bpc
from skytemple_rust.st_bpl import Bpl
from range_typed_integers import *


class Bma:
map_width_camera: u8
Expand All @@ -46,21 +44,45 @@ class Bma:
collision2: Optional[Sequence[bool]]

def __init__(self, data: bytes): ...

def to_pil_single_layer(self, bpc: Bpc, palettes: Sequence[Sequence[int]], bpas: Sequence[Optional[Bpa]], layer: int) -> Image.Image: ...
def to_pil_single_layer(
self,
bpc: Bpc,
palettes: Sequence[Sequence[int]],
bpas: Sequence[Optional[Bpa]],
layer: int,
) -> Image.Image: ...
def to_pil(
self, bpc: Bpc, bpl: Bpl, bpas: List[Optional[Bpa]],
include_collision: bool = True, include_unknown_data_block: bool = True, pal_ani: bool = True, single_frame: bool = False
self,
bpc: Bpc,
bpl: Bpl,
bpas: List[Optional[Bpa]],
include_collision: bool = True,
include_unknown_data_block: bool = True,
pal_ani: bool = True,
single_frame: bool = False,
) -> List[Image.Image]: ...
def from_pil(
self, bpc: Bpc, bpl: Bpl, lower_img: Optional[Image.Image] = None, upper_img: Optional[Image.Image] = None,
force_import: bool = False, how_many_palettes_lower_layer: int = 16
self,
bpc: Bpc,
bpl: Bpl,
lower_img: Optional[Image.Image] = None,
upper_img: Optional[Image.Image] = None,
force_import: bool = False,
how_many_palettes_lower_layer: int = 16,
) -> None: ...
def remove_upper_layer(self) -> None: ...
def add_upper_layer(self) -> None: ...
def resize(self, new_width_chunks: int, new_height_chunks: int, new_width_camera: int, new_height_camera: int) -> None: ...
def resize(
self,
new_width_chunks: int,
new_height_chunks: int,
new_width_camera: int,
new_height_camera: int,
) -> None: ...
def place_chunk(self, layer_id: int, x: int, y: int, chunk_index: int) -> None: ...
def place_collision(self, collision_layer_id: int, x: int, y: int, is_solid: bool) -> None: ...
def place_collision(
self, collision_layer_id: int, x: int, y: int, is_solid: bool
) -> None: ...
def place_data(self, x: int, y: int, data: int) -> None: ...
def deepcopy(self) -> Bma: ...

Expand Down
15 changes: 7 additions & 8 deletions skytemple_rust/st_bpa.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@
#
# You should have received a copy of the GNU General Public License
# along with SkyTemple. If not, see <https://www.gnu.org/licenses/>.
from typing import List, Sequence, Optional

from PIL import Image
from range_typed_integers import *

from range_typed_integers import u16
from typing import List, Sequence, Optional

class BpaFrameInfo:
duration_per_frame: u16
unk2: u16
def __init__(self, duration_per_frame: int, unk2: int): ...

def __init__(self, duration_per_frame: int, unk2: int): ...

class Bpa:
number_of_tiles: u16
Expand All @@ -34,15 +32,16 @@ class Bpa:

def __init__(self, data: bytes): ...
@classmethod
def new_empty(cls) -> 'Bpa': ...
def new_empty(cls) -> "Bpa": ...
def get_tile(self, tile_idx: int, frame_idx: int) -> bytes: ...
def tiles_to_pil_separate(self, palette: Sequence[int], width_in_tiles: int = 20) -> List[Image.Image]: ...
def tiles_to_pil_separate(
self, palette: Sequence[int], width_in_tiles: int = 20
) -> List[Image.Image]: ...
def tiles_to_pil(self, palette: Sequence[int]) -> Optional[Image.Image]: ...
def pil_to_tiles(self, image: Image.Image) -> None: ...
def pil_to_tiles_separate(self, images: List[Image.Image]) -> None: ...
def tiles_for_frame(self, frame: int) -> Sequence[bytes]: ...


class BpaWriter:
def __new__(cls): ...
def write(self, model: Bpa) -> bytes: ...
Loading

0 comments on commit e944ad6

Please sign in to comment.