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 45 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
081fb75
Fix playlist crash when opening file
C0rn3j Jan 11, 2025
09918f4
Move all classes aside
C0rn3j Jan 12, 2025
1645361
Fix up GuiVar
C0rn3j Jan 12, 2025
714372b
Remove extra spaces
C0rn3j Jan 12, 2025
82d75fe
Bootstrap rework WIP
C0rn3j Jan 12, 2025
ba2d3f3
Fix up guivars more
C0rn3j Jan 12, 2025
3ae7de9
Fix colours class
C0rn3j Jan 12, 2025
aa2f4d5
Refactor holder WIP
C0rn3j Jan 12, 2025
69b8326
Small spacing fix
C0rn3j Jan 12, 2025
c6c2d54
Move things around
C0rn3j Jan 19, 2025
988d89e
More moving around
C0rn3j Jan 19, 2025
6b12011
Somewhat arrange to current upstream state
C0rn3j Jan 27, 2025
31eff3d
Small Prefs fix up
C0rn3j Jan 27, 2025
7b7c1a6
Bootstrap: Use dataclass
C0rn3j Jan 27, 2025
bcee659
t_main reworks
C0rn3j Jan 27, 2025
2b0641e
Move classes on top of main
C0rn3j Jan 27, 2025
91e6d96
More reworking
C0rn3j Jan 27, 2025
088693c
GuiVar: Remove duplicated macOS detection
C0rn3j Jan 27, 2025
9af5cf5
More rework
C0rn3j Jan 27, 2025
cce6b99
More rework, create class Formats, remove global formats
C0rn3j Jan 27, 2025
0ef4c94
Fix colon convention
C0rn3j Jan 27, 2025
c1bccda
Remove empty rework file
C0rn3j Jan 27, 2025
c271cf7
More refactoring
C0rn3j Jan 29, 2025
2a0b452
Add more typing
C0rn3j Jan 29, 2025
a1960f7
More rework
C0rn3j Jan 29, 2025
87c37fa
Remove old comment
C0rn3j Jan 29, 2025
0c49c6e
Refactor
C0rn3j Jan 29, 2025
7e1efda
Refactor fixups
C0rn3j Feb 1, 2025
c7cefde
Moar refactor
C0rn3j Feb 1, 2025
c808f5f
Refactor class Tauon
C0rn3j Feb 1, 2025
96bdbb8
Fix up asset_loader()
C0rn3j Feb 1, 2025
b26fb9a
Moar refactor
C0rn3j Feb 1, 2025
d0f71ce
More reworks
C0rn3j Feb 2, 2025
5565a82
Remove doubled ctypes import
C0rn3j Feb 2, 2025
42dbbf5
More refactor
C0rn3j Feb 2, 2025
74172c4
Further refactor and add accidentally deleted classes back
C0rn3j Feb 2, 2025
8e628c2
Premove touchups
C0rn3j Feb 2, 2025
5ead1fd
Add Bag to Tauon and continue refactoring
C0rn3j Feb 2, 2025
2b4421d
pctl reworks
C0rn3j Feb 2, 2025
8bc00ff
Move some things around and rename devance func to "previous"
C0rn3j Feb 2, 2025
c0e00eb
further reworks
C0rn3j Feb 2, 2025
c8d7e51
Further reworks
C0rn3j Feb 2, 2025
acdd040
Further reworks
C0rn3j Feb 3, 2025
decd033
More refactoring, convert Prefs to a dataclass, to be merged with Bag
C0rn3j Feb 3, 2025
47f2546
Small refactor
C0rn3j Feb 3, 2025
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
58 changes: 28 additions & 30 deletions src/tauon/t_modules/t_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

#from dataclasses import dataclass
from dataclasses import dataclass
from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand All @@ -11,34 +11,32 @@

from tauon.__main__ import LogHistoryHandler

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