Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor initialization and classes #1388

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions src/tauon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

from tauon.t_modules.logging import CustomLoggingFormatter, LogHistoryHandler

from tauon.t_modules import t_bootstrap
from tauon.t_modules.t_bootstrap import Holder

log = LogHistoryHandler()
formatter = logging.Formatter('[%(levelname)s] %(message)s')
Expand Down Expand Up @@ -427,32 +427,33 @@ def transfer_args_and_exit() -> None:
SDL_FreeSurface(raw_image)
SDL_DestroyTexture(sdl_texture)

holder = t_bootstrap.holder
holder.t_window = t_window
holder.renderer = renderer
holder.logical_size = logical_size
holder.window_size = window_size
holder.window_default_size = window_default_size
holder.scale = scale
holder.maximized = maximized
holder.transfer_args_and_exit = transfer_args_and_exit
holder.draw_border = draw_border
holder.window_opacity = window_opacity
holder.old_window_position = old_window_position
holder.install_directory = install_directory
holder.user_directory = user_directory
holder.pyinstaller_mode = pyinstaller_mode
holder.phone = phone
holder.window_title = window_title
holder.fs_mode = fs_mode
holder.t_title = t_title
holder.n_version = n_version
holder.t_version = t_version
holder.t_id = t_id
holder.t_agent = t_agent
holder.dev_mode = dev_mode
holder.instance_lock = fp
holder.log = log
holder = Holder(
t_window=t_window,
renderer=renderer,
logical_size=logical_size,
window_size=window_size,
window_default_size=window_default_size,
scale=scale,
maximized=maximized,
transfer_args_and_exit=transfer_args_and_exit,
draw_border=draw_border,
window_opacity=window_opacity,
old_window_position=old_window_position,
install_directory=install_directory,
user_directory=user_directory,
pyinstaller_mode=pyinstaller_mode,
phone=phone,
window_title=window_title,
fs_mode=fs_mode,
t_title=t_title,
n_version=n_version,
t_version=t_version,
t_id=t_id,
t_agent=t_agent,
dev_mode=dev_mode,
instance_lock=fp,
log=log,
)

del raw_image
del sdl_texture
Expand All @@ -464,7 +465,8 @@ def transfer_args_and_exit() -> None:

def main() -> None:
"""Launch Tauon by means of importing t_main.py"""
from tauon.t_modules import t_main
from tauon.t_modules.t_main import main as t_main
t_main(holder)

if __name__ == "__main__":
main()
Expand Down
62 changes: 34 additions & 28 deletions src/tauon/t_modules/t_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,38 @@

#@dataclass
class Holder:
"""Class that holds variables for forwarding them from tauon.py to t_main.py"""
"""Class that holds variables for forwarding them from __main__.py to t_main.py"""

t_window: Any # SDL_CreateWindow() return type (???)
renderer: Any # SDL_CreateRenderer() return type (???)
logical_size: list[int] # X Y res
window_size: list[int] # X Y res
maximized: bool
scale: float
window_opacity: float
draw_border: bool
transfer_args_and_exit: Callable[[]] # transfer_args_and_exit() - TODO(Martin): This should probably be moved to extra module
old_window_position: tuple [int, int] | None # X Y res
install_directory: Path
user_directory: Path
pyinstaller_mode: bool
phone: bool
window_default_size: tuple[int, int] # X Y res
window_title: bytes # t_title.encode("utf-8")
fs_mode: bool
t_title: str # "Tauon"
n_version: str # "7.9.0"
t_version: str # "v" + n_version
t_id: str # "tauonmb" | "com.github.taiko2k.tauonmb"
t_agent: str # "TauonMusicBox/7.9.0"
dev_mode: bool
instance_lock: TextIOWrapper | None
log: LogHistoryHandler

holder = Holder()
def __init__(
self, t_window: Any, renderer: Any, logical_size: list[int], window_size: list[int], maximized: bool,
scale: float, window_opacity: float, draw_border: bool, transfer_args_and_exit: Callable[[]],
old_window_position: tuple [int, int] | None, install_directory: Path, user_directory: Path,
pyinstaller_mode: bool, phone: bool, window_default_size: tuple[int, int], window_title: bytes,
fs_mode: bool, t_title: str, n_version: str, t_version: str, t_id: str, t_agent: str, dev_mode: bool,
instance_lock: TextIOWrapper | None, log: LogHistoryHandler,
) -> None:
self.t_window = t_window # SDL_CreateWindow() return type (???)
self.renderer = renderer # SDL_CreateRenderer() return type (???)
self.logical_size = logical_size # X Y res
self.window_size = window_size # X Y res
self.maximized = maximized
self.scale = scale
self.window_opacity = window_opacity
self.draw_border = draw_border
self.transfer_args_and_exit = transfer_args_and_exit # transfer_args_and_exit() - TODO(Martin): This should probably be moved to extra module
self.old_window_position = old_window_position # X Y res
self.install_directory = install_directory
self.user_directory = user_directory
self.pyinstaller_mode = pyinstaller_mode
self.phone = phone
self.window_default_size = window_default_size # X Y res
self.window_title = window_title # t_title.encode("utf-8")
self.fs_mode = fs_mode
self.t_title = t_title # "Tauon"
self.n_version = n_version # "7.9.0"
self.t_version = t_version # "v" + n_version
self.t_id = t_id # "tauonmb" | "com.github.taiko2k.tauonmb"
self.t_agent = t_agent # "TauonMusicBox/7.9.0"
self.dev_mode = dev_mode
self.instance_lock = instance_lock
self.log = log
Loading