[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 Tue 27 Oct 2015 11:17 PM (UTC)
Message
I'm trying to adapt the Generic GUI.

This is my current layout:

https://dl.dropboxusercontent.com/u/59281190/MushClient.jpg

Now, i've manage to remove lots of things, but how can i put my miniwindows plugins inside this one, and make the windows static in position? The only thing that i need working is the reload the windows (in order to delete all of the content) and the scroll (can be without a bar).

I still didn't manage to get that.
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #1 on Tue 27 Oct 2015 11:24 PM (UTC)
Message
You have entered too much data - maximum is 6000 characters.

Not even trying to split the plugin.

The plugin is here:

https://dl.dropboxusercontent.com/u/59281190/Generic_GUI.xml

Thank you.
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #2 on Wed 28 Oct 2015 (UTC)
Message
And the original Plugin:

https://dl.dropboxusercontent.com/u/59281190/Generic_GUI_org.xml
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #3 on Wed 28 Oct 2015 10:43 PM (UTC)

Amended on Thu 29 Oct 2015 05:31 AM (UTC) by Nick Gammon

Message
Ok, so i started messing around with this. Slowly.

I have a problem. In the GUI there is a top bar, that aare macros (hotkeys), but i can't manage to change what the F1, F2, ..., F12 do.
The code that i get from the plugin is this:


-- update the hotkeys
function update_hotkeys ()

  -- To stop F1 opening the windows help dialog:
  -- File -> Global Preferences -> General, "F1, F6 are macros"

  data = msdp["HOTKEY"]

  if data ~= nil then
    hotkey = {}
    index = 0
    startpos = 1
    max = 0
    for i=1,string.len(data),1 do
      if string.byte(data,i) == 9 or i == string.len(data) then
        index = index + 1
        hotkey[index] = string.sub(data, startpos, i)
        startpos = i+1
      end -- if
    end -- for

    if index == 3 then
      hotkeys_name[tonumber(hotkey[1])] = hotkey[2]
      hotkeys_action[tonumber(hotkey[1])] = hotkey[3]
      Accelerator ("F"..hotkey[1], hotkey[3])
    end -- if
  end -- if

end -- update_hotkeys

function draw_hotkeys ()

  for i=1,12,1 do
    create_hotkey(i)
  end -- for

end -- draw_hotkeys

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
  if hotkeys[hotkey_number] == nil or hotkeys[hotkey_number] == false then
    button = "images/layout/button_background.png"
  else -- true means the button has been pressed
    button = "images/layout/button_background2.png"
  end -- if

  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", "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")

    if hotkeys[hotkey_number] == false then
      button = "images/layout/button_background.png"
    else -- true means the button has been pressed
      button = "images/layout/button_background2.png"
    end -- if

    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

function outlined_text (colour, window, text, size, x, y)

  outlineColour = colourBlack

  -- write the information inside
  WindowFont(window,'f','Times New Roman',size,1,0,0,0)

  -- smear black text around the location to create an outline, so that it's clearer to read
  WindowText(window,'f',text,x+1,y+1,0,0,outlineColour,0)
  WindowText(window,'f',text,x+1,y,0,0,outlineColour,0)
  WindowText(window,'f',text,x+1,y-1,0,0,outlineColour,0)
  WindowText(window,'f',text,x,y+1,y,0,outlineColour,0)
  WindowText(window,'f',text,x,y-1,y,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y+1,0,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y,0,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y-1,0,0,outlineColour,0)

  -- display the text
  WindowText(window,'f',text,x,y,0,0,colour,0)

end -- outlined_text

function get_hotkey_value (hotkey_string)
  if hotkey_string == "hs_F1" then
    return 1
  elseif hotkey_string == "hs_F2" then
    return 2
  elseif hotkey_string == "hs_F3" then
    return 3
  elseif hotkey_string == "hs_F4" then
    return 4
  elseif hotkey_string == "hs_F5" then
    return 5
  elseif hotkey_string == "hs_F6" then
    return 6
  elseif hotkey_string == "hs_F7" then
    return 7
  elseif hotkey_string == "hs_F8" then
    return 8
  elseif hotkey_string == "hs_F9" then
    return 9
  elseif hotkey_string == "hs_F10" then
    return 10
  elseif hotkey_string == "hs_F11" then
    return 11
  elseif hotkey_string == "hs_F12" then
    return 12
  else
    return 0
  end -- if
end -- get_hotkey_value

function hotkey_down (flags, hotspot_id)
  hotkey_number = get_hotkey_value (hotspot_id)
  if hotkey_number ~= 0 then
    hotkeys[hotkey_number] = true
    update_hotkey (hotkey_number)
    Redraw()
  end -- if
  return 0
end -- hotkey_down

function hotkey_up (flags, hotspot_id)
  hotkey_number = get_hotkey_value (hotspot_id)
  if hotkey_number ~= 0 then
    hotkeys[hotkey_number] = false
    update_hotkey (hotkey_number)
    if hotkeys_action[hotkey_number] ~= nil then
      Execute(hotkeys_action[hotkey_number])
      Redraw()
    else
      Note("Hotkey not defined.  Type 'hotkey' to set it.")
    end -- if
  end -- if
  return 0
end -- hotkey_up
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #4 on Wed 28 Oct 2015 10:44 PM (UTC)
Message
I only need to get the values from MushClient itself, or find a way to set them.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 29 Oct 2015 05:35 AM (UTC)
Message
Halig said:

And the original Plugin:

https://dl.dropboxusercontent.com/u/59281190/Generic_GUI_org.xml


It's not loading for me:


Run-time error
Plugin: Generic_GUI (called from world: smaug2)
Function/Sub: OnPluginWorldOutputResized called by Plugin Generic_GUI
Reason: Executing plugin Generic_GUI sub OnPluginWorldOutputResized
[string "Plugin"]:311: Cannot open the specified file
stack traceback:
        [C]: in function 'error'
        [string "Check function"]:1: in function 'check'
        [string "Plugin"]:311: in function 'create_layout'
        [string "Plugin"]:400: in function <[string "Plugin"]:399>
Error context in script:
 307 :                 7,          -- draw underneath (1) + absolute location (2) + transparent (4)
 308 :                 0x000000))  -- background colour
 309 : 
 310 :   -- load the titlebar image
 311*:   check (WindowLoadImage (titlebar_window, "titlebar", GetInfo (66) .. "Generic/layout/Generic_title.png"))
 312 : 
 313 :   -- draw it
 314 :   check (WindowDrawImage (titlebar_window, "titlebar", 0, -20, 0, 0, 3))  -- draw it
 315 : 



