From e8b25a8d0a5c70f434a2cb268a7b62190b7adcfc Mon Sep 17 00:00:00 2001
From: Sebastian Krzyszkowiak <dos@dosowisko.net>
Date: Tue, 14 Nov 2023 22:39:18 +0100
Subject: [PATCH] Allow downloading the Starter Pack in the flow3r simulator

---
 download.py | 9 ++++++++-
 select.py   | 5 +++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/download.py b/download.py
index 2d053b5..debf0ed 100644
--- a/download.py
+++ b/download.py
@@ -31,11 +31,18 @@ download_lock = _thread.allocate_lock()
 
 def download_thread(self):
     download_lock.acquire(1)
+    if st3m.utils.sd_card_plugged():
+        rootpath = "/sd/PetalHero"
+    else:
+        rootpath = f"{self.app.path}/songs"
+        if not os.path.exists(rootpath):
+            os.mkdir(rootpath)
+
     while self.file_list and not self.cancel:
         self.current_song = self.file_list.pop(0)
         self.file_no += 1
         self.file_progress = 0
-        dirname = f"/sd/PetalHero/{self.current_song[2]} - {self.current_song[3]}"
+        dirname = f"{rootpath}/{self.current_song[2]} - {self.current_song[3]}"
 
         try:
             l = os.listdir(dirname)
diff --git a/select.py b/select.py
index bbc1c89..a9b576c 100644
--- a/select.py
+++ b/select.py
@@ -3,6 +3,7 @@ from st3m.input import InputState
 from st3m.ui.interactions import ScrollController
 from st3m.goose import Optional
 from ctx import Context
+import st3m.utils
 import math
 import os, stat
 import time
@@ -195,7 +196,7 @@ class SelectView(BaseView):
                 ctx.font_size = 24
                 ctx.text("No songs found!")
                 
-                if self.sd_card_present:
+                if self.sd_card_present or st3m.utils.is_simulator():
                     ctx.gray(0.8)
                     ctx.move_to(0, 32)
                     ctx.font_size = 17
@@ -330,7 +331,7 @@ class SelectView(BaseView):
             utils.play_go(self.app)
             if self.songs:
                 self.vm.push(difficulty.DifficultyView(self.app, self.songs[pos]), ViewTransitionSwipeLeft())
-            elif self.sd_card_present:
+            elif self.sd_card_present or st3m.utils.is_simulator():
                 self.vm.replace(connecting.ConnectingView(self.app), ViewTransitionBlend())
 
         if self.first_scroll_think:
-- 
GitLab