Skip to content

Commit

Permalink
add offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryddag committed May 4, 2018
1 parent b613d42 commit 33836b4
Show file tree
Hide file tree
Showing 14 changed files with 1,140 additions and 372 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## [v2.0.5.0](https://github.com/ProjectCeleste/Celeste_Launcher/tree/v2.0.5.0) (2018-05-04)

[Full Changelog](https://github.com/ProjectCeleste/Celeste_Launcher/compare/v2.0.4.0...v2.0.5.0)

**New Features:**

- "Offline Mode" : You can now play custom scneario made by the community using "Game Editor".

**Enhancements:**

- Necessary file for "Diagnostic Mode" are now automatically downloaded if missing.
- "Game Editor" can now be launched without an internet connection available.

## [v2.0.4.0](https://github.com/ProjectCeleste/Celeste_Launcher/tree/v2.0.4.0) (2018-03-27)

[Full Changelog](https://github.com/ProjectCeleste/Celeste_Launcher/compare/v2.0.3.2...v2.0.4.0)
Expand Down
20 changes: 10 additions & 10 deletions Celeste_Launcher_Gui/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public enum GameLanguage
public class UserConfig
{
#if DEBUG
[DefaultValue("ws://127.0.0.1:4512/")]
[DefaultValue("wss://127.0.0.1:4513/")]
[XmlElement(ElementName = "ServerUri")]
public string ServerUri { get; set; } = "ws://127.0.0.1:4512/";
public string ServerUri { get; set; } = "wss://127.0.0.1:4513/";
#else
[DefaultValue("wss://ns544971.ip-66-70-180.net:4513/")]
[XmlElement(ElementName = "ServerUri")]
Expand Down Expand Up @@ -67,7 +67,7 @@ public static UserConfig Load(string path)
if (userConfig.MpSettings.IsOnline)
return userConfig;

if (!string.IsNullOrEmpty(userConfig.MpSettings.LanNetworkInterface))
if (!string.IsNullOrWhiteSpace(userConfig.MpSettings.LanNetworkInterface))
{
var selectedNetInt = userConfig.MpSettings.LanNetworkInterface;
var netInterface = NetworkInterface.GetAllNetworkInterfaces()
Expand Down Expand Up @@ -116,12 +116,12 @@ public string CryptedPassword
{
_cryptedPassword = value;

if (!string.IsNullOrEmpty(_uncryptedPassword))
if (!string.IsNullOrWhiteSpace(_uncryptedPassword))
return;

try
{
_uncryptedPassword = string.IsNullOrEmpty(value)
_uncryptedPassword = string.IsNullOrWhiteSpace(value)
? string.Empty
: EncryptDecrypt.Decrypt(value, true);
}
Expand All @@ -143,12 +143,12 @@ public string Password
{
get
{
if (!string.IsNullOrEmpty(_uncryptedPassword))
if (!string.IsNullOrWhiteSpace(_uncryptedPassword))
return _uncryptedPassword;

try
{
_uncryptedPassword = string.IsNullOrEmpty(CryptedPassword)
_uncryptedPassword = string.IsNullOrWhiteSpace(CryptedPassword)
? string.Empty
: EncryptDecrypt.Decrypt(CryptedPassword, true);
}
Expand All @@ -161,12 +161,12 @@ public string Password
}
set
{
if (string.IsNullOrEmpty(value))
if (string.IsNullOrWhiteSpace(value))
CryptedPassword = string.Empty;

try
{
CryptedPassword = string.IsNullOrEmpty(value) ? string.Empty : EncryptDecrypt.Encrypt(value, true);
CryptedPassword = string.IsNullOrWhiteSpace(value) ? string.Empty : EncryptDecrypt.Encrypt(value, true);
}
catch (Exception)
{
Expand Down Expand Up @@ -202,7 +202,7 @@ public bool AutoPortMapping
[XmlIgnore]
public string PublicIp
{
get => string.IsNullOrEmpty(_publicIp) ? "127.0.0.1" : _publicIp;
get => string.IsNullOrWhiteSpace(_publicIp) ? "127.0.0.1" : _publicIp;
set => _publicIp = value;
}

Expand Down
45 changes: 33 additions & 12 deletions Celeste_Launcher_Gui/Forms/EditorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Celeste_AOEO_Controls.Helpers;
using Celeste_AOEO_Controls.MsgBox;
using Celeste_Public_Api.GameScanner_Api;
using Celeste_Public_Api.Helpers;

#endregion

Expand All @@ -19,7 +20,7 @@ public partial class EditorForm : Form

public EditorForm()
{
var path = !string.IsNullOrEmpty(Program.UserConfig.GameFilesPath)
var path = !string.IsNullOrWhiteSpace(Program.UserConfig.GameFilesPath)
? Program.UserConfig.GameFilesPath
: GameScannnerApi.GetGameFilesRootPath();

Expand All @@ -44,21 +45,32 @@ private async void EditorForm_Load(object sender, EventArgs e)
//
}

if (await _gameScannner.QuickScan())
if (!DownloadFileUtils.IsConnectedToInternet())
{
Btn_Install_Editor.Enabled = false;
btn_Browse.Enabled = true;
if (await _gameScannner.QuickScan())
{
Btn_Install_Editor.Enabled = false;
btn_Browse.Enabled = true;

label2.Text = @"Installed";
label2.ForeColor = Color.Green;
}
else
{
label2.Text = @"Non-Installed Or Outdated";
label2.ForeColor = Color.Red;

label2.Text = @"Installed";
label2.ForeColor = Color.Green;
Btn_Install_Editor.Enabled = true;
btn_Browse.Enabled = false;
}
}
else
{
label2.Text = @"Non-Installed";
label2.ForeColor = Color.Red;

Btn_Install_Editor.Enabled = true;
btn_Browse.Enabled = false;
btn_Browse.Enabled = true;

label2.Text = @"Unknow";
label2.ForeColor = Color.OrangeRed;
}
}

Expand All @@ -76,7 +88,7 @@ private void Btn_Browse_Click(object sender, EventArgs e)
btn_Browse.Enabled = false;

//Launch Game
var path = !string.IsNullOrEmpty(Program.UserConfig.GameFilesPath)
var path = !string.IsNullOrWhiteSpace(Program.UserConfig.GameFilesPath)
? Program.UserConfig.GameFilesPath
: GameScannnerApi.GetGameFilesRootPath();

Expand All @@ -85,6 +97,15 @@ private void Btn_Browse_Click(object sender, EventArgs e)
if (!File.Exists(spartanPath))
throw new FileNotFoundException("Editor.exe not found!", spartanPath);

//isSteam
if (!Program.UserConfig.IsSteamVersion)
{
var steamApiDll = Path.Combine(Program.UserConfig.GameFilesPath, "steam_api.dll");
if (File.Exists(steamApiDll))
File.Delete(steamApiDll);
}

//
string lang;
switch (Program.UserConfig.GameLanguage)
{
Expand Down Expand Up @@ -126,7 +147,7 @@ private void Btn_Browse_Click(object sender, EventArgs e)
@"Celeste Fan Project",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
btn_Browse.Enabled = false;
btn_Browse.Enabled = true;
}

private void Btn_Install_Editor_Click(object sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions Celeste_Launcher_Gui/Forms/FirewallForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void RefreshForm()
}
}

var path = !string.IsNullOrEmpty(Program.UserConfig?.GameFilesPath)
var path = !string.IsNullOrWhiteSpace(Program.UserConfig?.GameFilesPath)
? Program.UserConfig?.GameFilesPath
: GameScannnerApi.GetGameFilesRootPath();

Expand Down Expand Up @@ -254,7 +254,7 @@ private void Btn_Fix_SpartanRules_Click(object sender, EventArgs e)
Enabled = false;
try
{
var path = !string.IsNullOrEmpty(Program.UserConfig?.GameFilesPath)
var path = !string.IsNullOrWhiteSpace(Program.UserConfig?.GameFilesPath)
? Program.UserConfig?.GameFilesPath
: GameScannnerApi.GetGameFilesRootPath();

Expand Down
2 changes: 1 addition & 1 deletion Celeste_Launcher_Gui/Forms/GameScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public GameScan()

SkinHelper.SetFont(Controls);

if (Program.UserConfig != null && !string.IsNullOrEmpty(Program.UserConfig.GameFilesPath))
if (Program.UserConfig != null && !string.IsNullOrWhiteSpace(Program.UserConfig.GameFilesPath))
tb_GamePath.Text = Program.UserConfig.GameFilesPath;
else
tb_GamePath.Text = GameScannnerApi.GetGameFilesRootPath();
Expand Down
2 changes: 1 addition & 1 deletion Celeste_Launcher_Gui/Forms/GameScanProgressForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public GameScanProgressForm(string gameFilesPath, bool isSteam, bool isLegacyXLi
{
InitializeComponent();

if (string.IsNullOrEmpty(gameFilesPath))
if (string.IsNullOrWhiteSpace(gameFilesPath))
throw new Exception(@"Game files path is empty!");

SkinHelper.SetFont(Controls);
Expand Down
Loading

0 comments on commit 33836b4

Please sign in to comment.