private IEnumerator CheckForUpdates() { //PLog.Info("Checking for plugin updates..."); int updates = 0; foreach (Plugin plugin in Loader.plugins.Values) { try { bool has_update = plugin.check_for_updates(); if (has_update) { updates++; } //PLog.Info("Plugin[{0}] has_update = {1}", plugin.data.NAME, (has_update ? "TRUE" : "FALSE")); } catch (Exception ex) { SLog.Error(ex); } } if (updates <= 0) { this.Hide(); } else { this.Show(); } yield break; }
public void Update_Plugins_List() { set_layout_dirty(); list.Clear_Children(); float dY = 3f; foreach (KeyValuePair <string, Plugin> kv in Loader.plugins) { try { var sel = Create <Plugin_Manager_List_Item>(); sel.Set_Plugin(kv.Value); sel.onClicked += Sel_onClicked; list.Add(kv.Value.Hash, sel); } catch (Exception ex) { SLog.Error(ex); } } if (list.isEmpty) { tab_need_plugins.Select(); // tabPanel.Set_Tab(NEED_PLUGINS_TAB_NAME); } else { tab_ins.Select(); // tabPanel.Set_Tab(INSTRUCTION_TAB_NAME); } // Set the very first plugin in our list as the active one //if (Loader.plugins.Count > 0) { this.Select_Plugin(Loader.plugins.First().Value); } }
/// <summary> /// Find texture by name, if the path is unknown. Warning: It is a slow process and uses a lot of memory. /// </summary> public static Texture FindTexture(string name) { Texture result; if (loadedTextures.TryGetValue(name, out result)) { return(result); //Already loaded the texture } else { //Search in all the textures that been loaded by unity Texture[] allTextures = Resources.FindObjectsOfTypeAll <Texture>(); foreach (Texture tex in allTextures) { if (tex.name == name) { loadedTextures.Add(name, tex); //Store the found texture return(tex); } } loadedTextures.Add(name, null); SLog.Error("Could not find texture: " + name); return(null); } }
public static void Save_Config() { if (IN_LOADING_PHASE == true) { return; } try { if (plugins == null) { SLog.Warn("CRITICAL ERROR: Active plugins list is null!"); return; } // Select the keynames of all non-null, enabled plugins from our dictionary. List <string> list = Loader.plugins.Where(kv => (kv.Value != null && kv.Value.Enabled)).Select(kv => kv.Key).ToList(); Config.Set_Array <string>("ENABLED_PLUGINS", list); Config.Save(); } catch (Exception ex) { SLog.Error(ex); } }
public static byte[] Load_Resource(string name, string namespace_str = "SR_PluginLoader") { try { using (var stream = Get_Resource_Stream(name, namespace_str)) { if (stream == null) { return(null); } var buf = new byte[stream.Length]; var read = stream.Read(buf, 0, (int)stream.Length); if (read >= (int)stream.Length) { return(buf); } var remain = ((int)stream.Length - read); var r = 0; while (r < remain && remain > 0) { r = stream.Read(buf, read, remain); read += r; remain -= r; } return(buf); } } catch (Exception ex) { SLog.Error(ex); return(null); } }
private void Add_Error(Exception ex) { string str = Logging.Logger.Format_Exception(ex); Errors.Add(str); SLog.Error("[ <b>{0}</b> ] {1}", dll_name, str); onError?.Invoke(); }
private bool Load_DLL() { try { dll = load_assembly(dll != null); //find the static SR_Plugin class amongst however many namespaces this library has. foreach (Type ty in dll.GetExportedTypes()) { if (String.Compare(ty.Name, "SR_Plugin") == 0) { if (ty.IsPublic == false) { continue; } pluginClass = ty; break; } } if (pluginClass == null) { Add_Error("Unable to locate a static 'SR_Plugin' class in the loaded library."); return(false); } load_funct = pluginClass.GetMethod("Load", BindingFlags.Static | BindingFlags.Public); unload_funct = pluginClass.GetMethod("Unload", BindingFlags.Static | BindingFlags.Public); if (load_funct == null) { Add_Error("Unable to find Load function!"); } if (unload_funct == null) { Add_Error("Unable to find Unload function!"); } if (load_funct == null || unload_funct == null) { SLog.Info("Unable to locate load/unload functions."); return(false); } //PLog.Info("[{0}] Plugin loaded!", this.dll_name); return(true); } catch (Exception ex) { SLog.Error(ex); return(false); } }
private static GUISkin New_Skin() { GUISkin skin = ScriptableObject.CreateInstance <GUISkin>(); skin.customStyles = new GUIStyle[] { Create_Named_Style("panel"), Create_Named_Style("disabled"), }; try { var style_panel = skin.GetStyle("panel"); // Setup all of the default font values skin.box = defaultFont(skin.box, Color.white); skin.button = defaultFont(skin.button, Color.white); skin.window = defaultFont(skin.window, new Color(0.7f, 0.7f, 0.7f)); skin.label = defaultFont(skin.label, Color.white); skin.textArea = defaultFont(skin.textArea, Color.white); skin.textField = defaultFont(skin.textField, Color.white); skin.scrollView = defaultFont(skin.scrollView, Color.white); style_panel = defaultFont(style_panel, Color.white); skin.textArea.wordWrap = true;//TextAreas are multi-line by default skin.textField.wordWrap = true; skin.textArea.alignment = TextAnchor.UpperLeft; skin.label.alignment = TextAnchor.MiddleLeft; skin.button.alignment = TextAnchor.MiddleCenter; skin.window.fontSize = 16; skin.button.fontSize = 16; skin.button.fontStyle = FontStyle.Bold; // Text Editor skin.settings.cursorFlashSpeed = 0.8f; skin.settings.selectionColor = new Color(0.196f, 0.592f, 0.992f, 0.5f); // Scrollbars int scrollbar_width = 9; skin.verticalScrollbar = new GUIStyle(); skin.verticalScrollbar.fixedWidth = scrollbar_width; Util.Set_BG_Color(skin.verticalScrollbar.normal, new Color32(16, 16, 16, 200)); skin.verticalScrollbarThumb = new GUIStyle(); skin.verticalScrollbarThumb.fixedWidth = scrollbar_width; Util.Set_BG_Color(skin.verticalScrollbarThumb.normal, new Color32(80, 80, 80, 255)); } catch (Exception ex) { SLog.Error(ex); } return(skin); }
string TryGet(string key) { if (json[key] == null) { SLog.Error(new ArgumentNullException(String.Format("\"{0}\" is null!", key))); return(null); } return(json[key]); }
public static void Load_Config() { Config = new SettingsFile("plugins.json"); if (Config == null) { throw new Exception("CONFIG is not ready!"); } try { if (Config["ENABLED_PLUGINS"] != null) { List <string> list = Config.Get_Array <string>("ENABLED_PLUGINS"); Load_Enabled_Plugins(list.ToArray()); } else// Load from the old save format! { string[] list = new string[] { }; if (Loader.config_stream != null) { byte[] buf = new byte[Loader.config_stream.Length]; int read = Loader.config_stream.Read(buf, 0, (int)Loader.config_stream.Length); if (read < (int)Loader.config_stream.Length) { int remain = ((int)Loader.config_stream.Length - read); int r = 0; while (r < remain && remain > 0) { r = Loader.config_stream.Read(buf, read, remain); read += r; remain -= r; } } string str = Encoding.ASCII.GetString(buf); list = str.Split('\n'); Load_Enabled_Plugins(list); } Config.Set_Array <string>("ENABLED_PLUGINS", list); Config.Save(); } if (Loader.config_stream != null) { Loader.config_stream.Close(); File.Delete(Get_CFG_File()); } } catch (Exception ex) { SLog.Error(ex); } }
private bool Load() { var dupe = GameObject.Find(Unique_GameObject_Name); if (dupe != null) { GameObject.DestroyImmediate(dupe); SLog.Info("Destroyed pre-existing plugin manager GameObject instance!"); } GameObject gmObj = new GameObject(Unique_GameObject_Name); UnityEngine.GameObject.DontDestroyOnLoad(gmObj); try { if (load_funct != null) { object[] args = new object[load_funct.GetParameters().Length]; var paramz = load_funct.GetParameters(); for (int i = 0; i < paramz.Length; i++) { ParameterInfo param = paramz[i]; if (typeof(GameObject) == param.ParameterType) { args[i] = gmObj; } else if (typeof(Plugin) == param.ParameterType) { args[i] = this; } } load_funct.Invoke(null, args); } else { return(false); } GM = gmObj; } catch (Exception ex) { SLog.Error(ex); Add_Error(ex); Unload(); return(false); } return(true); }
public static bool Is_Plugin_Installed(string hash) { foreach (KeyValuePair <string, Plugin> kv in Loader.plugins) { if (kv.Value == null || kv.Value.data == null) { SLog.Error("@ Loader.Is_Plugin_Installed(): Value for KeyValuePair @ Key {0} is not a valid/loaded plugin!", kv.Key); } else if (String.Compare(kv.Value.Hash, hash) == 0) { return(true); } } return(false); }
public byte[] Load_Resource(string name) { try { string[] assets = this.dll.GetManifestResourceNames(); if (assets == null || assets.Length <= 0) { return(null); } string asset_name = assets.FirstOrDefault(r => r.EndsWith(name)); if (asset_name == null || asset_name.Length <= 0) { return(null); } using (Stream stream = this.dll.GetManifestResourceStream(asset_name)) { if (stream == null) { return(null); } byte[] buf = new byte[stream.Length]; int read = stream.Read(buf, 0, (int)stream.Length); if (read < (int)stream.Length) { int remain = ((int)stream.Length - read); int r = 0; while (r < remain && remain > 0) { r = stream.Read(buf, read, remain); read += r; remain -= r; } } return(buf); } } catch (Exception ex) { SLog.Error(ex); return(null); } }
public void Remove_All() { List <PlotUpgrade> list = new List <PlotUpgrade>(upgrades); foreach (PlotUpgrade u in list) { try { SLog.Info("Removing: {0}", u); u.Remove(plot); } catch (Exception ex)// No surprises kthx { SLog.Error(ex); } } }
public static void Load_Enabled_Plugins(string[] list) { foreach (var name in list) { Plugin p = null; if (plugins.TryGetValue(name, out p)) { try { p.Enable(); } catch (Exception ex) { SLog.Error(ex); } } } }
private void Load_Plugin_Info() { try { var field = pluginClass.GetField("PLUGIN_INFO", BindingFlags.Public | BindingFlags.Static); if (field == null) { return; } data = (Plugin_Data)field.GetValue(null); data.DESCRIPTION = data.DESCRIPTION.Trim(new char[] { '\n', '\r' }); } catch (Exception ex) { SLog.Error(ex); } }
public void Set_Plugin(Plugin p) { if (p == null) { SLog.Error(new Exception("Plugin is null!")); return; } try { plugin = p; if (plugin.data == null) { SLog.Error(new Exception("Plugin data is NULL!")); return; } pl_title.Text = plugin.data.NAME; pl_version.Text = plugin.data.VERSION.ToString(); Plugin_State_Changed(); if (plugin.icon != null) { pl_icon.Image = plugin.icon; } else if (TextureHelper.icon_unknown != null) { pl_icon.Image = TextureHelper.icon_unknown; } else { pl_icon.Image = null; } plugin_state_init = false; } catch (Exception ex) { SLog.Error(ex); } }
public static void Restart_App() { try { byte[] buf = Util.Load_Resource("Restart_Helper.exe"); if (buf != null && buf.Length > 0) { File.WriteAllBytes(update_helper_file, buf); string args = String.Format("{0}", Process.GetCurrentProcess().Id); Process.Start(update_helper_file, args); } else { SLog.Warn("Failed to unpack the auto update helper!"); } } catch (Exception ex) { SLog.Error(ex); } }
public void Draw(Color?clr = null) { if (GM == null) { return; } Color c = color; if (clr.HasValue) { c = clr.Value; } GL.PushMatrix(); try { if (MaterialHelper.mat_bright.SetPass(0)) { GL.MultMatrix(GM.transform.localToWorldMatrix); GL.Begin(GL.LINES); //GL.Color(c); foreach (dGizmo gizmo in gizmos) { gizmo.Draw(); } GL.End(); } } catch (Exception ex) { SLog.Error(ex); } finally { GL.PopMatrix(); } }
public void Render() { GL.PushMatrix(); try { SLog.Assert(gameObject != null, "gameObject is NULL!"); SLog.Assert(transform != null, "transform is NULL!"); GL.MultMatrix(transform.localToWorldMatrix); switch (Bright) { case true: if (MaterialHelper.mat_bright.SetPass(0)) { GL.Begin(GL.LINES); Draw(); GL.End(); } break; case false: if (MaterialHelper.mat_line.SetPass(0)) { GL.Begin(GL.LINES); Draw(); GL.End(); } break; } } catch (Exception ex) { SLog.Error(ex); } finally { GL.PopMatrix(); } }
/// <summary> /// Attempts to execute the plugins unload logic. /// </summary> private void Unload() { try { if (unload_funct != null) { object[] args = new object[unload_funct.GetParameters().Length]; var paramz = unload_funct.GetParameters(); for (int i = 0; i < paramz.Length; i++) { ParameterInfo param = paramz[i]; if (typeof(GameObject) == param.ParameterType) { args[i] = GM; } else if (typeof(Plugin) == param.ParameterType) { args[i] = this; } } this.unload_funct.Invoke(null, args); } } catch (Exception ex) { SLog.Error(ex); Add_Error(ex); } finally { if (GM != null) { UnityEngine.GameObject.Destroy(GM); } GM = null; Loader.Plugin_Status_Change(this, Enabled); } }
public static bool Load_Config_Stream() { try { if (!File.Exists(Get_CFG_File())) { return(true); } FileStream stream = new FileStream(Get_CFG_File(), FileMode.Open, FileAccess.ReadWrite); if (stream == null) { return(true); } Loader.config_stream = stream; return(true); } catch (Exception ex) { SLog.Error(ex); return(false); } }
// Remember: when this function is used by plugins they will pass their given updater_method URL for 'remote_file' // In the case of things like the Git updater this is fine as that url will BE a link to the most current version of the plugin DLL // However in the case of the JSON updater that url will instead be a link to the JSON file containing the HASH and DOWNLOAD URL for said plugin. // So for the JSON updater this method needs to be overriden and made to download that JSON info and treat the DOWNLOAD url contained therein as if IT was passed as the 'remote_file' public virtual IEnumerator DownloadAsync(string remote_file, string local_file, Updater_File_Type_Confirm confirm = null, Updater_File_Download_Progress prog_callback = null, Updater_File_Download_Completed download_completed = null) { SLog.Debug("Downloading: {0}", remote_file); if (local_file == null) { local_file = String.Format("{0}\\{1}", UnityEngine.Application.dataPath, Path.GetFileName(remote_file)); } WebResponse resp = null; Stream stream = null; HttpWebRequest webRequest = CreateRequest(remote_file); WebAsync webAsync = new WebAsync(); IEnumerator e = webAsync.GetResponse(webRequest); while (e.MoveNext()) { yield return(e.Current); } // wait for response to arrive while (!webAsync.isResponseCompleted) { yield return(null); // double check for clarity & safety } RequestState result = webAsync.requestState; resp = result.webResponse; if (confirm != null) { if (confirm(resp.ContentType) == false) { yield break;//exit routine } } stream = resp.GetResponseStream(); int total = (int)resp.ContentLength; byte[] buf = new byte[total]; int read = 0; //how many bytes we have read so far (offset within the stream) int remain = total; //how many bytes are left to read int r = 0; while (remain > 0) { r = stream.Read(buf, read, Math.Min(remain, CHUNK_SIZE)); read += r; remain -= r; if (prog_callback != null) { try { prog_callback(read, total); } catch (Exception ex) { SLog.Error(ex); } } yield return(0);// yield execution until next frame } // It's good practice when overwriting files to write the new version to a temporary location and then copy it overtop of the original. string temp_file = String.Format("{0}.temp", local_file); File.WriteAllBytes(temp_file, buf); File.Copy(temp_file, local_file, true); File.Delete(temp_file);// delete the now unneeded .temp file download_completed?.Invoke(local_file); yield break;//exit routine }
public static void init(string hash) { lock (locker) { if (Loader.Config != null) { return; } //Application.stackTraceLogType = StackTraceLogType.Full; Logging.Logger.Begin(Path.Combine(Application.dataPath, "plugins.log")); Stopwatch timer = new Stopwatch(); timer.Start(); if (!Loader.Load_Config_Stream()) { return; } try { DebugHud.Init(); TextureHelper.Setup(); MaterialHelper.Setup(); SiscosHooks.Setup(); PluginLoader_Watermark.Setup(); MainMenu.Setup(); DebugUI.Setup(); Setup_Update_Helper(); bool ok = Verify_PluginLoader_Hash(hash); if (!ok) { return; } IN_LOADING_PHASE = true; Setup_Plugin_Dir(); Check_For_Updates(); Setup_Assembly_Resolver(); Upgrades.Setup(); Assemble_Plugin_List(); Load_Config(); IN_LOADING_PHASE = false; ResourceExt.map_SR_Icons(); plugin_updater = uiControl.Create <Plugin_Update_Viewer>();// This control manages itself and is only able to become visible under certain conditions which it will control. Therefore it needs no var to track it. plugin_updater.Show(); dev_tools = uiControl.Create <DevMenu>(); //dev_tools.Show(); //dev_tools.onShown += (uiWindow w) => { GameTime.Pause(); }; //dev_tools.onHidden += (uiWindow w) => { GameTime.Unpause(); }; //Misc_Experiments.Find_Common_Classes_For_Idents(new HashSet<Identifiable.Id> { Identifiable.Id.PINK_RAD_LARGO }); } catch (Exception ex) { SLog.Error("Exception during PluginLoader initialization!"); SLog.Error(ex); } finally { timer.Stop(); SLog.Debug("Plugin Loader initialized! Took: {0}ms", timer.ElapsedMilliseconds); } } }
/// <summary> /// Performs a coroutine Http GET request and returns a byte array with the result via both a callback and the current value of the IEnumerator object. /// </summary> public static IEnumerator GetAsync(string url, Updater_File_Type_Confirm confirm = null, Updater_File_Download_Progress prog_callback = null, Updater_Get_Result callback = null) { if (remote_file_cache.ContainsKey(url)) { yield return(remote_file_cache[url]); yield break; } WebResponse resp = null; Stream stream = null; HttpWebRequest webRequest = CreateRequest(url); WebAsync webAsync = new WebAsync(); IEnumerator e = webAsync.GetResponse(webRequest); if (e == null) { SLog.Info("Updater_Base.Get() Enumerator is NULL!"); yield return(null); yield break; } while (e.MoveNext()) { yield return(null); } // wait for response to arrive while (!webAsync.isResponseCompleted) { yield return(null); // double check for clarity & safety } RequestState result = webAsync.requestState; resp = result.webResponse; if (confirm != null) { if (confirm(resp.ContentType) == false) { yield break;//exit routine } } stream = resp.GetResponseStream(); int total = (int)resp.ContentLength; byte[] buf = new byte[total]; int read = 0; //how many bytes we have read so far (offset within the stream) int remain = total; //how many bytes are left to read int r = 0; while (remain > 0) { r = stream.Read(buf, read, Math.Min(remain, CHUNK_SIZE)); read += r; remain -= r; if (prog_callback != null) { try { prog_callback(read, total); } catch (Exception ex) { SLog.Error(ex); } } yield return(null);// yield execution until next frame } if (!remote_file_cache.ContainsKey(url)) { remote_file_cache.Add(url, buf); } else { remote_file_cache[url] = buf; } callback?.Invoke(buf); yield return(buf); yield break; }
public static bool Add_Plugin_To_List(string file) { string ext = Path.GetExtension(file); if (ext != ".dll") { return(false); } Plugin plug = new Plugin(file); string name = Path.GetFileNameWithoutExtension(file); plugins[name] = plug; try { plug.Setup(); foreach (KeyValuePair <string, Plugin> kv in plugins) { if (String.Compare(name, kv.Key) == 0) { continue; } if (String.Compare(plug.Hash, kv.Value.Hash) == 0) // These plugins are different files but are the same plugin according to their hash (not data hash, id hash so they might be differing versions of the same plugin). { //we need to unload, maybe delete one of them. figure out which one is the latest Plugin trash = null; if (plug.data.VERSION > kv.Value.data.VERSION) { trash = kv.Value; } else if (plug.data.VERSION < kv.Value.data.VERSION) { trash = plug; } else { if (trash == null) { if (plug.file_time > kv.Value.file_time) { trash = plug; } else { trash = kv.Value; } } } if (trash == null) { SLog.Info("Found multiple instances of the same plugin and cannot determine which plugin file to ignore! Plugin: ", plug); } else { SLog.Info("Multiple instances of the same plugin have been found, uninstalling file: {0}", trash.FilePath); trash.Uninstall(); return(false); } } } } catch (Exception ex) { SLog.Error(ex); return(false); } if (MainMenu.isReady) { if (PluginManager.Instance != null) { PluginManager.Instance.Update_Plugins_List(); } } return(true); }
/// <summary> /// Checks if a specified file exists in the project GIT repository. /// </summary> /// <param name="url"></param> /// <returns></returns> public static IEnumerator Query_Remote_File_Exists_Async(string url) { HttpWebResponse response = null; HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest; if (webRequest == null) { SLog.Info("Unable to create an instance of HttpWebRequest!"); yield return(false); } webRequest.UserAgent = USER_AGENT; webRequest.Method = "HEAD"; WebAsync webAsync = new WebAsync(); IEnumerator e = webAsync.GetResponse(webRequest); if (e == null) { SLog.Info("Updater_Base.Get() Enumerator is NULL!"); yield return(false); yield break; } bool failed = false; bool done = false; do// wait for response to arrive { try { done = !e.MoveNext(); } catch (Exception ex) { SLog.Error(ex); failed = true; } yield return(null); }while (!done); while (!webAsync.isResponseCompleted) { yield return(null); // double check for clarity & safety } if (!failed) { try { RequestState result = webAsync.requestState; response = (HttpWebResponse)result.webResponse; } catch (WebException wex) { if (wex.Status == WebExceptionStatus.ProtocolError) { var wres = wex.Response as HttpWebResponse; if (wres != null) { if (wres.StatusCode == HttpStatusCode.NotFound)// A file for this hash does not exist on the github repo. So this must be a Dev version. { failed = true; } } } failed = true; } finally { if (response != null) { response.Close(); } } } yield return(!failed); yield break; }
public override FILE_UPDATE_STATUS Get_Update_Status(string remote_path, string local_file) { if (!File.Exists(local_file)) { return(FILE_UPDATE_STATUS.OUT_OF_DATE); } string repo_url = Extract_Repository_URL_From_Github_URL(remote_path); string remote_file = Extract_File_Path_From_Github_URL(remote_path); // Time to check with GitHub and see if there is a newer version of the plugin loader out! try { JSONArray repo = Cache_Git_Repo(repo_url); // Go ahead and get the hash for the file we're checking on. string cSHA = Util.Git_File_Sha1_Hash(local_file); // Let's make sure we didn't already check on this same file in the past. FILE_UPDATE_STATUS?lastResult = Get_Cached_Result(remote_path, local_file); //if we DID cache the result from a past check against this file then return it here and don't waste time. if (lastResult.HasValue) { SLog.Debug("Returning Cached Result: {2} | \"{0}\" | SHA({1})", local_file, cSHA, Enum.GetName(typeof(FILE_UPDATE_STATUS), lastResult.Value)); return(lastResult.Value); } if (repo == null) { SLog.Info("[AutoUpdater] Unable to cache git repository!"); return(FILE_UPDATE_STATUS.ERROR); } // Find the plugin loaders DLL installation file foreach (JSONNode file in repo) { if (String.Compare(file["path"], remote_file) == 0) { // Compare the SHA1 hash for the dll on GitHub to the hash for the one currently installed string nSHA = file["sha"]; //PLog.Info("nSHA({0}) cSHA({1}) local_file: {2}", nSHA, cSHA, local_file); if (String.Compare(nSHA, cSHA) != 0) { // ok they don't match, now let's just make double sure that it isn't because we are using an unreleased developer version // First find the url for the file on GitHub string tmpurl = file["url"]; // now we want to replace it's hash with ours and check if it exists! tmpurl = tmpurl.Replace(nSHA, cSHA); // Check if the file for the currently installed loaders sha1 hash exists. bool exist = false; try { exist = Query_Remote_File_Exists(tmpurl); //PLog.Info("Query_Remote_File_Exists: {0} = {1}", tmpurl, (exist ? "TRUE" : "FALSE")); } catch (WebException wex) { if (wex.Status == WebExceptionStatus.ProtocolError) { var response = wex.Response as HttpWebResponse; if (response != null) { if (response.StatusCode == HttpStatusCode.NotFound)// A file for this hash does not exhist on the github repo. So this must be a Dev version. { exist = false; } } } } if (!exist) { //PLog.Info("[Updater] Dev file: {0}", Path.GetFileName(local_file)); Cache_Result(remote_path, local_file, FILE_UPDATE_STATUS.DEV_FILE); return(FILE_UPDATE_STATUS.DEV_FILE); } //PLog.Info("[Updater] Outdated file: {0}", Path.GetFileName(local_file)); Cache_Result(remote_path, local_file, FILE_UPDATE_STATUS.OUT_OF_DATE); return(FILE_UPDATE_STATUS.OUT_OF_DATE); } else { Cache_Result(remote_path, local_file, FILE_UPDATE_STATUS.UP_TO_DATE); return(FILE_UPDATE_STATUS.UP_TO_DATE); } } } } catch (WebException wex) { SLog.Error(wex); } catch (Exception ex) { SLog.Error(ex); } SLog.Debug("[Git_Updater] Unable to find file in repository: {0}", remote_file); return(FILE_UPDATE_STATUS.NOT_FOUND);//no update }
private IEnumerator Client_Plugins_List_Update() { loading_tab.Select(); ld_text.Text = "Fetching master plugins list"; retry_pl_list_btn.isVisible = false; yield return(new WaitForSeconds(0.4f)); bool b = true, fail = false; IEnumerator iter = null; try { iter = Git_Updater.instance.Cache_And_Open_File_Async(PLUGINS_LIST_URL); } catch (Exception ex) { SLog.Error(ex); fail = true; } //while (iter.MoveNext()) yield return null; while (b && !fail) { try { if (iter == null) { fail = true; break; } b = iter.MoveNext(); } catch (Exception ex) { SLog.Error(ex); fail = true; } //if(b) yield return null;// wait yield return(null);// wait } if (fail == false) { ld_text.Text = "Listing plugins"; if (iter.Current != null) { try { FileStream strm = iter.Current as FileStream; byte[] data = Util.Read_Stream(strm); var list = JSON.Parse(Encoding.ASCII.GetString(data))["plugins"]; plugins.Clear(); foreach (JSONNode json in list.Childs) { var dat = new Plugin_Download_Data(json); plugins[dat.Hash] = dat; } lbl_pl_count.Value = plugins.Count.ToString(); pending_rebuild = true; plugins_tab.Select(); } catch (Exception ex) { SLog.Info("Error while updating plugins list."); SLog.Error(ex); fail = true; } } else { fail = true; } } if (fail) { retry_pl_list_btn.isVisible = true; // show the retry button ld_text.Text = "unable to load plugin master list"; yield break; // exit } else { retry_pl_list_btn.isVisible = false;// show the retry button ld_text.Text = "Done!"; plugins_tab.Select(); } yield break; }
private static void Log(Exception ex) { string str = Logging.Logger.Format_Exception(ex); SLog.Error("{0}(Exception) {1}", LOG_TAG, str); }