getSetting() public static méthode

public static getSetting ( string key ) : List
key string
Résultat List
Exemple #1
0
 private static void writeToAutoHotkeyFile()
 {
     if (!SettingsManager.settingExists("AutoHotkeySettings"))
     {
         return;
     }
     using (StreamWriter writer = new StreamWriter(Constants.AutohotkeyFile)) {
         writer.WriteLine("#SingleInstance force");
         writer.WriteLine("SetTitleMatchMode 3");
         if (ProcessManager.TibiaClientType != "Classic")
         {
             Process p = ProcessManager.GetTibiaProcess();
             writer.WriteLine(String.Format("#IfWinActive ahk_pid {0}", p == null ? 0 : p.Id));
         }
         else
         {
             writer.WriteLine("#IfWinActive ahk_class TibiaClient");
         }
         foreach (string l in SettingsManager.getSetting("AutoHotkeySettings"))
         {
             string line = l.ToLower();
             if (line.Length == 0 || line[0] == ';')
             {
                 continue;
             }
             if (line.Contains("suspend"))
             {
                 // if the key is set to suspend the hotkey layout, we set it up so it sends a message to us
                 writer.WriteLine(modifyKeyString(line.ToLower().Split(new string[] { "suspend" }, StringSplitOptions.None)[0], l));
                 writer.WriteLine("suspend");
                 writer.WriteLine("if (A_IsSuspended)");
                 // message 32 is suspend
                 writer.WriteLine("PostMessage, 0x317,32,32,,Tibialyzer");
                 writer.WriteLine("else");
                 // message 33 is not suspended
                 writer.WriteLine("PostMessage, 0x317,33,33,,Tibialyzer");
                 writer.WriteLine("return");
             }
             else
             {
                 writer.WriteLine(modifyKeyString(line, l));
             }
         }
     }
 }
Exemple #2
0
        public HealthList()
        {
            InitializeComponent();

            this.BackColor       = StyleManager.BlendTransparencyKey;
            this.TransparencyKey = StyleManager.BlendTransparencyKey;

            displayNames    = SettingsManager.getSettingBool(GetHUD() + "DisplayNames");
            displayIcons    = SettingsManager.getSettingBool(GetHUD() + "DisplayIcons");
            displayText     = SettingsManager.getSettingBool(GetHUD() + "DisplayText");
            healthBarHeight = SettingsManager.getSettingInt(GetHUD() + "Height");
            playerBarHeight = displayNames ? healthBarHeight * 5 / 3 : healthBarHeight;

            List <string> names = SettingsManager.getSetting(GetHUD() + "PlayerNames");
            int           index = 0;

            foreach (string name in names)
            {
                if (name.Trim() == "")
                {
                    continue;
                }
                string imagePath = SettingsManager.getSettingString(GetHUD() + "Image" + index.ToString());
                Image  image     = null;
                if (imagePath != null)
                {
                    try {
                        image = Image.FromFile(imagePath);
                    } catch { }
                }
                this.players.Add(new PlayerEntry {
                    name = name, playerImage = image
                });
                index++;
            }

            double opacity = SettingsManager.getSettingDouble(GetHUD() + "Opacity");

            opacity      = Math.Min(1, Math.Max(0, opacity));
            this.Opacity = opacity;
        }
Exemple #3
0
        public static IEnumerable <string> UpdateCommands(Dictionary <string, List <Tuple <string, string> > > newCommands)
        {
            string extraPlayer = SettingsManager.getSettingBool("AutomaticallyDetectCharacter") ? MemoryReader.PlayerName : null;

            lock (totalCommands) {
                foreach (KeyValuePair <string, List <Tuple <string, string> > > kvp in newCommands)
                {
                    string t = kvp.Key;
                    List <Tuple <string, string> > currentCommands = kvp.Value;
                    if (!totalCommands.ContainsKey(t))
                    {
                        totalCommands[t] = new List <Tuple <string, string> >();
                    }
                    if (currentCommands.Count > totalCommands[t].Count)
                    {
                        List <Tuple <string, string> > unseenCommands = new List <Tuple <string, string> >();
                        List <Tuple <string, string> > commandsList   = totalCommands[t].ToList(); // create a copy of the list
                        foreach (Tuple <string, string> command in currentCommands)
                        {
                            if (!totalCommands[t].Contains(command))
                            {
                                unseenCommands.Add(command);
                                string player = command.Item1;
                                string cmd    = command.Item2;
                                if (SettingsManager.getSetting("Names").Contains(player) || (extraPlayer != null && player.Equals(extraPlayer, StringComparison.InvariantCultureIgnoreCase)))
                                {
                                    yield return(cmd);
                                }
                            }
                            else
                            {
                                totalCommands[t].Remove(command);
                            }
                        }
                        commandsList.AddRange(unseenCommands);
                        totalCommands[t] = commandsList;
                    }
                }
            }
            yield break;
        }
