Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.IO;
  4. using System.Threading;
  5. using System.Timers;
  6. using System.Linq;
  7. using System.Xml;
  8. using Decal.Adapter;
  9. using Decal.Adapter.Wrappers;
  10. using MyClasses.MetaViewWrappers;
  11. using System.Text.RegularExpressions;
  12. using System.Collections.Generic;
  13. using VirindiViewService.Controls;
  14. using System.Data;
  15. using System.Data.Linq;
  16.  
  17. namespace UtilityBelt.Tools {
  18. class EmuConfig : IDisposable {
  19.  
  20. // this will hold a reference to our ui button for UseDeception
  21. //HudButton UIEmuConfigUseDeception { get; set; }
  22. //HudList UIEmuConfigLabelList { get; set; }
  23. HudList UIEmuConfigList { get; set; }
  24. //HudCheckBox UIConfigCheckBox { get; set; }
  25.  
  26. DataTable emuConfigDataTable = new DataTable();
  27.  
  28. private bool disposed = false;
  29. //private static readonly Regex EmuConfigRegex = new Regex(@"(?<ConfigHeader>.*) settings:[\n]+(?<ConfigValues>[a-zA-Z ,]+)");
  30. private static readonly Regex EmuConfigRegex = new Regex(@"(?<ConfigHeader>.*) settings:\n(?<ConfigValues>.*)");
  31. //private string configValuesArray;
  32.  
  33.  
  34. public EmuConfig() {
  35. UIEmuConfigList = Globals.View.view != null ? (HudList)Globals.View.view["EmuConfigList"] : new HudList();
  36. //UIConfigCheckBox = Globals.View.view != null ? (HudCheckBox)Globals.View.view["ConfigCheckBox"] : new HudCheckBox();
  37. Globals.Core.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(Current_ChatBoxMessage);
  38. Globals.Core.Actions.InvokeChatParser("/config list");
  39. // Find the button in the view, or create if it doesnt exist (which is bad and shouldnt happen)
  40. //UIEmuConfigUseDeception = Globals.View.view != null ? (HudButton)Globals.View.view["EmuConfigUseDeception"] : new HudButton();
  41. // listen to Hit (click) event on the button
  42. //UIEmuConfigUseDeception.Hit += (s, e) => { ToggleConfig("UseDeception"); };
  43.  
  44. //UIEmuConfigUseDeception = Globals.View.view != null ? (HudButton)Globals.View.view["EmuConfigUseDeception"] : new HudButton();
  45. // listen to Hit (click) event on the button
  46. //UIEmuConfigUseDeception.Hit += (s, e) => { ToggleConfig("UseDeception"); };
  47.  
  48. }
  49.  
  50. public void CreateDataTable() {
  51. emuConfigDataTable.Columns.Add("ConfigHeader");
  52. emuConfigDataTable.Columns.Add("ConfigName");
  53. emuConfigDataTable.Columns.Add("ConfigValue");
  54. }
  55.  
  56.  
  57. public void Current_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e) {
  58. try {
  59. //Util.WriteToChat(e.Text);
  60.  
  61. Match match = EmuConfigRegex.Match(e.Text);
  62.  
  63. if (match.Success) {
  64. e.Eat = true;
  65.  
  66. string configHeader = match.Groups["ConfigHeader"].Value;
  67. string configValues = match.Groups["ConfigValues"].Value;
  68. string[] configValuesArray = (configValues.Split(','));
  69.  
  70. HudList.HudListRowAccessor newHeaderRow = UIEmuConfigList.AddRow();
  71. ((HudStaticText)newHeaderRow[0]).Text = configHeader.Trim() + " settings";
  72. ((HudStaticText)newHeaderRow[0]).TextColor = System.Drawing.Color.Goldenrod;
  73.  
  74. Util.WriteToChat(configHeader.Trim());
  75. foreach(string configValue in configValuesArray) {
  76.  
  77. // Regex.Replace(configValue, "([A-Z])", " $1").Trim();
  78. HudList.HudListRowAccessor newValueRow = UIEmuConfigList.AddRow();
  79. ((HudStaticText)newValueRow[0]).Text = " " + Regex.Replace(configValue, "([A-Z]+)", " $1").Trim();
  80. ((HudCheckBox)newValueRow[1]).Checked = false;
  81. // ((HudStaticText)newValueRow[0]).TextColor = System.Drawing.Color.Gold;
  82.  
  83.  
  84. Util.WriteToChat(" "+configValue.Trim());
  85. }
  86. }
  87. else {
  88. //Util.WriteToChat(e.Text);
  89. }
  90. } catch (Exception ex) { Util.LogException(ex); }
  91. }
  92.  
  93.  
  94. public enum CharacterOptionsKeys{
  95. }
  96.  
  97.  
  98. //if ((Globals.Core.CharacterFilter.CharacterOptions & 0x00000002) != 0) { "this setting is on" };
  99.  
  100. // sends a /config command to toggle a setting
  101. private void ToggleConfig(string setting) {
  102. try {
  103. Util.DispatchChatToBoxWithPluginIntercept(string.Format("/config {0}", setting));
  104. }
  105. catch (Exception ex) { Util.LogException(ex); }
  106. }
  107.  
  108. public void Dispose() {
  109. Dispose(true);
  110. GC.SuppressFinalize(this);
  111.  
  112. }
  113.  
  114. protected virtual void Dispose(bool disposing) {
  115. if (!disposed) {
  116. if (disposing) {
  117. Globals.Core.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(Current_ChatBoxMessage);
  118. }
  119. disposed = true;
  120. }
  121. }
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement