yaoguai 发表于 2009-4-2 04:09:59

mush 状态栏

这个是主要代码

function doGauge (sPrompt, iCurrent, iMax)
InfoColour("black")
InfoFont("Arial", 10, 0)
Info(sPrompt)
InfoFont("Webdings", 10, 0)
local perc = math.floor(iCurrent/(iMax/10))
local color = "red"
if (perc > 8) then
color = "green"
elseif (perc > 5) then
color = "yellow"
end
InfoColour(color)
for i = 1, perc, 1 do
Info("g")
end
InfoColour("dimgray")
for i = perc, 10 do
Info("g")
end
end

这个是效果

http://img25.imageshack.us/img25/2203/gaugey.jpg

yaoguai 发表于 2009-4-2 04:12:51

ps 颜色会随着你的状态变化的
hiahia

下一步是做一个 华丽的mini window
其实代码是从
http://www.gammon.com.au/mushclient/plugins/
抄来的
grin
R&D = read & duplicate!!!

yaoguai 发表于 2009-4-2 06:01:52

mini window看起来也不麻烦
估计今天晚上就做好了

yaoguai 发表于 2009-4-2 07:14:10

mini win也差不多了

yaoguai 发表于 2009-4-2 07:49:03

final version

yaoguai 发表于 2009-4-2 07:56:17

状态栏位子可以随意调整
还可以弄背景图片
总而言之是很好很强大

mok 发表于 2009-4-2 08:15:09

感觉很好啊,赶快共享插件,否则当场革毙,grin

yaoguai 发表于 2009-4-2 08:16:34

不知道怎么做成puglin.....

sure 发表于 2009-4-2 08:20:18

mush是很强的,慢慢学吧,我只熟悉js而已,mush提供的很多功能我还没用上。

yaoguai 发表于 2009-4-2 08:39:35

function drawGauge(win, font, param, left, top, current, maxium)
local height = WindowFontInfo(win, font, 1)
local descent = WindowFontInfo(win, font, 3)
WindowText (win, font,
param, -- text
left, top, 0, 0, -- rectangle
ColourNameToRGB ("darkgreen"), -- colour
false) -- not Unicode

width = WindowTextWidth (win, font, param)
local seperate = 5
local barTop = top + descent
local barLeft = left + width + seperate
local barWidth = 200
local barHeight = height - 2 * descent
local percent = current / maxium
local barColor = getColorByPercent(percent)
if (percent > 1) then
percent = 1
end
WindowRectOp (win, 2, barLeft, barTop, barLeft + barWidth * percent, barTop + barHeight, ColourNameToRGB(barColor)) -- draw rectangle
WindowRectOp (win, 1, barLeft, barTop, barLeft + barWidth, barTop + barHeight, ColourNameToRGB("blue")) -- draw rectangle

WindowText (win, font,
current .. "/" .. maxium, -- text
barLeft + barWidth + seperate, top, 0, 0, -- rectangle
ColourNameToRGB (barColor), -- colour
false)

end
页: [1] 2 3
查看完整版本: mush 状态栏