PANEL = {} PANEL.HeaderHieght = 15 PANEL.ItemIconPadding = 1 PANEL.ItemIconSize = 39 function PANEL:Init() self.CraftingList = CreateGenericListView(self, 0, 0, false) self.CraftingList:SetSize(540, 275) self.CraftingList:AddColumn("Recipe Results"):SetFixedWidth( 240 ) self.CraftingList:AddColumn("Recipe Requirements"):SetFixedWidth( 300 ) self.CraftHolder = CreateGenericPanel(self) self.CraftHolder:SetSize(540, 40) self.CraftHolder:SetPos(0, 279) self.CraftAmount = CreateGenericSlider(self.CraftHolder, "Craft how many?", 1, 10 , 0, nil) self.CraftButton = CreateGenericButton(self.CraftHolder, "Start Crafting") self.InfoButton = CreateGenericButton(self.CraftHolder, "Recipe Info") self.StopCraftButton = CreateGenericButton(self.CraftHolder, "Stop Crafting") self.InfoPopUp = CreateGenericFrame("Info", true, true) self.InfoPopUp:SetSize(200, 200) self.InfoPopUp:SetDeleteOnClose(false) self.InfoPopUp:SetVisible(true) self.InfoPopUp:Center() self.InfoPopUp:Close() self.InfoPopUpText = CreateGenericDLabel(self.InfoPopUp, "Default", "placeholder", clrWhite) self.InfoPopUpText:SetPos(10, 30) self.CraftButton:SetPos(2, 2) self.CraftButton:SetSize(100, 36) self.InfoButton:SetPos(206, 2) self.InfoButton:SetSize(100, 36) self.StopCraftButton:SetPos(104, 2) self.StopCraftButton:SetSize(100, 36) self.CraftAmount:SetPos(408, 2) self.CraftAmount:SetValue(1) self.CraftAmount:SetWide(130) self.StopCraftButton:SetDisabled(true) self.StopCraftButton.DoClick = function() timer.Stop("crafttimer") self.StopCraftButton:SetDisabled(true) self.CraftAmount:SetValue(1) end self.CraftButton.DoClick = function() for strRecipe, _ in pairs(LocalPlayer().Recipes or {}) do local recipe = RecipeTable(strRecipe).PrintName if (self.Selected and recipe == self.Selected:GetValue(1)) then if (self.CraftAmount:GetValue() > 0) then if (LocalPlayer():CanMake(strRecipe)) then RunConsoleCommand("UD_CraftRecipe", strRecipe) self.StopCraftButton:SetDisabled(false) if (self.CraftAmount:GetValue()-1 > 0) then timer.Create("crafttimer",RecipeTable(strRecipe).MakeTime + .1,self.CraftAmount:GetValue() - 1, function() if (LocalPlayer():CanMake(strRecipe)) then RunConsoleCommand("UD_CraftRecipe", strRecipe) self.CraftAmount:SetValue(self.CraftAmount:GetValue() - 1) if (self.CraftAmount:GetValue() < 1) then self.CraftAmount:SetValue(1) self.StopCraftButton:SetDisabled(true) end else self.CraftAmount:SetValue(1) Msg("Can not craft any more of this item.\n") //Possible to change to PrintMessage to print to HUD or chat timer.Stop("crafttimer") end end) end else Msg("Can not craft this item.\n") //Possible to change to PrintMessage to print to HUD or chat self.CraftAmount:SetValue(1) end end break end end end self.InfoButton.DoClick = function() for strRecipe, _ in pairs(LocalPlayer().Recipes or {}) do recipe = RecipeTable(strRecipe).PrintName if (self.Selected and recipe == self.Selected:GetValue(1)) then local strToolTip = "Ingredients:" for strItem, intAmount in pairs(RecipeTable(strRecipe).Ingredients) do strToolTip = strToolTip .. "\n" .. intAmount .. " " .. ItemTable(strItem).PrintName end strToolTip = strToolTip .. "\n\nProducts:" for strItem, intAmount in pairs(RecipeTable(strRecipe).Products) do strToolTip = strToolTip .. "\n" .. intAmount .. " " .. ItemTable(strItem).PrintName end strToolTip = strToolTip .. "\n\nRequirements:" if RecipeTable(strRecipe).NearFire then strToolTip = strToolTip .. "\nMust be done near fire" end for strMaster, intLevel in pairs(RecipeTable(strRecipe).RequiredMasters) do strToolTip = strToolTip .. "\n" .. intLevel .. " " .. MasterTable(strMaster).PrintName end self.InfoPopUpText:SetText(strToolTip) self.InfoPopUpText:SizeToContents() self.InfoPopUpText:SetWrap(true) self.InfoPopUp:MakePopup() self.InfoPopUp:Center() self.InfoPopUp:SetVisible(true) break end end end end function PANEL:PerformLayout() self.CraftingList:Clear() for strRecipe, _ in pairs(LocalPlayer().Recipes or {}) do local strToolTip = "" for strItem, intAmount in pairs(RecipeTable(strRecipe).Ingredients) do strToolTip = strToolTip .. intAmount .. " " .. ItemTable(strItem).PrintName .. " " end self.CraftingList:AddLine(RecipeTable(strRecipe).PrintName, strToolTip) end end function PANEL:Think() if (self.CraftingList and self.CraftingList:GetLine(self.CraftingList:GetSelectedLine()) != nil) then self.Selected = self.CraftingList:GetLine(self.CraftingList:GetSelectedLine()) or nil if self.InfoButton then self.InfoButton:SetDisabled(false) end if self.CraftButton then self.CraftButton:SetDisabled(false) end else if self.InfoButton then self.InfoButton:SetDisabled(true) end if self.CraftButton then self.CraftButton:SetDisabled(true) end if self.CraftAmount then self.CraftAmount:SetValue(1) end end end function PANEL:LoadSkills() end function PANEL:CreateNewTierList(pnlParent, intSkillNeeded, intTier) end function PANEL:AddSkill(pnlParent, strSkill, tblSkillTable) end function PANEL:LoadMasters() end function PANEL:LoadHeader() end vgui.Register("craftingtab", PANEL, "Panel")