Skip to content

Commit

Permalink
Localization and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghostopheles committed Aug 19, 2024
1 parent 2374353 commit d6e7a46
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 13 deletions.
40 changes: 38 additions & 2 deletions Rustbolt/Features/Notifications/Manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ function NotificationManager.TriggerNotification(notifType, title, text)
Registry:TriggerEvent(Events.NOTIFICATION_ADDED, notifType, title, text);
end

function NotificationManager.ClearNotifications()
Registry:TriggerEvent(Events.CLEAR_NOTIFICATIONS);
end

local function RegisterButton()
local button = {
Side = RustboltBasementMixin.Side.RIGHT,
ID = "NOTIFICATION_TRAY",
Text = "$NOTIF$",
OnClick = function() RustboltNotificationTray:Toggle(); end
};

RustboltGameWindow.Basement:AddButton(button);

RustboltNotificationTray:SetParent(RustboltGameWindow);
RustboltNotificationTray:SetPoint("BOTTOMRIGHT", -45, 45);
end

Registry:RegisterCallback(Events.ADDON_LOADED, RegisterButton);

------------

Rustbolt.NotificationManager = NotificationManager;
Expand Down Expand Up @@ -65,10 +85,14 @@ function RustboltNotificationTrayMixin:OnLoad()

Registry:RegisterCallback(Events.NOTIFICATION_ADDED, self.AddNotification, self);
Registry:RegisterCallback(Events.DISMISS_NOTIFICATION, self.DismissNotification, self);
Registry:RegisterCallback(Events.CLEAR_NOTIFICATIONS, self.ClearNotifications, self);

self:SetTitle("Notifications");
self:SetTitle(L.NOTIFICATION_TRAY_TITLE);

self.ClearButton:Raise();
self.CloseButton:SetDisabledAtlas("128-redbutton-exit-disabled");
self.CloseButton:SetNormalAtlas("128-redbutton-exit");
self.CloseButton:SetPushedAtlas("128-redbutton-exit-pressed");
self.CloseButton:SetHighlightAtlas("128-redbutton-exit-highlight");
end

function RustboltNotificationTrayMixin:OnShow()
Expand All @@ -77,13 +101,21 @@ end
function RustboltNotificationTrayMixin:OnHide()
end

function RustboltNotificationTrayMixin:OnClearButtonClicked()
Registry:TriggerEvent(Events.CLEAR_NOTIFICATIONS);
end

function RustboltNotificationTrayMixin:Reset()
self.ScrollView:Flush();

self.DataProvider = CreateDataProvider();
self.ScrollView:SetDataProvider(self.DataProvider);
end

function RustboltNotificationTrayMixin:Toggle()
self:SetShown(not self:IsShown());
end

function RustboltNotificationTrayMixin:AddNotification(notifType, title, text)
self.DataProvider:Insert({
Title = title,
Expand All @@ -97,4 +129,8 @@ function RustboltNotificationTrayMixin:DismissNotification(notifType, title, tex
return elementData.Type == notifType and elementData.Title == title and elementData.Text == text;
end);
Registry:TriggerEvent(Events.NOTIFICATION_REMOVED, notifType, title, text);
end

function RustboltNotificationTrayMixin:ClearNotifications()
self:Reset();
end
20 changes: 9 additions & 11 deletions Rustbolt/Features/Notifications/Manager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@

<Script file="Manager.lua" />

<Frame name="RustboltNotificationTrayTemplate" mixin="RustboltNotificationTrayMixin"
inherits="PortraitFrameFlatTemplate"
virtual="true">
<Frame name="RustboltNotificationTray" mixin="RustboltNotificationTrayMixin"
inherits="PortraitFrameFlatTemplate" hidden="true">
<Size x="300" y="600" />

<Frames>
<Button parentKey="ClearButton" inherits="UIButtonTemplate" frameLevel="515">
<Size x="24" y="24" />
<Anchors>
<Anchor point="RIGHT" relativeKey="$parent.CloseButton" relativePoint="LEFT"
x="-4" y="0" />
<Anchor point="RIGHT" relativeKey="$parent.CloseButton" relativePoint="LEFT" />
</Anchors>
<KeyValues>
<KeyValue key="buttonArtKit" value="128-redbutton-delete" type="string" />
</KeyValues>
<Scripts>
<OnClick>
CallMethodOnNearestAncestor(self, "OnClearButtonClicked");
</OnClick>
</Scripts>
</Button>
<Frame parentKey="ScrollBox" inherits="WowScrollBoxList" />
<EventFrame parentKey="ScrollBar" inherits="MinimalScrollBar">
Expand All @@ -34,10 +38,4 @@
</Scripts>
</Frame>

<Frame name="NotifTrayTest" inherits="RustboltNotificationTrayTemplate" parent="UIParent">
<Size x="300" y="600" />
<Anchors>
<Anchor point="CENTER" />
</Anchors>
</Frame>
</Ui>
2 changes: 2 additions & 0 deletions Rustbolt/Localization/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ L["START_SCREEN_CREDITS"] = "$Credits$";
L["CAMPAIGN_NEW_PH"] = "New Campaign";
L["CAMPAIGN_WINDOW_TITLE"] = "Playing: %s";

L["NOTIFICATION_TRAY_TITLE"] = "Notifications";

-- END LOCALIZATION

Rustbolt.Strings = AceLocale:GetLocale("Rustbolt", false);

0 comments on commit d6e7a46

Please sign in to comment.