From 9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 27 Aug 2016 17:08:46 -0400 Subject: Moved prayers to their own system --- gamemode/client/cl_inventory.lua | 233 +++++++++++++++++----------------- gamemode/client/cl_weaponswitch.lua | 3 + gamemode/client/healthbar.lua | 58 ++++++++- gamemode/client/qpanels/inventory.lua | 179 ++++++++++++++++++++++++++ gamemode/client/qpanels/prayers.lua | 170 +++++++++++++++++++++++++ gamemode/client/qpanels/quests.lua | 31 +++++ gamemode/client/qpanels/skills.lua | 10 ++ 7 files changed, 560 insertions(+), 124 deletions(-) create mode 100644 gamemode/client/cl_weaponswitch.lua create mode 100644 gamemode/client/qpanels/inventory.lua create mode 100644 gamemode/client/qpanels/prayers.lua create mode 100644 gamemode/client/qpanels/quests.lua create mode 100644 gamemode/client/qpanels/skills.lua (limited to 'gamemode/client') diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua index 837f7a1..b806846 100644 --- a/gamemode/client/cl_inventory.lua +++ b/gamemode/client/cl_inventory.lua @@ -3,11 +3,19 @@ ]] print("Hello from cl_inventory.lua") --debug.Trace() -local invfuncs -invfuncs = ART.invfuncs ---invfuncs = include("../gamemodes/artery/gamemode/shared/inventory_common.lua") ---invfuncs = include("../shared/inventory_common.lua") -assert(invfuncs ~= nil, "Dependency failed") + +ART.PrayerEquiped = ART.PrayerEquiped or { + false,false,false,false +} + +local lastpanel = lastpanel or 1 + +local inventorysheets = {} +ART.RegisterInventorySheet = function(func) + inventorysheets[#inventorysheets + 1] = func +end + + local plyisininventory = false --Displays a dropdown of options under the players mouse, if the option is clicked, does the function @@ -15,7 +23,7 @@ local plyisininventory = false --Be careful not to make this a recursive table. local function createMenuFor(menu, tbl) for k,v in pairs(tbl) do - if(isfunction(v)) then --This is a dead-end, add the menu + if isfunction(v) then --This is a dead-end, add the menu local thisoption = menu:AddOption(k,v) else --Otherwise it should be a table, recursively call to create local submenu = menu:AddSubMenu(k) @@ -24,102 +32,23 @@ local function createMenuFor(menu, tbl) end end -local function DrawBackpackOnDPanel(dp, backpack, backpacknum, tent) - local width = ScrW() - local height = ScrH() - local slotsize = math.Round(width / 32) - local backgrid = vgui.Create( "DGrid", dp ) - backgrid:SetPos( 10, 30 ) - backgrid:SetCols( backpack[2][1] ) - backgrid:SetColWide( backpack[2][2] ) - backgrid:Dock(FILL) - for i = 1,#(backpack[1]) do - for j = 1,#(backpack[1][i]) do - local item = backpack[1][j][i] - if type(backpack[1][j][i]) == "table" then - local itemwidth = 0 - for _,l in pairs(item.Shape) do - itemwidth = math.Max(itemwidth,#l) - end - local itemheight = #item.Shape - local invicon = vgui.Create( "DImageButton", dp ) - invicon:SetSize(slotsize * itemwidth, slotsize * itemheight) - invicon:SetPos(slotsize * (i - 1), slotsize * (j - 1)) - invicon:SetText(item.Name) - if item.Tooltip then - invicon:SetTooltip(item.Tooltip) - end - if item.Paint then - invicon.Paint = item.Paint - end - if item.DoOnPanel then - item.DoOnPanel(invicon) - end - --invicon.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,100,0)) end - invicon.DoClick = function() - if not item.GetOptions then return end - local menu = vgui.Create("DMenu") - createMenuFor(menu,item:GetOptions()) - menu:Open() - end - invicon.Item = item - invicon.invpos = {j,i} - invicon.ent = tent - invicon.backpacknum = backpacknum - invicon:Droppable("Inventory") - elseif not backpack[1][j][i] then - local emptyslot = vgui.Create("DPanel", dp) - emptyslot:SetSize(slotsize,slotsize) - emptyslot:SetPos(slotsize * (i - 1), slotsize * (j - 1)) - --emptyslot.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,0,100)) end - emptyslot:Receiver( "Inventory", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY ) - if not isDropped then return end - local icon = tableOfDroppedPanels[1] - local item = icon.Item - local curpos = icon.invpos - --Set the shape it was at to false - if not icon.wasequiped and icon.ent == tent then - assert(curpos ~= nil, "print curpos was nil when not equiped") - for k = 1,#item.Shape do - for l = 1,#(item.Shape[k]) do - if k == 1 and l == 1 then continue end - backpack[1][curpos[1] + k - 1][curpos[2] + l - 1] = false - end - end - backpack[1][curpos[1]][curpos[2]] = false - end - if invfuncs.CanFitInBackpack(backpack,j,i,item) then - local fromtbl = icon.invpos - local wasequiped = icon.wasequiped - if wasequiped then - net.Start("unequipitem") - net.WriteString(wasequiped) - net.WriteUInt(backpacknum,16) - net.WriteUInt(i,16) - net.WriteUInt(j,16) - net.SendToServer() - else - net.Start("moveitem") - net.WriteEntity(icon.ent) -- from ent - net.WriteEntity(tent) -- to ent - net.WriteUInt(icon.backpacknum,16) -- from backpack number - net.WriteUInt(backpacknum,16) -- to backpack number - net.WriteUInt(fromtbl[1],16) -- From position - net.WriteUInt(fromtbl[2],16) - net.WriteUInt(j,16) -- To position - net.WriteUInt(i,16) - net.SendToServer() - if item.onEquip ~= nil then - item:onEquip(LocalPlayer()) - end - end - end - end, {} ) - end +function ART.RefreshDisplays() + local discopy = LocalPlayer().invdisplays + LocalPlayer().invdisplays = {} + for k,ptbl in pairs(discopy) do + if not ptbl.panel:IsValid() then continue end + if ptbl.panel.Close ~= nil then + ptbl.panel:Close() + else + print(ptbl.panel) + error("panel has no close method") + ptbl.panel:Remove() end + ptbl.redraw() end end +local sheet function ShowInventory(ply,cmd,args) if plyisininventory then return end LocalPlayer().invdisplays = LocalPlayer().invdisplays or {} @@ -140,28 +69,83 @@ function ShowInventory(ply,cmd,args) plyisininventory = false end - local sheet = vgui.Create( "DPropertySheet", invpanel ) + sheet = vgui.Create( "DPropertySheet", invpanel ) sheet:Dock( FILL ) - local invsheet = vgui.Create( "DPanel", sheet ) - invsheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end - sheet:AddSheet( "Inventory", invsheet, "icon16/cross.png" ) + for k,v in pairs(inventorysheets) do + local name,tsheet,image = v() + sheet:AddSheet(name,tsheet,image) + tsheet.sheetnum = name + end + sheet:SwitchToName(lastpanel) + + --[[ + + local prayersheet = vgui.Create( "DListLayout", sheet) + sheet:AddSheet( "Prayers", prayersheet, "icon16/coins.png") + + --Prayers + local prayergridscroll = vgui.Create("DScrollPanel") + prayergridscroll:SetSize( (width / 4) - 20, height / 3 ) + prayergridscroll:SetPos( 5, 5 ) + prayersheet:Add(prayergridscroll) + local prayergrid = vgui.Create( "DGrid", prayergridscroll ) + prayergrid:SetPos( 5 , 5 ) + prayergrid:Dock(FILL) - local skillsheet = vgui.Create( "DPanel", sheet ) - skillsheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end - sheet:AddSheet( "Skills", skillsheet, "icon16/tick.png" ) + prayergrid:SetCols( (width / 4) / 64 ) + prayergrid:SetColWide( 64 ) + prayergrid:SetRowHeight(64) + prayergridscroll:AddItem(prayergrid) - local questsheet = vgui.Create( "DPanel", sheet) - questsheet.Paint = function(self,w,h) draw.RoundedBox(4,0,0,w,h,Color(157,160,167)) end - sheet:AddSheet( "Quests", questsheet, "icon16/house.png") + for k,v in pairs(ART.Prayer) do + local but = vgui.Create( "DButton", prayergrid ) + but:SetText( v.Name ) + but:SetSize( 64, 64 ) + but:SetWrap(true) + prayergrid:AddItem( but ) + but.PrayerName = v.Name + but:Droppable("PrayerBind") + end + + local prayerbindgrid = vgui.Create("DGrid") + prayerbindgrid:SetPos(height * (2 / 3),5) + prayerbindgrid:SetSize((width / 4) - 20, height / 3) + prayerbindgrid:SetColWide(64) + prayerbindgrid:SetRowHeight(64) + function prayerbindgrid:Paint(w,h) + draw.RoundedBox( 8, 0, 0, w, h, Color( 0, 255, 0 ) ) + end + local n = 0 + for k,v in pairs(ART.PrayerEquiped) do + n = n + 1 + local but = vgui.Create( "DPanel", prayerbindgrid ) + but:SetSize(64, 64) + if v ~= false then + local prayerbut = vgui.Create( "DLabel", but ) + prayerbut:SetText( v.Name ) + prayerbut:SetSize( 64, 64 ) + prayerbut:SetWrap(true) + else + local blabel = vgui.Create( "DLabel", but ) + blabel:SetText( "F" .. k ) + blabel:SetDark(true) + but:Receiver( "PrayerBind", function( self, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY ) + if not isDropped then return end + ART.PrayerEquiped[k] = tableOfDroppedPanels.PrayerName + print("Prayer bound to " .. k) + end) + end + prayerbindgrid:AddItem(but) + end + prayersheet:Add(prayerbindgrid) --Display quests local questselector = vgui.Create( "DScrollPanel", questsheet ) questselector:SetSize((width / 4) - 20, (height / 2) - 40) questselector:SetPos(0,0) local questinfo = vgui.Create("DScrollPanel", questsheet) - questinfo:SetSize(width / 4, (height / 2)) - --questinfo.Paint = function(self,w,h) draw.RoundedBox(4,0,0,w,h,Color(0,160,167)) end + questinfo:SetSize(width / 4, height / 2) questinfo:SetPos(0,height / 2) for k,v in pairs(LocalPlayer().Quests or {}) do print("Displaying quest:" .. k) @@ -223,8 +207,6 @@ function ShowInventory(ply,cmd,args) if v.DoOnEqupPanel then v.DoOnEqupPanel(eqslot) end - --eqslot:SetImage( "overviews/de_inferno", "vgui/avatar_default" ) - --eqslot.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(100,0,0)) end eqslot:Droppable("Inventory") eqslot.Item = v eqslot.wasequiped = k @@ -245,36 +227,51 @@ function ShowInventory(ply,cmd,args) DrawBackpackOnDPanel(tbacksheet,v,k,LocalPlayer()) end + ]] + end + + hook.Add("OnSpawnMenuOpen","ArteryOpenInventory",ShowInventory) hook.Add("OnSpawnMenuClose","ArteryCloseInventory",function() + lastpanel = sheet:GetActiveTab():GetPanel().sheetnum for k,v in pairs(LocalPlayer().invdisplays) do if not v.panel:IsValid() then continue end - PrintTable(v) + --PrintTable(v) v.panel:Close() LocalPlayer().invdisplays[k] = nil end - --if LocalPlayer().invpanel == nil then return end - --LocalPlayer().invpanel:Remove() plyisininventory = false end) concommand.Add("showinventory",ShowInventory) local viewdistance = 100 local rotatespeed = 65 +local bone = nil +local previousheadscale = Vector(1,1,1) hook.Add("CalcView","ArteryInventoryView",function(ply,pos,ang,fov,nearz,farz) + if bone == nil then + bone = LocalPlayer():LookupBone("ValveBiped.Bip01_Head1") + end local view = {} + --view.origin = LocalPlayer():GetBonePosition(bone) + LocalPlayer():GetUp() * 2 view.origin = pos if plyisininventory then - local xoff = viewdistance * math.sin(math.rad(CurTime() * rotatespeed)) - local yoff = viewdistance * math.cos(math.rad(CurTime() * rotatespeed)) - view.origin = view.origin + ( Vector(xoff,yoff,10) ) + local trot = math.rad(CurTime() * rotatespeed) + local xoff = viewdistance * math.sin(trot) + local yoff = viewdistance * math.cos(trot) + view.origin = view.origin + Vector(xoff,yoff,10) ang.pitch = 20 ang.yaw = (-CurTime() * rotatespeed) - 90 end view.angles = ang view.fov = fov + if not plyisininventory then + LocalPlayer():ManipulateBoneScale(bone,Vector(0,0,0)) + else + LocalPlayer():ManipulateBoneScale(bone,previousheadscale) + end view.drawviewer = plyisininventory return view diff --git a/gamemode/client/cl_weaponswitch.lua b/gamemode/client/cl_weaponswitch.lua new file mode 100644 index 0000000..5aaed87 --- /dev/null +++ b/gamemode/client/cl_weaponswitch.lua @@ -0,0 +1,3 @@ +function GM:PlayerSwitchWeapon( ply, oldWeapon, newWeapon ) + return false +end diff --git a/gamemode/client/healthbar.lua b/gamemode/client/healthbar.lua index d9a050c..67a3090 100644 --- a/gamemode/client/healthbar.lua +++ b/gamemode/client/healthbar.lua @@ -35,9 +35,14 @@ function draw.DrawElipse(x,y,radius,elong,rotation) surface.DrawPoly( cir ) end +local width,height = ScrW(),ScrH() +local padding = height / 32 +local barheight = height / 16 +local bubbles = {} local blobs = {} local lastpos = 0 -local delpoint = ScrH() +local bubbleradius = height/64 +local delpoint = height hook.Add( "Tick", "Hudpaintbloodtick",function() for k,v in pairs(blobs) do if v.y > delpoint then @@ -51,15 +56,32 @@ hook.Add( "Tick", "Hudpaintbloodtick",function() } end end + for k,v in pairs(bubbles) do + if v.y < height - padding - barheight -bubbleradius then + bubbles[k] = nil + else + local subheight = v.y - (1.5 + math.sin((v.y/4) + (v.x*10)))/5 + bubbles[k].y = subheight + end + end end) local lasthealth -local width,height = ScrW(),ScrH() -local padding = height / 32 -local barheight = height / 16 local obarlength = width / 4 local barlength = obarlength local xs,ys = padding,height - padding - barheight +local bubblespawnrate,bubblespawnchance = 1,0.7 + +timer.Create("Healthbar_bubble_timer",bubblespawnrate,0,function() + if math.random() < bubblespawnchance then + local newbubble = { + ["x"] = math.random(xs + bubbleradius,barlength-bubbleradius), + ["y"] = height - padding + bubbleradius + } + table.insert(bubbles,newbubble) + end +end) + hook.Add( "HUDPaint", "HUD_DrawHealth", function() --Spawn a bunch of blobs if our health has changed @@ -87,14 +109,38 @@ hook.Add( "HUDPaint", "HUD_DrawHealth", function() end lasthealth = health end - --Draw the current health thing + --Background surface.SetDrawColor(100,100,100,100) surface.DrawRect( xs, ys, obarlength, barheight) + --Foreground surface.SetDrawColor( 150, 0, 0, 255 ) surface.DrawRect( xs, ys, barlength, barheight ) + --Heighlighting/shadows + local heighlightheight = barheight/3 + for k = 1, heighlightheight do + local perc = Lerp(k/heighlightheight,100,0) + surface.SetDrawColor( 150+perc, perc, perc, 255) + surface.DrawRect( xs, ys+k, barlength, 1) + end + for k = 1, heighlightheight do + local perc = Lerp(k/heighlightheight,0,100) + surface.SetDrawColor( 150 - perc, 0, 0, 255) + surface.DrawRect(xs, ys+k+(2*heighlightheight), barlength, 1) + end + + --Draw bubbles + render.SetScissorRect( xs, ys, xs + barlength, ys + barheight, true ) -- Enable the rect + surface.SetDrawColor(250,150,150,10) + for k,v in pairs(bubbles) do + surface.DrawCircle(v.x,v.y,bubbleradius,250,150,150,30) + draw.DrawElipse(v.x,v.y,bubbleradius,1,0) + end + render.SetScissorRect( 0, 0, 0, 0, false ) -- Disable after you are done + --Draw the animation for blobs + surface.SetDrawColor(150,0,0,255) for k,v in pairs(blobs) do --Elongation is based on velocity local elong = (v.yv^2 + v.xv^2)^0.5 @@ -102,6 +148,6 @@ hook.Add( "HUDPaint", "HUD_DrawHealth", function() elong = math.Clamp(elong,1,3) --Rotation is also based on velcotiy local rot = math.deg(math.atan(v.yv/v.xv)) - draw.DrawElipse(v.x,v.y,10/elong,elong,rot) + draw.DrawElipse(v.x,v.y,10/elong,elong, rot) end end ) diff --git a/gamemode/client/qpanels/inventory.lua b/gamemode/client/qpanels/inventory.lua new file mode 100644 index 0000000..f4adad6 --- /dev/null +++ b/gamemode/client/qpanels/inventory.lua @@ -0,0 +1,179 @@ +local invfuncs +invfuncs = ART.invfuncs +--invfuncs = include("../gamemodes/artery/gamemode/shared/inventory_common.lua") +--invfuncs = include("../shared/inventory_common.lua") +assert(invfuncs ~= nil, "Dependency failed") + +local function DrawBackpackOnDPanel(dp, backpack, backpacknum, tent) + local width = ScrW() + local height = ScrH() + local slotsize = math.Round(width / 32) + local backgrid = vgui.Create( "DGrid", dp ) + backgrid:SetPos( 10, 30 ) + backgrid:SetCols( backpack[2][1] ) + backgrid:SetColWide( backpack[2][2] ) + backgrid:Dock(FILL) + for i = 1,#(backpack[1]) do + for j = 1,#(backpack[1][i]) do + local item = backpack[1][j][i] + if type(backpack[1][j][i]) == "table" then + local itemwidth = 0 + for _,l in pairs(item.Shape) do + itemwidth = math.Max(itemwidth,#l) + end + local itemheight = #item.Shape + local invicon = vgui.Create( "DImageButton", dp ) + invicon:SetSize(slotsize * itemwidth, slotsize * itemheight) + invicon:SetPos(slotsize * (i - 1), slotsize * (j - 1)) + invicon:SetText(item.Name) + if item.Tooltip then + invicon:SetTooltip(item.Tooltip) + end + if item.Paint then + invicon.Paint = item.Paint + end + if item.DoOnPanel then + item.DoOnPanel(invicon) + end + --invicon.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,100,0)) end + invicon.DoClick = function() + if not item.GetOptions then return end + local menu = vgui.Create("DMenu") + createMenuFor(menu,item:GetOptions()) + menu:Open() + end + invicon.Item = item + invicon.invpos = {j,i} + invicon.ent = tent + invicon.backpacknum = backpacknum + invicon:Droppable("Inventory") + elseif not backpack[1][j][i] then + local emptyslot = vgui.Create("DPanel", dp) + emptyslot:SetSize(slotsize,slotsize) + emptyslot:SetPos(slotsize * (i - 1), slotsize * (j - 1)) + --emptyslot.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,0,100)) end + emptyslot:Receiver( "Inventory", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY ) + if not isDropped then return end + local icon = tableOfDroppedPanels[1] + local item = icon.Item + local curpos = icon.invpos + --Set the shape it was at to false + if not icon.wasequiped and icon.ent == tent then + assert(curpos ~= nil, "print curpos was nil when not equiped") + for k = 1,#item.Shape do + for l = 1,#(item.Shape[k]) do + if k == 1 and l == 1 then continue end + backpack[1][curpos[1] + k - 1][curpos[2] + l - 1] = false + end + end + backpack[1][curpos[1]][curpos[2]] = false + end + if invfuncs.CanFitInBackpack(backpack,j,i,item) then + local fromtbl = icon.invpos + local wasequiped = icon.wasequiped + if wasequiped then + net.Start("unequipitem") + net.WriteString(wasequiped) + net.WriteUInt(backpacknum,16) + net.WriteUInt(i,16) + net.WriteUInt(j,16) + net.SendToServer() + else + net.Start("moveitem") + net.WriteEntity(icon.ent) -- from ent + net.WriteEntity(tent) -- to ent + net.WriteUInt(icon.backpacknum,16) -- from backpack number + net.WriteUInt(backpacknum,16) -- to backpack number + net.WriteUInt(fromtbl[1],16) -- From position + net.WriteUInt(fromtbl[2],16) + net.WriteUInt(j,16) -- To position + net.WriteUInt(i,16) + net.SendToServer() + if item.onEquip ~= nil then + item:onEquip(LocalPlayer()) + end + end + end + end, {} ) + end + end + end +end + +local invsheetfunc = function() + local width = ScrW() + local height = ScrH() + + + local invsheet = vgui.Create( "DPanel" ) + + invsheet.Paint = function( self, w, h ) end + + --Display gear + local slotsize = math.Round(width / 32) + local displaypos = { + ["Head"] = {(width / 8) - slotsize, 25}, + ["Body"] = {(width / 8) - slotsize, slotsize + 26}, + ["Legs"] = {(width / 8) - slotsize, (slotsize * 2) + 27}, + ["Boots"] = {(width / 8) - slotsize, (slotsize * 3) + 28}, + ["Gloves"] = {(width / 8) + (slotsize), (slotsize * 2) + 27}, + ["Left"] = {(width / 8) - (1.5 * slotsize), (slotsize * 4) + 29}, + ["Right"] = {(width / 8) - (0.5 * slotsize), (slotsize * 4) + 29} + } + for k,v in pairs (LocalPlayer().Inventory.Equiped) do + if v == false then + local eqslot = vgui.Create( "DPanel", invsheet ) + eqslot:SetSize( slotsize, slotsize ) + eqslot:SetPos(displaypos[k][1],displaypos[k][2]) + eqslot:Receiver( "Inventory", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY ) + if not isDropped then return end + print("Attempting to equip") + local icon = tableOfDroppedPanels[1] + local item = icon.Item + if item.Equipable == k then + net.Start("equipitem") + net.WriteUInt(icon.backpacknum,16) -- Backpack number + local fromtbl = icon.invpos + net.WriteUInt(fromtbl[1],16) -- From position + net.WriteUInt(fromtbl[2],16) + net.WriteString(k) + net.SendToServer() + end + end, {} ) + else + local eqslot = vgui.Create("DImageButton",invsheet) + eqslot:SetSize(slotsize,slotsize) + eqslot:SetPos(displaypos[k][1],displaypos[k][2]) + if v.PaintEquiped then + eqslot.Paint = v.PaintEquiped + end + if v.DoOnEqupPanel then + v.DoOnEqupPanel(eqslot) + end + eqslot:Droppable("Inventory") + eqslot.Item = v + eqslot.wasequiped = k + end + end + local moneylabel = vgui.Create("DLabel",invsheet) + moneylabel:SetPos(0,0) + moneylabel:SetSize(width/5,18) + moneylabel:SetText(string.format("Credits:%7d", ART.Credits or 0)) + print("Displaying credits:" .. string.format("Credits:%7d", ART.Credits or 0)) + + local backpacksheet = vgui.Create( "DPropertySheet", invsheet ) + backpacksheet:SetPos(0,slotsize * 6) + backpacksheet:SetSize((width / 4) - 26, height - (slotsize * 6) - 70) + for k,v in pairs(LocalPlayer().Inventory.Backpacks) do + local tbacksheet = vgui.Create( "DPanel", backpacksheet ) + tbacksheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end + backpacksheet:AddSheet( v[3], tbacksheet, "icon16/cross.png" ) + + DrawBackpackOnDPanel(tbacksheet,v,k,LocalPlayer()) + end + + return "Inventory", invsheet, "icon16/cross.png" +end + + +ART.RegisterInventorySheet(invsheetfunc) diff --git a/gamemode/client/qpanels/prayers.lua b/gamemode/client/qpanels/prayers.lua new file mode 100644 index 0000000..bc955ce --- /dev/null +++ b/gamemode/client/qpanels/prayers.lua @@ -0,0 +1,170 @@ + +local refreshboundprayers +local infopart +local prayersheet + +local function displaydefaulthelp(panel) + local ll = vgui.Create("DLabel",panel) + ll:Dock(FILL) + ll:SetWrap(true) + ll:SetDark(true) + ll:SetText("Oh no! It looks like this dosen't have any help text yet!") +end + +local function createprayericon(parrent,prayer,equiped,place) + + local width = ScrW() + local height = ScrH() + + local ret = vgui.Create("DButton",parrent) + ret:SetText(prayer) + ret:SetWrap(true) + ret:SetSize(64,64) + local prayertbl = ART.GetPrayerByName(prayer) + assert(prayertbl ~= nil, "Could not find an appropriate prayer!") + if prayertbl.Paint then + ret.Paint = prayertbl.Paint + end + if prayertbl.DoOnPanel then + prayertbl.DoOnPanel(ret) + end + if equiped then + ret.DoClick = function(self) + self:Remove() + ART.PrayerEquiped[place] = false + refreshboundprayers() + infopart:Remove() + infopart = vgui.Create("DPanel") + infopart:SetSize( (width / 4) - 10, height / 3) + infopart:SetPos(0, height * 2 / 3) + prayersheet:Add(infopart) + end + else + ret:Droppable("PrayerBind") + ret.PrayerName = prayer + ret:SetSize(64,64) + ret.DoClick = function(self) + infopart:Remove() + infopart = vgui.Create("DPanel") + infopart:SetSize( (width / 4) - 10, height / 3) + prayersheet:Add(infopart) + local rettbl = ART.GetPrayerByName(prayer) + if rettbl.DisplayHelp ~= nil then + rettbl.DisplayHelp(infopart) + else + displaydefaulthelp(infopart) + end + end + end + return ret +end + +local function createreceiver(parrent,num) + local prayerbut = vgui.Create( "DPanel", parrent ) + local prayerlabel = vgui.Create("DLabel",prayerbut) + prayerlabel:SetText( "F" .. num ) + prayerlabel.Paint = function( self, w, h ) end + prayerlabel:SetWrap(true) + prayerlabel:SetDark(true) + prayerlabel:Dock(FILL) + prayerbut:Dock(FILL) + prayerbut:Receiver( "PrayerBind", function( self, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY ) + if not isDropped then return end + local pname = tableOfDroppedPanels[1].PrayerName + print("Prayer name:") + print(pname) + ART.PrayerEquiped[num] = pname + print("Prayer bound to " .. num) + prayerbut:Remove() + createprayericon(parrent,pname,true,num) + end) +end + +local function displayboundprayers(panel) + + local width = ScrW() + local height = ScrH() + + local prayerbindgrid = nil + + refreshboundprayers = function() + + if prayerbindgrid ~= nil then prayerbindgrid:Remove() end + + prayerbindgrid = vgui.Create("DGrid") + prayerbindgrid:SetPos(height * (2 / 3),5) + prayerbindgrid:SetSize((width / 4) - 20, height / 3) + prayerbindgrid:SetColWide(64) + prayerbindgrid:SetRowHeight(64) + function prayerbindgrid:Paint(w,h) + draw.RoundedBox( 8, 0, 0, w, h, Color( 0, 255, 0 ) ) + end + + for k,v in pairs(ART.PrayerEquiped) do + local but = vgui.Create( "DPanel", prayerbindgrid ) + but:SetSize(64, 64) + if v ~= false then + createprayericon(but,v,true,k) + else + createreceiver(but,k) + end + prayerbindgrid:AddItem(but) + end + panel:Add(prayerbindgrid) + end + refreshboundprayers() +end + +ART.RegisterInventorySheet(function() + + local width = ScrW() + local height = ScrH() + + prayersheet = vgui.Create( "DListLayout") + + local prayergridscroll = vgui.Create("DScrollPanel") + prayergridscroll:SetSize( (width / 4) - 20, height / 3 ) + prayergridscroll:SetPos( 5, 5 ) + prayersheet:Add(prayergridscroll) + local prayergrid = vgui.Create( "DGrid", prayergridscroll ) + prayergrid:SetPos( 5 , 5 ) + prayergrid:Dock(FILL) + + prayergrid:SetCols( (width / 4) / 64 ) + prayergrid:SetColWide( 64 ) + prayergrid:SetRowHeight(64) + prayergridscroll:AddItem(prayergrid) + + for k,v in pairs(ART.MyPrayer) do + print("Displaying prayer:" .. k) + print("Type:" .. type(k)) + if k == "" then + ART.MyPrayer[k] = nil + end + local but = createprayericon(prayergrid,k,false,nil) + prayergrid:AddItem(but) + end + + displayboundprayers(prayersheet) + + infopart = vgui.Create("DPanel") + infopart:SetSize( (width / 4) - 10, height / 3) + infopart:SetPos(0, height * 2 / 3) + prayersheet:Add(infopart) + + return "Prayers", prayersheet, "icon16/tick.png" +end) + +hook.Add("Think","art_prayer_keybinds",function() + local mapping = { + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + } + for k,v in pairs(mapping) do + if input.IsKeyDown(v) and ART.PrayerEquiped[k] then + ART.GetPrayerByName(ART.PrayerEquiped[k]).Pray() + end + end +end) diff --git a/gamemode/client/qpanels/quests.lua b/gamemode/client/qpanels/quests.lua new file mode 100644 index 0000000..1ca723b --- /dev/null +++ b/gamemode/client/qpanels/quests.lua @@ -0,0 +1,31 @@ + + +ART.RegisterInventorySheet(function() + + local width = ScrW() + local height = ScrH() + + local questsheet = vgui.Create( "DPanel") + questsheet.Paint = function(self,w,h) end + + --Display quests + local questselector = vgui.Create( "DScrollPanel", questsheet ) + questselector:SetSize((width / 4) - 20, (height / 2) - 40) + questselector:SetPos(0,0) + local questinfo = vgui.Create("DScrollPanel", questsheet) + questinfo:SetSize(width / 4, height / 2) + questinfo:SetPos(0,height / 2) + for k,v in pairs(LocalPlayer().Quests or {}) do + print("Displaying quest:" .. k) + local questbutton = vgui.Create( "DButton" , questselector ) + questbutton:Dock(TOP) + questbutton:SetText(k) + questbutton.DoClick = function() + print("At point of clicking, art is:") + PrintTable(ART) + ART.GetQuest(k).DrawQuestInfo(questinfo,v) + end + end + + return "Quests", questsheet, "icon16/house.png" +end) diff --git a/gamemode/client/qpanels/skills.lua b/gamemode/client/qpanels/skills.lua new file mode 100644 index 0000000..4693032 --- /dev/null +++ b/gamemode/client/qpanels/skills.lua @@ -0,0 +1,10 @@ + + + +ART.RegisterInventorySheet(function() + + local skillsheet = vgui.Create( "DPanel" ) + skillsheet.Paint = function( self, w, h ) end + + return "Skills", skillsheet, "icon16/tick.png" +end) -- cgit v1.2.3-70-g09d2