Skip to content

Commit 6bd86b9

Browse files
authored
Merge pull request YimMenu-Lua#133 from YimMenu-Lua/translator_fmt
feat(Translator): add string formatting
2 parents 709d0af + 1c8047f commit 6bd86b9

23 files changed

Lines changed: 100 additions & 94 deletions

File tree

SSV2/includes/classes/gta/CWheel.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ local VEC3_ZERO <const> = vec3:zero()
4242
---@field m_suspension_raise pointer<float>
4343
---@field m_unk_suspension_raise pointer<float>
4444
---@field m_suspension_fwd_offset pointer<float>
45-
---@field m_hydraulic_state pointer<int32_t> some enum related to hydraulic state. can't find any refs online. where's Yimura when you need to skid from him? :(
46-
---@field m_hydraulic_state_2 pointer<int32_t> -- ??
45+
---@field m_hydraulic_state pointer<uint32_t> some enum related to hydraulic state. can't find any refs online. where's Yimura when you need to skid from him? :(
46+
---@field m_hydraulic_state_2 pointer<uint32_t> -- ??
4747
---@field m_suspension_compression pointer<float>
4848
---@field m_suspension_compression_2 pointer<float>
4949
---@field m_wheel_compression pointer<float>
50-
---@field m_rotation_angle pointer -- radians?
51-
---@field m_rotation_speed pointer -- velocity
52-
---@field m_unk_0174 pointer -- ??
50+
---@field m_rotation_angle pointer<float> -- radians?
51+
---@field m_rotation_speed pointer<float> -- velocity
52+
---@field m_unk_0174 pointer<float> -- ?? don't know what this is. using float to keep the 4 byte alignment
5353
---@field m_tyre_temperature pointer<float> -- don't want to admit how long it took to figure out what this little shit is. are we playing Assetto Corsa now? it seems to only be relevant for F1 vehicles
54-
---@field m_unk_0194 pointer -- ??
54+
---@field m_unk_0194 pointer<float> -- ??
5555
---@field m_tire_drag_coeff pointer<float>
5656
---@field m_top_speed_mult pointer<float>
5757
---@field m_steering_angle pointer<float>
@@ -61,7 +61,7 @@ local VEC3_ZERO <const> = vec3:zero()
6161
---@field m_suspension_health pointer<float> -- 100.0f: car gets slammed (old method of shooting your suspension to stance your car) // 0.0f: wheel should fall off but doesn't. Something else must be set to trigger wheel detachment
6262
---@field m_tyre_health pointer<float> -- <= 500.0f: flat tyre // 0.0f: no tyre
6363
---@field m_tyre_wear_mult pointer<float> -- 0.0f: tyres won't burst from long burnout
64-
---@field m_tyre_wear_unk pointer<float> -- similar? // looks like a wear rate not current tyre wear
64+
---@field m_tyre_wear_unk pointer<float> -- similar? // looks like rate rather than a multiplier
6565
---@field m_wheel_dynamic_flags pointer<eWheelDynamicFlags>
6666
---@field m_wheel_config_flags pointer<eWheelConfigFlags>
6767
---@field m_tyre_is_burst pointer<bool>
@@ -75,8 +75,8 @@ local CWheel = CStructView("CWheel", 0x020E)
7575
function CWheel.new(ptr)
7676
return setmetatable({
7777
m_ptr = ptr,
78-
m_rotation = fVector3(ptr:add(0x0004)),
79-
m_rotation_inv = fVector3(ptr:add(0x000A)),
78+
m_rotation = fVector3(ptr:add(0x0000)),
79+
m_rotation_inv = fVector3(ptr:add(0x000C)),
8080
m_offset_from_body = ptr:add(0x0020),
8181
m_x_offset = ptr:add(0x0030),
8282
m_last_ground_pos = fVector3(ptr:add(0x003C)),

SSV2/includes/data/stancer_data.lua

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-- * Provide a copy of or a link to the original license (GPL-3.0 or later); see LICENSE.md or <https://www.gnu.org/licenses/>.
88

99

10-
---@alias ptr_read fun(w: CWheel): anyval
10+
---@alias ptr_read fun(w: CWheel, veh?: PlayerVehicle): float
1111

1212
---@enum eWheelAxle
1313
Enums.eWheelAxle = {
@@ -16,23 +16,20 @@ Enums.eWheelAxle = {
1616
}
1717

1818
return {
19-
---@type array<{ key: string, axle: eWheelAxle, read: ptr_read, write: fun(w: CWheel, v: anyval, veh?: PlayerVehicle), side_dont_care?: boolean}>
19+
---@type array<{ key: string, axle: eWheelAxle, read: ptr_read, write: fun(w: CWheel, v: float, veh?: PlayerVehicle), side_dont_care?: boolean}>
2020
decorators = {
2121
{
2222
key = "m_toe",
2323
axle = Enums.eWheelAxle.FRONT,
24-
read = function(w) return w.m_rotation.x end,
25-
write = function(w, v)
26-
w.m_rotation.x = v
27-
w.m_rotation_inv.x = -v
28-
end
24+
read = function(w) return w.m_rotation.y end,
25+
write = function(w, v) w.m_rotation.y = v end
2926
},
3027
{
3128
key = "m_camber",
3229
axle = Enums.eWheelAxle.FRONT,
3330
read = function(w) return w.m_rotation.y end,
3431
write = function(w, v)
35-
w.m_rotation.y = v
32+
w.m_rotation.z = v
3633
w.m_rotation_inv.y = -v
3734
end
3835
},
@@ -53,9 +50,9 @@ return {
5350
key = "m_wheel_width",
5451
axle = Enums.eWheelAxle.FRONT, -- doesn't matter
5552
side_dont_care = true,
56-
read = function(w) return w.m_tyre_width:get_float() end,
57-
write = function(w, v, veh)
58-
w.m_tyre_width:set_float(v)
53+
read = function() return 0 end,
54+
write = function(_, v, veh)
55+
---@type float?
5956
local cached = Decorator:GetDecor(veh:GetHandle(), "m_visual_width")
6057
if (cached and cached > 0 and veh:GetVisualWheelWidth() ~= cached + v) then
6158
veh:SetVisualWheelWidth(cached + v)
@@ -66,9 +63,9 @@ return {
6663
key = "m_wheel_size",
6764
axle = Enums.eWheelAxle.FRONT, -- doesn't matter
6865
side_dont_care = true,
69-
read = function(w) return w.m_tyre_radius:get_float() end,
70-
write = function(w, v, veh)
71-
w.m_tyre_radius:set_float(v)
66+
read = function() return 0 end,
67+
write = function(_, v, veh)
68+
---@type float?
7269
local cached = Decorator:GetDecor(veh:GetHandle(), "m_visual_size")
7370
if (cached and cached > 0 and veh:GetVisualWheelSize() ~= cached + v) then
7471
veh:SetVisualWheelSize(cached + v)
@@ -78,18 +75,15 @@ return {
7875
{
7976
key = "m_toe",
8077
axle = Enums.eWheelAxle.REAR,
81-
read = function(w) return w.m_rotation.x end,
82-
write = function(w, v)
83-
w.m_rotation.x = v
84-
w.m_rotation_inv.x = -v
85-
end
78+
read = function(w) return w.m_rotation.y end,
79+
write = function(w, v) w.m_rotation.y = v end
8680
},
8781
{
8882
key = "m_camber",
8983
axle = Enums.eWheelAxle.REAR,
90-
read = function(w) return w.m_rotation.y end,
84+
read = function(w) return w.m_rotation.z end,
9185
write = function(w, v)
92-
w.m_rotation.y = v
86+
w.m_rotation.z = v
9387
w.m_rotation_inv.y = -v
9488
end
9589
},

SSV2/includes/features/extra/billionaire_services/BillionaireServicesV2.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,7 @@ function BillionaireServices:CallPrivateJet(model, airportData)
647647
self:RegisterEntity(jet:GetHandle())
648648
self:RegisterEntity(jet.pilot)
649649
self:RegisterEntity(jet.copilot)
650-
651-
Notifier:ShowMessage("Billionaire Services",
652-
_F(_T("BSV2_JET_SPAWN_SUCCESS"), jet.name, airportData.name)
653-
)
650+
Notifier:ShowMessage("Billionaire Services", _T("BSV2_JET_SPAWN_SUCCESS", jet.name, airportData.name))
654651
end)
655652
end
656653

SSV2/includes/features/extra/entity_forge/EntityForge.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ function EntityForge:AddModelToFavorites(model, name, _type)
13551355

13561356
self.FavoriteModels[model] = { name = name, entityType = _type }
13571357
self:ParseFavorites()
1358-
Notifier:ShowSuccess("EntityForge", _F(_T("EF_FAV_SAVE_SUCCESS"), name))
1358+
Notifier:ShowSuccess("EntityForge", _T("EF_FAV_SAVE_SUCCESS", name))
13591359
end
13601360

13611361
---@param modelHash hash

SSV2/includes/features/online/CasinoPacino.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ function CasinoPacino:GetCooldownString()
380380
local max_chip_wins = tunables.get_int("VC_CASINO_CHIP_MAX_WIN_DAILY")
381381

382382
return (chipswon_gd >= max_chip_wins)
383-
and _F(_T("CP_COOLDOWN_BYPASS_STATUS_FORMAT"), minutes_left)
383+
and _T("CP_COOLDOWN_BYPASS_STATUS_FORMAT", minutes_left)
384384
or _T("CP_COOLDOWN_BYPASS_STATUS_OFF")
385385
end
386386

SSV2/includes/features/vehicle/stancer.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ function Stancer:RestoreDeltasFromQueue()
521521

522522
for _, v in ipairs(StancerData.decorators) do
523523
local queued_key = _F("%s_%d_queue", v.key, v.axle)
524-
local val = Decorator:GetDecor(handle, queued_key)
524+
local val = Decorator:GetDecor(handle, queued_key)
525525
if (type(val) == "number") then
526526
self.m_deltas[v.axle][v.key] = val
527527
end
@@ -549,7 +549,7 @@ function Stancer:ReadDefaultValues()
549549
self:ForEach(wheel_array, function(i, cwheel)
550550
local decor = _F("%s_%d_%d", v.key, v.axle, i)
551551
local existsOn = Decorator:ExistsOn(handle, decor)
552-
local default_val = existsOn and Decorator:GetDecor(handle, decor) or v.read(cwheel)
552+
local default_val = existsOn and Decorator:GetDecor(handle, decor) or v.read(cwheel, self.m_entity)
553553
if (not existsOn) then
554554
Decorator:Register(handle, decor, default_val)
555555
end
@@ -652,7 +652,7 @@ function Stancer:Update()
652652
local base = self.m_base_values[v.axle][v.key]
653653
local sum = base + delta
654654
self:ForEach(wheel_array, function(_, cwheel)
655-
local current = v.read(cwheel)
655+
local current = v.read(cwheel, self.m_entity)
656656
local desired = v.side_dont_care and sum or self:GetValueBySideLR(cwheel, sum)
657657
if (math.abs(desired) ~= math.abs(current)) then
658658
v.write(cwheel, desired, self.m_entity)

SSV2/includes/frontend/billionaire_services/escort_groups_ui.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ local function drawGroupCreatorStep1()
370370
local groups = BSV2:GetEscortGroupList()
371371
local exists = groups[newGroup.nameBuffer] ~= nil
372372
local isValid = string.isvalid(newGroup.buffer.name) and not exists
373-
local text = isValid and _F(_T("BSV2_ES_NEW_GROUP_NEXT"), "[ > ]") or _T("BSV2_ES_NEW_GROUP_NAME")
373+
local text = isValid and _T("BSV2_ES_NEW_GROUP_NEXT", "[ > ]") or _T("BSV2_ES_NEW_GROUP_NAME")
374374
ImGui.Text(text)
375375

376376
ImGui.Spacing()
@@ -389,7 +389,7 @@ end
389389
local function drawGroupCreatorStep2()
390390
ImGui.Dummy(0, 15)
391391
local isValid = newGroup.buffer.vehicleModel ~= nil
392-
local text = isValid and _F(_T("BSV2_ES_NEW_GROUP_NEXT"), "[ > ]") or _T("BSV2_ES_NEW_GROUP_VEH")
392+
local text = isValid and _T("BSV2_ES_NEW_GROUP_NEXT", "[ > ]") or _T("BSV2_ES_NEW_GROUP_VEH")
393393
ImGui.Text(text)
394394

395395
ImGui.Spacing()
@@ -420,7 +420,7 @@ local function drawGroupCreatorStep3()
420420
local infoText = membersFull and "BSV2_ES_NEW_GROUP_MEMBERS_DONE" or "BSV2_ES_NEW_GROUP_MEMBERS"
421421
ImGui.Text(_T(infoText))
422422
ImGui.Spacing()
423-
ImGui.BulletText(_F(_T("BSV2_ES_NEW_GROUP_MEMBERS_COUNT"), count))
423+
ImGui.BulletText(_T("BSV2_ES_NEW_GROUP_MEMBERS_COUNT", count))
424424

425425
local removeDisabled = not math.is_inrange(count, 1, 3)
426426
ImGui.SameLine()
@@ -495,7 +495,7 @@ local function drawGroupCreator()
495495
stage / 3.0,
496496
vec2:new(ImGui.GetContentRegionAvail() - btnSize.x - style.ItemSpacing.x, btnSize.y),
497497
ImGuiValueBarFlags.NONE,
498-
{ fmt = _F(_T("BSV2_ES_NEW_GROUP_STEP_LABEL"), stage) }
498+
{ fmt = _T("BSV2_ES_NEW_GROUP_STEP_LABEL", stage) }
499499
)
500500

501501
ImGui.SameLine()
@@ -520,7 +520,7 @@ local function drawGroupCreator()
520520
GUI:Tooltip(_T("GENERIC_CONFIRM"))
521521
end
522522

523-
if (ImGui.DialogBox("##confirmNewGroup", _F(_T("BSV2_ES_NEW_GROUP_PROMPT"), newGroup.buffer.name), ImGuiDialogBoxStyle.INFO)) then
523+
if (ImGui.DialogBox("##confirmNewGroup", _T("BSV2_ES_NEW_GROUP_PROMPT", newGroup.buffer.name), ImGuiDialogBoxStyle.INFO)) then
524524
BSV2:AddNewEscortGroup(table.copy(newGroup.buffer))
525525
clearNewGroupBuffer()
526526
end

SSV2/includes/frontend/billionaire_services/jet_ui.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ local function drawSpawnedJet(jet)
142142
if (GUI:Button(_T("GENERIC_GO"))) then
143143
ThreadManager:Run(function(s)
144144
if (jet.departureAirport and (jet.departureAirport.name == selectedAirport.name)) then
145-
Notifier:ShowError("Private Jet", _F(_T("BSV2_JET_LANDING_SAME_AP_ERR"), selectedAirport.name))
145+
Notifier:ShowError("Private Jet", _T("BSV2_JET_LANDING_SAME_AP_ERR", selectedAirport.name))
146146
return
147147
end
148148

149149
jet.arrivalAirport = selectedAirport
150-
Notifier:ShowMessage("Private Jet", _F(_T("BSV2_JET_FLY_CONFIRM"), selectedAirport.name))
150+
Notifier:ShowMessage("Private Jet", _T("BSV2_JET_FLY_CONFIRM", selectedAirport.name))
151151
jet:FlyTo(selectedAirport.landingApproach.pos, s)
152152
end)
153153
end

SSV2/includes/frontend/entity_forge/forge_creator_ui.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ local function DrawChildStuff()
389389

390390
EntityForge.SavedForges[new_creation.name] = new_creation
391391
EntityForge:ParseForges()
392-
Notifier:ShowSuccess("EntityForge", _F(_T("EF_NEW_FORGE_SUCCESS"), newEntityNameBuffer))
392+
Notifier:ShowSuccess("EntityForge", _T("EF_NEW_FORGE_SUCCESS", newEntityNameBuffer))
393393

394394
s:sleep(300)
395395
newEntityNameBuffer = ""
@@ -467,7 +467,7 @@ local function DrawLowerSection()
467467
end
468468

469469
local function ControlMouseCursor()
470-
ImGui.Text(_F(_T("EF_MOUSE_CURSOR_HINT"), "I", gui.mouse_override() and _T("GENERIC_DISABLE") or _T("GENERIC_ENABLE")))
470+
ImGui.Text(_T("EF_MOUSE_CURSOR_HINT", "I", gui.mouse_override() and _T("GENERIC_DISABLE") or _T("GENERIC_ENABLE")))
471471
if (KeyManager:IsKeyJustPressed(eVirtualKeyCodes.I)) then
472472
gui.override_mouse(not gui.mouse_override())
473473
end

SSV2/includes/frontend/mastermind_ui.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ local function drawBasicTab()
120120
if (heist.opt_info and not is_done) then
121121
GUI:Tooltip(heist.opt_info)
122122
elseif (on_cooldown) then
123-
GUI:Tooltip(_F(_T("CP_COOLDOWN_BYPASS_STATUS_FORMAT"), seconds_left / 60))
123+
GUI:Tooltip(_T("CP_COOLDOWN_BYPASS_STATUS_FORMAT", seconds_left / 60))
124124
end
125125
ImGui.EndDisabled()
126126

@@ -193,7 +193,7 @@ local function drawCayoTab()
193193

194194
if (on_cooldown) then
195195
local minutes_left = (cooldown_seconds_left > 0 and cooldown_seconds_left or cooldown_hard_seconds_left) / 60
196-
GUI:HeaderText(_F(_T("CP_COOLDOWN_BYPASS_STATUS_FORMAT"), minutes_left),
196+
GUI:HeaderText(_T("CP_COOLDOWN_BYPASS_STATUS_FORMAT", minutes_left),
197197
{ separator = false, spacing = true, color = Color.RED })
198198
end
199199

@@ -340,7 +340,7 @@ local function drawDDayTab()
340340

341341
if (on_cooldown) then
342342
local minutes_left = cooldown_seconds_left / 60
343-
GUI:HeaderText(_F(_T("CP_COOLDOWN_BYPASS_STATUS_FORMAT"), minutes_left),
343+
GUI:HeaderText(_T("CP_COOLDOWN_BYPASS_STATUS_FORMAT", minutes_left),
344344
{ separator = false, spacing = true, color = Color.RED })
345345
end
346346

@@ -351,7 +351,7 @@ local function drawDDayTab()
351351
if (GUI:Button(button_label)) then
352352
stats.set_int("MPX_GANGOPS_HEIST_STATUS", 9999)
353353
end
354-
GUI:HelpMarker(_F(_T("YH_DDAY_HELP2_FMT"), button_label))
354+
GUI:HelpMarker(_T("YH_DDAY_HELP2_FMT", button_label))
355355

356356
GUI:HeaderText(_T("CP_HEIST_SETUP"), { separator = true, spacing = true })
357357

0 commit comments

Comments
 (0)