Skip to content

Commit e8e1170

Browse files
committed
AppMan integration improvements...
1 parent ce91a67 commit e8e1170

9 files changed

Lines changed: 121 additions & 21 deletions

File tree

External/Plugins/AS2Context/AS2Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public bool FixPackageAutomatically
227227
private bool useMtascIntrinsic = DEFAULT_USEMTASC;
228228
private string mtascCheckParameters = DEFAULT_MTASCCHECKPARAMS;
229229

230-
[DisplayName("Use Mtasc Intrinsics")]
230+
[DisplayName("Use MTASC Intrinsics")]
231231
[LocalizedCategory("ASCompletion.Category.Language"), LocalizedDescription("AS2Context.Description.UseMtascIntrinsic"), DefaultValue(DEFAULT_USEMTASC)]
232232
public bool UseMtascIntrinsic
233233
{

External/Plugins/AS2Context/PluginMain.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using PluginCore.Helpers;
99
using PluginCore;
1010
using System.Text.RegularExpressions;
11+
using System.Collections.Generic;
1112

1213
namespace AS2Context
1314
{
@@ -172,16 +173,31 @@ private void ValidateSettings()
172173
{
173174
if (settingObject.InstalledSDKs == null || settingObject.InstalledSDKs.Length == 0)
174175
{
176+
List<InstalledSDK> allSdks = new List<InstalledSDK>();
175177
string includedSDK = "Tools\\mtasc";
176178
if (Directory.Exists(PathHelper.ResolvePath(includedSDK)))
177179
{
178180
InstalledSDK sdk = new InstalledSDK(this);
179181
sdk.Path = includedSDK;
180-
settingObject.InstalledSDKs = new InstalledSDK[] { sdk };
182+
allSdks.Add(sdk);
181183
}
184+
string appManDir = Path.Combine(PathHelper.BaseDir, @"Data\AppMan\Archive\mtasc");
185+
if (Directory.Exists(appManDir))
186+
{
187+
string[] versionDirs = Directory.GetDirectories(appManDir);
188+
foreach (string versionDir in versionDirs)
189+
{
190+
if (Directory.Exists(versionDir))
191+
{
192+
InstalledSDK sdk = new InstalledSDK(this);
193+
sdk.Path = versionDir;
194+
allSdks.Add(sdk);
195+
}
196+
}
197+
}
198+
settingObject.InstalledSDKs = allSdks.ToArray();
182199
}
183200
else foreach (InstalledSDK sdk in settingObject.InstalledSDKs) ValidateSDK(sdk);
184-
185201
settingObject.OnClasspathChanged += SettingObjectOnClasspathChanged;
186202
}
187203

@@ -239,12 +255,12 @@ public bool ValidateSDK(InstalledSDK sdk)
239255
if (mVer.Success)
240256
{
241257
sdk.Version = mVer.Groups[1].Value;
242-
sdk.Name = "Mtasc " + sdk.Version;
258+
sdk.Name = "MTASC " + sdk.Version;
243259
return true;
244260
}
245261
else ErrorManager.ShowInfo("Invalid changes.txt file:\n" + descriptor);
246262
}
247-
else ErrorManager.ShowInfo("No change.txt found:\n" + descriptor);
263+
else ErrorManager.ShowInfo("No changes.txt found:\n" + descriptor);
248264
return false;
249265
}
250266

