..:D&G:.. Posted May 8, 2016 Share Posted May 8, 2016 Is there a way to have the tooltips thing on dxDrawImage? tooltips only work on gui elements and not on dx drawn... Maybe there is a way to detect the image by hovering the mouse over it? Thanks. Link to comment
Moderators IIYAMA Posted May 9, 2016 Moderators Share Posted May 9, 2016 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
..:D&G:.. Posted May 9, 2016 Author Share Posted May 9, 2016 I don't think that will work. 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 IIYAMA Posted May 9, 2016 Moderators Share Posted May 9, 2016 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now