aboutsummaryrefslogtreecommitdiff
path: root/srb_tk.py
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-04-05 12:07:53 -0400
committerB. Stack <bgstack15@gmail.com>2024-04-05 12:07:53 -0400
commit219e0ff7b8e40d49a1b386823bfbef9f25e94166 (patch)
treea38e7dd4a0b6369394d29e2607bd9de6594e7ef8 /srb_tk.py
parenttk: moved flash_entry to lib, added frame_backgrounds checkbox (diff)
downloadsrb_lib-219e0ff7b8e40d49a1b386823bfbef9f25e94166.tar.gz
srb_lib-219e0ff7b8e40d49a1b386823bfbef9f25e94166.tar.bz2
srb_lib-219e0ff7b8e40d49a1b386823bfbef9f25e94166.zip
lib: rename to completed_levels, tk: show enabled levels
Diffstat (limited to 'srb_tk.py')
-rwxr-xr-xsrb_tk.py40
1 files changed, 30 insertions, 10 deletions
diff --git a/srb_tk.py b/srb_tk.py
index f78569a..dda1029 100755
--- a/srb_tk.py
+++ b/srb_tk.py
@@ -23,8 +23,6 @@
# https://stackoverflow.com/questions/67334913/can-i-possibly-put-an-image-label-into-an-option-box-in-tkinter
# Improve:
# Add reset-level-breakables
-# disable/gray out levels labels not reachable because of levelset_available_levels
-# setting that sets the background colors of the regions
# Dependencies:
# dep-devuan: python3-tkinter, python3-pil.imagetk
# rec-devuan: python3-cairosvg
@@ -302,10 +300,8 @@ class App(tk.Frame):
self.lbl_levelsets = []
self.spn_levelsets = []
self.ent_levelsets_balloons = []
- self.lbl_levelsets_name = tk.Label(self.frm_levels,text="Billboard/Available")
+ self.lbl_levelsets_name = tk.Label(self.frm_levels,text="Billboard/Completed")
self.lbl_levelsets_name.grid(row=0,column=0,sticky="EW",columnspan=4)
- #self.lbl_levelsets_available_levels = tk.Label(self.frm_levels,text="Available")
- #self.lbl_levelsets_available_levels.grid(row=0,column=1,columnspan=2)
self.lbl_levels_name = tk.Label(self.frm_levels,text="Level")
self.lbl_levels_name.grid(row=0,column=5,sticky="EW")
self.lbl_levels_status = tk.Label(self.frm_levels,text="Rank")
@@ -505,15 +501,15 @@ class App(tk.Frame):
bdata, message = srb_lib.set_purchased_planes(bdata, profile_id, "add", pur_planes_list, silent=self.silent.get())
if bdata == -1 or message != "":
raise Exception(f"Failed when setting purchased planes, message {message}.")
- # levelset available levels
+ # levelset completed levels
for i in range(0,len(srb_lib.LEVELSETS)):
- bdata, message = srb_lib.set_levelset_available_levels(bdata, profile_id, i, self.levelset_status_ints[i].get())
+ bdata, message = srb_lib.set_levelset_completed_levels(bdata, profile_id, i, self.levelset_status_ints[i].get())
if bdata == -1 or message != "":
- raise Exception(f"Failed to set levelset available levels for levelset {i}, message {message}.")
+ raise Exception(f"Failed to set levelset completed levels for levelset {i}, message {message}.")
for i in range(0,len(srb_lib.LEVELS)):
ts = self.level_statuses[i].get()
if ts != "unknown":
- bdata, current_status, message = srb_lib.set_level_status(bdata, profile_id, i, ts, fix_levelset_available_levels=False)
+ bdata, current_status, message = srb_lib.set_level_status(bdata, profile_id, i, ts, fix_levelset_completed_levels=False)
if bdata == -1 or current_status == -1 or message != "":
raise Exception(f"Failed to set level status for {i} to {ts}, because {message}")
except Exception as e:
@@ -688,7 +684,7 @@ class App(tk.Frame):
self.pur_plane_str_woodstock.set(letters)
elif 5 == x:
self.pur_plane_str_baron.set(letters)
- # levelset available levels
+ # levelset completed levels
mission_mask = bin(int(mission_mask[1:],2)).count('1')
#print(f"for levelset {i}, need to set max {i['l']}, current {mission_mask}")
self.levelset_status_ints[x].set(mission_mask)
@@ -696,6 +692,7 @@ class App(tk.Frame):
x += 1
# levels
for i in range(0,len(srb_lib.LEVELS)):
+ this_level = [j for j in srb_lib.LEVELS if j["id"] == i][0]
tl_status, tl_balloons, tl_letters = srb_lib.get_level_status(self.bdata,profile_id,i,silent=True)
# level status
tl_status = int(tl_status,16)
@@ -711,6 +708,29 @@ class App(tk.Frame):
# level balloons
self.level_balloons[i].set(tl_balloons)
self.level_letters[i].set(tl_letters)
+ # level available because of completed levels
+ # we are not in the loop of levelsets, so we need to re-get mission_mask.
+ mission_mask, _, _ = srb_lib.get_levelset_status(self.bdata,profile_id,this_level["setid"],silent=True)
+ mission_mask = bin(int(mission_mask[1:],2)).count('1')
+ prev_mission_mask = 0
+ this_levelset = [l for l in srb_lib.LEVELSETS if l["id"] == this_level["setid"]][0]
+ if this_level["setid"] > 0:
+ prev_mission_mask, _, _ = srb_lib.get_levelset_status(self.bdata,profile_id,this_level["setid"]-1,silent=True)
+ prev_mission_mask = bin(int(prev_mission_mask[1:],2)).count('1')
+ # work up from here
+ state = "disabled"
+ if this_level["set_pos"] == 0:
+ if this_level["setid"] == 0:
+ if srb_lib.get_tutorial_completed(self.bdata,profile_id):
+ state = "normal"
+ elif prev_mission_mask >= this_levelset["a"]:
+ state = "normal"
+ elif this_level["set_pos"] <= mission_mask:
+ state = "normal"
+ self.lbl_levels[this_level['id']].config(state=state)
+ # if level set_pos 0, then update the label for the whole levelset
+ if this_level["set_pos"] == 0:
+ self.lbl_levelsets[this_level["setid"]].config(state=state)
# end if-profile_id is 1,2 or 3.
# mark-traces-enable must happen at the end!
self.mark_traces(True)
bgstack15