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

Hopeful contributions #1205

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions Cmdline/Action/Remove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ public int RunCommand(CKAN.KSP ksp, object raw_options)
options.modules = selectedModules;
}

if (options.rmall)
{
log.Debug("Removing all mods");
// Get the list of installed modules
IRegistryQuerier registry = RegistryManager.Instance(ksp).registry;
var installed = new SortedDictionary<string, Version>(registry.Installed(false));

// Add it to the list that should be uninstalled.
options.modules.AddRange(installed.Keys);
}

if (options.modules != null && options.modules.Count > 0)
{
try
Expand Down
3 changes: 3 additions & 0 deletions Cmdline/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ internal class RemoveOptions : CommonOptions

[ValueList(typeof(List<string>))]
public List<string> modules { get; set; }

[Option("all", HelpText = "Remove all installed mods.")]
public bool rmall { get; set; }
}

internal class ShowOptions : CommonOptions
Expand Down
11 changes: 11 additions & 0 deletions Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,17 @@ private void Uninstall(string modName)
log.InfoFormat("Not removing directory {0}, it's not empty", directory);
}
}

// Check if Ships/VAB or Ships/SPH is missing for some reason.
if (!Directory.Exists(KSPPathUtils.ToAbsolute("VAB", ksp.Ships())))
{
Directory.CreateDirectory(KSPPathUtils.ToAbsolute("VAB", ksp.Ships()));
}
if (!Directory.Exists(KSPPathUtils.ToAbsolute("SPH", ksp.Ships())))
{
Directory.CreateDirectory(KSPPathUtils.ToAbsolute("SPH", ksp.Ships()));
}

transaction.Complete();
}
}
Expand Down
6 changes: 6 additions & 0 deletions GUI/CKAN-GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,10 @@
<Name>CKAN-core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\deselect.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\selectinstalled.png" />
</ItemGroup>
</Project>
9 changes: 7 additions & 2 deletions GUI/GUIMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,16 @@ public void SetUpgradeChecked(DataGridViewRow row, bool? setvalueto = null)
if (old_value != value) update_cell.Value = value;
}

public void SetInstallChecked(DataGridViewRow row)
public void SetInstallChecked(DataGridViewRow row, bool? setvalueto = null)
{
//Contract.Requires<ArgumentException>(row.Cells[0] is DataGridViewCheckBoxCell);
var install_cell = row.Cells[0] as DataGridViewCheckBoxCell;
IsInstallChecked = (bool) install_cell.Value;
var old_value = (bool)install_cell.Value;

bool value = (setvalueto.HasValue ? setvalueto.Value : old_value);
IsInstallChecked = value;

if (old_value != value) install_cell.Value = value;
}

protected bool Equals(GUIMod other)
Expand Down
47 changes: 36 additions & 11 deletions GUI/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 31 additions & 3 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,8 @@ private async void ModList_CellValueChanged(object sender, DataGridViewCellEvent
switch (column_index)
{
case 0:
gui_mod.SetInstallChecked(row);
if(gui_mod.IsInstallChecked)
last_mod_to_have_install_toggled.Push(gui_mod);
MarkModForInstall(gui_mod.Identifier, !(bool)grid_view_cell.Value);
// Used to push to "last_mod_to_have_install_toggled", but this is also done in MarkModForInstall.
break;
case 1:
gui_mod.SetUpgradeChecked(row);
Expand Down Expand Up @@ -989,6 +988,35 @@ private void openKspDirectoyToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start(Instance.manager.CurrentInstance.GameDir());
}

private void DeselectAllToolButton_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in ModList.Rows)
{
var mod = ((GUIMod)row.Tag);
if (row.Cells[0] is DataGridViewCheckBoxCell && (bool) row.Cells[0].Value)
{
MarkModForInstall(mod.Identifier, (bool)row.Cells[0].Value);
ApplyToolButton.Enabled = true;
}
}

ModList.Refresh();
}

private void SelectInstalledToolButton_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in ModList.Rows)
{
var mod = ((GUIMod)row.Tag);
if (row.Cells[0] is DataGridViewCheckBoxCell && !(bool)row.Cells[0].Value && mod.IsInstalled)
{
MarkModForInstall(mod.Identifier, false);
}
}

ModList.Refresh();
}
}

public class GUIUser : NullUser
Expand Down
3 changes: 2 additions & 1 deletion GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ private void _MarkModForInstall(string identifier, bool uninstall)
var mod = (GUIMod) row.Tag;
if (mod.Identifier == identifier)
{
var toggled = uninstall == mod.IsInstalled;
mod.IsInstallChecked = !uninstall;
//TODO Fix up MarkMod stuff when I commit the GUIConflict
(row.Cells[0] as DataGridViewCheckBoxCell).Value = !uninstall;
if (!uninstall) last_mod_to_have_install_toggled.Push(mod);
if (!toggled) last_mod_to_have_install_toggled.Push(mod);
break;
}
}
Expand Down
22 changes: 21 additions & 1 deletion GUI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 17 additions & 11 deletions GUI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,28 +118,34 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="search" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="apply" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\apply.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="refresh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="settings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="deselect" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\deselect.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="apply" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\apply.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ksp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ksp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="search" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="refresh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="CKANFileFilter" xml:space="preserve">
<value>CKAN metadata (*.ckan)|*.ckan</value>
</data>
<data name="ExportInstalledModsDialogTitle" xml:space="preserve">
<value>Export Mod List</value>
</data>
<data name="settings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="selectinstalled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\selectinstalled.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added GUI/Resources/deselect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/Resources/selectinstalled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.