Exemple #4
0
        public void InitializeSettings()
        {
            customCommands.Clear();
            foreach (string str in SettingsManager.getSetting("CustomCommands"))
            {
                string[] split = str.Split('#');
                if (split.Length <= 2)
                {
                    continue;
                }
                customCommands.Add(new SystemCommand {
                    tibialyzer_command = split[0], command = split[1], parameters = split[2]
                });
            }

            if (customCommands.Count == 0)
            {
                customCommands.Add(new SystemCommand {
                    tibialyzer_command = "Unknown Command", command = "", parameters = ""
                });
            }

            customCommandList.Items.Clear();
            foreach (SystemCommand c in customCommands)
            {
                customCommandList.Items.Add(c.tibialyzer_command);
            }
            customCommandList.ItemsChanged      += CustomCommandList_ItemsChanged;
            customCommandList.ChangeTextOnly     = true;
            customCommandList.AttemptDeleteItem += CustomCommandList_AttemptDeleteItem;
            customCommandList.AttemptNewItem    += CustomCommandList_AttemptNewItem;
            customCommandList.RefreshControl();
            CustomCommandList_ItemsChanged(null, null);

            automaticallyBackupSettingsCheckbox.Checked = SettingsManager.getSettingBool("AutomaticSettingsBackup");
            Constants.OBSEnableWindowCapture            = SettingsManager.getSettingBool("OBSEnableWindowCapture");
            enableWindowCaptureCheckbox.Checked         = Constants.OBSEnableWindowCapture;

            this.maxDamageDropDownList.SelectedIndex = Math.Min(Math.Max(SettingsManager.getSettingInt("MaxDamageChartPlayers"), 0), maxDamageDropDownList.Items.Count - 1);
        }
 public static IEnumerable <string> UpdateCommands(Dictionary <string, List <Tuple <string, string> > > newCommands)
 {
     lock (totalCommands) {
         foreach (KeyValuePair <string, List <Tuple <string, string> > > kvp in newCommands)
         {
             string t = kvp.Key;
             List <Tuple <string, string> > currentCommands = kvp.Value;
             if (!totalCommands.ContainsKey(t))
             {
                 totalCommands[t] = new List <Tuple <string, string> >();
             }
             if (currentCommands.Count > totalCommands[t].Count)
             {
                 List <Tuple <string, string> > unseenCommands = new List <Tuple <string, string> >();
                 List <Tuple <string, string> > commandsList   = totalCommands[t].ToList(); // create a copy of the list
                 foreach (Tuple <string, string> command in currentCommands)
                 {
                     if (!totalCommands[t].Contains(command))
                     {
                         unseenCommands.Add(command);
                         string player = command.Item1;
                         string cmd    = command.Item2;
                         if (SettingsManager.getSetting("Names").Contains(player))
                         {
                             yield return(cmd);
                         }
                     }
                     else
                     {
                         totalCommands[t].Remove(command);
                     }
                 }
                 commandsList.AddRange(unseenCommands);
                 totalCommands[t] = commandsList;
             }
         }
     }
     yield break;
 }
