diff --git a/CraftResearchTimer.txt b/CraftResearchTimer.txt deleted file mode 100644 index 09065de..0000000 --- a/CraftResearchTimer.txt +++ /dev/null @@ -1,21 +0,0 @@ -## Title: |c96FF00Craft Research Timer|r - |c96FF000.4.11|r -## APIVersion: 100010 -## SavedVariables: CraftResearchTimer_SavedVariables -## Version: 0.4.11 -## Author: @aTo (EU) + Patch by @GarulfoX - -lib\LibStub.lua - -lua\header.lua -lua\CORE.lua -lua\ALERT.lua -lua\GRID.lua -lua\CRAFT.lua -lua\CraftResearchTimer.lua -lua\Menu-function.lua - -xml\Bindings.xml -xml\CraftResearchTimer.xml - -Language/en.lua -Language/$(language).lua diff --git a/Language/en.lua b/Language/en.lua index fb630e4..6dbba4c 100644 --- a/Language/en.lua +++ b/Language/en.lua @@ -1,19 +1,17 @@ -- Language file: ENGLISH -function CRT.InitialiseLanguage() - CRT.L = {} +function RT.InitialiseLanguage() + RT.L = {} -- Settings / Config menu stuff - CRT.L["PanelHeading"] = "|c96FF00Craft Research Timer|r Settings" - CRT.L["General Options"] = "|c45D7F7General Options|r" - CRT.L["Keybinds"] = "|c45D7F7Keybinds|r" + RT.L["Keybinds"] = "|c45D7F7Keybinds|r" - CRT.L["Clothing"] = "CLOTHING" - CRT.L["BS"] = "BLACKSMITHING" - CRT.L["Woodwork"] = "WOODWORKING" + RT.L["Clothing"] = "CLOTHING" + RT.L["BS"] = "BLACKSMITHING" + RT.L["Woodwork"] = "WOODWORKING" - CRT.L["Finished"] = "|cFF0000Finished|r" - CRT.L["Completed"] = "Research completed on" + RT.L["Finished"] = "|cFF0000Finished|r" + RT.L["Completed"] = "Research completed on" end diff --git a/ResearchTimer.txt b/ResearchTimer.txt new file mode 100644 index 0000000..20d6c8d --- /dev/null +++ b/ResearchTimer.txt @@ -0,0 +1,16 @@ +## Title: |c96FF00Research Timer|r - |c96FF00 v1|r +## APIVersion: 100010 +## SavedVariables: ResearchTimer +## Version: 1 +## Author: Hisdad + + +lua\CORE.lua +lua\GRID.lua +lua\ResearchTimer.lua + + +xml\Bindings.xml + +Language/en.lua +Language/$(language).lua diff --git a/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua b/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua deleted file mode 100644 index 05f0670..0000000 --- a/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua +++ /dev/null @@ -1,322 +0,0 @@ --- LibAddonMenu-2.0 & its files © Ryan Lakanen (Seerah) -- --- All Rights Reserved -- --- Permission is granted to use Seerah's LibAddonMenu-2.0 -- --- in your project. Any modifications to LibAddonMenu-2.0 -- --- may not be redistributed. -- --------------------------------------------------------------- - - ---Register LAM with LibStub -local MAJOR, MINOR = "LibAddonMenu-2.0", 16 -local lam, oldminor = LibStub:NewLibrary(MAJOR, MINOR) -if not lam then return end --the same or newer version of this lib is already loaded into memory - - ---UPVALUES-- -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert -local optionsWindow = ZO_OptionsWindowSettingsScrollChild -local _ - -local addonsForList = {} -local addonToOptionsMap = {} -local optionsCreated = {} -lam.widgets = lam.widgets or {} -local widgets = lam.widgets - - ---METHOD: REGISTER WIDGET-- ---each widget has its version checked before loading, ---so we only have the most recent one in memory ---Usage: --- widgetType = "string"; the type of widget being registered --- widgetVersion = integer; the widget's version number -LAMCreateControl = LAMCreateControl or {} -local lamcc = LAMCreateControl - -function lam:RegisterWidget(widgetType, widgetVersion) - if widgets[widgetType] and widgets[widgetType] >= widgetVersion then - return false - else - widgets[widgetType] = widgetVersion - return true - end -end - - ---METHOD: OPEN TO ADDON PANEL-- ---opens to a specific addon's option panel ---Usage: --- panel = userdata; the panel returned by the :RegisterOptionsPanel method ---local settings = {en = "Settings", de = "Einstellungen", fr = "Réglages"} ---local locSettings = settings[GetCVar("Language.2")] -local locSettings = GetString(SI_GAME_MENU_SETTINGS) -function lam:OpenToPanel(panel) - SCENE_MANAGER:Show("gameMenuInGame") - zo_callLater(function() - ZO_GameMenu_InGame.gameMenu.headerControls[locSettings]:SetOpen(true) - SCENE_MANAGER:AddFragment(OPTIONS_WINDOW_FRAGMENT) - --ZO_OptionsWindow_ChangePanels(lam.panelID) - KEYBOARD_OPTIONS:ChangePanels(lam.panelID) - --if not lam.panelSubCategoryControl then - -- lam.panelSubCategoryControl = _G["ZO_GameMenu_InGameNavigationContainerScrollChildZO_GameMenu_SubCategory"..(lam.panelID + 1)] - --end - --ZO_TreeEntry_OnMouseUp(lam.panelSubCategoryControl, true) - panel:SetHidden(false) - end, 200) -end - - ---INTERNAL FUNCTION ---creates controls when options panel is first shown ---controls anchoring of these controls in the panel -local function CreateOptionsControls(panel) - local addonID = panel:GetName() - local optionsTable = addonToOptionsMap[addonID] - - if optionsTable then - local lastAddedControl, lacAtHalfRow - for _, widgetData in ipairs(optionsTable) do - local widgetType = widgetData.type - if widgetType == "submenu" then - local submenu = LAMCreateControl[widgetType](panel, widgetData) - if lastAddedControl then - submenu:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15) - else - submenu:SetAnchor(TOPLEFT) - end - lastAddedControl = submenu - lacAtHalfRow = false - - local lastAddedControlSub, lacAtHalfRowSub - for _, subWidgetData in ipairs(widgetData.controls) do - local subWidgetType = subWidgetData.type - local subWidget = LAMCreateControl[subWidgetType](submenu, subWidgetData) - local isHalf = subWidgetData.width == "half" - if lastAddedControlSub then - if lacAtHalfRowSub and isHalf then - subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, TOPRIGHT, 5, 0) - lacAtHalfRowSub = false - else - subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, BOTTOMLEFT, 0, 15) - lacAtHalfRowSub = isHalf and true or false - lastAddedControlSub = subWidget - end - else - subWidget:SetAnchor(TOPLEFT) - lacAtHalfRowSub = isHalf and true or false - lastAddedControlSub = subWidget - end - end - else - local widget = LAMCreateControl[widgetType](panel, widgetData) - local isHalf = widgetData.width == "half" - if lastAddedControl then - if lacAtHalfRow and isHalf then - widget:SetAnchor(TOPLEFT, lastAddedControl, TOPRIGHT, 10, 0) - lacAtHalfRow = false - else - widget:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15) - lacAtHalfRow = isHalf and true or false - lastAddedControl = widget - end - else - widget:SetAnchor(TOPLEFT) - lacAtHalfRow = isHalf and true or false - lastAddedControl = widget - end - end - end - end - - optionsCreated[addonID] = true - cm:FireCallbacks("LAM-PanelControlsCreated", panel) -end - - ---INTERNAL FUNCTION ---handles switching between panels -local function ToggleAddonPanels(panel) --called in OnShow of newly shown panel - local currentlySelected = LAMAddonPanelsMenu.currentlySelected - if currentlySelected and currentlySelected ~= panel then - currentlySelected:SetHidden(true) - end - LAMAddonPanelsMenu.currentlySelected = panel - - if not optionsCreated[panel:GetName()] then --if this is the first time opening this panel, create these options - CreateOptionsControls(panel) - end - - cm:FireCallbacks("LAM-RefreshPanel", panel) -end - - ---METHOD: REGISTER ADDON PANEL ---registers your addon with LibAddonMenu and creates a panel ---Usage: --- addonID = "string"; unique ID which will be the global name of your panel --- panelData = table; data object for your panel - see controls\panel.lua -function lam:RegisterAddonPanel(addonID, panelData) - local panel = lamcc.panel(nil, panelData, addonID) --addonID==global name of panel - panel:SetHidden(true) - panel:SetAnchor(TOPLEFT, LAMAddonPanelsMenu, TOPRIGHT, 10, 0) - panel:SetAnchor(BOTTOMLEFT, LAMAddonPanelsMenu, BOTTOMRIGHT, 10, 0) - panel:SetWidth(549) - panel:SetDrawLayer(DL_OVERLAY) - tinsert(addonsForList, {panel = addonID, name = panelData.name}) - panel:SetHandler("OnShow", ToggleAddonPanels) - if panelData.slashCommand then - SLASH_COMMANDS[panelData.slashCommand] = function() - lam:OpenToPanel(panel) - end - end - - return panel --return for authors creating options manually -end - - ---METHOD: REGISTER OPTION CONTROLS ---registers the options you want shown for your addon ---these are stored in a table where each key-value pair is the order ---of the options in the panel and the data for that control, respectively ---see exampleoptions.lua for an example ---see controls\<widget>.lua for each widget type ---Usage: --- addonID = "string"; the same string passed to :RegisterAddonPanel --- optionsTable = table; the table containing all of the options controls and their data -function lam:RegisterOptionControls(addonID, optionsTable) --optionsTable = {sliderData, buttonData, etc} - addonToOptionsMap[addonID] = optionsTable -end - - ---INTERNAL FUNCTION ---handles switching between LAM's Addon Settings panel and other panels in the Settings menu -local oldDefaultButton = ZO_OptionsWindowResetToDefaultButton -local oldCallback = oldDefaultButton.callback -local dummyFunc = function() end -local panelWindow = ZO_OptionsWindow -local bgL = ZO_OptionsWindowBGLeft -local bgR = ZO_OptionsWindowBGLeftBGRight -local function HandlePanelSwitching(self, panel) - if panel == lam.panelID then --our addon settings panel - oldDefaultButton:SetCallback(dummyFunc) - oldDefaultButton:SetHidden(true) - oldDefaultButton:SetAlpha(0) --just because it still bugs out - panelWindow:SetDimensions(999, 960) - bgL:SetWidth(666) - bgR:SetWidth(333) - else - local shown = LAMAddonPanelsMenu.currentlySelected - if shown then shown:SetHidden(true) end - oldDefaultButton:SetCallback(oldCallback) - oldDefaultButton:SetHidden(false) - oldDefaultButton:SetAlpha(1) - panelWindow:SetDimensions(768, 914) - bgL:SetWidth(512) - bgR:SetWidth(256) - end -end - - ---INTERNAL FUNCTION ---creates LAM's Addon Settings panel -local function CreateAddonSettingsPanel() - if not LAMSettingsPanelCreated then - local controlPanelID = "LAM_ADDON_SETTINGS_PANEL" - --Russian for TERAB1T's RuESO addon, which creates an "ru" locale - --game font does not support Cyrillic, so they are using custom fonts + extended latin charset - --Spanish provided by Luisen75 for their translation project - local controlPanelNames = { - en = "Addon Settings", - fr = "Extensions", - de = "Erweiterungen", - ru = "Îacòpoéêè äoïoìîeîèé", - es = "Configura Addons", - } - - ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelNames[GetCVar("Language.2")] or controlPanelName["en"]) - - lam.panelID = _G[controlPanelID] - - --ZO_PreHook("ZO_OptionsWindow_ChangePanels", HandlePanelSwitching) - ZO_PreHook(ZO_SharedOptions, "ChangePanels", HandlePanelSwitching) - - LAMSettingsPanelCreated = true - end -end - - ---INTERNAL FUNCTION ---adds each registered addon to the menu in LAM's panel -local function CreateAddonButtons(list, addons) - for i = 1, #addons do - local button = wm:CreateControlFromVirtual("LAMAddonMenuButton"..i, list.scrollChild, "ZO_DefaultTextButton") - button.name = addons[i].name - button.panel = _G[addons[i].panel] - button:SetText(button.name) - button:SetHorizontalAlignment(TEXT_ALIGN_LEFT) - button:SetWidth(190) - if i == 1 then - button:SetAnchor(TOPLEFT, list.scrollChild, TOPLEFT, 5, 5) - else - button:SetAnchor(TOPLEFT, _G["LAMAddonMenuButton"..i-1], BOTTOMLEFT) - end - button:SetHandler("OnClicked", function(self) self.panel:SetHidden(false) end) - end -end - - ---INTERNAL FUNCTION ---creates the left-hand menu in LAM's panel -local function CreateAddonList() - local list - --check if an earlier loaded copy of LAM created it already - list = LAMAddonPanelsMenu or wm:CreateControlFromVirtual("LAMAddonPanelsMenu", optionsWindow, "ZO_ScrollContainer") - list:ClearAnchors() - list:SetAnchor(TOPLEFT) - list:SetHeight(675) - list:SetWidth(200) - - list.bg = list.bg or wm:CreateControl(nil, list, CT_BACKDROP) - local bg = list.bg - bg:SetAnchorFill() --offsets of 8? - bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) - bg:SetCenterColor(0, 0, 0, 0) - - list.scrollChild = LAMAddonPanelsMenuScrollChild - list.scrollChild:SetResizeToFitPadding(0, 15) - - local generatedButtons - list:SetHandler("OnShow", function(self) - if not generatedButtons and #addonsForList > 0 then - --we're about to show our list for the first time - let's sort the buttons before creating them - table.sort(addonsForList, function(a, b) - return a.name < b.name - end) - CreateAddonButtons(list, addonsForList) - self.currentlySelected = LAMAddonMenuButton1 and LAMAddonMenuButton1.panel - --since our addon panels don't have a parent, let's make sure they hide when we're done with them - ZO_PreHookHandler(ZO_OptionsWindow, "OnHide", function() self.currentlySelected:SetHidden(true) end) - generatedButtons = true - end - if self.currentlySelected then self.currentlySelected:SetHidden(false) end - end) - - --list.controlType = OPTIONS_CUSTOM - --list.panel = lam.panelID - list.data = { - controlType = OPTIONS_CUSTOM, - panel = lam.panelID, - } - - ZO_OptionsWindow_InitializeControl(list) - - return list -end - - ---INITIALIZING -CreateAddonSettingsPanel() -CreateAddonList() - diff --git a/lib/LibAddonMenu-2.0/controls/button.lua b/lib/LibAddonMenu-2.0/controls/button.lua deleted file mode 100644 index 13387a1..0000000 --- a/lib/LibAddonMenu-2.0/controls/button.lua +++ /dev/null @@ -1,89 +0,0 @@ ---[[buttonData = { - type = "button", - name = "My Button", - tooltip = "Button's tooltip text.", - func = function() end, - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - icon = "icon\\path.dds", --(optional) - warning = "Will need to reload the UI.", --(optional) - reference = "MyAddonButton" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 5 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("button", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.button:SetEnabled(not disable) -end - - ---controlName is optional -function LAMCreateControl.button(parent, buttonData, controlName) - local control = wm:CreateTopLevelWindow(controlName or buttonData.reference) - control:SetParent(parent.scroll or parent) - - local isHalfWidth = buttonData.width == "half" - control:SetDimensions(isHalfWidth and 250 or 510, isHalfWidth and 55 or 28) - control:SetMouseEnabled(true) - - if buttonData.icon then - control.button = wm:CreateControl(nil, control, CT_BUTTON) - control.button:SetDimensions(26, 26) - control.button:SetNormalTexture(buttonData.icon) - control.button:SetPressedOffset(2, 2) - else - --control.button = wm:CreateControlFromVirtual(controlName.."Button", control, "ZO_DefaultButton") - control.button = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultButton") - control.button:SetWidth(isHalfWidth and 180 or 200) - control.button:SetText(buttonData.name) - end - local button = control.button - button:SetAnchor(isHalfWidth and CENTER or RIGHT) - button:SetClickSound("Click") - --button.tooltipText = buttonData.tooltip - button.data = {tooltipText = buttonData.tooltip} - button:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - button:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - button:SetHandler("OnClicked", function(self, ...) - buttonData.func(self, ...) - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - end) - - if buttonData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, button, LEFT, -5, 0) - --control.warning.tooltipText = buttonData.warning - control.warning.data = {tooltipText = buttonData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = buttonData - - if buttonData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - - --this is here because buttons don't have an UpdateValue method - if control.panel.data.registerForRefresh then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - end - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/checkbox.lua b/lib/LibAddonMenu-2.0/controls/checkbox.lua deleted file mode 100644 index 14b1638..0000000 --- a/lib/LibAddonMenu-2.0/controls/checkbox.lua +++ /dev/null @@ -1,172 +0,0 @@ ---[[checkboxData = { - type = "checkbox", - name = "My Checkbox", - tooltip = "Checkbox's tooltip text.", - getFunc = function() return db.var end, - setFunc = function(value) db.var = value doStuff() end, - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonCheckbox" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 7 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("checkbox", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert ---label -local enabledColor = ZO_DEFAULT_ENABLED_COLOR -local enabledHLcolor = ZO_HIGHLIGHT_TEXT -local disabledColor = ZO_DEFAULT_DISABLED_COLOR -local disabledHLcolor = ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR ---checkbox -local checkboxColor = ZO_NORMAL_TEXT -local checkboxHLcolor = ZO_HIGHLIGHT_TEXT - - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.label:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or control.value and ZO_DEFAULT_ENABLED_COLOR or ZO_DEFAULT_DISABLED_COLOR):UnpackRGBA()) - control.checkbox:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or ZO_NORMAL_TEXT):UnpackRGBA()) - --control:SetMouseEnabled(not disable) - --control:SetMouseEnabled(true) - - control.isDisabled = disable -end - -local function ToggleCheckbox(control) - if control.value then - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.checkbox:SetText(control.checkedText) - else - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.checkbox:SetText(control.uncheckedText) - end -end - -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - elseif value ~= nil then --our value could be false - control.data.setFunc(value) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - end - control.value = value - - ToggleCheckbox(control) -end - -local function OnMouseEnter(control) - ZO_Options_OnMouseEnter(control) - - if control.isDisabled then return end - - local label = control.label - if control.value then - label:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) - else - label:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - end - control.checkbox:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) -end - -local function OnMouseExit(control) - ZO_Options_OnMouseExit(control) - - if control.isDisabled then return end - - local label = control.label - if control.value then - label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - else - label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - end - control.checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) -end - - ---controlName is optional -function LAMCreateControl.checkbox(parent, checkboxData, controlName) - local control = wm:CreateTopLevelWindow(controlName or checkboxData.reference) - control:SetParent(parent.scroll or parent) - control:SetMouseEnabled(true) - --control.tooltipText = checkboxData.tooltip - control:SetHandler("OnMouseEnter", OnMouseEnter) - control:SetHandler("OnMouseExit", OnMouseExit) - control:SetHandler("OnMouseUp", function(control) - if control.isDisabled then return end - PlaySound(SOUNDS.DEFAULT_CLICK) - control.value = not control.value - control:UpdateValue(false, control.value) - end) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetFont("ZoFontWinH4") - label:SetText(checkboxData.name) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetHeight(26) - - control.checkbox = wm:CreateControl(nil, control, CT_LABEL) - local checkbox = control.checkbox - checkbox:SetFont("ZoFontGameBold") - checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) - control.checkedText = GetString(SI_CHECK_BUTTON_ON):upper() - control.uncheckedText = GetString(SI_CHECK_BUTTON_OFF):upper() - - local isHalfWidth = checkboxData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - checkbox:SetDimensions(100, 26) - checkbox:SetAnchor(BOTTOMRIGHT) - label:SetAnchor(TOPLEFT) - label:SetAnchor(TOPRIGHT) - else - control:SetDimensions(510, 30) - checkbox:SetDimensions(200, 26) - checkbox:SetAnchor(RIGHT) - label:SetAnchor(LEFT) - label:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) - end - - if checkboxData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) - --control.warning.tooltipText = checkboxData.warning - control.warning.data = {tooltipText = checkboxData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = checkboxData - control.data.tooltipText = checkboxData.tooltip - - if checkboxData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/colorpicker.lua b/lib/LibAddonMenu-2.0/controls/colorpicker.lua deleted file mode 100644 index 3918030..0000000 --- a/lib/LibAddonMenu-2.0/controls/colorpicker.lua +++ /dev/null @@ -1,140 +0,0 @@ ---[[colorpickerData = { - type = "colorpicker", - name = "My Color Picker", - tooltip = "Color Picker's tooltip text.", - getFunc = function() return db.r, db.g, db.b, db.a end, --(alpha is optional) - setFunc = function(r,g,b,a) db.r=r, db.g=g, db.b=b, db.a=a end, --(alpha is optional) - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = {r = defaults.r, g = defaults.g, b = defaults.b, a = defaults.a}, --(optional) table of default color values (or default = defaultColor, where defaultColor is a table with keys of r, g, b[, a]) - reference = "MyAddonColorpicker" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 5 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("colorpicker", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert - - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end - - control.isDisabled = disable -end - -local function UpdateValue(control, forceDefault, valueR, valueG, valueB, valueA) - if forceDefault then --if we are forcing defaults - local color = control.data.default - valueR, valueG, valueB, valueA = color.r, color.g, color.b, color.a - control.data.setFunc(valueR, valueG, valueB, valueA) - elseif valueR and valueG and valueB then - control.data.setFunc(valueR, valueG, valueB, valueA or 1) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - valueR, valueG, valueB, valueA = control.data.getFunc() - end - - control.thumb:SetColor(valueR, valueG, valueB, valueA or 1) -end - - -function LAMCreateControl.colorpicker(parent, colorpickerData, controlName) - local control = wm:CreateTopLevelWindow(controlName or colorpickerData.reference) - control:SetParent(parent.scroll or parent) - control:SetMouseEnabled(true) - --control.tooltipText = colorpickerData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetDimensions(300, 26) - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(colorpickerData.name) - - control.color = wm:CreateControl(nil, control, CT_CONTROL) - local color = control.color - - local isHalfWidth = colorpickerData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - label:SetDimensions(250, 26) - color:SetDimensions(100, 24) - color:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) - else - control:SetDimensions(510, 30) - label:SetDimensions(300, 26) - color:SetDimensions(200, 24) - color:SetAnchor(TOPRIGHT) - end - - control.thumb = wm:CreateControl(nil, color, CT_TEXTURE) - local thumb = control.thumb - thumb:SetDimensions(36, 18) - thumb:SetAnchor(LEFT, color, LEFT, 4, 0) - - color.border = wm:CreateControl(nil, color, CT_TEXTURE) - local border = color.border - border:SetTexture("EsoUI\\Art\\ChatWindow\\chatOptions_bgColSwatch_frame.dds") - border:SetTextureCoords(0, .625, 0, .8125) - border:SetDimensions(40, 22) - border:SetAnchor(CENTER, thumb, CENTER, 0, 0) - - local function ColorPickerCallback(r, g, b, a) - control:UpdateValue(false, r, g, b, a) - end - - control:SetHandler("OnMouseUp", function(self, btn, upInside) - if self.isDisabled then return end - - if upInside then - local r, g, b, a = colorpickerData.getFunc() - COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, colorpickerData.name) - end - end) - - if colorpickerData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, control.color, LEFT, -5, 0) - --control.warning.tooltipText = colorpickerData.warning - control.warning.data = {tooltipText = colorpickerData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = colorpickerData - control.data.tooltipText = colorpickerData.tooltip - - if colorpickerData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/custom.lua b/lib/LibAddonMenu-2.0/controls/custom.lua deleted file mode 100644 index fcfa618..0000000 --- a/lib/LibAddonMenu-2.0/controls/custom.lua +++ /dev/null @@ -1,45 +0,0 @@ ---[[customData = { - type = "custom", - reference = "MyAddonCustomControl", --(optional) unique name for your control to use as reference - refreshFunc = function(customControl) end, --(optional) function to call when panel/controls refresh - width = "full", --or "half" (optional) -} ]] - -local widgetVersion = 4 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("custom", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local tinsert = table.insert - -local function UpdateValue(control) - if control.data.refreshFunc then - control.data.refreshFunc(control) - end -end - -function LAMCreateControl.custom(parent, customData, controlName) - local control = wm:CreateTopLevelWindow(controlName or customData.reference) - control:SetResizeToFitDescendents(true) - control:SetParent(parent.scroll or parent) - - local isHalfWidth = customData.width == "half" - if isHalfWidth then --note these restrictions - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 30, 510, 100) - control:SetDimensions(510, 30) - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = customData - - control.UpdateValue = UpdateValue - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/description.lua b/lib/LibAddonMenu-2.0/controls/description.lua deleted file mode 100644 index aac6d9e..0000000 --- a/lib/LibAddonMenu-2.0/controls/description.lua +++ /dev/null @@ -1,67 +0,0 @@ ---[[descriptionData = { - type = "description", - title = "My Title", --(optional) - text = "My description text to display.", - width = "full", --or "half" (optional) - reference = "MyAddonDescription" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 4 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("description", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local tinsert = table.insert - -local function UpdateValue(control) - if control.title then - control.title:SetText(control.data.title) - end - control.desc:SetText(control.data.text) -end - -function LAMCreateControl.description(parent, descriptionData, controlName) - local control = wm:CreateTopLevelWindow(controlName or descriptionData.reference) - control:SetResizeToFitDescendents(true) - control:SetParent(parent.scroll or parent) - local isHalfWidth = descriptionData.width == "half" - if isHalfWidth then - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 40, 510, 100) - control:SetDimensions(510, 30) - end - - control.desc = wm:CreateControl(nil, control, CT_LABEL) - local desc = control.desc - desc:SetVerticalAlignment(TEXT_ALIGN_TOP) - desc:SetFont("ZoFontGame") - desc:SetText(descriptionData.text) - desc:SetWidth(isHalfWidth and 250 or 510) - - if descriptionData.title then - control.title = wm:CreateControl(nil, control, CT_LABEL) - local title = control.title - title:SetWidth(isHalfWidth and 250 or 510) - title:SetAnchor(TOPLEFT, control, TOPLEFT) - title:SetFont("ZoFontWinH4") - title:SetText(descriptionData.title) - desc:SetAnchor(TOPLEFT, title, BOTTOMLEFT) - else - desc:SetAnchor(TOPLEFT) - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = descriptionData - - control.UpdateValue = UpdateValue - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control - -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/dropdown.lua b/lib/LibAddonMenu-2.0/controls/dropdown.lua deleted file mode 100644 index 10c44eb..0000000 --- a/lib/LibAddonMenu-2.0/controls/dropdown.lua +++ /dev/null @@ -1,153 +0,0 @@ ---[[dropdownData = { - type = "dropdown", - name = "My Dropdown", - tooltip = "Dropdown's tooltip text.", - choices = {"table", "of", "choices"}, - sort = "name-up", --or "name-down", "numeric-up", "numeric-down" (optional) - if not provided, list will not be sorted - getFunc = function() return db.var end, - setFunc = function(var) db.var = var doStuff() end, - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonDropdown" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 7 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("dropdown", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert - - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.dropdown:SetEnabled(not disable) - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end -end - -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - control.dropdown:SetSelectedItem(value) - elseif value then - control.data.setFunc(value) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - control.dropdown:SetSelectedItem(value) - end -end - -local function DropdownCallback(choice, choiceText, choice) - choice.control:UpdateValue(false, choiceText) -end - -local function UpdateChoices(control, choices) - control.dropdown:ClearItems() --remove previous choices --(need to call :SetSelectedItem()?) - - --build new list of choices - local choices = choices or control.data.choices - for i = 1, #choices do - local entry = control.dropdown:CreateItemEntry(choices[i], DropdownCallback) - entry.control = control - control.dropdown:AddItem(entry, not control.data.sort and ZO_COMBOBOX_SUPRESS_UPDATE) --if sort type/order isn't specified, then don't sort - end -end - -local function GrabSortingInfo(sortInfo) - local t, i = {}, 1 - for info in string.gmatch(sortInfo, "([^%-]+)") do - t[i] = info - i = i + 1 - end - - return t -end - - -local comboboxCount = 1 -function LAMCreateControl.dropdown(parent, dropdownData, controlName) - local control = wm:CreateTopLevelWindow(controlName or dropdownData.reference) - control:SetParent(parent.scroll or parent) - control:SetMouseEnabled(true) - --control.tooltipText = dropdownData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(dropdownData.name) - - control.combobox = wm:CreateControlFromVirtual(parent:GetName().."Combobox"..comboboxCount, control, "ZO_ComboBox") - comboboxCount = comboboxCount + 1 - local combobox = control.combobox - combobox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - combobox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) - control.dropdown = ZO_ComboBox_ObjectFromContainer(combobox) - local dropdown = control.dropdown - if dropdownData.sort then - local sortInfo = GrabSortingInfo(dropdownData.sort) - local sortType, sortOrder = sortInfo[1], sortInfo[2] - dropdown:SetSortOrder(sortOrder == "up" and ZO_SORT_ORDER_UP or ZO_SORT_ORDER_DOWN, sortType == "name" and ZO_SORT_BY_NAME or ZO_SORT_BY_NAME_NUMERIC) - end - - local isHalfWidth = dropdownData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - label:SetDimensions(250, 26) - combobox:SetDimensions(225, 26) - combobox:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) - else - control:SetDimensions(510, 30) - label:SetDimensions(300, 26) - combobox:SetDimensions(200, 26) - combobox:SetAnchor(TOPRIGHT) - end - - if dropdownData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, combobox, LEFT, -5, 0) - --control.warning.tooltipText = dropdownData.warning - control.warning.data = {tooltipText = dropdownData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = dropdownData - control.data.tooltipText = dropdownData.tooltip - - if dropdownData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateChoices = UpdateChoices - control:UpdateChoices(dropdownData.choices) - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/editbox.lua b/lib/LibAddonMenu-2.0/controls/editbox.lua deleted file mode 100644 index 25396ff..0000000 --- a/lib/LibAddonMenu-2.0/controls/editbox.lua +++ /dev/null @@ -1,155 +0,0 @@ ---[[editboxData = { - type = "editbox", - name = "My Editbox", - tooltip = "Editbox's tooltip text.", - getFunc = function() return db.text end, - setFunc = function(text) db.text = text doStuff() end, - isMultiline = true, --boolean - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.text, --(optional) - reference = "MyAddonEditbox" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 6 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("editbox", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local tinsert = table.insert - - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.editbox:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.editbox:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end - --control.editbox:SetEditEnabled(not disable) - control.editbox:SetMouseEnabled(not disable) -end - -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - control.editbox:SetText(value) - elseif value then - control.data.setFunc(value) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - control.editbox:SetText(value) - end -end - - -function LAMCreateControl.editbox(parent, editboxData, controlName) - local control = wm:CreateTopLevelWindow(controlName or editboxData.reference) - control:SetParent(parent.scroll or parent) - control:SetMouseEnabled(true) - control:SetResizeToFitDescendents(true) - --control.tooltipText = editboxData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(editboxData.name) - - control.bg = wm:CreateControlFromVirtual(nil, control, "ZO_EditBackdrop") - local bg = control.bg - - if editboxData.isMultiline then - control.editbox = wm:CreateControlFromVirtual(nil, bg, "ZO_DefaultEditMultiLineForBackdrop") - control.editbox:SetHandler("OnMouseWheel", function(self, delta) - if self:HasFocus() then --only set focus to new spots if the editbox is currently in use - local cursorPos = self:GetCursorPosition() - local text = self:GetText() - local textLen = text:len() - local newPos - if delta > 0 then --scrolling up - local reverseText = text:reverse() - local revCursorPos = textLen - cursorPos - local revPos = reverseText:find("\n", revCursorPos+1) - newPos = revPos and textLen - revPos - else --scrolling down - newPos = text:find("\n", cursorPos+1) - end - if newPos then --if we found a new line, then scroll, otherwise don't - self:SetCursorPosition(newPos) - end - end - end) - else - control.editbox = wm:CreateControlFromVirtual(nil, bg, "ZO_DefaultEditForBackdrop") - end - local editbox = control.editbox - editbox:SetText(editboxData.getFunc()) - editbox:SetMaxInputChars(3000) - editbox:SetHandler("OnFocusLost", function(self) control:UpdateValue(false, self:GetText()) end) - editbox:SetHandler("OnEscape", function(self) self:LoseFocus() control:UpdateValue(false, self:GetText()) end) - editbox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - editbox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) - - local isHalfWidth = editboxData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - label:SetDimensions(250, 26) - bg:SetDimensions(225, editboxData.isMultiline and 74 or 24) - bg:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) - if editboxData.isMultiline then - editbox:SetDimensionConstraints(210, 74, 210, 500) - end - else - control:SetDimensions(510, 30) - label:SetDimensions(300, 26) - bg:SetDimensions(200, editboxData.isMultiline and 100 or 24) - bg:SetAnchor(TOPRIGHT) - if editboxData.isMultiline then - editbox:SetDimensionConstraints(185, 100, 185, 500) - end - end - - if editboxData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(TOPRIGHT, control.bg, TOPLEFT, -5, 0) - --control.warning.tooltipText = editboxData.warning - control.warning.data = {tooltipText = editboxData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = editboxData - control.data.tooltipText = editboxData.tooltip - - if editboxData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/header.lua b/lib/LibAddonMenu-2.0/controls/header.lua deleted file mode 100644 index 98df539..0000000 --- a/lib/LibAddonMenu-2.0/controls/header.lua +++ /dev/null @@ -1,47 +0,0 @@ ---[[headerData = { - type = "header", - name = "My Header", - width = "full", --or "half" (optional) - reference = "MyAddonHeader" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 4 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("header", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local tinsert = table.insert - -local function UpdateValue(control) - control.header:SetText(control.data.name) -end - -function LAMCreateControl.header(parent, headerData, controlName) - local control = wm:CreateTopLevelWindow(controlName or headerData.reference) - control:SetParent(parent.scroll or parent) - local isHalfWidth = headerData.width == "half" - control:SetDimensions(isHalfWidth and 250 or 510, 30) - - control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider") - local divider = control.divider - divider:SetWidth(isHalfWidth and 250 or 510) - divider:SetAnchor(TOPLEFT) - - control.header = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") - local header = control.header - header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT) - header:SetAnchor(BOTTOMRIGHT) - header:SetText(headerData.name) - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = headerData - - control.UpdateValue = UpdateValue - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/panel.lua b/lib/LibAddonMenu-2.0/controls/panel.lua deleted file mode 100644 index 158fd8d..0000000 --- a/lib/LibAddonMenu-2.0/controls/panel.lua +++ /dev/null @@ -1,138 +0,0 @@ ---[[panelData = { - type = "panel", - name = "Window Title", - displayName = "My Longer Window Title", --(optional) (can be useful for long addon names or if you want to colorize it) - author = "Seerah", --(optional) - version = "2.0", --(optional) - slashCommand = "/myaddon", --(optional) will register a keybind to open to this panel (don't forget to include the slash!) - registerForRefresh = true, --boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown) - registerForDefaults = true, --boolean (optional) (will set all options controls back to default values) - resetFunc = function() print("defaults reset") end, --(optional) custom function to run after settings are reset to defaults -} ]] - - -local widgetVersion = 8 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("panel", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER - -local function RefreshPanel(control) - local panel = control.panel or control --callback can be fired by a single control or by the panel showing - local panelControls = panel.controlsToRefresh - - for i = 1, #panelControls do - local updateControl = panelControls[i] - if updateControl ~= control then - if updateControl.UpdateValue then - updateControl:UpdateValue() - end - if updateControl.UpdateDisabled then - updateControl:UpdateDisabled() - end - end - end -end - -local function ForceDefaults(panel) - local panelControls = panel.controlsToRefresh - - for i = 1, #panelControls do - local updateControl = panelControls[i] - if updateControl.UpdateValue and updateControl.data.default ~= nil then - updateControl:UpdateValue(true) - end - end - - if panel.data.resetFunc then - panel.data.resetFunc() - end - - cm:FireCallbacks("LAM-RefreshPanel", panel) -end -ESO_Dialogs["LAM_DEFAULTS"] = { - title = { - text = SI_OPTIONS_RESET_TITLE, - }, - mainText = { - text = SI_OPTIONS_RESET_PROMPT, - align = TEXT_ALIGN_CENTER, - }, - buttons = { - [1] = { - text = SI_OPTIONS_RESET, - callback = function(dialog) ForceDefaults(dialog.data[1]) end, - }, - [2] = { - text = SI_DIALOG_CANCEL, - }, - }, -} - -local callbackRegistered = false -LAMCreateControl.scrollCount = LAMCreateControl.scrollCount or 1 -function LAMCreateControl.panel(parent, panelData, controlName) - local control = wm:CreateTopLevelWindow(controlName) - control:SetParent(parent) - - control.bg = wm:CreateControl(nil, control, CT_BACKDROP) - local bg = control.bg - bg:SetAnchorFill() - bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) - bg:SetCenterColor(0, 0, 0, 0) - - control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") - local label = control.label - label:SetAnchor(TOPLEFT, control, TOPLEFT, 10, 10) - label:SetText(panelData.displayName and panelData.displayName or panelData.name) - - if panelData.author or panelData.version then - control.info = wm:CreateControl(nil, control, CT_LABEL) - local info = control.info - info:SetFont("$(CHAT_FONT)|14|soft-shadow-thin") - info:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) - info:SetHeight(13) - info:SetAnchor(TOPRIGHT, control, BOTTOMRIGHT, -5, 2) - if panelData.author and panelData.version then - --info:SetText("Version: "..panelData.version.." - "..GetString(SI_ADDON_MANAGER_AUTHOR)..": "..panelData.author) - info:SetText(string.format("Version: %s - %s: %s", panelData.version, GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) - elseif panelData.author then - info:SetText(string.format("%s: %s", GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) - else - info:SetText("Version: "..panelData.version) - end - end - - control.container = wm:CreateControlFromVirtual("LAMAddonPanelContainer"..LAMCreateControl.scrollCount, control, "ZO_ScrollContainer") - LAMCreateControl.scrollCount = LAMCreateControl.scrollCount + 1 - local container = control.container - container:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 20) - container:SetAnchor(BOTTOMRIGHT, control, BOTTOMRIGHT, -3, -3) - control.scroll = GetControl(control.container, "ScrollChild") - control.scroll:SetResizeToFitPadding(0, 20) - - if panelData.registerForDefaults then - control.defaultButton = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultTextButton") - local defaultButton = control.defaultButton - defaultButton:SetFont("ZoFontDialogKeybindDescription") - defaultButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) - --defaultButton:SetText("Reset To Defaults") - defaultButton:SetText(GetString(SI_OPTIONS_RESET_TITLE)) - defaultButton:SetDimensions(200, 30) - defaultButton:SetAnchor(TOPLEFT, control, BOTTOMLEFT, 0, 2) - defaultButton:SetHandler("OnClicked", function() - ZO_Dialogs_ShowDialog("LAM_DEFAULTS", {control}) - end) - end - - if panelData.registerForRefresh and not callbackRegistered then --don't want to register our callback more than once - cm:RegisterCallback("LAM-RefreshPanel", RefreshPanel) - callbackRegistered = true - end - - control.data = panelData - control.controlsToRefresh = {} - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/slider.lua b/lib/LibAddonMenu-2.0/controls/slider.lua deleted file mode 100644 index e7bc01c..0000000 --- a/lib/LibAddonMenu-2.0/controls/slider.lua +++ /dev/null @@ -1,184 +0,0 @@ ---[[sliderData = { - type = "slider", - name = "My Slider", - tooltip = "Slider's tooltip text.", - min = 0, - max = 20, - step = 1, --(optional) - getFunc = function() return db.var end, - setFunc = function(value) db.var = value doStuff() end, - width = "full", --or "half" (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonSlider" --(optional) unique global reference to control -} ]] - - -local widgetVersion = 5 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("slider", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local cm = CALLBACK_MANAGER -local round = zo_round -local strformat = string.format -local tinsert = table.insert - -local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.slider:SetEnabled(not disable) - control.slidervalue:SetEditEnabled(not disable) - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.minText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.maxText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.slidervalue:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.minText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.maxText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.slidervalue:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end -end - -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - elseif value and value >= control.data.min and value <= control.data.max then - control.data.setFunc(value) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - end - - control.slider:SetValue(value) - control.slidervalue:SetText(value) -end - - -function LAMCreateControl.slider(parent, sliderData, controlName) - local control = wm:CreateTopLevelWindow(controlName or sliderData.reference) - control:SetParent(parent.scroll or parent) - local isHalfWidth = sliderData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - else - control:SetDimensions(510, 40) - end - control:SetMouseEnabled(true) - --control.tooltipText = sliderData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetFont("ZoFontWinH4") - label:SetDimensions(isHalfWidth and 250 or 300, 26) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetAnchor(isHalfWidth and TOPLEFT or LEFT) - label:SetText(sliderData.name) - - --skipping creating the backdrop... Is this the actual slider texture? - control.slider = wm:CreateControl(nil, control, CT_SLIDER) - local slider = control.slider - slider:SetDimensions(190, 14) - if isHalfWidth then - slider:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT, -5, 2) - else - slider:SetAnchor(RIGHT, control, RIGHT, -5, -5) - end - slider:SetMouseEnabled(true) - slider:SetOrientation(ORIENTATION_HORIZONTAL) - --put nil for highlighted texture file path, and what look to be texture coords - slider:SetThumbTexture("EsoUI\\Art\\Miscellaneous\\scrollbox_elevator.dds", "EsoUI\\Art\\Miscellaneous\\scrollbox_elevator_disabled.dds", nil, 8, 16) - local minValue = sliderData.min - local maxValue = sliderData.max - slider:SetMinMax(minValue, maxValue) - slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseExit(control) end) - - slider.bg = wm:CreateControl(nil, slider, CT_BACKDROP) - local bg = slider.bg - bg:SetCenterColor(0, 0, 0) - bg:SetAnchor(TOPLEFT, slider, TOPLEFT, 0, 4) - bg:SetAnchor(BOTTOMRIGHT, slider, BOTTOMRIGHT, 0, -4) - bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-SliderBackdrop.dds", 32, 4) - - control.minText = wm:CreateControl(nil, slider, CT_LABEL) - local minText = control.minText - minText:SetFont("ZoFontGameSmall") - minText:SetAnchor(TOPLEFT, slider, BOTTOMLEFT) - minText:SetText(sliderData.min) - - control.maxText = wm:CreateControl(nil, slider, CT_LABEL) - local maxText = control.maxText - maxText:SetFont("ZoFontGameSmall") - maxText:SetAnchor(TOPRIGHT, slider, BOTTOMRIGHT) - maxText:SetText(sliderData.max) - - control.slidervalueBG = wm:CreateControlFromVirtual(nil, slider, "ZO_EditBackdrop") - control.slidervalueBG:SetDimensions(50, 16) - control.slidervalueBG:SetAnchor(TOP, slider, BOTTOM, 0, 0) - control.slidervalue = wm:CreateControlFromVirtual(nil, control.slidervalueBG, "ZO_DefaultEditForBackdrop") - local slidervalue = control.slidervalue - slidervalue:ClearAnchors() - slidervalue:SetAnchor(TOPLEFT, slidervaluebg, TOPLEFT, 3, 1) - slidervalue:SetAnchor(BOTTOMRIGHT, slidervaluebg, BOTTOMRIGHT, -3, -1) - slidervalue:SetTextType(TEXT_TYPE_NUMERIC) - slidervalue:SetFont("ZoFontGameSmall") - slidervalue:SetHandler("OnEscape", function(self) - self:LoseFocus() - control:UpdateValue() - end) - slidervalue:SetHandler("OnEnter", function(self) - self:LoseFocus() - control:UpdateValue(false, tonumber(self:GetText())) - end) - - local range = maxValue - minValue - slider:SetValueStep(sliderData.step or 1) - slider:SetHandler("OnValueChanged", function(self, value, eventReason) - if eventReason == EVENT_REASON_SOFTWARE then return end - self:SetValue(value) --do we actually need this line? - slidervalue:SetText(value) - end) - slider:SetHandler("OnSliderReleased", function(self, value) - --sliderData.setFunc(value) - control:UpdateValue(false, value) --does this work here instead? - end) - - if sliderData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, slider, LEFT, -5, 0) - --control.warning.tooltipText = sliderData.warning - control.warning.data = {tooltipText = sliderData.warning} - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is the submenu's parent - control.data = sliderData - control.data.tooltipText = sliderData.tooltip - - if sliderData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control:UpdateValue() - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/controls/submenu.lua b/lib/LibAddonMenu-2.0/controls/submenu.lua deleted file mode 100644 index ee2b777..0000000 --- a/lib/LibAddonMenu-2.0/controls/submenu.lua +++ /dev/null @@ -1,123 +0,0 @@ ---[[submenuData = { - type = "submenu", - name = "Submenu Title", - tooltip = "My submenu tooltip", --(optional) - controls = {sliderData, buttonData} --(optional) used by LAM - reference = "MyAddonSubmenu" --(optional) unique global reference to control -} ]] - -local widgetVersion = 7 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("submenu", widgetVersion) then return end - -local wm = WINDOW_MANAGER -local am = ANIMATION_MANAGER -local tinsert = table.insert - - -local function UpdateValue(control) - control.label:SetText(control.data.name) - if control.data.tooltip then - --control.label.tooltipText = control.data.tooltip - control.label.data = {tooltipText = control.data.tooltip} - end -end - -local function AnimateSubmenu(clicked) - local control = clicked:GetParent() - control.open = not control.open - - if control.open then - control.animation:PlayFromStart() - else - control.animation:PlayFromEnd() - end -end - - -function LAMCreateControl.submenu(parent, submenuData, controlName) - local control = wm:CreateTopLevelWindow(controlName or submenuData.reference) - control:SetParent(parent.scroll or parent) - control.panel = parent - control:SetDimensions(523, 40) - - control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") - local label = control.label - label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) - label:SetDimensions(520, 30) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(submenuData.name) - label:SetMouseEnabled(true) - if submenuData.tooltip then - --label.tooltipText = submenuData.tooltip - label.data = {tooltipText = submenuData.tooltip} - label:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - label:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - end - - control.scroll = wm:CreateControl(nil, control, CT_SCROLL) - local scroll = control.scroll - scroll:SetParent(control) - scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) - scroll:SetDimensionConstraints(525, 0, 525, 2500) - - control.bg = wm:CreateControl(nil, label, CT_BACKDROP) - local bg = control.bg - bg:SetAnchor(TOPLEFT, label, TOPLEFT, -5, -5) - bg:SetAnchor(BOTTOMRIGHT, scroll, BOTTOMRIGHT, -7, 0) - bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-Border.dds", 128, 16) - bg:SetCenterTexture("EsoUI\\Art\\Tooltips\\UI-TooltipCenter.dds") - bg:SetInsets(16, 16, -16, -16) - - control.arrow = wm:CreateControl(nil, bg, CT_TEXTURE) - local arrow = control.arrow - arrow:SetDimensions(28, 28) - arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") --list_sortup for the other way - arrow:SetAnchor(TOPRIGHT, bg, TOPRIGHT, -5, 5) - - --figure out the cool animation later... - control.animation = am:CreateTimeline() - local animation = control.animation - animation:SetPlaybackType(ANIMATION_SIZE, 0) --2nd arg = loop count - --animation:SetDuration(1) - --animation:SetEasingFunction(ZO_LinearEase) --is this needed? - --animation:SetHeightStartAndEnd(40, 80) --SetStartAndEndHeight - --animation:SetStartAndEndHeight(40, 80) --SetStartAndEndHeight - --animation:SetAnimatedControl(control) - - control:SetResizeToFitDescendents(true) - control.open = false - label:SetHandler("OnMouseUp", AnimateSubmenu) - animation:SetHandler("OnStop", function(self, completedPlaying) - scroll:SetResizeToFitDescendents(control.open) - if control.open then - control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortup.dds") - scroll:SetResizeToFitPadding(5, 20) - else - control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") - scroll:SetResizeToFitPadding(5, 0) - scroll:SetHeight(0) - end - end) - - --small strip at the bottom of the submenu that you can click to close it - control.btmToggle = wm:CreateControl(nil, control, CT_TEXTURE) - local btmToggle = control.btmToggle - btmToggle:SetMouseEnabled(true) - btmToggle:SetAnchor(BOTTOMLEFT, control.scroll, BOTTOMLEFT) - btmToggle:SetAnchor(BOTTOMRIGHT, control.scroll, BOTTOMRIGHT) - btmToggle:SetHeight(15) - btmToggle:SetAlpha(0) - btmToggle:SetHandler("OnMouseUp", AnimateSubmenu) - - control.data = submenuData - - control.UpdateValue = UpdateValue - - if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - - return control -end - diff --git a/lib/LibAddonMenu-2.0/controls/texture.lua b/lib/LibAddonMenu-2.0/controls/texture.lua deleted file mode 100644 index efb29ec..0000000 --- a/lib/LibAddonMenu-2.0/controls/texture.lua +++ /dev/null @@ -1,51 +0,0 @@ ---[[textureData = { - type = "texture", - image = "file/path.dds", - imageWidth = 64, --max of 250 for half width, 510 for full - imageHeight = 32, --max of 100 - tooltip = "Image's tooltip text.", --(optional) - width = "full", --or "half" (optional) - reference = "MyAddonTexture" --(optional) unique global reference to control -} ]] - ---add texture coords support? - -local widgetVersion = 5 -local LAM = LibStub("LibAddonMenu-2.0") -if not LAM:RegisterWidget("texture", widgetVersion) then return end - -local wm = WINDOW_MANAGER - -function LAMCreateControl.texture(parent, textureData, controlName) - local control = wm:CreateTopLevelWindow(controlName or textureData.reference) - control:SetResizeToFitDescendents(true) - control:SetParent(parent.scroll or parent) - - local isHalfWidth = textureData.width == "half" - if isHalfWidth then - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 30, 510, 100) - control:SetDimensions(510, 30) - end - - control.texture = wm:CreateControl(nil, control, CT_TEXTURE) - local texture = control.texture - texture:SetAnchor(CENTER) - texture:SetDimensions(textureData.imageWidth, textureData.imageHeight) - texture:SetTexture(textureData.image) - - if textureData.tooltip then - texture:SetMouseEnabled(true) - --texture.tooltipText = textureData.tooltip - texture.data = {tooltipText = textureData.tooltip} - texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseExit) - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = textureData - - return control -end \ No newline at end of file diff --git a/lib/LibStub.lua b/lib/LibStub.lua deleted file mode 100644 index 4dbff7b..0000000 --- a/lib/LibStub.lua +++ /dev/null @@ -1,34 +0,0 @@ --- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info --- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke --- LibStub developed for World of Warcraft by above members of the WowAce community. --- Ported to Elder Scrolls Online by Seerah - -local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! -local LibStub = _G[LIBSTUB_MAJOR] - -local strformat = string.format -if not LibStub or LibStub.minor < LIBSTUB_MINOR then - LibStub = LibStub or {libs = {}, minors = {} } - _G[LIBSTUB_MAJOR] = LibStub - LibStub.minor = LIBSTUB_MINOR - - function LibStub:NewLibrary(major, minor) - assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") - minor = assert(tonumber(zo_strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") - - local oldminor = self.minors[major] - if oldminor and oldminor >= minor then return nil end - self.minors[major], self.libs[major] = minor, self.libs[major] or {} - return self.libs[major], oldminor - end - - function LibStub:GetLibrary(major, silent) - if not self.libs[major] and not silent then - error(strformat("Cannot find a library instance of %q.", tostring(major)), 2) - end - return self.libs[major], self.minors[major] - end - - function LibStub:IterateLibraries() return pairs(self.libs) end - setmetatable(LibStub, { __call = LibStub.GetLibrary }) -end diff --git a/lua/ALERT.lua b/lua/ALERT.lua deleted file mode 100644 index 7c184a1..0000000 --- a/lua/ALERT.lua +++ /dev/null @@ -1,111 +0,0 @@ --- Craft Research Timer (CRT) by @aTo (EU) --- v0.4.8 - - -function CRT.Research_Alert(k, id_craft, simcraft, start) - if (start == true) then - for i = 0, 2, 1 do - local MaxResearch = CRT.SV.data.Craft[k][i].MaxResearch - local Simu_craft = CRT.SV.data.Craft[k][i].Simu_craft - if(Simu_craft < MaxResearch) then - if (i == 0 and CRT.SV.Settings.ALERT.BS == true) then - local msg = "Warning only "..Simu_craft.." / "..MaxResearch.." on Blacksmithing ( "..k.." )" - CRT.UI.ALERT_WD:AddMessage(msg, CRT.SV.Settings.ALERT.Color.r, CRT.SV.Settings.ALERT.Color.g, CRT.SV.Settings.ALERT.Color.b) - elseif (i == 1 and CRT.SV.Settings.ALERT.CL == true) then - local msg = "Warning only "..Simu_craft.." / "..MaxResearch.." on Clothing ( "..k.." )" - CRT.UI.ALERT_WD:AddMessage(msg, CRT.SV.Settings.ALERT.Color.r, CRT.SV.Settings.ALERT.Color.g, CRT.SV.Settings.ALERT.Color.b) - elseif (i == 2 and CRT.SV.Settings.ALERT.WO == true) then - local msg = "Warning only "..Simu_craft.." / "..MaxResearch.." on Woodworking ( "..k.." )" - CRT.UI.ALERT_WD:AddMessage(msg, CRT.SV.Settings.ALERT.Color.r, CRT.SV.Settings.ALERT.Color.g, CRT.SV.Settings.ALERT.Color.b) - end - end - end - else - - - -- UPDATE SIMU_CRAFT - local MaxResearch = CRT.SV.data.Craft[k][id_craft].MaxResearch - local Simu_craft = CRT.SV.data.Craft[k][id_craft].Simu_craft - 1 -- set new simucraft - CRT.SV.data.Craft[k][id_craft].Simu_craft = Simu_craft -- save new simucraft - if (id_craft == 0) then - id_text = "BS_Text" - elseif(id_craft == 1) then - id_text = "CL_Text" - elseif(id_craft == 2) then - id_text = "WO_Text" - end - - CRT.UI.GRID_WD[k][id_craft][0][id_text]:SetText(" "..Simu_craft.." / "..MaxResearch) - - local Item_name = CRT.SV.data.Craft[k][id_craft][simcraft]["Item_name"] - local Trait_name = CRT.SV.data.Craft[k][id_craft][simcraft]["Trait_name"] - local msg = CRT.L["Completed"].." "..k.." ( "..Item_name.." - "..Trait_name.." )" - CRT.UI.ALERT_WD:AddMessage(msg,1,0,0) - end -end - -function CRT.Alert_Create() - CRT.UI.ALERT_TLW = WINDOW_MANAGER:CreateTopLevelWindow("CRT_ALERT_TLW") - CRT.UI.ALERT_TLW:SetDimensions(800,300) - CRT.UI.ALERT_TLW:SetHidden(not CRT.SV.Settings.ALERT.hidden) - CRT.UI.ALERT_TLW:SetClampedToScreen(false) - CRT.UI.ALERT_TLW:SetMovable(CRT.SV.Settings.lock) - CRT.UI.ALERT_TLW:SetMouseEnabled(true) - CRT.UI.ALERT_TLW:SetDrawLayer(0) - CRT.UI.ALERT_TLW:SetScale(1) - CRT.UI.ALERT_TLW:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, CRT.SV.Settings.ALERT.offset.X, CRT.SV.Settings.ALERT.offset.Y) - CRT.UI.ALERT_TLW:SetHandler("OnMouseUp", function(self) CRT.Save_position("ALERT")end) - - --Text Buffer - CRT.UI.ALERT_WD = WINDOW_MANAGER:CreateControl("CRT_ALERT_WB",CRT.UI.ALERT_TLW,CT_TEXTBUFFER) - CRT.UI.ALERT_WD:SetDimensions( 800, 300 ) - CRT.UI.ALERT_WD:SetFont( "ZoFontGame" ) - CRT.UI.ALERT_WD:SetAnchor(TOPLEFT,lsSum,TOPLEFT,0,0) - CRT.UI.ALERT_WD:SetLineFade(10,2) - CRT.UI.ALERT_WD:SetHorizontalAlignment(1) - CRT.UI.ALERT_WD:SetClearBufferAfterFadeout(true) - -- CRT_ALERT_WB:SetLinkEnabled( true ) - - CRT.UI.ALERT_BD = WINDOW_MANAGER:CreateControl("CRT_ALERT_BD",CRT.UI.ALERT_TLW,CT_BACKDROP) - CRT.UI.ALERT_BD:SetHidden(not CRT.SV.Settings.ALERT.preview) - CRT.UI.ALERT_BD:SetDimensions( 800 , 300 ) - CRT.UI.ALERT_BD:SetCenterColor(0.1,0.1,0.1,1) - CRT.UI.ALERT_BD:SetEdgeColor(0,0,0,1) - CRT.UI.ALERT_BD:SetEdgeTexture("", 8, 1, 1) - CRT.UI.ALERT_BD:SetAlpha(0.6) - CRT.UI.ALERT_BD:SetAnchor(TOPLEFT,lsSum,TOPLEFT,0,0) -end - -function CRT.ALERT_Update(timestamp) - local k,j - for k, _ in pairs(CRT.SV.data.Craft) do - if (CRT.SV.data.Craft[CRT.playername]["Start"] == true) then - local CRT_Current_PlayerPosition = GetMapPlayerPosition("player") - if (CRT_Current_PlayerPosition ~= CRT_Start_PlayerPosition) then - CRT.SV.data.Craft[CRT.playername]["Start"] = false - CRT.Research_Alert(CRT.playername, nil, nil, true) - for j, _ in pairs(CRT.SV.data.Craft) do - if ((k ~= CRT.playername) and (CRT.SV.data.Craft[k][0].Simu_craft ~= 0 or CRT.SV.data.Craft[k][1].Simu_craft ~= 0 or CRT.SV.data.Craft[k][2].Simu_craft ~= 0)) then - CRT.Research_Alert(k, nil, nil, true) - end - end - end - end - - for id_craft = 0, 2,1 do - for simcraft = 1, 3,1 do - if (CRT.SV.data.Craft[k][id_craft][simcraft] ~= nil)then - local currenttimer = CRT.SV.data.Craft[k][id_craft][simcraft]["EndTimeStamp"] - timestamp - 1 - - if (currenttimer <= 0) then - - if (CRT.SV.data.Craft[k][id_craft][simcraft]["Alert"] == true) then - CRT.SV.data.Craft[k][id_craft][simcraft]["Alert"] = false - CRT.Research_Alert(k, id_craft, simcraft, false) - end - end - end - end - end - end -end \ No newline at end of file diff --git a/lua/CORE.lua b/lua/CORE.lua index 03a014d..696dee4 100644 --- a/lua/CORE.lua +++ b/lua/CORE.lua @@ -1,22 +1,43 @@ -- Craft Research Timer (CRT) by @aTo (EU) -- v0.4.11 - - -function CRT.Collect_Data() - CRT.Info_Research(CRAFTING_TYPE_BLACKSMITHING, 0) - CRT.Info_Research(CRAFTING_TYPE_CLOTHIER, 1) - CRT.Info_Research(CRAFTING_TYPE_WOODWORKING, 2) +RT = { + name = "ResearchTimer", + font = "ZoFontGame", + cmdsetup = "/rt", + svName = "ResearchTimer", + version = "v1", + playername = "", + font = "ZoFontGame", + interval = 20, + width = 100, + height = 80, + UI = {}, + SV={}, + collect=0 +} + + +RT.UI.GRID_TLW = {} +RT.UI.GRID_BD = {} +RT.UI.GRID_WD = {} +RT.UI.GRID_BTN = {} + + +function RT.Collect_Data() + RT.Info_Research(CRAFTING_TYPE_BLACKSMITHING, 0) + RT.Info_Research(CRAFTING_TYPE_CLOTHIER, 1) + RT.Info_Research(CRAFTING_TYPE_WOODWORKING, 2) end -function CRT.Info_Research(craft_type,id_craft) +function RT.Info_Research(craft_type,id_craft) local Simu_craft = 0 local ResearchLines, ResearchTrait local MaxResearch = GetMaxSimultaneousSmithingResearch(craft_type) local nbtype = GetNumSmithingResearchLines(craft_type) --Nombre de item craftable pour un craft(ex couture: jambe/robe/ect) - CRT.SV.data.Craft[CRT.playername][id_craft] = {} - CRT.SV.data.Craft[CRT.playername][id_craft].doing = {} + RT.SV.data.Craft[RT.playername][id_craft] = {} + RT.SV.data.Craft[RT.playername][id_craft].doing = {} for ResearchLines = 1, nbtype, 1 do local item_name, item_icon, numTraits, timeRequiredForNextResearchSecs = GetSmithingResearchLineInfo(craft_type, ResearchLines) for ResearchTrait = 1, numTraits, 1 do @@ -31,60 +52,60 @@ function CRT.Info_Research(craft_type,id_craft) - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft] = {} - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft]["PlayerName"] = CRT.playername - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft]["Alert"] = true - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft]["EndTimeStamp"] = GetTimeStamp() + timeRemaining - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft]["Item_name"] = string.sub(item_name, 1, 18) - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft]["Item_icon"] = item_icon - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft]["Trait_name"] = trait_name - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft]["Trait_icon"] = trait_icon - CRT.SV.data.Craft[CRT.playername][id_craft].doing[Simu_craft]["Trait_description"] = trait_description + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft] = {} + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft]["PlayerName"] = RT.playername + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft]["Alert"] = true + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft]["EndTimeStamp"] = GetTimeStamp() + timeRemaining + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft]["Item_name"] = string.sub(item_name, 1, 18) + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft]["Item_icon"] = item_icon + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft]["Trait_name"] = trait_name + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft]["Trait_icon"] = trait_icon + RT.SV.data.Craft[RT.playername][id_craft].doing[Simu_craft]["Trait_description"] = trait_description end end end - CRT.SV.data.Craft[CRT.playername][id_craft].MaxResearch = MaxResearch - CRT.SV.data.Craft[CRT.playername][id_craft].Simu_craft = Simu_craft + RT.SV.data.Craft[RT.playername][id_craft].MaxResearch = MaxResearch + RT.SV.data.Craft[RT.playername][id_craft].Simu_craft = Simu_craft end -function CRT.Char_sort() -- Produce a sorted list for display - CRT.CharsInOrder = {} - for k, _ in pairs(CRT.SV.data.Craft) do - table.insert(CRT.CharsInOrder,k) +function RT.Char_sort() -- Produce a sorted list for display + RT.CharsInOrder = {} + for k, _ in pairs(RT.SV.data.Craft) do + table.insert(RT.CharsInOrder,k) end - if CRT.SortFunction ~= nil then - table.sort(CRT.CharsInOrder, CRT.SortFunction) + if RT.SortFunction ~= nil then + table.sort(RT.CharsInOrder, RT.SortFunction) end end --- for each character, find the research completing soonest and set CRT.SV.data.Craft[Char].shortest -function CRT.Set_Shortest() +-- for each character, find the research completing soonest and set RT.SV.data.Craft[Char].shortest +function RT.Set_Shortest() local char,craft,shortest, remaining,v - for char,_ in pairs (CRT.SV.data.Craft) do + for char,_ in pairs (RT.SV.data.Craft) do shortest = 9999999999 for craft =0,2, 1 do - for _,v in pairs (CRT.SV.data.Craft[char][craft].doing) do + for _,v in pairs (RT.SV.data.Craft[char][craft].doing) do remaining = v["EndTimeStamp"] - GetTimeStamp() if shortest > remaining then shortest = remaining end end end - CRT.SV.data.Craft[char].shortest = shortest + RT.SV.data.Craft[char].shortest = shortest end end -function CRT.Research_started() -- Triggered by Event +function RT.Research_started() -- Triggered by Event -- erase all data for this character - CRT.SV.data.Craft[CRT.playername] = {} + RT.SV.data.Craft[RT.playername] = {} -- Collect new data - CRT.Collect_Data() + RT.Collect_Data() - if (CRT.UI.GRID_WD[CRT.playername] == nil) then - CRT.GRID_Create_Character(CRT.playername) + if (RT.UI.GRID_WD[RT.playername] == nil) then + RT.GRID_Create_Character(RT.playername) end - CRT.Set_Shortest() - CRT.UI.GRID_WD[CRT.playername].label:SetText(string.upper(CRT.playername)) -- remove highlighting + RT.Set_Shortest() + RT.UI.GRID_WD[RT.playername].label:SetText(string.upper(RT.playername)) -- remove highlighting end diff --git a/lua/CRAFT.lua b/lua/CRAFT.lua deleted file mode 100644 index f68c9f6..0000000 --- a/lua/CRAFT.lua +++ /dev/null @@ -1,191 +0,0 @@ --- Craft Research Timer (CRT) by @aTo (EU) --- v0.4.8 - -function CRT.CRAFT_Create() - - if (CRT.SV.Settings.mode == "Icon") then - CRT.mode_width = CRT.SV.Settings.icon_width - CRT.mode_height = CRT.SV.Settings.icon_height - CRT.vertical_move = 30 - elseif (CRT.SV.Settings.mode == "Text") then - CRT.mode_width = CRT.SV.Settings.text_width - CRT.mode_height = CRT.SV.Settings.text_height - CRT.vertical_move = 0 - end - - --- MAIN WINDOW --- - local scale = {} - scale[0] = CRT.SV.Settings.BS.Scale - scale[1] = CRT.SV.Settings.CL.Scale - scale[2] = CRT.SV.Settings.WO.Scale - local alpha = {} - alpha[0] = CRT.SV.Settings.BS.BackdropAlpha - alpha[1] = CRT.SV.Settings.CL.BackdropAlpha - alpha[2] = CRT.SV.Settings.WO.BackdropAlpha - - - for id_craft = 0, 2, 1 do - CRT.UI.CRAFT_TLW[id_craft] = WINDOW_MANAGER:CreateTopLevelWindow("CRT_CRAFT_TLW_"..id_craft) - CRT.UI.CRAFT_TLW[id_craft]:SetDimensions(CRT.mode_width,CRT.mode_height) - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(false) - CRT.UI.CRAFT_TLW[id_craft]:SetClampedToScreen(false) - CRT.UI.CRAFT_TLW[id_craft]:SetMovable(CRT.SV.Settings.lock) - CRT.UI.CRAFT_TLW[id_craft]:SetMouseEnabled(true) - CRT.UI.CRAFT_TLW[id_craft]:SetDrawLayer(1) - CRT.UI.CRAFT_TLW[id_craft]:SetScale(scale[id_craft]) - - if (id_craft == 0) then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(not CRT.SV.Settings.BS.craft) - CRT.UI.CRAFT_TLW[id_craft]:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, CRT.SV.Settings.BS.offset.X, CRT.SV.Settings.BS.offset.Y) - CRT.UI.CRAFT_TLW[id_craft]:SetHandler("OnMouseUp", function(self) CRT.Save_position(id_craft)end) - elseif(id_craft == 1) then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(not CRT.SV.Settings.CL.craft) - CRT.UI.CRAFT_TLW[id_craft]:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, CRT.SV.Settings.CL.offset.X, CRT.SV.Settings.CL.offset.Y) - CRT.UI.CRAFT_TLW[id_craft]:SetHandler("OnMouseUp", function(self) CRT.Save_position(id_craft)end) - elseif(id_craft == 2) then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(not CRT.SV.Settings.WO.craft) - CRT.UI.CRAFT_TLW[id_craft]:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, CRT.SV.Settings.WO.offset.X, CRT.SV.Settings.WO.offset.Y) - CRT.UI.CRAFT_TLW[id_craft]:SetHandler("OnMouseUp", function(self) CRT.Save_position(id_craft)end) - end - - CRT.UI.CRAFT_BD[id_craft] = WINDOW_MANAGER:CreateControlFromVirtual(CRT.name.."_Windows"..id_craft.."_BD",CRT.UI.CRAFT_TLW[id_craft], "ZO_DefaultBackdrop") - CRT.UI.CRAFT_BD[id_craft]:SetAlpha(alpha[id_craft]) - - - - - - ---- WINDOWS 0 ---- - -- icon - CRT.UI.CRAFT_WD[id_craft] = {} - CRT.UI.CRAFT_WD[id_craft][0] = {} - - if (CRT.SV.Settings.mode == "Icon") then - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"] = WINDOW_MANAGER:CreateControl("CRT_CRAFT_WD_"..id_craft.."_0_icon",CRT.UI.CRAFT_TLW[id_craft],CT_TEXTURE) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetHidden(false) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetDimensions(22,22) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetAlpha(1) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetAnchor(TOPLEFT,CRT.UI.CRAFT_TLW[id_craft],TOPLEFT,0,0) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetMouseEnabled(true) - -- CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetHandler("OnMouseEnter", function (self) ZO_Tooltips_ShowTextTooltip(self, RIGHT, updatetooltip) end) - -- CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) - - if (id_craft == 0) then - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetTexture("/esoui/art/icons/ability_smith_007.dds") - elseif (id_craft == 1) then - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetTexture("/esoui/art/icons/ability_tradecraft_008.dds") - elseif (id_craft == 2) then - CRT.UI.CRAFT_WD[id_craft][0]["Craft_icon"]:SetTexture("/esoui/art/icons/ability_tradecraft_009.dds") - end - end - - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"] = WINDOW_MANAGER:CreateControl("CRT_CRAFT_WD_"..id_craft.."_0_text",CRT.UI.CRAFT_TLW[id_craft],CT_LABEL) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetHidden(false) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetFont(CRT.font) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetDimensions(CRT.mode_width,CRT.mode_height) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetAlpha(1) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetAnchor(TOPLEFT,CRT.UI.CRAFT_TLW[id_craft],TOPLEFT,CRT.vertical_move,0) - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetText("Loading") - if(id_craft == 0) then - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetColor(CRT.SV.Settings.BS.Color.r, CRT.SV.Settings.BS.Color.g, CRT.SV.Settings.BS.Color.b, CRT.SV.Settings.BS.Color.a) - elseif(id_craft == 1) then - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetColor(CRT.SV.Settings.CL.Color.r, CRT.SV.Settings.CL.Color.g, CRT.SV.Settings.CL.Color.b, CRT.SV.Settings.CL.Color.a) - elseif(id_craft == 2) then - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetColor(CRT.SV.Settings.WO.Color.r, CRT.SV.Settings.WO.Color.g, CRT.SV.Settings.WO.Color.b, CRT.SV.Settings.WO.Color.a) - end - - - - ---- WINDOWS 1 / 2 / 3 ---- - for simcraft = 1, 3 , 1 do - local x = 5 - x = x + simcraft*20 - CRT.UI.CRAFT_WD[id_craft][simcraft] = {} - --// icon - if (CRT.SV.Settings.mode == "Icon") then - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"] = WINDOW_MANAGER:CreateControl("CRT_CRAFT_WD_"..id_craft.."_"..simcraft.."_icon",CRT.UI.CRAFT_TLW[id_craft],CT_TEXTURE) - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetHidden(true) - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetDimensions(20,20) - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetAlpha(1) - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetAnchor(TOPLEFT,CRT.UI.CRAFT_TLW[id_craft],TOPLEFT,0,x) - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetMouseEnabled(true) - if(CRT.SV.data.Craft[CRT.playername][id_craft][simcraft] ~= nil) then - local tooltip = CRT.SV.data.Craft[CRT.playername][id_craft][simcraft]["Item_name"].." - ".. CRT.SV.data.Craft[CRT.playername][id_craft][simcraft]["Trait_description"] - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetHandler("OnMouseEnter", function (self) ZO_Tooltips_ShowTextTooltip(self, TOP, tooltip) end) - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) - end - end - --// text - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"] = WINDOW_MANAGER:CreateControl("CRT_CRAFT_WD_"..id_craft.."_"..simcraft.."_text",CRT.UI.CRAFT_TLW[id_craft],CT_LABEL) - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetHidden(true) - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetFont(CRT.font) - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetDimensions(CRT.mode_width,CRT.mode_height) - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetAlpha(1) - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetAnchor(LEFT,CRT.UI.CRAFT_TLW[id_craft],LEFT,CRT.vertical_move,x) - if(id_craft == 0) then - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetColor(CRT.SV.Settings.BS.Color.r, CRT.SV.Settings.BS.Color.g, CRT.SV.Settings.BS.Color.b, CRT.SV.Settings.BS.Color.a) - elseif(id_craft == 1) then - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetColor(CRT.SV.Settings.CL.Color.r, CRT.SV.Settings.CL.Color.g, CRT.SV.Settings.CL.Color.b, CRT.SV.Settings.CL.Color.a) - elseif(id_craft == 2) then - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetColor(CRT.SV.Settings.WO.Color.r, CRT.SV.Settings.WO.Color.g, CRT.SV.Settings.WO.Color.b, CRT.SV.Settings.WO.Color.a) - end - if (CRT.SV.Settings.mode == "Text") then - if(CRT.SV.data.Craft[CRT.playername][id_craft][simcraft] ~= nil) then - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetMouseEnabled(true) - local tooltip = CRT.SV.data.Craft[CRT.playername][id_craft][simcraft]["Item_name"].." - ".. CRT.SV.data.Craft[CRT.playername][id_craft][simcraft]["Trait_description"] - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetHandler("OnMouseEnter", function (self) ZO_Tooltips_ShowTextTooltip(self, TOP, tooltip) end) - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) - end - end - end - end -end - -function CRT.CRAFT_Update(timestamp) - for id_craft = 0, 2,1 do - - local MaxResearch = CRT.SV.data.Craft[CRT.playername][id_craft]["MaxResearch"] - local Simu_craft = CRT.SV.data.Craft[CRT.playername][id_craft]["Simu_craft"] - local title = "error" - - if (CRT.SV.Settings.mode == "Text" and id_craft == 0) then - title = CRT.L["BS"] .. " : " .. "Simu_craft.. / "..MaxResearch - elseif (CRT.SV.Settings.mode == "Text" and id_craft == 1) then - title = CRT.L["Clothing"] .. " : "..Simu_craft.." / "..MaxResearch - elseif (CRT.SV.Settings.mode == "Text" and id_craft == 2) then - title = CRT.L["Woodwork"] .. " : "..Simu_craft.." / "..MaxResearch - elseif (CRT.SV.Settings.mode == "Icon") then - title = " "..Simu_craft.." / "..MaxResearch - end - CRT.UI.CRAFT_WD[id_craft][0]["Craft_Text"]:SetText(title) - - - for simcraft = 1, 3,1 do - - if (CRT.SV.data.Craft[CRT.playername][id_craft][simcraft] ~= nil)then - - local currenttimer = CRT.SV.data.Craft[CRT.playername][id_craft][simcraft]["EndTimeStamp"] - timestamp - 1 - local human_timer = CRT.Converthms(currenttimer) - - local msg = "error" - if (CRT.SV.Settings.mode == "Icon") then - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetHidden(false) - CRT.UI.CRAFT_WD[id_craft][simcraft]["item_icon"]:SetTexture(CRT.SV.data.Craft[CRT.playername][id_craft][simcraft]["Item_icon"]) - msg = human_timer - elseif (CRT.SV.Settings.mode == "Text") then - local Item_name = CRT.SV.data.Craft[CRT.playername][id_craft][simcraft]["Item_name"] - msg = Item_name.." - "..human_timer - end - - if (currenttimer > 0) then - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetHidden(false) - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetText(msg) - else - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetHidden(false) - CRT.UI.CRAFT_WD[id_craft][simcraft]["text"]:SetText(CRT.L["Finished"]) - end - - end - end - end -end \ No newline at end of file diff --git a/lua/CraftResearchTimer.lua b/lua/CraftResearchTimer.lua deleted file mode 100644 index 2499c58..0000000 --- a/lua/CraftResearchTimer.lua +++ /dev/null @@ -1,526 +0,0 @@ --- Craft Research Timer (CRT) by @aTo (EU) --- v0.4.11 - - ---sorting functions for grid. Arguments are character names -local function SortAlphaD (a,b) return a>b - end - -local function SortAlphaA (a,b) return a<b -end - -local function SortTimeA (a,b) - return CRT.SV.data.Craft[a].shortest < CRT.SV.data.Craft[b].shortest -end - -function CRT.Init(eventCode, addOnName) - - if(addOnName == CRT.name) then - CRT.Init_done = false - CRT.playername = GetUnitName("player") - - -- SavedVariables - CRT.SV.Settings = ZO_SavedVars:New(CRT.svName, CRT.svVersion*100, nil, CRT.svDefaults, nil) - CRT.SV.data = ZO_SavedVars:NewAccountWide(CRT.svName, 2, nil, CRT.data_defaults,nil ) - CRT.GRID_Remove_Expired() - - CRT.InitialiseLanguage() - --get rid of bad "version" key from CRT releases prior to this one - -- CRT.SV.data.Craft.versionx = nil - -- CRT.SV.Hireling_data.versionxx = nil - - -- Slash commands - SLASH_COMMANDS[CRT.cmdsetup] = CRT.CommandText_setup - - -- Default sort - CRT.SortFunction = SortTimeA - - - - -- Create Keybinds - ZO_CreateStringId("SI_BINDING_NAME_CRT_ToggleUI", "|c96FF00Toggle craft windows|r") - ZO_CreateStringId("SI_BINDING_NAME_CRT_toggleGRID", "|c96FF00Toggle GRID|r") - - -- options panel - local LAM = LibStub:GetLibrary("LibAddonMenu-2.0") - - local panelData = { - type = "panel", - name = "Craft Research Timer", - displayName=CRT.L["PanelHeading"] - } - - local optionsTable = { - - -- Main settings - { - type = "header", - name = "|c96FF00Options|r" - }, { - type = "checkbox", - name = "Unlock all windows", - tooltip = "Toggle lock on/off", - getFunc = function() return CRT.SV.Settings.lock end, - setFunc = CRT.SetLock - }, { - type = "dropdown", - name = "Select Mode", - tooltip = "Display researched items as icon or text?", - choices = {"Icon", "Text"}, - getFunc = function() return CRT.SV.Settings.mode end, - setFunc = CRT.SetMode, - warning = "Will need to reload the UI" - }, { - type = "dropdown", - name = "Timer format", - tooltip = "How to display remaining time?", - choices = {"smart", "fixed", "compact"}, - getFunc = CRT.Gettimer_format, - setFunc = CRT.Settimer_format, - }, { - type = "button", - name = "Reset to default", - tooltip = "Load default values", - func = CRT.Reset, - warning = "Will need to reload the UI" - }, - - -- Alert - { - type = "header", - name = "|c96FF00Alert Components|r" - }, { - type = "checkbox", - name = "Enable Alert window", - tooltip = "Enable Alert window", - getFunc = function() return CRT.SV.Settings.ALERT.hidden end, - setFunc = CRT.SetAlert - }, { - type = "checkbox", - name = "Preview Alert window", - tooltip = "Toggle preview on/off", - getFunc = function() return CRT.SV.Settings.ALERT.preview end, - setFunc = CRT.SetPreview - }, { - type = "colorpicker", - name = "Text Color", - tooltip = "Select the text color", - getFunc = CRT.GetALERTColor, - setFunc = CRT.SetALERTColor - }, { - type = "checkbox", - name = "Enable Blacksmithing alert", - tooltip = "Enable Blacksmithing alert", - getFunc = function() return CRT.SV.Settings.ALERT.BS end, - setFunc = CRT.SetALERTBS - }, { - type = "checkbox", - name = "Enable Clothing alert", - tooltip = "Enable Clothing alert", - getFunc = function() return CRT.SV.Settings.ALERT.CL end, - setFunc = CRT.SetALERTCL - }, { - type = "checkbox", - name = "Enable Woodworking alert", - tooltip = "Enable Woodworking alert", - getFunc = function() return CRT.SV.Settings.ALERT.WO end, - setFunc = CRT.SetALERTWO - }, - - -- Grid - { - type = "header", - name = "|c96FF00Grid|r" - }, { - type = "slider", - name = "Alpha", - tooltip = "Change the transparency of the window", - min = 0, - max = 100, - step = 1, - getFunc = CRT.GetGRIDBackdropAlpha, - setFunc = CRT.SetGRIDBackdropAlpha - }, { - type = "slider", - name = "Scale", - tooltip = "Change the scale of the window", - min = 0, - max = 200, - step = 1, - getFunc = CRT.GetGRIDScale, - setFunc = CRT.SetGRIDScale - }, { - type = "colorpicker", - name = "Text Color", - tooltip = "Select the text color", - getFunc = CRT.GetGRIDColor, - setFunc = CRT.SetGRIDColor - }, { - type = "button", - name = "Apply new colors", - tooltip = "Apply new colors", - func = function() ReloadUI() end, true, - warning = "Will reload the UI" - }, { - type = "button", - name = "Toggle grid view", - tooltip = "Display or hide the grid view", - func = function() CRT.toggleGRID() end, true, - }, - - --Blacksmithing - { - type = "header", - name = "|c96FF00Blacksmithing Components|r" - }, { - type = "checkbox", - name = "Enable Blacksmithing Tracker", - tooltip = "Enable Blacksmithing Tracker", - getFunc = function() return CRT.SV.Settings.BS.craft end, - setFunc = CRT.SetTrackerBS - }, { - type = "checkbox", - name = "Hide if no research", - tooltip = "Hide if no research", - getFunc = function() return CRT.SV.Settings.BS.Hide_0 end, - setFunc = CRT.SetBSHide0 - }, { - type = "dropdown", - name = "Display when", - tooltip = "Display when", - choices = {"Always", "Hide in menus","Menus only", "Toggle keybind"}, - getFunc = function() return CRT.SV.Settings.BS.Hide_Type end, - setFunc = CRT.SetBSHideMenu - }, { - type = "slider", - name = "Alpha", - tooltip = "Change the transparency of the blacksmithing window", - min = 0, - max = 100, - step = 1, - getFunc = CRT.GetBSBackdropAlpha, - setFunc = CRT.SetBSBackdropAlpha - }, { - type = "slider", - name = "Scale", - tooltip = "Change the scale of the blacksmithing window", - min = 0, - max = 200, - step = 1, - getFunc = CRT.GetBSScale, - setFunc = CRT.SetBSScale - }, - - --Clothing - { - type = "header", - name = "|c96FF00Clothing Components|r" - }, { - type = "checkbox", - name = "Enable Clothing Tracker", - tooltip = "Enable Clothing Tracker", - getFunc = function() return CRT.SV.Settings.CL.craft end, - setFunc = CRT.SetTrackerCL - }, { - type = "checkbox", - name = "Hide if no research", - tooltip = "Hide if no research", - getFunc = function() return CRT.SV.Settings.CL.Hide_0 end, - setFunc = CRT.SetCLHide0 - }, { - type = "dropdown", - name = "Display when", - tooltip = "Display when", - choices = {"Always", "Hide in menus","Menus only", "Toggle keybind"}, - getFunc = function() return CRT.SV.Settings.CL.Hide_Type end, - setFunc = CRT.SetCLHideMenu - }, { - type = "slider", - name = "Alpha", - tooltip = "Change the transparency of the clothing window", - min = 0, - max = 100, - step = 1, - getFunc = CRT.GetCLBackdropAlpha, - setFunc = CRT.SetCLBackdropAlpha - }, { - type = "slider", - name = "Scale", - tooltip = "Change the scale of the clothing window", - min = 0, - max = 200, - step = 1, - getFunc = CRT.GetCLScale, - setFunc = CRT.SetCLScale - }, - - --Woodworking - { - type = "header", - name = "|c96FF00 Woodworking Components|r" - }, { - type = "checkbox", - name = "Enable Woodworking Tracker", - tooltip = "Enable Woodworking Tracker", - getFunc = function() return CRT.SV.Settings.WO.craft end, - setFunc = CRT.SetTrackerWO - }, { - type = "checkbox", - name = "Hide if no research", - tooltip = "Hide if no research", - getFunc = function() return CRT.SV.Settings.WO.Hide_0 end, - setFunc = CRT.SetWOHide0 - }, { - type = "dropdown", - name = "Display when", - tooltip = "Display when", - choices = {"Always", "Hide in menus","Menus only", "Toggle keybind"}, - getFunc = function() return CRT.SV.Settings.WO.Hide_Type end, - setFunc = CRT.SetWOHideMenu - }, { - type = "slider", - name = "Alpha", - tooltip = "Change the transparency of the woodworking window", - min = 0, - max = 100, - step = 1, - getFunc = CRT.GetWOBackdropAlpha, - setFunc = CRT.SetWOBackdropAlpha - }, { - type = "slider", - name = "Scale", - tooltip = "Change the scale of the woodworking window", - min = 0, - max = 200, - step = 1, - getFunc = CRT.GetWOScale, - setFunc = CRT.SetWOScale - } - - } - LAM:RegisterAddonPanel("CRT_OptionsPanel", panelData); - LAM:RegisterOptionControls("CRT_OptionsPanel", optionsTable); - - CRT.Start_PlayerPosition = GetMapPlayerPosition("player") - local timestamp = GetTimeStamp() - - CRT.Alert_Create() - - -- check if old alert before erase data - --CRT_Alert_Check(playername,timestamp) - - -- erase data for this character - -- if CRT.SV.data.Craft == nil - -- then CRT.SV.data.Craft = {} - -- end - CRT.SV.data.Craft[CRT.playername] = {} - CRT.SV.data.Craft[CRT.playername]["Start"] = true - - CRT.Collect_Data() - -- Create GRID - CRT.GRID_Create() - -- Create SOLO CRAFT - CRT.CRAFT_Create() - CRT.Init_done = true - -- Only after initialised do we hook any other events. - EVENT_MANAGER:RegisterForEvent(CRT.name, EVENT_SMITHING_TRAIT_RESEARCH_STARTED, CRT.Research_started) - end -end - -function CRT.Update() - if not CRT.Init_done then return; end - if not BufferReached("Info_Research", CRT.tic) then return; end - local timestamp = GetTimeStamp() - CRT.ALERT_Update(timestamp) - CRT.GRID_Update(timestamp) - CRT.CRAFT_Update(timestamp) - CRT.toggleGUI() -end - -local bt= {} -function BufferReached( BufferName, ThrottleInSeconds ) - if not BufferName then return end - local ct, ThrottleInSeconds = GetGameTimeMilliseconds(), ((ThrottleInSeconds or 3) * 1000) - --d("start:"..start.. "test "..ThrottleInSeconds ) - if not bt[BufferName] then bt[BufferName] = ct end - if (ct - bt[BufferName]) >= ThrottleInSeconds - then bt[BufferName] = ct; return true; - else return false; end -end - -local btwait = {} -function BufferWait(BufferName, WaitTime) - if (btwait["BufferName"] ~= nil and GetGameTimeMilliseconds() < btwait["BufferName"]) then - d("false") - return false - else - btwait["BufferName"] = GetGameTimeMilliseconds() + (WaitTime * 1000) - d("true") - return true - end -end - -function CRT.ToggleUI() - if (CRT.SV.Settings.BS.craft == true and CRT.SV.Settings.BS.Hide_Type == "Toggle keybind") then - if (CRT.UI.CRAFT_TLW[0]:IsHidden() == true) then - CRT.UI.CRAFT_TLW[0]:SetHidden(false) - else - CRT.UI.CRAFT_TLW[0]:SetHidden(true) - end - end - if (CRT.SV.Settings.CL.craft == true and CRT.SV.Settings.CL.Hide_Type == "Toggle keybind") then - if (CRT.UI.CRAFT_TLW[1]:IsHidden() == true) then - CRT.UI.CRAFT_TLW[1]:SetHidden(false) - else - CRT.UI.CRAFT_TLW[1]:SetHidden(true) - end - end - if (CRT.SV.Settings.WO.craft == true and CRT.SV.Settings.WO.Hide_Type == "Toggle keybind") then - if (CRT.UI.CRAFT_TLW[2]:IsHidden() == true) then - CRT.UI.CRAFT_TLW[2]:SetHidden(false) - else - CRT.UI.CRAFT_TLW[2]:SetHidden(true) - end - end -end - -function CRT.toggleGRID() - if (CRT.UI.GRID_TLW:IsHidden() == true) then - CRT.GRID_Sort() - CRT.UI.GRID_TLW:SetHidden(false) - CRT.SV.Settings.GRID.hidden = false - else - CRT.UI.GRID_TLW:SetHidden(true) - CRT.SV.Settings.GRID.hidden = true - end -end - -function CRT.toggleGUI() - - local checkUI = ZO_Compass:IsHidden() - local hidemenu ={} - hidemenu[0] = CRT.SV.Settings.BS.Hide_Type - hidemenu[1] = CRT.SV.Settings.CL.Hide_Type - hidemenu[2] = CRT.SV.Settings.WO.Hide_Type - - - for id_craft = 0, 2 , 1 do - if ((id_craft == 0 and CRT.SV.Settings.BS.craft == true) or (id_craft == 1 and CRT.SV.Settings.CL.craft == true) or (id_craft == 2 and CRT.SV.Settings.WO.craft == true)) then - if (hidemenu[id_craft] ~= "Toggle keybind") then - if (hidemenu[id_craft] == "Hide in menus" and checkUI == true)then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(true) - elseif (hidemenu[id_craft] == "Hide in menus" and checkUI == false)then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(false) - elseif (hidemenu[id_craft] == "Menus only" and checkUI == true) then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(false) - elseif (hidemenu[id_craft] == "Menus only" and checkUI == false) then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(true) - elseif (hidemenu[id_craft] == "Always") then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(false) - end - end - end - - local hide0 ={} - hide0[0] = CRT.SV.Settings.BS.Hide_0 - hide0[1] = CRT.SV.Settings.CL.Hide_0 - hide0[2] = CRT.SV.Settings.WO.Hide_0 - - - if (hide0[id_craft] == true and hidemenu[id_craft] ~= "Toggle keybind" and CRT.SV.data.Craft[CRT.playername][id_craft]["Simu_craft"] == 0) then - CRT.UI.CRAFT_TLW[id_craft]:SetHidden(true) - end - end -end - -function CRT.Converthms(timesec) - - local showDays = false - local showSeconds = false - - local days = 0 - local hours = 0 - local minutes = 0 - local seconds = 0 - - local function extractIntegerUnits(sec, unitduration) - local units = math.floor(sec / unitduration) - return units, sec - (units * unitduration) - end - - local format = CRT.SV.Settings.timer_format - if ((format ~= "fixed") and (format ~= "compact")) then - format = "smart" - end - - if (format == "smart") then - days, timesec = extractIntegerUnits(timesec, 60*60*24) - end - hours, timesec = extractIntegerUnits(timesec, 60*60) - minutes, seconds = extractIntegerUnits(timesec, 60) - - local humanDuration - if (format == "smart") then - humanDuration = string.format("%d:%02d", hours, minutes) - if (days > 0) then - humanDuration = string.format("%dd ", days)..humanDuration - end - else - humanDuration = string.format("%02d:%02d", hours, minutes) - if (format == "fixed") then - humanDuration = humanDuration..(string.format(":%02d", seconds)) - end - end - - return humanDuration - -end - - -function CRT.Save_position(id_craft) - if (id_craft == 0) then - CRT.SV.Settings.BS.offset.X = math.floor(CRT.UI.CRAFT_TLW[id_craft]:GetLeft()) - CRT.SV.Settings.BS.offset.Y = math.floor(CRT.UI.CRAFT_TLW[id_craft]:GetTop()) - elseif (id_craft == 1) then - CRT.SV.Settings.CL.offset.X = math.floor(CRT.UI.CRAFT_TLW[id_craft]:GetLeft()) - CRT.SV.Settings.CL.offset.Y = math.floor(CRT.UI.CRAFT_TLW[id_craft]:GetTop()) - elseif (id_craft == 2) then - CRT.SV.Settings.WO.offset.X = math.floor(CRT.UI.CRAFT_TLW[id_craft]:GetLeft()) - CRT.SV.Settings.WO.offset.Y = math.floor(CRT.UI.CRAFT_TLW[id_craft]:GetTop()) - elseif (id_craft == "GRID") then - CRT.SV.Settings.GRID.offset.X = math.floor(CRT.UI.GRID_TLW:GetLeft()) - CRT.SV.Settings.GRID.offset.Y = math.floor(CRT.UI.GRID_TLW:GetTop()) - elseif (id_craft == "ALERT") then - CRT.SV.Settings.ALERT.offset.X = math.floor(CRT.UI.ALERT_TLW:GetLeft()) - CRT.SV.Settings.ALERT.offset.Y = math.floor(CRT.UI.ALERT_TLW:GetTop()) - end -end - - - -function CRT.CommandText_setup(lparam) - if (lparam == "info") then - d("Craft Research Timer (CRT) by @aTo (EU)") - d("Version " .. CRT.version) - d("The CRT have moved to the normal game settings") - d("Player: " .. CRT.playername) - d("Shortest: " .. CRT.Converthms(CRT.SV.data.Craft[CRT.playername].shortest)) - elseif (lparam == "grid") then - CRT.toggleGRID() - elseif (lparam == "sortA") then - CRT.SortFunction = SortAlphaA - CRT.GRID_Sort() - elseif (lparam == "sortD") then - CRT.SortFunction = SortAlphaD - CRT.GRID_Sort() - elseif (lparam == "sortT") then - CRT.SortFunction = SortTimeT - CRT.GRID_Sort() - else - CRT.ToggleUI() - end -end - -EVENT_MANAGER:RegisterForEvent(CRT.name, EVENT_ADD_ON_LOADED, CRT.Init) - - diff --git a/lua/GRID.lua b/lua/GRID.lua index 543bcc5..012c76c 100644 --- a/lua/GRID.lua +++ b/lua/GRID.lua @@ -4,54 +4,47 @@ local num_char --track character number drawing for, for positioning local k,v -function CRT.GRID_Remove_Expired() --- Prevent display for completely expired crafting chars. - for k, _ in pairs(CRT.SV.data.Craft) do +function RT.GRID_Remove_Expired() --- Prevent display for completely expired crafting chars. + for k, _ in pairs(RT.SV.data.Craft) do - if ((CRT.SV.data.Craft[k][0].Simu_craft == 0 and - CRT.SV.data.Craft[k][1].Simu_craft == 0 and - CRT.SV.data.Craft[k][2].Simu_craft == 0)) + if ((RT.SV.data.Craft[k][0].Simu_craft == 0 and + RT.SV.data.Craft[k][1].Simu_craft == 0 and + RT.SV.data.Craft[k][2].Simu_craft == 0)) then - CRT.SV.data.Craft[k] = nil + RT.SV.data.Craft[k] = nil end end end -function CRT.GRID_Create() +function RT.GRID_Create() - -- Fenetre de base - CRT.UI.GRID_TLW= WINDOW_MANAGER:CreateTopLevelWindow("CRT_GRID_TLW") - CRT.UI.GRID_TLW:SetHidden(CRT.SV.Settings.GRID.hidden) - CRT.UI.GRID_TLW:SetClampedToScreen(false) - CRT.UI.GRID_TLW:SetMovable(CRT.SV.Settings.lock) - CRT.UI.GRID_TLW:SetMouseEnabled(true) - CRT.UI.GRID_TLW:SetDrawLayer(1) - CRT.UI.GRID_TLW:SetScale(CRT.SV.Settings.GRID.Scale) - CRT.UI.GRID_TLW:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, CRT.SV.Settings.GRID.offset.X, CRT.SV.Settings.GRID.offset.Y) - CRT.UI.GRID_TLW:SetHandler("OnMouseUp", function(self) CRT.Save_position("GRID")end) - CRT.UI.GRID_TLW:SetHidden(true) + RT.UI.GRID_TLW= WINDOW_MANAGER:CreateTopLevelWindow("RT_GRID_TLW") + RT.UI.GRID_TLW:SetClampedToScreen(false) + RT.UI.GRID_TLW:SetMouseEnabled(true) + RT.UI.GRID_TLW:SetDrawLayer(1) + RT.UI.GRID_TLW:SetHidden(true) --/background - CRT.UI.GRID_BD = WINDOW_MANAGER:CreateControlFromVirtual("CRT_GRID_BD",CRT.UI.GRID_TLW, "ZO_DefaultBackdrop") - CRT.UI.GRID_BD:SetAlpha(CRT.SV.Settings.GRID.BackdropAlpha) + RT.UI.GRID_BD = WINDOW_MANAGER:CreateControlFromVirtual("RT_GRID_BD",RT.UI.GRID_TLW, "ZO_DefaultBackdrop") -- Close Button - CRT.UI.GRID_BTN = WINDOW_MANAGER:CreateControl("CRT_GRID_BTN" , CRT.UI.GRID_TLW, CT_BUTTON) - CRT.UI.GRID_BTN:SetDimensions( 30 , 30 ) - CRT.UI.GRID_BTN:SetAnchor(TOPRIGHT,CRT.UI.GRID_TLW,TOPRIGHT,5,-10) - CRT.UI.GRID_BTN:SetState( BSTATE_NORMAL ) - CRT.UI.GRID_BTN:SetMouseOverBlendMode(0) - CRT.UI.GRID_BTN:SetNormalTexture("/esoui/art/buttons/decline_down.dds") - CRT.UI.GRID_BTN:SetMouseOverTexture("/esoui/art/buttons/decline_up.dds") - CRT.UI.GRID_BTN:SetHandler( "OnClicked" , function(self) CRT.UI.GRID_TLW:SetHidden(true); CRT.SV.Settings.GRID.hidden = true end ) - - for k, _ in pairs(CRT.SV.data.Craft) do - CRT.GRID_Create_Character(k) + RT.UI.GRID_BTN = WINDOW_MANAGER:CreateControl("RT_GRID_BTN" , RT.UI.GRID_TLW, CT_BUTTON) + RT.UI.GRID_BTN:SetDimensions( 30 , 30 ) + RT.UI.GRID_BTN:SetAnchor(TOPRIGHT,RT.UI.GRID_TLW,TOPRIGHT,5,-10) + RT.UI.GRID_BTN:SetState( BSTATE_NORMAL ) + RT.UI.GRID_BTN:SetMouseOverBlendMode(0) + RT.UI.GRID_BTN:SetNormalTexture("/esoui/art/buttons/decline_down.dds") + RT.UI.GRID_BTN:SetMouseOverTexture("/esoui/art/buttons/decline_up.dds") + RT.UI.GRID_BTN:SetHandler( "OnClicked" , function(self) RT.UI.GRID_TLW:SetHidden(true); end ) + + for k, _ in pairs(RT.SV.data.Craft) do + RT.GRID_Create_Character(k) end end -function CRT.GRID_Create_Character(k) - local x, y +function RT.GRID_Create_Character(k) + local x, y local width = 360 local panelheight = 130 -- per character at 100% local prevcontrol, ctl_headers @@ -60,152 +53,137 @@ function CRT.GRID_Create_Character(k) num_char = 0 end - CRT.UI.GRID_WD[k] = {} + RT.UI.GRID_WD[k] = {} -- Containing window for character data. We can then move it as a group - CRT.UI.GRID_WD[k].panel = WINDOW_MANAGER:CreateTopLevelWindow("CRT_GRID_"..k.."_panel") - CRT.UI.GRID_WD[k].panel:SetParent(CRT.UI.GRID_TLW) - CRT.UI.GRID_WD[k].panel:SetAnchor(TOPRIGHT,CRT.UI.GRID_TLW,TOPRIGHT,0,panelheight*num_char) - CRT.UI.GRID_WD[k].panel:SetDimensions(width,panelheight) + RT.UI.GRID_WD[k].panel = WINDOW_MANAGER:CreateTopLevelWindow("RT_GRID_"..k.."_panel") + RT.UI.GRID_WD[k].panel:SetParent(RT.UI.GRID_TLW) + RT.UI.GRID_WD[k].panel:SetAnchor(TOPRIGHT,RT.UI.GRID_TLW,TOPRIGHT,0,panelheight*num_char) + RT.UI.GRID_WD[k].panel:SetDimensions(width,panelheight) -- label for character name - CRT.UI.GRID_WD[k].label = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_label",CRT.UI.GRID_WD[k].panel,CT_LABEL) - CRT.UI.GRID_WD[k].label:SetFont("ZoFontGame") - CRT.UI.GRID_WD[k].label:SetDimensions(width,20) - CRT.UI.GRID_WD[k].label:SetColor(CRT.SV.Settings.GRID.Color.r, CRT.SV.Settings.GRID.Color.g, CRT.SV.Settings.GRID.Color.b, CRT.SV.Settings.GRID.Color.a) - CRT.UI.GRID_WD[k].label:SetAlpha(1) - CRT.UI.GRID_WD[k].label:SetAnchor(TOPLEFT,CRT.UI.GRID_WD[k].panel,TOPLEFT,0,0) - CRT.UI.GRID_WD[k].label:SetHorizontalAlignment(1) - CRT.UI.GRID_WD[k].label:SetText(string.upper(k)) + RT.UI.GRID_WD[k].label = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_label",RT.UI.GRID_WD[k].panel,CT_LABEL) + RT.UI.GRID_WD[k].label:SetFont("ZoFontGame") + RT.UI.GRID_WD[k].label:SetDimensions(width,20) + RT.UI.GRID_WD[k].label:SetAnchor(TOPLEFT,RT.UI.GRID_WD[k].panel,TOPLEFT,0,0) + RT.UI.GRID_WD[k].label:SetHorizontalAlignment(1) + RT.UI.GRID_WD[k].label:SetText(string.upper(k)) - prevcontrol = CRT.UI.GRID_WD[k].label -- use this to anchor the next control, in this case the row of skill headers + prevcontrol = RT.UI.GRID_WD[k].label -- use this to anchor the next control, in this case the row of skill headers -- Create section headers with dummy text for each skill --blacksmithing - CRT.UI.GRID_WD[k][0] = {} - CRT.UI.GRID_WD[k][0][0] = {} - CRT.UI.GRID_WD[k][0][0]["BS_Icon"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_0_icon",CRT.UI.GRID_WD[k].panel,CT_TEXTURE) - CRT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetHidden(false) - CRT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetDimensions(20,20) - CRT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetAlpha(1) - CRT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetAnchor(TOPLEFT,prevcontrol,BOTTOMLEFT,0,5) -- below - CRT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetTexture("/esoui/art/icons/ability_smith_007.dds") - - CRT.UI.GRID_WD[k][0][0]["BS_Text"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_0_text",CRT.UI.GRID_WD[k].panel,CT_LABEL) - CRT.UI.GRID_WD[k][0][0]["BS_Text"]:SetHidden(false) - CRT.UI.GRID_WD[k][0][0]["BS_Text"]:SetFont("ZoFontGame") - CRT.UI.GRID_WD[k][0][0]["BS_Text"]:SetDimensions(width/3,20) - CRT.UI.GRID_WD[k][0][0]["BS_Text"]:SetColor(CRT.SV.Settings.GRID.Color.r, CRT.SV.Settings.GRID.Color.g, CRT.SV.Settings.GRID.Color.b, CRT.SV.Settings.GRID.Color.a) - CRT.UI.GRID_WD[k][0][0]["BS_Text"]:SetAlpha(1) - CRT.UI.GRID_WD[k][0][0]["BS_Text"]:SetAnchor(TOPLEFT,CRT.UI.GRID_WD[k][0][0]["BS_Icon"],TOPRIGHT,0,0) -- Side by the previous - CRT.UI.GRID_WD[k][0][0]["BS_Text"]:SetText("Loading") - ctl_headers[0] = CRT.UI.GRID_WD[k][0][0]["BS_Icon"] + RT.UI.GRID_WD[k][0] = {} + RT.UI.GRID_WD[k][0][0] = {} + RT.UI.GRID_WD[k][0][0]["BS_Icon"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_0_icon",RT.UI.GRID_WD[k].panel,CT_TEXTURE) + RT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetHidden(false) + RT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetDimensions(20,20) + RT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetAnchor(TOPLEFT,prevcontrol,BOTTOMLEFT,0,5) -- below + RT.UI.GRID_WD[k][0][0]["BS_Icon"]:SetTexture("/esoui/art/icons/ability_smith_007.dds") + + RT.UI.GRID_WD[k][0][0]["BS_Text"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_0_text",RT.UI.GRID_WD[k].panel,CT_LABEL) + RT.UI.GRID_WD[k][0][0]["BS_Text"]:SetHidden(false) + RT.UI.GRID_WD[k][0][0]["BS_Text"]:SetFont("ZoFontGame") + RT.UI.GRID_WD[k][0][0]["BS_Text"]:SetDimensions(width/3,20) + RT.UI.GRID_WD[k][0][0]["BS_Text"]:SetAnchor(TOPLEFT,RT.UI.GRID_WD[k][0][0]["BS_Icon"],TOPRIGHT,0,0) -- Side by the previous + RT.UI.GRID_WD[k][0][0]["BS_Text"]:SetText("Loading") + ctl_headers[0] = RT.UI.GRID_WD[k][0][0]["BS_Icon"] --Clothing - CRT.UI.GRID_WD[k][1] = {} - CRT.UI.GRID_WD[k][1][0] = {} - CRT.UI.GRID_WD[k][1][0]["CL_Icon"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_1_icon",CRT.UI.GRID_WD[k].panel,CT_TEXTURE) - CRT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetHidden(false) - CRT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetDimensions(20,20) - CRT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetAlpha(1) - CRT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetAnchor(TOPLEFT,prevcontrol,BOTTOMLEFT,width/3,5) - CRT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetTexture("/esoui/art/icons/ability_tradecraft_008.dds") - - CRT.UI.GRID_WD[k][1][0]["CL_Text"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_1_text",CRT.UI.GRID_WD[k].panel,CT_LABEL) - CRT.UI.GRID_WD[k][1][0]["CL_Text"]:SetHidden(false) - CRT.UI.GRID_WD[k][1][0]["CL_Text"]:SetFont("ZoFontGame") - CRT.UI.GRID_WD[k][1][0]["CL_Text"]:SetDimensions(width/3,20) - CRT.UI.GRID_WD[k][1][0]["CL_Text"]:SetColor(CRT.SV.Settings.GRID.Color.r, CRT.SV.Settings.GRID.Color.g, CRT.SV.Settings.GRID.Color.b, CRT.SV.Settings.GRID.Color.a) - CRT.UI.GRID_WD[k][1][0]["CL_Text"]:SetAlpha(1) - CRT.UI.GRID_WD[k][1][0]["CL_Text"]:SetAnchor(TOPLEFT,CRT.UI.GRID_WD[k][1][0]["CL_Icon"],TOPRIGHT,0,0) - CRT.UI.GRID_WD[k][1][0]["CL_Text"]:SetText("Loading") - ctl_headers[1] = CRT.UI.GRID_WD[k][1][0]["CL_Icon"] + RT.UI.GRID_WD[k][1] = {} + RT.UI.GRID_WD[k][1][0] = {} + RT.UI.GRID_WD[k][1][0]["CL_Icon"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_1_icon",RT.UI.GRID_WD[k].panel,CT_TEXTURE) + RT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetHidden(false) + RT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetDimensions(20,20) + RT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetAnchor(TOPLEFT,prevcontrol,BOTTOMLEFT,width/3,5) + RT.UI.GRID_WD[k][1][0]["CL_Icon"]:SetTexture("/esoui/art/icons/ability_tradecraft_008.dds") + + RT.UI.GRID_WD[k][1][0]["CL_Text"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_1_text",RT.UI.GRID_WD[k].panel,CT_LABEL) + RT.UI.GRID_WD[k][1][0]["CL_Text"]:SetHidden(false) + RT.UI.GRID_WD[k][1][0]["CL_Text"]:SetFont("ZoFontGame") + RT.UI.GRID_WD[k][1][0]["CL_Text"]:SetDimensions(width/3,20) + RT.UI.GRID_WD[k][1][0]["CL_Text"]:SetAnchor(TOPLEFT,RT.UI.GRID_WD[k][1][0]["CL_Icon"],TOPRIGHT,0,0) + RT.UI.GRID_WD[k][1][0]["CL_Text"]:SetText("Loading") + ctl_headers[1] = RT.UI.GRID_WD[k][1][0]["CL_Icon"] --Woodworking - CRT.UI.GRID_WD[k][2] = {} - CRT.UI.GRID_WD[k][2][0] = {} - CRT.UI.GRID_WD[k][2][0]["WO_Icon"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_2_icon",CRT.UI.GRID_WD[k].panel,CT_TEXTURE) - CRT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetHidden(false) - CRT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetDimensions(20,20) - CRT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetAlpha(1) - CRT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetAnchor(TOPLEFT,prevcontrol,BOTTOMLEFT,(width*2/3),5) - CRT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetTexture("/esoui/art/icons/ability_tradecraft_009.dds") - - CRT.UI.GRID_WD[k][2][0]["WO_Text"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_2_text",CRT.UI.GRID_WD[k].panel,CT_LABEL) - CRT.UI.GRID_WD[k][2][0]["WO_Text"]:SetHidden(false) - CRT.UI.GRID_WD[k][2][0]["WO_Text"]:SetFont("ZoFontGame") - CRT.UI.GRID_WD[k][2][0]["WO_Text"]:SetDimensions(width,20) - CRT.UI.GRID_WD[k][2][0]["WO_Text"]:SetColor(CRT.SV.Settings.GRID.Color.r, CRT.SV.Settings.GRID.Color.g, CRT.SV.Settings.GRID.Color.b, CRT.SV.Settings.GRID.Color.a) - CRT.UI.GRID_WD[k][2][0]["WO_Text"]:SetAlpha(1) - CRT.UI.GRID_WD[k][2][0]["WO_Text"]:SetAnchor(TOPLEFT,CRT.UI.GRID_WD[k][2][0]["WO_Icon"],TOPRIGHT,0,0) - CRT.UI.GRID_WD[k][2][0]["WO_Text"]:SetText("Loading") - ctl_headers[2] = CRT.UI.GRID_WD[k][2][0]["WO_Icon"] + RT.UI.GRID_WD[k][2] = {} + RT.UI.GRID_WD[k][2][0] = {} + RT.UI.GRID_WD[k][2][0]["WO_Icon"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_2_icon",RT.UI.GRID_WD[k].panel,CT_TEXTURE) + RT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetHidden(false) + RT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetDimensions(20,20) + RT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetAnchor(TOPLEFT,prevcontrol,BOTTOMLEFT,(width*2/3),5) + RT.UI.GRID_WD[k][2][0]["WO_Icon"]:SetTexture("/esoui/art/icons/ability_tradecraft_009.dds") + + RT.UI.GRID_WD[k][2][0]["WO_Text"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_2_text",RT.UI.GRID_WD[k].panel,CT_LABEL) + RT.UI.GRID_WD[k][2][0]["WO_Text"]:SetHidden(false) + RT.UI.GRID_WD[k][2][0]["WO_Text"]:SetFont("ZoFontGame") + RT.UI.GRID_WD[k][2][0]["WO_Text"]:SetDimensions(width,20) + RT.UI.GRID_WD[k][2][0]["WO_Text"]:SetAnchor(TOPLEFT,RT.UI.GRID_WD[k][2][0]["WO_Icon"],TOPRIGHT,0,0) + RT.UI.GRID_WD[k][2][0]["WO_Text"]:SetText("Loading") + ctl_headers[2] = RT.UI.GRID_WD[k][2][0]["WO_Icon"] for id_craft = 0, 2,1 do -- column prevcontrol=ctl_headers[id_craft] -- line up under this column for simcraft = 1, 3,1 do - CRT.UI.GRID_WD[k][id_craft][simcraft] = {} + RT.UI.GRID_WD[k][id_craft][simcraft] = {} -- item icon - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_"..id_craft.."_"..simcraft.."_icon",CRT.UI.GRID_WD[k].panel,CT_TEXTURE) - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHidden(true) - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetDimensions(20,20) - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetAlpha(1) - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetAnchor(TOPLEFT,prevcontrol,BOTTOMLEFT,0,0) --below - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetMouseEnabled(true) - - -- CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHandler("OnMouseEnter", function (self) - -- ZO_Tooltips_ShowTextTooltip(self, TOP, CRT.SV.data.Craft[k].doing[simcraft]["Item_name"]) + RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_"..id_craft.."_"..simcraft.."_icon",RT.UI.GRID_WD[k].panel,CT_TEXTURE) + RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHidden(true) + RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetDimensions(20,20) + RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetAnchor(TOPLEFT,prevcontrol,BOTTOMLEFT,0,0) --below + RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetMouseEnabled(true) + + -- RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHandler("OnMouseEnter", function (self) + -- ZO_Tooltips_ShowTextTooltip(self, TOP, RT.SV.data.Craft[k].doing[simcraft]["Item_name"]) -- end) - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHandler("OnMouseExit", function (self) + RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) - prevcontrol= CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"] + prevcontrol= RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"] -- trait icon - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_"..id_craft.."_"..simcraft.."_trait",CRT.UI.GRID_WD[k].panel,CT_TEXTURE) - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHidden(true) - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetDimensions(20,20) - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetAlpha(1) - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetAnchor(TOPLEFT,prevcontrol,TOPRIGHT,0,0) --to right - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetMouseEnabled(true) - - -- CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHandler("OnMouseEnter", function (self) - -- ZO_Tooltips_ShowTextTooltip(self, TOP, CRT.SV.data.Craft[k][id_craft].doing[simcraft]["Trait_description"]) + RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_"..id_craft.."_"..simcraft.."_trait",RT.UI.GRID_WD[k].panel,CT_TEXTURE) + RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHidden(true) + RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetDimensions(20,20) + RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetAnchor(TOPLEFT,prevcontrol,TOPRIGHT,0,0) --to right + RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetMouseEnabled(true) + + -- RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHandler("OnMouseEnter", function (self) + -- ZO_Tooltips_ShowTextTooltip(self, TOP, RT.SV.data.Craft[k][id_craft].doing[simcraft]["Trait_description"]) -- end) - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHandler("OnMouseExit", function (self) + RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) - prevcontrol=CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"] + prevcontrol=RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"] -- text - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"] = WINDOW_MANAGER:CreateControl("CRT_GRID_"..k.."_"..id_craft.."_"..simcraft.."_text",CRT.UI.GRID_WD[k].panel,CT_LABEL) - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetHidden(true) - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetFont("ZoFontGame") - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetDimensions(360,20) - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetColor(CRT.SV.Settings.GRID.Color.r, CRT.SV.Settings.GRID.Color.g, CRT.SV.Settings.GRID.Color.b, CRT.SV.Settings.GRID.Color.a) - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetAlpha(1) - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetAnchor(TOPLEFT,prevcontrol,TOPRIGHT,0,0) --to right - - prevcontrol=CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"] -- set back to beginning of line + RT.UI.GRID_WD[k][id_craft][simcraft]["text"] = WINDOW_MANAGER:CreateControl("RT_GRID_"..k.."_"..id_craft.."_"..simcraft.."_text",RT.UI.GRID_WD[k].panel,CT_LABEL) + RT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetHidden(true) + RT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetFont("ZoFontGame") + RT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetDimensions(360,20) + RT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetAnchor(TOPLEFT,prevcontrol,TOPRIGHT,0,0) --to right + + prevcontrol=RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"] -- set back to beginning of line end end num_char = num_char+1 - CRT.UI.GRID_TLW:SetDimensions(width,CRT.UI.GRID_WD[k].panel:GetHeight()*num_char) + RT.UI.GRID_TLW:SetDimensions(width,RT.UI.GRID_WD[k].panel:GetHeight()*num_char) end -function CRT.GRID_Update(timestamp) +function RT.GRID_Update(timestamp) local emp_start, em_finish - for k, _ in pairs(CRT.SV.data.Craft) do - if ( (CRT.SV.data.Craft[k][0].Simu_craft ~= 0 or CRT.SV.data.Craft[k][1].Simu_craft ~= 0 or CRT.SV.data.Craft[k][2].Simu_craft ~= 0)) then + for k, _ in pairs(RT.SV.data.Craft) do + if ( (RT.SV.data.Craft[k][0].Simu_craft ~= 0 or RT.SV.data.Craft[k][1].Simu_craft ~= 0 or RT.SV.data.Craft[k][2].Simu_craft ~= 0)) then for id_craft = 0, 2,1 do - if (CRT.SV.data.Craft[k][id_craft].MaxResearch ~= nil ) then - local MaxResearch = CRT.SV.data.Craft[k][id_craft].MaxResearch - local Simu_craft = CRT.SV.data.Craft[k][id_craft].Simu_craft + if (RT.SV.data.Craft[k][id_craft].MaxResearch ~= nil ) then + local MaxResearch = RT.SV.data.Craft[k][id_craft].MaxResearch + local Simu_craft = RT.SV.data.Craft[k][id_craft].Simu_craft if Simu_craft == MaxResearch then emp_start = "" --no highlighting em_finish = "" @@ -214,13 +192,13 @@ function CRT.GRID_Update(timestamp) em_finish = "|r" end if (id_craft == 0) then - CRT.UI.GRID_WD[k][id_craft][0]["BS_Text"]:SetText(" "..emp_start .. Simu_craft.." / "..MaxResearch .. em_finish) + RT.UI.GRID_WD[k][id_craft][0]["BS_Text"]:SetText(" "..emp_start .. Simu_craft.." / "..MaxResearch .. em_finish) elseif(id_craft == 1) then - CRT.UI.GRID_WD[k][id_craft][0]["CL_Text"]:SetText(" "..emp_start .. Simu_craft.." / "..MaxResearch .. em_finish) + RT.UI.GRID_WD[k][id_craft][0]["CL_Text"]:SetText(" "..emp_start .. Simu_craft.." / "..MaxResearch .. em_finish) elseif(id_craft == 2) then - CRT.UI.GRID_WD[k][id_craft][0]["WO_Text"]:SetText(" "..emp_start .. Simu_craft.." / "..MaxResearch .. em_finish) + RT.UI.GRID_WD[k][id_craft][0]["WO_Text"]:SetText(" "..emp_start .. Simu_craft.." / "..MaxResearch .. em_finish) end end @@ -228,41 +206,41 @@ function CRT.GRID_Update(timestamp) for simcraft = 1, 3,1 do - if (CRT.SV.data.Craft[k][id_craft].doing[simcraft] ~= nil)then + if (RT.SV.data.Craft[k][id_craft].doing[simcraft] ~= nil)then - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHidden(false) - CRT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetTexture(CRT.SV.data.Craft[k][id_craft].doing[simcraft]["Item_icon"]) + RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHidden(false) + RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetTexture(RT.SV.data.Craft[k][id_craft].doing[simcraft]["Item_icon"]) - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHidden(false) - CRT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetTexture(CRT.SV.data.Craft[k][id_craft].doing[simcraft]["Trait_icon"]) + RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHidden(false) + RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetTexture(RT.SV.data.Craft[k][id_craft].doing[simcraft]["Trait_icon"]) - local currenttimer = CRT.SV.data.Craft[k][id_craft].doing[simcraft]["EndTimeStamp"] - timestamp - 1 + local currenttimer = RT.SV.data.Craft[k][id_craft].doing[simcraft]["EndTimeStamp"] - timestamp - 1 if (currenttimer > 0) then - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetHidden(false) - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetText(CRT.Converthms(currenttimer)) + RT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetHidden(false) + RT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetText(RT.Converthms(currenttimer)) else - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetHidden(false) - CRT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetText(CRT.L["Finished"]) - CRT.UI.GRID_WD[k].label:SetText("|cFF0000" .. string.upper(k) .."|r" ) + RT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetHidden(false) + RT.UI.GRID_WD[k][id_craft][simcraft]["text"]:SetText(RT.L["Finished"]) + RT.UI.GRID_WD[k].label:SetText("|cFF0000" .. string.upper(k) .."|r" ) end end end end end end - CRT.Set_Shortest() + RT.Set_Shortest() end -- move characters in grid -function CRT.GRID_Sort() +function RT.GRID_Sort() local panelheight - CRT.Char_sort() - panelheight = CRT.UI.GRID_WD[CRT.CharsInOrder[1]].panel:GetHeight() -- after scaling - for k, v in ipairs(CRT.CharsInOrder) do - CRT.UI.GRID_WD[v].panel:SetAnchor(TOPLEFT,CRT.UI.GRID_TLW,TOPLEFT,0,panelheight*(k-1)) + RT.Char_sort() + panelheight = RT.UI.GRID_WD[RT.CharsInOrder[1]].panel:GetHeight() -- after scaling + for k, v in ipairs(RT.CharsInOrder) do + RT.UI.GRID_WD[v].panel:SetAnchor(TOPLEFT,RT.UI.GRID_TLW,TOPLEFT,0,panelheight*(k-1)) end -- We shouldn't have to manually set the height of the TLW and scale it, but we do. Bug perhaps?? - CRT.UI.GRID_TLW:SetHeight(table.getn(CRT.CharsInOrder) * panelheight / CRT.UI.GRID_TLW:GetScale()) + RT.UI.GRID_TLW:SetHeight(table.getn(RT.CharsInOrder) * panelheight / RT.UI.GRID_TLW:GetScale()) end diff --git a/lua/Menu-function.lua b/lua/Menu-function.lua deleted file mode 100644 index 828760e..0000000 --- a/lua/Menu-function.lua +++ /dev/null @@ -1,406 +0,0 @@ --- Craft Research Timer (CRT) by @aTo (EU) --- v0.4.8 - -function CRT.SetLock(Newlock) - CRT.SV.Settings.lock = Newlock - if (CRT.UI.GRID_TLW~= nil) then - CRT.UI.GRID_TLW:SetMovable(Newlock) - end - if (CRT.UI.CRAFT_TLW[0] ~= nil) then - CRT.UI.CRAFT_TLW[0]:SetMovable(Newlock) - end - if (CRT.UI.CRAFT_TLW[1] ~= nil) then - CRT.UI.CRAFT_TLW[1]:SetMovable(Newlock) - end - if (CRT.UI.CRAFT_TLW[2] ~= nil) then - CRT.UI.CRAFT_TLW[2]:SetMovable(Newlock) - end -end - -function CRT.SetMode(NewMode) - CRT.SV.Settings.mode = NewMode -ReloadUI() -end - -function CRT.Settimer_format(Newtimer_format) - CRT.SV.Settings.timer_format = Newtimer_format -end - -function CRT.Gettimer_format() - local format = CRT.SV.Settings.timer_format - if (string.match(format, ":")) then - format = "smart" - CRT.SV.Settings.timer_format = format - end - return format -end - - --------------------------ALERT Components--------------------------------------- -function CRT.SetAlert(NewAlert) - CRT.SV.Settings.ALERT.hidden = NewAlert - if (CRT.UI.ALERT_TLW ~= nil) then - CRT.UI.ALERT_TLW:SetHidden(not NewAlert) - end -end - -function CRT.SetPreview(NewPreview) - CRT.SV.Settings.ALERT.preview = NewPreview - CRT.UI.ALERT_BD:SetHidden(not NewPreview) - if (CRT.UI.ALERT_TLW ~= nil) then - CRT.UI.ALERT_TLW:SetMovable(NewPreview) - end -end - -function CRT.GetALERTColor() - return CRT.SV.Settings.ALERT.Color.r, CRT.SV.Settings.ALERT.Color.g, CRT.SV.Settings.ALERT.Color.b, CRT.SV.Settings.ALERT.Color.a -end - -function CRT.SetALERTColor(r, g, b, a) - if (CRT.UI.ALERT_WD ~= nil) then - CRT.UI.ALERT_WD:AddMessage("New Alert Color", CRT.SV.Settings.ALERT.Color.r, CRT.SV.Settings.ALERT.Color.g, CRT.SV.Settings.ALERT.Color.b) - end - CRT.SV.Settings.ALERT.Color.r = r - CRT.SV.Settings.ALERT.Color.g = g - CRT.SV.Settings.ALERT.Color.b = b - CRT.SV.Settings.ALERT.Color.a = a -end - -function CRT.SetALERTBS(Alertswitch) - CRT.SV.Settings.ALERT.BS = Alertswitch -end - -function CRT.SetALERTCL(Alertswitch) - CRT.SV.Settings.ALERT.CL = Alertswitch -end -function CRT.SetALERTWO(Alertswitch) - CRT.SV.Settings.ALERT.WO = Alertswitch -end - --------------------------GRID Components--------------------------------------- -function CRT.GetGRIDBackdropAlpha() - local BackdropAlphaPercent = CRT.SV.Settings.GRID.BackdropAlpha * 100 - return BackdropAlphaPercent -end -function CRT.SetGRIDBackdropAlpha(NewGRIDBackdropAlphaPercent) - local NewGRIDBackdropAlpha = NewGRIDBackdropAlphaPercent / 100 - if (CRT.UI.GRID_BD ~= nil) then - CRT.UI.GRID_BD:SetAlpha(NewGRIDBackdropAlpha) - end - CRT.SV.Settings.GRID.BackdropAlpha = NewGRIDBackdropAlpha -end - -function CRT.GetGRIDScale() - local ScalePercent = CRT.SV.Settings.GRID.Scale * 100 - return ScalePercent -end -function CRT.SetGRIDScale(NewGRIDScalePercent) - local NewGRIDScale = NewGRIDScalePercent / 100 - if (CRT.UI.GRID_TLW~= nil) then - CRT.UI.GRID_TLW:SetScale(NewGRIDScale) - end - CRT.SV.Settings.GRID.Scale = NewGRIDScale - CRT.GRID_Sort() -end - -function CRT.GetGRIDColor() - return CRT.SV.Settings.GRID.Color.r, CRT.SV.Settings.GRID.Color.g, CRT.SV.Settings.GRID.Color.b, CRT.SV.Settings.GRID.Color.a -end - -function CRT.SetGRIDColor(r, g, b, a) - CRT.SV.Settings.GRID.Color.r = r - CRT.SV.Settings.GRID.Color.g = g - CRT.SV.Settings.GRID.Color.b = b - CRT.SV.Settings.GRID.Color.a = a -end - --------------------------BS Components--------------------------------------- - -function CRT.SetTrackerBS(state) - CRT.SV.Settings.BS.craft = state - if (CRT.UI.CRAFT_TLW[0] ~= nil) then - CRT.UI.CRAFT_TLW[0]:SetHidden(not state) - end -end - -function CRT.SetBSHide0(NewBSHide0) - CRT.SV.Settings.BS.Hide_0 = NewBSHide0 - if (CRT.UI.CRAFT_TLW[0] ~= nil and NewBSHide0 == false and CRT.SV.Settings.BS.Hide_Type ~= "Toggle keybind" and CRT.SV.Settings.BS.craft == true) then - CRT.UI.CRAFT_TLW[0]:SetHidden(false) - end -end - - -function CRT.SetBSHideMenu(NewBSHideMenu) - CRT.SV.Settings.BS.Hide_Type = NewBSHideMenu - if (NewBSHideMenu == "Toggle keybind") then - if (CRT.UI.CRAFT_TLW[0] ~= nil and CRT.SV.Settings.BS.craft == true) then - CRT.UI.CRAFT_TLW[0]:SetHidden(false) - end - if (CRT.UI.CRAFT_TLW[1] ~= nil and CRT.SV.Settings.CL.craft == true) then - CRT.UI.CRAFT_TLW[1]:SetHidden(false) - end - if (CRT.UI.CRAFT_TLW[2] ~= nil and CRT.SV.Settings.WO.craft == true) then - CRT.UI.CRAFT_TLW[2]:SetHidden(false) - end - end -end - - -function CRT.GetBSBackdropAlpha() - local BackdropAlphaPercent = CRT.SV.Settings.BS.BackdropAlpha * 100 - return BackdropAlphaPercent -end -function CRT.SetBSBackdropAlpha(NewBSBackdropAlphaPercent) - local NewBSBackdropAlpha = NewBSBackdropAlphaPercent / 100 - if (CRT.UI.CRAFT_TLW[0] ~= nil) then - CRT.UI.CRAFT_BD[0]:SetAlpha(NewBSBackdropAlpha) - end - CRT.SV.Settings.BS.BackdropAlpha = NewBSBackdropAlpha -end - -function CRT.GetBSScale() - local ScalePercent = CRT.SV.Settings.BS.Scale * 100 - return ScalePercent -end -function CRT.SetBSScale(NewBSScalePercent) - local NewBSScale = NewBSScalePercent / 100 - if (CRT.UI.CRAFT_TLW[0] ~= nil) then - CRT.UI.CRAFT_TLW[0]:SetScale(NewBSScale) - end - CRT.SV.Settings.BS.Scale = NewBSScale -end - -function CRT.GetBSColor() - return CRT.SV.Settings.BS.Color.r, CRT.SV.Settings.BS.Color.g, CRT.SV.Settings.BS.Color.b, CRT.SV.Settings.BS.Color.a -end - -function CRT.SetBSColor(r, g, b, a) - if (CRT.UI.CRAFT_TLW[0] ~= nil) then - CRT.UI.CRAFT_WD[0][0]["Craft_Text"]:SetColor(r,g,b,a) - for simcraft = 1, 3, 1 do - CRT.UI.CRAFT_WD[0][simcraft]["text"]:SetColor(r,g,b,a) - end - end - - CRT.SV.Settings.BS.Color.r = r - CRT.SV.Settings.BS.Color.g = g - CRT.SV.Settings.BS.Color.b = b - CRT.SV.Settings.BS.Color.a = a -end - - --------------------------CL Components--------------------------------------- -function CRT.SetTrackerCL(state) - CRT.SV.Settings.CL.craft = state - if (CRT.UI.CRAFT_TLW[1] ~= nil) then - CRT.UI.CRAFT_TLW[1]:SetHidden(not state) - end -end - -function CRT.SetCLHide0(NewCLHide0) - CRT.SV.Settings.CL.Hide_0 = NewCLHide0 - if (CRT.UI.CRAFT_TLW[1] ~= nil and NewCLHide0 == false and CRT.SV.Settings.CL.Hide_Type ~= "Toggle keybind" and CRT.SV.Settings.CL.craft == true) then - CRT.UI.CRAFT_TLW[1]:SetHidden(false) - end -end - - -function CRT.SetCLHideMenu(NewCLHideMenu) - CRT.SV.Settings.CL.Hide_Type = NewCLHideMenu - if (NewCLHideMenu == "Toggle keybind") then - if (CRT.UI.CRAFT_TLW[0] ~= nil and CRT.SV.Settings.BS.craft == true) then - CRT.UI.CRAFT_TLW[0]:SetHidden(false) - end - if (CRT.UI.CRAFT_TLW[1] ~= nil and CRT.SV.Settings.CL.craft == true) then - CRT.UI.CRAFT_TLW[1]:SetHidden(false) - end - if (CRT.UI.CRAFT_TLW[2] ~= nil and CRT.SV.Settings.WO.craft == true) then - CRT.UI.CRAFT_TLW[2]:SetHidden(false) - end - end -end - -function CRT.GetCLBackdropAlpha() - local BackdropAlphaPercent = CRT.SV.Settings.CL.BackdropAlpha * 100 - return BackdropAlphaPercent -end -function CRT.SetCLBackdropAlpha(NewCLBackdropAlphaPercent) - local NewCLBackdropAlpha = NewCLBackdropAlphaPercent / 100 - if (CRT.UI.CRAFT_BD[1] ~= nil) then - CRT.UI.CRAFT_BD[1]:SetAlpha(NewCLBackdropAlpha) - end - CRT.SV.Settings.CL.BackdropAlpha = NewCLBackdropAlpha -end - -function CRT.GetCLScale() - local ScalePercent = CRT.SV.Settings.CL.Scale * 100 - return ScalePercent -end -function CRT.SetCLScale(NewCLScalePercent) - local NewCLScale = NewCLScalePercent / 100 - if (CRT.UI.CRAFT_TLW[1] ~= nil) then - CRT.UI.CRAFT_TLW[1]:SetScale(NewCLScale) - end - CRT.SV.Settings.CL.Scale = NewCLScale -end - -function CRT.GetCLColor() -return CRT.SV.Settings.CL.Color.r, CRT.SV.Settings.CL.Color.g, CRT.SV.Settings.CL.Color.b, CRT.SV.Settings.CL.Color.a -end - -function CRT.SetCLColor(r, g, b, a) - if (CRT.UI.CRAFT_TLW[1] ~= nil) then - CRT.UI.CRAFT_WD[1][0]["Craft_Text"]:SetColor(r,g,b,a) - for simcraft = 1, 3, 1 do - CRT.UI.CRAFT_WD[1][simcraft]["text"]:SetColor(r,g,b,a) - end - end - - CRT.SV.Settings.CL.Color.r = r - CRT.SV.Settings.CL.Color.g = g - CRT.SV.Settings.CL.Color.b = b - CRT.SV.Settings.CL.Color.a = a -end - --------------------------Woodworking Components--------------------------------------- -function CRT.SetTrackerWO(state) - CRT.SV.Settings.WO.craft = state - if (CRT.UI.CRAFT_TLW[2] ~= nil) then - CRT.UI.CRAFT_TLW[2]:SetHidden(not state) - end -end - -function CRT.SetWOHide0(NewWOHide0) - CRT.SV.Settings.WO.Hide_0 = NewWOHide0 - if (CRT.UI.CRAFT_TLW[2] ~= nil and NewWOHide0 == false and CRT.SV.Settings.WO.Hide_0 ~= "Toggle keybind" and CRT.SV.Settings.WO.craft == true) then - CRT.UI.CRAFT_TLW[2]:SetHidden(false) - end -end - -function CRT.SetWOHideMenu(NewWOHideMenu) - CRT.SV.Settings.WO.Hide_Type = NewWOHideMenu - if (NewWOHideMenu == "Toggle keybind") then - if (CRT.UI.CRAFT_TLW[0] ~= nil and CRT.SV.Settings.BS.craft == true) then - CRT.UI.CRAFT_TLW[0]:SetHidden(false) - end - if (CRT.UI.CRAFT_TLW[1] ~= nil and CRT.SV.Settings.CL.craft == true) then - CRT.UI.CRAFT_TLW[1]:SetHidden(false) - end - if (CRT.UI.CRAFT_TLW[2] ~= nil and CRT.SV.Settings.WO.craft == true) then - CRT.UI.CRAFT_TLW[2]:SetHidden(false) - end - end -end - -function CRT.GetWOBackdropAlpha() - local BackdropAlphaPercent = CRT.SV.Settings.WO.BackdropAlpha * 100 - return BackdropAlphaPercent -end - -function CRT.SetWOBackdropAlpha(NewWOBackdropAlphaPercent) - local NewWOBackdropAlpha = NewWOBackdropAlphaPercent / 100 - if (CRT.UI.CRAFT_BD[2] ~= nil) then - CRT.UI.CRAFT_BD[2]:SetAlpha(NewWOBackdropAlpha) - end - CRT.SV.Settings.WO.BackdropAlpha = NewWOBackdropAlpha -end - -function CRT.GetWOScale() - local ScalePercent = CRT.SV.Settings.WO.Scale * 100 - return ScalePercent -end - -function CRT.SetWOScale(NewWOScalePercent) - local NewWOScale = NewWOScalePercent / 100 - if (CRT.UI.CRAFT_TLW[1] ~= nil) then - CRT.UI.CRAFT_TLW[2]:SetScale(NewWOScale) - end - CRT.SV.Settings.WO.Scale = NewWOScale -end - -function CRT.GetWOColor() - return CRT.SV.Settings.WO.Color.r, CRT.SV.Settings.WO.Color.g, CRT.SV.Settings.WO.Color.b, CRT.SV.Settings.WO.Color.a -end - -function CRT.SetWOColor(r, g, b, a) - if (CRT.UI.CRAFT_TLW[2] ~= nil) then - CRT.UI.CRAFT_WD[2][0]["Craft_Text"]:SetColor(r,g,b,a) - for simcraft = 1, 3, 1 do - CRT.UI.CRAFT_WD[2][simcraft]["text"]:SetColor(r,g,b,a) - end - end - - CRT.SV.Settings.WO.Color.r = r - CRT.SV.Settings.WO.Color.g = g - CRT.SV.Settings.WO.Color.b = b - CRT.SV.Settings.WO.Color.a = a -end - -function CRT.Reset() - - CRT.SV.Settings.icon_width = CRT.svDefaults.icon_width - CRT.SV.Settings.icon_height = CRT.svDefaults.icon_height - CRT.SV.Settings.text_width = CRT.svDefaults.text_width - CRT.SV.Settings.text_height = CRT.svDefaults.text_height - CRT.SV.Settings.mode = CRT.svDefaults.mode - CRT.SV.Settings.timer_format = CRT.svDefaults.timer_format - -- blacksmithing - CRT.SV.Settings.BS.offset.X = CRT.svDefaults.BS.offset.X - CRT.SV.Settings.BS.offset.Y = CRT.svDefaults.BS.offset.Y - CRT.SV.Settings.BS.craft = CRT.svDefaults.BS.craft - CRT.SV.Settings.BS.Hide_0 = CRT.svDefaults.BS.Hide_0 - CRT.SV.Settings.BS.Hide_Type = CRT.svDefaults.BS.Hide_Type - CRT.SV.Settings.BS.BackdropAlpha = CRT.svDefaults.BS.BackdropAlpha - CRT.SV.Settings.BS.Scale = CRT.svDefaults.BS.Scale - CRT.SV.Settings.BS.Color.r = CRT.svDefaults.BS.Color.r - CRT.SV.Settings.BS.Color.g = CRT.svDefaults.BS.Color.g - CRT.SV.Settings.BS.Color.b = CRT.svDefaults.BS.Color.b - CRT.SV.Settings.BS.Color.a = CRT.svDefaults.BS.Color.a - --clothing - CRT.SV.Settings.CL.offset.X = CRT.svDefaults.CL.offset.X - CRT.SV.Settings.CL.offset.Y = CRT.svDefaults.CL.offset.Y - CRT.SV.Settings.CL.craft = CRT.svDefaults.CL.craft - CRT.SV.Settings.CL.Hide_0 = CRT.svDefaults.CL.Hide_0 - CRT.SV.Settings.CL.Hide_Type = CRT.svDefaults.CL.Hide_Type - CRT.SV.Settings.CL.BackdropAlpha = CRT.svDefaults.CL.BackdropAlpha - CRT.SV.Settings.CL.Scale = CRT.svDefaults.CL.Scale - CRT.SV.Settings.CL.Color.r = CRT.svDefaults.CL.Color.r - CRT.SV.Settings.CL.Color.g = CRT.svDefaults.CL.Color.g - CRT.SV.Settings.CL.Color.b = CRT.svDefaults.CL.Color.b - CRT.SV.Settings.CL.Color.a = CRT.svDefaults.CL.Color.a - -- woodworking - CRT.SV.Settings.WO.offset.X = CRT.svDefaults.WO.offset.X - CRT.SV.Settings.WO.offset.Y = CRT.svDefaults.WO.offset.Y - CRT.SV.Settings.WO.craft = CRT.svDefaults.WO.craft - CRT.SV.Settings.WO.Hide_0 = CRT.svDefaults.WO.Hide_0 - CRT.SV.Settings.WO.Hide_Type = CRT.svDefaults.WO.Hide_Type - CRT.SV.Settings.WO.BackdropAlpha = CRT.svDefaults.WO.BackdropAlpha - CRT.SV.Settings.WO.Scale = CRT.svDefaults.WO.Scale - CRT.SV.Settings.WO.Color.r = CRT.svDefaults.WO.Color.r - CRT.SV.Settings.WO.Color.g = CRT.svDefaults.WO.Color.g - CRT.SV.Settings.WO.Color.b = CRT.svDefaults.WO.Color.b - CRT.SV.Settings.WO.Color.a = CRT.svDefaults.WO.Color.a - --Grid - CRT.SV.Settings.GRID.hidden = CRT.svDefaults.GRID.hidden - CRT.SV.Settings.GRID.offset.X = CRT.svDefaults.GRID.offset.X - CRT.SV.Settings.GRID.offset.Y = CRT.svDefaults.GRID.offset.Y - CRT.SV.Settings.GRID.BackdropAlpha = CRT.svDefaults.GRID.BackdropAlpha - CRT.SV.Settings.GRID.Scale = CRT.svDefaults.GRID.Scale - CRT.SV.Settings.GRID.Color.r = CRT.svDefaults.GRID.Color.r - CRT.SV.Settings.GRID.Color.g = CRT.svDefaults.GRID.Color.g - CRT.SV.Settings.GRID.Color.b = CRT.svDefaults.GRID.Color.b - CRT.SV.Settings.GRID.Color.a = CRT.svDefaults.GRID.Color.a - --Alert - CRT.SV.Settings.ALERT.hidden = CRT.svDefaults.ALERT.hidden - CRT.SV.Settings.ALERT.preview = CRT.svDefaults.ALERT.preview - CRT.SV.Settings.ALERT.offset.X = CRT.svDefaults.ALERT.offset.X - CRT.SV.Settings.ALERT.offset.Y = CRT.svDefaults.ALERT.offset.Y - CRT.SV.Settings.ALERT.Color.r = CRT.svDefaults.ALERT.Color.r - CRT.SV.Settings.ALERT.Color.g = CRT.svDefaults.ALERT.Color.g - CRT.SV.Settings.ALERT.Color.b = CRT.svDefaults.ALERT.Color.b - CRT.SV.Settings.ALERT.Color.a = CRT.svDefaults.ALERT.Color.a - - ReloadUI() - -end diff --git a/lua/ResearchTimer.lua b/lua/ResearchTimer.lua new file mode 100644 index 0000000..027e3aa --- /dev/null +++ b/lua/ResearchTimer.lua @@ -0,0 +1,92 @@ +-- Research Timer by hisdad +-- v1 + + + +local function SortTimeA (a,b) + return RT.SV.data.Craft[a].shortest < RT.SV.data.Craft[b].shortest +end + +function RT.Init(eventCode, addOnName) + + if(addOnName == RT.name) then + RT.Init_done = false + RT.playername = GetUnitName("player") + + -- SavedVariables + RT.SV.data = ZO_SavedVars:NewAccountWide(RT.svName, 1, nil, nil,nil ) + RT.GRID_Remove_Expired() + + RT.InitialiseLanguage() + + -- Slash commands + SLASH_COMMANDS[RT.cmdsetup] = RT.CommandText_setup + + -- Default sort + RT.SortFunction = SortTimeA + + -- Create Keybinds + ZO_CreateStringId("SI_BINDING_NAME_RT_toggleGRID", "|c96FF00Toggle GRID|r") + + local timestamp = GetTimeStamp() + + RT.SV.data.Craft[RT.playername] = {} + RT.SV.data.Craft[RT.playername]["Start"] = true + + RT.Collect_Data() + RT.GRID_Create() + RT.Init_done = true + -- Only after initialised do we hook any other events. + EVENT_MANAGER:RegisterForEvent(RT.name, EVENT_SMITHING_TRAIT_RESEARCH_STARTED, RT.Research_started) + end +end + +function RT.toggleGRID() + if (RT.UI.GRID_TLW:IsHidden() == true) then + RT.GRID_Sort() + RT.UI.GRID_TLW:SetHidden(false) + else + RT.UI.GRID_TLW:SetHidden(true) + end +end + +function RT.Converthms(timesec) + + local days = 0 + local hours = 0 + local minutes = 0 + local seconds = 0 + local humanDuration + + local function extractIntegerUnits(sec, unitduration) + local units = math.floor(sec / unitduration) + return units, sec - (units * unitduration) + end + + + days, timesec = extractIntegerUnits(timesec, 60*60*24) + hours, timesec = extractIntegerUnits(timesec, 60*60) + minutes, seconds = extractIntegerUnits(timesec, 60) + + + + humanDuration = string.format("%d:%02d", hours, minutes) + if (days > 0) then + humanDuration = string.format("%dd ", days)..humanDuration + end + + return humanDuration + +end + + + + + +function RT.CommandText_setup() + RT.toggleGRID() +end + +EVENT_MANAGER:RegisterForEvent(RT.name, EVENT_ADD_ON_LOADED, RT.Init) + + diff --git a/lua/header.lua b/lua/header.lua deleted file mode 100644 index ddbf795..0000000 --- a/lua/header.lua +++ /dev/null @@ -1,128 +0,0 @@ --- Craft Research Timer (CRT) by @aTo (EU) --- v0.4.11 - --- Define the variables to start with. -CRT = { - name = "CraftResearchTimer", - font = "ZoFontGame", - cmdsetup = "/crt", - tic = 1, - svName = "CraftResearchTimer_SavedVariables", - svVersion = 0.4, - version = "v0.4.11", - playername = "", - font = "ZoFontGame", - interval = 20, - width = 100, - height = 80, - UI = {}, - collect=0, - data_defaults = { - Craft = {} - }, - svDefaults = { - icon_width = 100, - icon_height = 80, - text_width = 200, - text_height = 80, - lock = true, - mode = "Icon", - timer_format = "smart", - BS = { - offset = { - X = 950, - Y = 540, - }, - craft = true, - Hide_0 = false, - Hide_Type = "Menus only", - BackdropAlpha = 0.8, - Scale = 1, - Color = { - r = 1, - g = 1, - b = 1, - a = 1 }, - }, - CL = { - offset = { - X = 1080, - Y = 540, - }, - craft = true, - Hide_0 = false, - Hide_Type = "Menus only", - BackdropAlpha = 0.8, - Scale = 1, - Color = { - r = 1, - g = 1, - b = 1, - a = 1 }, - }, - WO = { - offset = { - X = 1210, - Y = 540, - }, - craft = true, - Hide_0 = false, - Hide_Type = "Menus only", - BackdropAlpha = 0.8, - Scale = 1, - Color = { - r = 1, - g = 1, - b = 1, - a = 1 }, - }, - GRID = { - hidden = true, - offset = { - X = 950, - Y = 400, - }, - Hide_Type = "Menus only", - BackdropAlpha = 0.8, - Scale = 1, - Color = { - r = 1, - g = 1, - b = 1, - a = 1 }, - }, - ALERT = { - hidden = true, - preview = false, - BS = true, - CL = true, - WO = true, - offset = { - X = 560, - Y = 100, - }, - Color = { - r = 1, - g = 0, - b = 0, - a = 1 }, - - } - } -} - -CRT.SV={} -CRT.UI.GRID_TLW = {} -CRT.UI.GRID_BD = {} -CRT.UI.GRID_WD = {} -CRT.UI.GRID_BTN = {} - -CRT.UI.CRAFT_TLW = {} -CRT.UI.CRAFT_BD = {} -CRT.UI.CRAFT_WD = {} - -CRT.UI.ALERT_TLW = {} -CRT.UI.ALERT_BD = {} -CRT.UI.ALERT_WD = {} - - diff --git a/xml/Bindings.xml b/xml/Bindings.xml index a9fcb02..e12b97d 100644 --- a/xml/Bindings.xml +++ b/xml/Bindings.xml @@ -1,11 +1,8 @@ <Bindings> <Layer name="SI_KEYBINDINGS_LAYER_GENERAL"> - <Category name="|c96FF00Craft Research Timer|r"> - <Action name="CRT_ToggleUI"> - <Down>CRT.ToggleUI()</Down> - </Action> - <Action name="CRT_toggleGRID"> - <Down>CRT.toggleGRID()</Down> + <Category name="|c96FF00Research Timer|r"> + <Action name="RT_toggleGRID"> + <Down>RT.toggleGRID()</Down> </Action> </Category> </Layer> diff --git a/xml/CraftResearchTimer.xml b/xml/CraftResearchTimer.xml deleted file mode 100644 index d3aab36..0000000 --- a/xml/CraftResearchTimer.xml +++ /dev/null @@ -1,9 +0,0 @@ -<GuiXml> - <Controls> - <TopLevelControl name="CraftTimer" mouseEnabled="true" movable="true"> - <OnUpdate> - CRT.Update() - </OnUpdate> - </TopLevelControl> - </Controls> -</GuiXml>