Skip to content

Commit 3d5cd5b

Browse files
authored
Merge pull request #82 from acidlabsdev/main
chore(data): remove weapon lists from global ns
2 parents 1b992b7 + 17c306f commit 3d5cd5b

27 files changed

Lines changed: 225 additions & 154 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
local Enums <const> = {
2+
eGameState = require("includes.data.enums.game_state"),
3+
eModelType = require("includes.data.enums.model_type"),
4+
eRagdollBlockingFlags = require("includes.data.enums.ragdoll_blocking_flags"),
5+
eVehicleClasses = require("includes.data.enums.vehicle_classes"),
6+
eHandlingType = require("includes.data.enums.handling_type"),
7+
eDrivingFlags = require("includes.data.enums.driving_flags"),
8+
eVehicleHandlingFlags = require("includes.data.enums.handling_flags"),
9+
eVehicleModelFlags = require("includes.data.enums.vehicle_model_flags"),
10+
eVehicleModelInfoFlags = require("includes.data.enums.vehicle_model_info_flags"),
11+
eVehicleAdvancedFlags = require("includes.data.enums.vehicle_advanced_flags"),
12+
ePedType = require("includes.data.enums.ped_type"),
13+
ePedGender = require("includes.data.enums.ped_gender"),
14+
ePedComponents = require("includes.data.enums.ped_components"),
15+
ePedConfigFlags = require("includes.data.enums.ped_config_flags"),
16+
ePedResetFlags = require("includes.data.enums.ped_reset_flags"),
17+
ePedCombatAttributes = require("includes.data.enums.ped_combat_attributes"),
18+
ePedTaskIndex = require("includes.data.enums.ped_task_index"),
19+
eAnimFlags = require("includes.data.enums.anim_flags"),
20+
eActionType = require("includes.data.enums.action_type"),
21+
eVehicleTask = require("includes.data.enums.vehicle_task"),
22+
eLandingGearState = require("includes.data.enums.landing_gear_state"),
23+
}
24+
25+
return Enums

SSV2/includes/data/weapons.lua

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
---@diagnostic disable
22

3-
t_AllWeapons = {}
4-
t_MeleeWeapons = {}
5-
t_Handguns = {}
6-
t_SMG = {}
7-
t_Shotguns = {}
8-
t_AssaultRifles = {}
9-
t_MachineGuns = {}
10-
t_SniperRifles = {}
11-
t_HeavyWeapons = {}
12-
t_Throwables = {}
13-
t_MiscWeapons = {}
3+
---@type table<string, array<hash>>
4+
local Weapons = {
5+
All = {},
6+
Melee = {},
7+
Pistols = {},
8+
SMG = {},
9+
Shotguns = {},
10+
AssaultRifles = {},
11+
MachineGuns = {},
12+
SniperRifles = {},
13+
Heavy = {},
14+
Throwables = {},
15+
Misc = {},
16+
}
17+
18+
return Weapons

SSV2/includes/features/BillionaireServicesV2.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---@diagnostic disable: lowercase-global
22

3-
local GroupManager = require("includes.services.GroupManager")
3+
local GroupManager = require("includes.services.GroupManager")
44
local t_RandomPedNames = require("includes.data.ped_names")
5-
local PrivateHeli = require("includes.modules.PrivateHeli")
6-
local PrivateJet = require("includes.modules.PrivateJet")
7-
local PrivateLimo = require("includes.modules.PrivateLimo")
8-
local __t = require("includes.modules.Bodyguard")
9-
local Bodyguard = __t.bg
10-
local EscortGroup = __t.eg
5+
local PrivateHeli = require("includes.modules.PrivateHeli")
6+
local PrivateJet = require("includes.modules.PrivateJet")
7+
local PrivateLimo = require("includes.modules.PrivateLimo")
8+
local __t = require("includes.modules.Bodyguard")
9+
local Bodyguard = __t.bg
10+
local EscortGroup = __t.eg
1111

1212
---@alias ServiceType integer
1313
---| -1 # ALL

SSV2/includes/features/YimActionsV3.lua

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ local CompanionManager = require("includes.services.CompanionManager")
33
local t_AnimList = require("includes.data.actions.animations")
44
local t_PedScenarios = require("includes.data.actions.scenarios")
55
local Action = require("includes.structs.Action")
6+
local Weapons = require("includes.data.weapons")
67

78
---@alias ActionCategory
89
--- | "anims"
@@ -151,7 +152,7 @@ function YimActions:WasActionInterrupted(ped)
151152
end
152153

