aboutsummaryrefslogtreecommitdiff
path: root/gamemode/inventorysystem/quests/cl_quests.lua
blob: e485109c45a9c2bd9cb44a835e9942ae98e6102d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local log = nrequire("log.lua")
local inv = {}
--the gui elements
local elements = {}

local questlist = nil
local questlog = nil
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 qls = vgui.Create("DScrollPanel", spanel)
	qls:SetSize((scrw/4) - 40, hh)
	inv.qls = qls
	local sls = vgui.Create("DScrollPanel", spanel)
	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)
	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
		add_quest(panel,v,k)
	end

	local prox = {}
	prox.Put = function(s,position,item)
		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
end

return inv