Skip to content

Commit

Permalink
Add support for PFRPG2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZarestiaDev committed Sep 23, 2022
1 parent 91dea7d commit 129394e
Show file tree
Hide file tree
Showing 9 changed files with 409 additions and 5 deletions.
File renamed without changes.
File renamed without changes.
63 changes: 63 additions & 0 deletions campaign/record_char_main_pfrpg2.xml
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="iso-8859-1"?>

<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root>
<windowclass name="charsheet_main" merge="join">
<script file="campaign/scripts/char_main.lua" />
<sheetdata>
<!-- ancestry -->
<frame_char name="ancestryframe" merge="delete" />
<linkfield name="racelink" merge="delete" />
<string_labeled name="race" merge="delete" />

<!--Background-->
<frame_char name="backgroundframe" merge="delete" />
<linkfield name="backgroundlink" merge="delete" />
<string_labeled name="background" merge="delete" />

<button_text_sm name="chartrackerlaunch" merge="delete" />

<!-- Class / Level -->
<frame_char name="classframe" merge="delete" />
<stringc_charclasslevel name="classlevel" merge="delete" />
<button_charclasslevel name="button_classlevel" merge="delete" />

<!-- Traits -->
<frame_char name="traitsframe" merge="delete" />
<string_labeled name="traits" merge="delete" />

<!-- Abilities -->
<frame_char name="abilityframe">
<bounds>15,0,275,225</bounds>
</frame_char>
<!-- Speed -->
<frame_char name="speedframe">
<bounds>15,225,385,50</bounds>
</frame_char>
<!-- Senses -->
<frame_char name="sensesframe">
<bounds>15,275,385,60</bounds>
</frame_char>
<!-- Health -->
<frame_char name="hpframe">
<bounds>15,335,385,100</bounds>
</frame_char>
<!-- Attacks -->
<frame_char name="combatframe">
<bounds>305,0,95,225</bounds>
</frame_char>
<!-- Defenses -->
<frame_char name="acframe">
<bounds>400,0,95,225</bounds>
</frame_char>
<!-- Saves -->
<frame_char name="saveframe">
<bounds>400,225,95,210</bounds>
</frame_char>
</sheetdata>
</windowclass>
</root>
190 changes: 190 additions & 0 deletions campaign/record_char_pfrpg2.xml
@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="iso-8859-1"?>

<root>
<windowclass name="charsheet" merge="join">
<script file="campaign/scripts/char.lua" />
<frame>charsheet</frame>
<placement>
<size width="570" height="630" />
</placement>
<sizelimits>
<minimum width="570" height="630" />
<dynamic />
</sizelimits>
<sheetdata>
<button_charactivate name="speak">
<bounds>-70,25,23,22</bounds>
</button_charactivate>

<token_char name="token">
<bounds>-76,55,40,40</bounds>
</token_char>

<genericcontrol name="portraitbase" merge="replace">
<anchored position="insidetopleft" offset="20,19" width="148" height="148" />
<icon>charlist_base</icon>
<disabled />
</genericcontrol>
<portrait_char name="portrait" merge="replace">
<anchored position="insidetopleft" offset="20,19" width="148" height="148" />
</portrait_char>

<frame_char name="overviewframe" merge="replace">
<anchored height="45" width="240">
<top offset="10" />
<left parent="portrait" anchor="right" />
</anchored>
</frame_char>

<button_text_sm name="chartrackerlaunch">
<anchored to="overviewframe" position="righthigh" offset="0,6" width="80" height="35" />
<state textres="char_button_chartracker" />
<script>
function onButtonPress()
local wCharTracker = Interface.findWindow( "chargen_tracker", window.getDatabaseNode() )
if wCharTracker then
Interface.toggleWindow( "chargen_tracker", window.getDatabaseNode() )
else
Interface.openWindow("chargen_tracker", window.getDatabaseNode());
end
end
</script>
</button_text_sm>

<!-- ancestry -->
<frame_char name="ancestryframe" insertbefore="heroframe">
<anchored height="45" width="185">
<top parent="overviewframe" anchor="bottom" offset="-5" />
<left parent="portrait" anchor="right" />
</anchored>
</frame_char>
<linkfield name="racelink">
<anchored to="ancestryframe" position="insidetopright" offset="10,10" width="20" height="20" />
<description field="race" />
<closetoggle />
<invisible />
<script>
function onInit()
onValueChanged();
end
function onValueChanged()
if isEmpty() then
setVisible(false);
else
setVisible(true);
end
end
</script>
</linkfield>
<string_labeled name="race">
<anchored to="ancestryframe" position="insidetopleft" offset="15,10" height="20">
<right parent="racelink" anchor="left" offset="-5" />
</anchored>
<labelres>char_label_ancestry</labelres>
</string_labeled>