External/Plugins/AS3Context/PluginMain.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,54 @@ private void ValidateSettings()
451451
sdk.Path = includedSDK;
452452
sdks.Add(sdk);
453453
}
454+
/* Resolve AppMan Flex SDKs */
455+
string appManDir = Path.Combine(PathHelper.BaseDir, @"Data\AppMan\Archive\flexsdk");
456+
if (Directory.Exists(appManDir))
457+
{
458+
string[] versionDirs = Directory.GetDirectories(appManDir);
459+
foreach (string versionDir in versionDirs)
460+
{
461+
if (Directory.Exists(versionDir))
462+
{
463+
sdk = new InstalledSDK(this);
464+
sdk.Path = versionDir;
465+
sdks.Add(sdk);
466+
}
467+
}
468+
}
469+
/* Resolve AppMan Flex+AIR SDKs */
470+
appManDir = Path.Combine(PathHelper.BaseDir, @"Data\AppMan\Archive\flexairsdk");
471+
if (Directory.Exists(appManDir))
472+
{
473+
string[] versionDirs = Directory.GetDirectories(appManDir);
474+
foreach (string versionDir in versionDirs)
475+
{
476+
if (Directory.Exists(versionDir))
477+
{
478+
sdk = new InstalledSDK(this);
479+
sdk.Path = versionDir;
480+
sdks.Add(sdk);
481+
}
482+
}
483+
}
484+
/* Resolve AppMan AIR SDKs */
485+
appManDir = Path.Combine(PathHelper.BaseDir, @"Data\AppMan\Archive\ascsdk");
486+
if (Directory.Exists(appManDir))
487+
{
488+
string[] versionDirs = Directory.GetDirectories(appManDir);
489+
foreach (string versionDir in versionDirs)
490+
{
491+
if (Directory.Exists(versionDir))
492+
{
493+
sdk = new InstalledSDK(this);
494+
sdk.Path = versionDir;
495+
sdks.Add(sdk);
496+
}
497+
}
498+
}
499+
//
500+
// TODO: Resolve Apache Flex SDK
501+
//
454502
if (settingObject.InstalledSDKs != null)
455503
{
456504
char[] slashes = new char[] { '/', '\\' };

External/Tools/ASDocGen/MainForm.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,14 @@ private String SettingDir
636636
if (!Directory.Exists(asDocGenDataDir)) Directory.CreateDirectory(asDocGenDataDir);
637637
return asDocGenDataDir;
638638
}
639-
else return this.AppDir;
639+
else
640+
{
641+
String fdPath = Path.Combine(this.AppDir, @"..\..\");
642+
fdPath = Path.GetFullPath(fdPath); /* Fix weird path */
643+
String asDocGenDataDir = Path.Combine(fdPath, @"Data\ASDocGen\");
644+
if (!Directory.Exists(asDocGenDataDir)) Directory.CreateDirectory(asDocGenDataDir);
645+
return asDocGenDataDir;
646+
}
640647
}
641648
}
642649

External/Tools/AppMan/MainForm.Designer.cs

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

