Keep utility pages within menu bounds
This commit is contained in:
parent
3dbfd74b6c
commit
1f3308d83b
3 changed files with 200 additions and 85 deletions
|
|
@ -3253,8 +3253,13 @@ func _finish_menu_entry(generation: int) -> void:
|
||||||
_presentation_tween = null
|
_presentation_tween = null
|
||||||
_transitioning = false
|
_transitioning = false
|
||||||
_set_shell_interactive(true)
|
_set_shell_interactive(true)
|
||||||
|
# A queued TAB press closes the menu immediately after its entry animation.
|
||||||
|
# Do that before scheduling deferred focus so the closing menu cannot leave a
|
||||||
|
# stale grab_focus call targeting controls that have just been disabled.
|
||||||
|
if _backpack_toggle_queued:
|
||||||
|
_consume_queued_backpack_toggle()
|
||||||
|
return
|
||||||
_reset_controller_zone_for_section()
|
_reset_controller_zone_for_section()
|
||||||
_consume_queued_backpack_toggle()
|
|
||||||
|
|
||||||
|
|
||||||
func _begin_menu_exit(reason: CloseReason, restore_controls: bool) -> void:
|
func _begin_menu_exit(reason: CloseReason, restore_controls: bool) -> void:
|
||||||
|
|
|
||||||
|
|
@ -470,77 +470,94 @@ func _build_active_rows() -> void:
|
||||||
_add_empty("No authenticated players.")
|
_add_empty("No authenticated players.")
|
||||||
return
|
return
|
||||||
for entry: PlayerListEntry in entries:
|
for entry: PlayerListEntry in entries:
|
||||||
var row := _make_row()
|
_build_active_player_row(entry)
|
||||||
var identity := Label.new()
|
|
||||||
identity.custom_minimum_size.x = 250
|
|
||||||
identity.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
func _build_active_player_row(entry: PlayerListEntry) -> void:
|
||||||
var markers: Array[String] = []
|
var row := _make_active_player_row()
|
||||||
if entry.is_host:
|
var identity_row := HBoxContainer.new()
|
||||||
markers.append("host")
|
identity_row.add_theme_constant_override("separation", 8)
|
||||||
if entry.is_operator:
|
row.add_child(identity_row)
|
||||||
markers.append("operator")
|
|
||||||
if entry.is_local_player:
|
var identity := Label.new()
|
||||||
markers.append("You")
|
identity.clip_text = true
|
||||||
identity.text = "%s%s · %s\n%s" % [
|
identity.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||||
entry.display_name,
|
identity.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
" [%s]" % ", ".join(markers) if not markers.is_empty() else "",
|
var markers: Array[String] = []
|
||||||
entry.compact_fingerprint,
|
if entry.is_host:
|
||||||
entry.continuity_state,
|
markers.append("host")
|
||||||
]
|
if entry.is_operator:
|
||||||
identity.tooltip_text = "Full identity fingerprint:\n%s" % (
|
markers.append("operator")
|
||||||
entry.full_fingerprint
|
if entry.is_local_player:
|
||||||
)
|
markers.append("You")
|
||||||
identity.add_theme_color_override(
|
identity.text = "%s%s · %s\n%s" % [
|
||||||
"font_color", UtilityPageStyle.OCEAN_TEXT_PRIMARY
|
entry.display_name,
|
||||||
)
|
" [%s]" % ", ".join(markers) if not markers.is_empty() else "",
|
||||||
row.add_child(identity)
|
entry.compact_fingerprint,
|
||||||
var ping := Label.new()
|
entry.continuity_state,
|
||||||
ping.custom_minimum_size.x = 60
|
]
|
||||||
ping.text = (
|
identity.tooltip_text = "Full identity fingerprint:\n%s" % (
|
||||||
"Local" if entry.is_host
|
entry.full_fingerprint
|
||||||
else "%d ms" % entry.ping_to_host_ms
|
)
|
||||||
if entry.ping_to_host_ms >= 0 else "—"
|
identity.add_theme_color_override(
|
||||||
)
|
"font_color", UtilityPageStyle.OCEAN_TEXT_PRIMARY
|
||||||
ping.add_theme_color_override(
|
)
|
||||||
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
identity_row.add_child(identity)
|
||||||
)
|
var ping := Label.new()
|
||||||
row.add_child(ping)
|
ping.custom_minimum_size.x = 72
|
||||||
var mute := Button.new()
|
ping.text = (
|
||||||
var mute_action: String = "unmute" if entry.muted else "mute"
|
"Local" if entry.is_host
|
||||||
mute.disabled = entry.is_local_player
|
else "%d ms" % entry.ping_to_host_ms
|
||||||
mute.pressed.connect(_toggle_mute.bind(entry))
|
if entry.ping_to_host_ms >= 0 else "—"
|
||||||
_configure_moderation_button(mute, MODERATION_MUTE_ICON, mute_action)
|
)
|
||||||
row.add_child(mute)
|
ping.add_theme_color_override(
|
||||||
var block := Button.new()
|
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
||||||
block.disabled = entry.is_local_player
|
)
|
||||||
block.pressed.connect(_confirm_block.bind(entry))
|
ping.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||||
_configure_moderation_button(block, MODERATION_BLOCK_ICON, "block")
|
identity_row.add_child(ping)
|
||||||
row.add_child(block)
|
|
||||||
if entry.can_manage_operator:
|
var actions := HBoxContainer.new()
|
||||||
var operator := Button.new()
|
actions.alignment = BoxContainer.ALIGNMENT_END
|
||||||
operator.text = "deop" if entry.is_operator else "op"
|
actions.add_theme_constant_override("separation", 6)
|
||||||
operator.pressed.connect(_confirm_operator.bind(entry))
|
row.add_child(actions)
|
||||||
UtilityPageStyle.apply_compact_ocean_button(operator)
|
var mute := Button.new()
|
||||||
row.add_child(operator)
|
var mute_action: String = "unmute" if entry.muted else "mute"
|
||||||
var clear_art := Button.new()
|
mute.disabled = entry.is_local_player
|
||||||
clear_art.text = "clear art"
|
mute.pressed.connect(_toggle_mute.bind(entry))
|
||||||
clear_art.disabled = not entry.can_clear_art
|
_configure_moderation_button(mute, MODERATION_MUTE_ICON, mute_action)
|
||||||
clear_art.tooltip_text = (
|
actions.add_child(mute)
|
||||||
"Remove every shared artwork this player participated in."
|
var block := Button.new()
|
||||||
)
|
block.disabled = entry.is_local_player
|
||||||
clear_art.pressed.connect(_confirm_clear_art.bind(entry))
|
block.pressed.connect(_confirm_block.bind(entry))
|
||||||
UtilityPageStyle.apply_compact_ocean_button(clear_art)
|
_configure_moderation_button(block, MODERATION_BLOCK_ICON, "block")
|
||||||
row.add_child(clear_art)
|
actions.add_child(block)
|
||||||
var kick := Button.new()
|
if entry.can_manage_operator:
|
||||||
kick.disabled = not entry.can_kick
|
var operator := Button.new()
|
||||||
kick.pressed.connect(_confirm_kick.bind(entry))
|
operator.text = "deop" if entry.is_operator else "op"
|
||||||
_configure_moderation_button(kick, MODERATION_KICK_ICON, "kick")
|
operator.pressed.connect(_confirm_operator.bind(entry))
|
||||||
row.add_child(kick)
|
UtilityPageStyle.apply_compact_ocean_button(operator)
|
||||||
var ban := Button.new()
|
operator.custom_minimum_size = MODERATION_BUTTON_SIZE
|
||||||
ban.disabled = not entry.can_ban
|
actions.add_child(operator)
|
||||||
ban.pressed.connect(_confirm_ban.bind(entry))
|
var clear_art := Button.new()
|
||||||
_configure_moderation_button(ban, MODERATION_BAN_ICON, "ban")
|
clear_art.text = "clear art"
|
||||||
row.add_child(ban)
|
clear_art.disabled = not entry.can_clear_art
|
||||||
|
clear_art.tooltip_text = (
|
||||||
|
"Remove every shared artwork this player participated in."
|
||||||
|
)
|
||||||
|
clear_art.pressed.connect(_confirm_clear_art.bind(entry))
|
||||||
|
UtilityPageStyle.apply_compact_ocean_button(clear_art)
|
||||||
|
clear_art.custom_minimum_size = Vector2(84.0, 40.0)
|
||||||
|
actions.add_child(clear_art)
|
||||||
|
var kick := Button.new()
|
||||||
|
kick.disabled = not entry.can_kick
|
||||||
|
kick.pressed.connect(_confirm_kick.bind(entry))
|
||||||
|
_configure_moderation_button(kick, MODERATION_KICK_ICON, "kick")
|
||||||
|
actions.add_child(kick)
|
||||||
|
var ban := Button.new()
|
||||||
|
ban.disabled = not entry.can_ban
|
||||||
|
ban.pressed.connect(_confirm_ban.bind(entry))
|
||||||
|
_configure_moderation_button(ban, MODERATION_BAN_ICON, "ban")
|
||||||
|
actions.add_child(ban)
|
||||||
|
|
||||||
|
|
||||||
func _configure_moderation_button(
|
func _configure_moderation_button(
|
||||||
|
|
@ -580,8 +597,9 @@ func _build_session_artwork_controls() -> void:
|
||||||
var counts: Vector2i = _service.get_session_artwork_counts()
|
var counts: Vector2i = _service.get_session_artwork_counts()
|
||||||
var row := _make_row()
|
var row := _make_row()
|
||||||
var label := Label.new()
|
var label := Label.new()
|
||||||
label.custom_minimum_size.x = 600
|
|
||||||
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
label.clip_text = true
|
||||||
|
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||||
label.text = "session artwork · %d layers · %d painted pixels" % [
|
label.text = "session artwork · %d layers · %d painted pixels" % [
|
||||||
counts.x, counts.y,
|
counts.x, counts.y,
|
||||||
]
|
]
|
||||||
|
|
@ -611,8 +629,9 @@ func _build_relationship_rows() -> void:
|
||||||
for record: Dictionary in records:
|
for record: Dictionary in records:
|
||||||
var row := _make_row()
|
var row := _make_row()
|
||||||
var label := Label.new()
|
var label := Label.new()
|
||||||
label.custom_minimum_size.x = 560
|
|
||||||
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
label.clip_text = true
|
||||||
|
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||||
var fingerprint := str(record["fingerprint"])
|
var fingerprint := str(record["fingerprint"])
|
||||||
label.text = "%s · %s %s" % [
|
label.text = "%s · %s %s" % [
|
||||||
str(record.get("last_known_display_name", "Player")),
|
str(record.get("last_known_display_name", "Player")),
|
||||||
|
|
@ -651,8 +670,9 @@ func _build_ban_rows() -> void:
|
||||||
var row := _make_row()
|
var row := _make_row()
|
||||||
var fingerprint := str(record["target_fingerprint"])
|
var fingerprint := str(record["target_fingerprint"])
|
||||||
var label := Label.new()
|
var label := Label.new()
|
||||||
label.custom_minimum_size.x = 600
|
|
||||||
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
label.clip_text = true
|
||||||
|
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||||
label.text = "%s · %s banned %s" % [
|
label.text = "%s · %s banned %s" % [
|
||||||
str(record.get("last_known_display_name", "Player")),
|
str(record.get("last_known_display_name", "Player")),
|
||||||
NetworkIdentityCrypto.compact_suffix(fingerprint),
|
NetworkIdentityCrypto.compact_suffix(fingerprint),
|
||||||
|
|
@ -683,6 +703,20 @@ func _make_row() -> HBoxContainer:
|
||||||
return row
|
return row
|
||||||
|
|
||||||
|
|
||||||
|
func _make_active_player_row() -> VBoxContainer:
|
||||||
|
var panel := PanelContainer.new()
|
||||||
|
panel.clip_contents = true
|
||||||
|
panel.add_theme_stylebox_override(
|
||||||
|
"panel", UtilityPageStyle.row_style(false)
|
||||||
|
)
|
||||||
|
_list.add_child(panel)
|
||||||
|
var row := VBoxContainer.new()
|
||||||
|
row.custom_minimum_size.y = 88
|
||||||
|
row.add_theme_constant_override("separation", 4)
|
||||||
|
panel.add_child(row)
|
||||||
|
return row
|
||||||
|
|
||||||
|
|
||||||
func _add_empty(text: String) -> void:
|
func _add_empty(text: String) -> void:
|
||||||
var label := Label.new()
|
var label := Label.new()
|
||||||
label.text = text
|
label.text = text
|
||||||
|
|
|
||||||
|
|
@ -311,15 +311,17 @@ func _build_job_rows(jobs: Array[Dictionary], empty_text: String) -> void:
|
||||||
return
|
return
|
||||||
for job: Dictionary in jobs:
|
for job: Dictionary in jobs:
|
||||||
var row := PanelContainer.new()
|
var row := PanelContainer.new()
|
||||||
|
row.clip_contents = true
|
||||||
row.add_theme_stylebox_override(
|
row.add_theme_stylebox_override(
|
||||||
"panel", UtilityPageStyle.row_style(false)
|
"panel", UtilityPageStyle.row_style(false)
|
||||||
)
|
)
|
||||||
var content := HBoxContainer.new()
|
var content := HBoxContainer.new()
|
||||||
content.add_theme_constant_override("separation", 14)
|
content.clip_contents = true
|
||||||
|
content.add_theme_constant_override("separation", 10)
|
||||||
row.add_child(content)
|
row.add_child(content)
|
||||||
|
|
||||||
var text_column := VBoxContainer.new()
|
var text_column := VBoxContainer.new()
|
||||||
text_column.custom_minimum_size.x = 245.0
|
text_column.custom_minimum_size.x = 220.0
|
||||||
text_column.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
text_column.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
content.add_child(text_column)
|
content.add_child(text_column)
|
||||||
var title := Label.new()
|
var title := Label.new()
|
||||||
|
|
@ -334,6 +336,8 @@ func _build_job_rows(jobs: Array[Dictionary], empty_text: String) -> void:
|
||||||
var description := Label.new()
|
var description := Label.new()
|
||||||
description.text = str(job.get("description", ""))
|
description.text = str(job.get("description", ""))
|
||||||
description.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
description.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
description.max_lines_visible = 2
|
||||||
|
description.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||||
description.add_theme_font_size_override("font_size", 16)
|
description.add_theme_font_size_override("font_size", 16)
|
||||||
description.add_theme_color_override(
|
description.add_theme_color_override(
|
||||||
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
||||||
|
|
@ -343,7 +347,8 @@ func _build_job_rows(jobs: Array[Dictionary], empty_text: String) -> void:
|
||||||
var target: int = int(job.get("target", 1))
|
var target: int = int(job.get("target", 1))
|
||||||
var progress: int = int(job.get("progress", 0))
|
var progress: int = int(job.get("progress", 0))
|
||||||
var progress_bar := ProgressBar.new()
|
var progress_bar := ProgressBar.new()
|
||||||
progress_bar.custom_minimum_size = Vector2(100.0, 24.0)
|
progress_bar.custom_minimum_size = Vector2(104.0, 24.0)
|
||||||
|
progress_bar.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||||
progress_bar.max_value = float(target)
|
progress_bar.max_value = float(target)
|
||||||
progress_bar.value = float(progress)
|
progress_bar.value = float(progress)
|
||||||
progress_bar.show_percentage = false
|
progress_bar.show_percentage = false
|
||||||
|
|
@ -360,24 +365,30 @@ func _build_job_rows(jobs: Array[Dictionary], empty_text: String) -> void:
|
||||||
content.add_child(progress_bar)
|
content.add_child(progress_bar)
|
||||||
|
|
||||||
var count := Label.new()
|
var count := Label.new()
|
||||||
count.custom_minimum_size.x = 54.0
|
count.custom_minimum_size.x = 82.0
|
||||||
count.text = "%d / %d" % [progress, target]
|
count.clip_text = true
|
||||||
|
count.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||||
|
count.text = "%s / %s" % [
|
||||||
|
_compact_integer(progress),
|
||||||
|
_compact_integer(target),
|
||||||
|
]
|
||||||
|
count.tooltip_text = "%d / %d" % [progress, target]
|
||||||
count.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
count.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||||
count.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
count.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||||
|
count.add_theme_font_size_override("font_size", 14)
|
||||||
count.add_theme_color_override(
|
count.add_theme_color_override(
|
||||||
"font_color", UtilityPageStyle.OCEAN_TEXT_PRIMARY
|
"font_color", UtilityPageStyle.OCEAN_TEXT_PRIMARY
|
||||||
)
|
)
|
||||||
content.add_child(count)
|
content.add_child(count)
|
||||||
|
|
||||||
var reward := _make_reward_display(
|
var reward := _make_job_reward_display(
|
||||||
int(job.get("fish_coin", 0)),
|
int(job.get("fish_coin", 0)),
|
||||||
int(job.get("experience", 0)),
|
int(job.get("experience", 0)),
|
||||||
)
|
)
|
||||||
reward.custom_minimum_size.x = 128.0
|
|
||||||
content.add_child(reward)
|
content.add_child(reward)
|
||||||
|
|
||||||
var claim := Button.new()
|
var claim := Button.new()
|
||||||
claim.custom_minimum_size = Vector2(76.0, 36.0)
|
claim.custom_minimum_size = Vector2(72.0, 36.0)
|
||||||
var claimable: bool = bool(job.get("claimable", false))
|
var claimable: bool = bool(job.get("claimable", false))
|
||||||
claim.text = "claim" if claimable else (
|
claim.text = "claim" if claimable else (
|
||||||
"done" if int(job.get("completed_count", 0)) > 0 else "working"
|
"done" if int(job.get("completed_count", 0)) > 0 else "working"
|
||||||
|
|
@ -457,17 +468,21 @@ func _claim(claim_id: String) -> void:
|
||||||
|
|
||||||
func _make_reward_display(fish_coin: int, experience: int) -> HBoxContainer:
|
func _make_reward_display(fish_coin: int, experience: int) -> HBoxContainer:
|
||||||
var reward := HBoxContainer.new()
|
var reward := HBoxContainer.new()
|
||||||
reward.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
reward.tooltip_text = "%d fish coins · %d xp" % [fish_coin, experience]
|
||||||
reward.add_theme_constant_override("separation", 7)
|
reward.add_theme_constant_override("separation", 7)
|
||||||
var currency: CurrencyAmount = (
|
var currency: CurrencyAmount = (
|
||||||
CurrencyPresentationType.instantiate_amount(fish_coin, 18.0)
|
CurrencyPresentationType.instantiate_amount(fish_coin, 18.0)
|
||||||
)
|
)
|
||||||
|
currency.set_amount_text(_compact_integer(fish_coin))
|
||||||
|
currency.tooltip_text = "%d fish coins" % fish_coin
|
||||||
currency.get_amount_label().add_theme_color_override(
|
currency.get_amount_label().add_theme_color_override(
|
||||||
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
||||||
)
|
)
|
||||||
reward.add_child(currency)
|
reward.add_child(currency)
|
||||||
var experience_label := Label.new()
|
var experience_label := Label.new()
|
||||||
experience_label.text = "• %d xp" % experience
|
experience_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
experience_label.text = "• %s xp" % _compact_integer(experience)
|
||||||
|
experience_label.tooltip_text = "%d xp" % experience
|
||||||
experience_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
experience_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||||
experience_label.add_theme_color_override(
|
experience_label.add_theme_color_override(
|
||||||
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
||||||
|
|
@ -476,6 +491,67 @@ func _make_reward_display(fish_coin: int, experience: int) -> HBoxContainer:
|
||||||
return reward
|
return reward
|
||||||
|
|
||||||
|
|
||||||
|
func _make_job_reward_display(
|
||||||
|
fish_coin: int,
|
||||||
|
experience: int,
|
||||||
|
) -> VBoxContainer:
|
||||||
|
var reward := VBoxContainer.new()
|
||||||
|
reward.custom_minimum_size.x = 104.0
|
||||||
|
reward.tooltip_text = "%d fish coins · %d xp" % [fish_coin, experience]
|
||||||
|
reward.add_theme_constant_override("separation", 1)
|
||||||
|
var currency: CurrencyAmount = (
|
||||||
|
CurrencyPresentationType.instantiate_amount(fish_coin, 16.0)
|
||||||
|
)
|
||||||
|
currency.set_amount_text(_compact_integer(fish_coin))
|
||||||
|
currency.tooltip_text = "%d fish coins" % fish_coin
|
||||||
|
currency.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
currency.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||||
|
currency.get_amount_label().add_theme_font_size_override("font_size", 14)
|
||||||
|
currency.get_amount_label().add_theme_color_override(
|
||||||
|
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
||||||
|
)
|
||||||
|
reward.add_child(currency)
|
||||||
|
var experience_label := Label.new()
|
||||||
|
experience_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
experience_label.text = "%s xp" % _compact_integer(experience)
|
||||||
|
experience_label.tooltip_text = "%d xp" % experience
|
||||||
|
experience_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||||
|
experience_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||||
|
experience_label.add_theme_font_size_override("font_size", 14)
|
||||||
|
experience_label.add_theme_color_override(
|
||||||
|
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
||||||
|
)
|
||||||
|
reward.add_child(experience_label)
|
||||||
|
return reward
|
||||||
|
|
||||||
|
|
||||||
|
func _compact_integer(value: int) -> String:
|
||||||
|
var magnitude: int = absi(value)
|
||||||
|
var divisor: float = 1.0
|
||||||
|
var suffix: String = ""
|
||||||
|
if magnitude >= 1_000_000_000_000:
|
||||||
|
divisor = 1_000_000_000_000.0
|
||||||
|
suffix = "t"
|
||||||
|
elif magnitude >= 1_000_000_000:
|
||||||
|
divisor = 1_000_000_000.0
|
||||||
|
suffix = "b"
|
||||||
|
elif magnitude >= 1_000_000:
|
||||||
|
divisor = 1_000_000.0
|
||||||
|
suffix = "m"
|
||||||
|
elif magnitude >= 1_000:
|
||||||
|
divisor = 1_000.0
|
||||||
|
suffix = "k"
|
||||||
|
else:
|
||||||
|
return str(value)
|
||||||
|
var scaled: float = float(value) / divisor
|
||||||
|
var number: String = (
|
||||||
|
str(roundi(scaled))
|
||||||
|
if absf(scaled) >= 100.0
|
||||||
|
else ("%.1f" % scaled).trim_suffix(".0")
|
||||||
|
)
|
||||||
|
return number + suffix
|
||||||
|
|
||||||
|
|
||||||
func _add_empty(message: String) -> void:
|
func _add_empty(message: String) -> void:
|
||||||
var empty := Label.new()
|
var empty := Label.new()
|
||||||
empty.text = message
|
empty.text = message
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue