mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-21 15:08:12 +00:00
fonts can now have custom variations via jsons
This commit is contained in:
6
Assets/Sprites/UI/FontMain.json
Normal file
6
Assets/Sprites/UI/FontMain.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"variations": {
|
||||
"SMB1": {"source": "Font.fnt"},
|
||||
"SMBLL": {"source": "FontLL.fnt"}
|
||||
}
|
||||
}
|
5
Assets/Sprites/UI/ScoreFont.json
Normal file
5
Assets/Sprites/UI/ScoreFont.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"variations": {
|
||||
"default": {"source": "ScoreFont.fnt"}
|
||||
}
|
||||
}
|
@@ -146,7 +146,6 @@ layer = 0
|
||||
script = ExtResource("1_f34v2")
|
||||
|
||||
[node name="Main" type="HBoxContainer" parent="."]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(256, 32)
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
@@ -242,7 +241,6 @@ offset_left = 4.0
|
||||
offset_top = -12.0
|
||||
offset_right = 36.0
|
||||
offset_bottom = 4.0
|
||||
theme_override_fonts/font = ExtResource("17_2w8b3")
|
||||
text = "*03"
|
||||
|
||||
[node name="CoinIcon" type="AnimatedSprite2D" parent="Main/CoinCount"]
|
||||
@@ -267,7 +265,6 @@ offset_left = 4.0
|
||||
offset_top = -4.0
|
||||
offset_right = 36.0
|
||||
offset_bottom = 12.0
|
||||
theme_override_fonts/font = ExtResource("17_2w8b3")
|
||||
text = "*00"
|
||||
|
||||
[node name="RedCoins" type="Control" parent="Main"]
|
||||
@@ -585,6 +582,7 @@ custom_minimum_size = Vector2(24, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ModernHUD" type="Control" parent="."]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(256, 0)
|
||||
layout_mode = 3
|
||||
anchors_preset = 10
|
||||
|
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=56 format=3 uid="uid://c3h2iqkvitqd2"]
|
||||
[gd_scene load_steps=58 format=3 uid="uid://c3h2iqkvitqd2"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bod0jkf7jc5pm" path="res://Scenes/Prefabs/GameHud.tscn" id="1_ctvpw"]
|
||||
[ext_resource type="Script" uid="uid://bbxqn16ekbpcl" path="res://Scripts/Classes/Singletons/Global.gd" id="1_t23sr"]
|
||||
@@ -23,6 +23,8 @@
|
||||
[ext_resource type="Script" uid="uid://cbal8ms2oe1ik" path="res://Scripts/Classes/Components/ResourceSetterNew.gd" id="19_okfpr"]
|
||||
[ext_resource type="Texture2D" uid="uid://bhgjvnslkt143" path="res://Assets/Sprites/UI/PanelSelected.png" id="19_xspbb"]
|
||||
[ext_resource type="JSON" path="res://Assets/Sprites/UI/Cursor.json" id="20_3l3ph"]
|
||||
[ext_resource type="JSON" path="res://Assets/Sprites/UI/FontMain.json" id="23_3l3ph"]
|
||||
[ext_resource type="JSON" path="res://Assets/Sprites/UI/ScoreFont.json" id="24_m6bur"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_6jmk5"]
|
||||
resource_name = "FadeIn"
|
||||
@@ -441,6 +443,22 @@ metadata/_custom_type_script = "uid://cbal8ms2oe1ik"
|
||||
script = ExtResource("18_1la0o")
|
||||
metadata/_custom_type_script = "uid://ctsjagoa5t33f"
|
||||
|
||||
[node name="MainFontGetter" type="Node" parent="FontUpdater" node_paths=PackedStringArray("node_to_affect")]
|
||||
script = ExtResource("19_okfpr")
|
||||
node_to_affect = NodePath("..")
|
||||
property_name = "main_font"
|
||||
mode = 4
|
||||
resource_json = ExtResource("23_3l3ph")
|
||||
metadata/_custom_type_script = "uid://cbal8ms2oe1ik"
|
||||
|
||||
[node name="ScoreFontGetter" type="Node" parent="FontUpdater" node_paths=PackedStringArray("node_to_affect")]
|
||||
script = ExtResource("19_okfpr")
|
||||
node_to_affect = NodePath("..")
|
||||
property_name = "score_font"
|
||||
mode = 4
|
||||
resource_json = ExtResource("24_m6bur")
|
||||
metadata/_custom_type_script = "uid://cbal8ms2oe1ik"
|
||||
|
||||
[node name="TextShadowColourChanger" type="Node" parent="." node_paths=PackedStringArray("labels")]
|
||||
script = ExtResource("19_l7dvb")
|
||||
labels = [NodePath("../CanvasLayer/VBoxContainer/ErrorMessage"), NodePath("../CanvasLayer/VBoxContainer/Comment"), NodePath("../CanvasLayer/VBoxContainer/Warning"), NodePath("../GameHUD/FPSCount")]
|
||||
|
@@ -10,7 +10,7 @@ extends Node
|
||||
resource_json = value
|
||||
update_resource()
|
||||
|
||||
enum ResourceMode {SPRITE_FRAMES, TEXTURE, AUDIO, RAW}
|
||||
enum ResourceMode {SPRITE_FRAMES, TEXTURE, AUDIO, RAW, FONT}
|
||||
@export var use_cache := true
|
||||
|
||||
static var cache := {}
|
||||
@@ -156,6 +156,9 @@ func get_resource(json_file: JSON) -> Resource:
|
||||
resource = load_audio_from_path(source_resource_path)
|
||||
ResourceMode.RAW:
|
||||
pass
|
||||
ResourceMode.FONT:
|
||||
resource = FontFile.new()
|
||||
resource.load_bitmap_font(source_resource_path)
|
||||
if cache.has(json_file.resource_path) == false and use_cache and not is_random:
|
||||
cache[json_file.resource_path] = resource
|
||||
return resource
|
||||
|
@@ -1,12 +1,10 @@
|
||||
class_name FontUpdater
|
||||
extends Node
|
||||
|
||||
@onready var resource_getter_smb1 := ResourceGetter.new()
|
||||
@onready var resource_getter_smbll := ResourceGetter.new()
|
||||
@onready var resource_getter_score := ResourceGetter.new()
|
||||
var main_font: Resource = null
|
||||
var score_font: Resource = null
|
||||
|
||||
@onready var FONT_LL_MAIN = load("uid://djxdgxy1iv8yv")
|
||||
@onready var FONT_MAIN = load("uid://bl7sbw4nx3l1t")
|
||||
var FONT_MAIN = preload("uid://bl7sbw4nx3l1t")
|
||||
@onready var SCORE_FONT = load("uid://cflgloiossd8a")
|
||||
|
||||
|
||||
@@ -17,6 +15,5 @@ func _ready() -> void:
|
||||
Global.level_theme_changed.connect(update_fonts)
|
||||
|
||||
func update_fonts() -> void:
|
||||
FONT_MAIN.base_font = resource_getter_smb1.get_resource(FONT_MAIN.base_font)
|
||||
FONT_LL_MAIN.base_font = resource_getter_smbll.get_resource(FONT_LL_MAIN.base_font)
|
||||
SCORE_FONT.base_font = resource_getter_score.get_resource(SCORE_FONT.base_font)
|
||||
FONT_MAIN.base_font = main_font
|
||||
SCORE_FONT.base_font = score_font
|
||||
|
@@ -3,8 +3,7 @@ extends Node
|
||||
|
||||
@export var labels: Array[Label]
|
||||
|
||||
const SMB1 = preload("uid://bl7sbw4nx3l1t")
|
||||
const SMBLL = preload("uid://djxdgxy1iv8yv")
|
||||
const MAIN_FONT = preload("uid://bl7sbw4nx3l1t")
|
||||
const SCORE_FONT = preload("uid://bk0no5p6sifgu")
|
||||
|
||||
@export var use_score_font := false
|
||||
@@ -16,18 +15,11 @@ func _ready() -> void:
|
||||
Global.level_theme_changed.connect(refresh_font)
|
||||
|
||||
func refresh_font() -> void:
|
||||
if Global.current_campaign == "SMBLL":
|
||||
current_font = SMBLL
|
||||
else:
|
||||
current_font = SMB1
|
||||
update_labels()
|
||||
|
||||
func update_labels() -> void:
|
||||
var font_to_use = current_font
|
||||
if use_score_font:
|
||||
font_to_use = SCORE_FONT
|
||||
for i in labels:
|
||||
if i == null:
|
||||
continue
|
||||
i.remove_theme_font_override("font")
|
||||
i.add_theme_font_override("font", font_to_use)
|
||||
i.add_theme_font_override("font", MAIN_FONT)
|
||||
|
Reference in New Issue
Block a user