aboutsummaryrefslogtreecommitdiff
path: root/gamemode/inventorysystem/quests/cl_quests.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-07-15 19:57:27 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2018-07-15 19:57:27 -0400
commit534103be54a129d8255988fc1e75a21a63c6021f (patch)
treec172b0884b4ca26452c5a74f5033b3b1526b6e3a /gamemode/inventorysystem/quests/cl_quests.lua
parent34d9ae7c4f4176fa9a943e9c2776afc32a867163 (diff)
downloadartery-534103be54a129d8255988fc1e75a21a63c6021f.tar.gz
artery-534103be54a129d8255988fc1e75a21a63c6021f.tar.bz2
artery-534103be54a129d8255988fc1e75a21a63c6021f.zip
Finished gather quest arcs
Finished base quest system, and added "Gather" arcs, where players gather a certain number of a certain item.
Diffstat (limited to 'gamemode/inventorysystem/quests/cl_quests.lua')
-rw-r--r--gamemode/inventorysystem/quests/cl_quests.lua84
1 files changed, 48 insertions, 36 deletions
diff --git a/gamemode/inventorysystem/quests/cl_quests.lua b/gamemode/inventorysystem/quests/cl_quests.lua
index 2052e19..9ad8eb1 100644
--- a/gamemode/inventorysystem/quests/cl_quests.lua
+++ b/gamemode/inventorysystem/quests/cl_quests.lua
@@ -1,59 +1,71 @@
+local log = nrequire("log.lua")
local inv = {}
--the gui elements
local elements = {}
local questlist = nil
local questlog = nil
-local function add_quest(panel,quest)
-
-end
+local function add_quest(panel,quest,position)
+ local questbutton = vgui.Create("DButton",questlist)
+ questbutton:SetText(quest.QuestName)
+ questbutton.DoClick = function()
+ log.debug("Setting quest text to:" .. quest:GetText())
+ questlog:SetText(quest:GetText())
+ end
+ log.debug("questlist: " .. tostring(questlist) .. "\tquestbutton: " .. tostring(questbutton))
+ questlist:AddItem(questbutton)
+ elements[position] = questbutton
+end
+local scrw, scrh = ScrW(), ScrH() -- Assume screen size dosn't change
+local hh = (scrh - 100) / 2
inv.DrawOnDPanel = function(self,panel)
local spanel = vgui.Create("DPanel", panel)
spanel:Dock(FILL)
- local halfs = vgui.Create("DVerticalDivider",spanel)
- questlist = vgui.Create("DListLayout", spanel)
- questlog = vgui.Create("DLabel",spanel)
- halfs:SetBottom(questlist)
- halfs:SetTop(questlog)
- questlist:Dock(FILL)
+ function spanel:Paint(w,h)
+ draw.RoundedBox( 8, 0, 0, w, h, Color( 255, 0, 0 ) )
+ end
+ local qls = vgui.Create("DScrollPanel", spanel)
+ function qls:Paint(w,h)
+ draw.RoundedBox( 8, 0, 0, w, h, Color( 0, 255, 0 ) )
+ end
+ qls:SetSize((scrw/4) - 40, hh)
+ inv.qls = qls
+ local sls = vgui.Create("DScrollPanel", spanel)
+ function sls:Paint(w,h)
+ draw.RoundedBox( 8, 0, 0, w, h, Color( 0, 0, 255 ) )
+ end
+ sls:SetSize((scrw/4) - 40, hh)
+ sls:SetPos(0,hh)
+ inv.sls = sls
+ questlist = vgui.Create("DGrid", qls)
+ questlist:SetCols(4)
+ questlist:SetColWide(((scrw/4) - 40) /4)
+ questlist:SetSize((scrw/4) - 50, hh)
+ function questlist:Paint(w,h)
+ draw.RoundedBox( 8, 0, 0, w, h, Color( 0, 255, 255 ) )
+ end
+ inv.questlist = questlist
+ inv.questlog = questlog
+ questlog = vgui.Create("DLabel", sls)
questlog:Dock(FILL)
+ questlog:SetDark(true)
+ questlog:SetText("Quest Log")
+ -- questlist:Dock(TOP)
+ -- questlog:Dock(BOTTOM)
for k,v in pairs(self.track) do
- local questbutton = vgui.Create("DButton",questlist)
- questbutton:SetText(v.QuestName)
- questbutton.DoClick = function()
- questlog:SetText(v:GetText())
- end
- for i,j in pairs(v) do
- local ipanel = vgui.Create("DListLayout",layout)
- local label = vgui.Create("DLabel",ipanel)
- label:Dock(TOP)
- label:SetDark(true)
- local bar = vgui.Create("DProgress",ipanel)
- bar:Dock(TOP)
- elements[j] = {
- ["label"] = label,
- ["bar" ] = bar,
- }
- set_xp_of(j,self.skills[j] or 0)
- ipanel:Add(label)
- ipanel:Add(bar)
- ipanel:InvalidateLayout()
- ipanel:SizeToChildren(true,true)
- layout:Add(ipanel)
- end
- layout:Dock(FILL)
- sheet:AddSheet(k, spanel, "icon16/cross.png")
+ add_quest(panel,v,k)
end
local prox = {}
prox.Put = function(s,position,item)
- --Observer might be called before our put()
+ add_quest(panel,item,position[1])
end
prox.Remove = function(s,position)
- --
+ questlist:RemoveItem(elements[position[1]])
+ -- log.error("Atempted to remove a quest")
end
return prox