Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create text UI inspired by Turbo Vision #2177

Merged
merged 38 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a32aca9
Create text UI inspired by Turbo Vision
HebaruSan Oct 26, 2017
2ec58fd
Attempt to fix travis's compile errors
HebaruSan Nov 7, 2017
cc5aba6
EarliestCompatibleKSP was documented wrong
HebaruSan Nov 7, 2017
0460a06
We don't need EventArgs for the key bindings
HebaruSan Nov 7, 2017
d5cff01
Extend tech section of the README
HebaruSan Nov 7, 2017
14238a4
Make the mod info screen's hamburger menu list the URLs
HebaruSan Nov 8, 2017
186dabf
Forgot XML docs for new function
HebaruSan Nov 8, 2017
b17504d
Full redraw after help screen
HebaruSan Nov 9, 2017
dadae35
Truncate frame titles as needed
HebaruSan Nov 9, 2017
7efe502
Jump to mod details from recommendations (see #858)
HebaruSan Nov 9, 2017
7b2e56e
Mac fixes: replace Alt hotkeys, add key capture menu option
HebaruSan Nov 10, 2017
113124d
Remove unnecessary using directives
HebaruSan Nov 10, 2017
b89af7c
Update .csproj
Olympic1 Nov 11, 2017
eac713c
Keep DocumentationFile
Olympic1 Nov 11, 2017
b1c04e3
Remove PlatformTarget from Release group
HebaruSan Nov 11, 2017
145eda5
Update csproj to latest commit in #2182
Olympic1 Nov 13, 2017
5e11817
Add repo list and edit screens to instance edit screen
HebaruSan Nov 14, 2017
96eb606
Redraw on Ctrl+L
HebaruSan Nov 16, 2017
602eeaf
Random fixes while testing with old installs
HebaruSan Nov 16, 2017
5d4cae3
Don't hide download key if zip is invalid
HebaruSan Nov 17, 2017
8c7c79e
Notify user of failed downloads
HebaruSan Nov 17, 2017
0f557cb
Don't crash at splash screen with small window
HebaruSan Nov 17, 2017
0d2761c
The arrow key bindings were moved to the field object
HebaruSan Nov 17, 2017
f46c9af
Don't say "1 new mods, show them"
HebaruSan Nov 18, 2017
03cb122
Remove Mac warning, prompt for "provides" optional dependencies
HebaruSan Nov 18, 2017
c686bb6
Add download import option as per #1788
HebaruSan Nov 24, 2017
c0d2322
Semantic sorting
HebaruSan Nov 26, 2017
8a520d7
Avoid exceptions in file browser on small screen
HebaruSan Nov 27, 2017
ecceac5
Remove leading slashes in dir names
HebaruSan Nov 27, 2017
fc02c17
Address some of @politas's feedback
HebaruSan Nov 29, 2017
5e1952f
Dispose all RegistryManagers at exit
HebaruSan Nov 30, 2017
7481249
Add an Id-inspired exit screen
HebaruSan Nov 30, 2017
e2eed62
Scrollable, non-hidden install window messages
HebaruSan Nov 30, 2017
36a1cd0
Only prompt for each optional dependency once per install
HebaruSan Nov 30, 2017
305dae6
Add keys to select and deselect all optional dependencies
HebaruSan Nov 30, 2017
b13c38a
Visual tweaks
HebaruSan Dec 1, 2017
d0b5afb
Debug option to view mod's metadata
HebaruSan Dec 3, 2017
24644c9
Minimum width for popups, scrollable description in mod info screen
HebaruSan Dec 6, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CKAN.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CKAN-autoupdate", "AutoUpda
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CKAN-cmdline", "Cmdline\CKAN-cmdline.csproj", "{E97D81F6-85E2-4F1F-906D-BE21766602E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CKAN-ConsoleUI", "ConsoleUI\CKAN-ConsoleUI.csproj", "{DA5C7023-9A3B-4204-AE2F-BBA6C388B436}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CKAN-GUI", "GUI\CKAN-GUI.csproj", "{A79F9D54-315C-472B-928F-713A5860B2BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CKAN-netkan", "Netkan\CKAN-netkan.csproj", "{4336F356-33DB-442A-BF74-5E89AF47A5B9}"
Expand Down Expand Up @@ -45,6 +47,10 @@ Global
{4F41255E-8BC1-465B-82D5-1C5665BC099A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F41255E-8BC1-465B-82D5-1C5665BC099A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F41255E-8BC1-465B-82D5-1C5665BC099A}.Release|Any CPU.Build.0 = Release|Any CPU
{DA5C7023-9A3B-4204-AE2F-BBA6C388B436}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA5C7023-9A3B-4204-AE2F-BBA6C388B436}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA5C7023-9A3B-4204-AE2F-BBA6C388B436}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA5C7023-9A3B-4204-AE2F-BBA6C388B436}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions Cmdline/Action/Repo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace CKAN.CmdLine
{

public class Repo : ISubCommand
{
public Repo() { }
Expand Down
4 changes: 4 additions & 0 deletions Cmdline/CKAN-cmdline.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
<Project>{A79F9D54-315C-472B-928F-713A5860B2BE}</Project>
<Name>CKAN-GUI</Name>
</ProjectReference>
<ProjectReference Include="..\ConsoleUI\CKAN-ConsoleUI.csproj">
<Project>{DA5C7023-9A3B-4204-AE2F-BBA6C388B436}</Project>
<Name>CKAN-ConsoleUI</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="log4net.xml">
Expand Down
10 changes: 10 additions & 0 deletions Cmdline/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ private static int RunSimpleAction(Options cmdline, CommonOptions options, strin
case "gui":
return Gui((GuiOptions)options, args);

case "consoleui":
return ConsoleUi(options, args);

case "version":
return Version(user);

Expand Down Expand Up @@ -209,6 +212,13 @@ private static int Gui(GuiOptions options, string[] args)
return Exit.OK;
}

private static int ConsoleUi(CommonOptions opts, string[] args)
{
// Debug/verbose output just messes up the screen
LogManager.GetRepository().Threshold = Level.Warn;
return CKAN.ConsoleUI.ConsoleUI.Main_(args, opts.Debug);
}

private static int Version(IUser user)
{
user.RaiseMessage(Meta.GetVersion(VersionFormat.Full));
Expand Down
5 changes: 5 additions & 0 deletions Cmdline/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ internal class Actions : VerbCommandOptions
[VerbOption("gui", HelpText = "Start the CKAN GUI")]
public GuiOptions GuiOptions { get; set; }

[VerbOption("consoleui", HelpText = "Start the CKAN console UI")]
public ConsoleUIOptions ConsoleUIOptions { get; set; }

[VerbOption("search", HelpText = "Search for mods")]
public SearchOptions SearchOptions { get; set; }

Expand Down Expand Up @@ -396,6 +399,8 @@ internal class GuiOptions : InstanceSpecificOptions
public bool ShowConsole { get; set; }
}

internal class ConsoleUIOptions : CommonOptions { }

internal class UpdateOptions : InstanceSpecificOptions
{
// This option is really meant for devs testing their CKAN-meta forks.
Expand Down
12 changes: 12 additions & 0 deletions ConsoleUI/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<runtime>
<enforceFIPSPolicy enabled="false"/>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
159 changes: 159 additions & 0 deletions ConsoleUI/CKAN-ConsoleUI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA5C7023-9A3B-4204-AE2F-BBA6C388B436}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>CKAN</RootNamespace>
<AssemblyName>CKAN-ConsoleUI</AssemblyName>
<ApplicationIcon>..\assets\ckan.ico</ApplicationIcon>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<IntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\_build\lib\nuget\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Transactions" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\_build\meta\GlobalAssemblyVersionInfo.cs">
<Link>Properties\GlobalAssemblyVersionInfo.cs</Link>
</Compile>
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="CompatibleVersionDialog.cs" />
<Compile Include="ConsoleCKAN.cs" />
<Compile Include="DependencyScreen.cs" />
<Compile Include="DownloadImportDialog.cs" />
<Compile Include="InstallScreen.cs" />
<Compile Include="KSPAddScreen.cs" />
<Compile Include="KSPEditScreen.cs" />
<Compile Include="KSPListScreen.cs" />
<Compile Include="KSPScreen.cs" />
<Compile Include="ModInfoScreen.cs" />
<Compile Include="ModListHelpDialog.cs" />
<Compile Include="ModListScreen.cs" />
<Compile Include="Program.cs" />
<Compile Include="ProgressScreen.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="RepoAddScreen.cs" />
<Compile Include="RepoEditScreen.cs" />
<Compile Include="RepoScreen.cs" />
<Compile Include="SplashScreen.cs" />
<Compile Include="ExitScreen.cs" />
<Compile Include="Toolkit\ConsoleButton.cs" />
<Compile Include="Toolkit\ConsoleChoiceDialog.cs" />
<Compile Include="Toolkit\ConsoleFileMultiSelectDialog.cs" />
<Compile Include="Toolkit\ConsoleDialog.cs" />
<Compile Include="Toolkit\ConsoleField.cs" />
<Compile Include="Toolkit\ConsoleFrame.cs" />
<Compile Include="Toolkit\ConsoleDoubleFrame.cs" />
<Compile Include="Toolkit\ConsoleLabel.cs" />
<Compile Include="Toolkit\ConsoleListBox.cs" />
<Compile Include="Toolkit\ConsoleMessageDialog.cs" />
<Compile Include="Toolkit\ConsolePopupMenu.cs" />
<Compile Include="Toolkit\ConsoleProgressBar.cs" />
<Compile Include="Toolkit\ConsoleScreen.cs" />
<Compile Include="Toolkit\ConsoleTextBox.cs" />
<Compile Include="Toolkit\ConsoleTheme.cs" />
<Compile Include="Toolkit\Formatting.cs" />
<Compile Include="Toolkit\Keys.cs" />
<Compile Include="Toolkit\ScreenContainer.cs" />
<Compile Include="Toolkit\ScreenObject.cs" />
<Compile Include="Toolkit\Symbols.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
<Visible>False</Visible>
<ProductName>Windows Installer 4.5</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\CKAN-core.csproj">
<Project>{3B9AEA22-FA3B-4E43-9283-EABDD81CF271}</Project>
<Name>CKAN-core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="log4net.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild">
<Exec Command="powershell ../build.ps1 Generate-GlobalAssemblyVersionInfo" Condition="!Exists('../_build/meta/GlobalAssemblyVersionInfo.cs') And '$(OS)' == 'Windows_NT'" />
<Exec Command="sh ../build Generate-GlobalAssemblyVersionInfo" Condition="!Exists('../_build/meta/GlobalAssemblyVersionInfo.cs') And '$(OS)' == 'Unix'" />
</Target>
</Project>
105 changes: 105 additions & 0 deletions ConsoleUI/CompatibleVersionDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using CKAN.Versioning;
using CKAN.GameVersionProviders;
using CKAN.ConsoleUI.Toolkit;

namespace CKAN.ConsoleUI {

/// <summary>
/// Popup letting user pick a game version from a list or enter it manually
/// </summary>
public class CompatibleVersionDialog : ConsoleDialog {

/// <summary>
/// Initialize the popup
/// </summary>
public CompatibleVersionDialog() : base()
{
int l = GetLeft(),
r = GetRight();
int t = GetTop(),
b = GetBottom();

choices = new ConsoleListBox<KspVersion>(
l + 2, t + 2, r - 2, b - 4,
options,
new List<ConsoleListBoxColumn<KspVersion>>() {
new ConsoleListBoxColumn<KspVersion>() {
Header = "Predefined Version",
Width = r - l - 5,
Renderer = v => v.ToString(),
Comparer = (v1, v2) => v1.CompareTo(v2)
}
},
0, 0, ListSortDirection.Descending
);
AddObject(choices);
choices.AddTip("Enter", "Select version");
choices.AddBinding(Keys.Enter, (object sender) => {
choice = choices.Selection;
return false;
});

manualEntry = new ConsoleField(
l + 2, b - 2, r - 2
) {
GhostText = () => "<Enter a version>"
};
AddObject(manualEntry);
manualEntry.AddTip("Enter", "Accept value", () => KspVersion.TryParse(manualEntry.Value, out choice));
manualEntry.AddBinding(Keys.Enter, (object sender) => {
if (KspVersion.TryParse(manualEntry.Value, out choice)) {
// Good value, done running
return false;
} else {
// Not valid, so they can't even see the key binding
return true;
}
});

AddTip("Esc", "Cancel");
AddBinding(Keys.Escape, (object sender) => {
choice = null;
return false;
});

CenterHeader = () => "Select Compatible Version";
}

/// <summary>
/// Display the dialog and handle its interaction
/// </summary>
/// <param name="process">Function to control the dialog, default is normal user interaction</param>
/// <returns>
/// Row user selected
/// </returns>
public new KspVersion Run(Action process = null)
{
base.Run(process);
return choice;
}

static CompatibleVersionDialog()
{
options = new KspBuildMap(new Win32Registry()).KnownVersions;
// C# won't let us foreach over an array while modifying it
for (int i = options.Count - 1; i >= 0; --i) {
KspVersion v = options[i];
// From GUI/CompatibleKspVersionsDialog.cs
KspVersion fullKnownVersion = v.ToVersionRange().Lower.Value;
KspVersion toAdd = new KspVersion(fullKnownVersion.Major, fullKnownVersion.Minor);
if (!options.Contains(toAdd)) {
options.Add(toAdd);
}
}
}

private static List<KspVersion> options;

private ConsoleListBox<KspVersion> choices;
private ConsoleField manualEntry;
private KspVersion choice;
}
}
Loading