Skip to content

Commit ecc3094

Browse files
authoredDec 1, 2024··
Launcher: launch without delay on URI without choice (#4279)
1 parent 17b3ee6 commit ecc3094

File tree

1 file changed

+18
-40
lines changed

1 file changed

+18
-40
lines changed
 

‎Launcher.py

+18-40
Original file line numberDiff line numberDiff line change
@@ -126,61 +126,39 @@ def handle_uri(path: str, launch_args: Tuple[str, ...]) -> None:
126126
elif component.display_name == "Text Client":
127127
text_client_component = component
128128

129-
from kvui import App, Button, BoxLayout, Label, Clock, Window
129+
if client_component is None:
130+
run_component(text_client_component, *launch_args)
131+
return
130132

131-
class Popup(App):
132-
timer_label: Label
133-
remaining_time: Optional[int]
133+
from kvui import App, Button, BoxLayout, Label, Window
134134

135+
class Popup(App):
135136
def __init__(self):
136137
self.title = "Connect to Multiworld"
137138
self.icon = r"data/icon.png"
138139
super().__init__()
139140

140141
def build(self):
141142
layout = BoxLayout(orientation="vertical")
143+
layout.add_widget(Label(text="Select client to open and connect with."))
144+
button_row = BoxLayout(orientation="horizontal", size_hint=(1, 0.4))
142145

143-
if client_component is None:
144-
self.remaining_time = 7
145-
label_text = (f"A game client able to parse URIs was not detected for {game}.\n"
146-
f"Launching Text Client in 7 seconds...")
147-
self.timer_label = Label(text=label_text)
148-
layout.add_widget(self.timer_label)
149-
Clock.schedule_interval(self.update_label, 1)
150-
else:
151-
layout.add_widget(Label(text="Select client to open and connect with."))
152-
button_row = BoxLayout(orientation="horizontal", size_hint=(1, 0.4))
153-
154-
text_client_button = Button(
155-
text=text_client_component.display_name,
156-
on_release=lambda *args: run_component(text_client_component, *launch_args)
157-
)
158-
button_row.add_widget(text_client_button)
146+
text_client_button = Button(
147+
text=text_client_component.display_name,
148+
on_release=lambda *args: run_component(text_client_component, *launch_args)
149+
)
150+
button_row.add_widget(text_client_button)
159151

160-
game_client_button = Button(
161-
text=client_component.display_name,
162-
on_release=lambda *args: run_component(client_component, *launch_args)
163-
)
164-
button_row.add_widget(game_client_button)
152+
game_client_button = Button(
153+
text=client_component.display_name,
154+
on_release=lambda *args: run_component(client_component, *launch_args)
155+
)
156+
button_row.add_widget(game_client_button)
165157

166-
layout.add_widget(button_row)
158+
layout.add_widget(button_row)
167159

168160
return layout
169161

170-
def update_label(self, dt):
171-
if self.remaining_time > 1:
172-
# countdown the timer and string replace the number
173-
self.remaining_time -= 1
174-
self.timer_label.text = self.timer_label.text.replace(
175-
str(self.remaining_time + 1), str(self.remaining_time)
176-
)
177-
else:
178-
# our timer is finished so launch text client and close down
179-
run_component(text_client_component, *launch_args)
180-
Clock.unschedule(self.update_label)
181-
App.get_running_app().stop()
182-
Window.close()
183-
184162
def _stop(self, *largs):
185163
# see run_gui Launcher _stop comment for details
186164
self.root_window.close()

0 commit comments

Comments
 (0)
Please sign in to comment.