Update Aardwolf_Clock.xml

Added new phrasing of time
master
AardCrowley 10 months ago committed by GitHub
parent d2d2eb7a60
commit f9b424faf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -6,14 +6,14 @@
<!-- Plugin "Aardwolf_Clock" generated by Plugin Wizard --> <!-- Plugin "Aardwolf_Clock" generated by Plugin Wizard -->
<muclient> <muclient>
<plugin name="Aardwolf_Clock" author="Crowley, with help from Fiendish" id="28a36788fa20aa062e760ee2" language="Lua" purpose="Displays a realtime clock based on Aardwolf game time" save_state="y" date_written="2018-05-15 11:43:22" requires="4.90" version="2.84"> <plugin name="Aardwolf_Clock" author="Crowley, with help from Fiendish" id="28a36788fa20aa062e760ee2" language="Lua" purpose="Displays a realtime clock based on Aardwolf game time" save_state="y" date_written="2018-05-15 11:43:22" requires="4.90" version="4.00">
</plugin> </plugin>
<!-- Triggers --> <!-- Triggers -->
<triggers> <triggers>
<trigger enabled="n" match="^\s+\*\s+It is ((?:\d+|Noon|Midnight))((?:p|a))?m? on the (\d+)(?:rd|th|nd|st) day of the Season of (?:the )?(\w+).*$" script="getTime" regexp="y" sequence="100" omit_from_output="n" name="GetTime"> <trigger enabled="n" match="^\s+\*\s+It is ((?:\d+|Noon|Midnight))((?:p|a))?m? (?:in the daytime|in the evening|during the night) of the (\d+)(?:rd|th|nd|st) day of the Season of (?:the )?(\w+).*$" script="getTime" regexp="y" sequence="100" omit_from_output="n" name="GetTime">
</trigger> </trigger>
</triggers> </triggers>
@ -42,6 +42,9 @@
<script> <script>
<![CDATA[ <![CDATA[
require 'movewindow' require 'movewindow'
require 'themed_miniwindows'
async_ok, async = pcall (require, "async")
clock_seasons = { clock_seasons = {
Sun = {138, 3, 19, 1, "Light"}, Sun = {138, 3, 19, 1, "Light"},
@ -91,16 +94,14 @@
clock_current = {Season = "Sun", day = 1, order = 1} clock_current = {Season = "Sun", day = 1, order = 1}
local win = "AardClock_" .. GetPluginID() win = "AardClock_Crowley"
local font = "f" font = "f"
windowinfo = movewindow.install(win, 7, miniwin.create_absolute_location, true, nil)
checked_time = false checked_time = false
local footer_text = {} footer_text = {}
local font_families = utils.getfontfamilies() font_families = utils.getfontfamilies()
if font_families["Monoid"] then if font_families["Monoid"] then
font_name = "Monoid" font_name = "Monoid"
font_size = 8 font_size = 8
@ -115,25 +116,37 @@
font_size = 10 font_size = 10
end end
WindowCreate(win, 0, 0, 0, 0, 1, 0, 0) clockWin = ThemedBasicWindow(
win, -- id
0, -- default_left_position
0, -- default_top_position
0, -- default_width
0, -- default_height
"AardClock", -- title
"center", -- title alignment
false, -- is_temporary
1, -- resizer_type
nil, -- do_while_resizing
nil, -- do_after_resizing
nil, -- do_on_delete
fontName, -- title_font_name
fontSize, -- title_font_size
true -- defer_showing
)
require 'tprint'
--tprint(clockWin)
WindowFont(win, font, clockWin.title_font_name, clockWin.title_font_size, true)
title_height = WindowFontInfo(win, font, 1) + 5
WindowFont(win, font, font_name, font_size, true) WindowFont(win, font, font_name, font_size, true)
local font_height = WindowFontInfo(win, font, 1) font_height = WindowFontInfo(win, font, 1)
local font_width = WindowTextWidth(win, font, " ", 1) font_width = WindowTextWidth(win, font, " ", 1)
window_width = (20 * font_width) + 11 window_width = (20 * font_width) + 11
local cx = math.floor((window_width-5)/2) + 3 cx = math.floor((window_width-5)/2) + 3
local cy = cx + font_height cy = cx + font_height + title_height
bgDay = 'khaki'
bgNight = 'navy'
textDay = 'black'
textNight = 'white'
hourTime = 12
bgColour = 'khaki'
textColour = 'black'
handDay = 'black'
handNight = 'yellow'
handColour = 'black'
function round(v) function round(v)
local r = 0 local r = 0
@ -171,6 +184,32 @@
return {posx = x - offset, posy = y} return {posx = x - offset, posy = y}
end end
PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19)
PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1)
clock_numbers = {}
for i = 1,12 do
table.insert(clock_numbers, {text = i, pos = findPos(i)})
end
endy = clock_numbers[6].pos.posy
starty = clock_numbers[12].pos.posy
window_height = font_height + title_height + 5 + endy + starty + (font_height * (#footer_text + 2)) -- font_height * 10
clockWin:resize(window_width, window_height)
bgDay = 'khaki'
bgNight = 'navy'
textDay = 'black'
textNight = 'white'
hourTime = 12
bgColour = 'khaki'
textColour = 'black'
handDay = 'black'
handNight = 'yellow'
handColour = 'black'
function drawHand(t, r, subset) function drawHand(t, r, subset)
local y9, x12, y3, x6 = findPos(9), findPos(12), findPos(3), findPos(6) local y9, x12, y3, x6 = findPos(9), findPos(12), findPos(3), findPos(6)
local startx, starty, endx, endy = x12.posx + (font_width)/2, y9.posy + (font_height/2), x6.posx + font_width/2, y3.posy + font_height/2 local startx, starty, endx, endy = x12.posx + (font_width)/2, y9.posy + (font_height/2), x6.posx + font_width/2, y3.posy + font_height/2
@ -200,19 +239,20 @@
end end
function drawFace() function drawFace()
clockWin:blank()
WindowDrawImage(win, "background", 0, 0, (WindowInfo(win, 3) or 0), (WindowInfo(win, 4) or 0), miniwin.image_stretch) WindowDrawImage(win, "background", 0, 0, (WindowInfo(win, 3) or 0), (WindowInfo(win, 4) or 0), miniwin.image_stretch)
local x = 5 local x = 5
local y = clock_numbers[6].pos.posy + font_height * 2 local y = clock_numbers[6].pos.posy + title_height + font_height * 2
WindowText(win, font, seasonEnd, center(seasonEnd), font_height/2, 0, 0, ColourNameToRGB(textColour)) WindowText(win, font, seasonEnd, center(seasonEnd), font_height/2 + title_height, 0, 0, ColourNameToRGB(textColour))
local sunr = (clock_seasons[clock_current.Season][2] or 1) .. "am" local sunr = (clock_seasons[clock_current.Season][2] or 1) .. "am"
local suns = ((tonumber(clock_seasons[clock_current.Season][3]) - 12) or 12) .. "pm" local suns = ((tonumber(clock_seasons[clock_current.Season][3]) - 12) or 12) .. "pm"
WindowText(win, font, sunr, x, font_height*1.5, 0, 0, ColourNameToRGB(textColour)) WindowText(win, font, sunr, x, title_height + font_height*1.5, 0, 0, ColourNameToRGB(textColour))
local cdiml, cdimt = font_width, font_height*2.5 local cdiml, cdimt = font_width, title_height + font_height*2.5
local cdimr, cdimb = cdiml + font_width*2, cdimt + (font_width*2) local cdimr, cdimb = cdiml + font_width*2, cdimt + (font_width*2)
WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("yellow"), 2, 1, ColourNameToRGB("yellow"), 0) WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("yellow"), 2, 1, ColourNameToRGB("yellow"), 0)
@ -220,7 +260,7 @@
cdiml = (WindowInfo(win, 3) - 5) - font_width*3 cdiml = (WindowInfo(win, 3) - 5) - font_width*3
cdimr = cdiml + font_width*2 cdimr = cdiml + font_width*2
WindowText(win, font, suns, ((WindowInfo(win, 3) -5) - font_width*4), font_height*1.5, 0, 0, ColourNameToRGB(textColour)) WindowText(win, font, suns, ((WindowInfo(win, 3) -5) - font_width*4), title_height + font_height*1.5, 0, 0, ColourNameToRGB(textColour))
WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("orangered"), 2, 1, ColourNameToRGB("orangered"), 0) WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("orangered"), 2, 1, ColourNameToRGB("orangered"), 0)
@ -242,7 +282,6 @@
for _,v in ipairs(clock_numbers) do for _,v in ipairs(clock_numbers) do
WindowText(win, font, v.text, v.pos.posx, v.pos.posy, 0, 0, ColourNameToRGB(textColour)) WindowText(win, font, v.text, v.pos.posx, v.pos.posy, 0, 0, ColourNameToRGB(textColour))
end end
WindowText(win, font, (dTime or ""), center((dTime or "")), y, 0, 0, ColourNameToRGB(textColour)) WindowText(win, font, (dTime or ""), center((dTime or "")), y, 0, 0, ColourNameToRGB(textColour))
@ -253,10 +292,10 @@
y = y + font_height y = y + font_height
WindowText(win, font, string.format("[ %s ]", footer_text.DamType), center(string.format("[ %s ]", footer_text.DamType)), y, 0, 0, ColourNameToRGB(textColour)) WindowText(win, font, string.format("[ %s ]", footer_text.DamType), center(string.format("[ %s ]", footer_text.DamType)), y, 0, 0, ColourNameToRGB(textColour))
WindowRectOp(win, 4, 1, 1, WindowInfo(win, 3)-1, WindowInfo(win, 4)-1, ColourNameToRGB("black"), ColourNameToRGB("black")) -- 9, 15 + 0x1000 + 0x4000) WindowRectOp(win, 4, 1, 1, WindowInfo(win, 3)-1, WindowInfo(win, 4)-1, ColourNameToRGB("black"), ColourNameToRGB("black")) -- 9, 15 + 0x1000 + 0x4000)
WindowSetZOrder(win, 50) clockWin:dress_window()
WindowShow(win, true) Redraw()
end end
function center(t) function center(t)
@ -356,6 +395,7 @@
checked_time = true checked_time = true
EnableTrigger("GetTime", false) EnableTrigger("GetTime", false)
clockWin:show()
end end
function updateTime() function updateTime()
@ -371,6 +411,7 @@
local rH, rM = math.floor(mins_left/60), math.floor(mins_left%60) local rH, rM = math.floor(mins_left/60), math.floor(mins_left%60)
seasonEnd = seasonEnd .. rH .. "h " .. rM .. "m" seasonEnd = seasonEnd .. rH .. "h " .. rM .. "m"
--clockWin.title = seasonEnd
end end
function onTimer() function onTimer()
@ -378,10 +419,12 @@
last_tick = last_tick or os.clock() last_tick = last_tick or os.clock()
local s = os.clock() - last_tick local s = os.clock() - last_tick
updateTime() updateTime()
clockWin:blank()
drawFace() drawFace()
drawHand(math.min(30, s), 60, 30) drawHand(math.min(30, s), 60, 30)
hourHandTime = hourTime + s/30 hourHandTime = hourTime + s/30
drawHand(hourHandTime, 45, 12) drawHand(hourHandTime, 45, 12)
--clockWin:dress_window()
Redraw() Redraw()
end end
end end
@ -405,42 +448,9 @@
end end
function OnPluginDisable()
WindowDelete(win)
end
function OnPluginSaveState()
movewindow.save_state(win)
end
function OnPluginClose()
OnPluginDisable()
end
function OnPluginInstall()
PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19)
PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1)
seasonEnd = ""
clock_numbers = {}
for i = 1,12 do
table.insert(clock_numbers, {text = i, pos = findPos(i)})
end
local endy = clock_numbers[6].pos.posy
local starty = clock_numbers[12].pos.posy
local window_height = font_height + 5 + endy + starty + (font_height * (#footer_text + 2)) -- font_height * 10
WindowCreate(win, windowinfo.window_left, windowinfo.window_top, window_width, window_height, windowinfo.window_mode, windowinfo.window_flags + miniwin.create_keep_hotspots, ColourNameToRGB("black"))
movewindow.add_drag_handler (win, 0, 0, 0, window_height)
end
function update_plugin() function update_plugin()
raw = "https://raw.githubusercontent.com/AardCrowley/Aardwolf-Scripts/master/Aardwolf_Clock%20V2/Aardwolf_Clock.xml" raw = "https://raw.githubusercontent.com/AardCrowley/Aardwolf-Scripts/master/Aardwolf_Clock%20V2/Aardwolf_Clock.xml"
async_ok, async = pcall (require, "async")
if async_ok then if async_ok then
plugin_page = async.doAsyncRemoteRequest(raw, raw_get, "HTTPS") plugin_page = async.doAsyncRemoteRequest(raw, raw_get, "HTTPS")
else else

Loading…
Cancel
Save