lotrointerface.com
Search Downloads

LoTROInterface SVN SequenceBars

[/] [trunk/] [Thurallor/] [SequenceBars/] [DirectoryWindow.lua] - Rev 177

Compare with Previous | Blame | View Log

DirectoryWindow = class(Turbine.UI.Lotro.Window);

function DirectoryWindow:Constructor(manager, optionsPanel)
    Turbine.UI.Lotro.Window.Constructor(self);
    self.manager = manager;
    self.settings = manager.settings.directoryWindow or {};
    manager.settings.directoryWindow = self.settings;
    self.optionsPanel = optionsPanel;

    -- Restore saved size/position
    self:SetResizable(true);
    self:SetMinimumSize(460, 226);
    local left, top = unpack(self.settings.position or {0, 0});
    local width, height = unpack(self.settings.size or {460, 226});
    self:SetPosition(left, top);
    self:SetSize(width, height);

    left, top = 20, 36;
    local label = Turbine.UI.Label();
    label:SetParent(self);
    label:SetMultiline(true);
    label:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
    label:SetHeight(32);
    label:SetFont(Turbine.UI.Lotro.Font.TrajanPro14);
    label:SetForeColor(Turbine.UI.Color.PaleGoldenrod);
    label:SetPosition(left, top);
    self.instructions = label;
    top = top + 32;

    self.tabs = Thurallor.UI.TabCardStack();
    self.tabs:SetParent(self);
    self.tabs:SetPosition(left, top);

    self.tab1 = BarsGroupsTab(manager);
    AddCallback(self.tab1, "Click", function ()
        self.tab1:Redraw();
    end);
    self.tab2 = UserEventsTab(manager);
    AddCallback(self.tab2, "Click", function ()
        self.tab2:Redraw();
    end);
    self.tabs:AddTabCard(self.tab1);
    self.tabs:AddTabCard(self.tab2);
    
    self:Localize();
    self.tab1:BringToFront();

    self:SizeChanged(true);
    self:PositionChanged(true);
    AddCallback(Turbine.UI.Display, "SizeChanged", function()
        self:PositionChanged(true);
    end);
end

function DirectoryWindow:Localize()
    self:SetText(L:GetText("/PluginManager/OptionsTab/Directory"));
    self.instructions:SetText(L:GetText("/DirectoryWindow/Instructions"));
    self.tab1:Localize();
    self.tab2:Localize();
    self.tabs:RedistributeTabs();
end

function DirectoryWindow:SizeChanged(loading)
    local width, height = self:GetSize();
    self.settings.size = {width, height};
    if (not loading) then
        self.manager:SaveSettings(false);
    end

    self.instructions:SetWidth(width - 40);
    self.tabs:SetSize(width - 40, height - 96);
    self.tabs:RedistributeTabs();
end

function DirectoryWindow:PositionChanged(loading)
    local left, top = self:GetPosition();
    self.settings.position = {left, top};
    if (loading) then
        -- Ensure the window is on the screen, in case the plugin is loading with a smaller screen size.
        local width, height = self:GetSize();
        local right, bottom = left + width, top + height;
        local screenRight, screenBottom = Turbine.UI.Display:GetSize();
        if (screenRight < right) then
            left = math.max(0, screenRight - width);
        end
        if (screenBottom < bottom) then
            top = math.max(0, screenBottom - height);
        end
        self:SetPosition(left, top);
    else
        self.manager:SaveSettings(false);
    end
end

function DirectoryWindow:Show(whichTab)
    self:SetVisible(true);
    if (whichTab == "bars") then
        self.tab1:BringToFront();
    elseif (whichTab == "events") then
        self.tab2:BringToFront();
    end
end

function DirectoryWindow:Hide()
    self:SetVisible(false);
end

function DirectoryWindow:Redraw(updateBarDirectory, updateEventDirectory)
    if (self.tab1:IsInFront() and updateBarDirectory) then
        self.tab1:Redraw();
    elseif (self.tab2:IsInFront() and updateEventDirectory) then
        self.tab2:Redraw();
    end
end

Compare with Previous | Blame


All times are GMT -5. The time now is 08:15 AM.


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