import "Turbine.UI";
SetupFeatures = class(Turbine.UI.ListBox);
-- helper functions
local tt = function(width, height, control, text)
local tooltip = KragenPlugs.UI.Tooltip();
tooltip:SetText(text);
tooltip:SetControl(control);
tooltip:SetSize(width, height);
end
local holder = function(parent, height)
local container = Turbine.UI.Control();
container:SetSize(400, height);
parent:AddItem(container);
return container;
end
function SetupFeatures:Constructor()
Turbine.UI.ListBox.Constructor(self);
self.current = nil;
self.titlebars = { };
self.traits = { };
self.features = { };
self.defaults = { };
self:SetOrientation(Turbine.UI.Orientation.Horizontal);
self:SetMaxItemsPerLine(1);
-- self:AddTitleBar("Traits");
-- for i = 1,4 do self:AddCheckboxRow(self.traits) end -- Adds 2 checkboxes each row therefore #checkboxes = for-end x 2
-- self:AddTitleBar("Features");
-- for i = 1,5 do self:AddCheckboxRow(self.features) end -- Adds 2 checkboxes each row therefore #checkboxes = for-end x 2
-- self:AddTitleBar("Defaults");
-- for i = 1,4 do self:AddComboBox(self.defaults) end
end
function SetupFeatures:AddTitleBar(text)
local index = #self.titlebars + 1;
local line = holder(self, 35);
self.titlebars[index] = KragenPlugs.UI.PanelDivider();
self.titlebars[index]:SetPosition(0,0);
self.titlebars[index]:SetParent(line);
self.titlebars[index]:SetText(text);
self.titlebars[index]:SetSize(400, 30);
end
function SetupFeatures:AddCheckboxRow(option)
local index = #option + 1;
local line = holder(self, 20);
for i = 1,2 do
option[index] = KragenPlugs.UI.CheckBox();
option[index]:SetParent(line);
option[index]:SetSize(180, 20);
if math.mod(index, 2) == 0 then
option[index]:SetPosition(220,0);
option[index]:AlignLeft(true);
else
option[index]:SetPosition(0,0);
end
option[index]:SetText("Checkbox");
option[index]:SetVisible(false);
index = #option + 1;
end
end
function SetupFeatures:AddSlider(option, mini, maxi, step, text)
local index = #option + 1;
local line = holder(self, 50);
option[index] = KragenPlugs.UI.Slider();
option[index]:SetParent(line);
option[index]:SetText(text);
option[index]:SetPosition(49, 0);
option[index]:SetSize(350, 40);
option[index]:SetStep(step);
option[index]:SetMin(mini);
option[index]:SetMax(maxi);
end
function SetupFeatures:AddComboBox(option)
local index = #option + 1;
local line = holder(self, 30);
option[index] = { };
option[index].label = KragenPlugs.UI.Label();
option[index].label:SetParent(line);
option[index].label:SetSize(190, 20);
option[index].label:SetPosition(20, 0);
option[index].label:SetText("Label");
option[index].label:SetVisible(false);
option[index].combobox = KragenPlugs.UI.ComboBox();
option[index].combobox:SetParent(line);
option[index].combobox:SetSize(190, 20);
option[index].combobox:SetPosition(210, 0);
option[index].combobox:SetVisible(false);
end
function SetupFeatures:Destroy()
-- cleanup the quickslots so the client doesn't crash
end