static void Main(string[] args) { // Note - a registry key must exist under hklm/software for this string below string domain = "log4net.Ext.Serializable.UnitTest1.2.10"; SLog log = (SLog)SLogManager.GetLogger(domain, typeof(TestSerializableLog)); log.RegistryConfigurator(); PropertiesCollectionEx props = new PropertiesCollectionEx(); props.Set("TESTPROP", "myprop"); log.InfoFormat(props, "Hello world with myprop for a prop {0}", log.GetHashCode()); ((ILog)log).DebugFormat("Shouldn't see this - its a debug."); SLog log2 = (SLog)SLogManager.GetLogger(domain, typeof(TestSerializableLog)); log2.Info("Hello world again - different SLog reference, same SLog? Look for myprop prop " + +log2.GetHashCode()); MemoryStream stream = new MemoryStream(); SoapFormatter formatter = new SoapFormatter(); formatter.Serialize(stream, log); formatter.Serialize(stream, props); System.Text.Encoding encoding = System.Text.Encoding.UTF8; string ser = encoding.GetString(stream.ToArray()); //log.Info("log looks like: " + ser); stream.Seek(0, System.IO.SeekOrigin.Begin); SoapFormatter formatter2 = new SoapFormatter(); SLog log3 = (SLog)formatter2.Deserialize(stream); PropertiesCollectionEx props2 = (PropertiesCollectionEx)formatter2.Deserialize(stream); log3.Info(props2, "Hello world from deserialized stream. Look for myprop prop. " + +log3.GetHashCode()); SLog log4 = (SLog)SLogManager.GetLogger(domain, typeof(TestSerializableLog)); log4.Info("Hello world again - different SLog reference, same SLog? Look for myprop prop. " + log4.GetHashCode()); log4.Info(string.Format("Hash codes: {0} {1} {2} {3}", log.Logger.GetHashCode(), log2.Logger.GetHashCode(), log3.Logger.GetHashCode(), log4.Logger.GetHashCode())); Console.ReadLine(); }
private void Setup_Dict(List <string[]> names_list, out Dictionary <string, GameObject> dict) { dict = new Dictionary <string, GameObject>(); foreach (string[] strs in names_list) { string fullName = strs[0]; string name = strs[1]; var child = base.gameObject.transform.Find(fullName); if (child == null) { SLog.Info("Unable to find child named: \"{0}\"", fullName); continue; } GameObject gObj = child.gameObject; if (!dict.ContainsKey(name)) { dict.Add(name, gObj); } else { SLog.Info("Duplicate entry for child named: \"{0}\"", name); } } //PLog.Info("Dictionary<> {0} entrys. {1}", dict.Keys.Count, String.Join(", ", dict.Keys.ToArray())); }
public static void Find_Common_Classes_For_Idents(HashSet <Identifiable.Id> ID_LIST) { Dictionary <string, int> TALLY = new Dictionary <string, int>(); //Lookup the prefab for each id and grab a list of all classes it has on it foreach (Identifiable.Id id in ID_LIST) { var pref = Directors.lookupDirector.GetPrefab(id); GameObject inst = (GameObject)GameObject.Instantiate(pref, Vector3.zero, Quaternion.identity); MonoBehaviour[] class_list = inst.GetComponentsInChildren <MonoBehaviour>(true); foreach (var cInst in class_list.DistinctBy(o => o.name)) { if (!TALLY.ContainsKey(cInst.name)) { TALLY.Add(cInst.name, 0); } TALLY[cInst.name]++; } GameObject.Destroy(inst); } SLog.Info("==== Results ===="); foreach (KeyValuePair <string, int> kvp in TALLY.OrderByDescending(o => o.Value)) { float pct = ((float)kvp.Value / ID_LIST.Count); SLog.Info("{0}: {1:P1}", kvp.Key, pct); } SLog.Info("================="); }
internal static void Setup() { SLog.Info("[SiscosHooks] Initialized..."); int max = HOOK_ID.Count; // foreach(var hook in HOOKS.HooksList) { max = Math.Max(max, hook.id); } EventCounter = new int[max]; for (int i = 0; i < EventCounter.Length; i++) { EventCounter[i] = 0; } #region Setup Event Extension Proxys register(HOOK_ID.Ext_Game_Saved, HookProxys.Ext_Game_Saved); register(HOOK_ID.Ext_Pre_Game_Loaded, HookProxys.Ext_Pre_Game_Loaded); register(HOOK_ID.Ext_Post_Game_Loaded, HookProxys.Ext_Post_Game_Loaded); register(HOOK_ID.Ext_Demolish_Plot, HookProxys.Ext_Demolish_Plot_Upgrade); register(HOOK_ID.Ext_Spawn_Plot_Upgrades_UI, HookProxys.Ext_Spawn_Plot_Upgrades_UI); register(HOOK_ID.Ext_Identifiable_Spawn, HookProxys.Ext_Identifiable_Spawn); register(HOOK_ID.Ext_Player_Death, HookProxys.Ext_Player_Death); register(HOOK_ID.Ext_LockOnDeath_Start, HookProxys.Ext_LockOnDeath_Start); register(HOOK_ID.Ext_LockOnDeath_End, HookProxys.Ext_LockOnDeath_End); #endregion #region Hook Prefab Instantiation Events Util.Inject_Into_Prefabs <Entity_Pref_Hook>(Ident.ALL_IDENTS); Util.Inject_Into_Prefabs <Plot_Pref_Hook>(Ident.ALL_PLOTS); Util.Inject_Into_Prefabs <Resource_Pref_Hook>(Ident.ALL_GARDEN_PATCHES); #endregion }
private void process_downloads() { if (download_queue.Count > 0) { Plugin plugin = download_queue.First(); Plugin_Update_Item itm = list.Get_Children().First(o => ((Plugin_Update_Item)o).plugin_hash == plugin.Hash) as Plugin_Update_Item; if (itm == null) { SLog.Info("Unable to find plugin_update_item for plugin {0}({1})", plugin.data.NAME, plugin.Hash); return; } else { SLog.Info("Found plugin_update_item for plugin {0}({1})", plugin.data.NAME, plugin.Hash); } uiProgressBar prog = null; if (itm != null) { prog = itm.progress_bar; } StartCoroutine(plugin.force_download(prog, (string file) => { download_queue.RemoveAt(0); process_downloads(); })); } else { this.Hide(); Loader.Restart_App(); } }
protected override void Display() { Display_BG();// Draw BG //GUI.BeginGroup(title_bar_abs_area); GUI.BeginGroup(draw_area); GUI.BeginGroup(titlebar_area); style_title.Draw(title_area, content, false, false, false, false); // Draw the titlebar text. GUI.DrawTextureWithTexCoords(title_stipple_area, title_bar_texture, title_stipple_coords, true); GUI.EndGroup(); GUI.EndGroup(); //GUI.BeginClip(_inner_area); GUI.BeginGroup(_inner_area); for (int i = 0; i < children.Count; i++) { if (CONFIRM_DRAW) { SLog.Info(" - Drawing child: {0}", children[i]); } children[i].TryDisplay(); } GUI.EndGroup(); //GUI.EndClip(); }
/// <summary> /// Child controls can use this function to query what kind of size constraints the parent will impose on them. /// </summary> internal virtual Vector2 Constrain_Child_Size(uiControl c, Vector2 requested_size) { Vector2 max = available_area;// This is the maximum size available to this control // We want to determine if the calling control's maximum extents would go outside the maximum possible extents of this control. // And if so, scale back the requested size so it fits within our limits. if (isSizeConstrained) { max.x = Get_Content_Area().width; } if (CONFIRM_SIZE) { SLog.Info("{0} Confirm Child Size Constraint | Available Area: {1} | Requested Size: {2} ", this, max, requested_size); } if ((requested_size.x + c.Pos.x) > max.x) { requested_size.x = (max.x - c.Pos.x); } if ((requested_size.y + c.Pos.y) > max.y) { requested_size.y = (max.y - c.Pos.y); } return(requested_size); }
private static Sisco_Return onPostGameLoaded(ref object sender, ref object[] args, ref object return_value) { string gameName = (string)args[0]; string plyUpgradesFile = String.Concat(gameName, ".pug"); // LOAD PLAYER UPGRADES if (File.Exists(plyUpgradesFile)) { string str = File.ReadAllText(plyUpgradesFile); string[] list = str.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); if (list.Length <= 0) { return(null); } foreach (string ID in list) { string id = ID.ToLower(); PlayerUpgrade upgrade = Get_Upgrade(Upgrade_Type.PLAYER_UPGRADE, id) as PlayerUpgrade; if (upgrade == null) { Player_Upgrades_Missing.Add(id); SLog.Info("[Upgrades] Unable to find Upgrade, ID: {0}", id); } else { Player.GiveUpgrade(upgrade); } } } return(null); }
private void Dev_Spawn_Item(Identifiable.Id ID) { if (Game.atMainMenu) { Sound.Play(SoundId.ERROR); SLog.Info("Failed to spawn item: {0}, We are at the main menu.", ID); return; } RaycastHit?ray = Player.Raycast(); if (!ray.HasValue) { Sound.Play(SoundId.ERROR); SLog.Info("Failed to spawn item: {0}, Unable to perform raycast from player's view. Perhaps the ray distance is too far.", ID); } if (Util.TrySpawn(ID, ray.Value) == null) { Sound.Play(SoundId.ERROR); SLog.Info("Failed to spawn item: {0}, An unknown error occured", ID); } else { Sound.Play(SoundId.BTN_CLICK); } }
public Dev_SpawnMenu() { Autosize = true; Autosize_Method = AutosizeMethod.FILL; onLayout += Layout; // This list will contain different categories of spawnable items cList = uiControl.Create <uiListView>(this); cList.Set_Margin(0, 4, 0, 0); cList.Set_Width(130f); catPanel = uiControl.Create <uiTabPanel>(this); foreach (SpawnCategory cty in Enum.GetValues(typeof(SpawnCategory))) { if (cty == SpawnCategory.NONE) { continue; } string catStr = Enum.GetName(typeof(SpawnCategory), cty); var catBtn = uiControl.Create <uiListItem>(String.Concat("category_", catStr.ToLower()), cList); catBtn.Title = catStr.ToLower().CapitalizeFirst(); catBtn.Description = null; uiTab cTab = null; switch (cty) { case SpawnCategory.SLIMES: cTab = Create_Spawn_Category_Menu(catPanel, cty, Ident.ALL_SLIMES); break; case SpawnCategory.PLORTS: cTab = Create_Spawn_Category_Menu(catPanel, cty, Identifiable.PLORT_CLASS); break; case SpawnCategory.ANIMALS: cTab = Create_Spawn_Category_Menu(catPanel, cty, Ident.ALL_ANIMALS); break; case SpawnCategory.FRUITS: cTab = Create_Spawn_Category_Menu(catPanel, cty, Identifiable.FRUIT_CLASS); break; case SpawnCategory.VEGETABLES: cTab = Create_Spawn_Category_Menu(catPanel, cty, Identifiable.VEGGIE_CLASS); break; default: SLog.Info("Unhandled Spawn menu category: {0}", catStr); break; } catBtn.onSelected += (uiControl c) => { Sound.Play(SoundId.BTN_CLICK); cTab.Select(); }; } }
private void Add_Error(string format, params object[] args) { string str = DebugHud.Format_Log(format, 1, args); Errors.Add(str); SLog.Info("[ <b>{0}</b> ] {1}", this.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); } }
public static void Log_Resource_Names() { var thisExe = System.Reflection.Assembly.GetCallingAssembly(); var resources = thisExe.GetManifestResourceNames(); foreach (var res in resources) { SLog.Info(res); } }
/// <summary> /// Starts downloading the latest version of this plugin. /// (Coroutine) /// </summary> /// <param name="prog">uiProgressBar instance which this function will use to display the current update progress.</param> /// <returns></returns> public IEnumerator download_update(uiProgressBar prog, Updater_File_Download_Completed download_complete_cb) { if (!this.check_for_updates()) { SLog.Info("{0} Plugin.download_update(): Already up to date!", this); yield break; } yield return(this.force_download(prog, download_complete_cb)); }
private void Btn_copy_json_onClicked(uiControl c) { Plugin pl = Plugin.Get_Plugin(this.selected); if (pl == null) { SLog.Info("Unable to find plugin via hash: {0}", this.selected); return; } GUIUtility.systemCopyBuffer = pl.data.ToJSON(); }
protected override void Display() { if (CONFIRM_DRAW) { SLog.Info("[{0}](" + Typename + ") Display confirm | {1}", this, inner_area); } Display_BG(); // Draw Background // Draw children within scrollable area Vector2 pre_scroll = _scroll_pos; //track what the scroll pos was before this frame // We still must implement handling for if the control has Scrollable turned off, just in case! if (Scrollable) { _scroll_pos = GUI.BeginScrollView(inner_area, _scroll_pos, _content_area); } else { GUI.BeginClip(inner_area); } for (int i = 0; i < children.Count; i++) { if (CONFIRM_DRAW) { SLog.Info(" - Drawing child: {0} {1}", children[i], children[i].Get_Status_String()); } children[i].TryDisplay(); } if (CONFIRM_DRAW) { SLog.Info(" - - - - - -"); } if (Scrollable) { GUI.EndScrollView(true); if (!Util.floatEq(_scroll_pos.x, pre_scroll.x) || !Util.floatEq(_scroll_pos.y, pre_scroll.y)) { if (CONFIRM_SCROLL) { SLog.Info("{0} Confirm Scroll | Scroll: {1} | pre_scroll: {2}", this, _scroll_pos, pre_scroll); } foreach (var child in children) { child.parent_scroll_updated(); } } } else { GUI.EndClip(); } }
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); }
/// <summary> /// Assists in loading a texture from a file that is an embedded resource. /// </summary> /// <param name="name">The embedded resource name.</param> /// <param name="namespace_str">The main namespace of the calling Assembly.</param> /// <param name="flags">A set of flags from the <c>TextureOpFlags</c> enum.</param> /// <returns></returns> public static Texture Load_From_Resource(string name, string namespace_str, TextureOpFlags flags) { var asset_name = String.Format("{0}.Resources.{1}", namespace_str, name); using (var stream = Assembly.GetCallingAssembly().GetManifestResourceStream(asset_name)) { var data = Util.Read_Stream(stream); if (data == null) { SLog.Info("UNABLE TO LOAD SPECIFIED RESOURCE: {0}", name); } return(Load(data, flags, name)); } }
protected override void Display() { if (CONFIRM_DRAW) { SLog.Info("[{0}]({1}) Confirm Display | draw_area: {2}", this, Typename, draw_area); } Display_BG(); // Draw BG Display_Text(); // Draw our text /* * Display_BG();// Draw Background * styleText.Draw(_inner_area, content, isMouseOver || isActive, isActive, false, isFocused);// Draw text */ }
/// <summary> /// Outputs a list of all loaded Unity Shaders. /// </summary> public static void Print_All_Shaders() { var all = Resources.FindObjectsOfTypeAll <Shader>(); List <string> list = new List <string>(); SLog.Info("=== SHADERS ==="); foreach (Shader shader in all) { list.Add(shader.name); SLog.Info(" - {0}", shader.name); } SLog.Info("==============="); System.IO.File.WriteAllLines("shader_list.txt", list.ToArray()); }
/// <summary> /// Returns the GameObject instance for a specified ATTACHMENT_POINT group. /// </summary> /// <param name="name"></param> /// <returns></returns> public GameObject Get_Attachment_Point(string name) { string keyStr = name.ToLowerInvariant(); if (ATTACHMENT_POINTS == null) { throw new Exception("ATTACHMENT_POINTS Dictionary not ready!"); } if (!ATTACHMENT_POINTS.ContainsKey(keyStr)) { SLog.Info("No ATTACHMENT_POINTS group named \"{0}\" could be found!", keyStr); return(null); } return(ATTACHMENT_POINTS[keyStr]); }
/// <summary> /// Returns the GameObject instance for a specified MESH group. /// </summary> /// <param name="name"></param> /// <returns></returns> public GameObject Get_Mesh(string name) { string keyStr = name.ToLowerInvariant(); if (MESHES == null) { throw new Exception("MESHES Dictionary not ready!"); } if (!MESHES.ContainsKey(keyStr)) { SLog.Info("No MESH group named \"{0}\" could be found!", keyStr); return(null); } return(MESHES[keyStr]); }
public virtual uiControl Add(string name, uiControl c) { Add(c); uiControl tmp; if (child_map.TryGetValue(name, out tmp)) { if (tmp != c) { SLog.Info("[Plugin UI] Warning: assigning new control to a name that is already taken: {0}", name); } } child_map[name] = c; c.Name = name; return(c); }
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); } } }
private void OnRenderObject() { if (!base.isActiveAndEnabled) { return; } if (!base.gameObject.activeSelf) { return; } if (transform == null) { return; } GL.PushMatrix(); //GL.LoadIdentity(); GL.MultMatrix(transform.localToWorldMatrix); lineMaterial.SetPass(0); GL.Color(Color.green); GL.Begin(4); if (FLAG_DRAW_ATTACHMENT_POINTS) { foreach (KeyValuePair <string, GameObject> kvp in ATTACHMENT_POINTS) { GameObject point = kvp.Value; if (point == null) { SLog.Info("attachment point is null!"); continue; } if (point.transform == null) { SLog.Info("attachment point transform is null!"); continue; } // Draw a triangle centered on this point GL_Render_Triangle(point.transform.position); } } GL.End(); GL.PopMatrix(); }
private static bool Check_Header(byte[] data, byte[] magic, int offset = 0) { if (magic == null || data == null || magic.Length <= 0 || (data.Length - offset) <= 0 || magic.Length > (data.Length - offset)) { SLog.Info("Bad arguments."); return(false); } for (var i = 0; i < magic.Length; i++) { if (data[i + offset] != magic[i]) { return(false); } } return(true); }
private Stream Resolve(string file) { if (resolver == null) { throw new ArgumentNullException( $"Material resolver callback is null, Cannot locate texture: {file}"); } //PLog.Debug("[MaterialBuilder] Resolving file: {0}", file); var stream = resolver(file); if (stream == null) { SLog.Info("Cannot resolve file: {0}", file); } return(stream); }
private void Install_btn_onClicked(uiControl c) { if (selected_plugin == null) { Sound.Play(SoundId.NEGATIVE); return; } var hash = selected_plugin.plugin_hash; string url = this.plugins[hash].URL; if (url == null || url.Length <= 0) { SLog.Info("Cannot download plugin, Invalid URL: {0}", url); return; } Download_Plugin(hash, url); }
/// <summary> /// Checks if a specified file exists in the project GIT repository. /// </summary> /// <param name="url"></param> /// <returns></returns> public static bool Query_Remote_File_Exists(string url) { HttpWebResponse response = null; var request = (HttpWebRequest)WebRequest.Create(url); if (request == null) { SLog.Info("Unable to create an instance of HttpWebRequest!"); return(false); } request.UserAgent = USER_AGENT; request.Method = "HEAD"; try { response = (HttpWebResponse)request.GetResponse(); } 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. { return(false); } } } //DebugHud.Log(wex); return(false); } finally { if (response != null) { response.Close(); } } return(true); }
public override void handleEvent() { if (!isVisible || isDisabled) { SLog.Info("[{0}] Window handling events while INVISIBLE!", this); return; } Event evt = Event.current; bool use_event = false; switch (evt.GetTypeForControl(unity_id)) { case EventType.MouseDrag: if (dragging) { use_event = true; Vector2 dtPos = evt.delta; Set_Pos(dtPos.x + Area.x, dtPos.y + Area.y); } break; case EventType.MouseDown: dragging = false; if (titlebar_areaAbs.Contains(evt.mousePosition) && draggable) { dragging = true; } break; case EventType.MouseUp: dragging = false; break; } base.handleEvent(); if (use_event && Event.current.GetTypeForControl(unity_id) != EventType.Used) { evt.Use(); } }