├── Locales ├── Locales.xml ├── deDE.lua ├── enUS.lua ├── frFR.lua ├── ruRU.lua ├── zhCN.lua └── zhTW.lua ├── README.md ├── Sounds ├── AlarmClockWarning1.wav ├── AlarmClockWarning2.wav └── AlarmClockWarning3.wav ├── Textures ├── ClockBackground.blp ├── GlobeIcon.blp ├── PauseButton.blp ├── ResetButton.blp └── TimerBackground.blp ├── TimeManager.lua ├── TimeManager.toc └── TimeManager.xml /Locales/Locales.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Locales/deDE.lua: -------------------------------------------------------------------------------- 1 | if GetLocale() ~= "deDE" then return end 2 | 3 | GAMETIME_TOOLTIP_TOGGLE_CLOCK = "Klicken, um die Einstellungen der Uhr anzuzeigen." 4 | NEWBIE_TOOLTIP_STOPWATCH_PLAYPAUSEBUTTON = "Start/Pause" 5 | NEWBIE_TOOLTIP_STOPWATCH_RESETBUTTON = "Zurücksetzen" 6 | SLASH_STOPWATCH1 = "/stopwatch" 7 | SLASH_STOPWATCH2 = "/timer" 8 | SLASH_STOPWATCH3 = "/sw" 9 | SLASH_STOPWATCH4 = "/stoppuhr" 10 | SLASH_STOPWATCH5 = "/timer" 11 | SLASH_STOPWATCH6 = "/su" 12 | SLASH_STOPWATCH_PARAM_PAUSE1 = "pause" 13 | SLASH_STOPWATCH_PARAM_PAUSE2 = "zwischenzeit" 14 | SLASH_STOPWATCH_PARAM_PLAY1 = "play" 15 | SLASH_STOPWATCH_PARAM_PLAY2 = "messen" 16 | SLASH_STOPWATCH_PARAM_STOP1 = "stop" 17 | SLASH_STOPWATCH_PARAM_STOP2 = "clear" 18 | SLASH_STOPWATCH_PARAM_STOP3 = "reset" 19 | SLASH_STOPWATCH_PARAM_STOP4 = "stopp" 20 | SLASH_STOPWATCH_PARAM_STOP5 = "löschen" 21 | SLASH_STOPWATCH_PARAM_STOP6 = "zurücksetzen" 22 | STOPWATCH_TIME_UNIT = "%02d" 23 | STOPWATCH_TITLE = "Stoppuhr" 24 | TIMEMANAGER_12HOUR = "%d" 25 | TIMEMANAGER_24HOUR = "%02d" 26 | TIMEMANAGER_24HOURMODE = "24-Stunden-Modus" 27 | TIMEMANAGER_ALARM_DISABLED = "Alarm abschalten" 28 | TIMEMANAGER_ALARM_ENABLED = "Alarm einschalten" 29 | TIMEMANAGER_ALARM_MESSAGE = "Alarmnachricht" 30 | TIMEMANAGER_ALARM_TIME = "Alarmzeit" 31 | TIMEMANAGER_ALARM_TOOLTIP_TURN_OFF = "Klicken, um den Alarm abzuschalten." 32 | TIMEMANAGER_AM = "AM" 33 | TIMEMANAGER_LOCALTIME = "Ortszeit benutzen" 34 | TIMEMANAGER_MINUTE = "%02d" 35 | TIMEMANAGER_PM = "PM" 36 | TIMEMANAGER_SHOW_STOPWATCH = "Stoppuhr anz." 37 | TIMEMANAGER_TICKER_12HOUR = "%d:%02d" 38 | TIMEMANAGER_TICKER_24HOUR = "%02d:%02d" 39 | TIMEMANAGER_TITLE = "Uhr" 40 | TIMEMANAGER_TOOLTIP_LOCALTIME = "Ortszeit:" 41 | TIMEMANAGER_TOOLTIP_REALMTIME = "Serverzeit:" 42 | TIMEMANAGER_TOOLTIP_TITLE = "Zeitinfo" -------------------------------------------------------------------------------- /Locales/enUS.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | GAMETIME_TOOLTIP_TOGGLE_CLOCK = "Click to show clock settings." 4 | NEWBIE_TOOLTIP_STOPWATCH_PLAYPAUSEBUTTON = "Play/Pause" 5 | NEWBIE_TOOLTIP_STOPWATCH_RESETBUTTON = "Reset" 6 | SLASH_STOPWATCH1 = "/stopwatch" 7 | SLASH_STOPWATCH2 = "/timer" 8 | SLASH_STOPWATCH3 = "/sw" 9 | SLASH_STOPWATCH4 = "/stopwatch" 10 | SLASH_STOPWATCH5 = "/timer" 11 | SLASH_STOPWATCH6 = "/sw" 12 | SLASH_STOPWATCH_PARAM_PAUSE1 = "pause" 13 | SLASH_STOPWATCH_PARAM_PAUSE2 = "pause" 14 | SLASH_STOPWATCH_PARAM_PLAY1 = "play" 15 | SLASH_STOPWATCH_PARAM_PLAY2 = "play" 16 | SLASH_STOPWATCH_PARAM_STOP1 = "stop" 17 | SLASH_STOPWATCH_PARAM_STOP2 = "clear" 18 | SLASH_STOPWATCH_PARAM_STOP3 = "reset" 19 | SLASH_STOPWATCH_PARAM_STOP4 = "stop" 20 | SLASH_STOPWATCH_PARAM_STOP5 = "clear" 21 | SLASH_STOPWATCH_PARAM_STOP6 = "reset" 22 | STOPWATCH_TIME_UNIT = "%02d" 23 | STOPWATCH_TITLE = "Stopwatch" 24 | TIMEMANAGER_12HOUR = "%d" 25 | TIMEMANAGER_24HOUR = "%02d" 26 | TIMEMANAGER_24HOURMODE = "24 Hour Mode" 27 | TIMEMANAGER_ALARM_DISABLED = "Alarm Disabled" 28 | TIMEMANAGER_ALARM_ENABLED = "Alarm Enabled" 29 | TIMEMANAGER_ALARM_MESSAGE = "Alarm Message" 30 | TIMEMANAGER_ALARM_TIME = "Alarm Time" 31 | TIMEMANAGER_ALARM_TOOLTIP_TURN_OFF = "Click to turn off alarm." 32 | TIMEMANAGER_AM = "AM" 33 | TIMEMANAGER_LOCALTIME = "Use Local Time" 34 | TIMEMANAGER_MINUTE = "%02d" 35 | TIMEMANAGER_PM = "PM" 36 | TIMEMANAGER_SHOW_STOPWATCH = "Show Stopwatch" 37 | TIMEMANAGER_TICKER_12HOUR = "%d:%02d" 38 | TIMEMANAGER_TICKER_24HOUR = "%02d:%02d" 39 | TIMEMANAGER_TITLE = "Clock" 40 | TIMEMANAGER_TOOLTIP_LOCALTIME = "Local time:" 41 | TIMEMANAGER_TOOLTIP_REALMTIME = "Realm time:" 42 | TIMEMANAGER_TOOLTIP_TITLE = "Time Info" -------------------------------------------------------------------------------- /Locales/frFR.lua: -------------------------------------------------------------------------------- 1 | if GetLocale() ~= "frFR" then return end 2 | 3 | GAMETIME_TOOLTIP_TOGGLE_CLOCK = "Cliquez pour voir les réglages de l'horloge." 4 | NEWBIE_TOOLTIP_STOPWATCH_PLAYPAUSEBUTTON = "Début/Pause" 5 | NEWBIE_TOOLTIP_STOPWATCH_RESETBUTTON = "Réinitialiser" 6 | SLASH_STOPWATCH1 = "/stopwatch" 7 | SLASH_STOPWATCH2 = "/timer" 8 | SLASH_STOPWATCH3 = "/sw" 9 | SLASH_STOPWATCH4 = "/chrono" 10 | SLASH_STOPWATCH5 = "/rebours" 11 | SLASH_STOPWATCH6 = "/cm" 12 | SLASH_STOPWATCH_PARAM_PAUSE1 = "pause" 13 | SLASH_STOPWATCH_PARAM_PAUSE2 = "pause" 14 | SLASH_STOPWATCH_PARAM_PLAY1 = "lecture" 15 | SLASH_STOPWATCH_PARAM_PLAY2 = "lecture" 16 | SLASH_STOPWATCH_PARAM_STOP1 = "arrêter" 17 | SLASH_STOPWATCH_PARAM_STOP2 = "effacer" 18 | SLASH_STOPWATCH_PARAM_STOP3 = "réinitialiser" 19 | SLASH_STOPWATCH_PARAM_STOP4 = "arrêter" 20 | SLASH_STOPWATCH_PARAM_STOP5 = "effacer" 21 | SLASH_STOPWATCH_PARAM_STOP6 = "réinitialiser" 22 | STOPWATCH_TIME_UNIT = "%02d" 23 | STOPWATCH_TITLE = "Chronomètre" 24 | TIMEMANAGER_12HOUR = "%d" 25 | TIMEMANAGER_24HOUR = "%02d" 26 | TIMEMANAGER_24HOURMODE = "Mode 24 heures" 27 | TIMEMANAGER_ALARM_DISABLED = "Alarme désactivée" 28 | TIMEMANAGER_ALARM_ENABLED = "Alarme activée" 29 | TIMEMANAGER_ALARM_MESSAGE = "Message de l'alarme" 30 | TIMEMANAGER_ALARM_TIME = "Heure de l'alarme" 31 | TIMEMANAGER_ALARM_TOOLTIP_TURN_OFF = "Cliquez pour éteindre l'alarme." 32 | TIMEMANAGER_AM = "AM" 33 | TIMEMANAGER_LOCALTIME = "Utiliser l'heure locale" 34 | TIMEMANAGER_MINUTE = "%02d" 35 | TIMEMANAGER_PM = "PM" 36 | TIMEMANAGER_SHOW_STOPWATCH = "Aff. chronomètre" 37 | TIMEMANAGER_TICKER_12HOUR = "%d:%02d" 38 | TIMEMANAGER_TICKER_24HOUR = "%02d:%02d" 39 | TIMEMANAGER_TITLE = "Horloge" 40 | TIMEMANAGER_TOOLTIP_LOCALTIME = "Heure locale :" 41 | TIMEMANAGER_TOOLTIP_REALMTIME = "Heure du royaume :" 42 | TIMEMANAGER_TOOLTIP_TITLE = "Info temps" -------------------------------------------------------------------------------- /Locales/ruRU.lua: -------------------------------------------------------------------------------- 1 | if GetLocale() ~= "ruRU" then return end 2 | 3 | GAMETIME_TOOLTIP_TOGGLE_CLOCK = "Щелкните, чтобы настроить часы." 4 | NEWBIE_TOOLTIP_STOPWATCH_PLAYPAUSEBUTTON = "Включить/пауза" 5 | NEWBIE_TOOLTIP_STOPWATCH_RESETBUTTON = "Сброс" 6 | SLASH_STOPWATCH1 = "/stopwatch" 7 | SLASH_STOPWATCH2 = "/timer" 8 | SLASH_STOPWATCH3 = "/sw" 9 | SLASH_STOPWATCH4 = "/stopwatch" 10 | SLASH_STOPWATCH5 = "/timer" 11 | SLASH_STOPWATCH6 = "/sw" 12 | SLASH_STOPWATCH_PARAM_PAUSE1 = "пауза" 13 | SLASH_STOPWATCH_PARAM_PAUSE2 = "пауза" 14 | SLASH_STOPWATCH_PARAM_PLAY1 = "старт" 15 | SLASH_STOPWATCH_PARAM_PLAY2 = "старт" 16 | SLASH_STOPWATCH_PARAM_STOP1 = "стоп" 17 | SLASH_STOPWATCH_PARAM_STOP2 = "очистить" 18 | SLASH_STOPWATCH_PARAM_STOP3 = "сброс" 19 | SLASH_STOPWATCH_PARAM_STOP4 = "стоп" 20 | SLASH_STOPWATCH_PARAM_STOP5 = "очистить" 21 | SLASH_STOPWATCH_PARAM_STOP6 = "сброс" 22 | STOPWATCH_TIME_UNIT = "%02d" 23 | STOPWATCH_TITLE = "Таймер" 24 | TIMEMANAGER_12HOUR = "%d" 25 | TIMEMANAGER_24HOUR = "%02d" 26 | TIMEMANAGER_24HOURMODE = "24 часа" 27 | TIMEMANAGER_ALARM_DISABLED = "Откл. напоминание" 28 | TIMEMANAGER_ALARM_ENABLED = "Вкл. напоминание" 29 | TIMEMANAGER_ALARM_MESSAGE = "Сообщение" 30 | TIMEMANAGER_ALARM_TIME = "Время будильника" 31 | TIMEMANAGER_ALARM_TOOLTIP_TURN_OFF = "Щелкните, чтобы отключить напоминание." 32 | TIMEMANAGER_AM = "AM" 33 | TIMEMANAGER_LOCALTIME = "Использовать местное время" 34 | TIMEMANAGER_MINUTE = "%02d" 35 | TIMEMANAGER_PM = "PM" 36 | TIMEMANAGER_SHOW_STOPWATCH = "Таймер" 37 | TIMEMANAGER_TICKER_12HOUR = "%d:%02d" 38 | TIMEMANAGER_TICKER_24HOUR = "%02d:%02d" 39 | TIMEMANAGER_TITLE = "Часы" 40 | TIMEMANAGER_TOOLTIP_LOCALTIME = "Местное время:" 41 | TIMEMANAGER_TOOLTIP_REALMTIME = "Серверное время:" 42 | TIMEMANAGER_TOOLTIP_TITLE = "Информация о времени" -------------------------------------------------------------------------------- /Locales/zhCN.lua: -------------------------------------------------------------------------------- 1 | if GetLocale() ~= "zhCN" then return end 2 | 3 | GAMETIME_TOOLTIP_TOGGLE_CLOCK = "点击这里显示时钟设置选项。" 4 | NEWBIE_TOOLTIP_STOPWATCH_PLAYPAUSEBUTTON = "开始/暂停" 5 | NEWBIE_TOOLTIP_STOPWATCH_RESETBUTTON = "重置" 6 | SLASH_STOPWATCH1 = "/stopwatch" 7 | SLASH_STOPWATCH2 = "/timer" 8 | SLASH_STOPWATCH3 = "/sw" 9 | SLASH_STOPWATCH4 = "/stopwatch" 10 | SLASH_STOPWATCH5 = "/timer" 11 | SLASH_STOPWATCH6 = "/sw" 12 | SLASH_STOPWATCH_PARAM_PAUSE1 = "暂停" 13 | SLASH_STOPWATCH_PARAM_PAUSE2 = "暂停" 14 | SLASH_STOPWATCH_PARAM_PLAY1 = "播放" 15 | SLASH_STOPWATCH_PARAM_PLAY2 = "播放" 16 | SLASH_STOPWATCH_PARAM_STOP1 = "停止" 17 | SLASH_STOPWATCH_PARAM_STOP2 = "清除" 18 | SLASH_STOPWATCH_PARAM_STOP3 = "重置" 19 | SLASH_STOPWATCH_PARAM_STOP4 = "停止" 20 | SLASH_STOPWATCH_PARAM_STOP5 = "清除" 21 | SLASH_STOPWATCH_PARAM_STOP6 = "重置" 22 | STOPWATCH_TIME_UNIT = "%02d" 23 | STOPWATCH_TITLE = "秒表" 24 | TIMEMANAGER_12HOUR = "%d" 25 | TIMEMANAGER_24HOUR = "%02d" 26 | TIMEMANAGER_24HOURMODE = "24小时模式" 27 | TIMEMANAGER_ALARM_DISABLED = "提醒已关闭" 28 | TIMEMANAGER_ALARM_ENABLED = "开启提醒" 29 | TIMEMANAGER_ALARM_MESSAGE = "提醒信息" 30 | TIMEMANAGER_ALARM_TIME = "提醒时间" 31 | TIMEMANAGER_ALARM_TOOLTIP_TURN_OFF = "点击这里关闭提醒。" 32 | TIMEMANAGER_AM = "AM" 33 | TIMEMANAGER_LOCALTIME = "使用本地时间" 34 | TIMEMANAGER_MINUTE = "%02d" 35 | TIMEMANAGER_PM = "PM" 36 | TIMEMANAGER_SHOW_STOPWATCH = "显示秒表" 37 | TIMEMANAGER_TICKER_12HOUR = "%d:%02d" 38 | TIMEMANAGER_TICKER_24HOUR = "%02d:%02d" 39 | TIMEMANAGER_TITLE = "时钟" 40 | TIMEMANAGER_TOOLTIP_LOCALTIME = "本地时间:" 41 | TIMEMANAGER_TOOLTIP_REALMTIME = "服务器时间:" 42 | TIMEMANAGER_TOOLTIP_TITLE = "时间信息" -------------------------------------------------------------------------------- /Locales/zhTW.lua: -------------------------------------------------------------------------------- 1 | if GetLocale() ~= "zhTW" then return end 2 | 3 | GAMETIME_TOOLTIP_TOGGLE_CLOCK = "點擊以顯示時鐘設定。" 4 | NEWBIE_TOOLTIP_STOPWATCH_PLAYPAUSEBUTTON = "計時/暫停" 5 | NEWBIE_TOOLTIP_STOPWATCH_RESETBUTTON = "重置" 6 | SLASH_STOPWATCH1 = "/碼錶" 7 | SLASH_STOPWATCH2 = "/計時" 8 | SLASH_STOPWATCH3 = "/sw" 9 | SLASH_STOPWATCH4 = "/stopwatch" 10 | SLASH_STOPWATCH5 = "/timer" 11 | SLASH_STOPWATCH6 = "/碼錶" 12 | SLASH_STOPWATCH_PARAM_PAUSE1 = "暫停" 13 | SLASH_STOPWATCH_PARAM_PAUSE2 = "暫停" 14 | SLASH_STOPWATCH_PARAM_PLAY1 = "播放" 15 | SLASH_STOPWATCH_PARAM_PLAY2 = "播放" 16 | SLASH_STOPWATCH_PARAM_STOP1 = "停止" 17 | SLASH_STOPWATCH_PARAM_STOP2 = "清除" 18 | SLASH_STOPWATCH_PARAM_STOP3 = "重置" 19 | SLASH_STOPWATCH_PARAM_STOP4 = "停止" 20 | SLASH_STOPWATCH_PARAM_STOP5 = "清除" 21 | SLASH_STOPWATCH_PARAM_STOP6 = "重置" 22 | STOPWATCH_TIME_UNIT = "%02d" 23 | STOPWATCH_TITLE = "碼錶" 24 | TIMEMANAGER_12HOUR = "%d" 25 | TIMEMANAGER_24HOUR = "%02d" 26 | TIMEMANAGER_24HOURMODE = "24小時模式" 27 | TIMEMANAGER_ALARM_DISABLED = "鬧鐘已關閉" 28 | TIMEMANAGER_ALARM_ENABLED = "鬧鐘已開啟" 29 | TIMEMANAGER_ALARM_MESSAGE = "鬧鐘訊息" 30 | TIMEMANAGER_ALARM_TIME = "鬧鐘時間" 31 | TIMEMANAGER_ALARM_TOOLTIP_TURN_OFF = "點擊以關閉鬧鐘。" 32 | TIMEMANAGER_AM = "AM" 33 | TIMEMANAGER_LOCALTIME = "使用當地時間" 34 | TIMEMANAGER_MINUTE = "%02d" 35 | TIMEMANAGER_PM = "PM" 36 | TIMEMANAGER_SHOW_STOPWATCH = "顯示碼錶" 37 | TIMEMANAGER_TICKER_12HOUR = "%d:%02d" 38 | TIMEMANAGER_TICKER_24HOUR = "%02d:%02d" 39 | TIMEMANAGER_TITLE = "時鐘" 40 | TIMEMANAGER_TOOLTIP_LOCALTIME = "當地時間:" 41 | TIMEMANAGER_TOOLTIP_REALMTIME = "伺服器時間:" 42 | TIMEMANAGER_TOOLTIP_TITLE = "時間資訊" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![TimeManager](http://i.imgur.com/mz7QX4A.png) 2 | 3 | # TimeManager (Blizzard_TimeManager) 4 | 5 | Time Management features from patch 2.4.3+. These features include an alarm clock, stopwatch, and viewing your computer's local time. 6 | 7 | ## Slash commands 8 | 9 | /stopwatch - Toggles the stopwatch 10 | /stopwatch time - Toggles the stopwatch to count down from the given time. Format: [[H:]M:]S 11 | /stopwatch clear - Stops the timer and resets to 0 12 | /stopwatch pause - Pauses the timer 13 | /stopwatch reset - Stops the timer and resets to 0 14 | /stopwatch stop - Stops the timer and resets to 0 15 | /stopwatch close - Closes the timer's window 16 | 17 | More information: http://wowwiki.wikia.com/wiki/MACRO_stopwatch 18 | 19 | ## Install 20 | 21 | 1. [Download TimeManager](https://github.com/gashole/TimeManager/releases/download/current/TimeManager.zip) 22 | 2. Extract the zip to an easy to find location such as your Desktop 23 | 3. Move the TimeManager folder into your AddOns folder 24 | -------------------------------------------------------------------------------- /Sounds/AlarmClockWarning1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gashole/TimeManager/4a2bd0af61745cf3d5f01166b470e33982759c56/Sounds/AlarmClockWarning1.wav -------------------------------------------------------------------------------- /Sounds/AlarmClockWarning2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gashole/TimeManager/4a2bd0af61745cf3d5f01166b470e33982759c56/Sounds/AlarmClockWarning2.wav -------------------------------------------------------------------------------- /Sounds/AlarmClockWarning3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gashole/TimeManager/4a2bd0af61745cf3d5f01166b470e33982759c56/Sounds/AlarmClockWarning3.wav -------------------------------------------------------------------------------- /Textures/ClockBackground.blp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gashole/TimeManager/4a2bd0af61745cf3d5f01166b470e33982759c56/Textures/ClockBackground.blp -------------------------------------------------------------------------------- /Textures/GlobeIcon.blp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gashole/TimeManager/4a2bd0af61745cf3d5f01166b470e33982759c56/Textures/GlobeIcon.blp -------------------------------------------------------------------------------- /Textures/PauseButton.blp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gashole/TimeManager/4a2bd0af61745cf3d5f01166b470e33982759c56/Textures/PauseButton.blp -------------------------------------------------------------------------------- /Textures/ResetButton.blp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gashole/TimeManager/4a2bd0af61745cf3d5f01166b470e33982759c56/Textures/ResetButton.blp -------------------------------------------------------------------------------- /Textures/TimerBackground.blp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gashole/TimeManager/4a2bd0af61745cf3d5f01166b470e33982759c56/Textures/TimerBackground.blp -------------------------------------------------------------------------------- /TimeManager.lua: -------------------------------------------------------------------------------- 1 | 2 | -- speed optimizations (mostly so update functions are faster) 3 | local _G = getfenv(0) 4 | local date = _G.date 5 | local abs = _G.abs 6 | local min = _G.min 7 | local max = _G.max 8 | local floor = _G.floor 9 | local format = _G.format 10 | local mod = _G.mod 11 | local tonumber = _G.tonumber 12 | local gsub = _G.gsub 13 | local GetGameTime = _G.GetGameTime 14 | 15 | -- private data 16 | local SEC_TO_MINUTE_FACTOR = 1 / 60 17 | local SEC_TO_HOUR_FACTOR = SEC_TO_MINUTE_FACTOR * SEC_TO_MINUTE_FACTOR 18 | MAX_TIMER_SEC = 99 * 3600 + 59 * 60 + 59 -- 99:59:59 19 | 20 | local WARNING_SOUND_TRIGGER_OFFSET = -2 * SEC_TO_MINUTE_FACTOR -- play warning sound 2 sec before alarm sound 21 | 22 | local Settings = { 23 | militaryTime = false, 24 | localTime = false, 25 | 26 | alarmHour = 12, 27 | alarmMinute = 00, 28 | alarmAM = true, 29 | alarmMessage = "", 30 | alarmEnabled = false 31 | } 32 | 33 | local UIDropDownMenu_ButtonInfo = {} 34 | 35 | function UIDropDownMenu_CreateInfo() 36 | -- Reuse the same table to prevent memory churn 37 | local info = UIDropDownMenu_ButtonInfo 38 | for k, v in pairs(info) do 39 | info[k] = nil 40 | end 41 | return UIDropDownMenu_ButtonInfo 42 | end 43 | 44 | function UIDropDownMenu_SetWidth(width, frame, padding) 45 | if not frame then frame = this end 46 | _G[frame:GetName() .. "Middle"]:SetWidth(width) 47 | local defaultPadding = 25 48 | if padding then 49 | frame:SetWidth(width + padding) 50 | _G[frame:GetName() .. "Text"]:SetWidth(width) 51 | else 52 | frame:SetWidth(width + defaultPadding + defaultPadding) 53 | _G[frame:GetName() .. "Text"]:SetWidth(width - defaultPadding) 54 | end 55 | frame.noResize = 1 56 | end 57 | 58 | local origToggleGameMenu = ToggleGameMenu 59 | function ToggleGameMenu(clicked) 60 | if TimeManagerFrame:IsShown() and not IsOptionFrameOpen() then 61 | TimeManagerCloseButton:Click() 62 | else 63 | origToggleGameMenu(clicked) 64 | end 65 | end 66 | 67 | local origWorldFrame_OnUpdate = WorldFrame_OnUpdate 68 | function WorldFrame_OnUpdate(elapsed) 69 | if not elapsed then elapsed = arg1 end 70 | origWorldFrame_OnUpdate(elapsed) 71 | -- Process time manager alarm onUpdates in order to allow the alarm to go off without the clock 72 | -- being visible 73 | if TimeManagerClockButton and not TimeManagerClockButton:IsVisible() and TimeManager_ShouldCheckAlarm() then 74 | TimeManager_CheckAlarm(elapsed) 75 | end 76 | if StopwatchTicker and not StopwatchTicker:IsVisible() and Stopwatch_IsPlaying() then 77 | StopwatchTicker_OnUpdate(elapsed) 78 | end 79 | end 80 | 81 | local function _TimeManager_ComputeMinutes(hour, minute, militaryTime, am) 82 | local minutes 83 | if militaryTime then 84 | minutes = minute + hour * 60 85 | else 86 | local h = hour 87 | if am then 88 | if h == 12 then 89 | h = 0 90 | end 91 | else 92 | if h ~= 12 then 93 | h = h + 12 94 | end 95 | end 96 | minutes = minute + h * 60 97 | end 98 | return minutes 99 | end 100 | 101 | local function _TimeManager_GetCurrentMinutes(localTime) 102 | local hour, minute 103 | if localTime then 104 | hour, minute = tonumber(date("%H")), tonumber(date("%M")) 105 | else 106 | hour, minute = GetGameTime() 107 | end 108 | return minute + hour * 60 109 | end 110 | 111 | function GameTime_GetFormattedTime(hour, minute, wantAMPM) 112 | if TimeManagerOptions and TimeManagerOptions.militaryTime == 1 then 113 | return format(TIMEMANAGER_TICKER_24HOUR, hour, minute) 114 | else 115 | if wantAMPM then 116 | local timeFormat = TIME_TWELVEHOURAM 117 | if hour == 0 then 118 | hour = 12 119 | elseif hour == 12 then 120 | timeFormat = TIME_TWELVEHOURPM 121 | elseif hour > 12 then 122 | timeFormat = TIME_TWELVEHOURPM 123 | hour = hour - 12 124 | end 125 | return format(timeFormat, hour, minute) 126 | else 127 | if hour == 0 then 128 | hour = 12 129 | elseif hour > 12 then 130 | hour = hour - 12 131 | end 132 | return format(TIMEMANAGER_TICKER_12HOUR, hour, minute) 133 | end 134 | end 135 | end 136 | 137 | function GameTime_GetLocalTime(wantAMPM) 138 | local hour, minute = tonumber(date("%H")), tonumber(date("%M")) 139 | return GameTime_GetFormattedTime(hour, minute, wantAMPM), hour, minute 140 | end 141 | 142 | function GameTime_GetGameTime(wantAMPM) 143 | local hour, minute = GetGameTime() 144 | return GameTime_GetFormattedTime(hour, minute, wantAMPM), hour, minute 145 | end 146 | 147 | function GameTime_GetTime(showAMPM) 148 | if TimeManagerOptions and TimeManagerOptions.localTime == 1 then 149 | return GameTime_GetLocalTime(showAMPM) 150 | else 151 | return GameTime_GetGameTime(showAMPM) 152 | end 153 | end 154 | 155 | function GameTime_UpdateTooltip() 156 | -- title 157 | GameTooltip:AddLine(TIMEMANAGER_TOOLTIP_TITLE, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b) 158 | -- realm time 159 | GameTooltip:AddDoubleLine( 160 | TIMEMANAGER_TOOLTIP_REALMTIME, 161 | GameTime_GetGameTime(true), 162 | NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 163 | HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b) 164 | -- local time 165 | GameTooltip:AddDoubleLine( 166 | TIMEMANAGER_TOOLTIP_LOCALTIME, 167 | GameTime_GetLocalTime(true), 168 | NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 169 | HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b) 170 | end 171 | 172 | function GameTimeFrame_Update() 173 | local hour, minute = GetGameTime() 174 | local time = (hour * 60) + minute 175 | if time ~= this.timeOfDay then 176 | this.timeOfDay = time 177 | local minx = 0 178 | local maxx = 50 / 128 179 | local miny = 0 180 | local maxy = 50 / 64 181 | if time < GAMETIME_DAWN or time >= GAMETIME_DUSK then 182 | minx = minx + 0.5 183 | maxx = maxx + 0.5 184 | end 185 | GameTimeTexture:SetTexCoord(minx, maxx, miny, maxy) 186 | end 187 | if GameTooltip:IsOwned(this) then 188 | GameTooltip:ClearLines() 189 | if not TimeManagerClockButton or not TimeManagerClockButton:IsVisible() or TimeManager_IsAlarmFiring() then 190 | GameTime_UpdateTooltip() 191 | GameTooltip:AddLine(" ") 192 | end 193 | GameTooltip:AddLine(GAMETIME_TOOLTIP_TOGGLE_CLOCK) 194 | GameTooltip:Show() 195 | end 196 | end 197 | 198 | function GameTimeFrame_OnClick() 199 | TimeManager_Toggle() 200 | end 201 | 202 | local function _TimeManager_Setting_SetBool(option, value) 203 | if value then 204 | TimeManagerOptions[option] = 1 205 | else 206 | TimeManagerOptions[option] = 0 207 | end 208 | Settings[option] = value 209 | end 210 | 211 | local function _TimeManager_Setting_Set(option, value) 212 | TimeManagerOptions[option] = value 213 | Settings[option] = value 214 | end 215 | 216 | local function _TimeManager_Setting_SetTime() 217 | local alarmTime = _TimeManager_ComputeMinutes(Settings.alarmHour, Settings.alarmMinute, Settings.militaryTime, Settings.alarmAM) 218 | TimeManagerOptions.alarmTime = alarmTime 219 | end 220 | 221 | -- TimeManagerFrame 222 | 223 | function TimeManager_Toggle() 224 | if TimeManagerFrame:IsShown() then 225 | TimeManagerFrame:Hide() 226 | else 227 | TimeManagerFrame:Show() 228 | end 229 | end 230 | 231 | function TimeManagerFrame_OnLoad() 232 | if not TimeManagerOptions then 233 | TimeManagerOptions = {} 234 | end 235 | 236 | Settings.militaryTime = TimeManagerOptions.militaryTime == 1 237 | Settings.localTime = TimeManagerOptions.localTime == 1 238 | local alarmTime = tonumber(TimeManagerOptions.alarmTime) 239 | if not alarmTime then alarmTime = 0 end 240 | Settings.alarmHour = floor(alarmTime / 60) 241 | Settings.alarmMinute = max(min(alarmTime - Settings.alarmHour * 60, 59), 0) 242 | Settings.alarmHour = max(min(Settings.alarmHour, 23), 0) 243 | if not Settings.militaryTime then 244 | if Settings.alarmHour == 0 then 245 | Settings.alarmHour = 12 246 | Settings.alarmAM = true 247 | elseif Settings.alarmHour < 12 then 248 | Settings.alarmAM = true 249 | elseif Settings.alarmHour == 12 then 250 | Settings.alarmAM = false 251 | else 252 | Settings.alarmHour = Settings.alarmHour - 12 253 | Settings.alarmAM = false 254 | end 255 | end 256 | Settings.alarmMessage = TimeManagerOptions.alarmMessage 257 | Settings.alarmEnabled = TimeManagerOptions.alarmEnabled == 1 258 | 259 | UIDropDownMenu_Initialize(TimeManagerAlarmHourDropDown, TimeManagerAlarmHourDropDown_Initialize) 260 | UIDropDownMenu_SetWidth(30, TimeManagerAlarmHourDropDown, 40) 261 | 262 | UIDropDownMenu_Initialize(TimeManagerAlarmMinuteDropDown, TimeManagerAlarmMinuteDropDown_Initialize) 263 | UIDropDownMenu_SetWidth(30, TimeManagerAlarmMinuteDropDown, 40) 264 | 265 | UIDropDownMenu_Initialize(TimeManagerAlarmAMPMDropDown, TimeManagerAlarmAMPMDropDown_Initialize) 266 | -- some languages have ridonculously long am/pm strings (i'm looking at you French) so we may have to 267 | -- readjust the ampm dropdown width plus do some reanchoring if the text is too wide 268 | local maxAMPMWidth 269 | TimeManagerAMPMDummyText:SetText(TIMEMANAGER_AM) 270 | maxAMPMWidth = TimeManagerAMPMDummyText:GetWidth() 271 | TimeManagerAMPMDummyText:SetText(TIMEMANAGER_PM) 272 | if maxAMPMWidth < TimeManagerAMPMDummyText:GetWidth() then 273 | maxAMPMWidth = TimeManagerAMPMDummyText:GetWidth() 274 | end 275 | maxAMPMWidth = ceil(maxAMPMWidth) 276 | if maxAMPMWidth > 40 then 277 | UIDropDownMenu_SetWidth(maxAMPMWidth + 20, TimeManagerAlarmAMPMDropDown, 40) 278 | TimeManagerAlarmAMPMDropDown:SetScript("OnShow", TimeManagerAlarmAMPMDropDown_OnShow) 279 | TimeManagerAlarmAMPMDropDown:SetScript("OnHide", TimeManagerAlarmAMPMDropDown_OnHide) 280 | else 281 | UIDropDownMenu_SetWidth(40, TimeManagerAlarmAMPMDropDown, 40) 282 | end 283 | 284 | TimeManager_Update() 285 | end 286 | 287 | function TimeManagerFrame_OnUpdate() 288 | TimeManager_UpdateTimeTicker() 289 | end 290 | 291 | function TimeManagerFrame_OnShow() 292 | TimeManager_Update() 293 | TimeManagerStopwatchCheck:SetChecked(StopwatchFrame:IsShown()) 294 | PlaySound("igCharacterInfoOpen") 295 | end 296 | 297 | function TimeManagerFrame_OnHide() 298 | PlaySound("igCharacterInfoClose") 299 | end 300 | 301 | function TimeManagerCloseButton_OnClick() 302 | TimeManagerFrame:Hide() 303 | end 304 | 305 | function TimeManagerStopwatchCheck_OnClick() 306 | Stopwatch_Toggle() 307 | if this:GetChecked() then 308 | PlaySound("igMainMenuOptionCheckBoxOn") 309 | else 310 | PlaySound("igMainMenuQuit") 311 | end 312 | end 313 | 314 | function TimeManagerAlarmHourDropDown_Initialize() 315 | local info = UIDropDownMenu_CreateInfo() 316 | 317 | local alarmHour = Settings.alarmHour 318 | local militaryTime = Settings.militaryTime 319 | 320 | local hourMin, hourMax 321 | if militaryTime then 322 | hourMin = 0 323 | hourMax = 23 324 | else 325 | hourMin = 1 326 | hourMax = 12 327 | end 328 | for hour = hourMin, hourMax, 1 do 329 | info.value = hour 330 | if militaryTime then 331 | info.text = format(TIMEMANAGER_24HOUR, hour) 332 | else 333 | info.text = hour 334 | info.justifyH = "RIGHT" 335 | end 336 | info.func = TimeManagerAlarmHourDropDown_OnClick 337 | if hour == alarmHour then 338 | info.checked = 1 339 | UIDropDownMenu_SetText(info.text, TimeManagerAlarmHourDropDown) 340 | else 341 | info.checked = nil 342 | end 343 | UIDropDownMenu_AddButton(info) 344 | end 345 | end 346 | 347 | function TimeManagerAlarmMinuteDropDown_Initialize() 348 | local info = UIDropDownMenu_CreateInfo() 349 | local alarmMinute = Settings.alarmMinute 350 | for minute = 0, 55, 5 do 351 | info.value = minute 352 | info.text = format(TIMEMANAGER_MINUTE, minute) 353 | info.func = TimeManagerAlarmMinuteDropDown_OnClick 354 | if minute == alarmMinute then 355 | info.checked = 1 356 | UIDropDownMenu_SetText(info.text, TimeManagerAlarmMinuteDropDown) 357 | else 358 | info.checked = nil 359 | end 360 | UIDropDownMenu_AddButton(info) 361 | end 362 | end 363 | 364 | function TimeManagerAlarmAMPMDropDown_Initialize() 365 | local info = UIDropDownMenu_CreateInfo() 366 | local pm = (Settings.militaryTime and Settings.alarmHour >= 12) or not Settings.alarmAM 367 | info.value = 1 368 | info.text = TIMEMANAGER_AM 369 | info.func = TimeManagerAlarmAMPMDropDown_OnClick 370 | if not pm then 371 | info.checked = 1 372 | UIDropDownMenu_SetText(info.text, TimeManagerAlarmAMPMDropDown) 373 | else 374 | info.checked = nil 375 | end 376 | UIDropDownMenu_AddButton(info) 377 | 378 | info.value = 0 379 | info.text = TIMEMANAGER_PM 380 | info.func = TimeManagerAlarmAMPMDropDown_OnClick 381 | if pm then 382 | info.checked = 1 383 | UIDropDownMenu_SetText(info.text, TimeManagerAlarmAMPMDropDown) 384 | else 385 | info.checked = nil 386 | end 387 | UIDropDownMenu_AddButton(info) 388 | end 389 | 390 | function TimeManagerAlarmHourDropDown_OnClick() 391 | UIDropDownMenu_SetSelectedValue(TimeManagerAlarmHourDropDown, this.value) 392 | local oldValue = Settings.alarmHour 393 | Settings.alarmHour = this.value 394 | if Settings.alarmHour ~= oldValue then 395 | TimeManager_StartCheckingAlarm() 396 | end 397 | _TimeManager_Setting_SetTime() 398 | end 399 | 400 | function TimeManagerAlarmMinuteDropDown_OnClick() 401 | UIDropDownMenu_SetSelectedValue(TimeManagerAlarmMinuteDropDown, this.value) 402 | local oldValue = Settings.alarmMinute 403 | Settings.alarmMinute = this.value 404 | if Settings.alarmMinute ~= oldValue then 405 | TimeManager_StartCheckingAlarm() 406 | end 407 | _TimeManager_Setting_SetTime() 408 | end 409 | 410 | function TimeManagerAlarmAMPMDropDown_OnClick() 411 | UIDropDownMenu_SetSelectedValue(TimeManagerAlarmAMPMDropDown, this.value) 412 | if this.value == 1 then 413 | if not Settings.alarmAM then 414 | Settings.alarmAM = true 415 | TimeManager_StartCheckingAlarm() 416 | end 417 | else 418 | if Settings.alarmAM then 419 | Settings.alarmAM = false 420 | TimeManager_StartCheckingAlarm() 421 | end 422 | end 423 | _TimeManager_Setting_SetTime() 424 | end 425 | 426 | function TimeManagerAlarmAMPMDropDown_OnShow() 427 | -- readjust the size of and reanchor TimeManagerAlarmAMPMDropDown and all frames below it 428 | TimeManagerAlarmAMPMDropDown:SetPoint("TOPLEFT", TimeManagerAlarmHourDropDown, "BOTTOMLEFT", 0, 5) 429 | TimeManagerAlarmMessageFrame:SetPoint("TOPLEFT", TimeManagerAlarmHourDropDown, "BOTTOMLEFT", 20, -23) 430 | TimeManagerAlarmEnabledButton:SetPoint("CENTER", TimeManagerFrame, "CENTER", -20, -69) 431 | TimeManagerMilitaryTimeCheck:SetPoint("TOPLEFT", TimeManagerFrame, "TOPLEFT", 174, -207) 432 | end 433 | 434 | function TimeManagerAlarmAMPMDropDown_OnHide() 435 | -- readjust the size of and reanchor TimeManagerAlarmAMPMDropDown and all frames below it 436 | TimeManagerAlarmAMPMDropDown:SetPoint("LEFT", TimeManagerAlarmHourDropDown, "RIGHT", -22, 0) 437 | TimeManagerAlarmMessageFrame:SetPoint("TOPLEFT", TimeManagerAlarmHourDropDown, "BOTTOMLEFT", 20, 0) 438 | TimeManagerAlarmEnabledButton:SetPoint("CENTER", TimeManagerFrame, "CENTER", -20, -50) 439 | TimeManagerMilitaryTimeCheck:SetPoint("TOPLEFT", TimeManagerFrame, "TOPLEFT", 174, -207) 440 | end 441 | 442 | function TimeManager_Update() 443 | TimeManager_UpdateTimeTicker() 444 | TimeManager_UpdateAlarmTime() 445 | TimeManagerAlarmEnabledButton_Update() 446 | if Settings.alarmMessage then 447 | TimeManagerAlarmMessageEditBox:SetText(Settings.alarmMessage) 448 | end 449 | TimeManagerMilitaryTimeCheck:SetChecked(Settings.militaryTime) 450 | TimeManagerLocalTimeCheck:SetChecked(Settings.localTime) 451 | end 452 | 453 | function TimeManager_UpdateAlarmTime() 454 | UIDropDownMenu_SetSelectedValue(TimeManagerAlarmHourDropDown, Settings.alarmHour) 455 | UIDropDownMenu_SetSelectedValue(TimeManagerAlarmMinuteDropDown, Settings.alarmMinute) 456 | UIDropDownMenu_SetText(format(TIMEMANAGER_MINUTE, Settings.alarmMinute), TimeManagerAlarmMinuteDropDown) 457 | if Settings.militaryTime then 458 | TimeManagerAlarmAMPMDropDown:Hide() 459 | UIDropDownMenu_SetText(format(TIMEMANAGER_24HOUR, Settings.alarmHour), TimeManagerAlarmHourDropDown) 460 | else 461 | TimeManagerAlarmAMPMDropDown:Show() 462 | UIDropDownMenu_SetText(Settings.alarmHour, TimeManagerAlarmHourDropDown) 463 | if Settings.alarmAM then 464 | UIDropDownMenu_SetSelectedValue(TimeManagerAlarmAMPMDropDown, 1) 465 | UIDropDownMenu_SetText(TIMEMANAGER_AM, TimeManagerAlarmAMPMDropDown) 466 | else 467 | UIDropDownMenu_SetSelectedValue(TimeManagerAlarmAMPMDropDown, 0) 468 | UIDropDownMenu_SetText(TIMEMANAGER_PM, TimeManagerAlarmAMPMDropDown) 469 | end 470 | end 471 | end 472 | 473 | function TimeManager_UpdateTimeTicker() 474 | TimeManagerFrameTicker:SetText(GameTime_GetTime(false)) 475 | end 476 | 477 | function TimeManagerAlarmMessageEditBox_OnEnterPressed() 478 | this:ClearFocus() 479 | end 480 | 481 | function TimeManagerAlarmMessageEditBox_OnEscapePressed() 482 | this:ClearFocus() 483 | end 484 | 485 | function TimeManagerAlarmMessageEditBox_OnEditFocusLost() 486 | _TimeManager_Setting_Set("alarmMessage", TimeManagerAlarmMessageEditBox:GetText()) 487 | end 488 | 489 | function TimeManagerAlarmEnabledButton_Update() 490 | if Settings.alarmEnabled then 491 | TimeManagerAlarmEnabledButton:SetText(TIMEMANAGER_ALARM_ENABLED) 492 | TimeManagerAlarmEnabledButton:SetTextFontObject("GameFontNormal") 493 | TimeManagerAlarmEnabledButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up") 494 | TimeManagerAlarmEnabledButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down") 495 | else 496 | TimeManagerAlarmEnabledButton:SetText(TIMEMANAGER_ALARM_DISABLED) 497 | TimeManagerAlarmEnabledButton:SetTextFontObject("GameFontHighlight") 498 | TimeManagerAlarmEnabledButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Disabled") 499 | TimeManagerAlarmEnabledButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Disabled-Down") 500 | end 501 | end 502 | 503 | function TimeManagerAlarmEnabledButton_OnClick() 504 | _TimeManager_Setting_SetBool("alarmEnabled", not Settings.alarmEnabled) 505 | if Settings.alarmEnabled then 506 | PlaySound("igMainMenuOptionCheckBoxOn") 507 | TimeManager_StartCheckingAlarm() 508 | else 509 | PlaySound("igMainMenuOptionCheckBoxOff") 510 | if TimeManagerClockButton.alarmFiring then 511 | TimeManager_TurnOffAlarm() 512 | end 513 | end 514 | TimeManagerAlarmEnabledButton_Update() 515 | end 516 | 517 | function TimeManagerMilitaryTimeCheck_OnClick() 518 | TimeManager_ToggleTimeFormat() 519 | if this:GetChecked() then 520 | PlaySound("igMainMenuOptionCheckBoxOn") 521 | else 522 | PlaySound("igMainMenuOptionCheckBoxOff") 523 | end 524 | end 525 | 526 | function TimeManager_ToggleTimeFormat() 527 | local alarmHour = Settings.alarmHour 528 | if Settings.militaryTime then 529 | _TimeManager_Setting_SetBool("militaryTime", false) 530 | Settings.alarmAM = alarmHour < 12 531 | if alarmHour > 12 then 532 | Settings.alarmHour = alarmHour - 12 533 | elseif alarmHour == 0 then 534 | Settings.alarmHour = 12 535 | end 536 | else 537 | _TimeManager_Setting_SetBool("militaryTime", true) 538 | if Settings.alarmAM and alarmHour == 12 then 539 | Settings.alarmHour = 0 540 | elseif not Settings.alarmAM and alarmHour < 12 then 541 | Settings.alarmHour = alarmHour + 12 542 | end 543 | end 544 | _TimeManager_Setting_SetTime() 545 | TimeManager_UpdateAlarmTime() 546 | -- TimeManagerFrame_OnUpdate will pick up the time ticker change 547 | -- TimeManagerClockButton_OnUpdate will pick up the clock change 548 | end 549 | 550 | function TimeManagerLocalTimeCheck_OnClick() 551 | TimeManager_ToggleLocalTime() 552 | -- since we're changing which time type we're checking, we need to check the alarm now 553 | TimeManager_StartCheckingAlarm() 554 | if this:GetChecked() then 555 | PlaySound("igMainMenuOptionCheckBoxOn") 556 | else 557 | PlaySound("igMainMenuOptionCheckBoxOff") 558 | end 559 | end 560 | 561 | function TimeManager_ToggleLocalTime() 562 | _TimeManager_Setting_SetBool("localTime", not Settings.localTime) 563 | -- TimeManagerFrame_OnUpdate will pick up the time ticker change 564 | -- TimeManagerClockButton_OnUpdate will pick up the clock change 565 | end 566 | 567 | -- TimeManagerClockButton 568 | 569 | function TimeManagerClockButton_Show() 570 | TimeManagerClockButton:Show() 571 | end 572 | 573 | function TimeManagerClockButton_Hide() 574 | TimeManagerClockButton:Hide() 575 | end 576 | 577 | function TimeManagerClockButton_OnLoad() 578 | this:RegisterEvent("ADDON_LOADED") 579 | this:SetFrameLevel(this:GetFrameLevel() + 2) 580 | TimeManagerClockButton_Show() 581 | end 582 | 583 | function TimeManagerClockButton_OnEvent() 584 | TimeManagerClockButton_Update() 585 | if Settings.alarmEnabled then 586 | TimeManager_StartCheckingAlarm() 587 | end 588 | end 589 | 590 | function TimeManagerClockButton_Update() 591 | TimeManagerClockTicker:SetText(GameTime_GetTime(false)) 592 | end 593 | 594 | function TimeManagerClockButton_OnEnter() 595 | GameTooltip:SetOwner(this, "ANCHOR_LEFT") 596 | TimeManagerClockButton:SetScript("OnUpdate", TimeManagerClockButton_OnUpdateWithTooltip) 597 | end 598 | 599 | function TimeManagerClockButton_OnLeave() 600 | GameTooltip:Hide() 601 | TimeManagerClockButton:SetScript("OnUpdate", TimeManagerClockButton_OnUpdate) 602 | end 603 | 604 | function TimeManagerClockButton_OnClick() 605 | if this.alarmFiring then 606 | PlaySound("igMainMenuQuit") 607 | TimeManager_TurnOffAlarm() 608 | elseif not GameTimeFrame:IsShown() then 609 | TimeManager_Toggle() 610 | end 611 | end 612 | 613 | function TimeManagerClockButton_OnUpdate() 614 | TimeManagerClockButton_Update() 615 | if TimeManagerClockButton.checkAlarm and Settings.alarmEnabled then 616 | TimeManager_CheckAlarm(arg1) 617 | end 618 | end 619 | 620 | function TimeManagerClockButton_OnUpdateWithTooltip() 621 | TimeManagerClockButton_OnUpdate(this, arg1) 622 | TimeManagerClockButton_UpdateTooltip() 623 | end 624 | 625 | function TimeManager_ShouldCheckAlarm() 626 | return TimeManagerClockButton.checkAlarm and Settings.alarmEnabled 627 | end 628 | 629 | function TimeManager_StartCheckingAlarm() 630 | TimeManagerClockButton.checkAlarm = true 631 | 632 | -- set the time to play the warning sound 633 | local alarmTime = _TimeManager_ComputeMinutes(Settings.alarmHour, Settings.alarmMinute, Settings.militaryTime, Settings.alarmAM) 634 | local warningTime = alarmTime + WARNING_SOUND_TRIGGER_OFFSET 635 | -- max minutes per day = 24*60 = 1440 636 | if warningTime < 0 then 637 | warningTime = warningTime + 1440 638 | elseif warningTime > 1440 then 639 | warningTime = warningTime - 1440 640 | end 641 | TimeManagerClockButton.warningTime = warningTime 642 | TimeManagerClockButton.checkAlarmWarning = true 643 | -- since game time isn't available in seconds, we have to keep track of the previous minute 644 | -- in order to play our alarm warning sound at the right time 645 | TimeManagerClockButton.currentMinute = _TimeManager_GetCurrentMinutes(Settings.localTime) 646 | TimeManagerClockButton.currentMinuteCounter = 0 647 | end 648 | 649 | function TimeManager_CheckAlarm() 650 | local currTime = _TimeManager_GetCurrentMinutes(Settings.localTime) 651 | local alarmTime = _TimeManager_ComputeMinutes(Settings.alarmHour, Settings.alarmMinute, Settings.militaryTime, Settings.alarmAM) 652 | 653 | -- check for the warning sound 654 | local clockButton = TimeManagerClockButton 655 | if clockButton.checkAlarmWarning then 656 | if clockButton.currentMinute ~= currTime then 657 | clockButton.currentMinute = currTime 658 | clockButton.currentMinuteCounter = 0 659 | end 660 | local secOffset = floor(clockButton.currentMinuteCounter) * SEC_TO_MINUTE_FACTOR 661 | if (currTime + secOffset) == clockButton.warningTime then 662 | TimeManager_FireAlarmWarning() 663 | end 664 | clockButton.currentMinuteCounter = clockButton.currentMinuteCounter + arg1 665 | end 666 | -- check for the alarm sound 667 | if currTime == alarmTime then 668 | TimeManager_FireAlarm() 669 | end 670 | end 671 | 672 | function TimeManager_FireAlarmWarning() 673 | TimeManagerClockButton.checkAlarmWarning = false 674 | PlaySoundFile("Interface\\AddOns\\TimeManager\\Sounds\\AlarmClockWarning1.wav") 675 | end 676 | 677 | function TimeManager_FireAlarm() 678 | TimeManagerClockButton.alarmFiring = true 679 | TimeManagerClockButton.checkAlarm = false 680 | 681 | -- do a bunch of crazy stuff to get the player's attention 682 | if Settings.alarmMessage and gsub(Settings.alarmMessage, "%s", "") ~= "" then 683 | local info = ChatTypeInfo["SYSTEM"] 684 | DEFAULT_CHAT_FRAME:AddMessage(Settings.alarmMessage, info.r, info.g, info.b, info.id) 685 | info = ChatTypeInfo["RAID_WARNING"] 686 | RaidWarningFrame:AddMessage(Settings.alarmMessage, info.r, info.g, info.b, info.id) 687 | end 688 | PlaySoundFile("Interface\\AddOns\\TimeManager\\Sounds\\AlarmClockWarning2.wav") 689 | UIFrameFlash(TimeManagerAlarmFiredTexture, 0.5, 0.5, -1) 690 | -- show the clock if necessary, but record its current state so it can return to that state after 691 | -- the player turns the alarm off 692 | TimeManagerClockButton.prevShown = TimeManagerClockButton:IsShown() 693 | TimeManagerClockButton:Show() 694 | end 695 | 696 | function TimeManager_TurnOffAlarm() 697 | UIFrameFlashStop(TimeManagerAlarmFiredTexture) 698 | if not TimeManagerClockButton.prevShown then 699 | TimeManagerClockButton:Hide() 700 | end 701 | 702 | TimeManagerClockButton.alarmFiring = false 703 | end 704 | 705 | function TimeManager_IsAlarmFiring() 706 | return TimeManagerClockButton.alarmFiring 707 | end 708 | 709 | function TimeManagerClockButton_UpdateTooltip() 710 | GameTooltip:ClearLines() 711 | 712 | if TimeManagerClockButton.alarmFiring then 713 | if Settings.alarmMessage and gsub(Settings.alarmMessage, "%s", "") ~= "" then 714 | GameTooltip:AddLine(Settings.alarmMessage, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b) 715 | GameTooltip:AddLine(" ") 716 | end 717 | GameTooltip:AddLine(TIMEMANAGER_ALARM_TOOLTIP_TURN_OFF) 718 | else 719 | GameTime_UpdateTooltip() 720 | if not GameTimeFrame:IsShown() then 721 | GameTooltip:AddLine(" ") 722 | GameTooltip:AddLine(GAMETIME_TOOLTIP_TOGGLE_CLOCK) 723 | end 724 | end 725 | 726 | -- readjust tooltip size 727 | GameTooltip:Show() 728 | end 729 | 730 | -- StopwatchFrame 731 | 732 | function Stopwatch_Toggle() 733 | if StopwatchFrame:IsShown() then 734 | StopwatchFrame:Hide() 735 | else 736 | StopwatchFrame:Show() 737 | end 738 | end 739 | 740 | function Stopwatch_StartCountdown(hour, minute, second) 741 | local sec = 0 742 | if hour then 743 | sec = hour * 3600 744 | end 745 | if minute then 746 | sec = sec + minute * 60 747 | end 748 | if second then 749 | sec = sec + second 750 | end 751 | if sec == 0 then 752 | Stopwatch_Toggle() 753 | return 754 | end 755 | if sec > MAX_TIMER_SEC then 756 | StopwatchTicker.timer = MAX_TIMER_SEC 757 | elseif sec < 0 then 758 | StopwatchTicker.timer = 0 759 | else 760 | StopwatchTicker.timer = sec 761 | end 762 | StopwatchTicker_Update() 763 | StopwatchTicker.reverse = sec > 0 764 | StopwatchFrame:Show() 765 | end 766 | 767 | function Stopwatch_ShowCountdown(hour, minute, second) 768 | local sec = 0 769 | if hour then 770 | sec = hour * 3600 771 | end 772 | if minute then 773 | sec = sec + minute * 60 774 | end 775 | if second then 776 | sec = sec + second 777 | end 778 | if sec == 0 then 779 | Stopwatch_Toggle() 780 | return 781 | end 782 | if sec > MAX_TIMER_SEC then 783 | StopwatchTicker.timer = MAX_TIMER_SEC 784 | elseif sec < 0 then 785 | StopwatchTicker.timer = 0 786 | else 787 | StopwatchTicker.timer = sec 788 | end 789 | StopwatchTicker_Update() 790 | StopwatchTicker.reverse = sec > 0 791 | StopwatchFrame:Show() 792 | end 793 | 794 | function Stopwatch_FinishCountdown() 795 | Stopwatch_Clear() 796 | PlaySoundFile("Interface\\AddOns\\TimeManager\\Sounds\\AlarmClockWarning3.wav") 797 | end 798 | 799 | function StopwatchCloseButton_OnClick() 800 | PlaySound("igMainMenuQuit") 801 | StopwatchFrame:Hide() 802 | end 803 | 804 | function StopwatchFrame_OnLoad() 805 | this:RegisterEvent("ADDON_LOADED") 806 | this:RegisterEvent("PLAYER_ENTERING_WORLD") 807 | this:RegisterEvent("PLAYER_LOGOUT") 808 | this:RegisterForDrag("LeftButton") 809 | StopwatchTabFrame:SetAlpha(0) 810 | Stopwatch_Clear() 811 | end 812 | 813 | function StopwatchFrame_OnEvent(event) 814 | if event == "ADDON_LOADED" then 815 | local name = arg1 816 | if name == "TimeManager" then 817 | if not StopwatchOptions then 818 | StopwatchOptions = {} 819 | end 820 | 821 | if StopwatchOptions.position then 822 | StopwatchFrame:ClearAllPoints() 823 | StopwatchFrame:SetPoint("CENTER", "UIParent", "BOTTOMLEFT", StopwatchOptions.position.x, StopwatchOptions.position.y) 824 | StopwatchFrame:SetUserPlaced(true) 825 | else 826 | StopwatchFrame:SetPoint("TOPRIGHT", "UIParent", "TOPRIGHT", -250, -300) 827 | end 828 | end 829 | if IsAddOnLoaded("modui") then 830 | SetCVar("modStopWatch", 0) 831 | 832 | GameTimeFrame:Hide() 833 | 834 | local a = TimeManagerClockButton:GetRegions() 835 | table.insert(MODUI_COLOURELEMENTS_FOR_UI, a) 836 | 837 | local _, a, b, c, d = TimeManagerFrame:GetRegions() 838 | for _, v in pairs({a, b, c, d}) do 839 | table.insert(MODUI_COLOURELEMENTS_FOR_UI, v) 840 | end 841 | 842 | local a, b = StopwatchFrame:GetRegions() 843 | for _, v in pairs({a, b}) do 844 | table.insert(MODUI_COLOURELEMENTS_FOR_UI, v) 845 | end 846 | 847 | local a, b, c = StopwatchTabFrame:GetRegions() 848 | for _, v in pairs({a, b, c}) do 849 | table.insert(MODUI_COLOURELEMENTS_FOR_UI, v) 850 | end 851 | end 852 | elseif event == "PLAYER_ENTERING_WORLD" then 853 | SlashCmdList["STOPWATCH"] = function(msg) 854 | local _, _, text = strfind(msg, "%s*([^%s]+)%s*") 855 | if text then 856 | text = strlower(text) 857 | 858 | -- in any of the following cases, the stopwatch will be shown 859 | StopwatchFrame:Show() 860 | 861 | -- try to match a command 862 | local function MatchCommand(param, text) 863 | local i, compare 864 | i = 1 865 | repeat 866 | compare = _G[param .. i] 867 | if compare and compare == text then 868 | return true 869 | end 870 | i = i + 1 871 | until not compare 872 | return false 873 | end 874 | if MatchCommand("SLASH_STOPWATCH_PARAM_PLAY", text) then 875 | Stopwatch_Play() 876 | return 877 | end 878 | if MatchCommand("SLASH_STOPWATCH_PARAM_PAUSE", text) then 879 | Stopwatch_Pause() 880 | return 881 | end 882 | if MatchCommand("SLASH_STOPWATCH_PARAM_STOP", text) then 883 | Stopwatch_Clear() 884 | return 885 | end 886 | -- try to match a countdown 887 | -- kinda ghetto, but hey, it's simple and it works =) 888 | local _, _, hour, minute, second = strfind(msg, "(%d+):(%d+):(%d+)") 889 | if not hour then 890 | _, _, minute, second = strfind(msg, "(%d+):(%d+)") 891 | if not minute then 892 | _, _, second = strfind(msg, "(%d+)") 893 | end 894 | end 895 | Stopwatch_StartCountdown(tonumber(hour), tonumber(minute), tonumber(second)) 896 | else 897 | Stopwatch_Toggle() 898 | end 899 | end 900 | elseif event == "PLAYER_LOGOUT" then 901 | if StopwatchFrame:IsUserPlaced() then 902 | if not StopwatchOptions.position then 903 | StopwatchOptions.position = {} 904 | end 905 | StopwatchOptions.position.x, StopwatchOptions.position.y = StopwatchFrame:GetCenter() 906 | StopwatchFrame:SetUserPlaced(false) 907 | else 908 | StopwatchOptions.position = nil 909 | end 910 | end 911 | end 912 | 913 | function StopwatchFrame_OnUpdate() 914 | if this.prevMouseIsOver then 915 | if not MouseIsOver(this, 20, -8, -8, 20) then 916 | UIFrameFadeOut(StopwatchTabFrame, CHAT_FRAME_FADE_TIME) 917 | this.prevMouseIsOver = false 918 | end 919 | else 920 | if MouseIsOver(this, 20, -8, -8, 20) then 921 | UIFrameFadeIn(StopwatchTabFrame, CHAT_FRAME_FADE_TIME) 922 | this.prevMouseIsOver = true 923 | end 924 | end 925 | end 926 | 927 | function StopwatchFrame_OnShow() 928 | TimeManagerStopwatchCheck:SetChecked(1) 929 | end 930 | 931 | function StopwatchFrame_OnHide() 932 | UIFrameFadeRemoveFrame(StopwatchTabFrame) 933 | StopwatchTabFrame:SetAlpha(0) 934 | this.prevMouseIsOver = false 935 | TimeManagerStopwatchCheck:SetChecked(nil) 936 | end 937 | 938 | function StopwatchFrame_OnMouseDown() 939 | this:SetScript("OnUpdate", nil) 940 | end 941 | 942 | function StopwatchFrame_OnMouseUp() 943 | this:SetScript("OnUpdate", StopwatchFrame_OnUpdate) 944 | end 945 | 946 | 947 | function StopwatchFrame_OnDragStart() 948 | this:StartMoving() 949 | end 950 | 951 | function StopwatchFrame_OnDragStop() 952 | StopwatchFrame_OnMouseUp() -- OnMouseUp won't fire if OnDragStart fired after OnMouseDown 953 | this:StopMovingOrSizing() 954 | end 955 | 956 | function StopwatchTicker_OnUpdate() 957 | if StopwatchTicker.reverse then 958 | StopwatchTicker.timer = StopwatchTicker.timer - arg1 959 | if StopwatchTicker.timer <= 0 then 960 | Stopwatch_FinishCountdown() 961 | return 962 | end 963 | elseif StopwatchTicker.timer then 964 | StopwatchTicker.timer = StopwatchTicker.timer + arg1 965 | else 966 | StopwatchTicker.timer = 0 967 | end 968 | StopwatchTicker_Update() 969 | end 970 | 971 | function StopwatchTicker_Update() 972 | local timer = StopwatchTicker.timer 973 | local hour = min(floor(timer * SEC_TO_HOUR_FACTOR), 99) 974 | local minute = mod(timer * SEC_TO_MINUTE_FACTOR, 60) 975 | local second = mod(timer, 60) 976 | StopwatchTickerHour:SetText(format(STOPWATCH_TIME_UNIT, hour)) 977 | StopwatchTickerMinute:SetText(format(STOPWATCH_TIME_UNIT, minute)) 978 | StopwatchTickerSecond:SetText(format(STOPWATCH_TIME_UNIT, second)) 979 | end 980 | 981 | function Stopwatch_Play() 982 | StopwatchPlayPauseButton.playing = true 983 | StopwatchTicker:SetScript("OnUpdate", StopwatchTicker_OnUpdate) 984 | StopwatchPlayPauseButton:SetNormalTexture("Interface\\AddOns\\TimeManager\\Textures\\PauseButton") 985 | end 986 | 987 | 988 | function Stopwatch_Pause() 989 | StopwatchPlayPauseButton.playing = false 990 | StopwatchTicker:SetScript("OnUpdate", nil) 991 | StopwatchPlayPauseButton:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up") 992 | end 993 | 994 | function Stopwatch_IsPlaying() 995 | return StopwatchPlayPauseButton.playing 996 | end 997 | 998 | function Stopwatch_Clear() 999 | StopwatchTicker.timer = 0 1000 | StopwatchTicker.reverse = false 1001 | StopwatchTicker:SetScript("OnUpdate", nil) 1002 | StopwatchTicker_Update() 1003 | StopwatchPlayPauseButton.playing = false 1004 | StopwatchPlayPauseButton:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up") 1005 | end 1006 | 1007 | function StopwatchResetButton_OnClick() 1008 | Stopwatch_Clear() 1009 | PlaySound("igMainMenuOptionCheckBoxOff") 1010 | end 1011 | 1012 | function StopwatchPlayPauseButton_OnClick() 1013 | if this.playing then 1014 | Stopwatch_Pause() 1015 | PlaySound("igMainMenuOptionCheckBoxOff") 1016 | else 1017 | Stopwatch_Play() 1018 | PlaySound("igMainMenuOptionCheckBoxOn") 1019 | end 1020 | end -------------------------------------------------------------------------------- /TimeManager.toc: -------------------------------------------------------------------------------- 1 | ## Interface: 11200 2 | ## Title: TimeManager 3 | ## Notes: Time Management features from patch 2.4.3+. These features include an alarm clock, stopwatch, and viewing your computer's local time. 4 | ## SavedVariablesPerCharacter: TimeManagerOptions, StopwatchOptions 5 | Locales\Locales.xml 6 | TimeManager.xml -------------------------------------------------------------------------------- /TimeManager.xml: -------------------------------------------------------------------------------- 1 | 2 |