Exemple #6
0
        public void InitializeSettings()
        {
            customCommands.Clear();
            foreach (string str in SettingsManager.getSetting("CustomCommands"))
            {
                string[] split = str.Split('#');
                if (split.Length <= 2)
                {
                    continue;
                }
                customCommands.Add(new SystemCommand {
                    tibialyzer_command = split[0], command = split[1], parameters = split[2]
                });
            }

            if (customCommands.Count == 0)
            {
                customCommands.Add(new SystemCommand {
                    tibialyzer_command = "Unknown Command", command = "", parameters = ""
                });
            }

            customCommandList.Items.Clear();
            foreach (SystemCommand c in customCommands)
            {
                customCommandList.Items.Add(c.tibialyzer_command);
            }
            customCommandList.ItemsChanged      += CustomCommandList_ItemsChanged;
            customCommandList.ChangeTextOnly     = true;
            customCommandList.AttemptDeleteItem += CustomCommandList_AttemptDeleteItem;
            customCommandList.AttemptNewItem    += CustomCommandList_AttemptNewItem;
            customCommandList.RefreshControl();
            CustomCommandList_ItemsChanged(null, null);

            Constants.OBSEnableWindowCapture = SettingsManager.getSettingBool("OBSEnableWindowCapture");
            enableWindowCapture.Checked      = Constants.OBSEnableWindowCapture;
        }
Exemple #7
0
        public void InitializeSettings()
        {
            this.popupAnchorBox.SelectedIndex = Math.Min(Math.Max(SettingsManager.getSettingInt("SimpleNotificationAnchor"), 0), 3);
            this.popupXOffsetBox.Text         = SettingsManager.getSettingInt("SimpleNotificationXOffset").ToString();
            this.popupYOffsetBox.Text         = SettingsManager.getSettingInt("SimpleNotificationYOffset").ToString();

            popupSpecificItemBox.Items.Clear();
            foreach (string str in SettingsManager.getSetting("NotificationItems"))
            {
                popupSpecificItemBox.Items.Add(str);
            }
            popupSpecificItemBox.ItemsChanged += PopupSpecificItemBox_ItemsChanged;
            popupSpecificItemBox.verifyItem    = StorageManager.itemExists;
            popupSpecificItemBox.RefreshControl();

            popupConditionBox.Items.Clear();
            foreach (string str in SettingsManager.getSetting("NotificationConditions"))
            {
                popupConditionBox.Items.Add(str);
            }
            popupConditionBox.ItemsChanged += PopupConditionBox_ItemsChanged;
            popupConditionBox.verifyItem    = NotificationConditionManager.ValidCondition;
            popupConditionBox.RefreshControl();
        }
