Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
AonaSuzutsuki committed Feb 20, 2023
2 parents ce7a73d + 1c60da3 commit 51cc6f2
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 46 deletions.
2 changes: 1 addition & 1 deletion ConfigEditor/ConfigEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommonStyleLib" Version="1.0.20" />
<PackageReference Include="CommonStyleLib" Version="1.0.23" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ConfigFileMaker/ConfigFileMaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommonCoreLib" Version="1.0.4" />
<PackageReference Include="CommonCoreLib" Version="1.0.6" />
<PackageReference Include="SavannahXmlLib" Version="1.0.5" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions SavannahManager/Models/AutoRestart/AbstractAutoRestart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ protected virtual async Task InnerStart()
{
if (!Model.IsSsh)
{
if (!await Model.Model.ServerStart())
if (!await Model.Model.ServerStart(true))
{
IsRequestStop = true;
return;
}
}
else
{
if (!await Model.Model.ServerStartWithSsh())
if (!await Model.Model.ServerStartWithSsh(true))
{
IsRequestStop = true;
return;
Expand Down
4 changes: 2 additions & 2 deletions SavannahManager/Models/Interfaces/IMainWindowServerStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public interface IMainWindowServerStart
public SettingLoader Setting { get; }
public int CurrentProcessId { get; }

Task<bool> ServerStart();
Task<bool> ServerStartWithSsh();
Task<bool> ServerStart(bool isAsync = false);
Task<bool> ServerStartWithSsh(bool isAsync = false);
bool ServerStop();
}
}
6 changes: 6 additions & 0 deletions SavannahManager/Models/Interfaces/ISettingMainWindowModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace _7dtd_svmanager_fix_mvvm.Models.Interfaces;

public interface ISettingMainWindowModel
{
bool AutoRestartEnabled { get; }
}
6 changes: 5 additions & 1 deletion SavannahManager/Models/Settings/SettingModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using _7dtd_svmanager_fix_mvvm.Models.Interfaces;
using CommonStyleLib.File;
using CommonStyleLib.Models;
using Reactive.Bindings;
Expand Down Expand Up @@ -210,11 +211,14 @@ public string RestoreDirPath

public ShortcutKeyManager ShortcutKeyManager { get; }

public ISettingMainWindowModel MainWindowModel { get; }

public SettingModel(SettingLoader setting, ShortcutKeyManager shortcutKeyManager)

public SettingModel(SettingLoader setting, ShortcutKeyManager shortcutKeyManager, ISettingMainWindowModel mainWindowModel)
{
_setting = setting;
ShortcutKeyManager = shortcutKeyManager;
MainWindowModel = mainWindowModel;

if (setting != null)
{
Expand Down
4 changes: 2 additions & 2 deletions SavannahManager/Models/Update/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task Initialize()
IsUpdate = latestVersion != CurrentVersion;
IsUpdUpdate = updVersion != latestUpdVersion;

var details = await _updateClient.DownloadFile(_updateClient.DetailVersionInfoDownloadUrlPath);
var details = await _updateClient.DownloadFileAsync(_updateClient.DetailVersionInfoDownloadUrlPath);

using var stream = new MemoryStream(details);
var reader = new SavannahXmlReader(stream);
Expand All @@ -68,7 +68,7 @@ public IEnumerable<string> GetVersions()
AbstractSavannahXmlNode notice;
try
{
var noticeXml = await _updateClient.DownloadFile("details/" + LangResources.UpdResources.Notice_XmlName);
var noticeXml = await _updateClient.DownloadFileAsync("details/" + LangResources.UpdResources.Notice_XmlName);
using var ms = new MemoryStream(noticeXml);
var reader = new SavannahXmlReader(ms);
notice = reader.GetNode($"/notices/notice[@version='{CurrentVersion}']");
Expand Down
43 changes: 23 additions & 20 deletions SavannahManager/Models/WindowModel/MainWindowModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

namespace _7dtd_svmanager_fix_mvvm.Models.WindowModel
{
public class MainWindowModel : ModelBase, IMainWindowTelnet, IMainWindowServerStart, IRelease
public class MainWindowModel : ModelBase, IMainWindowTelnet, IMainWindowServerStart, IRelease, ISettingMainWindowModel
{
#region AppendedLogTextEvent
public class AppendedLogTextEventArgs
Expand Down Expand Up @@ -476,14 +476,14 @@ public async Task<bool> ServerStartForButton()
return await ServerStart();
}

public async Task<bool> ServerStart()
public async Task<bool> ServerStart(bool isAsync = false)
{
if (!FileExistCheck()) return false;
if (!FileExistCheck(isAsync)) return false;

var checkedValues = ConfigChecker.GetConfigInfo(ConfigFilePath);
if (checkedValues.IsFailed)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = checkedValues.Message });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = checkedValues.Message, IsAsync = isAsync });
return false;
}

Expand All @@ -493,12 +493,12 @@ public async Task<bool> ServerStart()

if (IsConnected)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = Resources.AlreadyConnected });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = Resources.AlreadyConnected, IsAsync = isAsync });
return false;
}

