Began custom tooltip functions & other major stuff

master
AlmTech Software 5 years ago
parent 8d56602a80
commit 2b87f3b849
  1. 7
      gamemode/engine/core/client/cl_hud.lua
  2. 3
      gamemode/engine/derma/cl_menu.lua
  3. 45
      gamemode/engine/derma/lib/cl_menu_iteminfo.lua
  4. 10
      gamemode/engine/derma/lib/cl_menu_theme.lua
  5. 34
      gamemode/engine/derma/menus/menu_charinfo.lua

@ -55,7 +55,14 @@ function GM:HUDPaint()
end
end
end
end
function GM:Think()
if( Quantum.Client.IsInMenu ) then
if( gui.IsGameUIVisible() ) then -- hides the main menu for the player
gui.HideGameUI()
end
end
end
hook.Add( "RenderScreenspaceEffects", "Quantum_HUD_RenderLowHealth", function()

@ -13,7 +13,8 @@ local libs = {
["theme"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_theme.lua",
["dialogue"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua",
["sure"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_areusure.lua",
["fade"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_fade.lua"
["fade"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_fade.lua",
["iteminfo"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_iteminfo.lua"
}
Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end

@ -0,0 +1,45 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
local iteminfo = {}
local scale = Quantum.Client.ResolutionScale
local padding = math.Round( 10 * scale )
local padding_s = math.Round( 4 * scale )
local theme = Quantum.Client.Menu.GetAPI( "theme" )
function iteminfo.givetooltip( p )
local item = p:GetParent().item
local parWidth, parHeight = p:GetParent():GetSize()
local amountStr = ""
local tooltip = vgui.Create( "DPanel" )
tooltip:SetSize( 100 * scale, 80 * scale )
tooltip:SetVisible( false )
tooltip.Paint = function( self )
theme.itemtooltip( self, item )
end
if( item.amount > 1 ) then amountStr = "x" .. tostring( item.amount ) end
p.ItemInfoPanel = tooltip -- set the tooltip
p.Think = function( self )
self.ItemInfoPanel:SetVisible( self:IsHovered() )
if( self:IsHovered() ) then
self.ItemInfoPanel:SetPos( gui.MouseX(), gui.MouseY() - ( parHeight + padding )*2 )
end
end
--p:SetToolTip( item.name .. " " .. amountStr .. "\n\n" .. item.desc )
--p:SetTooltipPanel( tooltip )
--p.pnlTooltipPanel = tooltip -- overwrite the default tooltip
--p.strTooltipText = ""
end
return iteminfo

@ -137,14 +137,22 @@ end
function theme.itempanel( p, rarecolor )
local w, h = p:GetSize()
local icon = p.icon || p
surface.SetDrawColor( rarecolor || Color( 0, 0, 0, 120 ) )
surface.DrawRect( 0, 0, w, h )
if( p:IsHovered() ) then
if( icon:IsHovered() ) then
theme.borderpanel( p, Color( 116, 185, 255, 90 ) )
else
theme.borderpanel( p, Color( 255, 255, 255, 200 ) )
end
end
function theme.itemtooltip( p, item )
local w, h = p:GetSize()
surface.SetDrawColor( Color( 0, 0, 0, 255 ) )
surface.DrawRect( 0, 0, w, h )
end
return theme

@ -8,8 +8,8 @@
local menu = {}
local snm = Quantum.Client.Menu.GetAPI( "net" )
local page = Quantum.Client.Menu.GetAPI( "page" )
local theme = Quantum.Client.Menu.GetAPI( "theme" )
local iteminfo = Quantum.Client.Menu.GetAPI( "iteminfo" )
local resScale = Quantum.Client.ResolutionScale
local sw, sh = ScrW(), ScrH()
@ -113,7 +113,10 @@ function menu.open( dt )
itempanels[ii] = vgui.Create( "DPanel", itemframe )
itempanels[ii].index = ii -- set the vars
if( items[ii] ) then itempanels[ii].item = Quantum.Item.Get( items[ii][1] ) end -- get the items info through its id
if( items[ii] ) then
itempanels[ii].item = Quantum.Item.Get( items[ii][1] ) -- get the items info through its id
itempanels[ii].item.amount = Quantum.Item.Get( items[ii][2] ) || 1 -- get the amount
end
itempanels[ii]:SetSize( itemWidth, itemHeight )
if( count >= maxW ) then
@ -133,16 +136,39 @@ function menu.open( dt )
if( itempanels[ii].item == nil ) then -- get the items rarity color
itempanels[ii].itemcolor = Quantum.Rarity.None.color
print( ii, "is nil", itemcolor )
else
itempanels[ii].itemcolor = itempanels[ii].item.rarity.color
print( ii, "is an item", itemcolor )
end
itempanels[ii].Paint = function( self )
theme.itempanel( self, self.itemcolor )
end
---- Create the model icon for the item panel ----
if( itempanels[ii].item != nil && itempanels[ii].item.model != nil ) then
itempanels[ii].icon = vgui.Create( "DModelPanel", itempanels[ii] )
itempanels[ii].icon:SetSize( itempanels[ii]:GetSize() )
itempanels[ii].icon:SetPos( 0, 0 )
itempanels[ii].icon:SetModel( itempanels[ii].item.model )
itempanels[ii].icon:SetFOV( 45 )
-- get the dimensions of the models entity
local mn, mx = itempanels[ii].icon.Entity:GetRenderBounds()
local size = 0
-- calculate the vector axises so that the view doesn't go outside of the models renderbounds --
size = math.max( size, math.abs( mn.x ) + math.abs( mx.x ) )
size = math.max( size, math.abs( mn.y ) + math.abs( mx.y ) )
size = math.max( size, math.abs( mn.z ) + math.abs( mx.z ) )
-- Apply the new "data" --
itempanels[ii].icon:SetCamPos( Vector( size/2, size, size ) )
itempanels[ii].icon:SetLookAt( ( mn + mx )/2 )
iteminfo.givetooltip( itempanels[ii].icon ) -- give the item a tooltip
end
end

Loading…
Cancel
Save