External/Tools/AppMan/MainForm.cs

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,28 @@ private void InitializeSettings()
8989
else /* Defaults for FlashDevelop */
9090
{
9191
String local = Path.Combine(PathHelper.GetExeDirectory(), @"..\..\.local");
92+
local = Path.GetFullPath(local); /* Fix weird path */
9293
if (!File.Exists(local))
9394
{
9495
String userAppDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
95-
String appManDataDir = Path.Combine(userAppDir, @"FlashDevelop\Data\AppMan");
96+
String fdUserPath = Path.Combine(userAppDir, "FlashDevelop");
97+
String appManDataDir = Path.Combine(fdUserPath, @"Data\AppMan");
9698
PathHelper.ARCHIVE_DIR = Path.Combine(appManDataDir, "Archive");
9799
PathHelper.LOG_DIR = appManDataDir;
100+
this.notifyPaths = new String[1] { fdUserPath };
98101
}
102+
else
103+
{
104+
String fdPath = Path.Combine(PathHelper.GetExeDirectory(), @"..\..\");
105+
fdPath = Path.GetFullPath(fdPath); /* Fix weird path */
106+
PathHelper.ARCHIVE_DIR = Path.Combine(fdPath, @"Data\AppMan\Archive");
107+
PathHelper.LOG_DIR = Path.Combine(fdPath, @"Data\AppMan");
108+
this.notifyPaths = new String[1] { fdPath };
109+
}
110+
}
111+
if (!Directory.Exists(PathHelper.LOG_DIR))
112+
{
113+
Directory.CreateDirectory(PathHelper.LOG_DIR);
99114
}
100115
if (!Directory.Exists(PathHelper.ARCHIVE_DIR))
101116
{
@@ -165,7 +180,7 @@ private void MainFormClosed(Object sender, FormClosedEventArgs e)
165180
{
166181
try
167182
{
168-
if (!this.shouldNotify) return;
183+
if (!this.shouldNotify && this.notifyPaths == null) return;
169184
foreach (String nPath in this.notifyPaths)
170185
{
171186
try
@@ -441,14 +456,15 @@ private void AddToGroup(ListViewItem item)
441456
/// <summary>
442457
/// Creates a temporary file with the given extension.
443458
/// </summary>
444-
private String GetTempFileName(String file)
459+
private String GetTempFileName(String file, Boolean unique)
445460
{
446461
try
447462
{
448463
Int32 counter = 0;
449464
String tempDir = Path.GetTempPath();
450465
String fileName = Path.GetFileName(file);
451466
String tempFile = Path.Combine(tempDir, "appman_" + fileName);
467+
if (!unique) return tempFile;
452468
while (File.Exists(tempFile))
453469
{
454470
counter++;
@@ -596,7 +612,15 @@ private void DownloadNextFromQueue()
596612
this.fileQueue.Enqueue(file);
597613
}
598614
this.curFile = this.fileQueue.Dequeue();
599-
this.tempFile = this.GetTempFileName(this.curFile);
615+
this.tempFile = this.GetTempFileName(this.curFile, false);
616+
if (File.Exists(this.tempFile)) // Use already downloaded temp...
617+
{
618+
String idPath = Path.Combine(PathHelper.ARCHIVE_DIR, this.curEntry.Id);
619+
String vnPath = Path.Combine(idPath, this.curEntry.Version.ToLower());
620+
this.ExtractFile(this.tempFile, vnPath);
621+
return;
622+
}
623+
this.tempFile = this.GetTempFileName(this.curFile, true);
600624
this.webClient.DownloadFileAsync(new Uri(this.curFile), this.tempFile);
601625
this.statusLabel.Text = "Downloading: " + this.curFile;
602626
}
@@ -686,14 +710,6 @@ private void WorkerDoWork(Object sender, DoWorkEventArgs e)
686710
DialogHelper.ShowError("Error while extracting file: " + this.curFile + ".\nTrying to continue with the next item.");
687711
this.DownloadNextFromQueue();
688712
}
689-
finally /* Try to delete temp file if not executable */
690-
{
691-
if (!this.IsExecutable(this.curEntry))
692-
{
693-
try { File.Delete(this.tempFile); }
694-
catch { /* NO ERRORS*/ }
695-
}
696-
}
697713
}
698714

699715
/// <summary>
@@ -706,7 +722,16 @@ private void WorkerDoCompleted(Object sender, RunWorkerCompletedEventArgs e)
706722
if (this.fileQueue.Count > 0)
707723
{
708724
this.curFile = this.fileQueue.Dequeue();
709-
this.tempFile = this.GetTempFileName(this.curFile);
725+
this.tempFile = this.GetTempFileName(this.curFile, false);
726+
if (File.Exists(this.tempFile)) // Use already downloaded temp...
727+
{
728+
String idPath = Path.Combine(PathHelper.ARCHIVE_DIR, this.curEntry.Id);
729+
String vnPath = Path.Combine(idPath, this.curEntry.Version.ToLower());
730+
this.ExtractFile(this.tempFile, vnPath);
731+
this.bgWorker.Dispose();
732+
return;
733+
}
734+
this.tempFile = this.GetTempFileName(this.curFile, true);
710735
this.webClient.DownloadFileAsync(new Uri(this.curFile), this.tempFile);
711736
this.statusLabel.Text = "Downloading: " + this.curFile;
712737
}
512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

FlashDevelop/MainForm.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,13 @@ private void InitializeProperties()
689689
{
690690
try
691691
{
692+
String appman = Path.Combine(PathHelper.BaseDir, ".appman");
692693
String reconfig = Path.Combine(PathHelper.BaseDir, ".reconfig");
694+
if (File.Exists(appman))
695+
{
696+
File.Delete(appman);
697+
this.refreshConfig = true;
698+
}
693699
if (File.Exists(reconfig))
694700
{
695701
File.Delete(reconfig);

0 commit comments

Comments
 (0)