private void importIconsFromROMToolStripMenuItem_Click(object sender, EventArgs e) { if (mm.IsDecomp) { MessageBox.Show("Cannot import assets from decomp ROMs", "Decomp Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "ROM Files (*.z64)|*.z64", FilterIndex = 1, RestoreDirectory = true }; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { ROMManager rm = new ROMManager(openFileDialog.FileName); if (rm == null) { throw new IOException(); } Bitmap image = rm.GetStarImage(); ld = new LayoutDescriptionEx(ld.courseDescription, ld.secretDescription, image, ld.starAmount, ld.starsShown); InvalidateCache(); } catch (IOException) { MessageBox.Show("Failed to import star icons!", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
public ColorPicker(LayoutDescriptionEx ld) { this.ld = ld; img = ld.goldStar; int r = 0, g = 0, b = 0; for (int i = 0; i < img.Width; i++) { for (int j = 0; j < img.Height; j++) { Color c = img.GetPixel(i, j); r += c.R; g += c.G; b += c.B; } } r /= img.Width * img.Height; g /= img.Width * img.Height; b /= img.Width * img.Height; Color midColor = Color.FromArgb(r, g, b); ColorRGB.RGB2HSL(new ColorRGB(midColor), out double h, out double s, out double v); midHue = h; midVal = v; newImg = new Bitmap(img); InitializeComponent(); }
private void importIconsToolStripMenuItem_Click(object sender, EventArgs e) { Bitmap image = mm.GetImage(); ld = new LayoutDescriptionEx(ld.courseDescription, ld.secretDescription, image, ld.starAmount, ld.starsShown); InvalidateCache(); }
private void importFromImageToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { RestoreDirectory = true }; ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); string sep = string.Empty; foreach (var c in codecs) { string codecName = c.CodecName.Substring(8).Replace("Codec", "Files").Trim(); openFileDialog.Filter = string.Format("{0}{1}{2} ({3})|{3}", openFileDialog.Filter, sep, codecName, c.FilenameExtension); sep = "|"; } openFileDialog.Filter = String.Format("{0}{1}{2} ({3})|{3}", openFileDialog.Filter, sep, "All Files", "*.*"); openFileDialog.DefaultExt = "png"; // Default file extension UseDefaultExtAsFilterIndex(openFileDialog); if (openFileDialog.ShowDialog() == DialogResult.OK) { try { var image = new Bitmap(openFileDialog.FileName); ld = new LayoutDescriptionEx(ld.courseDescription, ld.secretDescription, image, ld.starAmount, ld.starsShown); InvalidateCache(); } catch (IOException) { MessageBox.Show("Failed to load image!", "Image Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
public void ParseStars(LayoutDescriptionEx ld) { int totalStars = 0; totalStars += UpdateLineDescriptionsWithStars(2 << 6, ld.courseDescription, ld.starsShown); totalStars += UpdateLineDescriptionsWithStars(0, ld.secretDescription, ld.starsShown); ld.RecountStars(); }
public MainWindow() { InitializeComponent(); ld = LayoutDescriptionEx.GenerateDefault(); // We need big enough picture to perform tests Image randomImage = new Bitmap(300, 50); gm = new GraphicsManager(Graphics.FromImage(randomImage), ld); starPicture.Image = randomImage; mm = new MemoryManager(null); um = new UpdateManager(); try { LoadSettings(); } catch (Exception) { sm = new SettingsManager(); } if (sm == null || !sm.isValid()) { sm = new SettingsManager(); } timer = new System.Threading.Timer(UpdateStars, null, 1, Timeout.Infinite); oldCRC = 0; fileMenuItems = new ToolStripMenuItem[4]; fileMenuItems[0] = fileAToolStripMenuItem; fileMenuItems[1] = fileBToolStripMenuItem; fileMenuItems[2] = fileCToolStripMenuItem; fileMenuItems[3] = fileDToolStripMenuItem; IEnumerable <Type> types = Action.GetAllSubclasses(); componentsClasses = new List <Type>(); foreach (Type type in types) { MethodInfo info = type.GetMethod("DrawConfigs"); if (info == null) { continue; } componentsClasses.Add(type); } starPicture.Width = this.Width; starPicture.Height = this.Height; }
public CollectablesOnlyDrawActions(LayoutDescriptionEx ld, byte[] stars, byte[] oldStars, int reds, int totalReds, int secrets, int totalSecrets, int activePanels, int totalPanels) { this.ld = ld; this.stars = stars; this.oldStars = oldStars; this.reds = reds; this.totalReds = totalReds; this.secrets = secrets; this.totalSecrets = totalSecrets; this.activePanels = activePanels; this.totalPanels = totalPanels; }
private void importIconsToolStripMenuItem_Click(object sender, EventArgs e) { if (mm.IsDecomp) { MessageBox.Show("Cannot extract assets from decomp ROM...", "Decomp Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Bitmap image = mm.GetImage(); ld = new LayoutDescriptionEx(ld.courseDescription, ld.secretDescription, image, ld.starAmount, ld.starsShown); InvalidateCache(); }
public LayoutAdvanced(LayoutDescriptionEx layout) { collectedStarIcon = layout.goldStar; missingStarIcon = layout.darkStar; groups = new List <LayoutAdvancedGroup>(); LayoutAdvancedGroup group = null; foreach (var ld in layout.courseDescription) { } foreach (var ld in layout.secretDescription) { } }
private void LoadLayoutNoInvalidate(string name) { IFormatter formatter = new BinaryFormatter(); int TotalWidth = this.Width / ld.starsShown; string ext = Path.GetExtension(name); Stream stream = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read); object layout = formatter.Deserialize(stream); string layoutClassName = layout.GetType().Name; if (layoutClassName == "LayoutDescription") { ld = new LayoutDescriptionEx((LayoutDescription)layout); } else if (layoutClassName == "LayoutDescriptionEx") { ld = (LayoutDescriptionEx)layout; } else { MessageBox.Show("Failed to load layout, unknown extension", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } ld.RecountStars(); this.SafeInvoke((MethodInvoker) delegate { this.Width = TotalWidth * ld.starsShown; }); if (ld.darkStar == null) { ld.GenerateDarkStar(); } if (ld.redOutline == null) { ld.GenerateOutline(); } if (ld.invertedStar == null) { ld.GenerateInvertedStar(); } ld.Trim(); }
private void loadDefaultToolStripMenuItem_Click(object sender, EventArgs e) { ld = LayoutDescriptionEx.GenerateDefault(); InvalidateCache(); }
private void LoadDefaultLayoutNoInvalidate() { ld = LayoutDescriptionEx.GenerateDefault(); ld.Trim(); }
private void LoadLayoutNoInvalidate(string name, bool showFail) { int TotalWidth = this.Width / ld.starsShown; try { string ext = Path.GetExtension(name); if (ext == ".sml") { Stream stream = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read); IFormatter formatter = new BinaryFormatter(); object layout = formatter.Deserialize(stream); string layoutClassName = layout.GetType().Name; if (layoutClassName == "LayoutDescriptionEx") { ld = (LayoutDescriptionEx)layout; } else { MessageBox.Show("Failed to load layout, unknown extension", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { var json = File.ReadAllText(name); ld = JsonConvert.DeserializeObject <LayoutDescriptionEx>(json); } } catch (Exception e) { if (showFail) { MessageBox.Show($"Failed to load the layout {name}!"); } else { throw e; } return; } ld.RecountStars(); if (ld.darkStar == null) { ld.GenerateDarkStar(); } if (ld.redOutline == null) { ld.GenerateOutline(); } if (ld.invertedStar == null) { ld.GenerateInvertedStar(); } ld.Trim(); this.SafeInvoke((MethodInvoker) delegate { this.Width = TotalWidth * ld.starsShown; }); }