示例#1
0
        public FormProject(ProjectInfo project)
        {
            InitializeComponent();

            m_project = project;

            UpdateInfo();
            ShowInfoSave(false);

            m_watcher = new FileSystemWatcher(m_project.GetPath(), "*.moon");
            m_watcher.IncludeSubdirectories = true;
            m_watcher.Created            += MoonWatcher_Created;
            m_watcher.Changed            += MoonWatcher_Changed;
            m_watcher.Deleted            += MoonWatcher_Deleted;
            m_watcher.Renamed            += MoonWatcher_Renamed;
            m_watcher.EnableRaisingEvents = true;

            m_watchQueue = new List <MoonQueuedItem>();

            m_watchTimer          = new Timer();
            m_watchTimer.Interval = 100;
            m_watchTimer.Tick    += WatchTimer_Tick;
            m_watchTimer.Enabled  = true;

            // This can fail if Path_Editor is an invalid value
            try {
                var editorExe = Path.GetFileName(Settings.Default.Path_Editor);

                m_hasSublimeText      = (editorExe == "sublime_text.exe");
                buttonSublime.Visible = m_hasSublimeText;

                m_hasVSCode        = (editorExe == "Code.exe" || editorExe == "VSCodium.exe");
                buttonCode.Visible = m_hasVSCode;

                m_hasAtom          = (editorExe == "atom.exe");
                buttonAtom.Visible = m_hasAtom;
            } catch { }

            try {
                m_hasSublimeMerge = (
                    Settings.Default.Path_SublimeMerge != "" &&
                    File.Exists(Path.Combine(Settings.Default.Path_SublimeMerge, "smerge.exe"))
                    );
                buttonSublimeMerge.Visible = m_hasSublimeMerge;
            } catch { }

            Interface.InterfaceTheme(this);

            flowButtons.BorderStyle = BorderStyle.None;
        }
示例#2
0
        private void BeginLoveBuild()
        {
            m_tasks.Add(new Task(() => {
                var useExtension = GetZipExtension();

                Invoke(new Action(() => labelBuildStatus.Text = "Building " + useExtension + " file"));

                var projectPath    = m_project.GetPath();
                var ignoreFilePath = Path.Combine(projectPath, ".lovemanignore");
                var releasePath    = Path.Combine(projectPath, "Release");
                var loveFilePath   = Path.Combine(releasePath, "Game" + useExtension);

                // Create Release folder if it doesn't exist yet
                if (!Directory.Exists(releasePath))
                {
                    Directory.CreateDirectory(releasePath);
                }

                // Delete any existing .love file if it exists
                if (File.Exists(loveFilePath))
                {
                    File.Delete(loveFilePath);
                }

                // Load .lovemanignore file
                var ignoredPaths = new List <string>();
                if (File.Exists(ignoreFilePath))
                {
                    using (var fs = File.OpenRead(ignoreFilePath)) {
                        using (var reader = new StreamReader(fs)) {
                            while (!reader.EndOfStream)
                            {
                                string line      = reader.ReadLine().Trim();
                                int commentIndex = line.IndexOf('#');
                                if (commentIndex != -1)
                                {
                                    line = line.Substring(0, commentIndex);
                                }
                                line = line.Trim();
                                if (line == "")
                                {
                                    continue;
                                }
                                ignoredPaths.Add(line.Replace(".", "\\.").Replace("*", ".*"));
                            }
                        }
                    }
                }

                // Create zip
                using (var fs = File.Create(loveFilePath)) {
                    using (var zip = new ZipArchive(fs, ZipArchiveMode.Create)) {
                        // Find all files
                        var files = Directory.GetFiles(projectPath, "*", SearchOption.AllDirectories);
                        foreach (var file in files)
                        {
                            var relPath = file.Substring(projectPath.Length + 1);

                            // Filter out files we don't want to distribute
                            if (relPath.StartsWith("Release\\"))
                            {
                                continue;
                            }
                            if (relPath.StartsWith(".git\\"))
                            {
                                continue;
                            }
                            if (Path.GetExtension(relPath) == ".moon")
                            {
                                continue;
                            }
                            if (relPath.EndsWith(".gitignore"))
                            {
                                continue;
                            }
                            if (relPath == "loveman.json")
                            {
                                continue;
                            }
                            if (relPath == "LovemanIcon.png")
                            {
                                continue;
                            }
                            if (relPath == ".lovemanignore")
                            {
                                continue;
                            }

                            // Filter out files from .lovemanignore file
                            bool filterPattern = false;
                            foreach (var pattern in ignoredPaths)
                            {
                                if (Regex.Match(relPath, pattern).Success)
                                {
                                    filterPattern = true;
                                    break;
                                }
                            }
                            if (filterPattern)
                            {
                                continue;
                            }

                            // Write file to zip
                            using (var ffs = File.OpenRead(file)) {
                                var newEntry = zip.CreateEntry(relPath.Replace('\\', '/'));
                                using (var entryStream = newEntry.Open()) {
                                    var buffer = new byte[1024];
                                    while (true)
                                    {
                                        int bytesRead = ffs.Read(buffer, 0, buffer.Length);
                                        if (bytesRead > 0)
                                        {
                                            entryStream.Write(buffer, 0, bytesRead);
                                        }
                                        if (bytesRead < buffer.Length)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }));
        }
示例#3
0
        private void StartGame(bool console)
        {
            var startInfo = new ProcessStartInfo();

            if (m_project.m_type == LoveType.Love2D)
            {
                startInfo.FileName = Path.Combine(Settings.Default.Path_Love, "love.exe");
                if (console)
                {
                    startInfo.FileName = Path.Combine(Settings.Default.Path_Love, "lovec.exe");
                }
            }
            else if (m_project.m_type == LoveType.Lovr)
            {
                startInfo.FileName = Path.Combine(Settings.Default.Path_Lovr, "lovr.exe");
                if (console)
                {
                    startInfo.Arguments = "--console";
                }
            }

            startInfo.Arguments       += " \"" + m_project.GetPath() + "\"";
            startInfo.WorkingDirectory = m_project.GetPath();
            Process.Start(startInfo);
        }