Beispiel #1
0
        public FormRelease(ProjectInfo projectInfo)
        {
            InitializeComponent();

            m_project = projectInfo;

            m_loveVersion         = new LoveVersion();
            m_loveVersion.Type    = projectInfo.m_type;
            m_loveVersion.Version = LoveVersion.GetInstalledVersion(projectInfo.m_type);

            m_tasks = new List <Task>();

            if (File.Exists(GetVersionPath("win32")))
            {
                m_loveVersion.Download_Win32 = "..";
            }
            if (File.Exists(GetVersionPath("win64")))
            {
                m_loveVersion.Download_Win64 = "..";
            }
            if (File.Exists(GetVersionPath("macos")))
            {
                m_loveVersion.Download_MacOS = "..";
            }

            if (!m_loveVersion.HasAllDownloads())
            {
                labelStatus.Text = "Finding version downloads for " + m_loveVersion.Version + "...";

                var wc = new WebClient();
                wc.DownloadStringCompleted += (o, e) => {
                    if (e.Error != null)
                    {
                        MessageBox.Show(this, "There was a problem fetching the Love2D downloads list from Github: " + e.Error.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Close();
                        return;
                    }

                    var arrValues = (ArrayList)Json.JsonDecode(e.Result);
                    foreach (Hashtable value in arrValues)
                    {
                        var version = (string)value["tag_name"];
                        var assets  = (ArrayList)value["assets"];

                        if (version != m_loveVersion.Version)
                        {
                            continue;
                        }

                        foreach (Hashtable asset in assets)
                        {
                            var contentType = (string)asset["content_type"];
                            if (contentType != "application/zip" && contentType != "application/x-zip-compressed")
                            {
                                continue;
                            }

                            var filename = (string)asset["name"];
                            var platform = "";

                            if (m_loveVersion.Type == LoveType.Love2D)
                            {
                                // "love-11.3-macos.zip"
                                // "love-11.3-win32.zip"
                                // "love-11.3-win64.zip"
                                var matchVersion = Regex.Match(filename, @"^love-[^\-]+-([^\.]+)\.zip$");
                                if (!matchVersion.Success)
                                {
                                    continue;
                                }

                                platform = matchVersion.Groups[1].Value;
                            }
                            else if (m_loveVersion.Type == LoveType.Lovr)
                            {
                                // "lovr-v0.12.0-windows-32.zip"
                                // "lovr-v0.13.0-windows-64.zip"
                                var matchVersion = Regex.Match(filename, @"^lovr-[^\-]+-([^\.]+)\.zip$");
                                if (!matchVersion.Success)
                                {
                                    continue;
                                }

                                platform = matchVersion.Groups[1].Value;
                            }

                            var url = (string)asset["browser_download_url"];

#if DEBUG
                            Console.WriteLine("Possible version: {0} (platform {1})", filename, platform);
#endif

                            if (platform == "win64" || platform == "windows-64")
                            {
                                m_loveVersion.Download_Win64 = url;
                            }
                            else if (platform == "win32" || platform == "windows-32")
                            {
                                m_loveVersion.Download_Win32 = url;
                            }
                            else if (platform == "macos")
                            {
                                m_loveVersion.Download_MacOS = url;
                            }
                        }

                        FoundVersions(true);
                    }
                };
                wc.Headers[HttpRequestHeader.UserAgent] = "Loveman / nimble.tools";

                switch (m_loveVersion.Type)
                {
                case LoveType.Love2D: wc.DownloadStringAsync(new Uri(URL_LOVE_DOWNLOADS)); break;

                case LoveType.Lovr: wc.DownloadStringAsync(new Uri(URL_LOVR_DOWNLOADS)); break;
                }
            }

            Interface.InterfaceTheme(this);
        }
Beispiel #2
0
        public ProjectInfo(string path)
        {
            m_path = path.Trim('/', '\\');

            var moonFiles = Directory.GetFiles(m_path, "*.moon", SearchOption.AllDirectories);

            m_moonscript = (moonFiles.Length > 0);

            var infoPath = GetInfoPath();

            if (File.Exists(infoPath))
            {
                Hashtable obj = (Hashtable)Json.JsonDecode(File.ReadAllText(infoPath));

                if (obj.ContainsKey("name"))
                {
                    m_name = (string)obj["name"];
                }
                if (obj.ContainsKey("author"))
                {
                    m_author = (string)obj["author"];
                }
                if (obj.ContainsKey("bundle-identifier"))
                {
                    m_bundleIdentifier = (string)obj["bundle-identifier"];
                }
                if (obj.ContainsKey("type"))
                {
                    m_type = (LoveType)Enum.Parse(typeof(LoveType), (string)obj["type"], true);
                }

                if (obj.ContainsKey("love-version"))
                {
                    m_loveVersion = (string)obj["love-version"];
                }
                if (obj.ContainsKey("icon-file"))
                {
                    m_iconFile = (string)obj["icon-file"];
                }
            }

            if (m_name == "")
            {
                m_name = Path.GetFileName(m_path);
            }

            if (m_author == "")
            {
                m_author = "Unknown";
            }

            if (m_bundleIdentifier == "")
            {
                m_bundleIdentifier = "com.example.game";
            }

            if (m_loveVersion == "")
            {
                m_loveVersion = LoveVersion.GetInstalledVersion(m_type);
            }
        }