Skip to content

Commit

Permalink
Delete of tooltips, add both option, change sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
ZarestiaDev committed Sep 2, 2022
1 parent a97337e commit 486e710
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 70 deletions.
6 changes: 1 addition & 5 deletions campaign/record_power.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<invis_string_additional name="updatecomponents" source="components" />
<invis_string_additional name="updaterange" source="range" />

<string_spell name="name">
<script file="campaign/scripts/name_tooltip.lua" />
</string_spell>

<!-- Zarestia adding label to display the casting time -->
<label name="action_info" insertbefore="group">
<script file="campaign/scripts/show_action_info.lua" />
Expand All @@ -24,7 +20,7 @@
<!-- Zarestia adding label to display the components -->
<label name="additional_info" insertbefore="group">
<script file="campaign/scripts/show_additional_info.lua" />
<anchored width="0">
<anchored width="65">
<top offset="2" />
<left parent="action_info" anchor="right" />
</anchored>
Expand Down
7 changes: 3 additions & 4 deletions campaign/record_spell_entry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<left parent="hanchor" anchor="right" relation="relative" offset="5" />
<right parent="action_info" anchor="left" offset="-10" />
</anchored>
<script file="campaign/scripts/name_tooltip.lua" />
</string_spell>

<!-- Zarestia adding invsible strings to update changes live -->
Expand All @@ -44,7 +43,7 @@
<!-- Zarestia adding label to display the casting time -->
<label name="action_info" insertbefore="actionsmini">
<script file="campaign/scripts/show_action_info.lua" />
<anchored width="70">
<anchored width="65">
<top offset="2" />
<left anchor="center" offset="0" />
</anchored>
Expand All @@ -53,9 +52,9 @@
<!-- Zarestia adding label to display the components -->
<label name="additional_info" insertbefore="actionsmini">
<script file="campaign/scripts/show_additional_info.lua" />
<anchored width="0">
<anchored width="65">
<top offset="2" />
<left parent="action_info" anchor="right" offset="10" />
<left parent="action_info" anchor="right" offset="5" />
</anchored>
</label>
</sheetdata>
Expand Down
5 changes: 2 additions & 3 deletions campaign/record_spell_mini.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
</anchored>
<multilinespacing>20</multilinespacing>
<readonly />
<script file="campaign/scripts/name_tooltip.lua" />
</simplestring>

<!-- Zarestia adding invsible strings to update changes live -->
Expand All @@ -41,7 +40,7 @@
<!-- Zarestia adding label to display the casting time -->
<label name="action_info" insertbefore="actions">
<script file="campaign/scripts/show_action_info.lua" />
<anchored width="70">
<anchored width="65">
<top offset="2" />
<left anchor="center" offset="0" />
</anchored>
Expand All @@ -50,7 +49,7 @@
<!-- Zarestia adding label to display the components -->
<label name="additional_info" insertbefore="actions">
<script file="campaign/scripts/show_additional_info.lua" />
<anchored width="0">
<anchored width="65">
<top offset="2" />
<left parent="action_info" anchor="right" relation="relative" offset="10" />
</anchored>
Expand Down
43 changes: 0 additions & 43 deletions campaign/scripts/name_tooltip.lua

This file was deleted.

18 changes: 16 additions & 2 deletions campaign/scripts/show_action_info.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
local RULESET = "";

function onInit()
RULESET = User.getRulesetName();

if RULESET == "SFRPG" then
self.setAnchoredWidth(60);
end

setActionInfo();
end

function setActionInfo()
local nodeSpell = window.getDatabaseNode();
local sAction = DB.getValue(nodeSpell, "castingtime", ""):lower();

if User.getRulesetName() == "5E" then
if RULESET == "5E" then
sAction = setActionInfo5E(nodeSpell, sAction);
else
sAction = sAction:gsub("%s?action", "");
sAction = setActionInfo35E(sAction);
end

if not (sAction:match("minute") or sAction:match("hour")) then
Expand Down Expand Up @@ -39,3 +47,9 @@ function setActionInfo5E(nodeSpell, sAction)

return sAction;
end

function setActionInfo35E(sAction)
sAction = sAction:gsub("%s?action", "");

return sAction;
end
51 changes: 41 additions & 10 deletions campaign/scripts/show_additional_info.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RULESET = "";
local RULESET = "";

