Skip to content

Commit ffc6c1f

Browse files
wgetJaneTimGoll
andauthored
Add option to select preferred unit of length for distance displays (#1774)
fixes #1770 this is a draft rn since it's untested, will test later --------- Co-authored-by: Tim Goll <github@timgoll.de>
1 parent 7001db9 commit ffc6c1f

File tree

23 files changed

+299
-58
lines changed

23 files changed

+299
-58
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
44

55
## Unreleased
66

7+
### Added
8+
9+
- Added option to select preferred unit of length for distance displays (by @wgetJane)
10+
711
### Changed
812
- Updated Russian and English localization files (by @Satton2)
913

gamemodes/terrortown/entities/entities/ttt_beacon.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ if CLIENT then
252252
local owner = ent:GetOriginator()
253253
local nick = IsValid(owner) and owner:Nick() or "---"
254254

255-
local distance = math.Round(util.HammerUnitsToMeters(mvData:GetEntityDistance()), 1)
255+
local distance = util.DistanceToString(mvData:GetEntityDistance(), 1)
256256

257257
mvData:EnableText()
258258

gamemodes/terrortown/entities/entities/ttt_c4/shared.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ else -- CLIENT
843843
local nick = IsValid(owner) and owner:Nick() or "---"
844844

845845
local time = util.SimpleTime(ent:GetExplodeTime() - CurTime(), "%02i:%02i")
846-
local distance = math.Round(util.HammerUnitsToMeters(mvData:GetEntityDistance()), 1)
846+
local distance = util.DistanceToString(mvData:GetEntityDistance(), 1)
847847

848848
mvData:EnableText()
849849

gamemodes/terrortown/entities/entities/ttt_radio.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ if CLIENT then
352352
local originator = ent:GetOriginator()
353353
local nick = IsValid(originator) and originator:Nick() or "---"
354354

355-
local distance = math.Round(util.HammerUnitsToMeters(mvData:GetEntityDistance()), 1)
355+
local distance = util.DistanceToString(mvData:GetEntityDistance(), 1)
356356

357357
mvData:EnableText()
358358

gamemodes/terrortown/entities/weapons/weapon_ttt_wtester.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,8 @@ if CLIENT then
576576
local vectorToPos = targetPos - scannerPos
577577
local angleToPos = vectorToPos:Angle()
578578
local arrowRotation = angleToPos.yaw - EyeAngles().yaw
579-
local distance = tostring(
580-
math.Round(
581-
util.HammerUnitsToMeters(LocalPlayer():EyePos():Distance(targetPos)),
582-
0
583-
)
584-
) .. "m"
579+
local distance =
580+
util.DistanceToString(LocalPlayer():EyePos():Distance(targetPos), 0)
585581

586582
surface.SetDrawColor(96, 255, 96, 255)
587583
surface.SetMaterial(dna_screen_arrow)

lua/terrortown/entities/items/item_ttt_radar/cl_init.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ local function DrawTarget(tgt, size, offset, no_shrink)
119119

120120
-- Drawing full size?
121121
if sz == size then
122-
local text = tostring(
123-
math.Round(util.HammerUnitsToMeters(LocalPlayer():EyePos():Distance(tgt.pos)), 0)
124-
) .. "m"
122+
local text = util.DistanceToString(LocalPlayer():EyePos():Distance(tgt.pos), 0)
125123
local w, h = surface.GetTextSize(text)
126124

127125
-- Show range to target

lua/terrortown/lang/de.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,11 +2070,11 @@ L.flaregun_help_primary = "Körper/Entität verbrennen"
20702070

20712071
-- 2023-12-14
20722072
L.marker_vision_owner = "Besitzer: {owner}"
2073-
L.marker_vision_distance = "Distanz: {distance}m"
2074-
L.marker_vision_distance_collapsed = "{distance}m"
2073+
L.marker_vision_distance = "Distanz: {distance}"
2074+
L.marker_vision_distance_collapsed = "{distance}"
20752075

20762076
L.c4_marker_vision_time = "Explosionszeit: {time}"
2077-
L.c4_marker_vision_collapsed = "{time} / {distance}m"
2077+
L.c4_marker_vision_collapsed = "{time} / {distance}"
20782078

20792079
L.c4_marker_vision_safe_zone = "Bombensicherheitszone"
20802080
L.c4_marker_vision_damage_zone = "Bombenschadenszone"
@@ -2801,3 +2801,14 @@ L.label_voice_activation_mode_toggle_enabled = "Umschalten (Aktiviert zum Start)
28012801
--Plays sounds to distract or deceive.
28022802
--
28032803
--Place the radio somewhere, and then remotely interact with it to choose sounds to play.]]
2804+
2805+
-- 2025-02-21
2806+
L.length_in_meters = "{length}m"
2807+
--L.length_in_yards = "{length}yd"
2808+
--L.length_in_feet = "{length}ft"
2809+
2810+
--L.label_distance_unit = "Preferred unit of length for distance displays"
2811+
--L.choice_distance_unit_0 = "Inches"
2812+
--L.choice_distance_unit_1 = "Meters"
2813+
--L.choice_distance_unit_2 = "Yards"
2814+
--L.choice_distance_unit_3 = "Feet"

