public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "LoadingExtension.OnLevelLoad"); button = (GenerateButton)UIView.GetAView().AddUIComponent(typeof(GenerateButton)); var go = new GameObject("procedural_cities"); }
private void WriteMessage(string p, PluginManager.MessageType type) { if (!this.Debug) { return; } var msg = FormatMessage(p, type); DebugOutputPanel.AddMessage(type, msg); if (_logOpened) { _log.WriteLine(msg); _log.Flush(); } //Unity engine logger switch (type) { case PluginManager.MessageType.Error: UnityEngine.Debug.LogError(msg); break; case PluginManager.MessageType.Message: UnityEngine.Debug.Log(msg); break; case PluginManager.MessageType.Warning: UnityEngine.Debug.LogWarning(msg); break; default: goto case PluginManager.MessageType.Message; } }
private void Rotate(bool forward) { var angle = forward ? Angle : -Angle; try { var currentBrush = GetCurrentBrush(); if (currentBrush == null) { return; } if (!_originalBrush.name.Equals(currentBrush.name)) { // brush has changed _dstAngle = 0; _originalBrush = currentBrush; } _dstAngle = (_dstAngle + angle + 360) % 360; var nextBrush = RotateTexture(_originalBrush, _dstAngle); SetBrush(nextBrush); } catch (Exception ex) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Error, "RotateBrush Exception: " + ex.ToString()); } }
public static void Dump <T>() where T : UnityEngine.Object { foreach (T t in Resources.FindObjectsOfTypeAll <T>()) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, t.name); } }
public static void Init() { var inst = instance; var incomingCount = typeof(TransferManager).GetField("m_incomingCount", BindingFlags.NonPublic | BindingFlags.Instance); var incomingOffers = typeof(TransferManager).GetField("m_incomingOffers", BindingFlags.NonPublic | BindingFlags.Instance); var incomingAmount = typeof(TransferManager).GetField("m_incomingAmount", BindingFlags.NonPublic | BindingFlags.Instance); var outgoingCount = typeof(TransferManager).GetField("m_outgoingCount", BindingFlags.NonPublic | BindingFlags.Instance); var outgoingOffers = typeof(TransferManager).GetField("m_outgoingOffers", BindingFlags.NonPublic | BindingFlags.Instance); var outgoingAmount = typeof(TransferManager).GetField("m_outgoingAmount", BindingFlags.NonPublic | BindingFlags.Instance); if (inst == null) { CODebugBase <LogChannel> .Error(LogChannel.Core, "No instance of TransferManager found!"); DebugOutputPanel.AddMessage(PluginManager.MessageType.Error, "No instance of TransferManager found!"); return; } m_incomingCount = incomingCount.GetValue(inst) as ushort[]; m_incomingOffers = incomingOffers.GetValue(inst) as TransferManager.TransferOffer[]; m_incomingAmount = incomingAmount.GetValue(inst) as int[]; m_outgoingCount = outgoingCount.GetValue(inst) as ushort[]; m_outgoingOffers = outgoingOffers.GetValue(inst) as TransferManager.TransferOffer[]; m_outgoingAmount = outgoingAmount.GetValue(inst) as int[]; InitDelegate(); }
public static void Error(string msg) { if (ModCorralConfig.instance.LogErrors) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Error, msg); } }
public static UISlider AddSlider(UIComponent parent, string text, float min, float max, float step, float defaultValue, OnValueChanged eventCallback, out UILabel label) { if (eventCallback != null) { var uIPanel = parent.AttachUIComponent(UITemplateManager.GetAsGameObject(kSliderTemplate)) as UIPanel; uIPanel.transform.localScale = Vector3.one; if (string.IsNullOrEmpty(text)) { label = null; GameObject.Destroy(uIPanel.Find <UILabel>("Label")); } else { label = uIPanel.Find <UILabel>("Label"); label.text = text; } UISlider uISlider = uIPanel.Find <UISlider>("Slider"); uISlider.minValue = min; uISlider.maxValue = max; uISlider.stepSize = step; uISlider.value = defaultValue; uISlider.eventValueChanged += delegate(UIComponent c, float val) { eventCallback(val); }; return(uISlider); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create slider with no name or no event"); label = null; return(null); }
public static void Log(string str) { var message = Prefix + str; DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, message); UE.Debug.Log(message); }
private void RemoveClickEvent(UIButton b) { try { FieldInfo f1 = typeof(UIComponent).GetField("eventClick", BindingFlags.NonPublic | BindingFlags.Instance); EventInfo e1 = typeof(UIComponent).GetEvent("eventClick", BindingFlags.Public | BindingFlags.Instance); if (f1 == null) { return; } if (e1 == null) { return; } MulticastDelegate d1 = f1.GetValue(b as UIComponent) as MulticastDelegate; if (d1 != null) { e1.RemoveEventHandler(b, d1); } } catch (Exception ex) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("removeclickevent() exception: {0}", ex.Message)); } }
// Custom method to delete a single message - uses ChirpMessages. private void DeleteMessage(ChirpMessage message) { // Get container for chirps Transform container = chirpPane.transform.FindChild("Chirps").FindChild("Clipper").FindChild("Container").gameObject.transform; for (int i = 0; i < container.childCount; ++i) { if (container.GetChild(i).GetComponentInChildren <UILabel>().text.Equals(message.GetText())) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Deleted Message:" + message.text); // Remove both visual and internal message. UITemplateManager.RemoveInstance("ChirpTemplate", container.GetChild(i).GetComponent <UIPanel>()); // Find the original message, remove it from manager. IChirperMessage delMessage; messageMap.TryGetValue(message, out delMessage); messageManager.DeleteMessage(delMessage); if (!userOpened) { chirpPane.Collapse(); } return; } } }
// Custom method to filter all messages private void FilterMessages() { Transform container = chirpPane.transform.FindChild("Chirps").FindChild("Clipper").FindChild("Container").gameObject.transform; foreach (ChirpMessage message in messageFilterMap.Keys) { // Check if we flagged it as garbage. bool filtered = false; messageFilterMap.TryGetValue(message, out filtered); if (filtered) { // Remove all instances of the message. try { DeleteMessage(message); messageFilterMap.Remove(message); messageMap.Remove(message); if (hashTaggedMessages.Contains(message)) { hashTaggedMessages.Remove(message); } } catch (Exception e) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Error: " + e.Message); } } } }
public static void LoadConfig() { try { var xmlSerializer = new XmlSerializer(typeof(MyConfig)); using (var reader = new StreamReader("ChirpBannerConfig.xml")) { ConfigHolder.Config = (MyConfig)xmlSerializer.Deserialize(reader); } } catch (FileNotFoundException) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("No config xml")); } /* * //MyConfig.Serialize("ChirpBannerConfig.xml", ChirpyBanner.CurrentConfig); * ChirpyBanner.CurrentConfig = MyConfig.Deserialize ("ChirpBannerConfig.xml"); * if (ChirpyBanner.CurrentConfig == null) { * ChirpyBanner.CurrentConfig = new MyConfig (); * * MyConfig.Serialize ("ChirpBannerConfig.xml", ChirpyBanner.CurrentConfig); * } * // if old version, update with new * if (ChirpyBanner.CurrentConfig.version == 0 || ChirpyBanner.CurrentConfig.version < currversion) { // update this when we add any new settings * ChirpyBanner.CurrentConfig.version = currversion; * MyConfig.Serialize ("ChirpBannerConfig.xml", ChirpyBanner.CurrentConfig); * } * * MyConfig.Serialize ("ChirpBannerConfig.xml", ChirpyBanner.CurrentConfig); */ }
private static Type GetManagerType(ulong modId, string typeName) { var mod = PluginManager.instance.GetPluginsInfo() .FirstOrDefault(pi => pi.name.Contains(modId.ToString())); if (mod?.isEnabled != true) { return(null); } var assembly = mod.GetAssemblies()?.FirstOrDefault(); if (assembly == null) { Log.Warning($"'Real Time' compatibility check: the mod {modId} has no assemblies."); return(null); } try { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "Real Time Offline: Time compatibility enabled."); return(assembly.GetType(typeName)); } catch (Exception ex) { Log.Warning($"'Real Time' compatibility check: the mod {modId} doesn't contain the '{typeName}' type: {ex}"); return(null); } }
private void loadAPIButton_eventClick(UIComponent component, UIMouseEventParameter eventParam) { Debug.Log("loadAPIButton_eventClick"); try { Debug.Log("GetBounds()"); ob = GetBounds(); Debug.Log("new OpenStreeMapFrRequest"); var streetMapRequest = new OpenStreeMapFrRequest(ob); Debug.Log("DebugOutputPanel.AddMessage"); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.NodeRequestUrl); Debug.Log("DebugOutputPanel.AddMessage"); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.WaysRequestUrl); Debug.Log("new WebClient()"); var nodesWebClient = new WebClient(); var nodeResponseData = nodesWebClient.DownloadData(new Uri(streetMapRequest.NodeRequestUrl)); NodesWebClientCallback(nodeResponseData); var waysWebClient = new WebClient(); var waysResponseData = waysWebClient.DownloadData(new Uri(streetMapRequest.WaysRequestUrl)); WaysWebClientCallback(waysResponseData); } catch (Exception ex) { Debug.Log(ex.ToString()); errorLabel.text = ex.ToString(); } }
//------------------------------------------------------------ // Force to reload the locale manager //------------------------------------------------------------ private void resetLocaleManager(String loc_name) { // Reload Locale Manager ColossalFramework.Globalization.LocaleManager.ForceReload(); string[] locales = ColossalFramework.Globalization.LocaleManager.instance.supportedLocaleIDs; for (int i = 0; i < locales.Length; i++) { #if (DEBUG) DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("Locale index: {0}, ID: {1}", i, locales[i])); #endif if (locales[i].Equals(loc_name)) { #if (DEBUG) DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("Find locale {0} at index: {1}", loc_name, i)); #endif ColossalFramework.Globalization.LocaleManager.instance.LoadLocaleByIndex(i); //thanks to: https://github.com/Mesoptier/SkylineToolkit/commit/d33f0bae67662df25bdf8ee2170d95a6999c3721 ColossalFramework.SavedString lang_setting = new ColossalFramework.SavedString("localeID", "gameSettings"); #if (DEBUG) DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("Current Language Setting: {0}", lang_setting.value)); #endif lang_setting.value = locale_name; ColossalFramework.GameSettings.SaveAll(); break; } } }
public DropDownColorSelector AddColorField(string name, Color defaultValue, OnColorChanged eventCallback, OnButtonClicked eventRemove) { if (eventCallback != null && !string.IsNullOrEmpty(name)) { UIPanel uIPanel = m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate)) as UIPanel; uIPanel.name = "DropDownColorSelector"; uIPanel.Find <UILabel>("Label").text = name; GameObject.Destroy(uIPanel.Find <UIDropDown>("Dropdown").gameObject); DropDownColorSelector ddcs = new DropDownColorSelector(uIPanel, defaultValue); ddcs.eventColorChanged += (Color32 value) => { eventCallback(value); }; ddcs.eventOnRemove += () => { if (eventRemove != null) { eventRemove(); } }; return(ddcs); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create colorPicker with no name or no event"); return(null); }
private static void LogToConsole(LogType type, string message) { if (UserModSettings.Settings.Logging_ToConsole) { DebugOutputPanel.AddMessage(ConvertToConsoleMessageType(type), message); } }
public NumberedColorList AddNumberedColorList(string name, List <Color32> defaultValues, OnButtonSelect <int> eventCallback, UIComponent addButtonContainer, OnButtonClicked eventAdd) { if (eventCallback != null) { UIPanel uIPanel = m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate)) as UIPanel; uIPanel.name = "NumberedColorList"; if (string.IsNullOrEmpty(name)) { uIPanel.Find <UILabel>("Label").text = ""; } else { uIPanel.Find <UILabel>("Label").text = name; } GameObject.Destroy(uIPanel.Find <UIDropDown>("Dropdown").gameObject); NumberedColorList ddcs = new NumberedColorList(uIPanel, defaultValues, addButtonContainer); ddcs.eventOnClick += (int value) => { eventCallback(value); }; ddcs.eventOnAdd += () => { if (eventAdd != null) { eventAdd(); } }; return(ddcs); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create colorPicker with no name or no event"); return(null); }
public static UIDropDown CloneBasicDropDownLocalized(string text, string[] options, OnDropdownSelectionChanged eventCallback, int defaultSelection, UIComponent parent, out UILabel label, out UIPanel container, bool limitLabelByPanelWidth = false) { if (eventCallback != null && !string.IsNullOrEmpty(text)) { container = parent.AttachUIComponent(UITemplateManager.GetAsGameObject(kDropdownTemplate)) as UIPanel; container.transform.localScale = Vector3.one; label = container.Find <UILabel>("Label"); label.localeID = text; label.isLocalized = true; if (limitLabelByPanelWidth) { KlyteMonoUtils.LimitWidthAndBox(label, (uint)container.width); } UIDropDown uIDropDown = container.Find <UIDropDown>("Dropdown"); uIDropDown.items = options; uIDropDown.selectedIndex = defaultSelection; uIDropDown.eventSelectedIndexChanged += delegate(UIComponent c, int sel) { eventCallback(sel); }; return(uIDropDown); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create dropdown with no name or no event"); label = null; container = null; return(null); }
public TextList <T> AddTextList <T>(string name, Dictionary <T, string> defaultValues, OnButtonSelect <T> eventCallback, int width, int height) { if (eventCallback != null) { UIPanel uIPanel = m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate)) as UIPanel; uIPanel.name = "NumberedColorList"; if (string.IsNullOrEmpty(name)) { uIPanel.Find <UILabel>("Label").text = ""; } else { uIPanel.Find <UILabel>("Label").text = name; } GameObject.Destroy(uIPanel.Find <UIDropDown>("Dropdown").gameObject); TextList <T> ddcs = new TextList <T>(uIPanel, defaultValues, width, height, name); ddcs.eventOnClick += (T value) => { eventCallback(value); }; return(ddcs); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create colorPicker with no name or no event"); return(null); }
public static void ValueChangedMessage(string objectName, string paramName, float oldValue, float newValue) { if (ShowMessages) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("{0}: {1} changed from {2} to {3}", objectName, paramName, oldValue, newValue)); } }
//send essential data to server in this funtion(the most current saveGame and maybe in future some statistics collected) public static void sendSaveToServer(Object source, ElapsedEventArgs eventArgs) { string pathAndFileName = ClientData.savePath + ClientData.SAVE_FILE_NAME + ".crp"; if (!File.Exists(pathAndFileName)) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Error, " Savefile did not exist!"); throw new FileNotFoundException("File " + pathAndFileName + " was not found!"); } //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "SendDataToServer()"); byte[] responseByte = new byte[1]; var clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); clientSocket.Connect(ClientData.hostIP, Message.PORT); clientSocket.Send(new Message(ClientData.name, ClientData.code, MessageStrings.saveToHost).messageAsByteArray()); clientSocket.Receive(responseByte); if (responseByte[0] != (byte)PMCommunication.Responses.ReceivingSave) { throw new Exception("Host was not willing to receive a savefile for unknown reason"); } clientSocket.SendFile(pathAndFileName); clientSocket.Close(); //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "Save file sent now"); TurnData.nullifyTurnData(); }
/// <summary> /// Save the config file changes /// </summary> /// <param name="component"></param> /// <param name="eventParam"></param> void saveButton_eventClick(UIComponent component, UIMouseEventParameter eventParam) { try { Configuration.ConfigurationSettings.UserName = _twitchUserNameTextField.text; Configuration.ConfigurationSettings.OAuthKey = _oauthKeyTextField.text; Configuration.ConfigurationSettings.IrcChannel = _channelTextField.text; int parsed; if (int.TryParse(_delayBetweenChirperMessagesTextField.text, out parsed)) { if (Configuration.ConfigurationSettings.DelayBetweenChirperMessages != parsed) { Configuration.ConfigurationSettings.DelayBetweenChirperMessages = parsed; ChirperExtension.GetChirperManager.ChangeTimerDelay(parsed); } } Configuration.SaveConfigFile(); if (ChirperExtension.IrcClient != null) { ChirperExtension.IrcClient.Reconnect(Configuration.ConfigurationSettings.UserName, Configuration.ConfigurationSettings.OAuthKey, Configuration.ConfigurationSettings.IrcChannel); } } catch (Exception ex) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, ex.Source + " " + ex.TargetSite); ChirperExtension.Logger.AddEntry(ex); } this.Hide(); }
//------------------------------------------------------------ // Copy the locale file //------------------------------------------------------------ private void copyLocaleFile(String dst_path) { Assembly asm = Assembly.GetExecutingAssembly(); Stream src = asm.GetManifestResourceStream(asm.GetName().Name + "." + locale_name + ".locale"); #if (DEBUG) DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("File size: {0}", src.Length)); #endif //File.OpenWrite won't truncate file, so delete it first File.Delete(dst_path); FileStream dst = File.OpenWrite(dst_path); byte[] buffer = new byte[8 * 1024]; int len = 0; while ((len = src.Read(buffer, 0, buffer.Length)) > 0) { dst.Write(buffer, 0, len); } dst.Close(); src.Close(); #if (DEBUG) DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("File write to: {0}", Path.GetFullPath(dst.Name))); #endif }
public bool init() { if (m_initialized == true) { return(true); } UIComponent bullBar = UIView.Find("BulldozerBar"); if (bullBar == null) { return(false); } GameObject obDemolishAbandoned = new GameObject(); UIButton checkDemolishAbandoned = obDemolishAbandoned.AddComponent <UIButton>(); ToolTipUpdateTimer.Interval = 5000; ToolTipUpdateTimer.Elapsed += ToolTipUpdateTimer_Elapsed; ToolTipUpdateTimer.Start(); checkDemolishAbandoned.transform.parent = bullBar.transform; checkDemolishAbandoned.transformPosition = new Vector3(-1.0f, 0.0f); checkDemolishAbandoned.text = "Abandoned"; nullAudioGroup = new AudioGroup(0, new SavedFloat("NOTEXISTINGELEMENT", Settings.gameSettingsFile, 0, false)); DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, "[Autobulldoze] Initialized"); m_initialized = true; return(true); }
//============================================================ // Main //============================================================ private void CopyLocaleAndReloadLocaleManager() { try { Boolean first_install = true; String dst_path = getDestinationPath(); if (dst_path.Length > 0) { if (File.Exists(dst_path)) { #if (DEBUG) DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "Locale file is found, user has already used this mod before."); #endif first_install = false; } copyLocaleFile(dst_path); if (first_install == true) { resetLocaleManager(locale_name); } } } catch (Exception e) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Error, e.ToString()); } }
void LogMsg(string msg) { Debug.Log(msg); #if dbg DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, msg); #endif }
//------------------------------------------------------------ // Create destination path to copy the locale file to //------------------------------------------------------------ private string getDestinationPath() { String dst_path = ""; #if (DEBUG) DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("OS Type: {0}", RunningPlatform().ToString())); #endif switch (RunningPlatform()) { case Platform.Windows: dst_path = "Files\\Locale\\" + locale_name + ".locale"; break; case Platform.Mac: dst_path = "Cities.app/Contents/Resources/Files/Locale/" + locale_name + ".locale"; break; case Platform.Linux: dst_path = "Files/Locale/" + locale_name + ".locale"; break; } #if (DEBUG) DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, String.Format("Destination {0}", dst_path)); #endif return(dst_path); }
private void loadAPIButton_eventClick(UIComponent component, UIMouseEventParameter eventParam) { ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback; try { ob = GetBounds(); // In LoadAPIButton //var streetMapRequest = new OpenStreeMapFrRequest(ob); //var streetMapRequest = new OpenStreeMapApi0_6Request(ob); var streetMapRequest = new OverpassRequest(ob); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.NodeRequestUrl); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.WaysRequestUrl); var nodesWebClient = new WebClient(); nodesWebClient.DownloadDataCompleted += NodesWebClientCallback; Debug.Log("NodeRequestUrl:" + streetMapRequest.NodeRequestUrl); nodesWebClient.DownloadDataAsync(new Uri(streetMapRequest.NodeRequestUrl)); var waysWebClient = new WebClient(); Debug.Log("WaysRequestUrl:" + streetMapRequest.WaysRequestUrl); waysWebClient.DownloadDataCompleted += WaysWebClientCallback; waysWebClient.DownloadDataAsync(new Uri(streetMapRequest.WaysRequestUrl)); } catch (Exception ex) { errorLabel.text = ex.ToString(); } }
public override void OnLevelLoaded(LoadMode mode) { GoogleApiHandler apiHandler = new GoogleApiHandler(); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "ApiHandler construtor has been called."); apiHandler.SendRefreshTokenRequestRequest(); }