PDA

View Full Version : [DEV] How to make character sheet windows resizable ?



PolluxTroy
May 21st, 2017, 19:08
Hi,

For conveniance purpose, i'd like to make the Actions tabs in the character sheet resizable.
I've been able to make the global window resizable but data in the tabs don't move.
I'm abble to set a fixed size for the actions box but when i resize the window, nothing happen.
I'd like to have something like the Mini sheet that is resizable but with the full sheet.

In action : https://i.imgur.com/phI6zBh.jpg

This is a part of my code for record_char_actions.xml :



<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<windowclass name="charsheet_actions">
<script file="campaign/scripts/char_actions.lua" />
<sheetdata>
<frame_char name="actionframe">
<bounds>15,0,480,480</bounds>
</frame_char>

<subwindow name="actions">
<anchored to="actionframe" position="over" offset="-8,-10">
<bottom offset="-50" />
</anchored>
<activate />
<class>char_actions_details</class>
</subwindow>
<scrollbar>
<anchored to="actions" position="right" offset="-2,-4" width="20">
<bottom offset="20" />
</anchored>
<target>actions</target>
</scrollbar>

<button_expand name="expand">
<anchored to="actionframe" position="insidebottomleft" offset="25,15" width="20" height="20" />
<target>actions,spellclasslist,levels,spells</target>
<togglelevel>3</togglelevel>
</button_expand>
<button_collapse name="collapse">
<anchored to="actionframe" position="insidebottomleft" offset="55,15" width="20" height="20" />
<target>actions,spellclasslist,levels,spells</target>
<togglelevel>3</togglelevel>
</button_collapse>

<label name="label_mode">
<anchored to="actionframe" position="insidebottomleft" offset="90,15" />
<static textres="spell_label_mode" />
</label>
<button_stringcycler name="spellmode">
<anchored to="label_mode" position="righthigh" offset="10,0" width="80" />
<parameters>
<labelsres>spell_label_modeprep|spell_label_modecombat</labelsres>
<values>preparation|combat</values>
<defaultlabelres>spell_label_modestd</defaultlabelres>
</parameters>
<script>
function onValueChanged()
window.onModeChanged();
end
</script>
</button_stringcycler>

<label name="label_display">
<anchored to="actionframe" position="insidebottomleft" offset="250,15" />
<static textres="spell_label_display" />
</label>
<button_stringcycler name="spelldisplaymode">
<anchored to="label_display" position="righthigh" offset="10,0" width="80" />
<parameters>
<labelsres>spell_label_displayaction</labelsres>
<values>action</values>
<defaultlabelres>spell_label_displaystd</defaultlabelres>
</parameters>
<script>
function onValueChanged()
window.onDisplayChanged();
end
</script>
</button_stringcycler>

<button_iedit name="actions_iedit">
<anchored to="actionframe" position="insidebottomright" offset="15,15" />
<tooltip textres="char_tooltip_actionedit" />
<script>
function onValueChanged()
local bEditMode = (getValue() == 1);

window.label_mode.setVisible(not bEditMode);
window.spellmode.setVisible(not bEditMode);
window.label_display.setVisible(not bEditMode);
window.spelldisplaymode.setVisible(not bEditMode);
if bEditMode then
DB.setValue(window.getDatabaseNode(), "spellmode", "string", "standard");
DB.setValue(window.getDatabaseNode(), "spelldisplaymode", "string", "");
end
window.spellclass_iadd.setVisible(bEditMode);
window.weapon_iadd.setVisible(bEditMode);
window.actions.subwindow.update();
end
</script>
</button_iedit>
<buttoncontrol name="spellclass_iadd">
<anchored to="actions_iedit" position="lefthigh" offset="5,0" width="20" height="20" />
<icon normal="button_star" pressed="button_star_down" />
<tooltip textres="char_tooltip_actionaddspellclass" />
<invisible />
<script>
function onButtonPress()
window.actions.subwindow.addSpellClass();
end
</script>
</buttoncontrol>
<buttoncontrol name="weapon_iadd">
<anchored to="spellclass_iadd" position="lefthigh" offset="5,0" width="20" height="20" />
<icon normal="button_weapon" pressed="button_weapon_down" />
<tooltip textres="char_tooltip_actionaddweapon" />
<invisible />
<script>
function onButtonPress()
window.actions.subwindow.addWeapon();
end
</script>
</buttoncontrol>
</sheetdata>
</windowclass>

<windowclass name="char_actions_details">
<!-- Taille dynamique de la fenêtre -->
<sizelimits>
<minimum width="480" height="480" />
<dynamic />
</sizelimits>
<!-- -->
<script file="campaign/scripts/char_actions_details.lua" />
<sheetdata>
<genericcontrol name="dropcatcher">
<anchored position="over" />
<script>
function onDrop(x, y, draginfo)
return CharManager.onActionDrop(draginfo, window.getDatabaseNode());
end
</script>
</genericcontrol>



Can someone help me please ?

Trenloe
May 21st, 2017, 19:42
Welcome to the forums PolluxTroy


I'm abble to set a fixed size for the actions box but when i resize the window, nothing happen.
This is your issue. If you set a fixed size, then that is exactly what you'll get - a fixed size that doesn't resize with anything else.

You have set the actions frame to have bounds of 15,0,480,480 This means that it will always start at 15,0 pixels within the window and always be 480x480 in size.

If you want it to move with the window, then best to set a negative value for width/height - as this means they reference the edge of the window.

This is fully documented under "Static Bounds" following "A slightly more complex set up involves negative coordinates." on this page of the Ruleset Modification Guide (https://www.fantasygrounds.com/modguide/): https://www.fantasygrounds.com/modguide/windowing.xcp

PolluxTroy
May 21st, 2017, 21:01
Thanks a lot,
I didn't know that there is a guide for scripting ;)

Trenloe
May 21st, 2017, 22:40
Here are a few guides. Referenced here: https://www.fantasygrounds.com/forums/showthread.php?19033-Modifying-the-3-5e-PFRPG-ruleset