Skip to content

Commit

Permalink
Centralize platform data for easier updating...
Browse files Browse the repository at this point in the history
  • Loading branch information
Meychi committed Feb 8, 2014
1 parent 1fbe3e9 commit 73e7867
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 57 deletions.
2 changes: 1 addition & 1 deletion External/Plugins/ProjectManager/Actions/ProjectActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void UpdateASCompletion(IMainForm mainForm, Project project)
minorVersion = project.MovieOptions.MinorVersion;
if (project.MovieOptions.Platform == AS3MovieOptions.AIR_PLATFORM
|| project.MovieOptions.Platform == AS3MovieOptions.AIR_MOBILE_PLATFORM)
AS3Project.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
PlatformData.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);

// add project classpaths
foreach (string cp in project.AbsoluteClasspaths)
Expand Down
20 changes: 12 additions & 8 deletions External/Plugins/ProjectManager/Projects/AS3/AS3MovieOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using PluginCore;

namespace ProjectManager.Projects.AS3
{
Expand Down Expand Up @@ -32,9 +33,9 @@ public override string[] TargetVersions(string platform)
switch (platform)
{
case CUSTOM_PLATFORM: return new string[] { "0.0" };
case AIR_MOBILE_PLATFORM: return new string[] { "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0" };
case AIR_PLATFORM: return new string[] { "1.5", "2.0", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0" };
default: return new string[] { "9.0", "10.0", "10.1", "10.2", "10.3", "11.0", "11.1", "11.2", "11.3", "11.4", "11.5", "11.6", "11.7", "11.8", "11.9", "12.0" };
case AIR_MOBILE_PLATFORM: return PlatformData.AIR_MOBILE_VERSIONS;
case AIR_PLATFORM: return PlatformData.AIR_VERSIONS;
default: return PlatformData.FLASH_VERSIONS;
}
}

Expand All @@ -43,9 +44,9 @@ public override string DefaultVersion(string platform)
switch (platform)
{
case CUSTOM_PLATFORM: return "0.0";
case AIR_PLATFORM: return "4.0";
case AIR_MOBILE_PLATFORM: return "4.0";
default: return "12.0";
case AIR_PLATFORM: return PlatformData.DEFAULT_AIR_VERSION;
case AIR_MOBILE_PLATFORM: return PlatformData.DEFAULT_AIR_MOBILE_VERSION;
default: return PlatformData.DEFAULT_FLASH_VERSION;
}
}

Expand Down Expand Up @@ -73,12 +74,15 @@ public string GetSWFVersion()
if (Platform != FLASHPLAYER_PLATFORM) return null;
return GetSWFVersion(Version);
}

public string GetSWFVersion(string version)
{
int index = Array.IndexOf(TargetVersions(FLASHPLAYER_PLATFORM), version);
if (index < 0) return null;
string[] versions = new string[] { "9", "10", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" };
return versions[index];
return PlatformData.SWF_VERSIONS[index];
}

}

}

33 changes: 2 additions & 31 deletions External/Plugins/ProjectManager/Projects/AS3/AS3Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,36 +267,7 @@ private string[] GetLibraryPaths(SwfAssetMode mode)

#endregion

static public string GuessFlashPlayerForAIR(string version)
{
string[] p = (version ?? "").Split('.');
int majorVersion = 10;
int minorVersion = 0;
if (p.Length > 0) int.TryParse(p[0], out majorVersion);
if (p.Length > 1) int.TryParse(p[1], out minorVersion);
GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
return majorVersion + "." + minorVersion;
}

static public void GuessFlashPlayerForAIR(ref int majorVersion, ref int minorVersion)
{
double v = majorVersion + (double)minorVersion / 10;
if (v < 2) { majorVersion = 9; minorVersion = 0; }
else if (v < 2.5) { majorVersion = 10; minorVersion = 0; }
else if (v < 2.6) { majorVersion = 10; minorVersion = 1; }
else if (v < 2.7) { majorVersion = 10; minorVersion = 2; }
else if (v < 3.0) { majorVersion = 10; minorVersion = 3; }
else if (v < 3.1) { majorVersion = 11; minorVersion = 0; }
else if (v < 3.2) { majorVersion = 11; minorVersion = 1; }
else if (v < 3.3) { majorVersion = 11; minorVersion = 2; }
else if (v < 3.4) { majorVersion = 11; minorVersion = 3; }
else if (v < 3.5) { majorVersion = 11; minorVersion = 4; }
else if (v < 3.6) { majorVersion = 11; minorVersion = 5; }
else if (v < 3.7) { majorVersion = 11; minorVersion = 6; }
else if (v < 3.8) { majorVersion = 11; minorVersion = 7; }
else if (v < 3.9) { majorVersion = 11; minorVersion = 8; }
else if (v < 4.0) { majorVersion = 11; minorVersion = 9; }
else { majorVersion = 12; minorVersion = 0; }
}
}

}

