From 85deb0c2dcfbcc86084d31621d3ea9e053652e15 Mon Sep 17 00:00:00 2001 From: Arne De Herdt Date: Sat, 30 May 2026 12:35:00 +0200 Subject: [PATCH 1/3] Initial Commit --- Yipper.Api.lua | 37 ++++++++++++++++++++++++ Yipper.toc | 4 ++- src/Events.lua | 6 ++-- src/UI.lua | 2 +- src/Utils.lua | 10 +------ ui/YipperSettingsFrameTemplate.lua | 0 ui/YipperSettingsFrameTemplate.xml | 45 ++++++++++++++++++++++++++++++ 7 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 Yipper.Api.lua create mode 100644 ui/YipperSettingsFrameTemplate.lua create mode 100644 ui/YipperSettingsFrameTemplate.xml diff --git a/Yipper.Api.lua b/Yipper.Api.lua new file mode 100644 index 0000000..e53e5aa --- /dev/null +++ b/Yipper.Api.lua @@ -0,0 +1,37 @@ +--- Yipper API +-- +-- This file represents the API of Yipper and the methods exposed towards other AddOns running in the client. +-- For more documentation, please check out our wiki on the usage of the methods. +-- +local addonName, Yipper = ... + +-- Define the table for the API so that other AddOns can simply call Yipper.API when the AddOn has been +-- loaded by the client. +Yipper.API = {} + +------------------------------------------------------------------------------------------------------------------------ +-- API Definition +------------------------------------------------------------------------------------------------------------------------ + +--- Returns all messages for the specified player +---@param guid string The GUID identifying the player. +---@return table An array of messages for the player +---@return nil If the GUID is secret or the table is empty +function Yipper.API:MessagesForPlayer(guid) + if self:IsSecret(guid) then + return nil + end + + if not Yipper.DB.Messages[guid] ~= nil then + return nil + end + + return Yipper.DB.Messages[guid] +end + +--- Determines whether the provided value is considered a secret or not. +--- @param value any The value to check for being a secret. +--- @return bool True if the value is a secret; otherwise false +function Yipper.API:IsSecret(value) + return issecretvalue(value) and not canaccessvalue(value) +end diff --git a/Yipper.toc b/Yipper.toc index e52ce42..fa3b888 100644 --- a/Yipper.toc +++ b/Yipper.toc @@ -1,5 +1,5 @@ ## Interface: 120007, 120005 -## Version: 2.1.0 +## Version: 3.0.0 ## Title: Yipper ## Notes: AddOn to track chat messages from players ## Author: Keento @@ -17,6 +17,8 @@ ## Category-zhCN: 角色扮演 ## Category-zhTW: 角色扮演 +Yipper.Api.lua + src/Constants.lua src/Utils.lua src/Comms.lua diff --git a/src/Events.lua b/src/Events.lua index ee3136e..964c778 100644 --- a/src/Events.lua +++ b/src/Events.lua @@ -88,7 +88,7 @@ function Yipper.Events:OnEvent(event, ...) -- Do not attempt to process messages when they are secret. -- If we're dealing with a secret system message, just ignore it. -- Means the player is in combat, and these messages are useless for us. - if Yipper.Utils:IsSecret(message) then + if Yipper.API:IsSecret(message) then return end @@ -147,7 +147,7 @@ function Yipper.Events:StoreMessage(message, guid, lineId, event) -- Since our entire logic hinges on the guid not being a secret, -- we will drop the entire message in case the guid is flagged as secret. -- When you're in combat, you really don't care about RP anyways. - if Yipper.Utils:IsSecret(guid) then + if Yipper.API:IsSecret(guid) then return end @@ -230,7 +230,7 @@ function Yipper.Events:UpdateTrackedPlayer() -- Do not proceed if the Guid is a secret. -- In PropHunt we're able to track players, but their values are secret. -- Attempting anything will just break the AddOn. - if Yipper.Utils:IsSecret(newTrackedPlayerGuid) then + if Yipper.API:IsSecret(newTrackedPlayerGuid) then return end diff --git a/src/UI.lua b/src/UI.lua index 0308961..7a170b3 100644 --- a/src/UI.lua +++ b/src/UI.lua @@ -268,7 +268,7 @@ function Yipper.UI:UpdateDisplayedText() if Yipper.TrackedPlayerGuid == nil or -- No player tracked Yipper.DB.Messages == nil or -- new character, no messages yet initializes Yipper.DB.Messages[Yipper.TrackedPlayerGuid] == nil or -- Player has not produced messages - Yipper.Utils:IsSecret(Yipper.TrackedPlayerGuid) then -- Value is a secret, don't bother... + Yipper.API:IsSecret(Yipper.TrackedPlayerGuid) then -- Value is a secret, don't bother... return end diff --git a/src/Utils.lua b/src/Utils.lua index 4ad6fa4..f742617 100644 --- a/src/Utils.lua +++ b/src/Utils.lua @@ -7,14 +7,6 @@ local _, Yipper = ... -- Initialize the module Yipper.Utils = {} --- Yipper.Utils - IsSecret --- --- Function that returns true when the passed in data is a secret --- and not accessible for safe usage. -function Yipper.Utils:IsSecret(value) - return issecretvalue(value) and not canaccessvalue(value) -end - -- Yipper.Utils - IsUpdated -- -- Returns a boolean if Yipper has been updated. @@ -90,7 +82,7 @@ end -- TODO: Expand to include the TRP3 Profile at some point. function Yipper.Utils:ColorizeMessage(message) -- Don't bother editing the message if we can't work with it. - if self:IsSecret(message) then + if Yipper.API:IsSecret(message) then return message end diff --git a/ui/YipperSettingsFrameTemplate.lua b/ui/YipperSettingsFrameTemplate.lua new file mode 100644 index 0000000..e69de29 diff --git a/ui/YipperSettingsFrameTemplate.xml b/ui/YipperSettingsFrameTemplate.xml new file mode 100644 index 0000000..f93ad0a --- /dev/null +++ b/ui/YipperSettingsFrameTemplate.xml @@ -0,0 +1,45 @@ + +