lotrointerface.com
Search Downloads

LoTROInterface SVN KragenBars

[/] [branches/] [3.01/] [KragenBars/] [SetupWindow.lua] - Rev 17

Compare with Previous | Blame | View Log

import "Turbine.Gameplay";
import "Turbine.UI";
import "KragenPlugs.KragenBars";
import "KragenPlugs.UI";

SetupWindow = class(KragenPlugs.UI.Window);

function SetupWindow:Constructor()

    KragenPlugs.UI.Window.Constructor(self);

        if (type( settings.setup ) ~= "table") then
                settings.setup = { };
                settings.setup.x = 100;
                settings.setup.y = 100;
                SaveSettings();
        end
    if (settings.setup.x ~= nil) then
        self:SetPosition(ValidatePosition(settings.setup.x, settings.setup.y, self:GetWidth(), self:GetHeight()));
    end

    self:SetVisible(false);
    self:SetText("KragenBars Setup");
    self:SetSize(575, 535);
    self.Closed = function(sender, args)
        KragenPlugs.UI.ComboBox.Cleanup();
        local i;
        for i = 1, table.getn(self.tabs) do
            if (type(self.tabs[i].Closed) == "function") then
                self.tabs[i]:Closed();
            end
        end

        -- save the position
        settings.setup.x, settings.setup.y = self:GetPosition();
                SaveSettings();

        -- remove the ref
        self:Destroy();
    end

    -- restore the position if there is one

    -- close any open drop downs
    self.PositionChanged = function(sender, args)
        KragenPlugs.UI.ComboBox.Cleanup();
    end

    -- listen for events
    -- KragenPlugs.Utils.KeyManager.AddListener(self);

    self.sideBar = Turbine.UI.Control();
    self.sideBar:SetParent(self);
    self.sideBar:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend);
    self.sideBar:SetBackground("KragenPlugs/UI/Resources/options_menu_side_bar.tga");
    self.sideBar:SetSize(140, 507);
    self.sideBar:SetPosition(432, 24);
    self.sideBar:SetMouseVisible(false);

    self.cancelButton = Turbine.UI.Lotro.Button();
    self.cancelButton:SetParent(self);
    self.cancelButton:SetPosition(122, 502);
    self.cancelButton:SetSize(100, 20);
    self.cancelButton:SetText("Cancel");
    self.cancelButton.Click = function(sender, args)
        self:Close();
    end

    self.acceptButton  = Turbine.UI.Lotro.Button();
    self.acceptButton:SetParent(self);
    self.acceptButton:SetPosition(237, 502);
    self.acceptButton:SetSize(100, 20);
    self.acceptButton:SetText("Accept");
    self.acceptButton.Click = function(sender, args)
        KragenBars:SetupClosing();
        self:Close();
    end

    -- create the tabs
    self.setupbb = SetupButtonBars();
    self.setupf = SetupFeatures();
    self.setupqs = SetupQuickslots();
        self.setuplmpets = SetupLMPets();

    self.tabs = {self.setupbb, self.setupf, self.setupqs, self.setuplmpets};
    self.buttons = {"Button Bars", "Features", "Quickslots", "Pets"};

    local i;
    for i = 1, table.getn(self.tabs) do
        -- create a tab button
        local button = KragenPlugs.UI.Button();
        button:SetParent(self);
        button:SetPosition(439, 60 + (25 * i));
        button:SetSize(127, 20);
        button:SetText(self.buttons[i]);
        button.Click = function(sender, args)
            self:SwitchTab(self.tabs[i], self.buttons[i]);
        end
        self.buttons[i] = button;

        -- create the tab
        local tab = Turbine.UI.Control();
        tab:SetParent(self);
        tab:SetSize(415, 447);
        tab:SetPosition(16, 53);
        tab:SetVisible(false);

        local scrollbar = Turbine.UI.Lotro.ScrollBar();
        scrollbar:SetOrientation(Turbine.UI.Orientation.Vertical);
        scrollbar:SetParent(tab);
        scrollbar:SetSize(10, 447);
        scrollbar:SetPosition(405, 0);

        local panel = self.tabs[i];
        panel.tab = tab;
        panel:SetParent(tab);
        panel:SetVerticalScrollBar(scrollbar);
        panel:SetSize(400, 447);
        panel:SetPosition(0, 0);
        panel:GetItem(1).PositionChanged = function(sender, args)
            KragenPlugs.UI.ComboBox.Cleanup();
        end
    end

        self.buttons[4]:SetVisible(false);
        
    -- show the first tab
    self:SwitchTab(self.tabs[1], self.buttons[1]);

end

function SetupWindow:SwitchTab(tab, button)
    KragenPlugs.UI.ComboBox.Cleanup();

    local i;
    for i = 1, table.getn(self.tabs) do
        self.tabs[i].tab:SetVisible(tab == self.tabs[i]);
        self.buttons[i]:SetSelected(button == self.buttons[i]);
    end
end

-- function SetupWindow:UiHidden(hidden)
    -- self:SetVisible(not hidden);
    -- KragenPlugs.UI.ComboBox.Cleanup();
-- end

function SetupWindow:Destroy()
    self:SetVisible(false);
    local i;
    for i = 1, table.getn(self.tabs) do
        if (type(self.tabs[i].Destroy) == "function") then
            self.tabs[i]:Destroy();
        end
    end
    SetupWindow.instance = nil;
end

-- class level stuff
SetupWindow.instance = nil;

-- command to show the options
function SetupWindow.ShowOptions()
    if (SetupWindow.instance == nil) then
        SetupWindow.instance = SetupWindow();
    end
end

-- command to close/cleanup the options
function SetupWindow.CloseOptions()
    if (SetupWindow.instance ~= nil) then
        SetupWindow.instance:Destroy();
    end
end

Compare with Previous | Blame


All times are GMT -5. The time now is 06:39 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui