From 0b916edadcba10003b784a354e89cd69f706ad91 Mon Sep 17 00:00:00 2001 From: "Jeison Yehuda Amihud (Blender Dumbass)" Date: Sat, 4 Feb 2023 17:52:33 +0000 Subject: [PATCH] Star System. --- studio/analytics.py | 21 ++++++++- studio/studio_analyticsLayer.py | 80 +++++++++++++++++++++++++++------ 2 files changed, 86 insertions(+), 15 deletions(-) diff --git a/studio/analytics.py b/studio/analytics.py index a1ff28f..68e200d 100644 --- a/studio/analytics.py +++ b/studio/analytics.py @@ -73,6 +73,8 @@ def get_legacy(project_location): "duration" : 0, # Amount in days between startdate and deadline "timepassed" : 0.0, # Percentage of how much time had passed "dayspassed" : 0, # Amount of days since the startdate + "needed" : 0, # Needed % per day + "star" : 0, # If star is reached "chr_factor" : 1, # Importance factor for Characters "veh_factor" : 1, # Importance factor for Vehicles "loc_factor" : 1, # Importance factor for Locations @@ -690,6 +692,8 @@ def load(project_location): "timepassed" : 0.0, # Percentage of how much time had passed "dayspassed" : 0, # Amount of days since the startdate "chr_factor" : 1, # Importance factor for Characters + "needed" : 0, # Needed % to do today + "star" : 0, # Did you get needed "veh_factor" : 1, # Importance factor for Vehicles "loc_factor" : 1, # Importance factor for Locations "obj_factor" : 1, # Importance factor for Objects (Other) @@ -823,5 +827,20 @@ def load(project_location): } - return data + # Needed + try: + data["needed"] = ( 1 - data["fraction"] ) / ( data["duration"] - data["dayspassed"] ) + except: + data["needed"] = 0 + prev_star = data.get("star", 0) + try: + prev_frac = data["dates"][list(reversed(data["dates"].keys()))[1]].get("fractions", {}).get("project", data["fraction"]) + data["star"] = (data["fraction"] - prev_frac) / data["needed"] + except: + data["star"] = 0 + + if data["star"] >= 1 and not prev_star >= 1: + talk.alert("⭐ Today's Requirement is Finished!") + + return data diff --git a/studio/studio_analyticsLayer.py b/studio/studio_analyticsLayer.py index 8d83de4..6f0ac3a 100644 --- a/studio/studio_analyticsLayer.py +++ b/studio/studio_analyticsLayer.py @@ -180,10 +180,9 @@ def layer(win): pass # MAIN PROGRESS - - # Icon + UI_elements.image(layer, win, "settings/themes/"\ - +win.settings["Theme"]+"/icons/analytics.png", + +win.settings["Theme"]+"/icons/star.png", win.current["w"]/4+10, 15, 40, @@ -197,19 +196,46 @@ def layer(win): win.current["w"]/2-80, 20, 10, - tip=str(round(projectdone*100, 1))+"%") + tip="Today's requirement is: "+str(round(win.analytics.get("needed", 0)*100, 1))+"% ( "+str(round(win.analytics.get("star", 0)*100, 1))+"% of which is done )") + + UI_color.set(layer, win, "text_link") + UI_elements.roundrect(layer, win, + win.current["w"]/4+60, + 25, + (win.current["w"]/2-80)*min(win.analytics.get("star", 0), 1), + 20, + 10) + + + # # Icon + # UI_elements.image(layer, win, "settings/themes/"\ + # +win.settings["Theme"]+"/icons/analytics.png", + # win.current["w"]/4+10, + # 15, + # 40, + # 40) + + # # Progressbar + # UI_color.set(layer, win, "progress_background") + # UI_elements.roundrect(layer, win, + # win.current["w"]/4+60, + # 25, + # win.current["w"]/2-80, + # 20, + # 10, + # tip=str(round(projectdone*100, 1))+"%") - # Project Done - UI_color.set(layer, win, "progress_active") - UI_elements.roundrect(layer, win, - win.current["w"]/4+60, - 25, - (win.current["w"]/2-80)*projectdone, - 20, - 10) + # # Project Done + # UI_color.set(layer, win, "progress_active") + # UI_elements.roundrect(layer, win, + # win.current["w"]/4+60, + # 25, + # (win.current["w"]/2-80)*projectdone, + # 20, + # 10) # TIME PASSED @@ -228,7 +254,7 @@ def layer(win): win.current["w"]/2-80, 20, 10, - tip=str(round(timepassed*100, 1))+"%") + tip="Time: "+str(round(timepassed*100, 1))+"% Project: "+str(round(projectdone*100, 1))+"%") # Timepassed UI_color.set(layer, win, "progress_time") @@ -238,6 +264,16 @@ def layer(win): (win.current["w"]/2-80)*timepassed, 20, 10) + + # Project Done + UI_color.set(layer, win, "progress_active") + UI_elements.roundrect(layer, win, + win.current["w"]/4+60, + 65, + (win.current["w"]/2-80)*projectdone, + 20, + 10) + # SCENES DONE ( RND ) @@ -998,7 +1034,7 @@ def layer(win): # design. But it ended up looking confusing. It needs lines! # Roundrects will not do. - + for num, thing in enumerate(reversed(cat)): if cat[thing][0]: @@ -1089,7 +1125,23 @@ def layer(win): height-(50*nicon)-50, 40, 40) + + # Stars! If the day was exceptional. + + try: + if win.analytics["needed"] <= fracs.get("project", 0) - Pfracs.get("project", 0) and theday <= today: + UI_elements.image(node, win, "settings/themes/"\ + +win.settings["Theme"]+"/icons/star.png", + 6+current_X+win.scroll["days"], + height-(50*nicon)-150, + 40, + 40) + except: + pass + + # Schedules + sch = [] if theday in win.analytics["dates"]: date = win.analytics["dates"][theday]