Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.IO;
- using System.Threading;
- using System.Timers;
- using System.Linq;
- using System.Xml;
- using Decal.Adapter;
- using Decal.Adapter.Wrappers;
- using MyClasses.MetaViewWrappers;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- using VirindiViewService.Controls;
- using System.Data;
- using System.Data.Linq;
- namespace UtilityBelt.Tools {
- class EmuConfig : IDisposable {
- // this will hold a reference to our ui button for UseDeception
- //HudButton UIEmuConfigUseDeception { get; set; }
- //HudList UIEmuConfigLabelList { get; set; }
- HudList UIEmuConfigList { get; set; }
- //HudCheckBox UIConfigCheckBox { get; set; }
- DataTable emuConfigDataTable = new DataTable();
- private bool disposed = false;
- //private static readonly Regex EmuConfigRegex = new Regex(@"(?<ConfigHeader>.*) settings:[\n]+(?<ConfigValues>[a-zA-Z ,]+)");
- private static readonly Regex EmuConfigRegex = new Regex(@"(?<ConfigHeader>.*) settings:\n(?<ConfigValues>.*)");
- //private string configValuesArray;
- public EmuConfig() {
- UIEmuConfigList = Globals.View.view != null ? (HudList)Globals.View.view["EmuConfigList"] : new HudList();
- //UIConfigCheckBox = Globals.View.view != null ? (HudCheckBox)Globals.View.view["ConfigCheckBox"] : new HudCheckBox();
- Globals.Core.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(Current_ChatBoxMessage);
- Globals.Core.Actions.InvokeChatParser("/config list");
- // Find the button in the view, or create if it doesnt exist (which is bad and shouldnt happen)
- //UIEmuConfigUseDeception = Globals.View.view != null ? (HudButton)Globals.View.view["EmuConfigUseDeception"] : new HudButton();
- // listen to Hit (click) event on the button
- //UIEmuConfigUseDeception.Hit += (s, e) => { ToggleConfig("UseDeception"); };
- //UIEmuConfigUseDeception = Globals.View.view != null ? (HudButton)Globals.View.view["EmuConfigUseDeception"] : new HudButton();
- // listen to Hit (click) event on the button
- //UIEmuConfigUseDeception.Hit += (s, e) => { ToggleConfig("UseDeception"); };
- }
- public void CreateDataTable() {
- emuConfigDataTable.Columns.Add("ConfigHeader");
- emuConfigDataTable.Columns.Add("ConfigName");
- emuConfigDataTable.Columns.Add("ConfigValue");
- }
- public void Current_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e) {
- try {
- //Util.WriteToChat(e.Text);
- Match match = EmuConfigRegex.Match(e.Text);
- if (match.Success) {
- e.Eat = true;
- string configHeader = match.Groups["ConfigHeader"].Value;
- string configValues = match.Groups["ConfigValues"].Value;
- string[] configValuesArray = (configValues.Split(','));
- HudList.HudListRowAccessor newHeaderRow = UIEmuConfigList.AddRow();
- ((HudStaticText)newHeaderRow[0]).Text = configHeader.Trim() + " settings";
- ((HudStaticText)newHeaderRow[0]).TextColor = System.Drawing.Color.Goldenrod;
- Util.WriteToChat(configHeader.Trim());
- foreach(string configValue in configValuesArray) {
- // Regex.Replace(configValue, "([A-Z])", " $1").Trim();
- HudList.HudListRowAccessor newValueRow = UIEmuConfigList.AddRow();
- ((HudStaticText)newValueRow[0]).Text = " " + Regex.Replace(configValue, "([A-Z]+)", " $1").Trim();
- ((HudCheckBox)newValueRow[1]).Checked = false;
- // ((HudStaticText)newValueRow[0]).TextColor = System.Drawing.Color.Gold;
- Util.WriteToChat(" "+configValue.Trim());
- }
- }
- else {
- //Util.WriteToChat(e.Text);
- }
- } catch (Exception ex) { Util.LogException(ex); }
- }
- public enum CharacterOptionsKeys{
- }
- //if ((Globals.Core.CharacterFilter.CharacterOptions & 0x00000002) != 0) { "this setting is on" };
- // sends a /config command to toggle a setting
- private void ToggleConfig(string setting) {
- try {
- Util.DispatchChatToBoxWithPluginIntercept(string.Format("/config {0}", setting));
- }
- catch (Exception ex) { Util.LogException(ex); }
- }
- public void Dispose() {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
- protected virtual void Dispose(bool disposing) {
- if (!disposed) {
- if (disposing) {
- Globals.Core.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(Current_ChatBoxMessage);
- }
- disposed = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement