Jump to content

[HELP] Tooltips popups on dxDrawImage


Recommended Posts

  • Moderators

Something like this:

local startBoundaryY = 400 
local itemsHeight = 30 
  
  
addEventHandler ( "onClientClick",root, 
function (button, state, cursorX, cursorY) 
    if button == "left" and state == "down" then 
        if cursorX > 300 and cursorX < 400 and cursorX > startBoundaryY then 
            local item = math.floor((cursorY-startBoundaryY)/itemsHeight) 
        end 
    end 
end) 

Link to comment

I don't think that will work.

h9GXG.png

As you see those "Rank" icons, a new one is added when a player is logged on the server, and players have different ranks so therefore different icons.

This is how the icons are drawn:

local SCOREBOARD_WIDTH              = 375               -- The scoreboard window width 
local SCOREBOARD_HEIGHT             = 400           -- The scoreboard window height 
local g_windowSize = { guiGetScreenSize () }    -- The window size 
local g_currentWidth = 0        -- Current window width. Used for the fade in/out effect. 
local g_currentHeight = 0       -- Current window height. Used for the fade in/out effect. 
local SCOREBOARD_X = math.floor ( ( g_windowSize[1] - SCOREBOARD_WIDTH ) / 2 ) 
local SCOREBOARD_Y = math.floor ( ( g_windowSize[2] - SCOREBOARD_HEIGHT ) / 2 ) 
  
-- Pre-calculate each row horizontal bounding box. 
local rowsBoundingBox = { { SCOREBOARD_X, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 } }  
  
local maxWidth = SCOREBOARD_X + g_currentWidth 
local left = rowsBoundingBox[1][1] 
-- Draw the body. 
-- Update the bounding box. 
local left, top, bottom = SCOREBOARD_X, SCOREBOARD_Y + SCOREBOARD_HEADER_HEIGHT + 2, SCOREBOARD_Y + g_currentHeight - 2 
  
-- Pre-calculate how much height will each row have. 
    local rowHeight = dxGetFontHeight ( 1, "default-bold" ) 
     
-- Add the offset for a new row 
top = top + rowHeight + 3 
  
dxDrawImage(left-10, top, 50, 20, "ranks/LEVEL"..rank..".png", 0, 0, 0, tocolor(255, 255, 255, 255), SCOREBOARD_POSTGUI) 

Link to comment
  • Moderators

Something like this. You have to adjust it to your girdlist.

local itemsHeight = rowHeight + 3 
  
local startBoundaryY = top 
  
addEventHandler ( "onClientClick",root, 
function (button, state, cursorX, cursorY) 
    if button == "left" and state == "down" then 
        if cursorX > 300 and cursorX < 400 and cursorX > startBoundaryY then 
            local yPositionOnItemIndex = (cursorY-startBoundaryY)/itemsHeight 
            if yPositionOnItemIndex < rowHeight then -- so without that 3 pixels offset on the top. 
                local itemIndex = math.floor(yPositionOnItemIndex) 
                outputDebugString("item: " .. tostring(itemIndex)) 
            end 
        end 
    end 
end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...