Quote:

but i can't manage to change what the F1, F2, ..., F12 do.


What do you mean?

- Nick Gammon

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

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #6 on Thu 29 Oct 2015 11:06 AM (UTC)

Amended on Thu 29 Oct 2015 11:07 AM (UTC) by Halig

Message
Hi Nick,

The bar has buttons F1 to F12.
I know the code is that, but i can't find out how to set what the buttons do.
For example, i have macros assined on MushClient, F2 make me invisible. With that code, the creation of a bar with buttons, is there a way to get that macro and put it on the bar?
That is my problem for now.

The full plugin, with all working except changing what the buttons do:

https://dl.dropboxusercontent.com/u/59281190/LoK_GUI2.xml

Nick, the things may not load for you cause of the images that are needed.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Thu 29 Oct 2015 08:27 PM (UTC)
Message
You want to click the button and have it send an existing macro? You can get the macro text.


print (ExportXML (3 , "F10" ))


That prints:


<macros>

  <macro name="F10" type="send_now" >
  <send>whatever</send>

  </macro>
</macros>


With a bit of fiddling with a regular expression you could extract the macro text.


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


That prints:


whatever

- Nick Gammon

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

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #8 on Thu 29 Oct 2015 08:34 PM (UTC)
Message
Thank you Nick.
I've tried that on the MUD and everything works. Now, my problem is how to implement that on the bar, like it is! :(
It has s many functions, update_hotkeys, draw_hotkeys, etc.
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #9 on Thu 29 Oct 2015 11:26 PM (UTC)
Message
I figure out something:

