Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Initial Commit
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/WhatHappened.iml" filepath="$PROJECT_DIR$/WhatHappened.iml" />
</modules>
</component>
</project>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
-----------------------------------------------------------------------------------------------------------------------
-- GeminiGUI
-- Formerly DaiGUI
-- @author daihenka
-- GUI Widget Creation Library for WildStar.
-----------------------------------------------------------------------------------------------------------------------
local MAJOR, MINOR = "Gemini:GUI-1.0", 3
local Lib = Apollo.GetPackage("Gemini:GUI-1.0") and Apollo.GetPackage("Gemini:GUI-1.0").tPackage or {}
if Lib and (Lib._VERSION or 0) >= MINOR then
return -- no upgrade is needed
end
local assert, tostring, error, pcall = assert, tostring, error, pcall
local getmetatable, setmetatable, rawset, rawget, pairs = getmetatable, setmetatable, rawset, rawget, pairs
local type, next = type, next
Lib._VERSION = MINOR
Lib.WidgetRegistry = Lib.WidgetRegistry or {}
Lib.WidgetVersions = Lib.WidgetVersions or {}
-- local upvalues
local WidgetRegistry = Lib.WidgetRegistry
local WidgetVersions = Lib.WidgetVersions
-- Create a widget prototype object
-- @param strType (Optional) Widget type. If not provided it will look at tOptions for
-- a WidgetType value. If no widget type is found, defaults to "Window".
-- @param tOptions Options table for the widget (see below usages)
-- @returns (table) Widget Prototype Object
--
-- @usage
-- local btnProto = GeminiGUI:Create("PushButton", {
-- AnchorCenter = { 100, 30 },
-- Text = "Push Me",
-- Events = { ButtonSignal = function() Print("You pushed me!") end },
-- })
-- local wndBtn = btnProto:GetInstance()
--
-- @usage #2
-- local myEventHandler = { OnClick = function() Print("You pushed me!") end }
--
-- local btnProto = GeminiGUI:Create({
-- WidgetType = "PushButton",
-- AnchorCenter = { 100, 30 },
-- Text = "Push Me",
-- Events = { ButtonSignal = "OnClick" },
-- })
-- local wndBtn = btnProto:GetInstance(myEventHandler)
function Lib:Create(strType, tOptions)
-- check if passed a function to generate the tOptions
if type(strType) == "function" then
tOptions = strType()
strType = tOptions.WidgetType or "Window"
elseif type(strType) == "string" and type(tOptions) == "function" then
tOptions = tOptions()
strType = strType or tOptions.WidgetType or "Window"
-- check if passed a table without a strType
elseif type(strType) == "table" then
tOptions = strType
strType = tOptions.WidgetType or "Window"
end
if type(strType) ~= "string" then
error(("Usage: Create([strType,] tOptions): 'strType' - string expected got '%s'."):format(type(strType)), 2)
end
if type(tOptions) ~= "table" then
error(("Usage: Create([strType,] tOptions): 'tOptions' - table expected got '%s'."):format(type(tOptions)), 2)
end
-- check if tOptions is already a widget prototype
if tOptions.__IsGeminiGuiPrototype == true then
return tOptions
end
strType = strType or "Window"
-- if not, check if the widget type is valid
if WidgetRegistry[strType] then
-- create the widget
local widget = WidgetRegistry[strType]()
widget.WidgetVersion = WidgetVersions[strType]
if tOptions ~= nil and type(tOptions) == "table" then
widget:SetOptions(tOptions)
end
widget.__IsGeminiGuiPrototype = true
return widget
end
end
-- Register a widget constructor that will return a new prototype of the widget
-- @param strType Name of the widget
-- @param fnConstructor Widget constructor function
-- @param nVersion Version of the widget
function Lib:RegisterWidgetType(strType, fnConstructor, nVersion)
assert(type(fnConstructor) == "function")
assert(type(nVersion) == "number")
local oldVersion = WidgetVersions[strType]
if oldVersion and oldVersion >= nVersion then return end
WidgetVersions[strType] = nVersion
WidgetRegistry[strType] = fnConstructor
end
-- Return the version of the currently registered widget type
-- @param strType Name of the widget
-- @returns (number) Version of the widget
function Lib:GetWidgetVersion(strType)
return WidgetVersions[strType]
end
function Lib:OnLoad()
end
function Lib:OnDependencyError(strDep, strError)
return false
end
Apollo.RegisterPackage(Lib, MAJOR, MINOR, {})
--[[ Widgets ]]--
local GeminiGUI = Lib
--[[ File: widgets/ControlBase.lua ]]--
do
GeminiGUI.ControlBase = {}
local Control = GeminiGUI.ControlBase
local kstrDefaultName = "GeminiGUIControl"
local pairs, ipairs, type, unpack, error = pairs, ipairs, type, unpack, error
local setmetatable, tostring = setmetatable, tostring
local ktAnchorPoints = {
TOPLEFT = { 0, 0, 0, 0 },
TOPRIGHT = { 1, 0, 1, 0 },
BOTTOMLEFT = { 0, 1, 0, 1 },
BOTTOMRIGHT = { 1, 1, 1, 1 },
CENTER = { 0.5, 0.5, 0.5, 0.5 },
VCENTER = { 0, 0.5, 0, 0.5 },
HCENTER = { 0.5, 0, 0.5, 0 },
VCENTERRIGHT = { 1, 0.5, 1, 0.5 },
HCENTERBOTTOM = { 0.5, 1, 0.5, 1 },
FILL = { 0, 0, 1, 1 },
HFILL = { 0, 0, 1, 0 },
VFILL = { 0, 0, 0, 1 },
VFILLRIGHT = { 1, 0, 1, 1 },
HFILLBOTTOM = { 0, 1, 1, 1 },
}
local function TranslateAnchorPoint(s, tOptions, v)
if type(v) == "string" then
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(ktAnchorPoints[v])
elseif type(v) == "table" then
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(v)
end
end
local function SetupWhiteFillMe(self, tOptions, v)
if v ~= true then return end
tOptions.Picture = true
tOptions.Sprite = "ClientSprites:WhiteFill"
tOptions.BGColor = "white"
end
local kSpecialFields = {
AnchorOffsets = function(s, tOptions, v)
tOptions.LAnchorOffset, tOptions.TAnchorOffset, tOptions.RAnchorOffset, tOptions.BAnchorOffset = unpack(v)
end,
AnchorPoints = TranslateAnchorPoint,
Anchor = TranslateAnchorPoint,
IncludeEdgeAnchors = function(s, tOptions, v)
if type(v) ~= "string" and (s.options.Name == nil or string.len(s.options.Name) == 0) then
error("IncludeEdgeAnchors requires a string or the control name to be set", 2)
end
local strPrefix = ((type(v) == "string") and v or s.options.Name)
tOptions.LeftEdgeControlsAnchor, tOptions.TopEdgeControlsAnchor, tOptions.RightEdgeControlsAnchor, tOptions.BottomEdgeControlsAnchor = strPrefix .. "_Left", strPrefix .. "_Top", strPrefix .. "_Right", strPrefix .. "_Bottom"
end,
AnchorCenter = function(s, tOptions, v)
if type(v) ~= "table" or #v ~= 2 then return end
local nWidth, nHeight = unpack(v)
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(ktAnchorPoints["CENTER"])
tOptions.LAnchorOffset, tOptions.TAnchorOffset, tOptions.RAnchorOffset, tOptions.BAnchorOffset = nWidth / 2 * -1, nHeight / 2 * -1, nWidth / 2, nHeight / 2
end,
AnchorFill = function(s, tOptions, v)
local nPadding = (type(v) == "number") and v or 0
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(ktAnchorPoints["FILL"])
tOptions.LAnchorOffset, tOptions.TAnchorOffset, tOptions.RAnchorOffset, tOptions.BAnchorOffset = nPadding, nPadding, -nPadding, -nPadding
end,
PosSize = function(s, tOptions, v)
if type(v) ~= "table" or #v ~= 4 then return end
local nLeft, nTop, nWidth, nHeight = unpack(v)
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(ktAnchorPoints["TOPLEFT"])
tOptions.LAnchorOffset, tOptions.TAnchorOffset, tOptions.RAnchorOffset, tOptions.BAnchorOffset = nLeft, nTop, nLeft + nWidth, nTop + nHeight
end,
UserData = function(s, tOptions, v)
s:SetData(v)
end,
LuaData = function(s, tOptions, v)
s:SetData(v)
end,
Events = function(s, tOptions, v)
if type(v) == "table" then
for strEventName, oHandler in pairs(v) do
if type(strEventName) == "number" and type(oHandler) == "table" then -- handle the old style
s:AddEvent(unpack(oHandler))
elseif type(strEventName) == "string" and (type(oHandler) == "string" or type(oHandler) == "function") then
s:AddEvent(strEventName, oHandler)
end
end
end
end,
Pixies = function(s, tOptions, v)
if type(v) == "table" then
for _, tPixie in ipairs(v) do
s:AddPixie(tPixie)
end
end
end,
Children = function(s, tOptions, v)
if type(v) == "table" then
for _, tChild in ipairs(v) do
local strWidgetType = "Window"
if type(tChild.WidgetType) == "string" then
strWidgetType = tChild.WidgetType
end
s:AddChild(GeminiGUI:Create(strWidgetType, tChild))
end
end
end,
}
function Control:new(o)
o = o or {}
o.events = {}
o.children = {}
o.pixies = {}
o.options = {}
setmetatable(o, self)
self.__index = self
return o
end
-- Set an option on the widget prototype
-- @param strOptionName the option name
-- @param value the value to set
function Control:SetOption(key, value)
self.options[key] = value
end
-- Set multiple options on the widget prototype
-- @param tOptions the options table
function Control:SetOptions(tOptions)
for k,v in pairs(tOptions) do
self.options[k] = v
end
end
-- pixie mapping table
local ktPixieMapping = {
strText = "Text",
strFont = "Font",
bLine = "Line",
fWidth = "Width",
strSprite = "Sprite",
cr = "BGColor",
crText = "TextColor",
fRotation = "Rotation",
strTextId = "TextId",
nTextId = "TextId",
loc = { fPoints = "AnchorPoints", nOffsets = "AnchorOffsets" },
flagsText = { DT_CENTER = "DT_CENTER", DT_VCENTER = "DT_VCENTER", DT_RIGHT = "DT_RIGHT", DT_BOTTOM = "DT_BOTTOM",
DT_WORDBREAK = "DT_WORDBREAK", DT_SINGLELINE = "DT_SINGLELINE" },
}
-- Add a pixie to the widget prototype
-- @param tPixie a table with pixie options
function Control:AddPixie(tPixie)
if tPixie == nil then return end
-- in case someone uses the C++ Window:AddPixie() format. Preference to the XML format over the C++ Window:AddPixie() format.
for oldKey, newKey in pairs(ktPixieMapping) do
if tPixie[oldKey] ~= nil then
if type(tPixie[oldKey]) == "table" then
for oldKey2, newKey2 in pairs(tPixie[oldKey]) do
if tPixie[oldKey][oldKey2] ~= nil then
tPixie[newKey2] = tPixie[newKey2] or tPixie[oldKey][oldKey2]
end
end
else
tPixie[newKey] = tPixie[newKey] or tPixie[oldKey]
end
end
end
if type(tPixie.AnchorOffsets) == "table" then
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = unpack(tPixie.AnchorOffsets)
tPixie.AnchorOffsets = nil
end
if tPixie.AnchorPoints ~= nil or tPixie.Anchor ~= nil then
local tAnchorPoints = tPixie.AnchorPoints or tPixie.Anchor
if type(tAnchorPoints) == "string" then
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(ktAnchorPoints[tAnchorPoints])
else
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(tAnchorPoints)
end
tPixie.AnchorPoints = nil
tPixie.Anchor = nil
end
if tPixie.AnchorFill ~= nil then
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(ktAnchorPoints["FILL"])
if type(self.options.AnchorFill) == "number" then
local nPadding = tPixie.AnchorFill
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = nPadding, nPadding, -nPadding, -nPadding
elseif type(self.options.AnchorFill) == "boolean" then
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = 0,0,0,0
end
tPixie.AnchorFill = nil
end
if type(tPixie.AnchorCenter) == "table" then
local nWidth, nHeight = unpack(tPixie.AnchorCenter)
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(ktAnchorPoints["CENTER"])
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = nWidth / 2 * -1, nHeight / 2 * -1, nWidth / 2, nHeight / 2
tPixie.AnchorCenter = nil
end
if type(tPixie.PosSize) == "table" then
local nLeft, nTop, nWidth, nHeight = unpack(tPixie.PosSize)
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(ktAnchorPoints["TOPLEFT"])
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = nLeft, nTop, nLeft + nWidth, nTop + nHeight
tPixie.PosSize = nil
end
tPixie.LAnchorOffset = tPixie.LAnchorOffset or 0
tPixie.RAnchorOffset = tPixie.RAnchorOffset or 0
tPixie.TAnchorOffset = tPixie.TAnchorOffset or 0
tPixie.BAnchorOffset = tPixie.BAnchorOffset or 0
tPixie.LAnchorPoint = tPixie.LAnchorPoint or 0
tPixie.RAnchorPoint = tPixie.RAnchorPoint or 0
tPixie.TAnchorPoint = tPixie.TAnchorPoint or 0
tPixie.BAnchorPoint = tPixie.BAnchorPoint or 0
-- ensure that pixie booleans are properly converted to 1/0
for k,v in pairs(tPixie) do
if type(v) == "boolean" then
tPixie[k] = v and "1" or "0"
end
end
table.insert(self.pixies, tPixie)
end
-- Add a child widget prototype to the widget prototype
-- @param tChild The child widget to add -- NOTE: Must be a GeminiGUI:Create() blessed prototype
function Control:AddChild(tChild)
if tChild == nil then return end
table.insert(self.children, tChild)
end
-- Add an event handler to the widget prototype
-- @param strName The event name to be handled
-- @param strFunction (Optional) The function name on the event handler table
-- @param fnInline (Optional) The anonymous function to handle the event
--
-- @usage myPrototype:AddEvent("ButtonSignal", "OnButtonClick") -- when the event is fired, it will call OnButtonClick on the event handler table
-- @usage myPrototype:AddEvent("ButtonSignal", function() Print("Clicked!") end) -- when the event is fired, the anonymous function will be called
function Control:AddEvent(strName, strFunction, fnInline)
if type(strFunction) == "function" then
fnInline = strFunction
strFunction = "On" .. strName .. tostring(fnInline):gsub("function: ", "_")
end
table.insert(self.events, {strName = strName, strFunction = strFunction, fnInline = fnInline })
end
-- Set the data the widget is to store
-- @param oData the lua data object
function Control:SetData(oData)
self.oData = oData
end
-- Parses the options table for the widget
-- Internal use only
function Control:ParseOptions()
local tOptions = {}
for k, fn in pairs(kSpecialFields) do
if self.options[k] ~= nil then
fn(self, tOptions, self.options[k])
end
end
for k,v in pairs(self.options) do
if not kSpecialFields[k] or k == "WhiteFillMe" then
tOptions[k] = v
end
end
SetupWhiteFillMe(self, tOptions, self.options.WhiteFillMe) -- for debug purposes ;)
-- if picture hasn't been set but a sprite has been, enable picture
if tOptions.Sprite ~= nil and tOptions.Picture == nil then
tOptions.Picture = true
end
for k,v in pairs(tOptions) do
if type(v) == "boolean" then
tOptions[k] = v and "1" or "0"
end
end
return tOptions
end
-- Creates an XmlDoc Table of the widget prototype
function Control:ToXmlDocTable(bIsForm)
local tInlineFunctions = {}
local tForm = self:ParseOptions()
-- setup defaults and necessary values
tForm.__XmlNode = bIsForm and "Form" or "Control"
tForm.Font = tForm.Font or "Default"
tForm.Template = tForm.Template or "Default"
tForm.TooltipType = tForm.TooltipType or "OnCursor"
if not tForm.PosX or not tForm.PosY or not tForm.Height or not tForm.Width then
tForm.TAnchorOffset = tForm.TAnchorOffset or 0
tForm.LAnchorOffset = tForm.LAnchorOffset or 0
tForm.BAnchorOffset = tForm.BAnchorOffset or 0
tForm.RAnchorOffset = tForm.RAnchorOffset or 0
tForm.BAnchorPoint = tForm.BAnchorPoint or 0
tForm.RAnchorPoint = tForm.RAnchorPoint or 0
tForm.TAnchorPoint = tForm.TAnchorPoint or 0
tForm.LAnchorPoint = tForm.LAnchorPoint or 0
end
if self.AddSubclassFields ~= nil and type(self.AddSubclassFields) == "function" then
self:AddSubclassFields(tForm)
end
tForm.Name = tForm.Name or kstrDefaultName
tForm.Class = tForm.Class or "Window"
local tAliasEvents = {}
local tInlineLookup = {}
for _, tEvent in ipairs(self.events) do
if tEvent.strName and tEvent.strFunction and tEvent.strName ~= "" then
if tEvent.strFunction:match("^Event::") then
table.insert(tAliasEvents, tEvent)
elseif tEvent.strFunction ~= "" then
table.insert(tForm, { __XmlNode = "Event", Function = tEvent.strFunction, Name = tEvent.strName })
if tEvent.fnInline ~= nil then
tInlineLookup[tEvent.strName] = tEvent.strFunction
tInlineFunctions[tEvent.strFunction] = tEvent.fnInline
end
end
end
end
-- check if an event would like to reference an another event handler's inline function
for _, tEvent in ipairs(tAliasEvents) do
local strFunctionName = tInlineLookup[tEvent.strFunction:gsub("^Event::", "")]
if strFunctionName then
table.insert(tForm, { __XmlNode = "Event", Function = strFunctionName, Name = tEvent.strName })
end
end
for _, tPixie in ipairs(self.pixies) do
local tPixieNode = { __XmlNode = "Pixie", }
for k,v in pairs(tPixie) do
tPixieNode[k] = v
end
table.insert(tForm, tPixieNode)
end
for _, tChild in ipairs(self.children) do
if tChild.ToXmlDocTable and type(tChild.ToXmlDocTable) == "function" then
local tXd, tIf = tChild:ToXmlDocTable()
table.insert(tForm, tXd)
for k,v in pairs(tIf) do
tInlineFunctions[k] = tInlineFunctions[k] or v
end
end
end
if self.oData ~= nil then
tForm.__GEMINIGUI_LUADATA = self.oData
end
if bIsForm then
tForm = { __XmlNode = "Forms", tForm }
end
return tForm, tInlineFunctions
end
-- Collect window name, data and text from the XmlDoc table (recursively)
-- and give each window a unique name for it's layer
local kstrTempName = "GeminiGUIWindow."
local function CollectNameData(tXml, tData, strNamespace)
if type(tXml) ~= "table" then return end
local nCount = 0
tData = tData or {}
strNamespace = strNamespace or ""
for i, t in ipairs(tXml) do
if t.__XmlNode == "Control" then -- only process controls (aka children)
local strName = t.Name
local strNS = string.format("%s%s%s", strNamespace, strNamespace:len() > 0 and ":" or "", strName)
while (strName or "") == "" or tData[strNS] ~= nil do
-- window name already exists at this child depth, rename it temporarily
nCount = nCount + 1
strName = "GeminiGUIWindow." .. nCount
strNS = string.format("%s%s%s", strNamespace, strNamespace:len() > 0 and ":" or "", strName)
end
local strFinalName = t.Name or strName
-- collect the info for the window/control
tData[strNS] = { strNS = strNS, strName = strName, strFinalName = strFinalName, luaData = t.__GEMINIGUI_LUADATA, strText = t.Text, bIsMLWindow = t.Class == "MLWindow" }
-- rename the window to the unique layered name
t.Name = strName
-- clean up XmlDoc table by removing unnecessary elements
t.__GEMINIGUI_LUADATA = nil
CollectNameData(t, tData, strNS)
elseif t.__XmlNode == "Form" or t.__XmlNode == "Forms" then
CollectNameData(t, tData, "")
end
end
return tData
end
-- Process each window and it's children and assign data, AML
-- and rename the window back to what the consumer wants.
local function FinalizeWindow(wnd, tData)
-- collect a list of keys and sort them in order
-- of how deep they are overall (# of :) (>^o^)>
local tChildOrder = {}
for strNS, _ in pairs(tData) do
local _, nCount = strNS:gsub(":", "")
table.insert(tChildOrder, { strNS, nCount })
end
table.sort(tChildOrder, function(a,b) return a[2] > b[2] end)
-- process child windows in depth order, setting their data, AML and
-- renaming them back to what they are intended to be
for i = 1, #tChildOrder do
local tWndData = tData[tChildOrder[i][1]]
local wndChild = wnd:FindChild(tWndData.strNS)
if wndChild then
if tWndData.luaData then
wndChild:SetData(tWndData.luaData)
end
if tWndData.bIsMLWindow and tWndData.strText then
wndChild:SetAML(tWndData.strText)
end
if tWndData.strFinalName ~= tWndData.strName then
wndChild:SetName(tWndData.strFinalName)
end
end
end
end
-- Gets an instance of the widget
-- @param eventHandler The eventHandler of the widget
-- @param wndParent The parent of the widget
-- @returns (userdata) The userdata version of the widget
function Control:GetInstance(eventHandler, wndParent)
eventHandler = eventHandler or {}
if type(eventHandler) ~= "table" then
error("Usage: EventHandler is not valid. Must be a table.")
end
local xdt, tInlines = self:ToXmlDocTable(true)
for k,v in pairs(tInlines) do
eventHandler[k] = eventHandler[k] or v
end
-- collect names and reassign them to something generic
-- collect any lua data and if AML needs to be set
local tChildData = CollectNameData(xdt)
-- create the XmlDoc and C++ window
local xd = XmlDoc.CreateFromTable(xdt)
local strFormName = self.options.Name or kstrDefaultName
local wnd = Apollo.LoadForm(xd, strFormName, wndParent, eventHandler)
if wnd then
-- set the lua data and aml followed by name for all child widgets
FinalizeWindow(wnd, tChildData)
if self.oData then
wnd:SetData(self.oData)
end
else
-- Print("GeminiGUI failed to create window")
end
return wnd
end
end
--[[ File: widgets/Window.lua ]]--
do
local WidgetType, Version = "Window", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
Template = "Default",
TooltipType = "OnCursor",
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/Button.lua ]]--
do
local WidgetType, Version = "Button", 1
local Button = GeminiGUI.ControlBase:new()
local function GetTextTheme(strTheme)
return {
NormalTextColor = strTheme .. "Normal",
PressedTextColor = strTheme .. "Pressed",
PressedFlybyTextColor = strTheme .. "PressedFlyby",
FlybyTextColor = strTheme .. "Flyby",
DisabledTextColor = strTheme .. "Disabled"
}
end
local function GetTextColorTheme(strColor)
return {
NormalTextColor = strColor,
PressedTextColor = strColor,
PressedFlybyTextColor = strColor,
FlybyTextColor = strColor,
DisabledTextColor = strColor
}
end
function Button:SetTextThemeToColor(strColor)
self:SetOptions(GetTextColorTheme(strColor))
end
function Button:SetTextTheme(strTheme)
self:SetOptions(GetTextTheme(strTheme))
end
function Button:AddSubclassFields(tForm)
if self.options.TextThemeColor ~= nil then
local tTheme = GetTextColorTheme(self.options.TextThemeColor)
for k,v in pairs(tTheme) do
tForm[k] = v
end
if tForm.TextThemeColor ~= nil then
tForm.TextThemeColor = nil
end
end
if self.options.TextTheme ~= nil then
local tTheme = GetTextTheme(self.options.TextTheme)
for k,v in pairs(tTheme) do
tForm[k] = v
end
if tForm.TextTheme ~= nil then
tForm.TextTheme = nil
end
end
end
local function Constructor()
local ctrl = Button:new()
ctrl:SetOptions{
Name = "GeminiGUI" .. WidgetType,
Class = WidgetType,
ButtonType = "PushButton",
RadioGroup = "",
Font = "Thick",
DT_VCENTER = true,
DT_CENTER = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/PushButton.lua ]]--
do
local WidgetType, Version = "PushButton", 1
local function Constructor()
local btn = GeminiGUI:Create('Button', {
Name = "GeminiGUI" .. WidgetType,
ButtonType = "PushButton",
DT_VCENTER = true,
DT_CENTER = true,
Base = "CRB_Basekit:kitBtn_Holo",
Font = "CRB_InterfaceMedium",
})
btn:SetTextTheme("UI_BtnTextHolo")
return btn
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/Buzzer.lua ]]--
do
local WidgetType, Version = "Buzzer", 1
local function Constructor()
local btn = GeminiGUI:Create('Button', {
Name = "GeminiGUI" .. WidgetType,
ButtonType = "Buzzer",
DT_VCENTER = true,
DT_CENTER = true,
Base = "CRB_Basekit:kitBtn_Holo",
Font = "CRB_InterfaceMedium",
BuzzerFrequency = 15,
})
btn:SetTextTheme("UI_BtnTextHolo")
return btn
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/CheckBox.lua ]]--
do
local WidgetType, Version = "CheckBox", 1
local function Constructor()
local checkbox = GeminiGUI:Create('Button', {
Name = "GeminiGUI" .. WidgetType,
DrawAsCheckbox = true,
DT_CENTER = false,
DT_VCENTER = true,
ButtonType = "Check",
Font = "CRB_InterfaceMedium",
Base = "CRB_Basekit:kitBtn_Holo_RadioRound",
TextColor = "White",
})
return checkbox
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ActionBarButton.lua ]]--
do
local WidgetType, Version = "ActionBarButton", 1
local function Constructor()
local btn = GeminiGUI.ControlBase:new()
btn:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Base = "ClientSprites:Button_ActionBarBlank",
RelativeToClient = true,
IfHoldNoSignal = true,
DT_VCENTER = true,
DT_CENTER = true,
NeverBringToFront = true,
WindowSoundTemplate = "ActionBarButton",
ProcessRightClick = true,
Font = "CRB_InterfaceLarge_O",
IgnoreTooltipDelay = true,
RechargeBarLAnchorPoint = 1,
RechargeBarLAnchorOffset = -8,
RechargeBarTAnchorPoint = 0,
RechargeBarTAnchorOffset = 4,
RechargeBarRAnchorPoint = 1,
RechargeBarRAnchorOffset = 4,
RechargeBarBAnchorPoint = 1,
RechargeBarBAnchorOffset = -14,
RechargeBarEmptyColorAttribute = "Black",
RechargeBarFullColorAttribute = "ffffffff",
RechargeBarEmptyAttribute = "WhiteFill",
RechargeBarFullAttribute = "sprStalker_VerticalGooPulse",
TooltipType = "DynamicFloater",
ShortHotkeyFontAttribute = "CRB_InterfaceLarge_BO",
LongHotkeyFontAttribute = "CRB_InterfaceSmall_O",
CountFontAttribute = "CRB_InterfaceSmall_O",
CooldownFontAttribute = "CRB_HeaderLarge",
}
return btn
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/TreeControl.lua ]]--
do
local WidgetType, Version = "TreeControl", 1
local function Constructor()
local wnd = GeminiGUI.ControlBase:new()
wnd:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_Pixel",
Template = "CRB_Hologram",
UseTemplateBG = true,
Picture = true,
Border = true,
RelativeToClient = true,
}
return wnd
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ComboBox.lua ]]--
do
local WidgetType, Version = "ComboBox", 1
local ComboBox = GeminiGUI.ControlBase:new()
function ComboBox:AddSubclassFields(tForm)
if self.options.UseTheme == true then
-- if windowload is set, it will respect that
-- apply the theme then call the windowload set
-- by the consumer. Otherwise it will setup
-- its own windowload event
-- todo: probably needs a refactor
local windowLoadEvent
for k,v in pairs(self.events) do
if v.strName == "WindowLoad" then
windowLoadEvent = v
break
end
end
if windowLoadEvent ~= nil then
local strFont = self.options.Font or "CRB_InterfaceMedium"
local strBtnBase = self.options.DropdownBtnBase or "Collections_TEMP:sprCollections_TEMP_RightAlignDropdown"
local nBtnWidth = self.options.DropdownBtnWidth
local fOldWindowLoad = windowLoadEvent.fnInline
local strOldWindowLoad = windowLoadEvent.strFunction
if windowLoadEvent.fnInline == nil then
fOldWindowLoad = windowLoadEvent.strFunction
end
local fNewWindowLoad = function(self, wndHandler, wndControl)
if wndHandler == wndControl then
local cbBtnSkin = GeminiGUI:Create({ Class="Button", Base=strBtnBase }):GetInstance()
if nBtnWidth then
wndControl:GetButton():SetAnchorOffsets(-nBtnWidth,0,0,0)
end
wndControl:GetButton():ChangeArt(cbBtnSkin)
wndControl:GetGrid():SetStyle("AutoHideScroll", true)
wndControl:GetGrid():SetStyle("TransitionShowHide", true)
wndControl:GetGrid():SetFont(strFont)
end
if type(fOldWindowLoad) == "function" then
fOldWindowLoad(self, wndHandler, wndControl)
elseif type(fOldWindowLoad) == "string" and type(self[fOldWindowLoad]) == "function" then
self[fOldWindowLoad](self, wndHandler, wndControl)
end
end
windowLoadEvent.fnInline = fNewWindowLoad
windowLoadEvent.strFunction = "OnWindowLoad_" .. tostring(windowLoadEvent.fnInline):gsub("function: ", "_")
end
if tForm.UseTheme ~= nil then
tForm.UseTheme = nil
end
end
end
local function Constructor()
local cbo = ComboBox:new()
cbo:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_InterfaceMedium",
DT_VCENTER = true,
RelativeToClient = true,
Overlapped = true,
AutoSize = true,
Template = "HologramControl2",
UseTemplateBG = true,
Picture = true,
Border = true,
UseTheme = true,
-- DropdownBtnBase = "CRB_Basekit:kitBtn_ScrollHolo_DownLarge",
-- DropdownBtnWidth = 20,
}
return cbo
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/Slider.lua ]]--
do
local WidgetType, Version = "SliderBar", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Template = "CRB_Scroll_HoloLarge",
Middle = "CRB_Basekit:kitScrollbase_Horiz_Holo",
UseButtons = true,
Min = 1,
Max = 100,
TickAmount = 1,
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ProgressBar.lua ]]--
do
local WidgetType, Version = "ProgressBar", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
ProgressEmpty = "BlackFill",
ProgressFull = "CRB_Raid:sprRaid_ShieldProgBar",
UseTemplateBG = true,
Template = "CRB_Hologram",
Border = true,
Picture = true,
BarColor = "white",
Font = "CRB_InterfaceMedium_BO",
UseValues = true,
RelativeToClient = true,
SetTextToProgress = true,
DT_CENTER = true,
DT_VCENTER = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/EditBox.lua ]]--
do
local WidgetType, Version = "EditBox", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
TabStop = true,
Font = "CRB_InterfaceMedium",
RelativeToClient = true,
DT_VCENTER = true,
Template = "HologramControl2",
UseTemplateBG = true,
Border = true,
Picture = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/Grid.lua ]]--
do
local WidgetType, Version = "Grid", 1
local Grid = GeminiGUI.ControlBase:new()
function Grid:AddColumn(tColumn)
self.columns = self.columns or {}
tColumn.TextColor = tColumn.TextColor or "White"
if tColumn.SimpleSort == nil then
tColumn.SimpleSort = true
end
table.insert(self.columns, tColumn)
end
function Grid:AddSubclassFields(tForm)
if self.options.Columns ~= nil then
for i = 1, #self.options.Columns do
self:AddColumn(self.options.Columns[i])
end
if tForm.Columns ~= nil then
tForm.Columns = nil
end
end
if self.columns ~= nil then
for i = #self.columns, 1, -1 do
local tColumn = self.columns[i]
local tNode = { __XmlNode = "Column", }
for k,v in pairs(tColumn) do
tNode[k] = v
end
table.insert(tForm, tNode)
end
end
end
local function Constructor()
local ctrl = Grid:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
IgnoreMouse = true,
Template = "CRB_Hologram",
UseTemplateBG = true,
Picture = true,
Border = true,
HeaderFont = "CRB_Pixel",
HeaderBG = "CRB_Basekit:kitBtn_List_HoloDisabled",
HeaderHeight = 26,
Font = "CRB_Pixel",
CellBGBase = "CRB_Basekit:kitBtn_List_HoloNormal",
RowHeight = 26,
MultiColumn = true,
FocusOnMouseOver = true,
SelectWholeRow = true,
RelativeToClient = true,
VariableHeight = true,
HeaderRow = true,
TextNormalColor = "white",
TextSelectedColor = "ff31fcf6",
TextNormalFocusColor = "white",
TextSelectedFocusColor = "ff31fcf6",
TextDisabledColor = "9d666666",
DT_VCENTER = true,
VScroll = true,
AutoHideScroll = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/MLWindow.lua ]]--
do
local WidgetType, Version = "MLWindow", 1
local function Constructor()
local ctrl = GeminiGUI:Create("Window", {
Class = "MLWindow",
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_InterfaceSmall",
})
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/TabWindow.lua ]]--
do
local WidgetType, Version = "TabWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Template = "CRB_ChatWindow",
Font = "CRB_InterfaceMedium",
Moveable = true,
Border = true,
AutoFadeNC = true,
AudoFadeBG = true,
Picture = true,
Sizable = true,
Overlapped = true,
DT_CENTER = true,
DT_VCENTER = true,
UseTemplateBG = true,
RelativeToClient = true,
TabTextMarginLeft = 10,
TabTextMarginRight = 10,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/AbilityItemWindow.lua ]]--
do
local WidgetType, Version = "AbilityItemWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
IgnoreTooltipDelay = true,
RelativeToClient = true,
DT_CENTER = true,
DT_VCENTER = true,
ListItem = true,
IgnoreMouse = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ActionConfirmButton.lua ]]--
do
local WidgetType, Version = "ActionConfirmButton", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "Default",
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/BagWindow.lua ]]--
do
local WidgetType, Version = "BagWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
SwallowMouseClicks = true,
IgnoreTooltipDelay = true,
Sprite = "CRB_UIKitSprites:spr_baseframe",
Template = "CRB_Normal",
NoClip = true,
UseTemplateBG = true,
NewQuestOverlaySprite = "ClientSprites:sprItem_NewQuest",
SquareSize = 50,
BoxesPerRow = 5,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/BuffWindow.lua ]]--
do
local WidgetType, Version = "BuffWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
NoClip = true,
HarmfulBuffs = true,
BuffIndex = 1,
IgnoreTooltipDelay = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/BuffContainerWindow.lua ]]--
do
local WidgetType, Version = "BuffContainerWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/CashWindow.lua ]]--
do
local WidgetType, Version = "CashWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_InterfaceSmall",
DT_RIGHT = true,
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/CharacterFrame.lua ]]--
do
local WidgetType, Version = "CharacterFrame", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Overlapped = true,
TestAlpha = true,
TransitionShowHide = true,
SwallowMouseClicks = true,
Font = "Default",
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/CostumeWindow.lua ]]--
do
local WidgetType, Version = "CostumeWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
Camera = "Paperdoll",
Animated = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/IconButton.lua ]]--
do
local WidgetType, Version = "IconButton", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
NoClip = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ItemSlotWindow.lua ]]--
do
local WidgetType, Version = "ItemSlotWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
WhenEmpty = "btn_Armor_HeadNormal",
EquipmentSlot = 2,
IgnoreTooltipDelay = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/LootWindow.lua ]]--
do
local WidgetType, Version = "LootWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_InterfaceMedium",
SwallowMouseClicks = true,
IgnoreTooltipDelay = true,
Sprite = "CRB_UIKitSprites:spr_baseframe",
Template = "CRB_Normal",
NoClip = true,
UseTemplateBG = true,
NewQuestOverlaySprite = "ClientSprites:sprItem_NewQuest",
SquareSize = 50,
BoxesPerRow = 3,
NewControlDepth = 1,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/MannequinSlotWindow.lua ]]--
do
local WidgetType, Version = "MannequinSlotWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
WhenEmpty = "btn_Armor_HeadNormal",
EquipmentSlot = 2,
IgnoreTooltipDelay = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/MiniMapWindow.lua ]]--
do
local WidgetType, Version = "MiniMapWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
Template = "Default",
NewControlDepth = 2,
Mask = [[ui\textures\UI_CRB_HUD_MiniMap_Mask.tex]],
CircularItems = true,
ItemRadius = 0.7,
IgnoreMouse = true,
MapOrientation = 0,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ProtostarMapWindow.lua ]]--
do
local WidgetType, Version = "ProtostarMapWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Template = "CRB_Normal",
NewControlDepth = 1,
SwallowMouseClicks = true,
IgnoreTooltipDelay = true,
NoClip = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/SendEmailButton.lua ]]--
do
local WidgetType, Version = "SendEmailButton", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/TradeCommitButton.lua ]]--
do
local WidgetType, Version = "TradeCommitButton", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/WorldFixedWindow.lua ]]--
do
local WidgetType, Version = "WorldFixedWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
Template = "Default",
SwallowMouseClicks = true,
Overlapped = true,
IgnoreMouse = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ZoneMapWindow.lua ]]--
do
local WidgetType, Version = "ZoneMapWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Template = "CRB_HologramFramedThick",
UseTemplateBG = true,
IgnoreTooltipDelay = true,
DrawObjectsOnContinent = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
<?xml version="1.1.3" encoding="UTF-8"?>
<Addon Author="Arthmael" APIVersion="8" Name="WhatHappened" Description="">
<Script Name="WhatHappened.lua"/>
<Script File="GeminiGUI.lua"/>
<Form Name="WhatHappened.xml"/>
</Addon>
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
-----------------------------------------------------------------------------------------------
-- Client Lua Script for WTF
-- Copyright (c) NCsoft. All rights reserved
-----------------------------------------------------------------------------------------------
require "Window"
require "ChatSystemLib"
-----------------------------------------------------------------------------------------------
-- WTF Module Definition
-----------------------------------------------------------------------------------------------
local WhatHappened = {}
local tSave = {}
local tMyParty = {}
local ICChannel
local tCombatHistory = {first = 0, last = -1}
local strChatAddon
local PushCount = 0
local Push, Pop
local PartyType = ""
-----------------------------------------------------------------------------------------------
-- Constants
-----------------------------------------------------------------------------------------------
-- e.g. local kiExampleVariableMax = 999
-----------------------------------------------------------------------------------------------
-- Initialization
-----------------------------------------------------------------------------------------------
function WhatHappened:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
-- initialize variables here
return o
end
function WhatHappened:Init()
local bHasConfigureFunction = false
local strConfigureButtonText = ""
local tDependencies = {
-- "UnitOrPackageName",
}
Apollo.RegisterAddon(self, bHasConfigureFunction, strConfigureButtonText, tDependencies)
end
-----------------------------------------------------------------------------------------------
-- GeminiGUI Table
-----------------------------------------------------------------------------------------------
local tWindowDefinition = {
Name = "MyExampleWindow",
Template = "CRB_TooltipSimple",
UseTemplateBG = true,
Picture = true,
Border = true,
AnchorCenter = { 500, 300 },
Children = {
{
WidgetType = "PushButton",
Base = "CRB_UIKitSprites:btn_square_LARGE_Red",
Text = "Close Parent",
TextThemeColor = "ffffffff", -- sets normal, flyby, pressed, pressedflyby, disabled to a color
AnchorCenter = { 150, 40 },
Events = {
ButtonSignal = function(self, wndHandler, wndControl)
wndControl:GetParent():Close()
end
},
},
},
}
-----------------------------------------------------------------------------------------------
-- WTF OnLoad
-----------------------------------------------------------------------------------------------
function WhatHappened:OnLoad()
-- load our form file
self.xmlDoc = XmlDoc.CreateFromFile("WhatHappened.xml")
self.xmlDoc:RegisterCallback("OnDocLoaded", self)
end
-----------------------------------------------------------------------------------------------
-- WTF OnDocLoaded
-----------------------------------------------------------------------------------------------
function WhatHappened:OnDocLoaded()
if self.xmlDoc ~= nil and self.xmlDoc:IsLoaded() then
self.wndMain = Apollo.LoadForm(self.xmlDoc, "WhatHappenedForm", nil, self)
self.wndSettings = Apollo.LoadForm(self.xmlDoc, "ConfigForm", nil, self)
if self.wndMain == nil then
Apollo.AddAddonErrorText(self, "Could not load the main window for some reason.")
return
end
if self.wndSettings == nil then
Apollo.AddAddonErrorText(self, "Could not load the settings window for some reason.")
end
self.wndMain:Show(false, true)
self.wndSettings:Show(false, true)
-- if the xmlDoc is no longer needed, you should set it to nil
-- self.xmlDoc = nil
-- Register handlers for events, slash commands and timer, etc.
-- e.g. Apollo.RegisterEventHandler("KeyDown", "OnKeyDown", self)
Apollo.RegisterSlashCommand("wh", "OnWhatHappenedOn", self)
Apollo.RegisterSlashCommand("wtf", "OnWhatHappenedOn", self)
--Event Handlers
Apollo.RegisterEventHandler("CombatLogDamage", "FilterByID", self)
Apollo.RegisterEventHandler("CombatLogDeath", "OnDeath", self)
--Apollo.RegisterEventHandler("CombatLogDeath", "OnDeathShow", self)
-- Do additional Addon initialization here
self.tTypeMapping =
{
[GameLib.CodeEnumDamageType.Physical] = Apollo.GetString("DamageType_Physical"),
[GameLib.CodeEnumDamageType.Tech] = Apollo.GetString("DamageType_Tech"),
[GameLib.CodeEnumDamageType.Magic] = Apollo.GetString("DamageType_Magic"),
[GameLib.CodeEnumDamageType.Fall] = Apollo.GetString("DamageType_Fall"),
[GameLib.CodeEnumDamageType.Suffocate] = Apollo.GetString("DamageType_Suffocate"),
["Unknown"] = Apollo.GetString("CombatLog_SpellUnknown"),
["UnknownDamageType"] = Apollo.GetString("CombatLog_SpellUnknown"),
}
self.tTypeColor =
{
[GameLib.CodeEnumDamageType.Heal] = "ff00ff00",
[GameLib.CodeEnumDamageType.HealShields] = "ff00ffae",
}
self.crVitalModifier = "ffffffff"
self.unitPlayer = nil
end
--self:OnRaidDeath(ICChannel, {strMsg = "testing!!"}, GameLib.GetPlayerUnit():GetName())
end
-----------------------------------------------------------------------------------------------
-- OnSave and OnRestore
-----------------------------------------------------------------------------------------------
function WhatHappened:OnSave(eType)
if eType ~= GameLib.CodeEnumAddonSaveLevel.General then
return nil
end
tSave.ICCommChanName = self.wndSettings:FindChild("ICCommChanName"):GetString()
return tSave
end
function WhatHappened:OnRestore(eType, tSave)
if eType ~= GameLib.CodeEnumAddonSaveLevel.General then
return
end
if tSave.ICCommChanName ~= nil then
self.wndSettings:FindChild("ICCommChanName"):SetText(tSave.ICCommChanName)
Print("TESTING!")
end
end
-----------------------------------------------------------------------------------------------
-- WTF Functions
-----------------------------------------------------------------------------------------------
-- Define general functions here
function WhatHappened:OnWhatHappenedOn(strCommand, strArg)
if strArg == "config" then
self.wndSettings:Invoke() -- show the config window
else
self.wndMain:Invoke() -- show the window
end
end
function WhatHappened:OnConfig()
self.wndMain:Invoke("ConfigForm")
end
--------------------------------------------------------------------
function WhatHappened:Count(strCountMe)
local count = 0
for _ in pairs(strCountMe) do
count = count + 1
end
return count
end
function WhatHappened:isPartyOrRaid()
local PartyType = ""
if GroupLib.GetGroupMaxSize() == 5 then
PartyType = "Party"
elseif GroupLib.GetGroupMaxSize() == 40 and GroupLib.GetMemberCount >= 20 then
PartyType = "20mRaid"
elseif GroupLib.GetGroupMaxSize() == 40 and GroupLib.GetMemberCount == 40 then
PartyType = "40mRaid"
end
end
--------------------------------------------------------------------
function WhatHappened:FilterByID(tEventArgs)
if tEventArgs.unitCaster:GetId() ~= GameLib.GetPlayerUnit():GetId() then
local strResult
local strOverkill = 0
if tEventArgs.nOverkill > 0 then
strOverkill = tEventArgs.nOverkill
end
local strDamageType = Apollo.GetString("CombatLog_UnknownDamageType")
if tEventArgs.eDamageType then
strDamageType = self.tTypeMapping[tEventArgs.eDamageType]
end
if PushCount <= 20 then
strResult1 = tEventArgs.splCallingSpell:GetName() .. " Has Hit "
strResult2 = GameLib.GetPlayerUnit():GetName()
strResult3 = " For " .. tEventArgs.nDamageAmount .. " As " .. strDamageType .. " Damage"
strResult = string.format("%s<T Font=\"CRB_Interface11_BO\">%s</T>%s", strResult1, strResult2, strResult3 )
if strOverkill ~= 0 then
strResult = strResult ..", OverKill Amount" .. strOverkill
end
Push(tCombatHistory, strResult)
PushCount = PushCount + 1
else
Pop(tCombatHistory)
strResult1 = tEventArgs.splCallingSpell:GetName() .. " Has Hit "
strResult2 = GameLib.GetPlayerUnit():GetName()
strResult3 = " For " .. tEventArgs.nDamageAmount .. " As " .. strDamageType .. " Damage"
strResult = string.format("%s<T Font=\"CRB_Interface11_BO\">%s</T>%s", strResult1, strResult2, strResult3 )
if strOverkill ~= 0 then
strResult = strResult ..", OverKill Amount" .. strOverkill
end
Push(tCombatHistory, strResult)
end
end
end
--------------------------------------------------------------------
function WhatHappened:OnDeath()
local CurrentLine = ""
local CurrentRaidLine = ""
local strOutput = ""
for k,v in pairs(tCombatHistory) do
CurrentLine = v --tCombatHistory[k]
if type(CurrentLine) == "string" then
strOutput = strOutput .. CurrentLine .. "\n"
end
end
self.wndMain:FindChild("CombatText"):SetAML(strOutput)
--for ICCommChan
if PushCount >= 15 then
for k,v in pairs(tCombatHistory) do
CurrentRaidLine = v --tCombatHistory[k]
--if type(CurrentLine) == "string" then
strRaidOutput = strOutput .. CurrentRaidLine .. "\n"
--end
end
end
ICChannel:SendMessage({strMsg = strRaidOutput})
PushCount = 0
end
--------------------------------------------------------------------
function Pop(list)
local first = list.first
if first > list.last then error("list is empty") end
local value = list[first]
list[first] = nil -- to allow garbage collection
list.first = first + 1
return value
end
--------------------------------------------------------------------
function Push(list, value)
local last = list.last + 1
list.last = last
list[last] = value
end
function WhatHappened:OnRaidDeath(chan, tMsg, strSender)
if tSave.ICCommChanName ~= nil then
Print(string.format("["..tSave.ICCommChanName.."] Recieved: %s", tMsg.strMsg))
end
end
-----------------------------------------------------------------------------------------------
-- WhatHappened Functions
-----------------------------------------------------------------------------------------------
function WhatHappened:OnClick()
self.wndMain.FindChild("CombatText"):SetAML("Testing!!")
end
-- when the OK button is clicked
function WhatHappened:OnOK()
self.wndMain:Close() -- hide the window
end
-- when the Cancel button is clicked
function WhatHappened:OnCancel()
self.wndMain:Close() -- hide the window
end
function WhatHappened:OnSettingsClose()
self.OnSave()
--ICComm Chan Join
if ICChannel == nil then
if tSave.ICCommChanName ~= nil then
ICChannel = ICCommLib.JoinChannel(tSave.ICCommChanName, "OnRaidDeath", self)
else
Print("YOU MUST ENTER A CHANNEL TO RECIEVE DEATH REPORTS!!")
end
end
self.wndSettings:Close()
end
-----------------------------------------------------------------------------------------------
-- WTF Instance
-----------------------------------------------------------------------------------------------
local WhatHappenedInst = WhatHappened:new()
WhatHappenedInst:Init()
--[[
--ICComm Chan Join
if ICChannel == nil then
if tSave.ICCommChanName == nil then
ICChannel = ICCommLib.JoinChannel("RaidDeath", "OnRaidDeath", self)
else
ICChannel = ICCommLib.JoinChannel(tSave.ICCommChanName, "OnRaidDeath", self)
end
end
]]
<?xml version="1.0" encoding="UTF-8"?>
<Forms>
<Form Class="Window" LAnchorPoint="0" LAnchorOffset="20" TAnchorPoint="0" TAnchorOffset="161" RAnchorPoint="0" RAnchorOffset="703" BAnchorPoint="0" BAnchorOffset="410" RelativeToClient="1" Font="CRB_Interface14_O" Text="" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Holo_Background_General" TooltipType="OnCursor" Name="WhatHappenedForm" Border="1" Picture="1" SwallowMouseClicks="1" Moveable="1" Escapable="1" Overlapped="0" TooltipColor="" Tooltip="" Visible="1" VScroll="0" HScroll="0" Sizable="0" UseTemplateBG="1" NoClip="1">
<Control Class="Button" Base="CRB_UIKitSprites:btn_square_LARGE_Red" Font="DefaultButton" ButtonType="PushButton" RadioGroup="" LAnchorPoint="0" LAnchorOffset="606" TAnchorPoint="0" TAnchorOffset="222" RAnchorPoint="0" RAnchorOffset="675" BAnchorPoint="0" BAnchorOffset="246" DT_VCENTER="1" DT_CENTER="1" BGColor="UI_BtnBGDefault" TextColor="UI_BtnTextDefault" NormalTextColor="UI_BtnTextDefault" PressedTextColor="UI_BtnTextDefault" FlybyTextColor="UI_BtnTextDefault" PressedFlybyTextColor="UI_BtnTextDefault" DisabledTextColor="UI_BtnTextDefault" TooltipType="OnCursor" Name="Button" TooltipColor="" Text="" TextId="CRB_Close">
<Event Name="ButtonSignal" Function="OnCancel"/>
</Control>
<Event Name="WindowShow" Function="OnShowLog"/>
<Control Class="MLWindow" LAnchorPoint="0" LAnchorOffset="193" TAnchorPoint="0" TAnchorOffset="23" RAnchorPoint="0" RAnchorOffset="659" BAnchorPoint="0" BAnchorOffset="207" RelativeToClient="1" Font="Default" Text="" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Holo_ScrollList" TooltipType="OnCursor" Name="CombatText" TooltipColor="" Border="1" IgnoreMouse="0" HScroll="0" VScroll="1" UseTemplateBG="1" AutoHideScroll="0" UseParentOpacity="1"/>
<Control Class="EditBox" LAnchorPoint="0" LAnchorOffset="-9" TAnchorPoint="0" TAnchorOffset="-9" RAnchorPoint="0" RAnchorOffset="656" BAnchorPoint="0" BAnchorOffset="22" RelativeToClient="1" Font="CRB_Interface14_BBO" Text="WTF Happened!!" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Default" TooltipType="OnCursor" Name="Title" TooltipColor="" TextId="" DT_BOTTOM="0" DT_VCENTER="1" DT_CENTER="1" ReadOnly="1" SizeToFit="0" Password="0" IgnoreMouse="1" Border="0" NoClip="0" UseTemplateBG="0"/>
<Control Class="MLWindow" LAnchorPoint="0" LAnchorOffset="0" TAnchorPoint="0" TAnchorOffset="3" RAnchorPoint="0" RAnchorOffset="188" BAnchorPoint="0" BAnchorOffset="227" RelativeToClient="1" Font="Default" Text="" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Holo_Background_Datachron" TooltipType="OnCursor" Name="PartyListForm" TooltipColor="" VScroll="1" Border="1" Picture="1" UseTemplateBG="1" DT_WORDBREAK="1">
<Control Class="EditBox" LAnchorPoint="0" LAnchorOffset="10" TAnchorPoint="0" TAnchorOffset="10" RAnchorPoint="0" RAnchorOffset="172" BAnchorPoint="0" BAnchorOffset="29" RelativeToClient="1" Font="Default" Text="Party Member #1" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Default" TooltipType="OnCursor" Name="EditBox" TooltipColor="" TextId="" DT_VCENTER="1" DT_CENTER="1" ReadOnly="1">
<Event Name="MouseButtonDown" Function="OnClick"/>
</Control>
</Control>
</Form>
<Form Class="Window" LAnchorPoint="0" LAnchorOffset="10" TAnchorPoint="0" TAnchorOffset="10" RAnchorPoint="0" RAnchorOffset="489" BAnchorPoint="0" BAnchorOffset="292" RelativeToClient="1" Font="Default" Text="" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Metal_Primary_NoNav" TooltipType="OnCursor" Name="ConfigForm" Border="1" Picture="0" SwallowMouseClicks="1" Moveable="1" Escapable="1" Overlapped="0" TooltipColor="" Tooltip="" DT_WORDBREAK="1" UseTemplateBG="0">
<Control Class="Window" LAnchorPoint="0" LAnchorOffset="-5" TAnchorPoint="0" TAnchorOffset="74" RAnchorPoint="0" RAnchorOffset="425" BAnchorPoint="0" BAnchorOffset="258" RelativeToClient="1" Font="Default" Text="" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="CRB_Datachron" TooltipType="OnCursor" Name="ConfigWindow" TooltipColor="" Border="1" IgnoreMouse="1" Picture="1" Overlapped="0" UseTemplateBG="1">
<Control Class="EditBox" LAnchorPoint="0" LAnchorOffset="57" TAnchorPoint="0" TAnchorOffset="9" RAnchorPoint="0" RAnchorOffset="158" BAnchorPoint="0" BAnchorOffset="29" RelativeToClient="1" Font="Default" Text="Channel Name:" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Default" TooltipType="OnCursor" Name="ChannelEditBox" TooltipColor="" TextId=""/>
<Control Class="EditBox" LAnchorPoint="0" LAnchorOffset="9" TAnchorPoint="0" TAnchorOffset="33" RAnchorPoint="0" RAnchorOffset="411" BAnchorPoint="0" BAnchorOffset="84" RelativeToClient="1" Font="Default" Text="This is the Channel specific to your raid (this can be anything and must be unique!) i.e PremonitionRaid2014" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Default" TooltipType="OnCursor" Name="Text" TooltipColor="" TextId="" DT_WORDBREAK="1" MultiLine="1" ReadOnly="1" SizeToFit="1" DT_VCENTER="0" DT_CENTER="1"/>
<Control Class="EditBox" LAnchorPoint="0" LAnchorOffset="157" TAnchorPoint="0" TAnchorOffset="5" RAnchorPoint="0" RAnchorOffset="361" BAnchorPoint="0" BAnchorOffset="30" RelativeToClient="1" Font="Default" Text="" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Holo_InputBox" TooltipType="OnCursor" Name="ICCommChanName" TooltipColor="" Picture="0" Border="1" UseTemplateBG="1" KeepStringList="0" DefaultTarget="1"/>
<Control Class="Button" Base="Crafting_CircuitSprites:btnCircuit_Glass_GreenOrange" Font="DefaultButton" ButtonType="PushButton" RadioGroup="" LAnchorPoint="0" LAnchorOffset="306" TAnchorPoint="0" TAnchorOffset="139" RAnchorPoint="0" RAnchorOffset="417" BAnchorPoint="0" BAnchorOffset="176" DT_VCENTER="1" DT_CENTER="1" BGColor="UI_BtnBGDefault" TextColor="UI_BtnTextDefault" NormalTextColor="UI_BtnTextDefault" PressedTextColor="UI_BtnTextDefault" FlybyTextColor="UI_BtnTextDefault" PressedFlybyTextColor="UI_BtnTextDefault" DisabledTextColor="UI_BtnTextDefault" TooltipType="OnCursor" Name="Button" TooltipColor="" Text="" TextId="CRB_Save" Border="0" Picture="0" UseTemplateBG="0" DrawAsCheckbox="0">
<Event Name="ButtonSignal" Function="OnSettingsClose"/>
</Control>
</Control>
<Control Class="EditBox" LAnchorPoint="0" LAnchorOffset="35" TAnchorPoint="0" TAnchorOffset="23" RAnchorPoint="0" RAnchorOffset="382" BAnchorPoint="0" BAnchorOffset="72" RelativeToClient="1" Font="CRB_Interface14_BBO" Text="What Happened Config" BGColor="UI_WindowBGDefault" TextColor="UI_WindowTextDefault" Template="Default" TooltipType="OnCursor" Name="Title" TooltipColor="" TextId="" DT_VCENTER="1" DT_CENTER="1" IgnoreMouse="1" UseTemplateBG="0" ReadOnly="1"/>
</Form>
</Forms>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment