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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Generic GUI Plugin

Generic GUI Plugin

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


Pages: 1  2  3 

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #30 on Tue 03 Nov 2015 09:23 PM (UTC)
Message

function create_hotkey (hotkey_number)

  win = "hotkey_window_"..hotkey_number
  hotkey = "hotkey_"..hotkey_number
  colour = ColourNameToRGB ("gold")
  offset = 115 + (67*hotkey_number)

  -- make a miniwindow under the text
  check (WindowCreate (win,   -- window ID
                offset,       -- left
                2,            -- top
                65,           -- width
                41,           -- depth
                12,           -- center it (ignored anyway) 
                2,            -- draw underneath (1) + absolute location (2)
                colour))      -- background colour

  -- load the icon background image if possible
  button = "images/layout/button_background.png"

  if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
    check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
  end -- if

  -- draw the 'F1' to 'F12' labels on the buttons
  outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)

  -- draw the label, if any
  if hotkeys_name[hotkey_number] ~= nil then
    outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
  end -- if

  -- show the window
  WindowShow (win, true)

  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "", "F"..tostring(hotkey_number), 1, 0)

print (hotkeys_name[hotkey_number])

end -- create_hotkey


function update_hotkey (hotkey_number)

  if hotkeys[hotkey_number] ~= nil then
    win = "hotkey_window_"..hotkey_number
    hotkey = "hotkey_"..hotkey_number
    colour = ColourNameToRGB ("gold")
    button = "images/layout/button_background.png"
 
    if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
      check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
    end -- if

    -- draw the label, if any
    if hotkeys_name[hotkey_number] ~= nil then
      outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
    end -- if

    -- draw the 'F1' to 'F12' labels on the buttons
    outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
  end -- if

print (hotkeys_name[hotkey_number])

end -- update_hotkey


Perhaps i'm not doing the things the way i should.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #31 on Tue 03 Nov 2015 10:33 PM (UTC)
Message
My earlier reply suggested:


macro = ExportXML (3 , "F10" )
macrotext = string.match (macro, "<send>(.*)</send>")


I'm not seeing that anywhere, or anything like it.

- Nick Gammon

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

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #32 on Tue 03 Nov 2015 10:43 PM (UTC)
Message
Oh, it is as follows. I declared the macros at the top of the plugin:


macro1 = ExportXML (3 , "F1" )
macro2 = ExportXML (3 , "F2" )
macro3 = ExportXML (3 , "F3" )
macro4 = ExportXML (3 , "F4" )
macro5 = ExportXML (3 , "F5" )
macro6 = ExportXML (3 , "F6" )
macro7 = ExportXML (3 , "F7" )
macro8 = ExportXML (3 , "F8" )
macro9 = ExportXML (3 , "F9" )
macro10 = ExportXML (3 , "F10" )
macro11 = ExportXML (3 , "F11" )
macro12 = ExportXML (3 , "F12" )

function get_hotkey_value (hotkey_string)
  if hotkey_string == "hs_F1" then
    macro = string.match (macro1, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 1
  elseif hotkey_string == "hs_F2" then
    macro = string.match (macro2, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 2
  elseif hotkey_string == "hs_F3" then
    macro = string.match (macro3, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 3
  elseif hotkey_string == "hs_F4" then
    macro = string.match (macro4, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 4
  elseif hotkey_string == "hs_F5" then
    macro = string.match (macro5, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 5
  elseif hotkey_string == "hs_F6" then
    macro = string.match (macro6, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 6
  elseif hotkey_string == "hs_F7" then
    macro = string.match (macro7, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 7
  elseif hotkey_string == "hs_F8" then
    macro = string.match (macro8, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 8
  elseif hotkey_string == "hs_F9" then
    macro = string.match (macro9, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 9
  elseif hotkey_string == "hs_F10" then
    macro = string.match (macro10, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 10
  elseif hotkey_string == "hs_F11" then
    macro = string.match (macro11, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 11
  elseif hotkey_string == "hs_F12" then
    macro = string.match (macro12, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 12
  else
    return 0
  end -- if
end -- get_hotkey_value
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #33 on Wed 04 Nov 2015 12:33 AM (UTC)
Message
Yes, but I don't see where you are putting that macro stuff into the part that displays the buttons.

- Nick Gammon

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

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #34 on Wed 04 Nov 2015 12:32 PM (UTC)
Message
Correct Nick. I was trying to put only the part that you told me.


print (hotkeys_name[hotkey_number])


I can't see what to do and where. Sorry about this Nick, and thank you for all your help.


function create_hotkey (hotkey_number)

  win = "hotkey_window_"..hotkey_number
  hotkey = "hotkey_"..hotkey_number
  colour = ColourNameToRGB ("gold")
  offset = 115 + (67*hotkey_number)

  -- make a miniwindow under the text
  check (WindowCreate (win,   -- window ID
                offset,       -- left
                2,            -- top
                65,           -- width
                41,           -- depth
                12,           -- center it (ignored anyway) 
                2,            -- draw underneath (1) + absolute location (2)
                colour))      -- background colour

  -- load the icon background image if possible
  button = "images/layout/button_background.png"

  if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
    check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
  end -- if

  -- draw the 'F1' to 'F12' labels on the buttons
  outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)

  -- draw the label, if any
  if hotkeys_name[hotkey_number] ~= nil then
    outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
  end -- if

  -- show the window
  WindowShow (win, true)

  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "", "F"..tostring(hotkey_number), 1, 0)

end -- create_hotkey


function update_hotkey (hotkey_number)

  if hotkeys[hotkey_number] ~= nil then
    win = "hotkey_window_"..hotkey_number
    hotkey = "hotkey_"..hotkey_number
    colour = ColourNameToRGB ("gold")
    button = "images/layout/button_background.png"
 
    if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
      check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
    end -- if

    -- draw the label, if any
    if hotkeys_name[hotkey_number] ~= nil then
      outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
    end -- if

    -- draw the 'F1' to 'F12' labels on the buttons
    outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
  end -- if

end -- update_hotkey
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #35 on Sat 07 Nov 2015 01:15 PM (UTC)
Message
Hello to all. Been trying and no luck.
Can you guide me in one direction?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #36 on Sat 07 Nov 2015 08:49 PM (UTC)
Message
I'd like to see you break the problem down into manageable steps.

Quote:

Been trying and no luck.


That doesn't tell me, or anyone else, anything.

What did you try? Post it, don't just talk about it.

You should be able to obtain the macro strings (I think you did that in reply #32). Now you should be able to use the code we discussed earlier to display them.

- 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.


64,390 views.

This is page 3, subject is 3 pages long:  [Previous page]  1  2  3 

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]