shadow_text theme for speedrun clock!

Chat bubble shadow (=
clock_show = SPEED.TRADE, trade between MAP and FILE when in puzzle or hub.
MenuBase close select() fix.
clock_decimals = 0 to 3 for pad_decimals
This commit is contained in:
Harmony Honey 2023-03-03 21:18:33 -05:00
parent fbdad23a45
commit e6aa7a1f24
15 changed files with 140 additions and 46 deletions

View file

@ -18,10 +18,28 @@ z_as_relative = false
script = ExtResource( 2 )
[node name="Bubble" type="Node2D" parent="."]
position = Vector2( 0, -30 )
[node name="Shadow" type="Node2D" parent="Bubble"]
modulate = Color( 0, 0, 0, 0.501961 )
position = Vector2( 7, 10 )
[node name="Triangle" type="Polygon2D" parent="Bubble/Shadow"]
position = Vector2( 0, 37.5 )
polygon = PoolVector2Array( -21.5, 0, 21.5, 0, 0, 40 )
[node name="Rect" type="Polygon2D" parent="Bubble/Shadow"]
texture = ExtResource( 1 )
texture_offset = Vector2( 0, 50 )
texture_scale = Vector2( 0, 1 )
polygon = PoolVector2Array( 260, 0.0999985, 259.062, 8.42228, 256.296, 16.3273, 251.84, 23.4185, 245.919, 29.3405, 238.827, 33.7962, 230.922, 36.5623, 222.6, 37.5, -222.6, 37.5, -230.922, 36.5623, -238.827, 33.7962, -245.919, 29.3405, -251.84, 23.4185, -256.296, 16.3273, -259.062, 8.42228, -260, 0.0999952, -260, -0.100002, -259.062, -8.42228, -256.296, -16.3273, -251.841, -23.4185, -245.919, -29.3405, -238.827, -33.7962, -230.922, -36.5623, -222.6, -37.5, 222.6, -37.5, 230.922, -36.5623, 238.827, -33.7962, 245.919, -29.3405, 251.84, -23.4185, 256.296, -16.3273, 259.062, -8.42228, 260, -0.0999919 )
script = ExtResource( 4 )
is_baked = false
size = Vector2( 260, 37.5 )
radius = Plane( -2, -1, -1, -1 )
[node name="Triangle" type="Polygon2D" parent="Bubble"]
position = Vector2( 0, 37.5 )
scale = Vector2( 1e-05, 1e-05 )
polygon = PoolVector2Array( -21.5, 0, 21.5, 0, 0, 40 )
[node name="Rect" type="Polygon2D" parent="Bubble"]
@ -50,6 +68,7 @@ custom_fonts/font = SubResource( 3 )
text = "I do adore the flowers"
align = 1
valign = 2
percent_visible = 1.27778
[node name="Label" type="Label" parent="Bubble/Center"]
margin_left = -240.0
@ -61,3 +80,4 @@ custom_fonts/font = SubResource( 3 )
text = "I do adore the flowers"
align = 1
valign = 2
percent_visible = 1.22222

View file

@ -128,7 +128,7 @@ export (Array, String, MULTILINE) var lines := ["Lovely day!", "I do adore the f
export (String, MULTILINE) var queue_write := "" setget set_queue_write
onready var chat := get_node_or_null("Sprites/Chat")
onready var arrow := get_node_or_null("Sprites/Arrow")
export var chat_offset := Vector2(0, -120) setget set_chat_offset
export var chat_offset := Vector2(0, -130) setget set_chat_offset
func _enter_tree():
if Engine.editor_hint: return

View file

@ -59,16 +59,7 @@ func _physics_process(delta):
is_clock = false
func activate():
if not "hub" in scene_path and scene_path.begins_with(Shared.worlds_path):
UI.clock_ease.show = arrow.is_active and Shared.clock_show > 0
var m = scene_path.lstrip(Shared.worlds_path).rstrip(".tscn")
UI.clock_best.visible = Shared.goals.has(m)
if UI.clock_best.visible:
UI.clock_best.text = "Best: " + Shared.time_string(Shared.goals[m], true)
UI.clock_goal.visible = Shared.speedruns.has(m)
if UI.clock_goal.visible:
UI.clock_goal.text = "Goal: " + Shared.time_string(Shared.speedruns[m], true)
Shared.speedrun_goal(scene_path, arrow.is_active)
func on_enter():
Shared.collect_gem()

View file

@ -7,13 +7,14 @@ onready var label := $Bubble/Center/Label
onready var rect := $Bubble/Rect
onready var triangle := $Bubble/Triangle
onready var arrow := $"../Arrow"
onready var shadows := $Bubble/Shadow.get_children()
export (Array, String, MULTILINE) var lines := ["Lovely day!", "I do adore the flowers", "Haven't seen you before (:"]
export (String, MULTILINE) var queue_write := "" setget set_queue_write
export (String, MULTILINE) var dialog := "I do adore the flowers" setget set_dialog
export var is_editor := false
export var is_show := false
export var is_show := false setget set_is_show
export var panel_grow := Vector2(20, 17)
export var show_range := Vector2(0, -30)
var panel_min := Vector2(35, 55)
@ -49,8 +50,10 @@ func _physics_process(delta):
if rect and triangle:
if panel_easy.clock < panel_easy.time:
rect.size = panel_easy.move(delta, is_show)
shadows[1].size = rect.size
triangle.position.y = rect.size.y
triangle.scale = Vector2.ONE * s
shadows[0].transform = triangle.transform
# input
key_up = Input.is_action_pressed("ui_up")
@ -104,6 +107,10 @@ func set_dialog(arg := dialog):
panel_easy.to = (label.get_font("font").get_string_size(dialog) / 2.0) + panel_grow
panel_easy.to.x = max(panel_easy.to.x, panel_min.y)
func set_is_show(arg := is_show):
is_show = arg
set_dialog()
func _on_Arrow_open():
if !is_show:
is_show = true

View file

@ -20,9 +20,12 @@ signal scene_changed
var gem_count := 0
var goals := {}
var clock_rank := 0
enum SPEED {OFF, MAP, FILE, BOTH}
enum SPEED {OFF, MAP, FILE, BOTH, TRADE}
var clock_show := 0
var clock_alpha := 0.5
var clock_alpha := 1.0
var clock_decimals := 2
var clock_best_color := [Color.white, Color("ffff00")]
var speedruns := {
"1/2": 11,
"1/3": 17.5,
@ -173,8 +176,8 @@ func _physics_process(delta):
map_clock += delta
# clock label
UI.clock_file.text = time_string(save_time, true)
UI.clock_map.text = time_string(map_clock, true)
UI.clock_file.text = time_string(save_time, clock_decimals)
UI.clock_map.text = time_string(map_clock, clock_decimals)
# auto save
auto_save_clock += delta
@ -182,11 +185,11 @@ func _physics_process(delta):
auto_save_clock = 0.0
save_data()
func time_string(t := 0.0, is_decimal = false, is_min := false, is_hour := false):
func time_string(t := 0.0, dec = 2, is_min := false, is_hour := false):
# time
var s_hour = str(int(t) / 3600) + ":" if is_hour or t > 3600 else ""
var s_min = str((int(t) / 60) % 60).pad_zeros(2 if s_hour else 0) + ":" if is_min or t > 60 else ""
var s_sec = str(fmod(t, 60)).pad_zeros(2).pad_decimals(2 if is_decimal else 0)
var s_sec = str(fmod(t, 60)).pad_zeros(2).pad_decimals(dec)
return s_hour + s_min + s_sec
@ -245,6 +248,8 @@ func change_scene():
break
if is_instance_valid(door_in): break
speedrun_goal(csfn, map_name != "" and not "hub" in map_name)
emit_signal("scene_changed")
func toggle_fullscreen():
@ -315,6 +320,20 @@ func collect_clocks(g := goals):
c += 1
return c
func speedrun_goal(scene_path := csfn, _show := true):
if not "hub" in scene_path and scene_path.begins_with(worlds_path):
UI.clock_ease.show = _show and clock_show > 0
var m = scene_path.lstrip(worlds_path).rstrip(".tscn")
UI.clock_best.visible = goals.has(m)
if UI.clock_best.visible:
var g = goals[m]
UI.clock_best.text = "Best: " + time_string(g, 2)
UI.clock_best.modulate = clock_best_color[int(goals[m] > 0 and goals[m] < speedruns[m])]
UI.clock_goal.visible = speedruns.has(m)
if UI.clock_goal.visible:
UI.clock_goal.text = "Goal: " + time_string(speedruns[m], 2)
### Volume
func set_volume(bus = 0, vol = 0):
@ -507,6 +526,7 @@ func save_options():
o["mouse"] = bool(Input.mouse_mode == Input.MOUSE_MODE_VISIBLE)
o["clock_show"] = int(clock_show)
o["clock_alpha"] = float(clock_alpha)
o["clock_decimals"] = int(clock_decimals)
file_save_json("user://options.json", o)
@ -534,6 +554,8 @@ func load_options():
clock_show = int(d["clock_show"])
if d.has("clock_alpha"):
clock_alpha = float(d["clock_alpha"])
if d.has("clock_decimals"):
clock_decimals = int(d["clock_decimals"])
func save_keys(path := "user://keys.tres"):
var s_keys = SaveDict.new()

View file

@ -46,13 +46,15 @@ func _physics_process(delta):
clock_down.modulate.a = clock_ease.count(delta)
func scene_changed():
func scene_changed(override := false):
up.clock = 0.0
var m = Shared.map_name != ""
var m = Shared.map_name != "" or override
var h = "hub" in Shared.map_name
var b = Shared.clock_show == Shared.SPEED.BOTH
clock_file.visible = m and (b or Shared.clock_show == Shared.SPEED.FILE)
clock_map.visible = not "hub" in Shared.map_name and m and (b or Shared.clock_show == Shared.SPEED.MAP)
clock_ease.show = false
var t = Shared.clock_show == Shared.SPEED.TRADE
clock_file.visible = m and ((t and h) or (b or Shared.clock_show == Shared.SPEED.FILE))
clock_map.visible = m and !h and (t or b or Shared.clock_show == Shared.SPEED.MAP)
clock_ease.show = m and !h and Shared.clock_show > 0
func menu_keys(accept := "", cancel := ""):
var c = $Control/Keys/List.get_children()

View file

@ -1,17 +1,13 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://src/theme/shadow_text.tres" type="Theme" id=1]
[ext_resource path="res://media/font/profile/UI_Keys.tres" type="DynamicFont" id=2]
[ext_resource path="res://media/font/profile/UI_gem.tres" type="DynamicFont" id=3]
[ext_resource path="res://media/font/mini-wakuwaku.otf" type="DynamicFontData" id=4]
[ext_resource path="res://src/actor/Clock.tscn" type="PackedScene" id=5]
[ext_resource path="res://src/actor/Gem.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/menu/options/Key.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/autoload/UI.gd" type="Script" id=10]
[sub_resource type="DynamicFont" id=1]
size = 50
font_data = ExtResource( 4 )
[node name="UI" type="CanvasLayer"]
pause_mode = 2
layer = 10
@ -173,7 +169,6 @@ action = "ui_cancel"
is_connect = true
[node name="Clock" type="VBoxContainer" parent="Control"]
modulate = Color( 1, 1, 1, 0.5 )
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = 20.0
@ -183,16 +178,17 @@ margin_bottom = -20.0
rect_min_size = Vector2( 300, 200 )
[node name="File" type="Label" parent="Control/Clock"]
modulate = Color( 1, 0.95, 0.95, 1 )
margin_right = 600.0
margin_bottom = 51.0
custom_fonts/font = SubResource( 1 )
text = "3:57"
theme = ExtResource( 1 )
text = "1:48:02"
[node name="Map" type="Label" parent="Control/Clock"]
margin_top = 55.0
margin_right = 600.0
margin_bottom = 106.0
custom_fonts/font = SubResource( 1 )
theme = ExtResource( 1 )
text = "3:57"
[node name="Spacer" type="Control" parent="Control/Clock"]
@ -207,14 +203,16 @@ margin_right = 600.0
margin_bottom = 680.0
[node name="Best" type="Label" parent="Control/Clock/Down"]
modulate = Color( 1, 1, 0, 1 )
margin_right = 600.0
margin_bottom = 51.0
custom_fonts/font = SubResource( 1 )
text = "Best 4:38"
theme = ExtResource( 1 )
text = "Best 17.49"
[node name="Goal" type="Label" parent="Control/Clock/Down"]
modulate = Color( 0.341176, 1, 0.341176, 1 )
margin_top = 55.0
margin_right = 600.0
margin_bottom = 106.0
custom_fonts/font = SubResource( 1 )
text = "Goal 2:16"
theme = ExtResource( 1 )
text = "Goal 23.50"

View file

@ -28,7 +28,7 @@ func set_card():
clocks.visible = clock_label.text != "0"
# time
time_label.text = Shared.time_string(d[slot]["time"], false, true)
time_label.text = Shared.time_string(d[slot]["time"], 0, true)
else:
is_new = true

View file

@ -152,7 +152,7 @@ func set_open(arg := is_open):
is_open = arg
if is_open:
cursor = 0
self.cursor = 0
fill_items()
UI.menu_keys(text_accept, text_cancel)
open()

View file

@ -21,6 +21,7 @@ func open():
func close():
Shared.save_options()
UI.scene_changed()
func open_remap(is_gamepad := false):
MenuRemap.is_gamepad = is_gamepad

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=21 format=2]
[gd_scene load_steps=22 format=2]
[ext_resource path="res://media/image/UI/clock.png" type="Texture" id=1]
[ext_resource path="res://media/font/profile/OptionsItem.tres" type="DynamicFont" id=2]
@ -19,6 +19,7 @@
[ext_resource path="res://src/menu/options/scroll/Vsync.gd" type="Script" id=17]
[ext_resource path="res://src/menu/options/scroll/Mouse.gd" type="Script" id=18]
[ext_resource path="res://src/menu/options/scroll/Borderless.gd" type="Script" id=19]
[ext_resource path="res://src/menu/options/scroll/SpeedDec.gd" type="Script" id=20]
[sub_resource type="StyleBoxFlat" id=18]
bg_color = Color( 0.75, 0.375, 0.38125, 1 )
@ -538,7 +539,7 @@ script = ExtResource( 15 )
__meta__ = {
"_edit_use_anchors_": false
}
list = PoolStringArray( "OFF", "MAP", "FILE", "BOTH" )
list = PoolStringArray( "OFF", "MAP", "FILE", "BOTH", "TRADE" )
[node name="Label" type="Label" parent="Control/Menu/List/Speedrun"]
anchor_right = 0.5
@ -592,5 +593,35 @@ text = "< HALF >"
align = 2
valign = 1
[node name="Decimals" type="Control" parent="Control/Menu/List" groups=["speed"]]
margin_top = 1370.0
margin_right = 640.0
margin_bottom = 1440.0
rect_min_size = Vector2( 0, 70 )
script = ExtResource( 20 )
__meta__ = {
"_edit_use_anchors_": false
}
count = 3
[node name="Label" type="Label" parent="Control/Menu/List/Decimals"]
anchor_right = 0.5
anchor_bottom = 1.0
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "Decimals"
valign = 1
[node name="Label2" type="Label" parent="Control/Menu/List/Decimals"]
anchor_left = 0.5
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 25.0
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "< 2 >"
align = 2
valign = 1
[editable path="Control/Menu/List/Music"]
[editable path="Control/Menu/List/SFX"]

View file

@ -7,3 +7,4 @@ func _ready():
func set_value():
Shared.clock_alpha = float(cursor + 1) / list.size()
UI.clock.modulate.a = Shared.clock_alpha
UI.scene_changed(true)

View file

@ -6,8 +6,5 @@ func _ready():
func set_value():
Shared.clock_show = cursor
var b = cursor == Shared.SPEED.BOTH
UI.clock_file.visible = b or Shared.clock_show == Shared.SPEED.FILE
UI.clock_map.visible = b or Shared.clock_show == Shared.SPEED.MAP
UI.scene_changed(true)
MenuOptions.fill_items()

View file

@ -0,0 +1,9 @@
extends Scroll
func _ready():
cursor = Shared.clock_decimals
set_label()
func set_value():
Shared.clock_decimals = cursor
UI.scene_changed(true)

View file

@ -0,0 +1,15 @@
[gd_resource type="Theme" load_steps=3 format=2]
[ext_resource path="res://media/font/mini-wakuwaku.otf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=2]
size = 50
font_data = ExtResource( 1 )
[resource]
default_font = SubResource( 2 )
Label/colors/font_color = Color( 1, 1, 1, 1 )
Label/colors/font_color_shadow = Color( 0.3, 0.3, 0.3, 0.25098 )
Label/constants/shadow_offset_x = 5
Label/constants/shadow_offset_y = 7
Label/fonts/font = SubResource( 2 )