Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Implemented the run preview button, added dettings window and enhance…
Browse files Browse the repository at this point in the history
…d recent items list
  • Loading branch information
REHERC committed Feb 7, 2021
1 parent 4810990 commit 7787d15
Show file tree
Hide file tree
Showing 25 changed files with 455 additions and 59 deletions.
34 changes: 34 additions & 0 deletions App.AdventureMaker.Core/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace App.AdventureMaker.Core
{
public class AppSettings
{
public const string SETTINGS_FILE_NAME = "settings.json";

#region Static
[Newtonsoft.Json.JsonIgnore]
public static AppSettings Instance { get; set; }

static AppSettings()
{
Instance = Json.GetOrCreate(SETTINGS_FILE_NAME, new AppSettings());

}

public static void Save()
{
Json.Save(SETTINGS_FILE_NAME, Instance);
}
#endregion

#region Instance
[JsonProperty("preview_mode")]
public int PreviewMode { get; set; } = 0;

[JsonProperty("game_executable")]
public string GameExe { get; set; } = string.Empty;
#endregion
}
}
9 changes: 2 additions & 7 deletions App.AdventureMaker.Core/Commands/FeedbackCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Eto.Forms;
using System;
using System.Diagnostics;
using static Utils;

namespace App.AdventureMaker.Core.Commands
{
Expand All @@ -16,13 +17,7 @@ public FeedbackCommand()

protected override void OnExecuted(EventArgs e)
{
new Process()
{
StartInfo = new ProcessStartInfo(Constants.GITHUB_ISSUES_PAGE)
{
UseShellExecute = true
}
}.Start();
ShellOpen(Constants.GITHUB_ISSUES_PAGE);
}
}
}
9 changes: 2 additions & 7 deletions App.AdventureMaker.Core/Commands/ProjectFolderCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Eto.Forms;
using System;
using System.Diagnostics;
using static Utils;

namespace App.AdventureMaker.Core.Commands
{
Expand Down Expand Up @@ -31,13 +32,7 @@ protected override void OnExecuted(EventArgs e)
{
if (editor.CurrentFile != null)
{
new Process()
{
StartInfo = new ProcessStartInfo(editor.CurrentFile.Directory.FullName)
{
UseShellExecute = true
}
}.Start();
ShellOpen(editor.CurrentFile.Directory.FullName);
}
}
}
Expand Down
28 changes: 26 additions & 2 deletions App.AdventureMaker.Core/Commands/RunGameCommand.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
using Eto.Forms;
using App.AdventureMaker.Core.Interfaces;
using Distance.AdventureMaker.Common.Models;
using Eto.Forms;
using System;

namespace App.AdventureMaker.Core.Commands
{
public class RunGameCommand : Command
{
public RunGameCommand()
private readonly IEditor<CampaignFile> editor;
public RunGameCommand(IEditor<CampaignFile> editor_)
{
editor = editor_;

MenuText = "&Run Preview";
ToolBarText = "Run Preview";
Image = Resources.GetIcon("Run.ico");
Shortcut = Application.Instance.CommonModifier | Keys.F5;

Enabled = false;

editor.OnLoaded += (_) =>
{
Enabled = editor.CurrentFile != null;
};
}

protected override void OnExecuted(EventArgs e)
{
base.OnExecuted(e);

if (editor.Modified && Messages.SaveBeforeContinue() == DialogResult.No)
{
return;
}

editor.SaveFile();
RunGame.Run(editor);
}
}
}
9 changes: 7 additions & 2 deletions App.AdventureMaker.Core/Commands/SettingsCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Eto.Forms;
using App.AdventureMaker.Core.Forms;
using Eto.Forms;
using System;

namespace App.AdventureMaker.Core.Commands
{
Expand All @@ -9,8 +11,11 @@ public SettingsCommand()
MenuText = "&Settings";
ToolBarText = "Settings";
Image = Resources.GetIcon("Settings.ico");
}

Enabled = false;
protected override void OnExecuted(EventArgs e)
{
new SettingsWindow().ShowModal();
}
}
}
10 changes: 2 additions & 8 deletions App.AdventureMaker.Core/Commands/TutorialsCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Eto.Forms;
using System;
using System.Diagnostics;
using static Utils;

