Skip to content

Commit

Permalink
compatibility with Sept 2022 ruleset updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bmos committed Aug 26, 2022
1 parent 73d4207 commit 87af045
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 97 deletions.
54 changes: 17 additions & 37 deletions campaign/record_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
-->

<root>
<windowclass name="item" merge="join">
<sheetdata>
<subwindow_record name="main">
<script file="campaign/scripts/item_drop.lua" />
</subwindow_record>
</sheetdata>
</windowclass>

<windowclass name="item_main" merge="join">
<margins control="0,0,0,2" />
<script file="campaign/scripts/item_main.lua" />
<sheetdata>
<label_column name="equipslot_label" insertbefore="divider2">
<static textres="item_label_equipslot" />
</label_column>
<string_columnh name="equipslot" insertbefore="divider2" />

<string_columnh name="cost">
<anchored>
<right offset="-30" />
Expand All @@ -32,18 +28,20 @@
window.update();
end
</script>
<gmeditonly />
<gmvisibleonly />
</buttonfield>

<sub_column name="type_stats2" insertbefore="divider4" />

<label_column name="charge_label" insertbefore="divider4">
<anchored>
<top offset="16" />
</anchored>
<static textres="item_label_charges" />
</label_column>

<number_columnh name="charge" insertbefore="divider4">
<anchored width="60" >
<anchored>
<top offset="16" />
</anchored>
<stateframe>
Expand All @@ -58,15 +56,15 @@
end
</script>
</number_columnh>

<label_fieldtop name="current_label" insertbefore="divider4">
<label_fieldtop name="current_label" insertafter="divider4">
<anchored to="charge" />
<static textres="item_label_curent" size="50%" />
</label_fieldtop>

<number_columnh name="maxcharges" insertbefore="divider4">
<anchored to="charge" width="60" >
<top offset="-20" relation="current" />
<number_column name="maxcharges">
<anchored>
<top parent="charge" anchor="top" offset="0" />
<left parent="charge" anchor="right" offset="10" />
</anchored>
<default>50</default>
<gmeditonly />
Expand All @@ -81,22 +79,12 @@
end
end
</script>
</number_columnh>

<label_fieldtop name="maxcharges_label" insertbefore="divider4">
</number_column>
<label_fieldtop name="maxcharges_label" insertafter="divider4">
<anchored to="maxcharges" />
<static textres="item_label_max_charges" size="50%" />
</label_fieldtop>

<label_column name="equipslot_label" insertbefore="divider4">
<static textres="item_label_equipslot" />
</label_column>
<string_columnh name="equipslot" insertbefore="divider4">
<gmeditonly />
</string_columnh>

<line_column name="divider6" />

<label_column name="gmonly_label">
<static textres="item_label_gmonly" />
</label_column>
Expand All @@ -107,19 +95,11 @@
</anchored>
<gmeditonly />
</ft_columnh>

<line_column name="divider5" />

<ft_columnh name="description">
<gmeditonly />
</ft_columnh>

<label_column name="sourcebook_label">
<static textres="item_label_sourcebook" />
</label_column>
<string_columnh name="sourcebook">
<gmeditonly />
</string_columnh>
<string_columnh name="sourcebook" />
</sheetdata>
</windowclass>
</root>
109 changes: 49 additions & 60 deletions campaign/scripts/item_main.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
--
--
-- Please see the LICENSE.md file included with this distribution for attribution and copyright information.
--
function onInit() update(); end

function VisDataCleared() update(); end

function InvisDataAdded() update(); end

function updateControl(sControl, bReadOnly, bID)
if not self[sControl] then return false; end

if not bID then return self[sControl].update(bReadOnly, true); end

return self[sControl].update(bReadOnly);
end
-- luacheck: globals update getItemType

function getItemType()
local bWeapon, bArmor, bShield, bWand, bStaff, bWondrous;
Expand All @@ -30,54 +19,61 @@ function getItemType()
return bWeapon, bArmor, bShield, bWand, bStaff, bWondrous;
end

function update()
function update(...)
if super and super.update then super.update(...); end

local nodeRecord = getDatabaseNode();
local bReadOnly = WindowManager.getReadOnlyState(nodeRecord);
local bID, bOptionID = ItemManager.getIDState(nodeRecord);
local nCostVisibility = cost_visibility.getValue();
local bID = LibraryData.getIDState("item", nodeRecord);

local bWeapon, bArmor, bShield, bWand, bStaff, bWondrous = getItemType();

local bSection1 = false;
if bOptionID and Session.IsHost then
if updateControl('nonid_name', bReadOnly, true) then bSection1 = true; end
if Session.IsHost then
if self.updateControl("nonid_name", bReadOnly, true) then bSection1 = true; end;
else
updateControl('nonid_name', false);
self.updateControl("nonid_name", false);
end
if bOptionID and (Session.IsHost or not bID) then
if updateControl('nonidentified', bReadOnly, true) then bSection1 = true; end
if (Session.IsHost or not bID) then
if self.updateControl("nonidentified", bReadOnly, true) then bSection1 = true; end;
else
updateControl('nonidentified', false);
self.updateControl("nonidentified", false);
end

