Skip to content

Commit ced7155

Browse files
Merge pull request #23 from xcoder-tool/rendering-refactoring
refactor(rendering): rendering rewrote, movie clips first frame rendering
2 parents 8967305 + 4bc7c8c commit ced7155

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1230
-970
lines changed

main.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
# Refactored by Vorono4ka
2-
31
import time
42

3+
from system.lib.config import config
4+
from system.lib.main_menu import (
5+
check_auto_update,
6+
check_files_updated,
7+
menu,
8+
refill_menu,
9+
)
10+
from system.localization import locale
11+
512
try:
613
from loguru import logger
714
except ImportError:
815
raise RuntimeError("Please, install loguru using pip")
916

1017
from system import clear
11-
from system.lib import (
12-
config,
13-
locale,
14-
refill_menu,
15-
menu,
16-
check_auto_update,
17-
check_files_updated,
18-
)
1918
from system.lib.features.initialization import initialize
2019

2120

@@ -50,4 +49,3 @@ def main():
5049
main()
5150
except KeyboardInterrupt:
5251
logger.info("Exit.")
53-
pass

system/bytestream.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import io
2-
from typing import Literal, Optional
2+
from typing import Literal
33

44

55
class Reader(io.BytesIO):
@@ -37,7 +37,7 @@ def read_twip(self) -> float:
3737

3838
def read_string(self) -> str:
3939
length = self.read_uchar()
40-
if length != 255:
40+
if length != 0xFF:
4141
return self.read(length).decode()
4242
return ""
4343

@@ -68,9 +68,9 @@ def write_uint32(self, integer: int):
6868
def write_int32(self, integer: int):
6969
self.write_int(integer, 4, True)
7070

71-
def write_string(self, string: Optional["str"] = None):
71+
def write_string(self, string: str | None = None):
7272
if string is None:
73-
self.write_byte(255)
73+
self.write_byte(0xFF)
7474
return
7575
encoded = string.encode()
7676
self.write_byte(len(encoded))

system/languages/en-EU.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"resizing": "Resizing...",
7171
"split_pic": "Splitting picture...",
7272
"writing_pic": "Writing pixels...",
73-
"header_done": "Header wrote!",
7473
"compressing_with": "Compressing texture with %s...",
7574
"compression_error": "Compression failed",
7675
"compression_done": "Compression done!",

system/languages/ru-RU.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"resizing": "Изменяем размер...",
7171
"split_pic": "Разделяем картинку...",
7272
"writing_pic": "Конвертируем пиксели...",
73-
"header_done": "Заголовок записан!",
7473
"compressing_with": "Сохраняем с применением %s сжатия...",
7574
"compression_error": "Сжатие не удалось",
7675
"compression_done": "Сжатие прошло успешно!",

system/languages/ua-UA.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"resizing": "змінюємо розмір...",
7171
"split_pic": "Розділюємо зоображення...",
7272
"writing_pic": "Записуємо пікселі...",
73-
"header_done": "Написали Header!",
7473
"compressing_with": "Запаковуємо з %s...",
7574
"compression_error": "Запаковування не вдалося",
7675
"compression_done": "Запаковування виконане!",

system/lib/__init__.py

Lines changed: 0 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
import sys
2-
import time
32

43
from loguru import logger
54

