diff --git a/ColtPlugin/ColtPlugin.csproj b/ColtPlugin/ColtPlugin.csproj new file mode 100644 index 0000000..a230317 --- /dev/null +++ b/ColtPlugin/ColtPlugin.csproj @@ -0,0 +1,131 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {78101C02-E186-4954-B1DD-DEBB7905FAD8} + Library + Properties + ColtPlugin + ColtPlugin + + + + + 3.5 + v2.0 + + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + true + ..\..\..\FlashDevelop\Bin\Debug\Plugins\ + TRACE + prompt + 4 + + + pdbonly + true + ..\..\..\FlashDevelop\Bin\Debug\Plugins\ + TRACE + prompt + 4 + + + x86 + ..\..\..\FlashDevelop\Bin\Debug\Plugins\ + TRACE + true + + + x86 + ..\..\..\FlashDevelop\Bin\Debug\Plugins\ + TRACE + true + + + + + + + + + + + + + + + + + + + + + {61885F70-B4DC-4B44-852D-5D6D03F2A734} + PluginCore + False + + + {E57AC379-B0A0-4D6F-BFB2-88639B280205} + ProjectManager + + + + + Designer + + + + + False + Microsoft .NET Framework 4 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + + + \ No newline at end of file diff --git a/ColtPlugin/ColtPlugin.sln b/ColtPlugin/ColtPlugin.sln new file mode 100644 index 0000000..331c607 --- /dev/null +++ b/ColtPlugin/ColtPlugin.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C# Express 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlashDevelop", "..\..\..\FlashDevelop\FlashDevelop.csproj", "{EFD07485-9A64-4EEC-94E7-ACBD4DA5CA93}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginCore", "..\..\..\PluginCore\PluginCore.csproj", "{61885F70-B4DC-4B44-852D-5D6D03F2A734}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColtPlugin", "ColtPlugin.csproj", "{78101C02-E186-4954-B1DD-DEBB7905FAD8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectManager", "..\ProjectManager\ProjectManager.csproj", "{E57AC379-B0A0-4D6F-BFB2-88639B280205}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EFD07485-9A64-4EEC-94E7-ACBD4DA5CA93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EFD07485-9A64-4EEC-94E7-ACBD4DA5CA93}.Debug|x86.ActiveCfg = Debug|x86 + {EFD07485-9A64-4EEC-94E7-ACBD4DA5CA93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EFD07485-9A64-4EEC-94E7-ACBD4DA5CA93}.Release|x86.ActiveCfg = Release|x86 + {61885F70-B4DC-4B44-852D-5D6D03F2A734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61885F70-B4DC-4B44-852D-5D6D03F2A734}.Debug|x86.ActiveCfg = Debug|x86 + {61885F70-B4DC-4B44-852D-5D6D03F2A734}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61885F70-B4DC-4B44-852D-5D6D03F2A734}.Release|x86.ActiveCfg = Release|x86 + {78101C02-E186-4954-B1DD-DEBB7905FAD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78101C02-E186-4954-B1DD-DEBB7905FAD8}.Debug|x86.ActiveCfg = Debug|x86 + {78101C02-E186-4954-B1DD-DEBB7905FAD8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78101C02-E186-4954-B1DD-DEBB7905FAD8}.Release|x86.ActiveCfg = Release|x86 + {E57AC379-B0A0-4D6F-BFB2-88639B280205}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E57AC379-B0A0-4D6F-BFB2-88639B280205}.Debug|x86.ActiveCfg = Debug|x86 + {E57AC379-B0A0-4D6F-BFB2-88639B280205}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E57AC379-B0A0-4D6F-BFB2-88639B280205}.Release|x86.ActiveCfg = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ColtPlugin/PluginMain.cs b/ColtPlugin/PluginMain.cs new file mode 100644 index 0000000..905cbf7 --- /dev/null +++ b/ColtPlugin/PluginMain.cs @@ -0,0 +1,339 @@ +using System; +using System.IO; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; +using System.ComponentModel; +using System.Reflection; +using WeifenLuo.WinFormsUI.Docking; +using ColtPlugin.Resources; +using PluginCore.Localization; +using PluginCore.Utilities; +using PluginCore.Managers; +using PluginCore.Helpers; +using PluginCore; +using ProjectManager.Projects.AS3; + +namespace ColtPlugin +{ + public class PluginMain : IPlugin + { + private String pluginName = "ColtPlugin"; + private String pluginGuid = "12600B5B-D185-4171-A362-25C5F73548C6"; + private String pluginHelp = "makc3d.wordpress.com/about/"; + private String pluginDesc = "COLT FD Plugin"; + private String pluginAuth = "Makc"; // as if + private String buttonText = "Open in COLT"; + private String settingFilename; + private Settings settingObject; + private ToolStripMenuItem menuItem; + private ToolStripButton toolbarButton; + private Boolean active = false; + + #region Required Properties + + /// + /// Api level of the plugin + /// + public Int32 Api + { + get { return 1; } + } + + /// + /// Name of the plugin + /// + public String Name + { + get { return this.pluginName; } + } + + /// + /// GUID of the plugin + /// + public String Guid + { + get { return this.pluginGuid; } + } + + /// + /// Author of the plugin + /// + public String Author + { + get { return this.pluginAuth; } + } + + /// + /// Description of the plugin + /// + public String Description + { + get { return this.pluginDesc; } + } + + /// + /// Web address for help + /// + public String Help + { + get { return this.pluginHelp; } + } + + /// + /// Object that contains the settings + /// + [Browsable(false)] + public Object Settings + { + get { return this.settingObject; } + } + + #endregion + + #region Required Methods + + /// + /// Initializes the plugin + /// + public void Initialize() + { + this.InitBasics(); + this.LoadSettings(); + this.InitLocalization(); + this.AddEventHandlers(); + } + + /// + /// Disposes the plugin + /// + public void Dispose() + { + this.SaveSettings(); + } + + /// + /// Handles the incoming events + /// + public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority) + { + switch (e.Type) + { + case EventType.Command: + string cmd = (e as DataEvent).Action; + if (cmd == "ProjectManager.Project") + { + IProject project = PluginBase.CurrentProject; + Boolean as3projectIsOpen = (project != null) && (project.Language == "as3"); + if (this.menuItem != null) this.menuItem.Enabled = as3projectIsOpen; + if (this.toolbarButton != null) this.toolbarButton.Enabled = as3projectIsOpen; + // deactivate if project is closed + active &= as3projectIsOpen; + } + else if (cmd == "ASCompletion.ClassPath") + { + // apparently project setting changes; reopen already opened COLT project + if (active) OpenInCOLT(); + } + else if (cmd == "ProjectManager.Menu") + { + Object menu = (e as DataEvent).Data; + this.CreateMenuItem(menu as ToolStripMenuItem); + } + else if (cmd == "ProjectManager.ToolBar") + { + Object toolStrip = (e as DataEvent).Data; + this.CreateToolbarButton(toolStrip as ToolStrip); + } + break; + } + } + + #endregion + + #region Initialize() stuff + + /// + /// Initializes important variables + /// + public void InitBasics() + { + String dataPath = Path.Combine(PathHelper.DataDir, "ColtPlugin"); + if (!Directory.Exists(dataPath)) Directory.CreateDirectory(dataPath); + this.settingFilename = Path.Combine(dataPath, "Settings.fdb"); + } + + /// + /// Initializes the localization of the plugin + /// + public void InitLocalization() + { + LocaleVersion locale = PluginBase.MainForm.Settings.LocaleVersion; + switch (locale) + { + /* + case LocaleVersion.fi_FI : + // We have Finnish available... or not. :) + LocaleHelper.Initialize(LocaleVersion.fi_FI); + break; + */ + default : + // Plugins should default to English... + LocaleHelper.Initialize(LocaleVersion.en_US); + break; + } + this.pluginDesc = LocaleHelper.GetString("Info.Description"); + this.buttonText = LocaleHelper.GetString("Info.ButtonText"); + } + + /// + /// Adds the required event handlers + /// + public void AddEventHandlers() + { + // Set events you want to listen (combine as flags) + EventManager.AddEventHandler(this, EventType.Command); + } + + #endregion + + #region Menu items stuff + + private void CreateMenuItem(ToolStripMenuItem projectMenu) + { + this.menuItem = new ToolStripMenuItem(buttonText, GetImage("colt.png"), new EventHandler(this.OnClick), null); + projectMenu.DropDownItems.Add(this.menuItem); + } + + private void CreateToolbarButton(ToolStrip toolStrip) + { + this.toolbarButton = new ToolStripButton(); + this.toolbarButton.Image = GetImage("colt.png"); + this.toolbarButton.Text = buttonText; + this.toolbarButton.DisplayStyle = ToolStripItemDisplayStyle.Image; + this.toolbarButton.Click += new EventHandler(this.OnClick); + toolStrip.Items.Add(this.toolbarButton); + } + + /// + /// Gets embedded image from resources + /// + private static Image GetImage(String imageName) + { + imageName = "ColtPlugin.Resources." + imageName; + Assembly assembly = Assembly.GetExecutingAssembly(); + return new Bitmap(assembly.GetManifestResourceStream(imageName)); + } + + private void OnClick(Object sender, System.EventArgs e) + { + active = true; + OpenInCOLT(); + } + + #endregion + + #region Plugin settings stuff (reserved for future use :) + + /// + /// Loads the plugin settings + /// + public void LoadSettings() + { + this.settingObject = new Settings(); + if (!File.Exists(this.settingFilename)) this.SaveSettings(); + else + { + Object obj = ObjectSerializer.Deserialize(this.settingFilename, this.settingObject); + this.settingObject = (Settings)obj; + } + } + + /// + /// Saves the plugin settings + /// + public void SaveSettings() + { + ObjectSerializer.Serialize(this.settingFilename, this.settingObject); + } + + #endregion + + + /// + /// Opens the project in COLT + /// + private void OpenInCOLT() + { + // our options: parse project.ProjectPath (xml file) or use api + AS3Project project = (AS3Project)PluginBase.CurrentProject; + + + // Create COLT subfolder if does not exist yet + String coltFolderPath = project.GetAbsolutePath("colt"); + if (!Directory.Exists(coltFolderPath)) Directory.CreateDirectory(coltFolderPath); + + // Create COLT project with random name (if we'd update same file - are there file locks? how to reopen in colt?) + String coltFileName = project.GetAbsolutePath("colt/" + System.Guid.NewGuid() + ".colt"); + StreamWriter stream = File.CreateText(coltFileName); + + + // Write current project settings there + stream.WriteLine("#Generated by FD plugin"); + + stream.WriteLine("name=" + project.Name); + + MxmlcOptions options = project.CompilerOptions; + String libraryPaths = ""; + foreach (String libraryPath in options.LibraryPaths) + libraryPaths += EscapeForCOLT(project.GetAbsolutePath(libraryPath)) + ";"; + stream.WriteLine("libraryPaths=" + libraryPaths); + + stream.WriteLine("clearMessages=true"); + + stream.WriteLine("targetPlayerVersion=" + project.MovieOptions.Version + ".0"); + + stream.WriteLine("mainClass=" + EscapeForCOLT(project.GetAbsolutePath(project.CompileTargets[0]))); + + stream.WriteLine("maxLoopIterations=10000"); + + stream.WriteLine("flexSDKPath=" + EscapeForCOLT(project.CurrentSDK)); + + stream.WriteLine("liveMethods=annotated"); + + // todo: add fd generated config here, -load-config+=... + //stream.WriteLine("compilerOptions=-swf-version\=13"); + + stream.WriteLine("target=SWF"); // use project.MovieOptions.Platform switch ?? + + String outputPath = project.OutputPath; + // fixme: colt does not take paths atm + int lastSlash = outputPath.LastIndexOf(@"\"); + if (lastSlash > -1) outputPath = outputPath.Substring(lastSlash + 1); + stream.WriteLine("outputFileName=" + outputPath); + + stream.WriteLine("useDefaultSDKConfiguration=true"); + + String sourcePaths = ""; + foreach (String sourcePath in project.SourcePaths) + sourcePaths += EscapeForCOLT(project.GetAbsolutePath(sourcePath)) + ";"; + stream.WriteLine("sourcePaths=" + sourcePaths); + + stream.Close(); + + // Open it with default app (COLT) + Process.Start(coltFileName); + /* seems to be same shit ?? + ProcessStartInfo psi = new ProcessStartInfo(coltFileName); + psi.UseShellExecute = true; + Process.Start(psi); */ + } + + private String EscapeForCOLT(String path) + { + // some standard escape ?? + return path.Replace(@"\", @"\\").Replace(":", @"\:").Replace("=", @"\="); + } + } + +} diff --git a/ColtPlugin/Properties/AssemblyInfo.cs b/ColtPlugin/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6928f8a --- /dev/null +++ b/ColtPlugin/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("ColtPlugin")] +[assembly: AssemblyDescription("COLT Plugin For FlashDevelop")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("CodeOrchestra.com")] +[assembly: AssemblyProduct("ColtPlugin")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.0.*")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/ColtPlugin/Resources/LocaleHelper.cs b/ColtPlugin/Resources/LocaleHelper.cs new file mode 100644 index 0000000..dd7df95 --- /dev/null +++ b/ColtPlugin/Resources/LocaleHelper.cs @@ -0,0 +1,34 @@ +using System; +using System.Text; +using System.Resources; +using System.Reflection; +using System.Collections.Generic; +using PluginCore.Localization; +using PluginCore; + +namespace ColtPlugin.Resources +{ + class LocaleHelper + { + private static ResourceManager resources = null; + + /// + /// Initializes the localization of the plugin + /// + public static void Initialize(LocaleVersion locale) + { + String path = "ColtPlugin.Resources." + locale.ToString(); + resources = new ResourceManager(path, Assembly.GetExecutingAssembly()); + } + + /// + /// Loads a string from the internal resources + /// + public static String GetString(String identifier) + { + return resources.GetString(identifier); + } + + } + +} diff --git a/ColtPlugin/Resources/colt.png b/ColtPlugin/Resources/colt.png new file mode 100644 index 0000000..3957016 Binary files /dev/null and b/ColtPlugin/Resources/colt.png differ diff --git a/ColtPlugin/Resources/en_US.resX b/ColtPlugin/Resources/en_US.resX new file mode 100644 index 0000000..7ecc2a0 --- /dev/null +++ b/ColtPlugin/Resources/en_US.resX @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Open in COLT + + + COLT FlashDevelop Plugin + + \ No newline at end of file diff --git a/ColtPlugin/Settings.cs b/ColtPlugin/Settings.cs new file mode 100644 index 0000000..63b7c14 --- /dev/null +++ b/ColtPlugin/Settings.cs @@ -0,0 +1,48 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Windows.Forms; +using System.Text; + +namespace ColtPlugin +{ + [Serializable] + public class Settings + { + private Int32 sampleNumber = 69; + private String sampleText = "This is a sample plugin."; + private Keys sampleShortcut = Keys.Control | Keys.F1; + + /// + /// Get and sets the sampleText + /// + [Description("A sample string setting."), DefaultValue("This is a sample plugin.")] + public String SampleText + { + get { return this.sampleText; } + set { this.sampleText = value; } + } + + /// + /// Get and sets the sampleNumber + /// + [Description("A sample integer setting."), DefaultValue(69)] + public Int32 SampleNumber + { + get { return this.sampleNumber; } + set { this.sampleNumber = value; } + } + + /// + /// Get and sets the sampleShortcut + /// + [Description("A sample shortcut setting."), DefaultValue(Keys.Control | Keys.F1)] + public Keys SampleShortcut + { + get { return this.sampleShortcut; } + set { this.sampleShortcut = value; } + } + + } + +} diff --git a/ColtPlugin/obj/Debug/ColtPlugin.dll b/ColtPlugin/obj/Debug/ColtPlugin.dll new file mode 100644 index 0000000..5248e8a Binary files /dev/null and b/ColtPlugin/obj/Debug/ColtPlugin.dll differ