using var serverProcessManager = new ServerProcessManager(ExeFilePath, ConfigFilePath);
void ProcessFailedAction(string message) => ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = message });
void ProcessFailedAction(string message) => ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = message, IsAsync = isAsync });
if (!serverProcessManager.ProcessStart(ProcessFailedAction))
return false;

Expand All @@ -515,11 +515,11 @@ public async Task<bool> ServerStart()
return true;
}

public async Task<bool> ServerStartWithSsh()
public async Task<bool> ServerStartWithSsh(bool isAsync = false)
{
if (IsConnected)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = Resources.AlreadyConnected });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = Resources.AlreadyConnected, IsAsync = isAsync });
return false;
}

Expand All @@ -544,21 +544,23 @@ public async Task<bool> ServerStartWithSsh()
}
catch (SshAuthenticationException)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = "failed to authenticate on ssh." });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = "failed to authenticate on ssh.", IsAsync = isAsync });

StartBtEnabled = true;
TelnetBtIsEnabled = true;
LocalModeEnabled = true;
BottomNewsLabel = Resources.UI_ReadyComplete;
return false;
}
catch (SshOperationTimeoutException)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = "failed to connect ssh." });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = "failed to connect ssh.", IsAsync = isAsync });

StartBtEnabled = true;
TelnetBtIsEnabled = true;
LocalModeEnabled = true;
BottomNewsLabel = Resources.UI_ReadyComplete;
return false;
}

await ConnectTelnetForServerStart(Address, _port, Password);
Expand Down Expand Up @@ -741,7 +743,8 @@ private void InnerStartAutoRestart()
}, () => BottomNewsLabel = newsLabel);
_autoRestart.FewRemaining.Subscribe(ts =>
{
SocTelnetSend($"say \"{string.Format(Setting.AutoRestartSendingMessageFormat, ts.Seconds)}\"");
var sec = Math.Round(ts.TotalSeconds);
SocTelnetSend($"say \"{string.Format(Setting.AutoRestartSendingMessageFormat, sec)}\"");
});
_autoRestart.ScriptRunning.Subscribe(args =>
{
Expand Down Expand Up @@ -776,20 +779,20 @@ public void StopAutoRestart(bool forceStop)
AutoRestartEnabled = false;
}

private bool FileExistCheck()
private bool FileExistCheck(bool isAsync = false)
{
try
{
var fi = new FileInfo(ExeFilePath);
if (!fi.Exists)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = string.Format(Resources.Not_Found_0, "7DaysToDieServer.exe") });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = string.Format(Resources.Not_Found_0, "7DaysToDieServer.exe"), IsAsync = isAsync });
return false;
}
}
catch (ArgumentException)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = string.Format(Resources._0_Is_Invalid, Resources.ServerFilePath) });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = string.Format(Resources._0_Is_Invalid, Resources.ServerFilePath), IsAsync = isAsync });
return false;
}