Exemple #8
0
        public static void Initialize()
        {
            //"Name#DBTableID#Track#Time#Exp#SideHunt#AggregateHunt#ClearOnStartup#Creature#Creature#..."
            if (!SettingsManager.settingExists("Hunts"))
            {
                SettingsManager.setSetting("Hunts", new List <string>()
                {
                    "New Hunt#True#0#0#False#True"
                });
            }
            hunts.Clear();
            int        activeHuntIndex = 0, index = 0;
            List <int> dbTableIds = new List <int>();

            foreach (string str in SettingsManager.getSetting("Hunts"))
            {
                SQLiteDataReader reader;
                Hunt             hunt   = new Hunt();
                string[]         splits = str.Split('#');
                if (splits.Length >= 7)
                {
                    hunt.name = splits[0];
                    if (!int.TryParse(splits[1].Trim(), out hunt.dbtableid))
                    {
                        continue;
                    }
                    if (dbTableIds.Contains(hunt.dbtableid))
                    {
                        continue;
                    }
                    dbTableIds.Add(hunt.dbtableid);

                    hunt.totalTime         = 0;
                    hunt.trackAllCreatures = splits[2] == "True";
                    double.TryParse(splits[3], NumberStyles.Any, CultureInfo.InvariantCulture, out hunt.totalTime);
                    long.TryParse(splits[4], out hunt.totalExp);
                    hunt.sideHunt       = splits[5] == "True";
                    hunt.aggregateHunt  = splits[6] == "True";
                    hunt.clearOnStartup = splits[7] == "True";
                    hunt.temporary      = false;
                    string massiveString = "";
                    for (int i = 8; i < splits.Length; i++)
                    {
                        if (splits[i].Length > 0)
                        {
                            massiveString += splits[i] + "\n";
                        }
                    }
                    hunt.trackedCreatures = massiveString;
                    // set this hunt to the active hunt if it is the active hunt
                    if (SettingsManager.settingExists("ActiveHunt") && SettingsManager.getSettingString("ActiveHunt") == hunt.name)
                    {
                        activeHuntIndex = index;
                    }

                    refreshLootCreatures(hunt);

                    if (hunt.clearOnStartup)
                    {
                        resetHunt(hunt);
                    }

                    // create the hunt table if it does not exist
                    LootDatabaseManager.CreateHuntTable(hunt);
                    // load the data for the hunt from the database
                    reader = LootDatabaseManager.GetHuntMessages(hunt);
                    while (reader.Read())
                    {
                        string message = reader["message"].ToString();
                        Tuple <Creature, List <Tuple <Item, int> > > resultList = Parser.ParseLootMessage(message);
                        if (resultList == null)
                        {
                            continue;
                        }

                        string t = message.Substring(0, 5);
                        if (!hunt.loot.logMessages.ContainsKey(t))
                        {
                            hunt.loot.logMessages.Add(t, new List <string>());
                        }
                        hunt.loot.logMessages[t].Add(message);

                        Creature cr = resultList.Item1;
                        if (!hunt.loot.creatureLoot.ContainsKey(cr))
                        {
                            hunt.loot.creatureLoot.Add(cr, new Dictionary <Item, int>());
                        }
                        foreach (Tuple <Item, int> tpl in resultList.Item2)
                        {
                            Item item  = tpl.Item1;
                            int  count = tpl.Item2;
                            if (!hunt.loot.creatureLoot[cr].ContainsKey(item))
                            {
                                hunt.loot.creatureLoot[cr].Add(item, count);
                            }
                            else
                            {
                                hunt.loot.creatureLoot[cr][item] += count;
                            }
                        }
                        if (!hunt.loot.killCount.ContainsKey(cr))
                        {
                            hunt.loot.killCount.Add(cr, 1);
                        }
                        else
                        {
                            hunt.loot.killCount[cr] += 1;
                        }
                    }
                    hunts.Add(hunt);
                    index++;
                }
            }
            if (hunts.Count == 0)
            {
                Hunt h = new Hunt();
                h.name      = "New Hunt";
                h.dbtableid = 1;
                hunts.Add(h);
                resetHunt(h);
            }
            activeHunt = hunts[activeHuntIndex];
            MainForm.mainForm.InitializeHuntDisplay(activeHuntIndex);
        }
Exemple #9
0
        public void initializeSettings()
        {
            SettingsManager.ApplyDefaultSettings();
            // convert legacy settings
            bool legacy = false;

            if (SettingsManager.settingExists("NotificationGoldRatio") || SettingsManager.settingExists("NotificationValue"))
            {
                // convert old notification conditions to new SQL conditions
                List <string> conditions = new List <string>();
                if (SettingsManager.settingExists("NotificationValue") && SettingsManager.getSettingBool("ShowNotificationsValue"))
                {
                    double value = SettingsManager.getSettingDouble("NotificationValue");
                    conditions.Add(String.Format("item.value >= {0}", value.ToString(CultureInfo.InvariantCulture)));
                }
                if (SettingsManager.settingExists("NotificationGoldRatio") && SettingsManager.getSettingBool("ShowNotificationsGoldRatio"))
                {
                    double value = SettingsManager.getSettingDouble("NotificationGoldRatio");
                    conditions.Add(String.Format("item.value / item.capacity >= {0}", value.ToString(CultureInfo.InvariantCulture)));
                }
                if (SettingsManager.getSettingBool("AlwaysShowLoot"))
                {
                    conditions.Add("1");
                }
                SettingsManager.removeSetting("NotificationGoldRatio");
                SettingsManager.removeSetting("NotificationValue");
                SettingsManager.removeSetting("ShowNotificationsGoldRatio");
                SettingsManager.removeSetting("ShowNotificationsValue");
                SettingsManager.removeSetting("AlwaysShowLoot");
                SettingsManager.setSetting("NotificationConditions", conditions);
                legacy = true;
            }
            if (SettingsManager.settingExists("NotificationDuration"))
            {
                int notificationLength = SettingsManager.getSettingInt("NotificationDuration") < 0 ? 30 : SettingsManager.getSettingInt("NotificationDuration");
                int anchor             = Math.Min(Math.Max(SettingsManager.getSettingInt("RichNotificationAnchor"), 0), 3);
                int xOffset            = SettingsManager.getSettingInt("RichNotificationXOffset") == -1 ? 30 : SettingsManager.getSettingInt("RichNotificationXOffset");
                int yOffset            = SettingsManager.getSettingInt("RichNotificationYOffset") == -1 ? 30 : SettingsManager.getSettingInt("RichNotificationYOffset");
                foreach (string obj in Constants.NotificationTypes)
                {
                    string settingObject = obj.Replace(" ", "");
                    SettingsManager.setSetting(settingObject + "Anchor", anchor);
                    SettingsManager.setSetting(settingObject + "XOffset", xOffset);
                    SettingsManager.setSetting(settingObject + "YOffset", yOffset);
                    SettingsManager.setSetting(settingObject + "Duration", notificationLength);
                    SettingsManager.setSetting(settingObject + "Group", 0);
                }
                SettingsManager.removeSetting("NotificationDuration");
                SettingsManager.removeSetting("RichNotificationAnchor");
                SettingsManager.removeSetting("RichNotificationXOffset");
                SettingsManager.removeSetting("RichNotificationYOffset");
                legacy = true;
            }
            if (legacy)
            {
                // legacy settings had "#" as comment symbol in AutoHotkey text, replace that with the new comment symbol ";"
                List <string> newAutoHotkeySettings = new List <string>();
                foreach (string str in SettingsManager.getSetting("AutoHotkeySettings"))
                {
                    newAutoHotkeySettings.Add(str.Replace('#', ';'));
                }
                SettingsManager.setSetting("AutoHotkeySettings", newAutoHotkeySettings);

                SettingsManager.setSetting("ScanSpeed", Math.Min(Math.Max(SettingsManager.getSettingInt("ScanSpeed") + 5, (Tabs[1] as SettingsTab).MinimumScanSpeed()), (Tabs[1] as SettingsTab).MaximumScanSpeed()));
            }

            foreach (TabInterface tab in Tabs)
            {
                tab.InitializeSettings();
            }
        }
