Initial version

This commit is contained in:
csd4ni3l
2025-04-21 10:50:45 +02:00
commit 5c3a23a711
16 changed files with 1458 additions and 0 deletions

49
menus/main.py Normal file
View File

@@ -0,0 +1,49 @@
import arcade, arcade.gui, asyncio, pypresence, time
from utils.preload import button_texture, button_hovered_texture
from utils.constants import button_style
from utils.utils import FakePyPresence
class Main(arcade.gui.UIView):
def __init__(self, pypresence_client=None):
super().__init__()
self.anchor = self.add_widget(arcade.gui.UIAnchorLayout())
self.box = self.anchor.add(arcade.gui.UIBoxLayout(space_between=10), anchor_x='center', anchor_y='center')
self.pypresence_client = pypresence_client
if self.pypresence_client == None: # Game has started
try:
asyncio.get_event_loop()
except:
asyncio.set_event_loop(asyncio.new_event_loop())
try:
self.pypresence_client = pypresence.Presence(1363780625928028200)
self.pypresence_client.connect()
self.pypresence_client.start_time = time.time()
except:
self.pypresence_client = FakePyPresence()
self.pypresence_client.start_time = time.time()
elif isinstance(self.pypresence_client, FakePyPresence):
# get start time from old object
start_time = copy.deepcopy(self.pypresence_client.start_time)
try:
self.pypresence_client = pypresence.Presence(1363780625928028200)
self.pypresence_client.connect()
self.pypresence_client.start_time = start_time
except:
self.pypresence_client = FakePyPresence()
self.pypresence_client.start_time = start_time
self.pypresence_client.update(state='In Menu', details='In Main Menu', start=self.pypresence_client.start_time)
def on_show_view(self):
super().on_show_view()
self.play_button = self.box.add(arcade.gui.UITextureButton(text="Play", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=150, style=button_style))
self.play_button.on_click = lambda event: self.play()
def play(self):
from game.play import Game
self.window.show_view(Game(self.pypresence_client))