Lots of localization setup, added controller BBCode stuff also.
This commit is contained in:
@@ -15,15 +15,19 @@ func start() -> void:
|
||||
if !showText:
|
||||
return
|
||||
|
||||
var text:String = "";
|
||||
var textKey:String
|
||||
match getType:
|
||||
GetType.FOUND:
|
||||
text = "Found " + str(quantity) + " " + ITEM.getItemName(itemType, quantity) + ".";
|
||||
textKey = "event.get_item.found"
|
||||
GetType.GIVEN:
|
||||
text = "Received " + str(quantity) + " " + ITEM.getItemName(itemType, quantity) + ".";
|
||||
textKey = "event.get_item.given"
|
||||
_:
|
||||
pass
|
||||
VN.getTextbox().setText(text);
|
||||
|
||||
VN.getTextbox().setText(tr_n(textKey, textKey + "_plural", quantity).format({
|
||||
"item": ITEM.getItemName(itemType, quantity),
|
||||
"quantity": quantity
|
||||
}));
|
||||
|
||||
func isDone() -> bool:
|
||||
if !super.isDone():
|
||||
|
@@ -1,6 +1,7 @@
|
||||
class_name MainMenuScene extends Node
|
||||
|
||||
func _enter_tree() -> void:
|
||||
$Control/Label.text = tr("main_menu.label").format({
|
||||
inputIcon = "[img=32x32]res://icon.svg[/img]"
|
||||
})
|
||||
pass
|
||||
# $Control/Label.text = tr("main_menu.label").format({
|
||||
# inputIcon = "[img=32x32]res://icon.svg[/img]"
|
||||
# })
|
||||
|
@@ -25,31 +25,30 @@ func _enter_tree() -> void:
|
||||
assert(false, "Missing item type: " + Item.Type.find_key(itemType))
|
||||
|
||||
|
||||
static func isStackable(itemType:Item.Type) -> bool:
|
||||
func isStackable(itemType:Item.Type) -> bool:
|
||||
if not ITEM_MAP.has(itemType):
|
||||
return false
|
||||
|
||||
var item:Item = ITEM_MAP[itemType]
|
||||
return item.stackable
|
||||
|
||||
static func getItemName(itemType:Item.Type, count:int = 1) -> String:
|
||||
func getItemName(itemType:Item.Type, count:int = 1) -> String:
|
||||
if not ITEM_MAP.has(itemType):
|
||||
return ""
|
||||
|
||||
|
||||
var item:Item = ITEM_MAP[itemType]
|
||||
if count > 1:
|
||||
return str(count) + "x " + item.title
|
||||
else:
|
||||
return item.title
|
||||
return tr_n(item.title, item.title + "_plural", count).format({
|
||||
"count": count
|
||||
})
|
||||
|
||||
static func getItemDescription(itemType:Item.Type) -> String:
|
||||
func getItemDescription(itemType:Item.Type) -> String:
|
||||
if not ITEM_MAP.has(itemType):
|
||||
return ""
|
||||
|
||||
var item:Item = ITEM_MAP[itemType]
|
||||
return item.description_text
|
||||
|
||||
static func getItemCategory(itemType:Item.Type) -> Item.Category:
|
||||
func getItemCategory(itemType:Item.Type) -> Item.Category:
|
||||
if not ITEM_MAP.has(itemType):
|
||||
return Item.Category.INGREDIENT
|
||||
|
||||
|
44
scripts/UI/AdvancedRichText.gd
Normal file
44
scripts/UI/AdvancedRichText.gd
Normal file
@@ -0,0 +1,44 @@
|
||||
@tool
|
||||
class_name AdvancedRichText extends RichTextLabel
|
||||
|
||||
@export_multiline var advancedText:String = "":
|
||||
get():
|
||||
return advancedText
|
||||
set(value):
|
||||
advancedText = value
|
||||
_parseAdvancedText()
|
||||
|
||||
@export var translate:bool = true:
|
||||
set(value):
|
||||
translate = value
|
||||
_parseAdvancedText()
|
||||
get():
|
||||
return translate
|
||||
|
||||
func _init() -> void:
|
||||
self._parseAdvancedText()
|
||||
|
||||
func _enter_tree() -> void:
|
||||
self._parseAdvancedText()
|
||||
|
||||
func _parseAdvancedText() -> void:
|
||||
if advancedText.is_empty():
|
||||
self.text = ""
|
||||
return
|
||||
var key = advancedText
|
||||
if self.translate:
|
||||
key = tr(key)
|
||||
self.text = processInputTags(key)
|
||||
|
||||
func processInputTags(text:String) -> String:
|
||||
var regex = RegEx.new()
|
||||
regex.compile(r"\[input action=(.*?)\](.*?)\[/input\]")
|
||||
var result = text
|
||||
for match in regex.search_all(text):
|
||||
var action = match.get_string(1).to_lower()
|
||||
var height:int = 32
|
||||
# var device = get_current_device_type()
|
||||
# var icon_path = get_icon_for_action(action, device)
|
||||
var img_tag = "[img height=%d valign=center,center]res://textures/input/%s.tres[/img]" % [ height, action ]
|
||||
result = result.replace(match.get_string(0), img_tag)
|
||||
return result
|
1
scripts/UI/AdvancedRichText.gd.uid
Normal file
1
scripts/UI/AdvancedRichText.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cq6bvma0kk6tg
|
1
scripts/UI/ExtendedRichText.gd.uid
Normal file
1
scripts/UI/ExtendedRichText.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bxj2865tb1u8r
|
1
scripts/UI/RichTextInputAction.gd.uid
Normal file
1
scripts/UI/RichTextInputAction.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bemtfi2rxy7ls
|
Reference in New Issue
Block a user