-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I tried to create an OutlineLabelConvert that automatically changes a label to a CanvasGroup and sets the correct stuff. There are several shortcomings: 1.This fucks up the node paths and creates crashes 2.CanvasGroup doesn't work well when parents have modulate, so to fix that I had to use top_level and recalculate self_modulate everytime on process, which is a bad solution. (possibly very inefficient) 3.Even with the (2) hacked around, if you manually change the CanvasGroup you have to be careful to change the self_modulate and not modulate, creating many other changes necessary in the code. Using a OutlineLabelConvert is clearly a bad idea. Just changing the labels to a instance of OutlineLabel is better, but (3) would still be a problem and we would need to change everything that changes modulate.
- Loading branch information
Showing
5 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
extends CanvasGroup | ||
|
||
var text: String : | ||
get: | ||
return $Label.text | ||
set(x): | ||
$Label.text = x | ||
|
||
|
||
func _process(dt): | ||
var a := 1.0 | ||
var n := get_parent() | ||
while n != null: | ||
if n.get("modulate") != null: | ||
a *= n.modulate.a | ||
else: | ||
break | ||
n = n.get_parent() | ||
self_modulate.a = a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://dexpbx7tera5u"] | ||
|
||
[ext_resource type="Script" path="res://game/ui/OutlineLabel.gd" id="1_i8vuh"] | ||
|
||
[node name="OutlineLabel" type="CanvasGroup"] | ||
script = ExtResource("1_i8vuh") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class_name OutlineLabelConvert | ||
extends Label | ||
|
||
func _ready() -> void: | ||
call_deferred("put_inside_group") | ||
|
||
func put_inside_group() -> void: | ||
var had_uniq := unique_name_in_owner | ||
var group := preload("res://game/ui/OutlineLabel.tscn").instantiate() | ||
add_sibling(group) | ||
reparent(group) | ||
if had_uniq: | ||
unique_name_in_owner = true |