diff --git a/Language/en.lua b/Language/en.lua index 6dbba4c..61e6ea3 100644 --- a/Language/en.lua +++ b/Language/en.lua @@ -4,9 +4,7 @@ function RT.InitialiseLanguage() RT.L = {} -- Settings / Config menu stuff - RT.L["Keybinds"] = "|c45D7F7Keybinds|r" - - + RT.L["Keybinds"] = "|c45D7F7Keybinds|r" RT.L["Clothing"] = "CLOTHING" RT.L["BS"] = "BLACKSMITHING" @@ -14,4 +12,5 @@ function RT.InitialiseLanguage() RT.L["Finished"] = "|cFF0000Finished|r" RT.L["Completed"] = "Research completed on" + RT.L["Loading"] = "Loading.." end diff --git a/ResearchTimer.txt b/ResearchTimer.txt index 6258c37..d2be921 100644 --- a/ResearchTimer.txt +++ b/ResearchTimer.txt @@ -1,14 +1,13 @@ ## Title: |c96FF00Research Timer|r - |c96FF00 v1|r -## APIVersion: 100010 +## APIVersion: 100011 ## SavedVariables: ResearchTimer ## Version: 1 ## Author: Hisdad -lua\core.lua -lua\grid.lua -lua\ResearchTimer.lua +lua\ResearchTimer.lua +lua\grid.lua xml\Bindings.xml diff --git a/lua/CORE.lua b/lua/CORE.lua deleted file mode 100644 index 79cc891..0000000 --- a/lua/CORE.lua +++ /dev/null @@ -1,107 +0,0 @@ --- Craft Research Timer (CRT) by @aTo (EU) --- v0.4.11 -RT = { - name = "ResearchTimer", - font = "ZoFontGame", - cmdsetup = "/rt", - version = "v1", - playername = "", - 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 = {} -RT.SV.data = {} - -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 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) - - 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 - local duration, timeRemaining = GetSmithingResearchLineTraitTimes(craft_type, ResearchLines, ResearchTrait) - - if (duration ~= nil and timeRemaining ~= nil) then - Simu_craft = Simu_craft + 1 - - - local traitType, trait_description, _ = GetSmithingResearchLineTraitInfo(craft_type,ResearchLines,ResearchTrait) - local _, trait_name, trait_icon, _, _, _, _ = GetSmithingTraitItemInfo(traitType+1) - - 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 - RT.SV.data.Craft[RT.playername][id_craft].MaxResearch = MaxResearch - RT.SV.data.Craft[RT.playername][id_craft].Simu_craft = Simu_craft -end - -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 RT.SortFunction ~= nil then - table.sort(RT.CharsInOrder, RT.SortFunction) - end -end - --- 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 (RT.SV.data.Craft) do - - shortest = 9999999999 - for craft =0,2, 1 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 - RT.SV.data.Craft[char].shortest = shortest - end -end - -function RT.Research_started() -- Triggered by Event - -- erase all data for this character - RT.SV.data.Craft[RT.playername] = {} - -- Collect new data - RT.Collect_Data() - - if (RT.UI.GRID_WD[RT.playername] == nil) then - RT.GRID_Create_Character(RT.playername) - end - RT.Set_Shortest() - RT.UI.GRID_WD[RT.playername].label:SetText(string.upper(RT.playername)) -- remove highlighting -end - diff --git a/lua/GRID.lua b/lua/GRID.lua index e538279..6a2849b 100644 --- a/lua/GRID.lua +++ b/lua/GRID.lua @@ -33,7 +33,7 @@ function RT.GRID_Create() 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: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 ) @@ -86,7 +86,7 @@ function RT.GRID_Create_Character(k) 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") + RT.UI.GRID_WD[k][0][0]["BS_Text"]:SetText(RT.L["Loading"]) ctl_headers[0] = RT.UI.GRID_WD[k][0][0]["BS_Icon"] --Clothing @@ -103,7 +103,7 @@ function RT.GRID_Create_Character(k) 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") + RT.UI.GRID_WD[k][1][0]["CL_Text"]:SetText(RT.L["Loading"]) ctl_headers[1] = RT.UI.GRID_WD[k][1][0]["CL_Icon"] --Woodworking @@ -120,7 +120,7 @@ function RT.GRID_Create_Character(k) 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") + RT.UI.GRID_WD[k][2][0]["WO_Text"]:SetText(RT.L["Loading"]) ctl_headers[2] = RT.UI.GRID_WD[k][2][0]["WO_Icon"] for id_craft = 0, 2,1 do -- column @@ -135,14 +135,6 @@ function RT.GRID_Create_Character(k) 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) - - RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"]:SetHandler("OnMouseExit", function (self) - ZO_Tooltips_HideTextTooltip() - end) prevcontrol= RT.UI.GRID_WD[k][id_craft][simcraft]["item_icon"] @@ -153,9 +145,6 @@ function RT.GRID_Create_Character(k) 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) RT.UI.GRID_WD[k][id_craft][simcraft]["trait_icon"]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() @@ -241,6 +230,6 @@ function RT.GRID_Sort() 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?? - RT.UI.GRID_TLW:SetHeight(table.getn(RT.CharsInOrder) * panelheight / RT.UI.GRID_TLW:GetScale()) + + RT.UI.GRID_TLW:SetHeight(table.getn(RT.CharsInOrder) * panelheight end diff --git a/lua/ResearchTimer.lua b/lua/ResearchTimer.lua index f4b1a30..c3f2d71 100644 --- a/lua/ResearchTimer.lua +++ b/lua/ResearchTimer.lua @@ -1,6 +1,111 @@ -- Research Timer by hisdad -- v1 +RT = { + name = "ResearchTimer", + font = "ZoFontGame", + cmdsetup = "/rt", + version = "v1", + playername = "", + 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 = {} +RT.SV.data = {} + +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 RT.Info_Research(craft_type,id_craft) + local Simu_craft = 0 + local ResearchLines, ResearchTrait + local MaxResearch = GetMaxSimultaneousSmithingResearch(craft_type) + local nbtype = GetNumSmithingResearchLines(craft_type) + + 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 + local duration, timeRemaining = GetSmithingResearchLineTraitTimes(craft_type, ResearchLines, ResearchTrait) + + if (duration ~= nil and timeRemaining ~= nil) then + Simu_craft = Simu_craft + 1 + + + local traitType, trait_description, _ = GetSmithingResearchLineTraitInfo(craft_type,ResearchLines,ResearchTrait) + local _, trait_name, trait_icon, _, _, _, _ = GetSmithingTraitItemInfo(traitType+1) + + 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]["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 + RT.SV.data.Craft[RT.playername][id_craft].MaxResearch = MaxResearch + RT.SV.data.Craft[RT.playername][id_craft].Simu_craft = Simu_craft +end + +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 RT.SortFunction ~= nil then + table.sort(RT.CharsInOrder, RT.SortFunction) + end +end + +-- 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 (RT.SV.data.Craft) do + + shortest = 9999999999 + for craft =0,2, 1 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 + RT.SV.data.Craft[char].shortest = shortest + end +end + +function RT.Research_started() -- Triggered by Event + -- erase all data for this character + RT.SV.data.Craft[RT.playername] = {} + -- Collect new data + RT.Collect_Data() + + if (RT.UI.GRID_WD[RT.playername] == nil) then + RT.GRID_Create_Character(RT.playername) + end + RT.Set_Shortest() + RT.UI.GRID_WD[RT.playername].label:SetText(string.upper(RT.playername)) -- remove highlighting +end + + local function SortTimeA (a,b) return RT.SV.data.Craft[a].shortest < RT.SV.data.Craft[b].shortest