Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ InfoBox module to do gauges etc.

InfoBox module to do gauges etc.

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


Pages: 1  2 3  

Posted by Razieltakato   Brazil  (2 posts)  Bio
Date Reply #15 on Tue 10 Mar 2009 12:07 PM (UTC)
Message
I can't upgrade my gauges from the prompt, and i can't find any tutorial in this forum. can u help me pls?
Top

Posted by Razieltakato   Brazil  (2 posts)  Bio
Date Reply #16 on Tue 10 Mar 2009 09:19 PM (UTC)

Amended on Tue 10 Mar 2009 09:20 PM (UTC) by Razieltakato

Message
Yeah!!!! I made it!!!! If you want to see the code just tell me and i post it ^^
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #17 on Wed 13 May 2009 02:58 PM (UTC)
Message
My current goal is to make two separate boxes that are nudged up against one another. The placement rules are a little confusing to me, so I'm asking for some clarification and/or advice.

If I setup two boxes with SE window positions, they are drawn directly over one another (same position) so that one occludes the other. I was hoping that the new box would be "anchored" to the top of the first box.

If I setup two boxes with E window positions, the second one gets its own position such that both are now visible, but there's a large gap in between the two boxes. The gap appears to be centered around the middle of the right edge of the window. I was hoping that the first box would be centered on the left edge until the second box was created. When both boxes are created, the first should have the top edge on the center and the second box has its bottom edge on that same center line. (Kind of a "push a box in and bump the others outward from the center" sort of thing?)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #18 on Thu 14 May 2009 12:28 AM (UTC)
Message
The middle ones (ie. N, S, E, W) are designed to space themselves evenly between any other middle ones and whatever is in the corners. However if you specify a corner that is what you get. It all gets too confusing having rules for "the corner but one down" or something like that, because then you ask "which one goes first" and so on.

If the auto positions don't work, you need to use manual positioning. For example the second one could detect where the first one is (the SE one) and then manually position itself directly on top.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #19 on Thu 14 May 2009 12:28 AM (UTC)
Message
That's just how the miniwindow positioning code works. It's Nick's code. not mine that determines it. :)

If you wanted to fake it, you could make a dummy infobox window, anchored in the corners, that are (GetInfo(263)-box1.windowHeight-box2.windowHeight)/2 in height. That tricks nick's code to squish em together.

The draw back of doing that is that adding a new plugin or another window would need those corner-shim windows to be recreated.
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #20 on Thu 14 May 2009 02:17 AM (UTC)
Message
Not sure I understand the "shim window" concept, actually. I guess I could add some padding to the second window equal in height to the first window, eh?

I'm also still confused why the miniwindows on N, S, E, and W get pushed so far out toward the corners, but I suppose I get that more. I know it's not a simple thing to compute for the general case (or else I'd already be sizing and positioning them manually myself).

Thanks for the inputs.
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #21 on Thu 14 May 2009 05:49 AM (UTC)
Message
There's no perfect solution for the auto positioning. your example of the bottom edge/top edge being centered is one solution, but what if window1 is twice as tall as window 2? should it still be the bottom edge, or have the centerline be 2/3rds the way down window1?

For the shim windows...

The code for autopositioning makes sure there's n+1 (where n is the number of miniwindows) equally sized gaps above and below the miniwindows so that the windows are centered between the space left from what's occupied by the corner windows.

The shims sit in the corners, and are basically 1 pixel wide by how ever many pixels it takes so that those 3 equal gaps above, between, and below window1 and window2 are 0 pixels.
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #22 on Thu 20 Aug 2009 11:11 PM (UTC)
Message
How would I go about using movewindow.lua with this?

Is it possible to make simple changes like adding a hotspot or some text with out digging into the module?
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #23 on Fri 21 Aug 2009 12:53 AM (UTC)

Amended on Fri 21 Aug 2009 01:02 AM (UTC) by WillFa

Message
I wrote this before movewindow, and I haven't gone through it's code to know exactly how it works... I'll have to look into it later this weekend.

Adding text and hotspots are simple tho. "To simplify the process" </marketing spin> or perhaps as a limitation depending on your perspective, each cell can easily be a hotspot (but not divided up into smaller sections) by setting a table with the parameters the WindowHotSpot function.


require "InfoBox"
InfoBox:Doc("button")


for more information.

Also, go through the Demo plugin for a get ready quick run-through of what InfoBox does.


Digging into the module might be ... fun. :) It's 73k of code and documentation. ;) It's mostly well-written though, so looking at the source shouldn't be mind-boggling... just overwhelming at first.

Except for, obviously, mcicon.png; all these are screen shots of InfoBox Windows.
http://cid-73890baf188d56e7.skydrive.live.com/browse.aspx/MCForum
Doing text is fairly simple with them, as you can see with InfoBox1.2.jpg .


Top

Posted by Blainer   (191 posts)  Bio
Date Reply #24 on Fri 21 Aug 2009 02:03 AM (UTC)
Message
Ok I don't think I understood the demo properly I'll go back and read some more.
I don't suppose you have the documentation in another format. Just a text file would
be great so I can have it up while I'm working with the module.

Thanks WillFa, this module is great btw, I'm itching to make a slick looking health
bar etc plugin for Aardwolf.
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #25 on Fri 21 Aug 2009 03:06 AM (UTC)
Message
Sorry, I wrote all the documentation right in the Lua module. What I normally do is have another world open, that has it's IP Adress set to 0.0.0.0, a scripting prefix set, and auto-say turned on that's set to prefix each line with the scripting char and checked to send to the interpreter. I have this world saved as Scratchpad.

