Skip to content

Commit

Permalink
fix(gearhandler): small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Torwent committed Sep 21, 2024
1 parent 3be543f commit 4b426b8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
25 changes: 13 additions & 12 deletions optional/handlers/gearhandler.simba
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,13 @@ var
i: Int32;
arr: TStringArray;
begin
if not GearHandler._FormFiltered then
Exit;
if not GearHandler._FormFiltered then Exit;

combobox.GetItems().Clear();
combobox.GetItems().Add('None');

name := combobox.getName().Before('_slot_combobox');

if name = 'secondary_ammo' then
json := GearData.GetJSONArray('ammo')
else
json := GearData.GetJSONArray(name);
json := GearData.GetJSONArray(name);

if name <> 'weapon' then
begin
Expand Down Expand Up @@ -340,6 +335,7 @@ begin
Self._RefreshList(combobox);

combobox.setItemIndex(combobox.getItems().IndexOf(gear.Items[slot]));

Self._OnGearChange(combobox);
end;

Expand Down Expand Up @@ -449,7 +445,6 @@ begin
img.setVisible(True);

id := ItemFinder.GetItemIDs(combobox.getText())[0];

path := ItemFinder.IMAGES_PATH.Replace('itemfinder', 'forms' + DirectorySeparator + 'gear');


Expand Down Expand Up @@ -478,7 +473,7 @@ procedure TScriptForm._OnLoadGear(sender: TObject);
var
combobox: TComboBox;
parent: TPanel;
items: TRSItemArray;
items, validItems: TRSItemArray;
item: TRSItem;
slot: ERSEquipmentSlot;
name: String;
Expand All @@ -497,14 +492,19 @@ begin

for slot := Low(ERSEquipmentSlot) to High(ERSEquipmentSlot) do
begin
items := Equipment.Discover(slot);
name := ToStr(slot).ToLower();
combobox := parent.GetChild(name + '_slot_combobox');

combobox.Clear();
combobox.getItems().Add('None');
for item in items do

items := Equipment.Discover(slot);
validItems := GearData.GetItems(name);
WriteLn validItems.Intersection(items);

for item in validItems.Intersection(items) do
begin
combobox.getItems().Add(ToStr(item).Capitalize());
end;

if combobox.getItems().getCount() = 1 then
combobox.setItemIndex(0)
Expand Down Expand Up @@ -939,6 +939,7 @@ begin

Self._RefreshSets(Result);
cb.SetItemIndex(0);

Self._OnGearSelectorChange(cb.ComboBox);
GearHandler._FormFiltered := False;
end;
Expand Down
2 changes: 2 additions & 0 deletions utils/data/data.simba
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ Using this requires knowledge of the structure of gear.json
function TGearData.GetJSONArray(key: String): TJSONArray;
begin
Self.Setup();
if key = 'secondary_ammo' then key := 'ammo';
Result := Self.Data.getJSONArray(key);
end;

Expand All @@ -1015,6 +1016,7 @@ var
i: Int32;
begin
Self.Setup();
if key = 'secondary_ammo' then key := 'ammo';
for i := 0 to Self.Data.getJSONArray(key).High() do
Result += Self.Data.getJSONArray(key).getString(i);
end;
Expand Down
Loading

0 comments on commit 4b426b8

Please sign in to comment.