private void RefreshColorPicker(int colorIndex) { this.colorIndex = colorIndex; headColorButton.Enabled = true; primaryColorButton.Enabled = true; secondaryColorButton.Enabled = true; detailColorButton.Enabled = true; switch (colorIndex) { case 0: headColorButton.Enabled = false; break; case 1: primaryColorButton.Enabled = false; break; case 2: secondaryColorButton.Enabled = false; break; case 3: detailColorButton.Enabled = false; break; } Image oldImage = colorPicker.Image; colorPicker.Image = OutfiterManager.GenerateColorImage(outfit.colors[colorIndex]); if (oldImage != null) { oldImage.Dispose(); } }
private void ChangeOutfitColor(object sender, MouseEventArgs e) { int index = OutfiterManager.ColorIndex(e.X, e.Y); if (index < 0) { return; } outfit.colors[colorIndex] = index; RefreshColorPicker(colorIndex); RefreshImage(); }
/// <summary> /// Get the image of the current outfit /// </summary> public Image GetImage() { int anim = 0; bool noAddons = OutfiterManager.OutfitHasNoAddons(outfit); int mult_y = noAddons ? 1 : 3; // if there is a mount, choose the "mounted" animation, otherwise choose the "normal" animation int y = (mount != 0 ? (noAddons ? 1 : 3) : 0) + (anim * mult_y); Bitmap outfitImage; // first get the outfit sheet (this contains all the different sprites for different facings/mounted/addons/etc) using (Bitmap outfitSheet = OutfiterManager.OutfitSheet(outfit, gender)) { outfitImage = GetRegion(outfitSheet, (int)facing * 2, y); using (Bitmap blendImage = GetRegion(outfitSheet, (int)facing * 2 + 1, y)) { // colorize the outfit based on the outfits' colors outfitImage = BlendPixels(outfitImage, blendImage, colors); // if there are any addons selected, merge them on top of the outfit for (int i = 0; i < 2; i++) { if (!noAddons && GetAddon(i)) { using (Bitmap oldImage = outfitImage) { // get the addon region using (Bitmap addonImage = GetRegion(outfitSheet, (int)facing * 2, y + i + 1)) { // blend the addon with the colors using (Bitmap addonBlendImage = GetRegion(outfitSheet, (int)facing * 2 + 1, y + i + 1)) { // merge the addon on top of the outfit outfitImage = MergePixels(oldImage, BlendPixels(addonImage, addonBlendImage, colors)); } } } } } } } if (mount != 0) { // if there is a mount, merge the outfit with the mount using (Bitmap mountSheet = OutfiterManager.MountSheet(mount)) { using (Bitmap mountImage = GetRegion(mountSheet, (int)facing, 0)) { Bitmap combinedImage = MergePixels(mountImage, outfitImage); outfitImage.Dispose(); return(combinedImage); } } } else { return(outfitImage); } }
/// <summary> /// Blends the specified colors onto "main", according to the blend pattern specified by "blend" /// Blend contains either (255,255,0) for colors[0]; (255,0,0) for colors [1]; (0,255,0) for colors[2]; (0,0,255) for colors[3]; or Transparent for nothing /// </summary> private static Bitmap BlendPixels(Bitmap main, Bitmap blend, int[] colors) { Color c1 = OutfiterManager.GetColor(colors[0]); Color c2 = OutfiterManager.GetColor(colors[1]); Color c3 = OutfiterManager.GetColor(colors[2]); Color c4 = OutfiterManager.GetColor(colors[3]); for (int x = 0; x < main.Width; x++) { for (int y = 0; y < main.Height; y++) { Color blendColor = blend.GetPixel(x, y); Color resultColor = Color.Transparent; if (blendColor.R == 255 && blendColor.G == 255 && blendColor.B == 0) { resultColor = c1; } else if (blendColor.R == 255 && blendColor.G == 0 && blendColor.B == 0) { resultColor = c2; } else if (blendColor.R == 0 && blendColor.G == 255 && blendColor.B == 0) { resultColor = c3; } else if (blendColor.R == 0 && blendColor.G == 0 && blendColor.B == 255) { resultColor = c4; } if (blendColor.A > 0) { Color mainColor = main.GetPixel(x, y); main.SetPixel(x, y, Color.FromArgb( (byte)((((double)mainColor.R / 255.0)) * resultColor.R), (byte)((((double)mainColor.G / 255.0)) * resultColor.G), (byte)((((double)mainColor.B / 255.0)) * resultColor.B))); } } } return(main); }
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); }