public MainForm() { startup = true; Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; mainForm = this; InitializeComponent(); SettingsManager.LoadSettings(Constants.SettingsFile); LootDatabaseManager.LootChanged += NotificationManager.UpdateLootDisplay; LootDatabaseManager.LootChanged += UpdateLogDisplay; GlobalDataManager.ExperienceChanged += NotificationManager.UpdateExperienceDisplay; GlobalDataManager.DamageChanged += NotificationManager.UpdateDamageDisplay; GlobalDataManager.UsedItemsChanged += NotificationManager.UpdateUsedItemsDisplay; if (!File.Exists(Constants.DatabaseFile)) { ExitWithError("Fatal Error", String.Format("Could not find database file {0}.", Constants.DatabaseFile)); } if (!File.Exists(Constants.NodeDatabase)) { ExitWithError("Fatal Error", String.Format("Could not find database file {0}.", Constants.NodeDatabase)); } LootDatabaseManager.Initialize(); StyleManager.InitializeStyle(); NotificationForm.Initialize(); Parser.Initialize(); PopupManager.Initialize(this.notifyIcon1); prevent_settings_update = true; try { StorageManager.InitializeStorage(); } catch (Exception e) { ExitWithError("Fatal Error", String.Format("Corrupted database {0}.\nMessage: {1}", Constants.DatabaseFile, e.Message)); } ProcessManager.Initialize(); this.initializeSettings(); try { Pathfinder.LoadFromDatabase(Constants.NodeDatabase); } catch (Exception e) { ExitWithError("Fatal Error", String.Format("Corrupted database {0}.\nMessage: {1}", Constants.NodeDatabase, e.Message)); } prevent_settings_update = false; this.InitializeTabs(); switchTab(0); makeDraggable(this.Controls); if (SettingsManager.getSettingBool("StartAutohotkeyAutomatically")) { AutoHotkeyManager.StartAutohotkey(); } ReadMemoryManager.Initialize(); HuntManager.Initialize(); UIManager.Initialize(); MemoryReader.Initialize(); HUDManager.Initialize(); GlobalDataManager.Initialize(); this.Load += MainForm_Load; fileWriter = new StreamWriter(Constants.BigLootFile, true); tibialyzerLogo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.draggable_MouseDown); startup = false; ScanningManager.StartScanning(); scan_tooltip.AutoPopDelay = 60000; scan_tooltip.InitialDelay = 500; scan_tooltip.ReshowDelay = 0; scan_tooltip.ShowAlways = true; scan_tooltip.UseFading = true; SetScanningImage("scanningbar-red.gif", "No Tibia Client Found...", true); }
public void UpdateLootForm() { Hunt hunt = HuntManager.activeHunt; int minheight, maxheight; ClearControlList(lootControls, out minheight, out maxheight); int counter; int y = minheight; if (maxheight < 0) { y = 30; foreach (Control c in summaryControls) { y = Math.Max(c.Location.Y + c.Height, y); } } var loot = LootDropForm.GenerateLootInformation(hunt, "", null); totalValue = 0; foreach (Tuple <Item, int> tpl in loot.Item2) { totalValue += tpl.Item1.GetMaxValue() * tpl.Item2; } averageValue = LootDropForm.GetAverageGold(loot.Item1); int maxDrops = SettingsManager.getSettingInt("SummaryMaxItemDrops"); if (maxDrops < 0) { maxDrops = 5; } if (maxDrops > 0) { List <ItemRegion> region; int imageHeight = SettingsManager.getSettingInt("SummaryLootItemSize"); imageHeight = imageHeight < 0 ? BlockHeight : imageHeight; CreateHeaderLabel("Item Drops", x, ref y, lootControls); counter = 0; bool display = true; int width = 0; var items = new List <Tuple <Item, int> >(); foreach (Tuple <Item, int> tpl in loot.Item2) { int amount = tpl.Item2; while (amount > 0) { int count = Math.Min(100, amount); amount -= count; items.Add(new Tuple <Item, int>(tpl.Item1, count)); width += imageHeight + 2; if (width > BlockWidth - imageHeight) { region = new List <ItemRegion>(); CreateItemList(items, x, ref y, lootControls, imageHeight, region, counter).MouseDown += OpenLootWindow; lootRegions[counter] = region; items.Clear(); width = 0; if (++counter >= maxDrops) { display = false; break; } } } if (!display) { break; } } if (items.Count > 0) { region = new List <ItemRegion>(); CreateItemList(items, x, ref y, lootControls, imageHeight, region, counter).MouseDown += OpenLootWindow; lootRegions[counter] = region; items.Clear(); } } int maxCreatures = SettingsManager.getSettingInt("SummaryMaxCreatures"); if (maxCreatures < 0) { maxCreatures = 5; } if (maxCreatures > 0) { CreateHeaderLabel("Creature Kills", x, ref y, lootControls); counter = 0; foreach (Creature cr in loot.Item1.Keys.OrderByDescending(o => loot.Item1[o] * (1 + o.experience)).ToList <Creature>()) { CreateCreatureBox(cr, loot.Item1[cr], x, ref y, lootControls); if (++counter >= maxCreatures) { break; } } } int maxRecentDrops = SettingsManager.getSettingInt("SummaryMaxRecentDrops"); if (maxRecentDrops < 0) { maxRecentDrops = 5; } if (maxRecentDrops > 0) { CreateHeaderLabel("Recent Drops", x, ref y, lootControls); int imageHeight = SettingsManager.getSettingInt("SummaryRecentDropsItemSize"); imageHeight = imageHeight < 0 ? BlockHeight : imageHeight; var recentDrops = ScanningManager.GetRecentDrops(maxRecentDrops); int index = 0; foreach (var drops in recentDrops) { List <ItemRegion> region = new List <ItemRegion>(); CreateCreatureDropsBox(drops.Item1, drops.Item2, drops.Item3, x, ref y, lootControls, imageHeight, region, index).MouseDown += OpenRecentDropsWindow; recentDropsRegions[index++] = region; } } UpdateDamageForm(); }
public MainForm() { startup = true; Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; mainForm = this; InitializeComponent(); Constants.InitializeConstants(); SettingsManager.Initialize(); if (File.Exists(Constants.SettingsTemporaryBackup)) { // a temporary backup file exists, this might indicate a problem occurred while writing a settings file (e.g. unexpected shutdown) try { SettingsManager.LoadSettings(Constants.SettingsTemporaryBackup); if (SettingsManager.settings.Count == 0) { throw new Exception("Failed to read backup settings."); } if (File.Exists(Constants.SettingsFile)) { File.Delete(Constants.SettingsFile); } File.Copy(Constants.SettingsTemporaryBackup, Constants.SettingsFile); File.Delete(Constants.SettingsTemporaryBackup); } catch (Exception ex) { DisplayWarning(String.Format("Backup settings file found, but could not read: {0}", ex.Message)); } } SettingsManager.LoadSettings(Constants.SettingsFile); LootDatabaseManager.LootChanged += NotificationManager.UpdateLootDisplay; LootDatabaseManager.LootChanged += UpdateLogDisplay; GlobalDataManager.ExperienceChanged += NotificationManager.UpdateExperienceDisplay; GlobalDataManager.DamageChanged += NotificationManager.UpdateDamageDisplay; GlobalDataManager.UsedItemsChanged += NotificationManager.UpdateUsedItemsDisplay; if (!File.Exists(Constants.DatabaseFile)) { ExitWithError("Fatal Error", String.Format("Could not find database file {0}.", Constants.DatabaseFile)); } if (!File.Exists(Constants.NodeDatabase)) { ExitWithError("Fatal Error", String.Format("Could not find database file {0}.", Constants.NodeDatabase)); } LootDatabaseManager.Initialize(); StyleManager.InitializeStyle(); NotificationForm.Initialize(); Parser.Initialize(); PopupManager.Initialize(this.notifyIcon1); prevent_settings_update = true; try { StorageManager.InitializeStorage(); } catch (Exception e) { ExitWithError("Fatal Error", String.Format("Corrupted database {0}.\nMessage: {1}", Constants.DatabaseFile, e.Message)); } try { OutfiterManager.Initialize(); } catch (Exception e) { ExitWithError("Fatal Error", String.Format("Corrupted outfiter database {0}.\nMessage: {1}", Constants.OutfiterDatabaseFile, e.Message)); } ProcessManager.Initialize(); this.initializeSettings(); try { Pathfinder.LoadFromDatabase(Constants.NodeDatabase); } catch (Exception e) { ExitWithError("Fatal Error", String.Format("Corrupted database {0}.\nMessage: {1}", Constants.NodeDatabase, e.Message)); } TaskManager.Initialize(); prevent_settings_update = false; ChangeLanguage(SettingsManager.getSettingString("TibialyzerLanguage")); this.InitializeTabs(); switchTab(0); makeDraggable(this.Controls); if (SettingsManager.getSettingBool("StartAutohotkeyAutomatically")) { AutoHotkeyManager.StartAutohotkey(); } ReadMemoryManager.Initialize(); HuntManager.Initialize(); UIManager.Initialize(); MemoryReader.Initialize(); HUDManager.Initialize(); GlobalDataManager.Initialize(); if (SettingsManager.getSettingBool("AutomaticallyDownloadAddresses")) { MainTab.DownloadNewAddresses(); } this.Load += MainForm_Load; fileWriter = new StreamWriter(Constants.BigLootFile, true); tibialyzerLogo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.draggable_MouseDown); startup = false; ScanningManager.StartScanning(); scan_tooltip.AutoPopDelay = 60000; scan_tooltip.InitialDelay = 500; scan_tooltip.ReshowDelay = 0; scan_tooltip.ShowAlways = true; scan_tooltip.UseFading = true; SetScanningImage("scanningbar-red.gif", "No Tibia Client Found...", true); }
public void UpdateLootForm() { Hunt hunt = HuntManager.activeHunt; int minheight, maxheight; ClearControlList(lootControls, out minheight, out maxheight); int counter; int y = minheight; if (maxheight < 0) { y = 30; foreach (Control c in summaryControls) { y = Math.Max(c.Location.Y + c.Height, y); } } var loot = LootDropForm.GenerateLootInformation(hunt, "", null); totalValue = 0; foreach (Tuple <Item, int> tpl in loot.Item2) { totalValue += tpl.Item1.GetMaxValue() * tpl.Item2; } int maxDrops = SettingsManager.getSettingInt("SummaryMaxItemDrops"); if (maxDrops < 0) { maxDrops = 5; } if (maxDrops > 0) { CreateHeaderLabel("Item Drops", x, ref y, lootControls); counter = 0; int width = 0; var items = new List <Tuple <Item, int> >(); foreach (Tuple <Item, int> tpl in loot.Item2) { int amount = tpl.Item2; while (amount > 0) { int count = Math.Min(100, amount); amount -= count; items.Add(new Tuple <Item, int>(tpl.Item1, count)); width += ImageHeight + 2; if (width > ImageWidth - ImageHeight) { CreateItemList(items, x, ref y, lootControls); items.Clear(); width = 0; if (++counter >= maxDrops) { break; } } } } if (items.Count > 0) { CreateItemList(items, x, ref y, lootControls); items.Clear(); } } int maxCreatures = SettingsManager.getSettingInt("SummaryMaxCreatures"); if (maxCreatures < 0) { maxCreatures = 5; } if (maxCreatures > 0) { CreateHeaderLabel("Creature Kills", x, ref y, lootControls); counter = 0; foreach (Creature cr in loot.Item1.Keys.OrderByDescending(o => loot.Item1[o] * (1 + o.experience)).ToList <Creature>()) { CreateCreatureBox(cr, loot.Item1[cr], x, ref y, lootControls); if (++counter >= maxCreatures) { break; } } } int maxRecentDrops = SettingsManager.getSettingInt("SummaryMaxRecentDrops"); if (maxRecentDrops < 0) { maxRecentDrops = 5; } if (maxRecentDrops > 0) { CreateHeaderLabel("Recent Drops", x, ref y, lootControls); var recentDrops = ScanningManager.GetRecentDrops(maxRecentDrops); foreach (var drops in recentDrops) { CreateCreatureDropsBox(drops.Item1, drops.Item2, drops.Item3, x, ref y, lootControls); } } UpdateDamageForm(); }