--[[
飺
    ʾħϷʱűʱʾʼϷϷʱ䡣
    Ϸǰű״̬ʱʵʱС2롣
ע⣺ϷнűԽűʱ俪ʼʱϷʱ䡣


[200996]
ʱ䴦ʽlua
ʱʾ(ȻҲԵ)
[200997]
ʾʽΪϷʼһֱʾ
ʾλÿѡ2ʾɫԶ
[20091026]
Żʾģʽ
[2010412]
˲
[2010426]
1.ʾǰϵͳʱ䡣
2.һʾλãλΪָϱ߿
3.˲ֱͬӦС
                                       ߣҹ
                                                              ]]
--ű
if getwshscriptversion() < 4 then
    msgbox('ʹø߰汾')
end
--û޸Ĵ
nShowPosition=1         --ʾλãѡ1(Ǯλ·)2(Сͼϱ߿)3(ָϱ߿)
fontColor=0x00FFFF      --ʾɫ0xFFFFFFΪɫ0x0000FFΪɫ,0x00FF00Ϊɫ,0x00FFFFΪɫ
--û޸Ĵ
iPLstate=0
iLastTick = 0
iTickCount = 0
iPLtime=0
sTimeOut=''
iFontW=7
iFontH=14

function myd3dsettext(nShowstate,strText,nAlpha)
    war3w = getwar3window()
    win3wl,win3wr,win3wt,win3wb = getclientrect(war3w)
    if((win3wr-win3wl)<790) then
        iFontW=5
    elseif((win3wr-win3wl)>=790 and (win3wr-win3wl)<1010) then
        iFontW=6
    else
        iFontW=7
    end
    if nShowPosition==1 then
        x=(win3wr-win3wl)*0.553
        y=(win3wb-win3wt)*0.045
    end
    if nShowPosition==2 then
        x=(win3wr-win3wl)*0.02
        y=(win3wb-win3wt)*0.7345
    end
    if nShowPosition==3 then
        x=(win3wr-win3wl)*0.768
        y=(win3wb-win3wt)*0.7525
    end
    if nShowstate==0 then 
        idSet, ridSet = d3dsettext(idSet, ridSet,strText, 1000, x, y, "", fontColor, nAlpha, iFontW, 0, 500, 0, 0, 0,0,0)
    else 
        idSet, ridSet = d3dsettext(idSet, ridSet,strText, 0, x, y, "", fontColor, nAlpha, iFontW, 0, 500, 0, 0, 0,0,0)
    end
end

function runshowfunc()
    if 1==isplaying() then
        if 0==iPLstate then
            iPLstate=1
            iLastTick = gettickcount()
        end
        iTickCount=gettickcount()
        iPLtime=tonumber(string.format('%d',(iTickCount-iLastTick)/1000))
        if iPLtime>3600 then
            sTimeH=tonumber(string.format('%d',iPLtime/3600))
            sTimeM=tonumber(string.format('%d',iPLtime/60))-sTimeH*60
            sTimeS=iPLtime-(sTimeH*3600+sTimeM*60)
            sTimeOut=sTimeH..':'..sTimeM..':'..sTimeS
        elseif iPLtime>60 then
            sTimeM=tonumber(string.format('%d',iPLtime/60))
            sTimeS=iPLtime-sTimeM*60
            sTimeOut='00:'..sTimeM..':'..sTimeS
        elseif iPLtime>0 then
            sTimeOut='00:'..'00:'..iPLtime
        end
        if(sTimeOut~='') then 
            sTimeOut = 'Used['..sTimeOut..']  Now['..os.date("%X",os.time{year=1970, month=1, day=1, hour=0})..']'
        end
        myd3dsettext(0,sTimeOut,255)
    else
        iPLstate=0
        sTimeOut=' '
	myd3dsettext(1,sTimeOut,255)
    end
end

settimer(1000, 'runshowfunc')