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 ➜ Suggestions ➜ gauge.lua additions

gauge.lua additions

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


Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Sun 24 Feb 2013 02:11 AM (UTC)
Message
I have the following changes to my gauge.lua file. I figure they might be useful for others too.

@@ -18,7 +18,8 @@
                 fg_colour, bg_colour,       -- colour for bar, colour for unfilled part
                 ticks, tick_colour,         -- number of ticks to draw, and in what colour
                 frame_colour,               -- colour for frame around bar
-                shadow_colour)              -- colour for shadow, nil for no shadow
+                shadow_colour,              -- colour for shadow, nil for no shadow
+                no_gradient)                -- don't use the gradient fill effect
 
   local Fraction
   
@@ -62,18 +63,22 @@
    -- box size must be > 0 or WindowGradient fills the whole thing 
   if math.floor (gauge_width) > 0 then
     
-    -- top half
-    WindowGradient (win, left, top, 
-                    left + gauge_width, top + height / 2, 
-                    0x000000, -- black
-                    fg_colour, 2)  -- vertical top to bottom
-    
-    -- bottom half
-    WindowGradient (win, left, top + height / 2, 
-                    left + gauge_width, top + height,   
-                    fg_colour,
-                    0x000000, -- black
-                    2) -- vertical top to bottom
+    if no_gradient then
+        WindowRectOp (win, 2, left+1, top, left+1+gauge_width, top+height, fg_colour)
+    else 
+        -- top half
+        WindowGradient (win, left, top-1, 
+                        left + gauge_width, top + height / 2, 
+                        0x000000, -- black
+                        fg_colour, 2)  -- vertical top to bottom
+        
+        -- bottom half
+        WindowGradient (win, left, top + height / 2, 
+                        left + gauge_width, top + height,   
+                        fg_colour,
+                        0x000000, -- black
+                        2) -- vertical top to bottom
+    end
 
   end -- non-zero
   
@@ -166,3 +171,17 @@
   
   return width
 end -- draw_text_box
+
+-- text with a black outline
+function outlined_text(window, font, text, startx, starty, endx, endy, color, utf8)
+    WindowText(window, font, text, startx-1, starty-1, endx, endy, 0x000000, utf8)
+    WindowText(window, font, text, startx-1, starty, endx, endy, 0x000000, utf8)
+    WindowText(window, font, text, startx-1, starty+1, endx, endy, 0x000000, utf8)
+    WindowText(window, font, text, startx, starty-1, endx, endy, 0x000000, utf8)
+    WindowText(window, font, text, startx, starty+1, endx, endy, 0x000000, utf8)
+    WindowText(window, font, text, startx+1, starty-1, endx, endy, 0x000000, utf8)
+    WindowText(window, font, text, startx+1, starty, endx, endy, 0x000000, utf8)
+    WindowText(window, font, text, startx+1, starty+1, endx, endy, 0x000000, utf8)
+    WindowText(window, font, text, startx, starty, endx, endy, color, utf8)
+end
+

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 24 Feb 2013 02:34 AM (UTC)
Message
Revisiting this thread:

http://www.gammon.com.au/forum/bbshowpost.php?id=10759

Your suggested change, with this test code:


win = "test"

WindowCreate (win , 
  0, -- left
  0, -- top
  200, -- width
  200, -- height
  miniwin.pos_top_left, -- mode
  0, -- flags
  ColourNameToRGB ("navajowhite"))

 WindowRectOp (win, miniwin.rect_frame, 10, 10, 50, 50, ColourNameToRGB ("red"))
 

 WindowGradient (win, 10, 10, 50, 50, 
                    ColourNameToRGB ("green"),
                    ColourNameToRGB ("blue"), 2)


 WindowRectOp (win, miniwin.rect_frame, 10, 10, 50, 50, ColourNameToRGB ("cyan"))
 

require "gauge"

gauge (win,    
        "hp",                  
        50, 100,              
        10, 60, 40, 20,  
        ColourNameToRGB ("green"), 
        ColourNameToRGB ("red"),       
        0, 0x000000,       
        ColourNameToRGB ("cyan"),           
        nil)             

 WindowShow (win  , true)


Produces this:



You added the "-1" to the top, which appears to cause it:


       -- top half
        WindowGradient (win, left, top-1, 


Is there any reason for that?

- Nick Gammon

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

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #2 on Sun 24 Feb 2013 04:42 AM (UTC)

Amended on Mon 25 Feb 2013 03:23 AM (UTC) by Fiendish

Message
Oh yeah, good memory, I totally forgot about that thread.

Do this instead:


        -- top half
        WindowGradient (win, left, top, 
                        left + gauge_width, top + height / 2, 
                        0x000000, -- black
                        fg_colour, 2)  -- vertical top to bottom
        
        -- bottom half
        WindowGradient (win, left, top + height / 2, 
                        left + gauge_width, top + height-1,   
                        fg_colour,
                        0x000000, -- black
                        2) -- vertical top to bottom

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #3 on Sun 17 Mar 2013 03:52 AM (UTC)
Message
I've been meaning to ask, do you get notified of edits?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 17 Mar 2013 06:22 AM (UTC)
Message
Fiendish said:

I've been meaning to ask, do you get notified of edits?


Edits on the forum? No.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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,293 views.

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.