PDA

View Full Version : Refreshing a char sheet?



Druthlen
July 4th, 2019, 23:58
I have a function that adds widgets, these widgets are dots.
I plan on linking the dots to a shortcut for discipline features.
However as I add dots, the char sheet must be exited and reentered to display the new dots.

How do I refresh the screen?

LordEntrails
July 5th, 2019, 00:10
/reload might work. Otherwise probably the way you are doing it.

Druthlen
July 5th, 2019, 02:25
/reload might work. Otherwise probably the way you are doing it.

Well I was hoping for something like:


inside the template.LUA

function updateStatus()
window.update();
end

Then inside the XML file



function onInit()
update();
end
function update()
local bReadOnly = WindowManager.getReadOnlyState(getDatabaseNode());
name.update(bReadOnly);
end


This doesn't work however. /reload just reloads the ruleset and I am looking for a way to refresh the screen after a handleDrop function.
Also here is how I am adding the widgets



local readonlyflag = false;
levels = {};
local nMaxSlotRow = 10;
local nDefaultSpacing = 10;
local nSpacing = nDefaultSpacing;
local clicknX = {};
local clicknY = {};

function onInit()
setIcon(stateicons[1].off[1]);
--initals value as 0
local node = DB.setValue(node, "level", "number", 0);
--grab value
node = window.getDatabaseNode();



local initialnode = nil;

if spacing then
nSpacing = tonumber(spacing[1]) or nDefaultSpacing;
end

setAnchoredHeight(nSpacing*2);
setAnchoredWidth(nSpacing);


if node then
-- Determine readonly state
if NodeManager.isReadOnly(node) then
readonlyflag = true;
end

-- Determine the name we should use for the node
local srcname = getName();
local srcvalue = node.getChild("level").getValue()
local i = 1;
while srcvalue >= i do
local widget = nil;
widget = addBitmapWidget(stateicons[1].on[1]);

local nW = (i - 1) % nMaxSlotRow;
local nH = math.floor((i - 1) / nMaxSlotRow);

local nX = (nSpacing * nW) + math.floor(nSpacing / 2);
local nY;
if srcvalue > nMaxSlotRow then
nY = (nSpacing * nH) + math.floor(nSpacing / 2);
else
nY = (nSpacing * nH) + nSpacing;
end

widget.setPosition("topleft", nX, nY);
local disciplinename = DB.getValue(node, "name", ""):lower();
local sRecord = "reference.disciplines." .. disciplinename .. "@VtM 20th Anniversary Edition";
local sFormat = Interface.getString("char_message_disciplineadd");
local sMsg = string.format(sFormat, sRecord, DB.getValue(nodeChar, "name", ""));
ChatManager.SystemMessage(sMsg);
--DB.setValue(widget, "shortcut", "windowreference", "referencediscipline", sRecord);
levels[i] = widget;
i = i + 1;
updateStatus();
end
end
end

function updateStatus()
window.update();
end

--[[function onClickDown(button, x, y)
return true;
end]]--

function onClickRelease(button, x, y)

Interface.openWindow("referencediscipline", window.getDatabaseNode());
end

function setReadOnly(state)
readonlyflag = state;
end

Druthlen
July 5th, 2019, 02:27
Oh, I have the chat messager in there as a debugging tool, it should be removed.

damned
July 5th, 2019, 04:55
If your code is running in onInit it will only do it on initialising the sheet.
Move the code to a function like onChangeValue or similar an in onInit also call the onChangeValue function.
That is how most of the systems do it.