local bSection2 = false;
if updateControl('type', bReadOnly, bID) then bSection2 = true; end
if updateControl('subtype', bReadOnly, bID) then bSection2 = true; end
if self.updateControl("type", bReadOnly, bID) then bSection2 = true; end
if self.updateControl("subtype", bReadOnly, bID) then bSection2 = true; end

local bSection3 = false;
if Session.IsHost then
if updateControl('cost', bReadOnly, bID) then bSection3 = true; end
if self.updateControl("cost", bReadOnly, bID) then bSection3 = true; end
else
if updateControl('cost', bReadOnly, bID and (nCostVisibility == 0)) then bSection3 = true; end
if self.updateControl('cost', bReadOnly, bID and (cost_visibility.getValue() == 0)) then bSection3 = true; end
end
if updateControl('weight', bReadOnly, bID) then bSection3 = true; end
if updateControl('size', bReadOnly, bID) then bSection3 = true; end

local bSection4 = false;
if updateControl('damage', bReadOnly, bID and bWeapon) then bSection4 = true; end
if updateControl('damagetype', bReadOnly, bID and bWeapon) then bSection4 = true; end
if updateControl('critical', bReadOnly, bID and bWeapon) then bSection4 = true; end
if updateControl('range', bReadOnly, bID and bWeapon) then bSection4 = true; end

if updateControl('ac', bReadOnly, bID and bArmor) then bSection4 = true; end
if updateControl('maxstatbonus', bReadOnly, bID and bArmor) then bSection4 = true; end
if updateControl('checkpenalty', bReadOnly, bID and bArmor) then bSection4 = true; end
if updateControl('spellfailure', bReadOnly, bID and bArmor) then bSection4 = true; end
if updateControl('speed30', bReadOnly, bID and bArmor) then bSection4 = true; end
if updateControl('speed20', bReadOnly, bID and bArmor) then bSection4 = true; end

if updateControl('charge', bReadOnly, bID and (bWand or bStaff)) then
bSection4 = true;
if self.updateControl("weight", bReadOnly, bID) then bSection3 = true; end
if self.updateControl('size', bReadOnly, bID) then bSection3 = true; end

local bSection4 = true;
if Session.IsHost or bID then
if bShield then
type_stats.setValue("item_main_armor", nodeRecord);
type_stats2.setValue("item_main_weapon", nodeRecord);
elseif bWeapon then
type_stats.setValue("item_main_weapon", nodeRecord);
elseif bArmor then
type_stats.setValue("item_main_armor", nodeRecord);
else
type_stats.setValue("", "");
bSection4 = false;
end
else
type_stats.setValue("", "");
bSection4 = false;
end
type_stats.update(bReadOnly, bID);
type_stats2.update(bReadOnly, bID);

if self.updateControl('charge', bReadOnly, bID and (bWand or bStaff)) then
maxcharges.setReadOnly(bReadOnly);
charge.setReadOnly(false);
current_label.setVisible(true);
Expand All @@ -89,28 +85,21 @@ function update()
maxcharges_label.setVisible(false);
end

if updateControl('equipslot', bReadOnly, bID and bWondrous) then bSection4 = true; end

if updateControl('properties', bReadOnly, bID and (bWeapon or bArmor)) then bSection4 = true; end
if self.updateControl('equipslot', bReadOnly, bID and bWondrous) then bSection4 = true; end

local bSection5 = false;
if updateControl('bonus', bReadOnly, bID and (bWeapon or bArmor)) then bSection5 = true; end
if updateControl('aura', bReadOnly, bID) then bSection5 = true; end
if updateControl('cl', bReadOnly, bID) then bSection5 = true; end
if updateControl('prerequisites', bReadOnly, bID) then bSection5 = true; end
if self.updateControl("aura", bReadOnly, bID) then bSection5 = true; end
if self.updateControl("cl", bReadOnly, bID) then bSection5 = true; end
if self.updateControl("prerequisites", bReadOnly, bID) then bSection5 = true; end

local bSection6 = bID;
description.setVisible(bID);
description.setReadOnly(bReadOnly);
updateControl('sourcebook', bReadOnly, bID);

local bSection7 = false;
divider6.setVisible(false);
gmonly_label.setVisible(false);
gmonly.setVisible(false);

if Session.IsHost then if updateControl('gmonly', bReadOnly, bOptionID) then bSection7 = true; end end
if Session.IsHost then divider6.setVisible((bSection1 or bSection2 or bSection3 or bSection4 or bSection5) and bSection7); end
self.updateControl('sourcebook', bReadOnly, bID);
if self.updateControl('gmonly', bReadOnly, bID) then
gmonly.setVisible(Session.IsHost);
gmonly_label.setVisible(Session.IsHost);
end

divider.setVisible(bSection1 and bSection2);
divider2.setVisible((bSection1 or bSection2) and bSection3);
Expand Down

0 comments on commit 87af045

Please sign in to comment.