<frame_char name="heroframe" merge="replace">
<anchored to="ancestryframe" position="right" offset="-5" width="145" />
</frame_char>

<!--Background-->
<frame_char name="backgroundframe">
<anchored height="45" width="185">
<top parent="ancestryframe" anchor="bottom" offset="-5" />
<left parent="portrait" anchor="right" />
</anchored>
</frame_char>
<linkfield name="backgroundlink">
<anchored to="backgroundframe" position="insidetopright" offset="10,10" width="20" height="20" />
<description field="background" />
<closetoggle />
<invisible />
<script>
function onInit()
onValueChanged();
end
function onValueChanged()
if isEmpty() then
setVisible(false);
else
setVisible(true);
end
end
</script>
</linkfield>
<string_labeled name="background">
<anchored to="backgroundframe" position="insidetopleft" offset="15,10" height="20">
<right parent="backgroundlink" anchor="left" offset="-5" />
</anchored>
<labelres>char_label_background</labelres>
</string_labeled>

<!-- Class / Level -->
<frame_char name="classframe">
<anchored height="45">
<top parent="ancestryframe" anchor="bottom" offset="-5" />
<left parent="backgroundframe" anchor="right" offset="-5" />
<right offset="-29" />
</anchored>
</frame_char>
<stringc_charclasslevel name="classlevel">
<anchored to="classframe" position="insidetopleft" offset="15,10">
<right offset="-25" />
</anchored>
<labelres>char_label_classlevelsummary</labelres>
</stringc_charclasslevel>
<button_charclasslevel name="button_classlevel">
<anchored to="classframe" position="insidetopright" offset="10,10" />
</button_charclasslevel>

<!-- Traits -->
<frame_char name="traitsframe">
<anchored height="45">
<top parent="backgroundframe" anchor="bottom" offset="-5" />
<left parent="portrait" anchor="right" />
<right offset="-29" />
</anchored>
</frame_char>
<string_labeled name="traits">
<anchored to="traitsframe" position="insidetopleft" offset="15,10" height="20">
<right offset="-10" />
</anchored>
<script file="common/scripts/string_traits_line.lua" />
<labelres>char_label_traits</labelres>
</string_labeled>

<subwindow name="main">
<bounds>0,170,-1,-20</bounds>
<class>charsheet_main</class>
</subwindow>
<subwindow name="combat">
<bounds>0,170,-1,-20</bounds>
<class>charsheet_combat</class>
</subwindow>
<subwindow name="skills">
<bounds>0,170,-1,-20</bounds>
<class>charsheet_skills</class>
<fastinit />
</subwindow>
<subwindow name="abilities">
<bounds>0,170,-1,-20</bounds>
<class>charsheet_abilities</class>
</subwindow>
<subwindow name="inventory">
<bounds>0,170,-1,-20</bounds>
<class>charsheet_inventory</class>
</subwindow>
<subwindow name="notes">
<bounds>0,170,-1,-20</bounds>
<class>charsheet_notes</class>
</subwindow>
<subwindow name="actions">
<bounds>0,170,-1,-20</bounds>
<class>charsheet_actions</class>
</subwindow>

<resize_charsheet />
<close_charsheet />
</sheetdata>
</windowclass>
</root>
21 changes: 21 additions & 0 deletions campaign/scripts/char.lua
@@ -0,0 +1,21 @@
function onInit()
if super and super.onInit then
super.onInit();
end
end

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

function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
local sClass, sRecord = draginfo.getShortcutData();
if StringManager.contains({"referenceclass", "referencerace", "reference_background", "referencefeat", "referenceclassability", "referenceracialtrait", "reference_lookupdata"}, sClass) then
CharManager.addInfoDB(getDatabaseNode(), sClass, sRecord);
return true;
end
end
end
120 changes: 120 additions & 0 deletions campaign/scripts/char_main.lua
@@ -0,0 +1,120 @@
--
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--

function onInit()
onLevelChanged();
DB.addHandler(DB.getPath(getDatabaseNode(), "classes"), "onChildUpdate", onLevelChanged);

onPCTypeChanged();
onHealthChanged();
end