Exemple #10
0
        public static bool ResolveConditions(Tuple <Creature, List <Tuple <Item, int> > > dropInformation)
        {
            List <string> conditions = SettingsManager.getSetting("NotificationConditions");

            var connection = new SQLiteConnection("Data Source=:memory:");

            connection.Open();

            SQLiteCommand command;

            command = new SQLiteCommand("CREATE TABLE item(name STRING, value INTEGER, capacity DOUBLE, count INTEGER)", connection);
            command.ExecuteNonQuery();
            command = new SQLiteCommand("CREATE TABLE creature(name STRING, exp INTEGER, hp INTEGER)", connection);
            command.ExecuteNonQuery();

            Creature cr = dropInformation.Item1;

            if (cr != null)
            {
                command = new SQLiteCommand(String.Format("INSERT INTO creature (name, exp, hp) VALUES (\"{0}\",{1},{2})", cr.GetName().Replace("\"", "\\\""), cr.experience, cr.health), connection);
                command.ExecuteNonQuery();
                if (dropInformation.Item2 != null && dropInformation.Item2.Count > 0)
                {
                    foreach (Tuple <Item, int> tpl in dropInformation.Item2)
                    {
                        Item it    = tpl.Item1;
                        int  count = tpl.Item2;
                        if (it == null)
                        {
                            continue;
                        }
                        command = new SQLiteCommand(String.Format("INSERT INTO item (name, value, capacity, count) VALUES (\"{0}\",{1},{2},{3})", it.GetName().Replace("\"", "\\\""), it.GetMaxValue(), it.capacity.ToString(CultureInfo.InvariantCulture), count), connection);
                        command.ExecuteNonQuery();
                    }
                }
                else
                {
                    command = new SQLiteCommand(String.Format("INSERT INTO item (name, value, capacity, count) VALUES (\"nothing\",0,1,1)"), connection);
                    command.ExecuteNonQuery();
                }
            }

            foreach (string condition in conditions)
            {
                if (condition.Trim().Length == 0)
                {
                    continue;
                }
                string query = String.Format("SELECT {0} FROM item,creature", condition);
                try {
                    command = new SQLiteCommand(query, connection);
                    SQLiteDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        double value = reader.GetDouble(0);
                        if (value > 0)
                        {
                            return(true);
                        }
                    }
                } catch {
                }
            }
            return(false);
        }