153154
if (current.action_type == Enums.eActionType.ANIM) then
154-
return not ENTITY.IS_ENTITY_PLAYING_ANIM(ped, current.data.dict, current.data.name, -1)
155+
return not ENTITY.IS_ENTITY_PLAYING_ANIM(ped, current.data.dict, current.data.name, 3)
155156
elseif (current.action_type == Enums.eActionType.SCENARIO) then
156157
return not PED.IS_PED_USING_ANY_SCENARIO(ped)
157158
elseif (current.action_type == Enums.eActionType.SCENE) then
@@ -330,11 +331,13 @@ end
330331
function YimActions:ResetPlayer()
331332
Self:Cleanup()
332333

333-
if (next(Audio.m_active_emitters) ~= nil) then
334-
for _, emitter in pairs(Audio.m_active_emitters) do
335-
if (emitter.source == Self:GetHandle()) then
336-
Audio:ToggleEmitter(emitter, false)
337-
end
334+
if (not Audio:AreAnyEmittersEnabled()) then
335+
return
336+
end
337+
338+
for _, emitter in pairs(Audio:GetActiveEmitters()) do
339+
if (emitter:GetOwner() == Self:GetHandle()) then
340+
Audio:ToggleEmitter(emitter, false)
338341
end
339342
end
340343
end
@@ -391,6 +394,7 @@ function YimActions:OnInterruptEvent()
391394
local localPlayer = Self:GetHandle()
392395
local current = self.CurrentlyPlaying[localPlayer]
393396
if (not current) then
397+
yield()
394398
return
395399
end
396400

@@ -595,10 +599,9 @@ function YimActions:GoofyUnaliveAnim()
595599
if (current ~= 0 and WEAPON.GET_WEAPONTYPE_GROUP(current) ~= joaat("GROUP_PISTOL")) then
596600
is_armed = true
597601
else
598-
for _, w in ipairs(t_Handguns) do
599-
local pistol = joaat(w)
600-
if (WEAPON.HAS_PED_GOT_WEAPON(ped, pistol, false)) then
601-
WEAPON.SET_CURRENT_PED_WEAPON(ped, pistol, true)
602+
for _, hash in ipairs(Weapons.Pistols) do
603+
if (WEAPON.HAS_PED_GOT_WEAPON(ped, hash, false)) then
604+
WEAPON.SET_CURRENT_PED_WEAPON(ped, hash, true)
602605
is_armed = true
603606
break
604607
end
@@ -669,7 +672,7 @@ function YimActions:MainThread()
669672
end
670673