When I want a quick Lua interactive session, the dummy world serves nicely.

Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #26 on Fri 08 Jan 2010 09:45 PM (UTC)
Message
Willfa, is this module at release status? I might add it into the next distribution of MUSHclient, to encourage its use in general plugin development.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Morat   (18 posts)  Bio
Date Reply #27 on Thu 04 Feb 2010 09:19 PM (UTC)

Amended on Thu 04 Feb 2010 09:33 PM (UTC) by Morat

Message
Great job, WillFa!

I think using HSL color space gives a more pleasing gradient then RGB color space.

HSL Color Theory Computation in Lua
http://sputnik.freewisdom.org/lib/colors/

Example Image (top gradient uses RGB & bottom gradient uses HSL)
http://i38.tinypic.com/29o0q4k.jpg

The following Lua script shows three power gauges using WindowGradient, WindowLine with RGB values and WindowLine with HSL values.

local function hsl_to_rgb(h, s, L)              -- h = Hue
  local h = h/360                               -- s = Saturation
  local m1, m2                                  -- L = Lightness
  if L<=0.5 then
    m2 = L*(s+1)                                -- hsl_to_rgb(120, 1, 0.5) = 0x00FF00
  else                                          -- hsl_to_rgb(  0, 1, 0.5) = 0x0000FF
    m2 = L+s-L*s
  end                                           -- ColourNameToRGB("lime") = 0x00FF00
  m1 = L*2-m2                                   -- ColourNameToRGB("red")  = 0x0000FF
  local function _h2rgb(m1, m2, h)
    if h<0 then h = h+1 end
    if h>1 then h = h-1 end
    if h*6<1 then
      return m1+(m2-m1)*h*6
    elseif h*2<1 then 
      return m2 
    elseif h*3<2 then 
      return m1+(m2-m1)*(2/3-h)*6
    else
      return m1
    end
  end
  return math.floor(255*_h2rgb(m1, m2, h+1/3))*16^0+
         math.floor(255*_h2rgb(m1, m2, h    ))*16^2+
         math.floor(255*_h2rgb(m1, m2, h-1/3))*16^4
end
local width = 800
WindowCreate("test",                            -- miniwindow name
  0, 0,                                          -- left, top (ignore)
  width, 350,                                    -- width, height
  12,                                            -- position (centre all)
  8,                                             -- flags (ignore mouse)
  ColourNameToRGB("black"))                      -- background colour
WindowShow("test", true)                        -- show miniwindow
WindowGradient("test",                          -- miniwindow name
  0, 0, width-1, 100-1,                          -- left, top, right, bottom
  ColourNameToRGB("lime"),                       -- start colour (0x00FF00)
  ColourNameToRGB("red"),                        -- end   colour (0x0000FF)
  1)                                             -- mode (horizontal)
for n = 0, width-1 do
  local r, g, rgb
  r = math.floor(255*n/(width-1))
  g = math.floor(255*(width-1-n)/(width-1))
  rgb = r*16^0+g*16^2                           -- rgb colour space
  WindowLine("test",                            -- miniwindow name
    n, 125, n, 225-1,                            -- left, top, right, bottom
    rgb, 0, 1)                                   -- pen colour, pen style (solid), pen width
  rgb = hsl_to_rgb(120-120*n/(width-1), 1, 0.5) -- hsl colour space
  WindowLine("test",                            -- miniwindow name
    n, 250, n, 350-1,                            -- left, top, right, bottom
    rgb, 0, 1)                                   -- pen colour, pen style (solid), pen width
end
Redraw()
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #28 on Thu 04 Feb 2010 11:19 PM (UTC)
Message
That looks nice, I'll add the colors.lua file to the next release of MUSHclient.

My test which used the module rather than copying bits of it in, was:


require "colors"

local width = 800
WindowCreate("test",                            -- miniwindow name
  0, 0,                                          -- left, top (ignore)
  width, 350,                                    -- width, height
  12,                                            -- position (centre all)
  8,                                             -- flags (ignore mouse)
  ColourNameToRGB("black"))                      -- background colour
WindowShow("test", true)                        -- show miniwindow
WindowGradient("test",                          -- miniwindow name
  0, 0, width-1, 100-1,                          -- left, top, right, bottom
  ColourNameToRGB("lime"),                       -- start colour (0x00FF00)
  ColourNameToRGB("red"),                        -- end   colour (0x0000FF)
  1)                                             -- mode (horizontal)
for n = 0, width-1 do
  local r, g, rgb
  r = math.floor(255*n/(width-1))
  g = math.floor(255*(width-1-n)/(width-1))
  rgb = r*16^0+g*16^2                           -- rgb colour space
  WindowLine("test",                            -- miniwindow name
    n, 125, n, 225-1,                            -- left, top, right, bottom
    rgb, 0, 1)                                   -- pen colour, pen style (solid), pen width
  r, g, b = colors.hsl_to_rgb(120-120*n/(width-1), 1, 0.5) -- hsl colour space
  rgb = math.floor(255*r)*16^0+
         math.floor(255*g)*16^2+
         math.floor(255*b)*16^4

  WindowLine("test",                            -- miniwindow name
    n, 250, n, 350-1,                            -- left, top, right, bottom
    rgb, 0, 1)                                   -- pen colour, pen style (solid), pen width
end
Redraw()

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #29 on Thu 04 Feb 2010 11:21 PM (UTC)
Message
I have to agree, the HSL-based gradients look brilliant.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
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.


130,807 views.

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

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

Go to topic:           Search the forum


[Go to top] top

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