Skip to content

Commit

Permalink
Merge pull request #390 from wbonbon/master
Browse files Browse the repository at this point in the history
bugfix and improvement
  • Loading branch information
wbonbon committed Feb 13, 2024
2 parents 2b32543 + 3ed4fc4 commit cd483a0
Show file tree
Hide file tree
Showing 67 changed files with 599 additions and 307 deletions.
6 changes: 3 additions & 3 deletions source/ACT.Hojoring.Common/SplashWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public string Message
{
if (this.SetProperty(ref this.message, value))
{
this.FadeOutStartTime = DateTime.Now.Add(SplashDuration);
this.FadeOutStartTime = DateTime.UtcNow.Add(SplashDuration);
}
}
}
Expand Down Expand Up @@ -183,11 +183,11 @@ public SplashWindow()

public async void StartFadeOut()
{
this.FadeOutStartTime = DateTime.Now.Add(SplashDuration);
this.FadeOutStartTime = DateTime.UtcNow.Add(SplashDuration);

await Task.Run(async () =>
{
while (DateTime.Now <= this.FadeOutStartTime || this.IsSustainFadeOut)
while (DateTime.UtcNow <= this.FadeOutStartTime || this.IsSustainFadeOut)
{
await Task.Delay(200);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void Clear()
{
lock (this.ScriptingBlocker)
{
var now = DateTime.Now;
var now = DateTime.UtcNow;

var scripts = this.Scripts.Where(x =>
{
Expand Down Expand Up @@ -264,7 +264,7 @@ public void Clear()
{
lock (this.ScriptingBlocker)
{
var now = DateTime.Now;
//var now = DateTime.UtcNow;

#if DEBUG
if (currentSubRoutine == "応用フェーズ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private static System.Timers.Timer CreateSyncSpeakTimer()
var interval = Settings.Default.WaitingTimeToSyncTTS / 4d;

SyncList.Add(new SyncTTS(SyncList.Count, priority, tts, config));
SyncListTimestamp = DateTime.Now;
SyncListTimestamp = DateTime.UtcNow;
SyncListCount = SyncList.Count;

SyncSpeakTimer.Interval = interval;
Expand All @@ -271,7 +271,7 @@ private static System.Timers.Timer CreateSyncSpeakTimer()
var syncs = default(IEnumerable<SyncTTS>);
lock (SyncList)
{
if ((DateTime.Now - SyncListTimestamp).TotalMilliseconds < Settings.Default.WaitingTimeToSyncTTS)
if ((DateTime.UtcNow - SyncListTimestamp).TotalMilliseconds < Settings.Default.WaitingTimeToSyncTTS)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using System.Xml;
using System.Xml.Serialization;
Expand Down Expand Up @@ -105,7 +106,7 @@ public bool OverlayVisible
}
else
{
button.BackColor = SystemColors.Control;
button.BackColor = System.Drawing.SystemColors.Control;
button.ForeColor = Color.Black;
}
}
Expand Down Expand Up @@ -723,9 +724,9 @@ public string LastUpdateDateTimeCrypted
DateTime d;
if (DateTime.TryParse(value, out d))
{
if (d > DateTime.Now)
if (d > DateTime.UtcNow)
{
d = DateTime.Now;
d = DateTime.UtcNow;
}

this.lastUpdateDateTime = d;
Expand All @@ -737,9 +738,9 @@ public string LastUpdateDateTimeCrypted
var decrypt = Crypter.DecryptString(value);
if (DateTime.TryParse(decrypt, out d))
{
if (d > DateTime.Now)
if (d > DateTime.UtcNow)
{
d = DateTime.Now;
d = DateTime.UtcNow;
}

this.lastUpdateDateTime = d;
Expand Down Expand Up @@ -783,16 +784,43 @@ public void Load()
return;
}

using (var sr = new StreamReader(this.FileName, new UTF8Encoding(false)))
try
{
if (sr.BaseStream.Length > 0)
using (var sr = new StreamReader(this.FileName, new UTF8Encoding(false)))
{
if (sr.BaseStream.Length > 0)
{
var xs = new XmlSerializer(this.GetType());
var data = xs.Deserialize(sr) as Settings;
if (data != null)
{
instance = data;
instance.isLoaded = true;
}
}
}
}
catch (Exception ex)
{
var info = ex.GetType().ToString() + Environment.NewLine + Environment.NewLine;
info += ex.Message + Environment.NewLine;
info += ex.StackTrace.ToString();

if (ex.InnerException != null)
{
info += Environment.NewLine + Environment.NewLine;
info += "Inner Exception :" + Environment.NewLine;
info += ex.InnerException.GetType().ToString() + Environment.NewLine + Environment.NewLine;
info += ex.InnerException.Message + Environment.NewLine;
info += ex.InnerException.StackTrace.ToString();
}

var result = MessageBox.Show("faild config load\n\n" + FileName + "\n" + info + "\n\ntry to load backup?", "error!", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
var xs = new XmlSerializer(this.GetType());
var data = xs.Deserialize(sr) as Settings;
if (data != null)
if (EnvironmentHelper.RestoreFile(FileName))
{
instance = data;
instance.isLoaded = true;
Load();
}
}
}
Expand Down Expand Up @@ -835,7 +863,7 @@ public void StartAutoSave()
{
this.PropertyChanged += async (_, __) =>
{
var now = DateTime.Now;
var now = DateTime.UtcNow;
if ((now - this.lastAutoSaveTimestamp).TotalSeconds > 20)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1183,12 +1183,12 @@ public string TimeupSoundToFile

public void StartMatching()
{
this.matchingStartDateTime = DateTime.Now;
this.matchingStartDateTime = DateTime.UtcNow;
}

public void EndMatching()
{
var ticks = (DateTime.Now - this.matchingStartDateTime).Ticks;
var ticks = (DateTime.UtcNow - this.matchingStartDateTime).Ticks;
if (ticks == 0)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Xml.Serialization;
using ACT.SpecialSpellTimer.Config;
using FFXIV.Framework.Common;

namespace ACT.SpecialSpellTimer.Models
{
Expand Down Expand Up @@ -112,6 +114,29 @@ public void Load()
}
}
}
} catch (Exception ex)
{
var info = ex.GetType().ToString() + Environment.NewLine + Environment.NewLine;
info += ex.Message + Environment.NewLine;
info += ex.StackTrace.ToString();

if (ex.InnerException != null)
{
info += Environment.NewLine + Environment.NewLine;
info += "Inner Exception :" + Environment.NewLine;
info += ex.InnerException.GetType().ToString() + Environment.NewLine + Environment.NewLine;
info += ex.InnerException.Message + Environment.NewLine;
info += ex.InnerException.StackTrace.ToString();
}

var result = MessageBox.Show("faild config load\n\n" + DefaultFile + "\n" + info + "\n\ntry to load backup?", "error!", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
if (EnvironmentHelper.RestoreFile(DefaultFile))
{
Load();
}
}
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Xml.Serialization;
using FFXIV.Framework.Common;
using FFXIV.Framework.Extensions;

namespace ACT.SpecialSpellTimer.Models
Expand Down Expand Up @@ -204,6 +206,29 @@ public void Load()
}
}
}
} catch (Exception ex)
{
var info = ex.GetType().ToString() + Environment.NewLine + Environment.NewLine;
info += ex.Message + Environment.NewLine;
info += ex.StackTrace.ToString();

if (ex.InnerException != null)
{
info += Environment.NewLine + Environment.NewLine;
info += "Inner Exception :" + Environment.NewLine;
info += ex.InnerException.GetType().ToString() + Environment.NewLine + Environment.NewLine;
info += ex.InnerException.Message + Environment.NewLine;
info += ex.InnerException.StackTrace.ToString();
}

var result = MessageBox.Show("faild config load\n\n" + DefaultFile + "\n" + info + "\n\ntry to load backup?", "error!", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
if (EnvironmentHelper.RestoreFile(DefaultFile))
{
Load();
}
}
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void End()

public event EventHandler CompileConditionChanged;

private DateTime lastDumpPositionTimestamp = DateTime.Now.AddMinutes(5);
private DateTime lastDumpPositionTimestamp = DateTime.UtcNow.AddMinutes(5);

private bool isQueueRecompile = false;
private bool isQueueZoneChange = false;
Expand Down Expand Up @@ -128,7 +128,7 @@ void enqueueRecompile()
SharlayanHelper.Instance.EnqueueReload();

this.isQueueRecompile = true;
this.lastQueueTimestamp = DateTime.Now;
this.lastQueueTimestamp = DateTime.UtcNow;
}
}

Expand All @@ -138,7 +138,7 @@ void enqueueByZoneChanged()
{
this.isQueueRecompile = true;
this.isQueueZoneChange = true;
this.lastQueueTimestamp = DateTime.Now;
this.lastQueueTimestamp = DateTime.UtcNow;
}
}
}
Expand All @@ -147,7 +147,7 @@ private void TryCompile()
{
lock (this)
{
if ((DateTime.Now - this.lastQueueTimestamp).TotalMilliseconds <= CompileHandlerInterval)
if ((DateTime.UtcNow - this.lastQueueTimestamp).TotalMilliseconds <= CompileHandlerInterval)
{
return;
}
Expand Down Expand Up @@ -228,9 +228,9 @@ private void TryWork()
LogBuffer.DumpMyPetDistance();

// 定期的に自分の座標をダンプする
if ((DateTime.Now - this.lastDumpPositionTimestamp).TotalSeconds >= 60.0)
if ((DateTime.UtcNow - this.lastDumpPositionTimestamp).TotalSeconds >= 60.0)
{
this.lastDumpPositionTimestamp = DateTime.Now;
this.lastDumpPositionTimestamp = DateTime.UtcNow;
LogBuffer.DumpPosition(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Xml.Serialization;
using FFXIV.Framework.Common;
using Prism.Mvvm;
Expand Down Expand Up @@ -110,6 +111,29 @@ public void Load()
this.Tags.AddRange(data.Tags);
}
}
} catch (Exception ex)
{
var info = ex.GetType().ToString() + Environment.NewLine + Environment.NewLine;
info += ex.Message + Environment.NewLine;
info += ex.StackTrace.ToString();

if (ex.InnerException != null)
{
info += Environment.NewLine + Environment.NewLine;
info += "Inner Exception :" + Environment.NewLine;
info += ex.InnerException.GetType().ToString() + Environment.NewLine + Environment.NewLine;
info += ex.InnerException.Message + Environment.NewLine;
info += ex.InnerException.StackTrace.ToString();
}

var result = MessageBox.Show("faild config load\n\n" + DefaultFile + "\n" + info + "\n\ntry to load backup?", "error!", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
if (EnvironmentHelper.RestoreFile(DefaultFile))
{
Load();
}
}
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,12 +522,12 @@ public string MatchSoundToFile

public void StartMatching()
{
this.matchingStartDateTime = DateTime.Now;
this.matchingStartDateTime = DateTime.UtcNow;
}

public void EndMatching()
{
var ticks = (DateTime.Now - this.matchingStartDateTime).Ticks;
var ticks = (DateTime.UtcNow - this.matchingStartDateTime).Ticks;
if (ticks == 0)
{
return;
Expand Down Expand Up @@ -582,7 +582,7 @@ public void StartDelayedSoundTimer()
}

var timeToPlay = this.MatchDateTime.AddSeconds(this.Delay);
var duration = (timeToPlay - DateTime.Now).TotalMilliseconds;
var duration = (timeToPlay - DateTime.UtcNow).TotalMilliseconds;

if (duration > 0d)
{
Expand Down Expand Up @@ -686,7 +686,7 @@ public Ticker CreateSimilarNew()

public void SimulateMatch()
{
var now = DateTime.Now;
var now = DateTime.UtcNow;

// 擬似的にマッチ状態にする
this.IsTest = true;
Expand Down
Loading

0 comments on commit cd483a0

Please sign in to comment.