namespace App.AdventureMaker.Core.Commands
{
Expand All @@ -18,13 +18,7 @@ public TutorialsCommand()

protected override void OnExecuted(EventArgs e)
{
new Process()
{
StartInfo = new ProcessStartInfo(Constants.GITHUB_WIKI)
{
UseShellExecute = true
}
}.Start();
ShellOpen(Constants.GITHUB_WIKI);
}
}
}
9 changes: 8 additions & 1 deletion App.AdventureMaker.Core/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using App.AdventureMaker.Core.Forms.Dialog;
using App.AdventureMaker.Core.Forms.ResourceDialogs;
using Distance.AdventureMaker.Common.Enums;
using Distance.AdventureMaker.Common.Models.Resources;
using System;
Expand All @@ -8,6 +8,8 @@ namespace App.AdventureMaker.Core
{
public static class Constants
{
public const string DISTANCE_STEAM_PROTOCOL_HANDLER_URL = "steam://rungameid/233610//";

public const string GITHUB_ISSUES_PAGE = "https://github.com/REHERC/Centrifuge.Mods.Distance/issues/new";
public const string GITHUB_WIKI = "https://github.com/REHERC/Centrifuge.Mods.Distance/wiki";
public const string DISCORD_DISTANCE = "https://discord.gg/distance";
Expand All @@ -17,15 +19,20 @@ public static class Constants

public const string DIALOG_MESSAGE_EDITOR_PREVIEW = "This software is currently still work in progress!\nPlease only use it for testing purposes and feedback as many breaking changes may occur in the future.";
public const string DIALOG_MESSAGE_UNSAVED_CHANGES = "The currently opened file has unsaved changes!\nContinue without saving?";
public const string DIALOG_MESSAGE_UNSAVED_CHANGES_CONTINUE = "You must save your changes before you continue!\nDo you want to save now?";
public const string DIALOG_MESSAGE_REMOVE_PLAYLIST = "Are you sure you want to remove the following playlist: \"{0}\" ?";
public const string DIALOG_MESSAGE_REMOVE_RESOURCE = "Are you sure you want to remove this resource ?\nObjects requiring this resource will need to be updated manually !";
public const string DIALOG_MESSAGE_MISSING_GAME_EXE = "Could not locate the game executable when starting preview mode!\nPlease locate it in the settings (File > Settings).";
public const string DIALOG_MESSAGE_ERROR_GAME_EXE = "An error occured when attempting to run the game!\n\nMake sure the following conditions are met:\n- The executable exists\n- The file is marked as executable (linux)\n- You have the adequate user permissions\n- You have enough system resources available\n\nTo set the game path, open the settings (File > Settings)";
public const string DIALOG_MESSAGE_GAME_EXE_NOT_SET = "The game executable path is currently not defined, the current operation cannot continue.\n\nDo you want to open the settings to set it?";

public const string DIALOG_CAPTION_EDITOR_PREVIEW = "Campaign Editor - Preview";
public const string DIALOG_CAPTION_APP_CLOSE = "Close application";
public const string DIALOG_CAPTION_NEW_FILE = "New file";
public const string DIALOG_CAPTION_CLOSE_PROJECT = "Close project";
public const string DIALOG_CAPTION_REMOVE_PLAYLIST = "Remove playlist";
public const string DIALOG_CAPTION_REMOVE_RESOURCE = "Remove resource";
public const string DIALOG_CAPTION_START_PREVIEW = "Preview mode";

public const string PLAYLIST_NO_NAME = "(No playlist name)";

Expand Down
2 changes: 1 addition & 1 deletion App.AdventureMaker.Core/Forms/AboutWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void InitializeComponent()
},*/
new Label()
{
Text = "Community-made content making tool for Distance",
Text = "Community content making tool for Distance",
TextAlignment = TextAlignment.Center
},
//new StackLayout()
Expand Down
4 changes: 1 addition & 3 deletions App.AdventureMaker.Core/Forms/AddResourceWindow.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using App.AdventureMaker.Core.Forms.Dialog;
using Distance.AdventureMaker.Common.Enums;
using Distance.AdventureMaker.Common.Enums;
using Distance.AdventureMaker.Common.Models.Resources;
using Eto.Drawing;
using Eto.Forms;
using System;
using System.Collections.Generic;

namespace App.AdventureMaker.Core.Forms
{
Expand Down
2 changes: 1 addition & 1 deletion App.AdventureMaker.Core/Forms/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void InitializeComponent()
UpdateTitle();
};

WindowState = WindowState.Maximized;
//WindowState = WindowState.Maximized;

UpdateTitle();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using App.AdventureMaker.Core.Controls;
using Distance.AdventureMaker.Common.Models.Resources;

namespace App.AdventureMaker.Core.Forms.Dialog
namespace App.AdventureMaker.Core.Forms.ResourceDialogs
{
public class LevelDialog : ResourceDialogBase<CampaignResource.Level>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Eto.Forms;
using System;

namespace App.AdventureMaker.Core.Forms.Dialog
namespace App.AdventureMaker.Core.Forms.ResourceDialogs
{
public abstract class ResourceDialogBase<T> : Dialog<T> where T : class, new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using App.AdventureMaker.Core.Controls;
using Distance.AdventureMaker.Common.Models.Resources;

namespace App.AdventureMaker.Core.Forms.Dialog
namespace App.AdventureMaker.Core.Forms.ResourceDialogs
{
public class TextureDialog : ResourceDialogBase<CampaignResource.Texture>
{
Expand Down
Loading

0 comments on commit 7787d15

Please sign in to comment.