A few issues, first of all, it seems that nothing at all happens if I try to make a 1x1 window, secondly I can't seem to pull the right color from the gradient rectangle that I've made, instead it just keeps pulling the background color and setting it. This is the code that I'm currently trying to use:
showing only relevant code because of post length limit:
function DoGauge (sPrompt, Percent, Colour)
local Fraction = tonumber (Percent)
if Fraction > 1 then Fraction = 1 end
if Fraction < 0 then Fraction = 0 end
local width = WindowTextWidth (win, font_id, sPrompt)
WindowText (win, font_id, sPrompt,
GAUGE_LEFT - width, vertical, 0, 0, FONT_COLOUR)
WindowCircleOp (win, 3, GAUGE_LEFT, vertical, WINDOW_WIDTH - 5, vertical + GAUGE_HEIGHT,
BACKGROUND_COLOUR, 0, 2, BACKGROUND_COLOUR, 10, 25, 25) -- fill entire box
local gauge_width = (WINDOW_WIDTH - GAUGE_LEFT - 5) * Fraction
-- box size must be > 0 or WindowGradient fills the whole thing
if math.floor (gauge_width) > 0 then
-- WindowRectOp (win2, 1, 2, 2, 100, 2, ColourNameToRGB ("lightgrey"))
--create the gradient line
WindowGradient (win2, 50, 1, 50, 1,
ColourNameToRGB ("red"),
Colour, 1)
-- top half
--old method commented out
-- WindowGradient (win, GAUGE_LEFT, vertical, GAUGE_LEFT + gauge_width, vertical + GAUGE_HEIGHT / 2,
-- 0x000000,
-- Colour, 2)
WindowGradient (win, GAUGE_LEFT, vertical, GAUGE_LEFT + gauge_width, vertical + GAUGE_HEIGHT / 2,
0x000000,
WindowGetPixel( win2, Fraction, 1 ), 2)
-- bottom half
WindowGradient (win, GAUGE_LEFT, vertical + GAUGE_HEIGHT / 2,
GAUGE_LEFT + gauge_width, vertical + GAUGE_HEIGHT,
WindowGetPixel( win2, Fraction, 1 ),
0x000000, 2)
end -- non-zero
function OnPluginInstall ()
win = GetPluginID ()
win2 = GetPluginID ()
font_id = "fn"
font_name = "Fixedsys" -- the actual font
local x, y, mode, flags =
tonumber (GetVariable ("windowx")) or 0,
tonumber (GetVariable ("windowy")) or 0,
tonumber (GetVariable ("windowmode")) or 8, -- bottom right
tonumber (GetVariable ("windowflags")) or 0
-- make miniwindow so I can grab the font info
check (WindowCreate (win,
x, y, WINDOW_WIDTH, WINDOW_HEIGHT,
mode,
flags,
BACKGROUND_COLOUR) )
check (WindowCreate (win2,
x, y, WINDOW_WIDTH, WINDOW_HEIGHT,
mode,
flags,
BACKGROUND_COLOUR) )
-- make a hotspot
WindowAddHotspot(win, "hs1",
0, 0, 0, 0, -- whole window
"", -- MouseOver
"", -- CancelMouseOver
"mousedown",
"", -- CancelMouseDown
"", -- MouseUp
"Drag to move", -- tooltip text
1, 0) -- hand cursor
-- make a hotspot
WindowAddHotspot(win2, "hs2",
0, 0, 0, 0, -- whole window
"", -- MouseOver
"", -- CancelMouseOver
"mousedown",
"", -- CancelMouseDown
"", -- MouseUp
"Drag to move", -- tooltip text
1, 0) -- hand cursor
WindowShow( win2, false )
WindowDragHandler(win, "hs1", "dragmove", "dragrelease", 0)
check (WindowFont (win, font_id, font_name, 9, false, false, false, false, 0, 0)) -- normal
font_height = WindowFontInfo (win, font_id, 1) -- height
if GetVariable ("enabled") == "false" then
ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
check (EnablePlugin(GetPluginID (), false))
return
end -- they didn't enable us last time
end -- OnPluginInstall
function OnPluginDisable ()
WindowShow (win, false)
WindowShow (win2, false )
end -- OnPluginDisable
function OnPluginSaveState ()
SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
SetVariable ("windowx", tostring (WindowInfo (win, 10)))
SetVariable ("windowy", tostring (WindowInfo (win, 11)))
SetVariable ("windowmode", tostring (WindowInfo (win, 7)))
SetVariable ("windowflags", tostring (WindowInfo (win, 8)))
end -- OnPluginSaveState
]]>
</script>
</muclient>
Everything else works, but I can't seem to be able to pull the right color.
Thanks for all the help,
KeB |