public static void Init(pb_VersionInfo newVersion, string changelog) { pb_UpdateAvailable win = EditorWindow.GetWindow <pb_UpdateAvailable>(true, "ProBuilder Update Available", true); win.m_NewVersion = newVersion; win.m_NewChangelog = changelog; }
public static bool GetCurrent(out pb_VersionInfo version) { pb_AboutEntry about; if (!GetAboutEntry(out about)) { version = new pb_VersionInfo(); return(false); } version = pb_VersionInfo.FromString(about.version); return(true); }
/** * Extracts and formats the latest changelog entry into rich text. Also grabs the version. */ public static bool FormatChangelog(string raw, out pb_VersionInfo version, out string formatted_changes) { bool success = true; // get first version entry string[] split = Regex.Split(raw, "(?mi)^#\\s", RegexOptions.Multiline); // get the version info try { Match versionMatch = Regex.Match(split[1], @"(?<=^ProBuilder\s).[0-9]*\.[0-9]*\.[0-9]*[a-z][0-9]*"); version = pb_VersionInfo.FromString(versionMatch.Success ? versionMatch.Value : split[1].Split('\n')[0]); } catch { version = pb_VersionInfo.FromString("not found"); success = false; } try { StringBuilder sb = new StringBuilder(); string[] newLineSplit = split[1].Trim().Split('\n'); for (int i = 2; i < newLineSplit.Length; i++) { sb.AppendLine(newLineSplit[i]); } formatted_changes = sb.ToString(); formatted_changes = Regex.Replace(formatted_changes, "^-", "\u2022", RegexOptions.Multiline); formatted_changes = Regex.Replace(formatted_changes, @"(?<=^##\\s).*", "<size=16><b>${0}</b></size>", RegexOptions.Multiline); formatted_changes = Regex.Replace(formatted_changes, @"^##\ ", "", RegexOptions.Multiline); } catch { formatted_changes = ""; success = false; } return(success); }