mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-09 21:27:13 +08:00
refactor(资源管理): 集中资源加载逻辑到ComponentManager
将分散在各处的资源加载逻辑统一到ComponentManager中管理 添加对UI组件、主题、物品纹理和饲料的集中管理 移除SkillIconBase.tscn并迁移到UI目录
This commit is contained in:
@@ -23,4 +23,4 @@ static var idMap = {
|
||||
ItemType.SOUL: "soul",
|
||||
}
|
||||
static func getTexture(type: ItemType) -> Texture2D:
|
||||
return load("res://resources/items/%s.svg" % idMap[type])
|
||||
return ComponentManager.getItemTexture(idMap[type])
|
||||
|
||||
@@ -3,6 +3,10 @@ class_name ComponentManager
|
||||
static var bullets = {}
|
||||
static var characters = {}
|
||||
static var effects = {}
|
||||
static var feeds = []
|
||||
static var uiComponents = {}
|
||||
static var themes = {}
|
||||
static var itemTextures = {}
|
||||
|
||||
static func init():
|
||||
for i in DirTool.listdir("res://components/Bullets"):
|
||||
@@ -11,9 +15,27 @@ static func init():
|
||||
characters[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||
for i in DirTool.listdir("res://components/Effects"):
|
||||
effects[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||
for i in DirTool.listdir("res://components/Feeds"):
|
||||
feeds.append(load(i))
|
||||
for i in DirTool.listdir("res://components/UI"):
|
||||
uiComponents[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||
for i in DirTool.listdir("res://themes"):
|
||||
themes[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||
for i in DirTool.listdir("res://resources/items"):
|
||||
itemTextures[DirTool.getBasenameWithoutExtension(i)] = load("res://resources/items/%s" % i)
|
||||
static func getBullet(name: String):
|
||||
return bullets[name]
|
||||
static func getCharacter(name: String):
|
||||
return characters[name]
|
||||
static func getEffect(name: String):
|
||||
return effects[name]
|
||||
static func getFeed(index: int):
|
||||
return feeds[index]
|
||||
static func getUIComponent(name: String):
|
||||
return uiComponents[name]
|
||||
static func getTheme(name: String):
|
||||
return themes[name]
|
||||
static func getItemTexture(name: String):
|
||||
return itemTextures[name]
|
||||
static func readResource(path: String):
|
||||
return load("res://resources/%s" % path)
|
||||
|
||||
@@ -3,7 +3,7 @@ class_name QuickUI
|
||||
static func smallText(text: String, center: bool = true):
|
||||
var label = Label.new()
|
||||
label.text = text
|
||||
label.theme = load("res://themes/smallText.tres")
|
||||
label.theme = ComponentManager.getTheme("smallText")
|
||||
if center:
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
return label
|
||||
@@ -15,4 +15,4 @@ static func graySmallText(text: String, center: bool = true):
|
||||
label.label_settings.font_color = Color(0.6, 0.6, 0.6, 1)
|
||||
if center:
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
return label
|
||||
return label
|
||||
|
||||
Reference in New Issue
Block a user