Toruqe 2D/Reference/Strategy/StrategyMouseSelections/addSelectionMenuButton
From TDN
|
[edit] The addSelectionMenuButton() completed function
// --------------------------------------------------------------------
// addSelectionMenuButton()
//
// Since we have all the positions calculated in initSelectionMenu()
// this function just grabs that position for the next button in line
// and generates a gui cutton control for it and adds it to the proper
// GuiControl, it also does all the proper incrementing
// --------------------------------------------------------------------
function addSelectionMenuButton(%extent, %obj, %pos, %val)
{
// first lets grab the x and the y position for this button based on its
// column and row position
%xPos = SelectionBox.xPos[SelectionMenu.columnCount];
%yPos = SelectionBox.yPos[SelectionMenu.rowCount];
// lets grab the object's name
%name = %obj.getSelectionName();
// new we generate the action gui button control, inputing the correct name,
// command (function to be called when clicked), position, and extent
new GuiButtonCtrl(%name @ %val) {
profile = "GuiButtonSelectionProfile";
text = %name;
command = "selectionInMultiple(" @ %obj @ ", \"" @ %pos @ "\");";
position = %xPos SPC %yPos;
extent = %extent;
};
// then we add the button we just generated to the control
SelectionMenu.add(%name @ %val);
// incriment the row count
SelectionMenu.rowCount++;
// here we check if the rowcount should trigger the increment of the next column
if(SelectionMenu.rowCount >= SelectionMenu.rowMax)
{
SelectionMenu.rowCount = 0;
SelectionMenu.columnCount++;
}
}
|



