The "Days per Week" option!

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2023-02-18 12:46:54 +00:00
parent 91b9a94c4b
commit 1b29759f6e
2 changed files with 51 additions and 1 deletions

View file

@ -52,6 +52,19 @@ def ifdate(string):
return ret
def if_days_a_week(string):
try:
string = int(string)
if string <= 7 and string >= 1:
return True
else:
return False
except Exception as e:
print("fail", e)
return False
def get_legacy(project_location):
# This function will return analytics data about a project. This particular
@ -832,7 +845,7 @@ def load(project_location):
alldates = list(reversed(data["dates"].keys()))
prevdate = alldates[alldates.index(today)+1]
prev_frac = data["dates"][prevdate].get("fractions", {}).get("project", data["fraction"])
data["needed"] = ( 1 - prev_frac ) / ( data["duration"] - data["dayspassed"] )
data["needed"] = ( 1 - prev_frac ) / (( data["duration"] - data["dayspassed"] )/7*data.get("days_a_week", 7))
except:
data["needed"] = 0

View file

@ -334,6 +334,43 @@ def layer(win):
icon="ok",
tip=talk.text("checked"))
current_Y += 50
# Days a week.
UI_elements.text(layer, win, "Project_days_a_week_setting",
win.current["w"]/2-190,
110 + current_Y + win.scroll["studio_settings"],
80,
40,
set_text=str(win.analytics.get("days_a_week", 7)),
tip=talk.text("days_a_week"))
if win.text["Project_days_a_week_setting"]["text"] != str(win.analytics.get("days_a_week", 7))\
and analytics.if_days_a_week(win.text["Project_days_a_week_setting"]["text"]):
def do():
win.analytics["days_a_week"] = int(win.text["Project_days_a_week_setting"]["text"])
# Refrashing the analytics
analytics.save(win.project, win.analytics)
win.analytics = analytics.load(win.project)
UI_elements.roundrect(layer, win,
win.current["w"]/2-150,
110 + current_Y + win.scroll["studio_settings"],
40,
40,
10,
button=do,
icon="ok",
tip=talk.text("checked"))
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to(win.current["w"]/2-100,
current_Y + win.scroll["studio_settings"] + 135)
layer.show_text(talk.text("days_a_week"))
current_Y += 100