PDA

View Full Version : Grouping and then referencing controls in the group



MadBeardMan
January 3rd, 2019, 22:18
Greetings All,

Thanks for the help so far on the random questions I've posted here.

Here's another that I'd like help with.

This code is to roll a number of dice to check for successes, it works getting the dice to roll (dot control) and I get the correct dice, but I don't know what dice roll this is.

Within the code there's a frame and then there's a label and then a dot control (1 dot per dice to roll) and then the 'roll the dice button'.

What I'd like to do is to group these inside a control, so that I can reference the label (to get what roll is about to be made) and get the number of dots without direct reference.

Ideally I'd like to place this into the button_roll class, but not sure then how to reference things.

If anyone could help that would be ace.


<frame_char name="init_frame">
<bounds>25,75,155,50</bounds>
</frame_char>
<label_frametop>
<anchored to="init_frame" />
<static textres="dicepool_label_initiative" />
<font>reference-headermini</font>
</label_frametop>
<dotcontrol name="initiativemod" >
<anchored to="init_frame" position="insidetopleft" offset="27,30" width="100" height="10" />
<center />
<readonly />
<dots>10</dots>
</dotcontrol>
<button_roll name="initiative_roll">
<anchored to="init_frame" position="insidetopleft" offset="0,0" width="18" height="18" />
<script>
function action(draginfo)

local nodeWin = window.getDatabaseNode();

if nodeWin then

local nTotal = window.initiativemod.getValue();

local nodeChar = nodeWin.getChild("...");
local rActor = ActorManager.getActor("pc", nodeChar);

print ('Dice to roll: ' .. nTotal)

end

return true;
end

function onDragStart(button, x, y, draginfo)
return action(draginfo);
end

function onDoubleClick(x,y)
return action();
end

</script>
</button_roll>

Cheers,
MBM

Moon Wizard
January 3rd, 2019, 23:09
There is no concept of "grouping" controls. You can use subwindows and windowlists to create something similar, but you should only use when appropriate to the data you're trying to display.

I wouldn't group the frame anyway, since you may not always want the frame.

A couple ways I would look at:

1. Create a single template that uses text and bitmap widgets to lay out the label and dots as needed to match the value of the control template. This would require lots of fiddling as you would need to define exact widget placement based on existing control size. Also, you need the template to track both the current and maximum values for the dots.

2. Create templates for each component that use relative layout to a single "parent" control object. Then, just add the templates as a group with the right relative layout names.

Also, you should look at using the existing "buttongroup_counter" template in the CoreRPG ruleset to implement the dots instead of implementing your own.

Regards,
JPG

MadBeardMan
January 3rd, 2019, 23:14
There is no concept of "grouping" controls. You can use subwindows and windowlists to create something similar, but you should only use when appropriate to the data you're trying to display.

I wouldn't group the frame anyway, since you may not always want the frame.

A couple ways I would look at:

1. Create a single template that uses text and bitmap widgets to lay out the label and dots as needed to match the value of the control template. This would require lots of fiddling as you would need to define exact widget placement based on existing control size. Also, you need the template to track both the current and maximum values for the dots.

2. Create templates for each component that use relative layout to a single "parent" control object. Then, just add the templates as a group with the right relative layout names.

Also, you should look at using the existing "buttongroup_counter" template in the CoreRPG ruleset to implement the dots instead of implementing your own.

Regards,
JPG

Hi Chap,

Thanks for the detailed response.

I'll go back to Dan on this (it's for the Vampire ruleset) as he added all the windows with all the controls and dots and things.

Cheers
MBM

damned
January 3rd, 2019, 23:20
Have a look at the Trackers in MoreCore.
Im not rolling dice but I do reference the number of dots and the name of the tracker.

MadBeardMan
January 3rd, 2019, 23:28
Have a look at the Trackers in MoreCore.
Im not rolling dice but I do reference the number of dots and the name of the tracker.

Morning Chap,

Ok thanks, I have dice rolling, just trying to find a better way to code it, rather than a lot of copied code across a lot of skills/disciplines/attributes etc.

Cheers,
MBM

damned
January 3rd, 2019, 23:47
Have a look at the Trackers in MoreCore.

MadBeardMan
January 3rd, 2019, 23:49
Have a look at the Trackers in MoreCore.

Great, I've made Dan aware of this thread, he's going to look at the Dots tomorrow.

Moon Wizard
January 4th, 2019, 00:09
The common button counter templates weren't around for the VtM ruleset originally (along with a lot of other pieces). It might be worth reviewing the CoreRPG common templates to see what is available.

JPG