Skip to content

Commit

Permalink
update for supportedVersions list
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffierThanThou committed May 11, 2019
1 parent e13b407 commit c962a9b
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 175 deletions.
3 changes: 2 additions & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ Brrainz: multi-version targetting, inspiration for mod promotions
b606: French translation
Proxyer: Japanese translation
奔跑的梅洛斯: Simplified Chinese translation
Zetrith:

<size=24>Version</size>
This is version 1.16.756, for RimWorld 1.0.2150.
This is version 1.16.761, for RimWorld 1.0.2231.

</description>
<supportedVersions>
Expand Down
Binary file modified Assemblies/ModManager.dll
Binary file not shown.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Sometimes, it's easier to navigate large lists with the keyboard.
- b606: French translation
- Proxyer: Japanese translation
- 奔跑的梅洛斯: Simplified Chinese translation
- Zetrith:

# Think you found a bug?
Please read [this guide](http://steamcommunity.com/sharedfiles/filedetails/?id=725234314) before creating a bug report,
Expand All @@ -92,4 +93,4 @@ Show your appreciation by buying me a coffee (or contribute towards a nice singl
[![Buy Me a Coffee](http://i.imgur.com/EjWiUwx.gif)](https://ko-fi.com/fluffymods)

# Version
This is version 1.16.756, for RimWorld 1.0.2150.
This is version 1.16.761, for RimWorld 1.0.2231.
7 changes: 4 additions & 3 deletions Source/ModConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"alpha": 18,
"major": 1,
"minor": 16,
"build": 756
"build": 761
},
"visibility": 0,
"git_repo": "ModManager",
Expand All @@ -14,9 +14,10 @@
"Brrainz": "multi-version targetting, inspiration for mod promotions",
"b606": "French translation",
"Proxyer": "Japanese translation",
"奔跑的梅洛斯": "Simplified Chinese translation"
"奔跑的梅洛斯": "Simplified Chinese translation",
"Zetrith": "Fix blurry mod descriptions"
},
"changenote": "correctly load modlists where Core isn't the first mod\nright click menus for mods",
"changenote": "correctly load modlists where Core isn't the first mod",
"tags": [],
"publishedfileid": "1507748539"
}
16 changes: 3 additions & 13 deletions Source/ModManager/ModButton/ModButton_Installed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,8 @@ public override IEnumerable<ModIssue> Issues
if ( _issues == null )
{
_issues = new List<ModIssue>();
switch ( Selected.GetVersionStatus().match )
{
case VersionMatch.DifferentVersion:
_issues.Add( ModIssue.DifferentVersion( this ));
break;
case VersionMatch.DifferentBuild:
_issues.Add( ModIssue.DifferentBuild( this ) );
break;
case VersionMatch.InvalidVersion when !IsCoreMod:
_issues.Add( ModIssue.InvalidVersion( this ) );
break;
}
if ( !Selected.GetVersionStatus().match )
_issues.Add( ModIssue.DifferentVersion( this ) );

var attributes = ModManager.Settings[Selected];
if ( attributes.Source != null && attributes.SourceHash != attributes.Source.RootDir.GetFolderHash() )
Expand Down Expand Up @@ -529,7 +519,7 @@ internal override void DoModDetails( Rect canvas )
Widgets.Label(labelRect, I18n.TargetVersion);
targetVersionRect.xMin += labelWidth + SmallMargin;
mod.GetVersionStatus().Label(targetVersionRect);
if ( mod.GetVersionStatus().match != VersionMatch.CurrentVersion )
if ( !mod.GetVersionStatus().match )
ActionButton( targetVersionRect,
() => Resolvers.ResolveFindMod( mod.Name.StripSpaces(), this, replace: true ) );

Expand Down
13 changes: 1 addition & 12 deletions Source/ModManager/ModIssue/ModIssue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright Karel Kroeze, 2018-2018

using System;
using System.Linq;
using RimWorld;
using UnityEngine;
using Verse;
Expand Down Expand Up @@ -46,12 +47,6 @@ public ModIssue( Severity severity, Subject subject, ModButton button, string ta
this.resolver = resolver;
}

public static ModIssue DifferentBuild( ModButton_Installed button )
{
return new ModIssue( Severity.Notice, Subject.Version, button, button.Identifier,
I18n.DifferentBuild( button.Selected ) );
}

public static ModIssue UpdateAvailable( ModButton_Installed button )
{
return new ModIssue( Severity.Update, Subject.Version, button, button.Identifier,
Expand All @@ -64,12 +59,6 @@ public static ModIssue DifferentVersion( ModButton_Installed button )
I18n.DifferentVersion( button.Selected ) );
}

public static ModIssue InvalidVersion( ModButton_Installed button )
{
return new ModIssue( Severity.Minor, Subject.Version, button, button.Identifier,
I18n.InvalidVersion( button.Selected.TargetVersion ) );
}

public static ModIssue MissingMod( ModButton_Missing button )
{
return new ModIssue( Severity.Major, Subject.Other, button, button.Identifier,
Expand Down
4 changes: 2 additions & 2 deletions Source/ModManager/ModIssue/ModIssue_Resolvers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public static void ResolveFindMod(
}
if ( requester is ModButton_Missing missing && missing.Identifier.IsSteamWorkshopIdentifier())
options.Add( SubscribeOption( missing.Name, missing.Identifier ) );
options.Add( WorkshopSearchOption( requester?.TrimmedName ?? identifier ) );
options.Add( ForumSearchOption( requester?.TrimmedName ?? identifier ) );
options.Add( WorkshopSearchOption( identifier ) );
options.Add( ForumSearchOption( identifier ) );
FloatMenu( options );
}

Expand Down
3 changes: 0 additions & 3 deletions Source/ModManager/ModList/Dialog_Rename_ModList.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System.IO;
using System.Linq;
using RimWorld;
using UnityEngine;
using Verse;

namespace ModManager
{
public class Dialog_Rename_ModList : Dialog_Rename
{
private ModList list;
private bool _focusedRenameField;

public Dialog_Rename_ModList( ModList list )
{
Expand Down
2 changes: 1 addition & 1 deletion Source/ModManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.16.756")]
[assembly: AssemblyFileVersion("1.16.761")]
12 changes: 6 additions & 6 deletions Source/ModManager/Utilities/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Extensions.cs
// Copyright Karel Kroeze, 2018-2018

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -57,16 +58,15 @@ public static Mod ModClassWithSettings( this ModMetaData mod )
public static int Compatibility( this ModMetaData mod, bool careAboutBuild = false )
{
if ( mod.VersionCompatible )
{
if ( careAboutBuild && VersionControl.CurrentBuild == VersionControl.BuildFromVersionString( mod.TargetVersion ) )
{
return 2;
}
return 1;
}
return 0;
}

public static string VersionList( this IEnumerable<Version> versions )
{
return versions.Select( v => $"{v.Major}.{v.Minor}" ).StringJoin( ", " );
}

private static Dictionary<ModMetaData, VersionStatus> _versionStatusCache = new Dictionary<ModMetaData, VersionStatus>();
public static VersionStatus GetVersionStatus( this ModMetaData mod )
{
Expand Down
18 changes: 5 additions & 13 deletions Source/ModManager/Utilities/I18n.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Copyright Karel Kroeze, 2018-2018

using System;
using System.Security.Policy;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
using static ModManager.Utilities;

Expand Down Expand Up @@ -43,24 +42,17 @@ private static string Key( params string[] keys )
public static string Yes = "Yes".Translate(); // core
public static string No = "No".Translate(); // core

public static string InvalidVersion( string version )
public static string InvalidVersion( List<Version> versions )
{
return Key( "InvalidVersion" ).Translate( version );
return Key( "InvalidVersion" ).Translate( versions.VersionList() );
}

public static string DifferentVersion( ModMetaData mod, string versionString = null )
public static string DifferentVersion( ModMetaData mod )
{
var version = new Version( versionString ?? mod.TargetVersion );
return Key( "DifferentVersion" ).Translate( mod.Name, version.Major + "." + version.Minor,
return Key( "DifferentVersion" ).Translate( mod.Name, mod.SupportedVersionsReadOnly.VersionList(),
VersionControl.CurrentMajor + "." + VersionControl.CurrentMinor );
}

public static string DifferentBuild( ModMetaData mod, string versionString = null )
{
var version = new Version(versionString ?? mod.TargetVersion );
return Key( "DifferentBuild" ).Translate( mod.Name, version.Build, VersionControl.CurrentBuild );
}

public static string CurrentVersion = Key("CurrentVersion").Translate();

public static string UpdateAvailable( Version current, Version latest )
Expand Down
15 changes: 1 addition & 14 deletions Source/ModManager/Utilities/IO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,7 @@ internal static void FinishBatchCreate()

internal static void DeleteLocalCopies( IEnumerable<ModMetaData> mods )
{
string Target(string versionString)
{
try
{
var version = VersionControl.VersionFromString(versionString);
return version.Major + "." + version.Minor;
}
catch
{
return versionString;
}
}

var modList = mods.Select(m => $"{m.Name} ({Target(m.TargetVersion)})").ToLineList();
var modList = mods.Select(m => $"{m.Name} ({m.SupportedVersionsReadOnly.Select( v => v.ToString() ).StringJoin( ", " )})").ToLineList();
var dialog = Dialog_MessageBox.CreateConfirmation(
I18n.MassUnSubscribeConfirm(mods.Count(), modList),
() =>
Expand Down
2 changes: 1 addition & 1 deletion Source/ModManager/Utilities/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static Resources()
Folder = ContentFinder<Texture2D>.Get( "UI/Icons/ContentSources/LocalFolder" );
Warning = ContentFinder<Texture2D>.Get( "UI/Icons/Warning" );
Question = ContentFinder<Texture2D>.Get( "UI/Icons/Question" );
Palette = ContentFinder<Texture2D>.Get( "UI/Icons/Palette" );
Palette = ContentFinder<Texture2D>.Get( "UI/Icons/palette" );
Gear = ContentFinder<Texture2D>.Get( "UI/Icons/Gear" );

Status_Cross = ContentFinder<Texture2D>.Get("UI/Icons/Status/Cross");
Expand Down
90 changes: 21 additions & 69 deletions Source/ModManager/Utilities/VersionStatus.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
// ModButton_Installed.cs
// Copyright Karel Kroeze, 2018-2018
// Copyright Karel Kroeze, 2018-2018

using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using UnityEngine;
using Verse;

namespace ModManager
{
public enum VersionMatch
{
CurrentVersion,
DifferentBuild,
DifferentVersion,
InvalidVersion
}

public struct VersionStatus
{
public VersionMatch match;
public string version;
public bool match;
public List<Version> versions;
public string tip;

public VersionStatus( VersionMatch match, string version, string tip )
public VersionStatus( bool match, List<Version> versions, string tip )
{
this.match = match;
this.version = version;
this.versions = versions;
this.tip = tip;
}

Expand All @@ -35,63 +27,33 @@ public static VersionStatus For( ModMetaData mod )
var manifest = Manifest.For( mod );
if ( manifest != null && !manifest.TargetVersions.NullOrEmpty() )
return For( mod, manifest );
return For( mod, Match( mod.TargetVersion ), mod.TargetVersion );
return For( mod, mod.SupportedVersionsReadOnly );
}

public static VersionStatus For( ModMetaData mod, Manifest manifest )
{
var best = manifest.TargetVersions
.Select( v => new {version = v, match = Match( v )} )
.MinBy( m => m.match );
return For( mod, best.match, best.version );
}

public static VersionStatus For( ModMetaData mod, VersionMatch match, string version )
{
return new VersionStatus( match, version, Tip( mod, match, version ) );
return For( mod, manifest.TargetVersions );
}

public static VersionStatus For( ModMetaData mod, VersionMatch match, Version version )
public static VersionStatus For( ModMetaData mod, List<Version> versions)
{
return For( mod, match, version.ToString() );
return For(mod, versions.Any(v => VersionControl.IsCompatible(v)), versions);
}

public static string Tip( ModMetaData mod, VersionMatch match, string version )
public static VersionStatus For( ModMetaData mod, bool match, List<Version> versions )
{
switch ( match )
{
case VersionMatch.CurrentVersion:
return I18n.CurrentVersion;
case VersionMatch.DifferentBuild:
return I18n.DifferentBuild( mod, version );
case VersionMatch.DifferentVersion:
return I18n.DifferentVersion( mod, version );
case VersionMatch.InvalidVersion:
default:
return I18n.InvalidVersion( version );

}
return new VersionStatus( match, versions, Tip( mod, match, versions ) );
}

public static VersionMatch Match( string version )
{
if (!VersionControl.IsWellFormattedVersionString(version))
return VersionMatch.InvalidVersion;
return Match( Manifest.ParseVersion( version, null ) );
}

public static VersionMatch Match( Version version )
public static string Tip( ModMetaData mod, bool match, List<Version> versions )
{
if (version.Major != VersionControl.CurrentMajor || version.Minor != VersionControl.CurrentMinor)
return VersionMatch.DifferentVersion;
if (version.Build != VersionControl.CurrentBuild)
return VersionMatch.DifferentBuild;
return VersionMatch.CurrentVersion;
if ( match )
return I18n.CurrentVersion;
else
return I18n.DifferentVersion( mod );
}

public static VersionStatus Unknown => new VersionStatus( VersionMatch.DifferentVersion, "?????",
"Unknown Version" );

public void Label( Rect canvas )
{
Label( canvas, UnityEngine.Color.white );
Expand All @@ -100,7 +62,7 @@ public void Label( Rect canvas )
public void Label( Rect canvas, Color okColor )
{
GUI.color = Color( match, okColor );
Widgets.Label( canvas, version );
Widgets.Label( canvas, versions.VersionList() );
GUI.color = UnityEngine.Color.white;
Tooltip( canvas );
}
Expand All @@ -115,19 +77,9 @@ public Color Color( Color? okColor = null )
return Color( match, okColor );
}

public static Color Color( VersionMatch match, Color? okColor = null )
public static Color Color( bool match, Color? okColor = null )
{
switch ( match )
{
case VersionMatch.InvalidVersion:
return UnityEngine.Color.magenta;
case VersionMatch.DifferentVersion:
return UnityEngine.Color.red;
case VersionMatch.DifferentBuild:
return new Color( .9f, .9f, .9f );
default:
return okColor ?? UnityEngine.Color.white;
}
return match ? okColor ?? UnityEngine.Color.white : UnityEngine.Color.red;
}
}
}
Loading

0 comments on commit c962a9b

Please sign in to comment.