function onClose()
DB.removeHandler(DB.getPath(getDatabaseNode(), "classes"), "onChildUpdate", onLevelChanged);
end

function onLevelChanged()
CharManager.calcLevel(getDatabaseNode());

CharManager.recalcProficiencies(getDatabaseNode());
end

function onPCTypeChanged()
local nodeChar = getDatabaseNode();
local sPCType = CharManager.getPCType(nodeChar);

GlobalDebug.consoleObjects("char_main.lua - onPCTypeChanged. nodeChar, sPCType = ", nodeChar, sPCType);

local bLinkedPC = false;

if sPCType == "eidolon" then
bLinkedPC = true;
end

hp.setVisible(not bLinkedPC);
hp.setEnabled(not bLinkedPC);
hp_label.setVisible(not bLinkedPC);
wounds.setVisible(not bLinkedPC);
wounds_label.setVisible(not bLinkedPC);
hptemp.setVisible(not bLinkedPC);
hptemp_label.setVisible(not bLinkedPC);
current.setVisible(not bLinkedPC);
current.setEnabled(not bLinkedPC);
current_label.setVisible(not bLinkedPC);
wounded.setVisible(not bLinkedPC);
wounded_label.setVisible(not bLinkedPC);
dying.setVisible(not bLinkedPC);
dying_label.setVisible(not bLinkedPC);

if bLinkedPC then
hp.destroy();
hp_label.destroy();
wounds.destroy();
wounds_label.destroy();
hptemp.destroy();
hptemp_label.destroy();
current.destroy();
current_label.destroy();
wounded.destroy();
wounded_label.destroy();
dying.destroy();
dying_label.destroy();
end

hp_linked.setVisible(bLinkedPC);
hp_linked.setEnabled(bLinkedPC);
hp_linked_label.setVisible(bLinkedPC);
wounds_linked.setVisible(bLinkedPC);
wounds_linked_label.setVisible(bLinkedPC);
hptemp_linked.setVisible(bLinkedPC);
hptemp_linked_label.setVisible(bLinkedPC);
current_linked.setVisible(bLinkedPC);
current_linked.setEnabled(bLinkedPC);
current_linked_label.setVisible(bLinkedPC);
wounded_linked.setVisible(bLinkedPC);
wounded_linked_label.setVisible(bLinkedPC);
dying_linked.setVisible(bLinkedPC);
dying_linked_label.setVisible(bLinkedPC);
button_hpdetails.setVisible(not bLinkedPC);

parentcontrol.window.ancestryframe.setVisible(not bLinkedPC);
parentcontrol.window.racelink.setVisible(not bLinkedPC);
parentcontrol.window.race.setVisible(not bLinkedPC);
parentcontrol.window.backgroundframe.setVisible(not bLinkedPC);
parentcontrol.window.backgroundlink.setVisible(not bLinkedPC);
parentcontrol.window.background.setVisible(not bLinkedPC);
parentcontrol.window.button_classlevel.setVisible(not bLinkedPC);

if sPCType == "eidolon" then
local tLinkedPCs = LinkedPCManager.getBaseLinkedPCs(nodeChar);
GlobalDebug.consoleObjects("char_main.lua - onPCTypeChanged. tLinkedPCs = ", tLinkedPCs);
if tLinkedPCs ~= {} then
-- We could have multiple linked PCs. This won't work properly if that is the case. Use the first linked PC as the base PC.
local sBaseLinkedPCNodeName = tLinkedPCs[1];
GlobalDebug.consoleObjects("char_main.lua - onPCTypeChanged. sBaseLinkedPCNodeName = ", sBaseLinkedPCNodeName);
if (sBaseLinkedPCNodeName or "") ~= "" then
local nodeBaseChar = DB.findNode(sBaseLinkedPCNodeName);
if nodeBaseChar then
LinkedPCManager.syncEidolonHP(nodeBaseChar);
end
end
end
end
end

function onHealthChanged()
local rActor = ActorManager.resolveActor(getDatabaseNode());
local sColor = ActorHealthManager.getHealthColor(rActor);
local nodeChar = getDatabaseNode();
local sPCType = CharManager.getPCType(nodeChar);

if sPCType == "eidolon" then
wounds_linked.setColor(sColor);
current_linked.setColor(sColor);
else
wounds.setColor(sColor);
current.setColor(sColor);
end
end
File renamed without changes.

0 comments on commit 129394e

Please sign in to comment.