Expand All @@ -798,13 +801,13 @@ private bool FileExistCheck()
var fi = new FileInfo(ConfigFilePath);
if (!fi.Exists)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = string.Format(Resources.Not_Found_0, Resources.ConfigFilePath) });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = string.Format(Resources.Not_Found_0, Resources.ConfigFilePath), IsAsync = isAsync });
return false;
}
}
catch (ArgumentException)
{
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = string.Format(Resources._0_Is_Invalid, "7DaysToDieServer.exe") });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = string.Format(Resources._0_Is_Invalid, "7DaysToDieServer.exe"), IsAsync = isAsync });
return false;
}
return true;
Expand Down Expand Up @@ -1122,12 +1125,12 @@ public string GetNextCommand()
return _commandCollector.GetNextCommand();
}

public bool CheckConnected()
public bool CheckConnected(bool isAsync = false)
{
if (IsConnected)
return true;

ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = Resources.HasnotBeConnected });
ErrorOccurredSubject.OnNext(new ModelErrorEventArgs { ErrorMessage = Resources.HasnotBeConnected, IsAsync = isAsync });
return false;
}
private void SocTelnetSendDirect(string cmd)
Expand All @@ -1138,9 +1141,9 @@ private void SocTelnetSendDirect(string cmd)
telnet.Write(TelnetClient.Crlf);
});
}
private string SocTelnetSend(string cmd)
private string SocTelnetSend(string cmd, bool isAsync = false)
{
if (!CheckConnected())
if (!CheckConnected(isAsync))
return null;

SocTelnetSendDirect(cmd);
Expand Down
12 changes: 6 additions & 6 deletions SavannahManager/SavannahManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<Authors>Aona Suzutsuki</Authors>
<Company>Kimama Lab.</Company>
<Copyright>Copyright (C) Aona Suzutsuki 2014 - 2023</Copyright>
<AssemblyVersion>2.6.55.3</AssemblyVersion>
<FileVersion>2.6.55.3</FileVersion>
<Version>2.6.55.3</Version>
<AssemblyVersion>2.6.56.4</AssemblyVersion>
<FileVersion>2.6.56.4</FileVersion>
<Version>2.6.56.4</Version>
<ApplicationIcon>Images\1.ico</ApplicationIcon>
</PropertyGroup>

Expand All @@ -32,14 +32,14 @@

<ItemGroup>
<PackageReference Include="BackupLib" Version="1.0.6" />
<PackageReference Include="CommonCoreLib" Version="1.0.4" />
<PackageReference Include="CommonCoreLib" Version="1.0.6" />
<PackageReference Include="CommonExtensionLib" Version="1.0.5" />
<PackageReference Include="CommonNavigationControlLib" Version="1.0.5" />
<PackageReference Include="CommonStyleLib" Version="1.0.20" />
<PackageReference Include="CommonStyleLib" Version="1.0.23" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="SavannahXmlLib" Version="1.0.5" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="UpdateLib" Version="1.0.0" />
<PackageReference Include="UpdateLib" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 13 additions & 3 deletions SavannahManager/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,18 @@ public class MainWindowViewModel : ViewModelBase
public MainWindowViewModel(MainWindowService windowService, MainWindowModel model) : base(windowService, model)
{
model.ConsoleTextAppended.Subscribe(Model_AppendConsoleText);
model.ErrorOccurred.Subscribe((message) => windowService.MessageBoxShow(message.ErrorMessage,
LangResources.CommonResources.Error, ExMessageBoxBase.MessageType.Exclamation));
model.ErrorOccurred.Subscribe((message) =>
{
if (message.IsAsync)
{
windowService.MessageBoxDispatchShow(message.ErrorMessage,
LangResources.CommonResources.Error, ExMessageBoxBase.MessageType.Exclamation);
}
else {
windowService.MessageBoxShow(message.ErrorMessage,
LangResources.CommonResources.Error, ExMessageBoxBase.MessageType.Exclamation);
}
});
model.MessageBoxOccurred.Subscribe(args =>
{
var dialogResult = windowService.MessageBoxShow(args.Message, args.Title, args.MessageType, args.ButtonType);
Expand Down Expand Up @@ -451,7 +461,7 @@ private void OpenMenuSettings()
var setting = _model.Setting;
var keyManager = _model.ShortcutKeyManager;

var settingModel = new SettingModel(setting, keyManager);
var settingModel = new SettingModel(setting, keyManager, _model);
var vm = new SettingWindowViewModel(new WindowService(), settingModel);
WindowManageService.ShowDialog<SettingWindow>(vm);
_model.IsBeta = setting.IsBetaMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public SettingWindowViewModel(WindowService windowService, SettingModel model) :
public ReactiveProperty<bool> IsAutoUpdateChecked { get; set; }
public ReactiveProperty<bool> IsEncryptPassword { get; set; }

public bool IsAutoRestartEnabled => !_model.MainWindowModel.AutoRestartEnabled;
public ReactiveProperty<int> AutoRestartIntervalTime { get; set; }
public ReactiveProperty<int> AutoRestartIntervalTimeMode { get; set; }
public ReactiveProperty<bool> IsAutoRestartSendMessage { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion SavannahManager/Views/Settings/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
</TabItem>

<TabItem Header="{Binding Source={x:Static app:ResourceService.Current}, Path=SettingsResources.UI_Restart, Mode=OneWay}">
<Grid>
<Grid IsEnabled="{Binding IsAutoRestartEnabled}">
<StackPanel Orientation="Vertical" Margin="6">

<StackPanel Orientation="Horizontal">
Expand Down
4 changes: 2 additions & 2 deletions SavannahManagerLibTests/SavannahManagerLibTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion SavannahManagerStyleLib/SavannahManagerStyleLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommonStyleLib" Version="1.0.20" />
<PackageReference Include="CommonStyleLib" Version="1.0.23" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Prism.Core" Version="8.1.97" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion SavannahXmlEditor/SavannahXmlEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommonStyleLib" Version="1.0.20" />
<PackageReference Include="CommonStyleLib" Version="1.0.23" />
<PackageReference Include="SavannahXmlLib" Version="1.0.5" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions Todo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
自動再起動と自動バックアップ機能
Config Editorのコンフィグファイルの翻訳やり直し
9 changes: 9 additions & 0 deletions UpdateLogs/updates.en.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<updates>
<update version="2.6.56.4">
1. Fixed a problem where error messages were not displayed correctly.
</update>
<update version="2.6.55.3">
1. Fixed the restart method of auto-restart
2. Two modes of automatic restart have been added.
Cool Time: Wait for a specified period of time after Telnet disconnection, and then perform restart process.
Wait Process: Wait for the process to terminate after Telnet disconnection, then reboot process.
</update>
<update version="2.6.54.2">
1. Fixed a crash when opening the log viewer without the logs directory present.
</update>
Expand Down
9 changes: 9 additions & 0 deletions UpdateLogs/updates.ja.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<updates>
<update version="2.6.56.4">
1. エラーメッセージが正しく表示されない問題を修正しました。
</update>
<update version="2.6.55.3">
1. 自動再起動の再起動方法を修正しました。
2. 自動再起動に2つのモードを追加しました。
Cool Time: Telnet接続解除後に指定した時間待機し、その後に再起動処理を行います。
Wait Process: Telnet接続解除後にプロセスが終了するのを待機し、その後に再起動処理を行います。
</update>
<update version="2.6.54.2">
1. logsディレクトリが存在しない状態でログビューアを開くとクラッシュする問題を修正しました。
</update>
Expand Down
Loading

0 comments on commit 51cc6f2

Please sign in to comment.