Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improved MpeMaker default message for the MediaPortal dependency to r…
…ead the actual MediaPortal release version that is required

improved the DependencyForm on extension install to show API and MP version and have a tooltip since which MP version a subsystem has the installed API version
added new method to CompatibilityManager that gives the highest subsystem version in the current installation (which actually correlates to the current MP version)
minor spelling correction
  • Loading branch information
offbyoneBB committed Sep 1, 2012
1 parent 7f6b569 commit a568416
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 9 deletions.
17 changes: 17 additions & 0 deletions Common-MP-TVE3/Common.Utils/Compatibility/CompatibilityManager.cs
Expand Up @@ -290,6 +290,12 @@ public static Version GetCurrentVersion()
return version;
}

public static Version GetCurrentMaxVersion()
{
CheckLoadedAssemblies();
return SubSystemVersions.Max(v => v.Value);
}

public static Version GetCurrentSubSystemVersion(string subSystem)
{
Version version = null;
Expand Down Expand Up @@ -368,5 +374,16 @@ public static bool IsPluginCompatible(System.Xml.XmlElement rootNode)
// Have all used subsystem known versions and prior to the one the plugin was designed for?
return subsystemsUsed.All(attr => SubSystemVersions.TryGetValue(attr, out ver) && CompareVersions(ver, designedForVersion) <= 0);
}

static readonly Dictionary<Version, string> MpReleaseApi = new Dictionary<Version, string>()
{
{ new Version("1.1.6.27644"), "1.2.0 Beta" },
{ new Version("1.2.100.0"), "1.3.0 Alpha" }
};

public static string MediaPortalReleaseForApiVersion(Version apiVersion)
{
return MpReleaseApi.First(v => v.Key >= apiVersion).Value;
}
}
}
2 changes: 1 addition & 1 deletion mediaportal/MPE/MpeCore/Classes/VersionInfo.cs
Expand Up @@ -78,7 +78,7 @@ public string Revision
set { _revision = value; }
}

public static VersionInfo Pharse(string s)
public static VersionInfo Parse(string s)
{
VersionInfo ver = new VersionInfo();
string[] vers = s.Split('.');
Expand Down
39 changes: 32 additions & 7 deletions mediaportal/MPE/MpeInstaller/Dialogs/DependencyForm.cs
Expand Up @@ -20,8 +20,9 @@ public DependencyForm(MpeCore.PackageClass pak)
InitializeComponent();
package = pak;
this.Text = pak.GeneralInfo.Name + " - Dependencies";
versionLabel.Text = string.Format("MediaPortal {0} - Skin {1}",
MediaPortal.Common.Utils.CompatibilityManager.GetCurrentVersion().ToString(),
versionLabel.Text = string.Format("MediaPortal {0} (API: {1}) - Skin {2}",
MediaPortal.Common.Utils.CompatibilityManager.MediaPortalReleaseForApiVersion(MediaPortal.Common.Utils.CompatibilityManager.GetCurrentMaxVersion()),
MediaPortal.Common.Utils.CompatibilityManager.GetCurrentVersion(),
MediaPortal.Common.Utils.CompatibilityManager.SkinVersion);
generalDepBindSource.DataSource = package.Dependencies.Items;
dataGridView1.AutoGenerateColumns = false;
Expand Down Expand Up @@ -69,11 +70,23 @@ public DependencyForm(MpeCore.PackageClass pak)
dataGridView2.AutoGenerateColumns = true;
dataGridView2.RowHeadersVisible = false;
dataGridView2.DataSource = pluginDepBindSource;
dataGridView2.CellToolTipTextNeeded += new DataGridViewCellToolTipTextNeededEventHandler(dataGridView2_CellToolTipTextNeeded);
dataGridView2.AutoResizeColumns( DataGridViewAutoSizeColumnsMode.AllCells);
dataGridView2.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView2_CellFormatting);
}
}

void dataGridView2_CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex == 4)
{
SimplePluginDependency depItem = pluginDepBindSource[e.RowIndex] as SimplePluginDependency;
if (depItem.CurrentVersion != null)
e.ToolTipText = string.Format("since MediaPortal {0}",
MediaPortal.Common.Utils.CompatibilityManager.MediaPortalReleaseForApiVersion(depItem.CurrentVersion));
}
}

