void Load() { data = Interface.GetMod().DataFileSystem.ReadObject <StoredData>(Title); tiList = new List <TimedInfo>(); currentTI = null; sky = TOD_Sky.Instance; CheckConfig(); double left = (double)Config["Position", "Left"]; double right = (double)Config["Position", "Left"] + (double)Config["Size", "Width"]; double bottom = (double)Config["Position", "Bottom"]; double top = (double)Config["Position", "Bottom"] + (double)Config["Size", "Height"]; clockJson = clockJson.Replace("%background%", (string)Config["BackgroundColor"]) .Replace("%color%", (string)Config["TextColor"]) .Replace("%size%", Config["FontSize"].ToString()) .Replace("%left%", left.ToString()) .Replace("%right%", right.ToString()) .Replace("%bottom%", bottom.ToString()) .Replace("%top%", top.ToString()) .Replace("%prefix%", (string)Config["Prefix"]) .Replace("%postfix%", (string)Config["Postfix"]); // --- for timed notifications List <object> ti = (List <object>)Config["TimedInfo"]; int size = ti.Count; for (int i = 0; i < size; i++) { string infoString = (string)ti[i]; if (infoString.Length > 0) { tiList.Add(GetTimedInfo(infoString)); } } double info_left = right + 0.002; infoJson = infoJson.Replace("%background%", (string)Config["BackgroundColor"]) .Replace("%color%", (string)Config["TextColor"]) .Replace("%size%", Config["FontSize"].ToString()) .Replace("%bottom%", bottom.ToString()) .Replace("%top%", top.ToString()) .Replace("%info_left%", info_left.ToString()) .Replace("%info_right%", defaultInfoSize); // --- UpdateTime(); updateTimer = timer.Repeat((int)Config["UpdateTimeInSeconds"], 0, () => UpdateTime()); }
void UpdateInfo() { if (tiList.Count > 0) { DateTime g = DateTime.Parse(gameTime.ToString("HH:mm")); DateTime s = DateTime.Parse(serverTime.ToString("HH:mm")); if (currentTI == null) { for (int i = 0; i < tiList.Count; i++) { if (!tiList[i].serverTime) { if (g.Ticks > tiList[i].startTime && g.Ticks < tiList[i].endTime) { currentTI = tiList[i]; ShowInfo(tiList[i].text, tiList[i].size); } } else { if (s.Ticks > tiList[i].startTime && s.Ticks < tiList[i].endTime) { currentTI = tiList[i]; ShowInfo(tiList[i].text, tiList[i].size); } } } } else { if (!currentTI.serverTime) { if (g.Ticks > currentTI.endTime) { currentTI = null; DestroyInfo(); } } else { if (s.Ticks > currentTI.endTime) { currentTI = null; DestroyInfo(); } } } } }