Skip to content

Commit 4d72c3d

Browse files
committed
Missing ProjectActions
Little API optimization
1 parent b786551 commit 4d72c3d

2 files changed

Lines changed: 33 additions & 25 deletions

File tree

External/Plugins/ProjectManager/Actions/ProjectActions.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,20 @@ public void UpdateASCompletion(IMainForm mainForm, Project project)
194194
{
195195
List<string> classPaths = new List<string>();
196196
List<string> hiddenPaths = new List<string>();
197-
int majorVersion = 0;
198-
int minorVersion = 0;
197+
string version;
199198
string platform = "";
200-
199+
201200
if (project != null)
202201
{
203202
BuildActions.GetCompilerPath(project); // refresh project's SDK
204203
project.UpdateVars(true);
205204

206205
// platform/version
207206
platform = project.MovieOptions.Platform;
208-
majorVersion = project.MovieOptions.MajorVersion;
209-
minorVersion = project.MovieOptions.MinorVersion;
210-
if (project.MovieOptions.Platform == AS3MovieOptions.AIR_PLATFORM
211-
|| project.MovieOptions.Platform == AS3MovieOptions.AIR_MOBILE_PLATFORM)
212-
PlatformData.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
207+
version = project.MovieOptions.Version;
208+
if (platform == AS3MovieOptions.AIR_PLATFORM
209+
|| platform == AS3MovieOptions.AIR_MOBILE_PLATFORM)
210+
version = PlatformData.ResolveFlashPlayerVersion(platform, version);
213211

214212
// add project classpaths
215213
foreach (string cp in project.AbsoluteClasspaths)
@@ -272,6 +270,11 @@ public void UpdateASCompletion(IMainForm mainForm, Project project)
272270
}
273271
}
274272
}
273+
else
274+
{
275+
var flashPlatform = PluginCore.PlatformData.PlatformTargets["Flash Player"];
276+
version = flashPlatform.LastVersion.Value;
277+
}
275278

276279
DataEvent de;
277280
Hashtable info = new Hashtable();
@@ -295,7 +298,7 @@ public void UpdateASCompletion(IMainForm mainForm, Project project)
295298
currentLang = project.Language;
296299

297300
info["platform"] = platform;
298-
info["version"] = majorVersion + "." + minorVersion;
301+
info["version"] = version;
299302
info["targetBuild"] = project.TargetBuild;
300303
info["lang"] = currentLang;
301304
info["classpath"] = classPaths.ToArray();

PluginCore/PluginCore/PlatformData.cs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ public class PlatformData
2828

2929
public static string ResolveFlashPlayerVersion(string otherPlatform, string version)
3030
{
31-
var otherTarget = PluginCore.PlatformData.PlatformTargets[otherPlatform];
3231
var flashTarget = PluginCore.PlatformData.PlatformTargets["Flash Player"];
33-
foreach (var otherVersion in otherTarget.Versions)
34-
if (otherVersion.Value == version)
35-
{
36-
foreach (var flashVersion in flashTarget.Versions)
37-
if (flashVersion.SwfVersion == otherVersion.SwfVersion) return flashVersion.Value;
38-
}
39-
// default to last
40-
return flashTarget.Versions[flashTarget.Versions.Count - 1].Value;
32+
if (PlatformTargets.ContainsKey(otherPlatform))
33+
{
34+
var otherTarget = PluginCore.PlatformData.PlatformTargets[otherPlatform];
35+
foreach (var otherVersion in otherTarget.Versions)
36+
if (otherVersion.Value == version)
37+
{
38+
foreach (var flashVersion in flashTarget.Versions)
39+
if (flashVersion.SwfVersion == otherVersion.SwfVersion) return flashVersion.Value;
40+
}
41+
}
42+
// default to last FP
43+
return flashTarget.LastVersion.Value;
4144
}
4245

4346
public static string ResolveSwfVersion(string platformName, string version)
@@ -46,7 +49,8 @@ public static string ResolveSwfVersion(string platformName, string version)
4649
foreach (var platformVersion in platform.Versions)
4750
if (platformVersion.Value == version)
4851
return platformVersion.SwfVersion;
49-
return platform.Versions[platform.Versions.Count - 1].SwfVersion;
52+
// default to last FP
53+
return platform.LastVersion.SwfVersion;
5054
}
5155

5256
#region platform config loading
@@ -81,13 +85,11 @@ private static void ParseLanguages(XmlNode languages)
8185
PlatformLanguages = new Dictionary<String, PlatformLanguage>();
8286
if (PlatformTargets == null || PlatformTargets.Count == 0)
8387
{
88+
var defaultVersion = new PlatformVersion { Value = "0.0" };
8489
var custom = new PlatformTarget {
8590
Name = "Custom",
86-
Versions = new List<PlatformVersion> {
87-
new PlatformVersion {
88-
Value = "0.0"
89-
}
90-
}
91+
Versions = new List<PlatformVersion> { defaultVersion },
92+
LastVersion = defaultVersion
9193
};
9294
PlatformTargets.Add(custom.Name, custom);
9395
return;
@@ -192,10 +194,12 @@ private static void ParsePlatforms(XmlNode platforms)
192194
PlatformTargets = new Dictionary<String, PlatformTarget>();
193195
foreach (XmlNode node in platforms.ChildNodes)
194196
{
197+
var versions = ParseVersions(node);
195198
var target = new PlatformTarget
196199
{
197200
Name = node.Attributes["name"].Value,
198-
Versions = ParseVersions(node),
201+
Versions = versions,
202+
LastVersion = versions[versions.Count - 1],
199203
RawData = node
200204
};
201205
PlatformTargets.Add(target.Name, target);
@@ -216,6 +220,7 @@ public class PlatformTarget
216220
{
217221
public string Name;
218222
public List<PlatformVersion> Versions;
223+
public PlatformVersion LastVersion;
219224
public XmlNode RawData;
220225
}
221226

0 commit comments

Comments
 (0)