Skip to content

Commit

Permalink
display linked ammo name in place of counter
Browse files Browse the repository at this point in the history
  • Loading branch information
bmos committed Apr 21, 2023
1 parent 859b387 commit 36e4a6b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
10 changes: 10 additions & 0 deletions campaign/5e_record_char_weapon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
<basicnumber name="maxammo">
<script file="common/scripts/number_crosslink_unlink.lua" />
</basicnumber>
<combobox_ammo name="ammopicker" source="ammunitionmanager.ammopicker">
<anchored>
<top parent="maxammo" anchor="top" offset="0" />
<bottom parent="maxammo" anchor="bottom" offset="2" />
<left parent="maxammo" anchor="right" offset="15" />
<right parent="attackframe" anchor="right" offset="0" />
</anchored>
<itemsheetname><string /><field>subtype</field></itemsheetname>
<itemsheetname><string /><field>type</field></itemsheetname>
</combobox_ammo>
</sheetdata>
</windowclass>

Expand Down
10 changes: 10 additions & 0 deletions campaign/pfrpg2_record_char_actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
<basicnumber name="maxammo">
<script file="common/scripts/number_crosslink_unlink.lua" />
</basicnumber>
<combobox_ammo name="ammopicker" source="ammunitionmanager.ammopicker">
<anchored>
<top parent="maxammo" anchor="top" offset="0" />
<bottom parent="maxammo" anchor="bottom" offset="2" />
<left parent="maxammo" anchor="right" offset="15" />
<right parent="attackframe" anchor="right" offset="0" />
</anchored>
<itemsheetname><string /><field>subtype</field></itemsheetname>
<itemsheetname><string /><field>type</field></itemsheetname>
</combobox_ammo>
</sheetdata>
</windowclass>

Expand Down
10 changes: 10 additions & 0 deletions campaign/pfrpg_record_char_actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
<basicnumber name="maxammo">
<script file="common/scripts/number_crosslink_unlink.lua" />
</basicnumber>
<combobox_ammo name="ammopicker" source="ammunitionmanager.ammopicker">
<anchored>
<top parent="maxammo" anchor="top" offset="0" />
<bottom parent="maxammo" anchor="bottom" offset="2" />
<left parent="maxammo" anchor="right" offset="15" />
<right parent="attackframe" anchor="right" offset="15" />
</anchored>
<itemsheetname><string /><field>subtype</field></itemsheetname>
<itemsheetname><string /><field>type</field></itemsheetname>
</combobox_ammo>
</sheetdata>
</windowclass>

Expand Down
19 changes: 9 additions & 10 deletions campaign/scripts/5e_char_weapon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ function setAmmoVis(nodeWeapon, ...)
isloaded.setVisible(bLoading)

local nodeAmmoLink = AmmunitionManager.getAmmoNode(nodeWeapon)
ammocounter.setVisible(not nodeAmmoLink)
local bRanged = AmmunitionManager.isWeaponRanged(nodeWeapon)
ammocounter.setVisible(bRanged and not nodeAmmoLink)
ammopicker.setComboBoxVisible(bRanged and nodeAmmoLink)
ammopicker.setComboBoxReadOnly(true)

local nodeCount
if nodeAmmoLink then nodeCount = DB.getChild(nodeAmmoLink, 'count') end
Expand Down Expand Up @@ -90,11 +93,9 @@ end
function onInit()
if super and super.onInit then super.onInit() end

if super then
if super.onAttackAction then
onAttackAction_old = super.onAttackAction
super.onAttackAction = onAttackAction_new
end
if super and super.onAttackAction then
onAttackAction_old = super.onAttackAction
super.onAttackAction = onAttackAction_new
end

local nodeWeapon = getDatabaseNode()
Expand All @@ -106,10 +107,8 @@ end
function onClose()
if super and super.onClose then super.onClose() end

if super then
if super.onAttackAction then
super.onAttackAction = onAttackAction_old
end
if super and super.onAttackAction then
super.onAttackAction = onAttackAction_old
end

local nodeWeapon = getDatabaseNode()
Expand Down
2 changes: 2 additions & 0 deletions campaign/scripts/ammo_weapon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ function onDataChanged()
label_ammo.setVisible(bRanged)
maxammo.setVisible(bRanged)
ammocounter.setVisible(bRanged and not bInfiniteAmmo and not nodeAmmoLink)
ammopicker.setComboBoxVisible(bRanged and not bInfiniteAmmo and nodeAmmoLink)
ammopicker.setComboBoxReadOnly(true)

if not maxammo.setLink then return end

Expand Down
4 changes: 2 additions & 2 deletions extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<root version='3.3' release='3'>
<properties>
<name>Feature: Ammunition Manager</name>
<version>4.0</version>
<version>4.1</version>
<author>bmos (Wil Thieme)</author>
<description>This extension aids in tracking ammunition and whether ranged weapons are loaded.</description>
<ruleset>
Expand All @@ -26,7 +26,7 @@
<loadorder>34</loadorder>
</properties>

<announcement text="https://github.com/bmos/FG-PFRPG-Ammunition-Manager\nAmmunition Manager v4.0-hotfix.4:\nThis extension aids in tracking ammunition and whether ranged weapons are loaded." font="emotefont" icon="archery_ammomanager" />
<announcement text="https://github.com/bmos/FG-PFRPG-Ammunition-Manager\nAmmunition Manager v4.1:\nThis extension aids in tracking ammunition and whether ranged weapons are loaded." font="emotefont" icon="archery_ammomanager" />

<base>
<!-- Campaign Records -->
Expand Down

0 comments on commit 36e4a6b

Please sign in to comment.