671674
-- this is very stupid but it works... kinda.
672-
if (ENTITY.IS_ENTITY_PLAYING_ANIM(ped, "mp_suicide", "pistol", 3) and t_Handguns and #t_Handguns > 0) then
675+
if (ENTITY.IS_ENTITY_PLAYING_ANIM(ped, "mp_suicide", "pistol", 3) and Weapons.Pistols and #Weapons.Pistols > 0) then
673676
self:GoofyUnaliveAnim()
674677
end
675678

@@ -705,7 +708,7 @@ function YimActions.PropManager:SpawnProp(owner, propData, isPed, coords, faceOw
705708
coords = vec3:zero()
706709
end
707710

708-
if (propData.model == 2767137151) or (propData.model == 976772591) then
711+
if (propData.model == 2767137151 or propData.model == 976772591) then
709712
Audio:PartyMode(true, owner)
710713
end
711714

SSV2/includes/frontend/bsv2_ui.lua

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local PrivateJet = require("includes.modules.PrivateJet")
55
local PrivateLimo = require("includes.modules.PrivateLimo")
66
local t_GamePeds = require("includes.data.peds")
77
local PreviewService = require("includes.services.PreviewService")
8+
local Weapons = require("includes.data.weapons")
89
local i_SelectedSidebarItem = 1
910
local i_WeaponCategoryIndex = 1
1011
local i_WeaponIndex = 1
@@ -45,18 +46,20 @@ local t_SelectedLimo = {}
4546
local t_WeaponList = {}
4647
local t_MainUIfooter = {}
4748
local t_SelectedEscortGroup = {}
49+
50+
---@type array<{name: string, list?: array<hash>}>
4851
local t_WeaponCategories = {
4952
{ name = "None" },
50-
{ name = "Melee", groupHash = 2685387236 },
51-
{ name = "Pistols", groupHash = 416676503 },
52-
{ name = "SMGs", groupHash = 3337201093 },
53-
{ name = "Shotguns", groupHash = 860033945 },
54-
{ name = "Assault Rifles", groupHash = 970310034 },
55-
{ name = "Machine Guns", groupHash = 1159398588 },
56-
{ name = "Sniper Rifles", groupHash = 3082541095 },
57-
{ name = "Heavy Weapons", groupHash = 2725924767 },
58-
{ name = "Throwables", groupHash = 1548507267 },
59-
{ name = "Miscellaneous", groupHash = 4257178988 },
53+
{ name = "Melee", list = Weapons.Melee },
54+
{ name = "Pistols", list = Weapons.Pistols },
55+
{ name = "SMGs", list = Weapons.SMG },
56+
{ name = "Shotguns", list = Weapons.Shotguns },
57+
{ name = "Assault Rifles", list = Weapons.AssaultRifles },
58+
{ name = "Machine Guns", list = Weapons.MachineGuns },
59+
{ name = "Sniper Rifles", list = Weapons.SniperRifles },
60+
{ name = "Heavy Weapons", list = Weapons.Heavy },
61+
{ name = "Throwables", list = Weapons.Throwables },
62+
{ name = "Miscellaneous", list = Weapons.Misc },
6063
}
6164
-- local t_NewEscortGroup = {
6265
-- name = "N/A",
@@ -215,41 +218,43 @@ local function BodyguardSpawnFooter()
215218
ImGui.PushItemWidth(200)
216219
if ImGui.BeginCombo("Category", t_WeaponCategories[i_WeaponCategoryIndex].name) then
217220
for i, cat in ipairs(t_WeaponCategories) do
218-
if cat.groupHash then
219-
local is_selected = (i_WeaponCategoryIndex == i)
221+
if (not cat.list) then
222+
goto continue
223+
end
220224

221-
if ImGui.Selectable(cat.name, is_selected) then
222-
i_WeaponCategoryIndex = i
223-
end
225+
local is_selected = (i_WeaponCategoryIndex == i)
226+
if ImGui.Selectable(cat.name, is_selected) then
227+
i_WeaponCategoryIndex = i
228+
end
224229

225-
if GUI:IsItemClicked(0) then
226-
GUI:PlaySound("Nav")
227-
t_WeaponList = weapons.get_all_weapons_of_group_type(cat.groupHash)
228-
end
230+
if GUI:IsItemClicked(0) then
231+
GUI:PlaySound("Nav")
232+
t_WeaponList = cat.list
233+
end
229234

230-
if is_selected then
231-
ImGui.SetItemDefaultFocus()
232-
end
235+
if is_selected then
236+
ImGui.SetItemDefaultFocus()
233237
end
238+
239+
::continue::
234240
end
235241
ImGui.EndCombo()
236242
end
237243

238-
if #t_WeaponList > 0 then
244+
if t_WeaponList and #t_WeaponList > 0 then
239245
ImGui.SameLine()
240246

241-
if ImGui.BeginCombo("Weapon", weapons.get_weapon_display_name(t_WeaponList[i_WeaponIndex])) then
247+
local wpn_name = weapons.get_weapon_display_name(t_WeaponList[i_WeaponIndex])
248+
if ImGui.BeginCombo("Weapon", wpn_name) then
242249
for i, wpn in ipairs(t_WeaponList) do
243250
local is_selected = (i_WeaponIndex == i)
244-
local wpn_name = weapons.get_weapon_display_name(wpn)
245-
246251
if ImGui.Selectable(wpn_name, is_selected) then
247252
i_WeaponIndex = i
248253
end
249254

250255
if GUI:IsItemClicked(0) then
251256
GUI:PlaySound("Nav")
252-
i_SelectedBodyguardWeapon = joaat(t_WeaponList[i_WeaponIndex])
257+
i_SelectedBodyguardWeapon = wpn
253258
end
254259

255260
if is_selected then

SSV2/includes/frontend/yav3_ui.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ local function DrawAnims()
226226
if ImGui.BeginListBox("##animlist", -1, -1) then
227227
if not b_DataListsSorted then
228228
ImGui.Dummy(1, 60)
229-
ImGui.TextSpinner("Loading Data. Please wait", 7, ImGui.SpinnerStyle.SCAN)
229+
ImGui.TextSpinner(_T("GENERIC_WAIT_LABEL"), 7, ImGui.SpinnerStyle.SCAN)
230230
else
231231
for i, action in ipairs(t_AnimList) do
232232
if (i_AnimSortByIndex > 0 and action.category ~= t_AnimSortbyList[i_AnimSortByIndex + 1]) then
@@ -883,9 +883,8 @@ local function DrawJsonMovementClipsets()
883883
else
884884
ImGui.BeginListBox("##jsonmvmts", -1, -1)
885885
if not b_MovementListCreated then
886-
ImGui.TextSpinner("Loading data from Json", 7.5, ImGui.SpinnerStyle.SCAN)
887-
ImGui.EndListBox()
888-
return
886+
ImGui.TextSpinner(_T("GENERIC_WAIT_LABEL"), 7.5, ImGui.SpinnerStyle.SCAN)
887+
ImGui.Spacing()
889888
end
890889

891890
for i = 1, #t_MovementClipsetsJson do
@@ -902,15 +901,19 @@ local function DrawJsonMovementClipsets()
902901
ImGui.PushStyleColor(ImGuiCol.Text, 0.8, 0.8, 0.4, 0.8)
903902
end
904903

904+
ImGui.BeginDisabled(not b_MovementListCreated)
905905
if ImGui.Selectable(label, is_selected) then
906906
t_SelectedMovementClipset = t_MovementClipsetsJson[i]
907907
end
908+
ImGui.EndDisabled()
908909

909910
if (is_favorite) then
910911
ImGui.PopStyleColor()
911912
end
912913

913-
GUI:Tooltip(_F("Right click to %s favorites.", is_favorite and "remove from" or "add to"))
914+
if (b_MovementListCreated) then
915+
GUI:Tooltip(_F("Right click to %s favorites.", is_favorite and "remove from" or "add to"))
916+
end
914917

915918
if GUI:IsItemClicked(1) then
916919
GUI:PlaySound("Click")

SSV2/includes/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ local GAME_VERSION <const> = {
2424
-- ### Enums Namespace.
2525
--
2626
-- All enums are stored here to avoid polluting the global namespace.
27-
Enums = require("includes.data.enums.__init")
27+
Enums = require("includes.data.enums.__init__")
2828

2929
-- ### Backend Module
3030
--

SSV2/includes/lib/imgui_ext.lua

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,42 @@ function ImGui.ColorEditVec4(label, outVector)
9696
end
9797

9898
---@param label string
99-
---@param inColor uint32_t
99+
---@param outU32 uint32_t
100100
---@return uint32_t, boolean
101-
function ImGui.ColorEditU32(label, inColor)
102-
local temp, changed = { Color(inColor):AsFloat() }, false
101+
function ImGui.ColorEditU32(label, outU32)
102+
local temp, changed = { Color(outU32):AsFloat() }, false
103103
temp, changed = ImGui.ColorEdit4(label, temp)
104104
if (changed) then
105105
return Color(temp):AsU32(), changed
106106
end
107107

108-
return inColor, changed
108+
return outU32, changed
109109
end
110110

111111
---@param label string
112112
---@param stringBuffer string
113-
---@param maxWidth? number
114113
---@param flags? integer ImGuiInputTextFlags
114+
---@param maxWidth? float
115+
---@param bufferSize? integer
115116
---@return string, boolean
116-
function ImGui.SearchBar(label, stringBuffer, maxWidth, flags)
117-
if (maxWidth) then
118-
ImGui.SetNextItemWidth(maxWidth)
119-
end
120-
121-
local out, changed = ImGui.InputTextWithHint(label, "Search", stringBuffer, SizeOf(stringBuffer), flags or 0)
122-
return out, changed
117+
function ImGui.SearchBar(label, stringBuffer, flags, maxWidth, bufferSize)
118+
maxWidth = maxWidth or -1
119+
bufferSize = bufferSize or math.max(#stringBuffer + 32, 256)
120+
flags = flags or ImGuiInputTextFlags.None
121+
local changed = false
122+
123+
ImGui.SetNextItemWidth(maxWidth)
124+
ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 6)
125+
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, 6, 4)
126+
stringBuffer, changed = ImGui.InputTextWithHint(
127+
label,
128+
_T("GENERIC_SEARCH_HINT"),
129+
stringBuffer,
130+
bufferSize,
131+
flags
132+
)
133+
ImGui.PopStyleVar(2)
134+
return stringBuffer, changed
123135
end
124136

125137
---@param label string

SSV2/includes/lib/translations/__hashmap.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,5 +533,6 @@
533533
"YAV3_DISABLE_SFX": 1106046395,
534534
"YRV3_TRIGGER_PROD": 4252794738,
535535
"YRV3_TRIGGER_PROD_TT": 2986635917,
536-
"YRV3_AUTO_PROD": 471356205
536+
"YRV3_AUTO_PROD": 471356205,
537+
"GENERIC_WAIT_LABEL": 3936747464
537538
}

SSV2/includes/lib/translations/de-DE.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,5 +533,6 @@ return {
533533
["YAV3_ANIM_FLAGS"] = "Verhaltensflags",
534534
["YRV3_TRIGGER_PROD"] = "Produktion auslösen",
535535
["YRV3_TRIGGER_PROD_TT"] = "Löst die Produktion sofort einmal aus, solange Vorräte vorhanden sind. Sie können die Taste gedrückt halten, um sie weiterhin auszulösen, oder das nächste Kontrollkästchen aktivieren, um den Vorgang vollständig zu automatisieren.",
536-
["YRV3_AUTO_PROD"] = "Automatisch produzieren"
536+
["YRV3_AUTO_PROD"] = "Automatisch produzieren",
537+
["GENERIC_WAIT_LABEL"] = "Bitte warten"
537538
}

0 commit comments

Comments
 (0)