data = msdp["HOTKEY"]

This line was missing in the plugin.
The only problem here is that the MUD that i play, doesn't support msdp. So i need to change all that to get the values of local macros, and not server hotkeys.
Still need some help please, cause i've tried endless things. Some give errors on fucntions, and some tries not even let the plugin load.
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #10 on Fri 30 Oct 2015 02:35 PM (UTC)
Message
Still trying and not getting the macros title or at least pressing for example F2 and send the command assigned, in this case, invis.
Don't know how to do that. I've read the posts on the icon bar (similar) but the way this is done, i can't manage to adapt.
I want to keep the backgrounds on the buttons and the 'F1' to 'F12' labels on the buttons, created in there in yellow.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Fri 30 Oct 2015 07:46 PM (UTC)
Message
I'm not sure where your problem is. Can you put in some debugging displays to clarify? You are talking about clicking on the button, right, not just hitting (say) F5?

You have a function: hotkey_up

Is that called? If not, you need to work out why. If so, is it not sending what you want it to send?

- Nick Gammon

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

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #12 on Fri 30 Oct 2015 07:51 PM (UTC)

Amended on Fri 30 Oct 2015 07:53 PM (UTC) by Halig

Message
Hello Nick. Correct, getting the value stored in local F5 for example, and when i press the button F5, it sends what it's stored there.
All it is sending is:

Hotkey not defined. Type 'hotkey' to set it.

But this is a msdp command, it goes get the hotkey value on the MUD itself, not on MushClient.
That's where my problem is.

TRACE: Executing Plugin LoK_GUI script "hotkey_down"
TRACE: Executing Plugin LoK_GUI script "hotkey_up"
Hotkey not defined. Type 'hotkey' to set it.
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #13 on Fri 30 Oct 2015 09:55 PM (UTC)
Message

function get_hotkey_value (hotkey_string)
  if hotkey_string == "hs_F1" then
    print("teste")
  elseif hotkey_string == "hs_F2" then
    return 2
  elseif hotkey_string == "hs_F3" then
    return 3
  elseif hotkey_string == "hs_F4" then
    return 4
  elseif hotkey_string == "hs_F5" then
    return 5
  elseif hotkey_string == "hs_F6" then
    return 6
  elseif hotkey_string == "hs_F7" then
    return 7
  elseif hotkey_string == "hs_F8" then
    return 8
  elseif hotkey_string == "hs_F9" then
    return 9
  elseif hotkey_string == "hs_F10" then
    return 10
  elseif hotkey_string == "hs_F11" then
    return 11
  elseif hotkey_string == "hs_F12" then
    return 12
  else
    return 0
  end -- if
end -- get_hotkey_value
[\code]

If i change on the string hs_F1 the return 1 to print("teste") i got this:

Error number: 0
Event:        Run-time error
Description:  [string "Plugin"]:492: table index is nil

stack traceback:

	[string "Plugin"]:492: in function <[string "Plugin"]:489>
Called by:    Function/Sub: hotkey_down called by Plugin LoK_GUI

Reason: Executing plugin LoK_GUI sub hotkey_down
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #14 on Sat 31 Oct 2015 04:03 AM (UTC)
Message
Well, you are no longer returning anything. So how about:


function get_hotkey_value (hotkey_string)
  if hotkey_string == "hs_F1" then
    print("teste")
    return 1
  elseif hotkey_string == "hs_F2" then


- 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,342 views.

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

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]