19 changes: 9 additions & 10 deletions External/Plugins/ProjectManager/Projects/Haxe/HaxeMovieOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using PluginCore;

namespace ProjectManager.Projects.Haxe
{
Expand All @@ -17,8 +18,6 @@ public class HaxeMovieOptions : MovieOptions
public const string NME_PLATFORM = "NME";
public const string CSHARP_PLATFORM = "C#";
public const string JAVA_PLATFORM = "Java";
public static string[] NME_TARGETS = new string[] {
"flash", "html5", "windows", "neko", "android", "webos", "blackberry" };

public HaxeMovieOptions()
{
Expand Down Expand Up @@ -52,10 +51,10 @@ public override string[] TargetVersions(string platform)
{
switch (platform)
{
case AIR_PLATFORM: return new string[] { "1.5", "2.0", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0" };
case AIR_MOBILE_PLATFORM: return new string[] { "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0" };
case FLASHPLAYER_PLATFORM: return new string[] { "6.0", "7.0", "8.0", "9.0", "10.0", "10.1", "10.2", "10.3", "11.0", "11.1", "11.2", "11.3", "11.4", "11.5", "11.6", "11.7", "11.8", "11.9", "12.0" };
case NME_PLATFORM: return new string[] { "3.0" };
case AIR_PLATFORM: return PlatformData.AIR_VERSIONS;
case AIR_MOBILE_PLATFORM: return PlatformData.AIR_MOBILE_VERSIONS;
case FLASHPLAYER_PLATFORM: return PlatformData.FLASH_VERSIONS;
case NME_PLATFORM: return PlatformData.NME_VERSIONS;
default: return new string[] { "1.0" };
}
}
Expand All @@ -64,10 +63,10 @@ public override string DefaultVersion(string platform)
{
switch (platform)
{
case AIR_PLATFORM: return "4.0";
case AIR_MOBILE_PLATFORM: return "4.0";
case FLASHPLAYER_PLATFORM: return "12.0";
case NME_PLATFORM: return "3.0";
case AIR_PLATFORM: return PlatformData.DEFAULT_AIR_VERSION;
case AIR_MOBILE_PLATFORM: return PlatformData.DEFAULT_AIR_MOBILE_VERSION;
case FLASHPLAYER_PLATFORM: return PlatformData.DEFAULT_FLASH_VERSION;
case NME_PLATFORM: return PlatformData.DEFAULT_NME_VERSION;
default: return "1.0";
}
}
Expand Down
8 changes: 4 additions & 4 deletions External/Plugins/ProjectManager/Projects/Haxe/HaxeProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Windows.Forms;
using System.Text.RegularExpressions;
using ProjectManager.Projects.AS3;
using PluginCore;

namespace ProjectManager.Projects.Haxe
{
Expand All @@ -15,8 +16,7 @@ public class HaxeProject : Project

protected string[] rawHXML;

public HaxeProject(string path)
: base(path, new HaxeOptions())
public HaxeProject(string path) : base(path, new HaxeOptions())
{
movieOptions = new HaxeMovieOptions();
}
Expand Down Expand Up @@ -261,7 +261,7 @@ public string[] BuildHXML(string[] paths, string outfile, bool release )

if (MovieOptions.Platform == HaxeMovieOptions.AIR_PLATFORM
|| MovieOptions.Platform == HaxeMovieOptions.AIR_MOBILE_PLATFORM)
AS3Project.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
PlatformData.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
if (movieOptions.Platform == HaxeMovieOptions.NME_PLATFORM)
HaxeProject.GuessFlashPlayerForNME(ref majorVersion, ref minorVersion);

Expand Down Expand Up @@ -483,7 +483,7 @@ private void ParseHXML(string[] raw)

if (MovieOptions.Platform == HaxeMovieOptions.NME_PLATFORM)
{
MovieOptions.TargetBuildTypes = HaxeMovieOptions.NME_TARGETS;
MovieOptions.TargetBuildTypes = PlatformData.NME_TARGETS;
if (TestMovieBehavior == TestMovieBehavior.Unknown)
TestMovieBehavior = TestMovieBehavior.Custom;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using PluginCore;

namespace ProjectManager.Projects.Haxe
{
Expand All @@ -22,7 +23,7 @@ public HaxeProjectReader(string filename)
protected override void PostProcess()
{
if (project.MovieOptions.Platform == HaxeMovieOptions.NME_PLATFORM)
project.MovieOptions.TargetBuildTypes = HaxeMovieOptions.NME_TARGETS;
project.MovieOptions.TargetBuildTypes = PlatformData.NME_TARGETS;

if (version > 1)
{
Expand Down
1 change: 0 additions & 1 deletion FlashDevelop/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ private void MainFormLoaded(Object sender, EventArgs e)
private Boolean closeAllCanceled = false;
private Boolean restartRequested = false;
private Boolean refreshConfig = false;
private Boolean silentInstall = false;
private Boolean closingAll = false;

/* Singleton */
Expand Down
1 change: 1 addition & 0 deletions PluginCore/PluginCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
<Compile Include="PluginCore\Bridge\BridgeClient.cs" />
<Compile Include="PluginCore\Bridge\ServerSocket.cs" />
<Compile Include="PluginCore\Bridge\WatcherEx.cs" />
<Compile Include="PluginCore\PlatformData.cs" />
<Compile Include="PluginCore\Utilities\CryptoClasses.cs" />
<Compile Include="PluginCore\Utilities\ImageKonverter.cs" />
<Compile Include="PluginCore\Utilities\LogicalComparer.cs" />
Expand Down
63 changes: 63 additions & 0 deletions PluginCore/PluginCore/PlatformData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Text;
using System.Collections.Generic;

namespace PluginCore
{
// When updating, update also AirProperties plugin!

public class PlatformData
{
public static String DEFAULT_NME_VERSION = "3.0";
public static String DEFAULT_AIR_VERSION = "4.0";
public static String DEFAULT_AIR_MOBILE_VERSION = "4.0";
public static String DEFAULT_FLASH_VERSION = "12.0";
public static String[] AIR_VERSIONS = new String[] { "1.5", "2.0", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0" };
public static String[] AIR_MOBILE_VERSIONS = new String[] { "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0" };
public static String[] FLASH_VERSIONS = new String[] { "9.0", "10.0", "10.1", "10.2", "10.3", "11.0", "11.1", "11.2", "11.3", "11.4", "11.5", "11.6", "11.7", "11.8", "11.9", "12.0" };
public static String[] SWF_VERSIONS = new String[] { "9", "10", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" };
public static String[] NME_TARGETS = new String[] { "flash", "html5", "windows", "neko", "android", "webos", "blackberry" };
public static String[] NME_VERSIONS = new String[] { "3.0" };

/// <summary>
///
/// </summary>
public static String GuessFlashPlayerForAIR(String version)
{
Int32 majorVersion = 10;
Int32 minorVersion = 0;
String[] p = (version ?? "").Split('.');
if (p.Length > 0) Int32.TryParse(p[0], out majorVersion);
if (p.Length > 1) Int32.TryParse(p[1], out minorVersion);
GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
return majorVersion + "." + minorVersion;
}

/// <summary>
///
/// </summary>
public static void GuessFlashPlayerForAIR(ref Int32 majorVersion, ref Int32 minorVersion)
{
Double v = majorVersion + (Double)minorVersion / 10;
if (v < 2) { majorVersion = 9; minorVersion = 0; }
else if (v < 2.5) { majorVersion = 10; minorVersion = 0; }
else if (v < 2.6) { majorVersion = 10; minorVersion = 1; }
else if (v < 2.7) { majorVersion = 10; minorVersion = 2; }
else if (v < 3.0) { majorVersion = 10; minorVersion = 3; }
else if (v < 3.1) { majorVersion = 11; minorVersion = 0; }
else if (v < 3.2) { majorVersion = 11; minorVersion = 1; }
else if (v < 3.3) { majorVersion = 11; minorVersion = 2; }
else if (v < 3.4) { majorVersion = 11; minorVersion = 3; }
else if (v < 3.5) { majorVersion = 11; minorVersion = 4; }
else if (v < 3.6) { majorVersion = 11; minorVersion = 5; }
else if (v < 3.7) { majorVersion = 11; minorVersion = 6; }
else if (v < 3.8) { majorVersion = 11; minorVersion = 7; }
else if (v < 3.9) { majorVersion = 11; minorVersion = 8; }
else if (v < 4.0) { majorVersion = 11; minorVersion = 9; }
else { majorVersion = 12; minorVersion = 0; }
}

}

}

0 comments on commit 73e7867

Please sign in to comment.