[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Nick's Hyperlink code that was made for another user on this forum

Nick's Hyperlink code that was made for another user on this forum

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Tue 08 Mar 2016 04:56 AM (UTC)

Amended on Tue 08 Mar 2016 05:16 AM (UTC) by Wuggly

Message
I'm referring to the one in this link.
http://www.gammon.com.au/forum/?id=12868&reply=7#reply7
I'll post the code in next post to save ya bit of time.

After you mouseover, the colour becomes richer.

I've tried writing black text over it before it returns and redraws the text, tried drawing a black rectangle, among a few other things trying to keep it from doing that, but with no success.

It's almost as if it is turning the text bold, but not quite.

Yellow seems to be the only colour where it's not quite as noticeable, but I'm wanting to use a different colour.

If you make the text white, keeping the mouseover blue, after you mouseover the white text has a blue haze to it and if you make the mouseover colour red, after you mouseover it has a red haze to it.

Any idea's on how to fix this little issue?

EDIT: I'm using v4.94 and although that plugin says it requires v4.97, I updated to that version and the issue still exists.
[Go to top] top

Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Reply #1 on Tue 08 Mar 2016 04:56 AM (UTC)
Message

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="KillArea"
   author="Quit"
   id="1257642da6518030a25c93c4"
   language="Lua"
   purpose="List Area to level in"
   date_written="2015-05-03 20:32:36"
   requires="4.97"
   version="1.0"
   save_state="y"
   >

</plugin>

<aliases>
  <alias
   match="killlist"
   enabled="y"
   send_to="12"
   sequence="100"
  >

<send>
 
  WindowShow (win, true)

</send>
  </alias>
</aliases>

<!--  Script  -->
<script>
<![CDATA[

require "movewindow"  -- load the movewindow.lua module

win = GetPluginID () .. "_KillArea"
font = "f"

-----------------------------------------
-- one entry for each hyperlink you want drawn
-----------------------------------------
links = {
 { text = "Jungles of Verume", tip = "Goto Jungle of Verume", send = "mapper goto 30599" },
 { text = "Seven Wonders",     tip = "Goto Seven Wonders",    send = "mapper goto 32981" },

-- more here ...

 } -- end of links table

-----------------------------------------
-- draw hyperlink text in required colour
-----------------------------------------
function drawText (which, colour)
  Redraw ()
  return WindowText (win, font, which.text, which.x, which.y, 0, 0, ColourNameToRGB  (colour))
end -- drawText
 
-----------------------------------------
-- mouse up
-----------------------------------------
function mouseup_hyperlink (flags, hotspotid)
  Send (links [tonumber (hotspotid)].send)  
end -- mouseup_hyperlink

-----------------------------------------
-- mouse over
-----------------------------------------
function mouseover_hyperlink (flags, hotspotid)
  drawText (links [tonumber (hotspotid)], "blue")
end -- mouseover_hyperlink

-----------------------------------------
-- cancel mouse over
-----------------------------------------
function cancel_mouseover_hyperlink (flags, hotspotid)
  drawText (links [tonumber (hotspotid)], "yellow")
end -- cancel_mouseover_hyperlink

-----------------------------------------
-- mouse down
-----------------------------------------
function mousedown_hyperlink (flags, hotspotid)
  drawText (links [tonumber (hotspotid)], "white")
end -- mousedown_hyperlink

-----------------------------------------
-- cancel mouse down
-----------------------------------------
function cancel_mousedown_hyperlink (flags, hotspotid)
  drawText (links [tonumber (hotspotid)], "yellow")
end -- cancel_mousedown_hyperlink

-----------------------------------------
-- make one hyperlink at current x,y location
-----------------------------------------
function MakeHyperlink (item, which)
 
  -- remember current x and y in the links table
  which.x = x
  which.y = y
 
  width = drawText (which, "yellow")
 
  WindowAddHotspot (win, item, which.x, which.y, which.x + width, which.y + font_height, 
                    "mouseover_hyperlink", -- MouseOver 
                    "cancel_mouseover_hyperlink", -- CancelMouseOver 
                    "mousedown_hyperlink", -- MouseDown 
                    "cancel_mousedown_hyperlink", -- CancelMouseDown 
                    "mouseup_hyperlink", -- MouseUp 
                    which.tip, 
                    miniwin.cursor_hand,
                    0) --  Flag

  y = y + font_height

end -- MakeHyperlink

function OnPluginInstall ()
  -- install the window movement handler, get back the window position
  windowinfo = movewindow.install (win, miniwin.pos_top_right)  -- default to top right
  
  -- make window so I can grab the font info
  WindowCreate (win, 0, 0, 0, 0, miniwin.pos_top_right, 0, 0)
  
  -- add the font                 
  WindowFont (win, font, "Lucida Console", 9)  
  
  -- find its height
  font_height = WindowFontInfo (win, font, 1)  -- height

  -- position for first hyperlink  
  x = 10    -- all text indented this far in
  y = 25    -- first hyperlink this far down
                 
  maxTextWidth = 0
  
  -- find maximum width 
  for k, v in ipairs (links) do
    maxTextWidth = math.max (maxTextWidth, WindowTextWidth(win, font, v.text))
  end -- for
  
  -- make the proper window
  WindowCreate (win, 
               windowinfo.window_left, 
               windowinfo.window_top, 
               maxTextWidth + (x * 2), 
               y + (#links * font_height) + 5,
               windowinfo.window_mode,   
               windowinfo.window_flags,
               ColourNameToRGB "black")

  -- title background
  WindowRectOp (win, miniwin.rect_fill, 0, 0, 0, font_height + 5, ColourNameToRGB "gray", 0)
  
                 
  -- draw a border
  WindowRectOp (win, miniwin.rect_draw_edge, 0, 0, 0, 0, 
                miniwin.rect_edge_raised, 
                miniwin.rect_edge_at_all + miniwin.rect_option_softer_buttons) -- draw border
  
  movewindow.add_drag_handler (win, 0, 0, 0, font_height) -- add the drag handler

  -- first line
  WindowText (win, font, "Kill Areas", x, 5, 0, 0, ColourNameToRGB  "gainsboro")

  -- add all hyperlinks  
  for k, v in ipairs (links) do
    MakeHyperlink (k, v)
  end -- for
       
end -- OnPluginInstall

function OnPluginSaveState ()
  -- save window current location for next time  
  movewindow.save_state (win)
end -- function OnPluginSaveState

]]>
</script>

</muclient>
[Go to top] top

Posted by Fiendish   USA  (2,517 posts)  [Biography] bio   Global Moderator
Date Reply #2 on Tue 08 Mar 2016 12:22 PM (UTC)

Amended on Tue 08 Mar 2016 12:51 PM (UTC) by Fiendish

Message
I don't see what you're describing. Can you show a picture or something of what you see?

Also you need to change this

function mouseup_hyperlink (flags, hotspotid)
  Send (links [tonumber (hotspotid)].send)  
end -- mouseup_hyperlink

into this

function mouseup_hyperlink (flags, hotspotid)
  Execute (links [tonumber (hotspotid)].send)  
end -- mouseup_hyperlink

Because mapper goto is an alias. You don't want to send it to the server.



Also, you should add callbacks to delete the miniwindow if the plugin is disabled or uninstalled.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Fiendish   USA  (2,517 posts)  [Biography] bio   Global Moderator
Date Reply #3 on Tue 08 Mar 2016 12:32 PM (UTC)

Amended on Tue 08 Mar 2016 07:46 PM (UTC) by Fiendish

Message
Fiendish said:

I don't see what you're describing. Can you show a picture or something of what you see?


Oh I see it now. I had to install the Lucida Console font.
That looks like it's because of truetype anti-aliasing.

In any case, you could use a different font like Courier New.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Reply #4 on Tue 08 Mar 2016 06:15 PM (UTC)

Amended on Tue 08 Mar 2016 06:38 PM (UTC) by Wuggly

Message
Thanks. Never thought of changing the font.

And I was just using that code as an example of the problem. In my version of it I don't use send/execute at all. I just use it to change variables.


map_selected = (links [tonumber (hotspotid)].map_selected)


EDIT: Looks like Courier New does it too. I found MS Sans Serif works, but can't get it small enough. Will keep looking around trying out different fonts.
[Go to top] top

Posted by Fiendish   USA  (2,517 posts)  [Biography] bio   Global Moderator
Date Reply #5 on Tue 08 Mar 2016 07:46 PM (UTC)

Amended on Tue 08 Mar 2016 08:05 PM (UTC) by Fiendish

Message
Well it's definitely a problem with what you're doing and how that interacts with ClearText. ( https://blogs.msdn.microsoft.com/oldnewthing/20060614-00/?p=30873#sthash.DeyKIWeW.dpuf )

The answer (because disabling cleartext for this is kinda silly) is that if you're going to print antialiased text on top of other antialiased text then first you need to redo the background.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (23,000 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Tue 08 Mar 2016 09:14 PM (UTC)
Message
Yes, perhaps work out the rough size of the text rectangle (using WindowTextWidth and working out the vertical height from the font info), and then clearing that rectangle first.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


18,268 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]