lua/terrortown/lang/en.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,11 +2076,11 @@ L.flaregun_help_primary = "Burn body/entity"
20762076

20772077
-- 2023-12-14
20782078
L.marker_vision_owner = "Owner: {owner}"
2079-
L.marker_vision_distance = "Distance: {distance}m"
2080-
L.marker_vision_distance_collapsed = "{distance}m"
2079+
L.marker_vision_distance = "Distance: {distance}"
2080+
L.marker_vision_distance_collapsed = "{distance}"
20812081

20822082
L.c4_marker_vision_time = "Detonation time: {time}"
2083-
L.c4_marker_vision_collapsed = "{time} / {distance}m"
2083+
L.c4_marker_vision_collapsed = "{time} / {distance}"
20842084

20852085
L.c4_marker_vision_safe_zone = "Bomb safe zone"
20862086
L.c4_marker_vision_damage_zone = "Bomb damage zone"
@@ -2807,3 +2807,14 @@ L.radio_desc = [[
28072807
Plays sounds to distract or deceive.
28082808
28092809
Place the radio somewhere, and then remotely interact with it to choose sounds to play.]]
2810+
2811+
-- 2025-02-21
2812+
L.length_in_meters = "{length}m"
2813+
L.length_in_yards = "{length}yd"
2814+
L.length_in_feet = "{length}ft"
2815+
2816+
L.label_distance_unit = "Preferred unit of length for distance displays"
2817+
L.choice_distance_unit_0 = "Inches"
2818+
L.choice_distance_unit_1 = "Meters"
2819+
L.choice_distance_unit_2 = "Yards"
2820+
L.choice_distance_unit_3 = "Feet"

lua/terrortown/lang/es.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,11 +2076,11 @@ L.search_eyes = "Gracias a tus habilidades de detective, has identificado que la
20762076

20772077
-- 2023-12-14
20782078
--L.marker_vision_owner = "Owner: {owner}"
2079-
--L.marker_vision_distance = "Distance: {distance}m"
2080-
--L.marker_vision_distance_collapsed = "{distance}m"
2079+
--L.marker_vision_distance = "Distance: {distance}"
2080+
--L.marker_vision_distance_collapsed = "{distance}"
20812081

20822082
--L.c4_marker_vision_time = "Detonation time: {time}"
2083-
--L.c4_marker_vision_collapsed = "{time} / {distance}m"
2083+
--L.c4_marker_vision_collapsed = "{time} / {distance}"
20842084

20852085
--L.c4_marker_vision_safe_zone = "Bomb safe zone"
20862086
--L.c4_marker_vision_damage_zone = "Bomb damage zone"
@@ -2807,3 +2807,14 @@ L.decoy_help_primary = "Colocar el señuelo"
28072807
--Plays sounds to distract or deceive.
28082808
--
28092809
--Place the radio somewhere, and then remotely interact with it to choose sounds to play.]]
2810+
2811+
-- 2025-02-21
2812+
--L.length_in_meters = "{length}m"
2813+
--L.length_in_yards = "{length}yd"
2814+
--L.length_in_feet = "{length}ft"
2815+
2816+
--L.label_distance_unit = "Preferred unit of length for distance displays"
2817+
--L.choice_distance_unit_0 = "Inches"
2818+
--L.choice_distance_unit_1 = "Meters"
2819+
--L.choice_distance_unit_2 = "Yards"
2820+
--L.choice_distance_unit_3 = "Feet"

lua/terrortown/lang/fr.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,11 +2070,11 @@ L.flaregun_help_primary = "Brûler un corps/une entité"
20702070

20712071
-- 2023-12-14
20722072
L.marker_vision_owner = "Propriétaire : {owner}"
2073-
L.marker_vision_distance = "Distance : {distance}m"
2074-
L.marker_vision_distance_collapsed = "{distance}m"
2073+
L.marker_vision_distance = "Distance : {distance}"
2074+
L.marker_vision_distance_collapsed = "{distance}"
20752075

20762076
L.c4_marker_vision_time = "Temps avant détonation : {time}"
2077-
L.c4_marker_vision_collapsed = "{time} / {distance}m"
2077+
L.c4_marker_vision_collapsed = "{time} / {distance}"
20782078

20792079
L.c4_marker_vision_safe_zone = "Zone hors de portée du C4"
20802080
L.c4_marker_vision_damage_zone = "Zone de dégâts du C4"
@@ -2801,3 +2801,14 @@ L.vehicle_enter = "Appuyez sur [{usekey}] pour entrer dans le véhicule"
28012801
--Plays sounds to distract or deceive.
28022802
--
28032803
--Place the radio somewhere, and then remotely interact with it to choose sounds to play.]]
2804+
2805+
-- 2025-02-21
2806+
L.length_in_meters = "{length}m"
2807+
--L.length_in_yards = "{length}yd"
2808+
--L.length_in_feet = "{length}ft"
2809+
2810+
--L.label_distance_unit = "Preferred unit of length for distance displays"
2811+
--L.choice_distance_unit_0 = "Inches"
2812+
--L.choice_distance_unit_1 = "Meters"
2813+
--L.choice_distance_unit_2 = "Yards"
2814+
--L.choice_distance_unit_3 = "Feet"

0 commit comments

Comments
 (0)