diff --git a/game/scripts/animations/transforms.rpy b/game/scripts/animations/transforms.rpy index 19657f26..b06c6e98 100644 --- a/game/scripts/animations/transforms.rpy +++ b/game/scripts/animations/transforms.rpy @@ -123,6 +123,18 @@ transform pulse_hover(t=2.0, strength=0.2, pause=0.0): pause pause repeat +transform smooth_swipe(start_yoffset=0, target_yoffset=-50): + subpixel True + alpha 0.0 + yoffset start_yoffset + parallel: + easeout 0.5 alpha 1.0 + parallel: + easein 4.0 yoffset target_yoffset + parallel: + pause 2.5 + easein 1.5 alpha 0.0 + transform gui_animation: nearest True events False diff --git a/game/scripts/interface/currency.rpy b/game/scripts/interface/currency.rpy index 30d72fd9..ccad553e 100644 --- a/game/scripts/interface/currency.rpy +++ b/game/scripts/interface/currency.rpy @@ -12,8 +12,8 @@ init python: return d, 0.01 screen currency(old, new, prefix): - tag gold - zorder 50 + tag currency + layer "interface" default d = DynamicDisplayable(animate_int_value, old, new, prefix) @@ -26,4 +26,21 @@ screen currency(old, new, prefix): add d yoffset 3 - timer 3.0 action Hide("currency") \ No newline at end of file + timer 3.0 action Hide("currency") + +screen currency_alt(displayables, properties): + tag currency_alt + layer "interface" + + hbox: + properties properties + + for d in displayables: + add d + + timer 4.0 action Hide("currency") + +style currency_alt_text: + outlines [(2, "#000000", 0, 0)] + size 24 + color "#daa520" \ No newline at end of file diff --git a/game/scripts/interface/house_points.rpy b/game/scripts/interface/house_points.rpy index c41eb460..1195419d 100644 --- a/game/scripts/interface/house_points.rpy +++ b/game/scripts/interface/house_points.rpy @@ -35,38 +35,3 @@ init python: points[house] = renpy.random.randint(point // 2, point) + house_points[house] states.env.set_points(points) - -screen house_points(gryffindor=None, slytherin=None, ravenclaw=None, hufflepuff=None, prefix="+", direction="up"): - tag house_points - layer "interface" - - hbox: - spacing 15 - align (0.5, 0.1) - if direction == "up": - at transform: - on start: - alpha 0.0 - on show: - alpha 1.0 - yoffset 0 - easein 4.0 yoffset -50 alpha 0.0 - else: - at transform: - on start: - alpha 0.0 - on show: - alpha 1.0 - yoffset -50 - easein 4.0 yoffset 0 alpha 0.0 - - if gryffindor: - text "[prefix][gryffindor]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#A74D2A" - if slytherin: - text "[prefix][slytherin]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#3A734B" - if ravenclaw: - text "[prefix][ravenclaw]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#5974C2" - if hufflepuff: - text "[prefix][hufflepuff]" outlines [(1, "#000000BF", 1, 0)] size 24 color "#FBC60A" - - timer 4.0 action Hide("house_points") diff --git a/game/scripts/variables.rpy b/game/scripts/variables.rpy index 80190c71..99d306ce 100644 --- a/game/scripts/variables.rpy +++ b/game/scripts/variables.rpy @@ -48,6 +48,28 @@ init python: self.difficulty = 2 self.cheats = False self.moon = True + self.houses = { + "gryffindor": { + "properties": { + "color": "#A74D2A", + } + }, + "slytherin": { + "properties": { + "color": "#3A734B", + } + }, + "ravenclaw": { + "properties": { + "color": "#5974C2", + } + }, + "hufflepuff": { + "properties": { + "color": "#FBC60A", + } + } + } # Currencies @property @@ -56,12 +78,25 @@ init python: @gold.setter def gold(self, value): - old = self._gold + old_value = self._gold + properties = {"pos": (70, 370)} + + if (adjusted := value - old_value) < 0: + displayables = (Text(f"-{adjusted}{{color=#FF0000}}{{size=-12}}{{unicode}} ▼{{/unicode}}{{/size}}{{/color}}", style="currency_alt_text"),) + properties["at"] = smooth_swipe(-50, 0) + else: + displayables = (Text(f"+{adjusted}{{color=#00FF00}}{{size=-12}}{{unicode}} ▲{{/unicode}}{{/size}}{{/color}}", style="currency_alt_text"),) + properties["at"] = smooth_swipe(0, -50) + self._gold = max(0, min(value, 99999)) if not renpy.in_rollback() and not _in_replay: renpy.hide_screen("currency") - renpy.show_screen("currency", old, self._gold, "💰") + renpy.show_screen("currency", old_value, value, "💰") + + if states.room == "main_room": + renpy.hide_screen("currency_alt") + renpy.show_screen("currency_alt", displayables, properties) @property def tokens(self): @@ -96,22 +131,23 @@ init python: # House Points def set_points(self, d): + properties = {"spacing": 15, "align": (0.5, 0.1)} + displayables = [] difference = {} for house, value in d.items(): old_value = self._points[house] if (adjusted := value - old_value) < 0: - prefix = "-" - direction = "down" + disp = At(Text(f"-{adjusted}{{color=#FF0000}}{{size=-12}}{{unicode}} ▼{{/unicode}}{{/size}}{{/color}}", style="currency_alt_text", **self.houses[house]["properties"]), smooth_swipe(-50, 0)) else: - prefix = "+" - direction = "up" + disp = At(Text(f"+{adjusted}{{color=#00FF00}}{{size=-12}}{{unicode}} ▲{{/unicode}}{{/size}}{{/color}}", style="currency_alt_text", **self.houses[house]["properties"]), smooth_swipe(0, -50)) + displayables.append(disp) value = min(max(1, value), 99999) self._points[house] = value difference[house] = adjusted if not renpy.in_rollback() and not _in_replay: - renpy.hide_screen("house_points") - renpy.show_screen("house_points", prefix=prefix, direction=direction, **difference) + renpy.hide_screen("currency_alt") + renpy.show_screen("currency_alt", displayables, properties) @property def gryffindor(self):