lotrointerface.com
Search Downloads

LoTROInterface SVN Reminders

[/] [trunk/] [Thurallor/] [Reminders/] [NotificationDialog.lua] - Rev 5

Compare with Previous | Blame | View Log

NotificationDialog = class(Turbine.UI.Window);

function NotificationDialog:Constructor(event)
    Turbine.UI.Window.Constructor(self);
    self.event = event;
    self:SetVisible(true);

    -- If the event is deleted, we should close this window
    self.eventDestroyedFunc = function()
        self:Close();
    end
    -- If the window is closed, we should unregister the callback
    self.Closing = function()
        RemoveCallback(event, "Destroyed", self.eventDestroyedFunc);
        self:SetWantsUpdates(false);
    end
    -- Register the callback now, but first make sure it isn't already registered
    self.Closing();
    AddCallback(event, "Destroyed", self.eventDestroyedFunc);

    self.tooltipOverlay = Turbine.UI.Control();
    self.tooltipOverlay:SetParent(self);
    self.tooltipOverlay:SetZOrder(1);
    self.tooltipOverlay.MouseDown = function(_, args)
        self.mouseDown = true;
        self.windowMoved = false;
        self.mousePosition = { self:GetMousePosition() };
    end
    self.tooltipOverlay.MouseUp = function(_, args)
        self.mouseDown = false;
        if (not self.windowMoved) then
            self:TooltipClicked(args);
        end
    end
    self.tooltipOverlay.MouseMove = function(_, args)
        if (self.mouseDown) then
            local x, y = unpack(self.mousePosition);
            local left, top = self:GetPosition();
            self:SetPosition(left + args.X - x, top + args.Y - y);
            self.mousePosition = { self:GetMousePosition() };
            self.windowMoved = true;
        end
    end
    self.tooltipOverlay.MouseEnter = function()
        local w, h = self.tooltipOverlay:GetSize();
        self.tooltip:SetBackColor(event.tab:GetHighlightColor());
        if (not self.x_icon or not self.x_icon:IsMouseOver()) then
            self.x_icon = event.tab:ShowXIcon(self.tooltipOverlay, 1, 1, event);
        end
        if (not self.waypoint_icon or not self.waypoint_icon:IsMouseOver()) then
            self.waypoint_icon = event.tab:ShowWaypointIcon(self.tooltipOverlay, 1, h - 23, event);
        end
        if (not self.reset_icon or not self.reset_icon:IsMouseOver()) then
            self.reset_icon = event.tab:ShowResetIcon(self.tooltipOverlay, w - 23, 1, event);
        end
    end
    self.tooltipOverlay.MouseLeave = function()
        self.tooltip:SetBackColor(event.tab:GetCellColor());
        if (not self.x_icon:IsMouseOver()) then
            self.x_icon:SetParent(nil);
        end
        if (not self.waypoint_icon:IsMouseOver()) then
            self.waypoint_icon:SetParent(nil);
        end
        if (not self.reset_icon:IsMouseOver()) then
            self.reset_icon:SetParent(nil);
        end
    end
    
    if (not event.settings.position) then
        CenterWindow(self);
        event.settings.position = { self:GetPosition() };
    end
    self:SetPosition(unpack(event.settings.position));
    EnsureOnScreen(self, true);

    self.nextUpdate = 0;
    self:SetWantsUpdates(true);
end

-- Update the tooltip once every second or so
function NotificationDialog:Update()
    if (Turbine.Engine.GetGameTime() < self.nextUpdate) then
        return;
    end
    self.nextUpdate = Turbine.Engine.GetGameTime() + 1;
    local tooltip = self.event:GetToolTip();
    tooltip:SetParent(self);
    local width, height = tooltip:GetSize();
    self:SetSize(width, height);
    self.tooltipOverlay:SetSize(width, height);
    if (self.tooltip) then
        tooltip:SetBackColor(self.tooltip:GetBackColor());
        self.tooltip:SetParent(nil);
    end
    self.tooltip = tooltip;
end

function NotificationDialog:TooltipClicked(args)
    if (args.Button == Turbine.UI.MouseButton.Left) then
        self.event:ZoomToEvent(self.tooltip);
    end
end

function NotificationDialog:PositionChanged()
    self.event.settings.position = { self:GetPosition() };
    self.event:SaveSettings();
end

function NotificationDialog:Close()
    DoCallbacks(self, "Closing");
    Turbine.UI.Lotro.Window.Close(self);
end

function NotificationDialog:SizeChanged()
    if (self.marquee) then
        self.marquee:SetSize(self:GetSize());
    end
end

function NotificationDialog:SelectionGained()
    if (not self.marquee) then
        self.marquee = Thurallor.UI.Marquee();
        if (not self.event.tab.window.settings.marqueeAntsEnabled) then
            self.marquee:SetAntsEnabled(false);
        end
        local H, S, V = self.event.tab.color:GetHSV();
        local color = Thurallor.Utils.Color();
        color:SetHSV(H, S, 0.75);        
        self.marquee:SetColor(color);
        self.marquee:SetSize(self:GetSize());
        self.marquee:SetParent(self.tooltipOverlay);
    end
end

function NotificationDialog:SelectionLost()
    if (self.marquee) then
        self.marquee:SetParent(nil);
        self.marquee = nil;
    end
end

Compare with Previous | Blame


All times are GMT -5. The time now is 07:12 AM.


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