6-
from system import clear
7-
from system.lib.config import config
8-
from system.lib.console import Console
9-
from system.lib.features.directories import clear_directories
10-
from system.lib.features.initialization import initialize
11-
from system.lib.features.update.check import check_for_outdated, check_update, get_tags
12-
from system.lib.menu import Menu, menu
13-
from system.localization import locale
14-
155
logger.remove()
166
logger.add(
177
"./logs/info/{time:YYYY-MM-DD}.log",
@@ -28,183 +18,3 @@
2818
level="ERROR",
2919
)
3020
logger.add(sys.stdout, format="<lvl>[{level}] {message}</lvl>", level="INFO")
31-
32-
33-
locale.load(config.language)
34-
35-
36-
def check_auto_update():
37-
if config.auto_update and time.time() - config.last_update > 60 * 60 * 24 * 7:
38-
check_update()
39-
config.last_update = int(time.time())
40-
config.dump()
41-
42-
43-
def check_files_updated():
44-
if config.has_update:
45-
logger.opt(colors=True).info(f'<green>{locale.update_done % ""}</green>')
46-
if Console.question(locale.done_qu):
47-
latest_tag = get_tags("vorono4ka", "xcoder")[0]
48-
latest_tag_name = latest_tag["name"][1:]
49-
50-
config.has_update = False
51-
config.version = latest_tag_name
52-
config.last_update = int(time.time())
53-
config.dump()
54-
else:
55-
exit()
56-
57-
58-
# noinspection PyUnresolvedReferences
59-
@logger.catch()
60-
def refill_menu():
61-
menu.categories.clear()
62-
63-
sc_category = Menu.Category(0, locale.sc_label)
64-
ktx_category = Menu.Category(1, locale.ktx_label)
65-
csv_category = Menu.Category(2, locale.csv_label)
66-
other = Menu.Category(10, locale.other_features_label)
67-
68-
menu.add_category(sc_category)
69-
menu.add_category(ktx_category)
70-
menu.add_category(csv_category)
71-
menu.add_category(other)
72-
73-
try:
74-
import sc_compression
75-
76-
del sc_compression
77-
except ImportError:
78-
logger.warning(locale.install_to_unlock % "sc-compression")
79-
else:
80-
from system.lib.features.csv.compress import compress_csv
81-
from system.lib.features.csv.decompress import decompress_csv
82-
83-
try:
84-
import PIL
85-
86-
del PIL
87-
except ImportError:
88-
logger.warning(locale.install_to_unlock % "PILLOW")
89-
else:
90-
from system.lib.features.sc.decode import (
91-
decode_and_render_objects,
92-
decode_textures_only,
93-
)
94-
from system.lib.features.sc.encode import (
95-
collect_objects_and_encode,
96-
encode_textures_only,
97-
)
98-
99-
sc_category.add(
100-
Menu.Item(
101-
name=locale.decode_sc,
102-
description=locale.decode_sc_description,
103-
handler=decode_textures_only,
104-
)
105-
)
106-
sc_category.add(
107-
Menu.Item(
108-
name=locale.encode_sc,
109-
description=locale.encode_sc_description,
110-
handler=encode_textures_only,
111-
)
112-
)
113-
sc_category.add(
114-
Menu.Item(
115-
name=locale.decode_by_parts,
116-
description=locale.decode_by_parts_description,
117-
handler=decode_and_render_objects,
118-
)
119-
)
120-
sc_category.add(
121-
Menu.Item(
122-
name=locale.encode_by_parts,
123-
description=locale.encode_by_parts_description,
124-
handler=collect_objects_and_encode,
125-
)
126-
)
127-
sc_category.add(
128-
Menu.Item(
129-
name=locale.overwrite_by_parts,
130-
description=locale.overwrite_by_parts_description,
131-
handler=lambda: collect_objects_and_encode(True),
132-
)
133-
)
134-
135-
from system.lib.features.ktx import (
136-
convert_ktx_textures_to_png,
137-
convert_png_textures_to_ktx,
138-
)
139-
from system.lib.pvr_tex_tool import can_use_pvr_tex_tool
140-
141-
if can_use_pvr_tex_tool():
142-
ktx_category.add(
143-
Menu.Item(
144-
name=locale.ktx_from_png_label,
145-
description=locale.ktx_from_png_description,
146-
handler=convert_png_textures_to_ktx,
147-
)
148-
)
149-
ktx_category.add(
150-
Menu.Item(
151-
name=locale.png_from_ktx_label,
152-
description=locale.png_from_ktx_description,
153-
handler=convert_ktx_textures_to_png,
154-
)
155-
)
156-
157-
csv_category.add(
158-
Menu.Item(
159-
name=locale.decompress_csv,
160-
description=locale.decompress_csv_description,
161-
handler=decompress_csv,
162-
)
163-
)
164-
csv_category.add(
165-
Menu.Item(
166-
name=locale.compress_csv,
167-
description=locale.compress_csv_description,
168-
handler=compress_csv,
169-
)
170-
)
171-
172-
other.add(
173-
Menu.Item(
174-
name=locale.check_update,
175-
description=locale.version % config.version,
176-
handler=check_update,
177-
)
178-
)
179-
other.add(Menu.Item(name=locale.check_for_outdated, handler=check_for_outdated))
180-
other.add(
181-
Menu.Item(
182-
name=locale.reinit,
183-
description=locale.reinit_description,
184-
handler=lambda: (initialize(), refill_menu()),
185-
)
186-
)
187-
other.add(
188-
Menu.Item(
189-
name=locale.change_language,
190-
description=locale.change_lang_description % config.language,
191-
handler=lambda: (config.change_language(locale.change()), refill_menu()),
192-
)
193-
)
194-
other.add(
195-
Menu.Item(
196-
name=locale.clear_directories,
197-
description=locale.clean_dirs_description,
198-
handler=lambda: clear_directories()
199-
if Console.question(locale.clear_qu)
200-
else -1,
201-
)
202-
)
203-
other.add(
204-
Menu.Item(
205-
name=locale.toggle_update_auto_checking,
206-
description=locale.enabled if config.auto_update else locale.disabled,
207-
handler=lambda: (config.toggle_auto_update(), refill_menu()),
208-
)
209-
)
210-
other.add(Menu.Item(name=locale.exit, handler=lambda: (clear(), exit())))

system/lib/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def __init__(self):
1616
"has_update",
1717
"last_update",
1818
"auto_update",
19+
"should_render_movie_clips",
1920
)
2021

2122
self.initialized: bool = False
@@ -24,6 +25,7 @@ def __init__(self):
2425
self.has_update: bool = False
2526
self.last_update: int = -1
2627
self.auto_update: bool = False
28+
self.should_render_movie_clips: bool = False
2729

2830
self.load()
2931

0 commit comments

Comments
 (0)