void dataGridView2_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
SimplePluginDependency depItem = pluginDepBindSource[e.RowIndex] as SimplePluginDependency;
Expand All @@ -82,7 +95,7 @@ void dataGridView2_CellFormatting(object sender, DataGridViewCellFormattingEvent
else
{
Version compatibleVersion = null;
try { compatibleVersion = new Version(depItem.MaxVersion); }
try { compatibleVersion = new Version(depItem.CompatibleVersionItem.DesignedForVersion); }
catch { }
if (compatibleVersion != null && depItem.CurrentVersion != null)
{
Expand All @@ -98,9 +111,9 @@ private void SetColumnsGeneral()
dataGridView1.Columns[0].DataPropertyName = "Name";
dataGridView1.Columns[1].Name = "Type";
dataGridView1.Columns[1].DataPropertyName = "Type";
dataGridView1.Columns[2].Name = "Min version";
dataGridView1.Columns[2].Name = "Min";
dataGridView1.Columns[2].DataPropertyName = "MinVersion";
dataGridView1.Columns[3].Name = "Max version";
dataGridView1.Columns[3].Name = "Max";
dataGridView1.Columns[3].DataPropertyName = "MaxVersion";
}

Expand Down Expand Up @@ -139,6 +152,11 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
public class SimplePluginDependency
{
private MpeCore.Classes.PluginDependencyItem baseItem;

internal MpeCore.Classes.CompatibleVersionItem CompatibleVersionItem
{
get { return baseItem.CompatibleVersion.Items.FirstOrDefault(); }
}

public string Name
{
Expand Down Expand Up @@ -174,8 +192,15 @@ public string MaxVersion
}
}

[DisplayName("Required")]
public Version CurrentVersion { get; set; }
internal Version CurrentVersion { get; set; }

public string Installed
{
get
{
return CurrentVersion == null ? "" : CurrentVersion.ToString();
}
}

public SimplePluginDependency(MpeCore.Classes.PluginDependencyItem item)
{
Expand Down
2 changes: 1 addition & 1 deletion mediaportal/MPE/MpeMaker/Classes/ProgramArguments.cs
Expand Up @@ -45,7 +45,7 @@ public ProgramArguments(string[] args)
if (s.StartsWith("/V="))
{
string ver = s.Remove(0, 3); // remove /?= from the argument
Version = VersionInfo.Pharse(ver);
Version = VersionInfo.Parse(ver);
SetVersion = true;
}

Expand Down
4 changes: 4 additions & 0 deletions mediaportal/MPE/MpeMaker/MpeMaker.csproj
Expand Up @@ -327,6 +327,10 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Common-MP-TVE3\Common.Utils\Common.Utils.csproj">
<Project>{F6EDA1F3-3DCD-43F4-8A90-E32DA70C8227}</Project>
<Name>Common.Utils</Name>
</ProjectReference>
<ProjectReference Include="..\MpeCore\MpeCore.csproj">
<Project>{4458F642-6022-4A3F-996F-E8AA510FB7E8}</Project>
<Name>MpeCore</Name>
Expand Down
4 changes: 4 additions & 0 deletions mediaportal/MPE/MpeMaker/Sections/RequirementsSection.cs
Expand Up @@ -60,6 +60,10 @@ private void testToolStripMenuItem_Click(object sender, EventArgs e)
if (type != null)
{
var item = new DependencyItem(type.DisplayName) { MinVersion = type.Version(null), MaxVersion = type.Version(null) };
if (type is MpeCore.Classes.VersionProvider.MediaPortalVersion)
{
item.Message = string.Format("This version of {0} requires MediaPortal {1} or higher!", Package.GeneralInfo.Name, MediaPortal.Common.Utils.CompatibilityManager.MediaPortalReleaseForApiVersion(new Version(item.MinVersion.ToString())));
}
Package.Dependencies.Add(item);
list_versions.Items.Add(item);
}
Expand Down

0 comments on commit a568416

Please sign in to comment.