function onInit()
OptionsManager.registerCallback("SAIO", StateChanged);
Expand All @@ -21,19 +21,25 @@ function StateChanged()
if OptionsManager.isOption("SAIO", "off") then
self.setVisible(false);
else
if RULESET == "5E" then
setAnchoredWidth(50);
if RULESET == "5E" or RULESET == "SFRPG" then
self.setAnchoredWidth(50);
else
setAnchoredWidth(75);
self.setAnchoredWidth(65);
end
self.setVisible(true);
end

local sAdditionalInfo = "";

if OptionsManager.isOption("SAIO", "components") then
setComponentsInfo();
sAdditionalInfo = setComponentsInfo();
elseif OptionsManager.isOption("SAIO", "range") then
setRangeInfo();
sAdditionalInfo = setRangeInfo();
elseif OptionsManager.isOption("SAIO", "both") then
sAdditionalInfo = setBothInfo();
end

self.setValue(sAdditionalInfo);
end

function setComponentsInfo()
Expand All @@ -55,25 +61,30 @@ function setComponentsInfo()
-- Getting rid of paranthesis and text inbewteen for 5e
sComponents = sComponents:gsub("%s?%b()", "");

self.setValue(sComponents);
return sComponents;
end

function setRangeInfo()
local nodeSpell = window.getDatabaseNode();
local sRange = DB.getValue(nodeSpell, "range", ""):lower();

if RULESET == "5E" then
sRange = sRange:gsub("%s?%b()", "");
sRange = setRangeInfo5E(sRange);
else
sRange = setRangeInfo35E(nodeSpell, sRange);
end

sRange = sRange:gsub("feet", "ft");
sRange = sRange:gsub("%.", "");

sRange = StringManager.capitalize(sRange);

self.setValue(sRange);
return sRange;
end

function setRangeInfo5E(sRange)
sRange = sRange:gsub("%s?%b()", "");

return sRange;
end

function setRangeInfo35E(nodeSpell, sRange)
Expand All @@ -99,3 +110,23 @@ function setRangeInfo35E(nodeSpell, sRange)

return sRange;
end

function setBothInfo()
if RULESET == "5E" then
self.setAnchoredWidth(100);
else
self.setAnchoredWidth(125);
end

local sRange = setRangeInfo();
local sComponents = setComponentsInfo();
local sSpacer = " | ";

if (sRange == "" or sComponents == "") then
sSpacer = "";
end

local sBoth = sComponents .. sSpacer .. sRange;

return sBoth;
end
4 changes: 2 additions & 2 deletions extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<root version="3.3" >
<properties>
<name>Feature: Spell Action Info</name>
<version>4.0</version>
<version>4.1</version>
<loadorder>142</loadorder>
<description>
<text>Spell Action Info</text>
Expand All @@ -23,7 +23,7 @@
</ruleset>
</properties>

<announcement text="https://forge.fantasygrounds.com/shop/items/242/view \n3.5E/PFRPG/5E Spell Action Info - v4.0 \rby Zarestia, compatibility contributions by MeAndUnique, 2022" font="emotefont" icon="sai_icon" />
<announcement text="https://forge.fantasygrounds.com/shop/items/242/view \n3.5E/PFRPG/5E Spell Action Info - v4.1 \rby Zarestia, contributions by MeAndUnique, Rhagelstrom" font="emotefont" icon="sai_icon" />

<base>
<!-- Campaign -->
Expand Down
2 changes: 1 addition & 1 deletion scripts/sai_data_options_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ end

function registerOptionsDND()
OptionsManager.registerOption2("SAIO",true, "option_header_client", "option_label_SAIO", "option_entry_cycler",
{ labels = "option_val_components|option_val_range", values = "components|range", baselabel = "option_val_off", baseval = "off", default = "off" });
{ labels = "option_val_components|option_val_range|option_val_both", values = "components|range|both", baselabel = "option_val_off", baseval = "off", default = "off" });
end

function registerOptionsSFRPG()
Expand Down
1 change: 1 addition & 0 deletions strings/sai_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
<string name="option_label_SAIO">Show additional Spell Info</string>
<string name="option_val_components">Components</string>
<string name="option_val_range">Range</string>
<string name="option_val_both">Both</string>
</root>

0 comments on commit 486e710

Please sign in to comment.