Floaty things when you click on things.

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2023-02-19 19:11:44 +00:00
parent 307a8b9981
commit 3afea198e0
2 changed files with 79 additions and 1 deletions

View file

@ -784,6 +784,10 @@ def draw(outlayer, win, path, back="story_editor"):
# CHECK BUTTON # CHECK BUTTON
def do(): def do():
# Before we overwrite the button
before_star = win.analytics.get("star", 0)
if task["fraction"]: if task["fraction"]:
task["fraction"] = 0.0 task["fraction"] = 0.0
history.record(win, path, "[Un-Checked]", schedulepath) history.record(win, path, "[Un-Checked]", schedulepath)
@ -805,6 +809,48 @@ def draw(outlayer, win, path, back="story_editor"):
win.multiuser["last_request"] = "" win.multiuser["last_request"] = ""
win.analytics = analytics.load(win.project) win.analytics = analytics.load(win.project)
after_star = win.analytics.get("star", 0)
# Calculating the amount got right
difference = after_star - before_star
positive = difference >= 0
if positive:
difference = "+" + str(round(difference*100,2))
else:
difference = str(round(difference*100,2))
result = str(round(after_star*100, 2)) + "% ( "+difference+"% )"
print(result)
floaty_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(len(result)*9+40), int(30))
floaty_layer = cairo.Context(floaty_surface)
floaty_layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
UI_color.set(floaty_layer, win, "shot_5")
if not positive:
UI_color.set(floaty_layer, win, "node_badfile")
UI_elements.roundrect(floaty_layer, win,
0,
0,
int(len(result)*9+40),
30,
10)
floaty_layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
floaty_layer.set_font_size(15)
UI_color.set(floaty_layer, win, "text_normal")
floaty_layer.move_to(20,20)
floaty_layer.show_text(result)
floaty = {"fx":win.current["mx"],
"fy":win.current["my"],
"tx":win.current["w"]/2,
"ty":0,
"ff":win.current["frame"],
"tf":win.current["frame"]+200,
"sf":floaty_surface}
print(floaty)
win.floaters.append(floaty)
UI_elements.roundrect(layer, win, UI_elements.roundrect(layer, win,
sx, sx,
sy, sy,

View file

@ -115,6 +115,7 @@ def run(project, win):
# Setting up the global variables. (kinda) # Setting up the global variables. (kinda)
win.animations = {} win.animations = {}
win.floaters = [] # Currently active floating animations.
win.previous = {} win.previous = {}
win.current = {} win.current = {}
win.images = {} win.images = {}
@ -430,6 +431,37 @@ def pmdrawing(pmdrawing, main_layer, win):
main_layer.paint() main_layer.paint()
# Floaters
fdels = []
for n, floaty in enumerate(win.floaters):
fx = floaty["fx"] # From X
fy = floaty["fy"] # From Y
tx = floaty["tx"] # To X
ty = floaty["ty"] # To Y
ff = floaty["ff"] # From Frame
tf = floaty["tf"] # To Frame
sf = floaty["sf"] # Surface
total_frames = tf - ff
passed_frames = win.current["frame"] - ff
frames_fraction = passed_frames / total_frames
if frames_fraction == 1:
fdels.append(n)
x = fx + ( (tx - fx) * frames_fraction )
y = fy + ( (ty - fy) * frames_fraction )
main_layer.set_source_surface(sf, x , y)
main_layer.paint_with_alpha(frames_fraction*-1+1)
for n in fdels:
try:
del win.floaters[n]
except:
pass
print(win.floaters)
win.get_root_window().set_cursor(win.current["cursor"]) win.get_root_window().set_cursor(win.current["cursor"])
# If you press ESC you get back from any window to the main menu. # If you press ESC you get back from any window to the main menu.