# HG changeset patch # User Jason Maltzen # Date 2016-02-11 01:41:10 # Node ID 5d0a31247a93da065757ddec625de4cbd6880ca0 # Parent 41dee13aa9762b35f2cbf7512bd8a4e8de534131 Refactor UI classes to be separate views instead of separate windows. Add a checkbox to switch to generating recipes for ribbons instead of paint. diff --git a/AppSettings.cs b/AppSettings.cs new file mode 100644 --- /dev/null +++ b/AppSettings.cs @@ -0,0 +1,43 @@ +using System; + +namespace DesertPaintLab +{ + public class AppSettings + { + private AppSettings() + { + } + + private static Settings _settings = new Settings(); + + public static void Get(string key, out int value) + { + _settings.Get(key, out value); + } + public static void Get(string key, out bool value) + { + _settings.Get(key, out value); + } + public static void Set(string key, int value) + { + _settings.Set(key, value); + } + public static void Set(string key, bool value) + { + _settings.Set(key, value); + } + + public static void Save() + { + string settingsPath = System.IO.Path.Combine(FileUtils.AppDataPath, "settings"); + _settings.Save(settingsPath); + } + + public static bool Load() + { + string settingsPath = System.IO.Path.Combine(FileUtils.AppDataPath, "settings"); + return _settings.Load(settingsPath); + } + } +} + diff --git a/DesertPaintLab.csproj b/DesertPaintLab.csproj --- a/DesertPaintLab.csproj +++ b/DesertPaintLab.csproj @@ -67,8 +67,6 @@ - - @@ -76,14 +74,20 @@ - - + + + + + + + + @@ -111,4 +115,7 @@ PreserveNewest + + + \ No newline at end of file diff --git a/MainWindow.cs b/MainWindow.cs --- a/MainWindow.cs +++ b/MainWindow.cs @@ -35,14 +35,14 @@ public partial class MainWindow : Gtk.Wi bool shouldShutDown = false; List profileList = new List(); PlayerProfile profile = null; - PaintColor expectedColor = new PaintColor(); - PaintColor reactedColor = new PaintColor(); Gdk.Window rootWindow = null; Gdk.Pixbuf screenBuffer = null; - Reagent[] reagents = new Reagent[3]; - PaintRecipe recipe = new PaintRecipe(); + // views + RecipeGeneratorView generatorView; + SimulatorView simulatorView; + CaptureView captureView; public bool ShouldShutDown { @@ -52,7 +52,6 @@ public partial class MainWindow : Gtk.Wi } } - public MainWindow () : base(Gtk.WindowType.Toplevel) { string appDataPath = FileUtils.AppDataPath; @@ -71,10 +70,6 @@ public partial class MainWindow : Gtk.Wi } } - reagents[0] = null; - reagents[1] = null; - reagents[2] = null; - string colorsPath = FileUtils.FindApplicationResourceFile("colors.txt"); if (colorsPath == null) { @@ -107,15 +102,6 @@ public partial class MainWindow : Gtk.Wi Build(); - if (unmodifiedSwatch != null) - { - unmodifiedSwatch.Clear(); - } - if (reactionSwatch != null) - { - reactionSwatch.Clear(); - } - // get the root window rootWindow = Gdk.Global.DefaultRootWindow; @@ -125,15 +111,15 @@ public partial class MainWindow : Gtk.Wi rootWindow.GetSize(out screenWidth, out screenHeight); int pixelMultiplier = 1; - if ( DesertPaintLab.Settings.Load() == true ) + if ( DesertPaintLab.AppSettings.Load() == true ) { - DesertPaintLab.Settings.Get("ScreenWidth", out screenWidth); - DesertPaintLab.Settings.Get("ScreenHeight", out screenHeight); - DesertPaintLab.Settings.Get("PixelMultiplier", out pixelMultiplier); + DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth); + DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight); + DesertPaintLab.AppSettings.Get("PixelMultiplier", out pixelMultiplier); } bool enableDebugMenu; - DesertPaintLab.Settings.Get("EnableDebugMenu", out enableDebugMenu); + DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu); this.DebugAction.Visible = enableDebugMenu; ScreenCheckDialog screenCheckDialog = new ScreenCheckDialog(); @@ -146,10 +132,10 @@ public partial class MainWindow : Gtk.Wi pixelMultiplier = screenCheckDialog.GamePixelWidth; screenCheckDialog.Destroy(); - DesertPaintLab.Settings.Set("ScreenWidth", screenWidth); - DesertPaintLab.Settings.Set("ScreenHeight", screenHeight); - DesertPaintLab.Settings.Set("PixelMultiplier", pixelMultiplier); - DesertPaintLab.Settings.Save(); + DesertPaintLab.AppSettings.Set("ScreenWidth", screenWidth); + DesertPaintLab.AppSettings.Set("ScreenHeight", screenHeight); + DesertPaintLab.AppSettings.Set("PixelMultiplier", pixelMultiplier); + DesertPaintLab.AppSettings.Save(); screenBuffer = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, screenWidth, screenHeight); @@ -159,6 +145,16 @@ public partial class MainWindow : Gtk.Wi { shouldShutDown = true; } + + captureView = new CaptureView(profile, screenBuffer); + generatorView = new RecipeGeneratorView(profile); + generatorView.SetStatus += OnStatusUpdate; + generatorView.Started += OnGeneratorRunning; + generatorView.Stopped += OnGeneratorStopped; + simulatorView = new SimulatorView(profile); + + contentContainer.Add(captureView); + captureView.Show(); } bool ConfirmedExit() @@ -177,14 +173,59 @@ public partial class MainWindow : Gtk.Wi } return true; } + + protected void OnStatusUpdate(object sender, EventArgs args) + { + StatusUpdateEventArgs statusArgs = (StatusUpdateEventArgs)args; + statusBar.Push(0, statusArgs.Status); + } + + protected void OnGeneratorRunning(object sender, EventArgs args) + { + NewProfileAction.Sensitive = false; + OpenProfileAction.Sensitive = false; + ImportProfileAction.Sensitive = false; + if (captureView != null) + { + captureView.DisableRecord(); + } + } + + protected void OnGeneratorStopped(object sender, EventArgs args) + { + NewProfileAction.Sensitive = true; + OpenProfileAction.Sensitive = true; + ImportProfileAction.Sensitive = true; + if (captureView != null) + { + captureView.EnableRecord(); + } + } void SetProfileName(string name) { profile = new PlayerProfile(name, System.IO.Path.Combine(FileUtils.AppDataPath, name)); - - statusBar.Push(0, name); } + + void ProfileChanged() + { + statusBar.Push(0, "Profile: " + profile.Name); + Title = "Desert Paint Lab - " + profile.Name; + + if (generatorView != null) + { + generatorView.Profile = profile; + } + if (simulatorView != null) + { + simulatorView.Profile = profile; + } + if (captureView != null) + { + captureView.Profile = profile; + } + } bool NewProfile() { @@ -197,7 +238,7 @@ public partial class MainWindow : Gtk.Wi // Make sure profile doesn't already exist. foreach (string profileName in profileList) { - if (profileName == newProfileDialog.ProfileName) + if (profileName.Equals(newProfileDialog.ProfileName)) { MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, @@ -226,6 +267,7 @@ public partial class MainWindow : Gtk.Wi md.Destroy(); duplicateName = false; } + ProfileChanged(); } } newProfileDialog.Destroy(); @@ -290,10 +332,10 @@ public partial class MainWindow : Gtk.Wi if (profileSelected) { bool ok = profile.Load(); + if (ok) { - PopulateDropDowns(); - recipe.Reactions = profile.Reactions; + ProfileChanged(); } else { @@ -311,166 +353,6 @@ public partial class MainWindow : Gtk.Wi return profileSelected; } - void PopulateDropDowns() - { - ReagentManager.PopulateReagents(ref ingredient1ComboBox); - ReagentManager.PopulateReagents(ref ingredient2ComboBox); - ReagentManager.PopulateReagents(ref ingredient3ComboBox); - - ingredient2ComboBox.Sensitive = false; - ingredient3ComboBox.Sensitive = false; - - Gtk.TreeIter iter; - ingredient1ComboBox.Model.IterNthChild(out iter, 0); - ingredient1ComboBox.SetActiveIter(iter); - ingredient2ComboBox.Model.IterNthChild(out iter, 0); - ingredient2ComboBox.SetActiveIter(iter); - ingredient3ComboBox.Model.IterNthChild(out iter, 0); - ingredient3ComboBox.SetActiveIter(iter); - } - - protected void SetExpectedColor(byte red, byte green, byte blue) - { - expectedColor.Red = red; - expectedColor.Green = green; - expectedColor.Blue = blue; - unmodifiedSwatch.Color = expectedColor; - } - - protected void SetExpectedColor(PaintColor color) - { - SetExpectedColor(color.Red, color.Green, color.Blue); - } - - protected void UpdateIngredients() - { - Reaction reaction1, reaction2; - TreeIter selectIter; - string reagentName; - reagents[0] = null; - reagents[1] = null; - reagents[2] = null; - - bool reactionKnown = true; - - saveButton.Sensitive = false; - - recipe.Clear(); - - if (ingredient1ComboBox.GetActiveIter(out selectIter)) - { - reagentName = (string)ingredient1ComboBox.Model.GetValue(selectIter, 0); - if ((reagentName == null) || (reagentName.Length == 0)) - { - // Nothing selected as reagent 1 - ingredient2ComboBox.Sensitive = false; - ingredient3ComboBox.Sensitive = false; - unmodifiedSwatch.Clear(); - captureButton.Sensitive = false; - } - else - { - recipe.AddReagent(reagentName); - reagents[0] = ReagentManager.GetReagent(reagentName); - ingredient2ComboBox.Sensitive = true; - if (ingredient2ComboBox.GetActiveIter(out selectIter)) - { - reagentName = (string)ingredient2ComboBox.Model.GetValue(selectIter, 0); - if ((reagentName == null) || (reagentName.Length == 0)) - { - ingredient3ComboBox.Sensitive = false; - saveButton.Sensitive = false; - reactionKnown = false; - } - else - { - recipe.AddReagent(reagentName); - reagents[1] = ReagentManager.GetReagent(reagentName); - ingredient3ComboBox.Sensitive = true; - captureButton.Sensitive = true; - - reaction1 = profile.FindReaction(reagents[0], reagents[1]); - - if ((reaction1 != null) || (reagents[0] == reagents[1])) - { - ingredient3ComboBox.Sensitive = true; - } - else - { - reactionKnown = false; - ingredient3ComboBox.Sensitive = false; - } - - if (ingredient3ComboBox.GetActiveIter(out selectIter)) - { - reagentName = (string)ingredient3ComboBox.Model.GetValue(selectIter, 0); - if ((reagentName != null) && (reagentName.Length != 0)) - { - recipe.AddReagent(reagentName); - reagents[2] = ReagentManager.GetReagent(reagentName); - - if (!reactionKnown) - { - MessageDialog md = new MessageDialog(this, - DialogFlags.DestroyWithParent, - MessageType.Error, ButtonsType.Ok, - "To do a three-ingredient reaction test, " + - "you must first recored the reaction of " + - "the first two ingredients."); - - md.Run(); - md.Destroy(); - captureButton.Sensitive = false; - } - - reaction1 = profile.FindReaction(reagents[0], reagents[2]); - reaction2 = profile.FindReaction(reagents[1], reagents[2]); - - if (reactionKnown && (reaction1 == null) && (reaction2 == null)) - { - MessageDialog md = new MessageDialog(this, - DialogFlags.DestroyWithParent, - MessageType.Error, ButtonsType.Ok, - "To do a three-ingredient reaction test, " + - "you must first record the reaction of " + - "either the first or second ingredient " + - "with the third ingredient."); - - md.Run(); - md.Destroy(); - captureButton.Sensitive = false; - } - - if ((reaction1 == null) && (reagents[0] != reagents[2])) - { - reactionKnown = false; - } - - if ((reaction2 == null) && (reagents[1] != reagents[2])) - { - reactionKnown = false; - } - } - } - } - } - expectedColor.Set(recipe.BaseColor); - unmodifiedSwatch.Color = expectedColor; - //SetExpectedColor(recipeColor.Red, recipeColor.Green, recipeColor.Blue); - - if (reactionKnown) - { - reactedColor.Set(recipe.ReactedColor); - reactionSwatch.Color = reactedColor; - } - else - { - reactionSwatch.Clear(); - } - } - } - } - protected void OnDeleteEvent(object sender, DeleteEventArgs a) { if (ConfirmedExit()) @@ -484,74 +366,12 @@ public partial class MainWindow : Gtk.Wi } } - bool IsPapyTexture(byte r, byte g, byte b) - { - return ((r > 0xD0) && (g > 0xC8) && (b > 0xA0)) && - ((r < 0xF4) && (g < 0xE0) && (b < 0xC4)); - } - - unsafe bool CaptureReactionColor() - { - // Take a screenshot. - int screenWidth, screenHeight; - bool debugScreenshot = false; - bool enableDebugMenu = false; - DesertPaintLab.Settings.Get("ScreenWidth", out screenWidth); - DesertPaintLab.Settings.Get("ScreenHeight", out screenHeight); - DesertPaintLab.Settings.Get("EnableDebugMenu", out enableDebugMenu); - DesertPaintLab.Settings.Get("DebugScreenshot", out debugScreenshot); - Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight); - screenBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight); - //screenBuffer.GetFromDrawable(rootWindow, - // rootWindow.Colormap, 0, 0, 0, 0, screenWidth, screenHeight); - int stride = screenBuffer.Rowstride; - byte* pixBytes = (byte*)screenBuffer.Pixels; - int redPixelStart = -1; - - bool wasCaptured = ReactionRecorder.CaptureReaction(pixBytes, screenWidth, screenHeight, stride, ref reactedColor, ref redPixelStart); - if (!wasCaptured && enableDebugMenu && debugScreenshot) - { - // write out the screenshot - string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - string filename; - int i = 0; - do - { - ++i; - filename = System.IO.Path.Combine(screenshotDir, String.Format("DesertPaintLab_Colormatch{0}.png", i)); - } while (System.IO.File.Exists(filename)); - screenBuffer.Save(filename, "png"); - } - else - { - // convert to pixel offset instead of byte - int redPixelStartX = (redPixelStart % stride) / 3; - int redPixelStartY = (redPixelStart / stride); - // write out the screenshot - string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - string filename; - int i = 0; - do - { - ++i; - filename = System.IO.Path.Combine(screenshotDir, String.Format("DesertPaintLab_Colormatch{0}.png", i)); - } while (System.IO.File.Exists(filename)); - int captureAreaWidth = Math.Min(64, screenWidth - redPixelStartX + 64); - int captureAreaHeight = Math.Min(64, screenHeight - redPixelStartY + 64); - Gdk.Pixbuf outPixBuf = new Gdk.Pixbuf(screenBuffer, Math.Max(0, redPixelStartX - 16), Math.Max(0, redPixelStartY - 16), captureAreaWidth, captureAreaHeight); - //screenBuffer.Save(filename, "png"); - outPixBuf.Save(filename, "png"); - } - //screenBuffer.Save("screenshot.png", "png"); - - return wasCaptured; - } - protected virtual void OnDebugScreenshot(object sender, System.EventArgs e) { int screenWidth, screenHeight; - DesertPaintLab.Settings.Get("ScreenWidth", out screenWidth); - DesertPaintLab.Settings.Get("ScreenHeight", out screenHeight); + rootWindow.GetSize(out screenWidth, out screenHeight); + DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth); + DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight); Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight); screenBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight); string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); @@ -565,93 +385,6 @@ public partial class MainWindow : Gtk.Wi screenBuffer.Save(filename, "png"); } - protected virtual void OnCaptureButton(object sender, System.EventArgs e) - { - if (CaptureReactionColor()) - { - string warning = ""; - if (reactedColor.Red == 0) - { - warning = warning + "\nRed is too low."; - } - if (reactedColor.Green == 0) - { - warning = warning + "\nGreen is too low."; - } - if (reactedColor.Blue == 0) - { - warning = warning + "\nBlue is too low."; - } - if (reactedColor.Red == 255) - { - warning = warning + "\nRed is too high."; - } - if (reactedColor.Green == 255) - { - warning = warning + "\nGreen is too high."; - } - if (reactedColor.Blue == 255) - { - warning = warning + "\nBlue is too high."; - } - - if (warning.Length != 0) - { - MessageDialog md = new MessageDialog(this, - DialogFlags.DestroyWithParent, - MessageType.Error, ButtonsType.Ok, - "Reaction clipped. You will need to do a " + - "3-way reaction to test this pair. Details: " + - warning); - - md.Run(); - md.Destroy(); - } - else - { - this.reactionSwatch.Color = reactedColor; - saveButton.Sensitive = true; - } - } - else - { - MessageDialog md = new MessageDialog(this, - DialogFlags.DestroyWithParent, - MessageType.Error, ButtonsType.Ok, - "Pigment Lab dialog box NOT FOUND. Please ensure " + - "that there is an unobstructed view of the dialog " + - "and that your interface size is set to 'small' " + - "when you press the Capture button."); - - md.Run(); - md.Destroy(); - } - } - - protected virtual void OnSaveButton(object sender, System.EventArgs e) - { - if (ReactionRecorder.RecordReaction(profile, expectedColor, reactedColor, reagents)) - { - saveButton.Sensitive = false; - } - } - - protected virtual void OnChangedIngredient1(object sender, System.EventArgs e) - { - UpdateIngredients(); - } - - protected virtual void OnChangedIngredient2(object sender, System.EventArgs e) - { - UpdateIngredients(); - } - - protected virtual void OnChangedIngredient3(object sender, System.EventArgs e) - { - UpdateIngredients(); - - } - protected virtual void OnNewProfile(object sender, System.EventArgs e) { if (unsavedData) @@ -675,8 +408,7 @@ public partial class MainWindow : Gtk.Wi bool ok = profile.Load(); if (ok) { - PopulateDropDowns(); - recipe.Reactions = profile.Reactions; + ProfileChanged(); } else { @@ -711,7 +443,7 @@ public partial class MainWindow : Gtk.Wi bool ok = profile.Load(); if (ok) { - PopulateDropDowns(); + ProfileChanged(); } else { @@ -746,7 +478,7 @@ public partial class MainWindow : Gtk.Wi } } - protected virtual void OnExport(object sender, System.EventArgs e) + protected virtual void OnExportToPracticalPaint(object sender, System.EventArgs e) { FileChooserDialog fileDialog = new FileChooserDialog("Select destination file.", @@ -762,26 +494,6 @@ public partial class MainWindow : Gtk.Wi } fileDialog.Destroy(); } - - protected virtual void RunSimulator(object sender, System.EventArgs e) - { - SimulatorWindow win = new SimulatorWindow(profile); - win.Show(); - } - - protected void OnOpenRecipeGenerator(object sender, EventArgs e) - { - RecipeGeneratorWindow win = new RecipeGeneratorWindow(profile); - win.Show(); - //RecipeGenerator gen = new RecipeGenerator(); - //gen.BeginRecipeGeneration(profile.Reactions, 15, 7); - //MessageDialog md = new MessageDialog(this, - // DialogFlags.DestroyWithParent, - // MessageType.Info, ButtonsType.Close, - // "Coming Soon!"); - //md.Run(); - //md.Destroy(); - } protected void OnShowReactionStatus(object sender, EventArgs e) { @@ -789,12 +501,6 @@ public partial class MainWindow : Gtk.Wi win.Show(); } - protected void OnShowIngredients(object sender, EventArgs e) - { - ReagentWindow win = new ReagentWindow(profile); - win.Show(); - } - protected void OnExportProfile(object sender, EventArgs e) { FileChooserDialog fileDialog = @@ -814,7 +520,7 @@ public partial class MainWindow : Gtk.Wi MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.OkCancel, - "Overwrite profile at" + + "Overwrite file at " + targetFile + "?"); resp = (ResponseType)md.Run(); @@ -856,8 +562,8 @@ public partial class MainWindow : Gtk.Wi MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.OkCancel, - "Overwrite profile at" + - directory + "?"); + "Overwrite profile '" + + profile.Name + "'?"); resp = (ResponseType)md.Run(); md.Destroy(); @@ -874,8 +580,7 @@ public partial class MainWindow : Gtk.Wi bool ok = profile.Load(); if (ok) { - PopulateDropDowns(); - recipe.Reactions = profile.Reactions; + ProfileChanged(); } else { @@ -889,5 +594,128 @@ public partial class MainWindow : Gtk.Wi } fileDialog.Destroy(); } + + protected void OnExportRecipeListToWiki(object sender, EventArgs e) + { + Gtk.FileChooserDialog fileDialog = + new Gtk.FileChooserDialog("Select destination file.", + (Gtk.Window)Toplevel, Gtk.FileChooserAction.Save, + Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, + Gtk.Stock.Save, Gtk.ResponseType.Accept); + Gtk.ResponseType resp = (Gtk.ResponseType)fileDialog.Run(); + if (resp == Gtk.ResponseType.Accept) + { + string fileName = fileDialog.Filename; + string directory = fileDialog.CurrentFolder; + profile.ExportWikiRecipes(System.IO.Path.Combine(directory, fileName)); + } + fileDialog.Destroy(); + } + + protected void OnCopyRecipeListToClipboard(object sender, EventArgs e) + { + Gtk.Clipboard clipboard = this.GetClipboard(Gdk.Selection.Clipboard); + + StringWriter writer = new StringWriter(); + profile.ExportWikiRecipes(writer); + + clipboard.Text = writer.ToString(); + } + + protected void OnSelectCaptureView(object sender, EventArgs e) + { + if (generatorView != null && generatorView.Visible) + { + generatorView.Hide(); + contentContainer.Remove(generatorView); + } + if (simulatorView != null && simulatorView.Visible) + { + simulatorView.Hide(); + contentContainer.Remove(simulatorView); + } + if (captureView == null) + { + captureView = new CaptureView(profile, screenBuffer); + } + if (captureView.Visible == false) + { + captureView.ResizeChildren(); + captureView.CheckResize(); + contentContainer.Add(captureView); + captureView.Show(); + } + CheckResize(); + + // TODO: enable/disable menu options based on view + NewProfileAction.Sensitive = true; + OpenProfileAction.Sensitive = true; + ImportProfileAction.Sensitive = true; + } + + protected void OnSelectRecipeGeneratorView(object sender, EventArgs e) + { + if (captureView != null && captureView.Visible) + { + captureView.Hide(); + contentContainer.Remove(captureView); + } + if (simulatorView != null && simulatorView.Visible) + { + simulatorView.Hide(); + contentContainer.Remove(simulatorView); + } + if (generatorView == null) + { + generatorView = new RecipeGeneratorView(profile); + generatorView.SetStatus += OnStatusUpdate; + generatorView.Started += OnGeneratorRunning; + generatorView.Stopped += OnGeneratorStopped; + } + if (generatorView.Visible == false) + { + generatorView.ResizeChildren(); + generatorView.CheckResize(); + contentContainer.Add(generatorView); + generatorView.Show(); + } + CheckResize(); + + // TODO: only when generator is running + NewProfileAction.Sensitive = false; + OpenProfileAction.Sensitive = false; + ImportProfileAction.Sensitive = false; + // TODO: enable/disable menu options based on view + } + + protected void OnSelectSimulatorView(object sender, EventArgs e) + { + if (captureView != null && captureView.Visible) + { + captureView.Hide(); + contentContainer.Remove(captureView); + } + if (generatorView != null && generatorView.Visible) + { + generatorView.Hide(); + contentContainer.Remove(generatorView); + } + if (simulatorView == null) + { + simulatorView = new SimulatorView(profile); + } + if (simulatorView.Visible == false) + { + simulatorView.ResizeChildren(); + simulatorView.CheckResize(); + contentContainer.Add(simulatorView); + simulatorView.Show(); + } + CheckResize(); + // TODO: enable/disable menu options based on view + NewProfileAction.Sensitive = true; + OpenProfileAction.Sensitive = true; + ImportProfileAction.Sensitive = true; + } } diff --git a/PaintRecipe.cs b/PaintRecipe.cs --- a/PaintRecipe.cs +++ b/PaintRecipe.cs @@ -27,6 +27,9 @@ namespace DesertPaintLab { public class PaintRecipe { + public static uint PAINT_RECIPE_MIN_CONCENTRATION = 10; + public static uint RIBBON_RECIPE_MIN_CONCENTRATION = 50; + public struct RGB { public int r; @@ -336,27 +339,24 @@ namespace DesertPaintLab return batchCount * cost; } - public bool IsValid + public bool IsValidForConcentration(uint concentration) { - get + uint weight = 0; + foreach (RecipeIngredient ingredient in recipe) { - uint weight = 0; - foreach (RecipeIngredient ingredient in recipe) + string reagentName = ingredient.name; + if (reagentName == null) { - string reagentName = ingredient.name; - if (reagentName == null) - { - continue; - } - - Reagent reagent = ReagentManager.GetReagent(reagentName); - if (!reagent.IsCatalyst) - { - weight += ingredient.quantity; - } + continue; } - return (weight >= 10); + + Reagent reagent = ReagentManager.GetReagent(reagentName); + if (!reagent.IsCatalyst) + { + weight += ingredient.quantity; + } } + return (weight >= concentration); } public bool CheckMissingReactions(ref List> missing) diff --git a/PlayerProfile.cs b/PlayerProfile.cs --- a/PlayerProfile.cs +++ b/PlayerProfile.cs @@ -31,10 +31,11 @@ namespace DesertPaintLab { public class PlayerProfile { - string name; + public string Name { get; private set; } string directory; string reactFile; string reagentFile; + string settingsFile; static Regex recipeHeaderRegex = new Regex(@"^--- Recipe: (?(\w*\s)*\w+)\s*"); static Regex recipeIngredientRegex = new Regex(@"(?(\w+\s)?\w+)\s*\|\s*(?\d+)\s*"); @@ -44,6 +45,14 @@ namespace DesertPaintLab //SortedDictionary> reactions = // new SortedDictionary>(); SortedDictionary recipes; + SortedDictionary ribbonRecipes; + + Settings settings = new Settings(); + public Settings ProfileSettings { + get { + return settings; + } + } static PlayerProfile current = null; @@ -58,15 +67,21 @@ namespace DesertPaintLab public PlayerProfile(string name, string directory) { - this.name = name; + this.Name = name; this.directory = directory; this.reactFile = System.IO.Path.Combine(directory, "dp_reactions.txt"); this.reagentFile = System.IO.Path.Combine(directory, "ingredients.txt"); + this.settingsFile = System.IO.Path.Combine(directory, "settings"); this.recipes = new SortedDictionary(); + this.ribbonRecipes = new SortedDictionary(); foreach (PaintColor color in Palette.Colors) { this.recipes.Add(color.Name, new PaintRecipe()); } + foreach (PaintColor color in Palette.Colors) + { + this.ribbonRecipes.Add(color.Name, new PaintRecipe()); + } } public string Directory @@ -97,13 +112,35 @@ namespace DesertPaintLab } } + public SortedDictionary RibbonRecipes + { + get { + return this.ribbonRecipes; + } + } + public int RecipeCount { get { int count = 0; foreach (PaintRecipe recipe in this.recipes.Values) { - if (recipe.IsValid) + if (recipe.IsValidForConcentration(PaintRecipe.PAINT_RECIPE_MIN_CONCENTRATION)) + { + ++count; + } + } + return count; + } + } + + public int RibbonCount + { + get { + int count = 0; + foreach (PaintRecipe recipe in this.ribbonRecipes.Values) + { + if (recipe.IsValidForConcentration(PaintRecipe.RIBBON_RECIPE_MIN_CONCENTRATION)) { ++count; } @@ -305,6 +342,8 @@ namespace DesertPaintLab public bool Load() { string line; + settings.Reset(); + settings.Load(settingsFile); reactions.Clear(); if (File.Exists(reagentFile)) { @@ -336,6 +375,7 @@ namespace DesertPaintLab public void Save() { + settings.Save(settingsFile); Reaction reaction; using (StreamWriter writer = new StreamWriter(reactFile, false)) { @@ -361,13 +401,13 @@ namespace DesertPaintLab } } - public void LoadRecipes() + private void LoadRecipes(SortedDictionary recipeDict, string filename, uint concentration) { - foreach (PaintRecipe recipe in this.recipes.Values) + foreach (PaintRecipe recipe in recipeDict.Values) { recipe.Clear(); } - string recipeFile = System.IO.Path.Combine(directory, "dp_recipes.txt"); + string recipeFile = System.IO.Path.Combine(directory, filename); string line; Match match; bool inRecipe = false; @@ -385,7 +425,10 @@ namespace DesertPaintLab { if (testRecipe != null && currentRecipeColor != null) { - recipes[currentRecipeColor].CopyFrom(testRecipe); + if (testRecipe.IsValidForConcentration(concentration)) + { + recipeDict[currentRecipeColor].CopyFrom(testRecipe); + } } testRecipe.Clear(); currentRecipeColor = match.Groups["colorname"].Value; @@ -404,20 +447,23 @@ namespace DesertPaintLab } if (inRecipe) { - recipes[currentRecipeColor].CopyFrom(testRecipe); + if (testRecipe.IsValidForConcentration(concentration)) + { + recipeDict[currentRecipeColor].CopyFrom(testRecipe); + } } } } } - public void SaveRecipes() + private void SaveRecipes(SortedDictionary recipeDict, string filename) { - if (recipes != null) + if (recipeDict != null) { - string recipeFile = System.IO.Path.Combine(directory, "dp_recipes.txt"); + string recipeFile = System.IO.Path.Combine(directory, filename); using (StreamWriter writer = new StreamWriter(recipeFile, false)) { - foreach (KeyValuePair pair in recipes) + foreach (KeyValuePair pair in recipeDict) { writer.WriteLine("--- Recipe: {0}", pair.Key); foreach (PaintRecipe.RecipeIngredient ingredient in pair.Value.Ingredients) @@ -429,13 +475,41 @@ namespace DesertPaintLab } } + public void LoadRecipes() + { + LoadRecipes(this.recipes, "dp_recipes.txt", PaintRecipe.PAINT_RECIPE_MIN_CONCENTRATION); + LoadRecipes(this.ribbonRecipes, "dp_ribbons.txt", PaintRecipe.RIBBON_RECIPE_MIN_CONCENTRATION); + } + + public void SaveRecipes() + { + SaveRecipes(this.recipes, "dp_recipes.txt"); + SaveRecipes(this.ribbonRecipes, "dp_ribbons.txt"); + } + public void ExportWikiRecipes(string file) { StreamWriter writer = new StreamWriter(file); - ExportWikiFormat(writer); + ExportWikiFormat(writer, this.recipes); } - public void ExportWikiFormat(TextWriter writer) + public void ExportWikiRibbons(string file) + { + StreamWriter writer = new StreamWriter(file); + ExportWikiFormat(writer, this.ribbonRecipes); + } + + public void ExportWikiRecipes(TextWriter writer) + { + ExportWikiFormat(writer, this.recipes); + } + + public void ExportWikiRibbons(TextWriter writer) + { + ExportWikiFormat(writer, this.ribbonRecipes); + } + + public void ExportWikiFormat(TextWriter writer, SortedDictionary recipeDict) { PaintRecipe recipe; List> missing = new List>(); @@ -460,7 +534,7 @@ namespace DesertPaintLab colorLine += " color: #FFFFFF;"; } colorLine += "\" | " + color.Name + " || "; - if (recipes.TryGetValue(color.Name, out recipe)) + if (recipeDict.TryGetValue(color.Name, out recipe)) { foreach (PaintRecipe.RecipeIngredient ingredient in recipe.Ingredients) { @@ -482,7 +556,7 @@ namespace DesertPaintLab writer.WriteLine("|}"); } } - + public Reaction FindReaction(Reagent reagent1, Reagent reagent2) { return reactions.Find(reagent1, reagent2); @@ -493,11 +567,23 @@ namespace DesertPaintLab reactions.Set(reagent1, reagent2, reaction); } + public void ClearReaction(Reagent reagent1, Reagent reagent2) + { + reactions.Remove(reagent1, reagent2); + } + public void SetRecipe(PaintRecipe recipe) { string colorName = Palette.FindNearest(recipe.ReactedColor); recipes[colorName].CopyFrom(recipe); } + + public void SetRibbonRecipe(PaintRecipe recipe) + { + string colorName = Palette.FindNearest(recipe.ReactedColor); + ribbonRecipes[colorName].CopyFrom(recipe); + } + } } diff --git a/ReactionRecorder.cs b/ReactionRecorder.cs --- a/ReactionRecorder.cs +++ b/ReactionRecorder.cs @@ -27,15 +27,17 @@ namespace DesertPaintLab // ReactionRecorder - business logic for recording paint reactions public class ReactionRecorder { - const int colorTolerance = 2; + const int COLOR_TOLERANCE = 3; const int DEFAULT_SWATCH_HEIGHT = 24; + const int DEFAULT_SWATCH_WIDTH = 260; const int DEFAULT_COLOR_BAR_WIDTH = 306; const int DEFAULT_RED_BAR_SPACING = 32; const int DEFAULT_GREEN_BAR_SPACING = 42; const int DEFAULT_BLUE_BAR_SPACING = 52; static int swatchHeight = DEFAULT_SWATCH_HEIGHT; + static int swatchWidth = DEFAULT_SWATCH_WIDTH; static int colorBarWidth = DEFAULT_COLOR_BAR_WIDTH; static int redBarSpacing = DEFAULT_RED_BAR_SPACING; static int greenBarSpacing = DEFAULT_GREEN_BAR_SPACING; @@ -43,24 +45,61 @@ namespace DesertPaintLab private static bool IsPapyTexture(byte r, byte g, byte b) { - return ((r > 0xD0) && (g > 0xC8) && (b > 0xA0)) && - ((r < 0xF4) && (g < 0xE0) && (b < 0xC4)); + return ((r > 0xD0) && (g >= 0xC4) && (b >= 0x91)) && + ((r < 0xF4) && (g <= 0xED) && (b <= 0xCD)); } public static void SetPixelMultiplier(int pixelMultiplier) { swatchHeight = DEFAULT_SWATCH_HEIGHT * pixelMultiplier; + swatchWidth = DEFAULT_SWATCH_WIDTH * pixelMultiplier; colorBarWidth = DEFAULT_COLOR_BAR_WIDTH * pixelMultiplier; redBarSpacing = DEFAULT_RED_BAR_SPACING * pixelMultiplier; greenBarSpacing = DEFAULT_GREEN_BAR_SPACING * pixelMultiplier; blueBarSpacing = DEFAULT_BLUE_BAR_SPACING * pixelMultiplier; } + unsafe private static void ColorAt(byte *pixBytes, int x, int y, int stride, out byte r, out byte g, out byte b) + { + int pixelStart = (y * stride) + (x * 3); + r = pixBytes[pixelStart]; + g = pixBytes[pixelStart + 1]; + b = pixBytes[pixelStart + 2]; + } + + unsafe private static bool IsPossibleBorderPixel(byte* pixBytes, int x, int y, int stride) + { + int testPixelStart = (y * stride) + (x * 3); + byte r = pixBytes[testPixelStart]; + byte g = pixBytes[testPixelStart+1]; + byte b = pixBytes[testPixelStart+2]; + + bool isDarkPixel = false; + bool isPapyAbove = false; + bool isPapyBelow = false; + // 1.) Check if this is a dark pixel. + isDarkPixel = ((r < 0x46) && (g < 0x46) && (b < 0x46)); + + // 2.) Check the pixel above it, + // to see if it's from the papy texture. + int otherPixelStart = testPixelStart - stride; + isPapyAbove = ((otherPixelStart >= 0) && + IsPapyTexture(pixBytes[otherPixelStart++], pixBytes[otherPixelStart++], pixBytes[otherPixelStart])); + + // 3.) Check the pixel below where the swatch should be, + // to see if it's also from the papy texture. + otherPixelStart = testPixelStart + (stride * swatchHeight); + isPapyBelow = (IsPapyTexture(pixBytes[otherPixelStart++], pixBytes[otherPixelStart++], pixBytes[otherPixelStart])); + + bool result = isDarkPixel && isPapyAbove && isPapyBelow; + return result; + } + unsafe public static bool CaptureReaction(byte* pixBytes, int screenshotWidth, int screenshotHeight, int stride, ref PaintColor reactedColor, ref int redPixelStart) { byte pixel_r, pixel_g, pixel_b; int pixelStart, otherPixelStart; - bool colorMatch; + bool colorMatch = true; for (int x = 0; x < screenshotWidth - colorBarWidth; ++x) { for (int y = 0; y < (screenshotHeight - 53); ++y) @@ -71,94 +110,83 @@ namespace DesertPaintLab pixel_g = pixBytes[pixelStart + 1]; pixel_b = pixBytes[pixelStart + 2]; - // 1.) Check if this is a dark pixel. - if ((pixel_r < 0x46) && (pixel_g < 0x46) && (pixel_b < 0x46)) + bool foundSwatch = IsPossibleBorderPixel(pixBytes, x, y, stride); // ((pixel_r < 0x46) && (pixel_g < 0x46) && (pixel_b < 0x46)); + if (foundSwatch) { - // 2.) Check the pixel above it, - // to see if it's from the papy texture. - otherPixelStart = pixelStart - stride; - if ((otherPixelStart >= 0) && - IsPapyTexture(pixBytes[otherPixelStart++], - pixBytes[otherPixelStart++], - pixBytes[otherPixelStart])) + int borderXOffset = 0; + for (borderXOffset = 0; foundSwatch && (borderXOffset < swatchWidth); ++borderXOffset) { - // 3.) Check the pixel below where the swatch should be, - // to see if it's also from the papy texture. - otherPixelStart = pixelStart + (stride * swatchHeight); - if (IsPapyTexture(pixBytes[otherPixelStart++], - pixBytes[otherPixelStart++], - pixBytes[otherPixelStart])) + foundSwatch &= IsPossibleBorderPixel(pixBytes, x + borderXOffset, y, stride); + } + } + + if (foundSwatch) + { + // found a swatch with an appropriate dark top border with papyrus texture above it and papyrus a jump below it + // 4.) Scan the left border of the potential swatch + // location. + colorMatch = true; + for (int i = 1; i < swatchHeight - 2; ++i) + { + otherPixelStart = pixelStart + (stride * i); + if ((Math.Abs(pixel_r - pixBytes[otherPixelStart++]) > COLOR_TOLERANCE) || + (Math.Abs(pixel_g - pixBytes[otherPixelStart++]) > COLOR_TOLERANCE) || + (Math.Abs(pixel_b - pixBytes[otherPixelStart]) > COLOR_TOLERANCE)) { - // pixBytes[pixelStart] = 0xFF; - // pixBytes[pixelStart + 1] = 0x00; - // pixBytes[pixelStart + 2] = 0xFF; - - // 4.) Scan the left border of the potential swatch - // location. - colorMatch = true; - for (int i = 1; i < swatchHeight - 2; ++i) - { - otherPixelStart = pixelStart + (stride * i); - if ((Math.Abs(pixel_r - pixBytes[otherPixelStart++]) > colorTolerance) || - (Math.Abs(pixel_g - pixBytes[otherPixelStart++]) > colorTolerance) || - (Math.Abs(pixel_b - pixBytes[otherPixelStart]) > colorTolerance)) - { - colorMatch = false; - break; - } - } + colorMatch = false; + break; + } + } + + if (colorMatch) + { + // WE FOUND THE SWATCH! + // Now we know where the color bars are. + redPixelStart = pixelStart + (redBarSpacing * stride); + int redPixelCount = 0; + while ((pixBytes[redPixelStart] > 0x9F) && + (pixBytes[redPixelStart + 1] < 0x62) && + (pixBytes[redPixelStart + 2] < 0x62)) + { + redPixelCount++; + // pixBytes[redPixelStart] = 0x00; + // pixBytes[redPixelStart + 1] = 0xFF; + // pixBytes[redPixelStart + 2] = 0xFF; + redPixelStart += 3; + } - if (colorMatch) - { - // WE FOUND THE SWATCH! - // Now we know where the color bars are. - redPixelStart = pixelStart + (redBarSpacing * stride); - int redPixelCount = 0; - while ((pixBytes[redPixelStart] > 0x9F) && - (pixBytes[redPixelStart + 1] < 0x62) && - (pixBytes[redPixelStart + 2] < 0x62)) - { - redPixelCount++; - // pixBytes[redPixelStart] = 0x00; - // pixBytes[redPixelStart + 1] = 0xFF; - // pixBytes[redPixelStart + 2] = 0xFF; - redPixelStart += 3; - } - - reactedColor.Red = (byte)Math.Round((float)redPixelCount * 255f / (float)colorBarWidth); - int greenPixelStart = pixelStart + (greenBarSpacing * stride); - - int greenPixelCount = 0; - while ((pixBytes[greenPixelStart] < 0x62) && - (pixBytes[greenPixelStart + 1] > 0x9F) && - (pixBytes[greenPixelStart + 2] < 0x62)) - { - greenPixelCount++; - // pixBytes[greenPixelStart] = 0x00; - // pixBytes[greenPixelStart + 1] = 0xFF; - // pixBytes[greenPixelStart + 2] = 0xFF; - greenPixelStart += 3; - } - - reactedColor.Green = (byte)Math.Round((float)greenPixelCount * 255f / (float)colorBarWidth); - int bluePixelStart = pixelStart + (blueBarSpacing * stride); - - int bluePixelCount = 0; - while ((pixBytes[bluePixelStart] < 0x62) && - (pixBytes[bluePixelStart + 1] < 0x62) && - (pixBytes[bluePixelStart + 2] > 0x9F)) - { - bluePixelCount++; - // pixBytes[bluePixelStart] = 0x00; - // pixBytes[bluePixelStart + 1] = 0xFF; - // pixBytes[bluePixelStart + 2] = 0xFF; - bluePixelStart += 3; - } - - reactedColor.Blue = (byte)Math.Round((float)bluePixelCount * 255f / (float)colorBarWidth); - return true; - } + reactedColor.Red = (byte)Math.Round((float)redPixelCount * 255f / (float)colorBarWidth); + int greenPixelStart = pixelStart + (greenBarSpacing * stride); + + int greenPixelCount = 0; + while ((pixBytes[greenPixelStart] < 0x62) && + (pixBytes[greenPixelStart + 1] > 0x9F) && + (pixBytes[greenPixelStart + 2] < 0x62)) + { + greenPixelCount++; + // pixBytes[greenPixelStart] = 0x00; + // pixBytes[greenPixelStart + 1] = 0xFF; + // pixBytes[greenPixelStart + 2] = 0xFF; + greenPixelStart += 3; } + + reactedColor.Green = (byte)Math.Round((float)greenPixelCount * 255f / (float)colorBarWidth); + int bluePixelStart = pixelStart + (blueBarSpacing * stride); + + int bluePixelCount = 0; + while ((pixBytes[bluePixelStart] < 0x62) && + (pixBytes[bluePixelStart + 1] < 0x62) && + (pixBytes[bluePixelStart + 2] > 0x9F)) + { + bluePixelCount++; + // pixBytes[bluePixelStart] = 0x00; + // pixBytes[bluePixelStart + 1] = 0xFF; + // pixBytes[bluePixelStart + 2] = 0xFF; + bluePixelStart += 3; + } + + reactedColor.Blue = (byte)Math.Round((float)bluePixelCount * 255f / (float)colorBarWidth); + return true; } } } diff --git a/ReactionSet.cs b/ReactionSet.cs --- a/ReactionSet.cs +++ b/ReactionSet.cs @@ -59,6 +59,16 @@ namespace DesertPaintLab secondReagentDict[reagent2.PracticalPaintName] = reaction; } + public void Remove(Reagent reagent1, Reagent reagent2) + { + SortedDictionary secondReagentDict = null; + reactions.TryGetValue(reagent1.PracticalPaintName, out secondReagentDict); + if (secondReagentDict != null) + { + secondReagentDict.Remove(reagent2.PracticalPaintName); + } + } + public void Clear() { reactions.Clear(); diff --git a/RecipeGenerator.cs b/RecipeGenerator.cs --- a/RecipeGenerator.cs +++ b/RecipeGenerator.cs @@ -64,7 +64,8 @@ namespace DesertPaintLab public SearchType Mode { get; set; } - public uint MaxQuantity { get; private set; } // maximum number of total ingredients + public uint MinConcentration { get; private set; } // minimum paint concentration + public uint MaxConcentration { get; private set; } // maximum paint concentration public uint MaxReagents { get; private set; } // maximum number of reagents to use in the recipe public uint MinReagents { get; private set; } // minimum number of reagents to use in the recipe public uint FullQuantityDepth { get; private set; } // at or equal this number of reagents, ignore ingredient settings for max quantity @@ -111,7 +112,8 @@ namespace DesertPaintLab } MinReagents = 1; MaxReagents = 5; - MaxQuantity = 20; + MinConcentration = 10; + MaxConcentration = 20; } public SortedDictionary Recipes @@ -167,6 +169,8 @@ namespace DesertPaintLab { return; } + recipeCosts.Clear(); + recipes.Clear(); foreach (PaintRecipe recipe in initialRecipes.Values) { //PaintRecipe recipeCopy = new PaintRecipe(recipe); @@ -185,7 +189,7 @@ namespace DesertPaintLab costSortedReagents.Sort(new ReagentCostSort()); } - public void BeginRecipeGeneration(uint maxQuantity, uint minReagents, uint maxReagents, uint fullQuantityDepth, uint fullQuantity) + public void BeginRecipeGeneration(uint minConcentration, uint maxConcentration, uint minReagents, uint maxReagents, uint fullQuantityDepth, uint fullQuantity) { if (running) { @@ -193,7 +197,8 @@ namespace DesertPaintLab return; } - this.MaxQuantity = maxQuantity; + this.MinConcentration = minConcentration; + this.MaxConcentration = maxConcentration; this.MinReagents = minReagents; this.MaxReagents = maxReagents; this.FullQuantity = fullQuantity; @@ -205,7 +210,7 @@ namespace DesertPaintLab totalReagents = (uint)costSortedReagents.Count; // Pre-populate recipes list with: - // 1) 1-ingredient recipes @ 10db for all enabled ingredients with a count >= 10 + // 1) 1-ingredient recipes @ min concentration for all enabled ingredients with a count >= min concentration // 2) any previously-generated recipes int enabledReagentCount = 0; PaintRecipe recipe = new PaintRecipe(); @@ -214,10 +219,10 @@ namespace DesertPaintLab { if (reagent.Enabled) { - if (!reagent.IsCatalyst && ((reagent.RecipeMax >= 10) || ((FullQuantityDepth > 0) && (FullQuantity >= 10)))) + if (!reagent.IsCatalyst && ((reagent.RecipeMax >= minConcentration) || ((FullQuantityDepth > 0) && (FullQuantity >= minConcentration)))) { recipe.Clear(); - recipe.AddReagent(reagent.Name, 10); + recipe.AddReagent(reagent.Name, minConcentration); AddCheapestRecipe(recipe); } ++enabledReagentCount; @@ -239,7 +244,8 @@ namespace DesertPaintLab RecipeSearchNode initialNode = new RecipeSearchNode(costSortedReagents, reagentIdx); initialNode.FullQuantity = FullQuantity; initialNode.FullQuantityDepth = FullQuantityDepth; - initialNode.MaxQuantity = maxQuantity; + initialNode.MinConcentration = minConcentration; + initialNode.MaxConcentration = maxConcentration; initialNode.MinReagents = minReagents; initialNode.MaxReagents = maxReagents; @@ -266,7 +272,7 @@ namespace DesertPaintLab if (log != null) { - log.WriteLine("Begin recipe generation: MaxQuantity={0} MinReagents={1} MaxReagents={2} FullQuantity={3} FullQuantityDepth={4}", MaxQuantity, MinReagents, MaxReagents, FullQuantity, FullQuantityDepth); + log.WriteLine("Begin recipe generation: MaxConcentration={0} MinReagents={1} MaxReagents={2} FullQuantity={3} FullQuantityDepth={4}", MaxConcentration, MinReagents, MaxReagents, FullQuantity, FullQuantityDepth); } // start worker threads to do the actual work @@ -440,7 +446,7 @@ namespace DesertPaintLab node.FullQuantityDepth = FullQuantityDepth; node.MinReagents = MinReagents; node.MaxReagents = MaxReagents; - node.MaxQuantity = MaxQuantity; + node.MaxConcentration = MaxConcentration; success = success && node.LoadState(reader); if (success) { @@ -486,11 +492,11 @@ namespace DesertPaintLab { if (Mode == SearchType.DEPTH_FIRST) { - uint targetQuantity = (node.ReagentCount <= FullQuantityDepth) ? ((uint)node.ReagentCount * FullQuantity) : node.MaxQuantity + 1; + uint targetQuantity = (node.ReagentCount <= FullQuantityDepth) ? ((uint)node.ReagentCount * FullQuantity) : node.MaxConcentration + 1; do { --targetQuantity; node.InitForQuantity(targetQuantity); - } while (targetQuantity > 10 && (node.CurrentTargetQuantity != node.UsedQuantity)); + } while (targetQuantity > MinConcentration && (node.CurrentTargetQuantity != node.UsedQuantity)); while ((ok = IterateDepthFirst(node)) && !requestCancel) { @@ -503,8 +509,8 @@ namespace DesertPaintLab else { // breadth-first search - uint targetQuantity = 9; - uint quantityLimit = (node.ReagentCount <= FullQuantityDepth) ? (FullQuantity * (uint)node.ReagentCount) : node.MaxQuantity; + uint targetQuantity = MinConcentration-1; + uint quantityLimit = (node.ReagentCount <= FullQuantityDepth) ? (FullQuantity * (uint)node.ReagentCount) : node.MaxConcentration; do { ++targetQuantity; node.InitForQuantity(targetQuantity); @@ -549,7 +555,7 @@ namespace DesertPaintLab // returns the discarded recipe from the pair (or null if no original recipe to replace) private void AddCheapestRecipe(PaintRecipe recipe) { - if (recipe.IsValid) + if (recipe.IsValidForConcentration(MinConcentration)) { recipe.Reactions = reactions; @@ -574,6 +580,10 @@ namespace DesertPaintLab NewRecipe(this, args); } } + else + { + Console.WriteLine("Ignoring recipe - existing cost is cheaper."); + } } else { @@ -588,17 +598,17 @@ namespace DesertPaintLab } } } - //else - //{ - // string msg = String.Format("Recipe is invalid ({0} ingredients)\n", recipe.Ingredients.Count); - // foreach (PaintRecipe.RecipeIngredient ingr in recipe.Ingredients) - // { - // msg += String.Format(" -> {0} {1}", ingr.quantity, ingr.name); - // } - // lock (workerLock) { - // Console.WriteLine(msg); - // } - //} + else + { + string msg = String.Format("Recipe is invalid ({0} ingredients)\n", recipe.Ingredients.Count); + foreach (PaintRecipe.RecipeIngredient ingr in recipe.Ingredients) + { + msg += String.Format(" -> {0} {1}", ingr.quantity, ingr.name); + } + lock (workerLock) { + Console.WriteLine(msg); + } + } } private bool IterateDepthFirst(RecipeSearchNode node) @@ -654,8 +664,8 @@ namespace DesertPaintLab } node.ReplaceLastReagent(nextReagent); } - } while (node.MaxQuantity < (10 + node.CatalystCount)); - node.InitForQuantity(node.MaxQuantity); + } while (node.MaxConcentration < (node.MinConcentration + node.CatalystCount)); + node.InitForQuantity(node.MaxConcentration); //string outStr = "{0} : {1} : "; //for (int i = 0; i < currentReagents.Count; ++i) @@ -689,7 +699,7 @@ namespace DesertPaintLab // Try next quantity uint newQuantity; - uint quantityLimit = ((uint)node.ReagentCount <= FullQuantityDepth) ? ((uint)node.ReagentCount * FullQuantity) : node.MaxQuantity; + uint quantityLimit = ((uint)node.ReagentCount <= FullQuantityDepth) ? ((uint)node.ReagentCount * FullQuantity) : node.MaxConcentration; do { newQuantity = node.CurrentTargetQuantity + 1; //Console.WriteLine("Try quantity {0}", newQuantity); @@ -715,8 +725,8 @@ namespace DesertPaintLab // next reagent in last position // if at end, pop reagent - //Console.WriteLine("Finding new recipe after quantity {0}/{1} used {2}", newQuantity, node.MaxQuantity, node.UsedQuantity); - node.InitForQuantity(10+node.CatalystCount); // reset quantity + //Console.WriteLine("Finding new recipe after quantity {0}/{1} used {2}", newQuantity, node.MaxConcentration, node.UsedQuantity); + node.InitForQuantity(node.MinConcentration+node.CatalystCount); // reset quantity int currentDepth = node.ReagentCount; bool recipeFound = false; uint nextReagent; @@ -791,7 +801,7 @@ namespace DesertPaintLab } while (currentDepth <= maxReagents); if (recipeFound) { - node.InitForQuantity(10+node.CatalystCount); // minimum quantity for this recipe + node.InitForQuantity(node.MinConcentration+node.CatalystCount); // minimum quantity for this recipe if (node.TestRecipe == null) { node.TestRecipe = new PaintRecipe(); @@ -835,7 +845,7 @@ namespace DesertPaintLab { // check for the next recipe uint remainingWeight = node.CurrentTargetQuantity - node.CatalystCount; - if (remainingWeight < 10) + if (remainingWeight < MinConcentration) { // not possible to make a valid recipe Console.WriteLine("Insufficient remaining weight"); @@ -899,7 +909,7 @@ namespace DesertPaintLab private bool NextRecipeSize(RecipeSearchNode node) { uint newQuantity = node.CurrentTargetQuantity - 1; - if (newQuantity < (10 + node.CatalystCount)) + if (newQuantity < (node.MinConcentration + node.CatalystCount)) { return false; } diff --git a/RecipeGeneratorWindow.cs b/RecipeGeneratorWindow.cs deleted file mode 100644 --- a/RecipeGeneratorWindow.cs +++ /dev/null @@ -1,656 +0,0 @@ -/* - * Copyright (c) 2015, Jason Maltzen - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -using System; -using System.IO; -using System.Collections.Generic; -using System.Collections.Concurrent; - -namespace DesertPaintLab -{ - public partial class RecipeGeneratorWindow : Gtk.Window - { - RecipeGenerator generator; - PlayerProfile profile; - bool canceling = false; - bool running = false; - bool pauseForCheckpoint = false; - - const long RECIPE_SAVE_INTERVAL = 30000; // msec between saving recipes - const long CHECKPOINT_INTERVAL = 17000; // msec between saving out generator state - const string STATE_FILE = "dp_generator_state"; - - static Gtk.ListStore colorStore = new Gtk.ListStore(typeof(string)); - - List> missingReactions = new List>(); - - long lastProgressUpdate; - long lastStatusUpdate; - long lastProfileSave; - long lastCheckpoint; - - static public Gtk.ListStore RecipeModel - { - get - { - return colorStore; - } - } - - Gtk.ThreadNotify notifyFinished; - Gtk.ThreadNotify notifyProgress; - Gtk.ThreadNotify notifyNewRecipe; - - ConcurrentQueue pendingNewRecipes = new ConcurrentQueue(); - - Gtk.ListStore reagentListStore; - // end reagent view - - public RecipeGeneratorWindow(PlayerProfile profile) : base(Gtk.WindowType.Toplevel) - { - this.profile = profile; - this.Build(); - minIngredientsSpinButton.Value = 1; // TODO: read/save profile info - maxIngredientsSpinButton.Value = 5; // TODO: read/save profile info - maxRecipeSpinButton.Value = 20; // TODO: read/save profile info - fullQuantitySpinButton.Value = 20; // TODO: read/save profile info - fullQuantityDepthSpinButton.Value = 4; // TODO: read/save profile info - - fullQuantityDepthSpinButton.SetRange(0, ReagentManager.Names.Count); - maxIngredientsSpinButton.SetRange(1, ReagentManager.Names.Count); - minIngredientsSpinButton.SetRange(1, ReagentManager.Names.Count); - - - Gtk.TreeViewColumn recipeColorColumn = new Gtk.TreeViewColumn(); - Gtk.CellRendererText recipeColumnCell = new Gtk.CellRendererText(); - recipeColorColumn.PackStart(recipeColumnCell, true); - recipeColorColumn.Title = "Color"; - - recipeList.AppendColumn(recipeColorColumn); - recipeColorColumn.AddAttribute(recipeColumnCell, "text", 0); - - colorStore.Clear(); - - colorStore.SetSortColumnId(0, Gtk.SortType.Ascending); - recipeList.Model = RecipeModel; - - recipeList.Selection.Changed += OnColorSelected; - - recipeIngredientsView.AppendColumn("Quantity", new Gtk.CellRendererText(), "text", 0); - recipeIngredientsView.AppendColumn("Ingredient", new Gtk.CellRendererText(), "text", 1); - recipeIngredientsView.Model = new Gtk.ListStore(typeof(string), typeof(string)); - - profile.LoadRecipes(); - - // init UI - foreach (KeyValuePair pair in profile.Recipes) - { - if (pair.Value.IsValid) - { - string colorName = pair.Key; - colorStore.AppendValues(colorName); - } - } - - canceling = false; - running = false; - pauseForCheckpoint = false; - - generator = new RecipeGenerator(profile.Reactions); - int threads; - DesertPaintLab.Settings.Get("GeneratorThreads", out threads); - if (threads <= 0) { threads = 15; } - generator.MaxThreads = (uint)threads; - generator.InitRecipes(profile.Recipes); - - generator.Progress += OnProgress; - generator.Finished += OnFinished; - generator.NewRecipe += OnNewRecipe; - - string stateFile = System.IO.Path.Combine(profile.Directory, STATE_FILE); - if (System.IO.File.Exists(stateFile)) - { - generator.LoadState(stateFile); - if (generator.CanResume) - { - beginButton.Label = "Restart"; - stopResumeButton.Label = "Resume"; - stopResumeButton.Sensitive = true; - - maxRecipeSpinButton.Value = Math.Max(generator.MaxQuantity, 14); // - fullQuantitySpinButton.Value = generator.FullQuantity; // TODO: read/save profile info - fullQuantityDepthSpinButton.Value = generator.FullQuantityDepth; // TODO: read/save profile info - maxIngredientsSpinButton.Value = generator.MaxReagents; - } - } - //generator.Log = System.IO.Path.Combine(profile.Directory, "dp_log.txt"); - countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount, Palette.Count); - - Destroyed += OnDestroyed; - - notifyFinished = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleFinished)); - notifyProgress = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleProgress)); - notifyNewRecipe = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleNewRecipe)); - - // initialize reagent list - - // Add the columns to the TreeView - Gtk.TreeViewColumn reagentEnabledColumn = new Gtk.TreeViewColumn (); - reagentEnabledColumn.Title = "Enabled"; - Gtk.CellRendererToggle reagentEnabledCell = new Gtk.CellRendererToggle (); - reagentEnabledCell.Activatable = true; - reagentEnabledCell.Sensitive = true; - reagentEnabledCell.Mode = Gtk.CellRendererMode.Activatable; - reagentEnabledCell.Visible = true; - reagentEnabledCell.Toggled += new Gtk.ToggledHandler(OnReagentEnableToggled); - reagentEnabledColumn.PackStart (reagentEnabledCell, true); - //reagentEnabledColumn.AddAttribute(reagentEnabledCell, "active", 0); - - Gtk.TreeViewColumn reagentNameColumn = new Gtk.TreeViewColumn (); - reagentNameColumn.Title = "Ingredient"; - Gtk.CellRendererText reagentNameCell = new Gtk.CellRendererText (); - reagentNameCell.Mode = Gtk.CellRendererMode.Inert; - reagentNameColumn.PackStart (reagentNameCell, true); - reagentNameColumn.AddAttribute(reagentNameCell, "text", 1); - reagentNameColumn.Expand = true; - - Gtk.TreeViewColumn reagentCostColumn = new Gtk.TreeViewColumn (); - reagentCostColumn.Title = "Cost"; - Gtk.CellRendererText reagentCostCell = new Gtk.CellRendererText (); - reagentCostCell.Edited += OnReagentCostChanged; - reagentCostCell.Editable = true; - reagentCostCell.Sensitive = true; - reagentCostCell.Mode = Gtk.CellRendererMode.Editable; - reagentCostColumn.PackStart (reagentCostCell, true); - //reagentCostColumn.AddAttribute(reagentCostCell, "text", 0); - - Gtk.TreeViewColumn reagentMaxColumn = new Gtk.TreeViewColumn (); - reagentMaxColumn.Title = "Max"; - Gtk.CellRendererText reagentMaxCell = new Gtk.CellRendererText (); - reagentMaxCell.Edited += OnReagentQuantityChanged; - reagentMaxCell.Editable = true; - reagentMaxCell.Sensitive = true; - reagentCostCell.Mode = Gtk.CellRendererMode.Editable; - reagentMaxColumn.PackStart (reagentMaxCell, true); - //reagentMaxColumn.AddAttribute(reagentMaxCell, "text", 0); - - reagentListStore = new Gtk.ListStore(typeof(Reagent), typeof(string), typeof(Reagent), typeof(Reagent)); - foreach (string reagentName in ReagentManager.Names) - { - Reagent reagent = ReagentManager.GetReagent(reagentName); - reagentListStore.AppendValues(reagent, reagentName); // , reagent, reagent); - } - - reagentEnabledColumn.SetCellDataFunc (reagentEnabledCell, new Gtk.TreeCellDataFunc (RenderReagentToggle)); - reagentCostColumn.SetCellDataFunc (reagentCostCell, new Gtk.TreeCellDataFunc (RenderReagentCost)); - reagentMaxColumn.SetCellDataFunc (reagentMaxCell, new Gtk.TreeCellDataFunc (RenderReagentQuantity)); - - // Assign the model to the TreeView - reagentListView.Model = reagentListStore; - reagentListView.Sensitive = true; - - reagentListView.AppendColumn(reagentEnabledColumn); - reagentListView.AppendColumn(reagentNameColumn); - reagentListView.AppendColumn(reagentCostColumn); - reagentListView.AppendColumn(reagentMaxColumn); - - reagentListView. - - ShowAll(); - } - - protected void OnMinIngredientsChanged(object sender, EventArgs e) - { - Gtk.SpinButton button = (Gtk.SpinButton) sender; - if (button.ValueAsInt > maxIngredientsSpinButton.ValueAsInt) - { - maxIngredientsSpinButton.Value = button.ValueAsInt; - } - maxIngredientsSpinButton.SetRange(button.ValueAsInt, maxIngredientsSpinButton.Adjustment.Upper); - } - - protected void OnMaxIngredientsChanged(object sender, EventArgs e) - { - Gtk.SpinButton button = (Gtk.SpinButton) sender; - if (button.ValueAsInt < minIngredientsSpinButton.ValueAsInt) - { - minIngredientsSpinButton.Value = button.ValueAsInt; - } - minIngredientsSpinButton.SetRange(1, button.ValueAsInt); - // TODO: save profile setting - // TODO: no longer permit resume - } - - protected void OnMaxRecipeChanged(object sender, EventArgs e) - { - // TODO: save profile setting - // TODO: no longer permit resume - } - - protected void OnFullQuantityDepthChanged(object sender, EventArgs e) - { - // TODO: save profile setting - // TODO: no longer permit resume - } - - protected void OnFullQuantityChanged(object sender, EventArgs e) - { - // TODO: save profile setting - // TODO: no longer permit resume - } - - protected void OnBegin(object sender, EventArgs e) - { - minIngredientsSpinButton.Sensitive = false; - maxIngredientsSpinButton.Sensitive = false; - ExportToWikiAction.Sensitive = false; - IngredientsAction.Sensitive = false; - maxRecipeSpinButton.Sensitive = false; - beginButton.Sensitive = false; // TODO: change to "pause"? - stopResumeButton.Sensitive = true; - fullQuantitySpinButton.Sensitive = false; - fullQuantityDepthSpinButton.Sensitive = false; - reagentListView.Sensitive = false; - - countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount, Palette.Count); - - // TODO: hook up event notifications - // - progress - // - complete - // - new recipe / recipe update - - // Total recipe search count - //int current = ReagentManager.Names.Count; - //long recipePermutations = 1; - //for (int i = 0; i < maxIngredientsSpinButton.ValueAsInt; ++i) - //{ - // recipePermutations *= current; - // --current; - //} - //System.Console.WriteLine("Will search {0} reagent permutations.", recipePermutations); - - lastProgressUpdate = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; - lastStatusUpdate = lastProgressUpdate; - - lastProfileSave = lastProgressUpdate; - lastCheckpoint = lastProgressUpdate; - - running = true; - canceling = false; - pauseForCheckpoint = false; - stopResumeButton.Label = "Pause"; - - generator.BeginRecipeGeneration((uint)maxRecipeSpinButton.ValueAsInt, (uint)minIngredientsSpinButton.Value, (uint)maxIngredientsSpinButton.ValueAsInt, (uint)fullQuantityDepthSpinButton.ValueAsInt, (uint)fullQuantitySpinButton.ValueAsInt); - } - - protected void OnStopResume(object sender, EventArgs e) - { - if (generator != null) - { - if (running) - { - canceling = true; - pauseForCheckpoint = false; - generator.Stop(); - } - else - { - // Resume previous run - ExportToWikiAction.Sensitive = false; - IngredientsAction.Sensitive = false; - reagentListView.Sensitive = false; - minIngredientsSpinButton.Sensitive = false; - maxIngredientsSpinButton.Sensitive = false; - maxRecipeSpinButton.Sensitive = false; - beginButton.Sensitive = false; - stopResumeButton.Sensitive = true; - fullQuantitySpinButton.Sensitive = false; - fullQuantityDepthSpinButton.Sensitive = false; - reagentListView.Sensitive = false; - - lastProgressUpdate = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; - lastStatusUpdate = lastProgressUpdate; - lastProfileSave = lastProgressUpdate; - lastCheckpoint = lastProgressUpdate; - - canceling = false; - pauseForCheckpoint = false; - running = true; - - stopResumeButton.Label = "Pause"; - generator.ResumeRecipeGeneration(); - } - } - } - - private void HandleFinished() - { - generator.Wait(); - if (pauseForCheckpoint) - { - pauseForCheckpoint = false; - generator.SaveState(System.IO.Path.Combine(profile.Directory, STATE_FILE)); - generator.ResumeRecipeGeneration(); - } - else - { - running = false; - beginButton.Sensitive = true; - ExportToWikiAction.Sensitive = true; - IngredientsAction.Sensitive = true; - stopResumeButton.Sensitive = false; - minIngredientsSpinButton.Sensitive = true; - maxIngredientsSpinButton.Sensitive = true; - maxRecipeSpinButton.Sensitive = true; - fullQuantitySpinButton.Sensitive = true; - fullQuantityDepthSpinButton.Sensitive = true; - reagentListView.Sensitive = true; - //generator = null; // don't. Hang on to generator for resume. - profile.SaveRecipes(); - if (canceling) - { - generator.SaveState(System.IO.Path.Combine(profile.Directory, STATE_FILE)); - stopResumeButton.Label = "Resume"; - stopResumeButton.Sensitive = true; - beginButton.Label = "Restart"; - } - else - { - System.IO.File.Delete(System.IO.Path.Combine(profile.Directory, STATE_FILE)); - } - } - } - - protected void OnFinished(object sender, EventArgs args) - { - notifyFinished.WakeupMain(); - //Gtk.Application.Invoke(delegate { - // HandleFinished(); - //}); - } - - private void HandleNewRecipe() - { - progressBar.Pulse(); - - PaintRecipe recipe = null; - if (pendingNewRecipes.TryDequeue(out recipe)) - { - string recipeColor = Palette.FindNearest(recipe.ReactedColor); - // TODO: Add item to recipe list only if not already listed - bool exists = false; - Gtk.TreeIter iter; - if (colorStore.GetIterFirst(out iter)) - { - do - { - string color = (string)colorStore.GetValue(iter, 0); - if (color.Equals(recipeColor)) - { - exists = true; - break; - } - } while (colorStore.IterNext(ref iter)); - } - if (!exists) - { - //Console.WriteLine("Add new recipe for {0}", recipeColor); - // bool isMissingReactions = args.Recipe.CheckMissingReactions(ref missingReactions); - // string missingReactionLabel = isMissingReactions ? "X" : ""; - colorStore.AppendValues(recipeColor); // , missingReactionLabel); - countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount+1, Palette.Count); - } - //else - //{ - // Console.WriteLine("Updated recipe for {0}", recipeColor); - //} - profile.SetRecipe(recipe); - - long progressTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; - long delta = progressTime - lastProfileSave; - if (delta >= RECIPE_SAVE_INTERVAL) - { - profile.SaveRecipes(); - lastProfileSave = progressTime; - } - Gtk.TreeModel model; - Gtk.TreeSelection selection = recipeList.Selection; - if ((selection != null) && selection.GetSelected(out model, out iter)) - { - string colorName = (string)colorStore.GetValue(iter, 0); - if (colorName.Equals(recipeColor)) - { - ShowColor(recipe); - } - } - } - } - - protected void OnNewRecipe(object sender, NewRecipeEventArgs args) - { - PaintRecipe recipe = new PaintRecipe(args.Recipe); // copy it, so the worker thread can release - lock(this) { - pendingNewRecipes.Enqueue(recipe); - } - notifyNewRecipe.WakeupMain(); - //Gtk.Application.Invoke(delegate { - // HandleNewRecipe(); - //}); - } - - private void HandleProgress() - { - long progressTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; - long delta = progressTime - lastProgressUpdate; - if (delta > 30) - { - lastProgressUpdate = progressTime; - progressBar.Pulse(); - } - delta = progressTime - lastStatusUpdate; - if (delta > 500) - { - lastStatusUpdate = progressTime; - statusLabel.Text = String.Format("Recipes searched: {0:N00}", generator.RecipeCount); - } - delta = progressTime - lastCheckpoint; - if (delta > CHECKPOINT_INTERVAL) - { - lastCheckpoint = progressTime; - pauseForCheckpoint = true; - generator.Stop(); - } - } - - protected void OnProgress(object sender, EventArgs args) - { - notifyProgress.WakeupMain(); - } - - private void ShowColor(PaintRecipe recipe) - { - Gtk.ListStore store = (Gtk.ListStore)recipeIngredientsView.Model; - store.Clear(); - if (recipe.CheckMissingReactions(ref missingReactions)) - { - statusLabel.Text = "WARNING: This recipe includes reactions that have not yet been recorded."; - } - foreach (PaintRecipe.RecipeIngredient ingredient in recipe.Ingredients) - { - store.AppendValues(ingredient.quantity.ToString(), ingredient.name); - } - paintSwatch.Color = recipe.ReactedColor; - } - - protected void OnColorSelected(object o, EventArgs args) - { - Gtk.TreeModel model; - Gtk.TreeIter iter; - Gtk.TreeSelection selection = recipeList.Selection; - if ((selection != null) && selection.GetSelected(out model, out iter)) - { - string colorName = (string)colorStore.GetValue(iter, 0); - PaintRecipe recipe; - if (profile.Recipes.TryGetValue(colorName, out recipe)) - { - ShowColor(recipe); - } - } - } - - protected void OnExportToWiki(object sender, EventArgs e) - { - Gtk.FileChooserDialog fileDialog = - new Gtk.FileChooserDialog("Select destination file.", - this, Gtk.FileChooserAction.Save, - Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, - Gtk.Stock.Save, Gtk.ResponseType.Accept); - Gtk.ResponseType resp = (Gtk.ResponseType)fileDialog.Run(); - if (resp == Gtk.ResponseType.Accept) - { - string fileName = fileDialog.Filename; - string directory = fileDialog.CurrentFolder; - profile.ExportWikiRecipes(System.IO.Path.Combine(directory, fileName)); - } - fileDialog.Destroy(); - } - - protected void OnShowIngredients(object sender, EventArgs e) - { - ReagentWindow win = new ReagentWindow(profile); - win.Show(); - } - - protected void OnDestroyed(object o, EventArgs args) - { - if (running) - { - // window closed while generator running: stop and save - generator.Finished -= OnFinished; - generator.Progress -= OnProgress; - generator.NewRecipe -= OnNewRecipe; - generator.Stop(); - generator.Wait(); - generator.SaveState(System.IO.Path.Combine(profile.Directory, STATE_FILE)); - } - } - - // Reagent view handling - private void RenderReagentToggle (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) - { - Reagent reagent = (Reagent) model.GetValue (iter, 0); - Gtk.CellRendererToggle toggle = (cell as Gtk.CellRendererToggle); - toggle.Active = reagent.Enabled; - toggle.Activatable = !reagent.IsCatalyst; - toggle.Mode = reagent.IsCatalyst ? Gtk.CellRendererMode.Inert : Gtk.CellRendererMode.Activatable; - } - private void RenderReagentCost (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) - { - Reagent reagent = (Reagent) model.GetValue (iter, 0); - (cell as Gtk.CellRendererText).Text = reagent.Cost.ToString(); - } - private void RenderReagentQuantity (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) - { - Reagent reagent = (Reagent) model.GetValue (iter, 0); - (cell as Gtk.CellRendererText).Text = reagent.RecipeMax.ToString(); - } - - private void OnReagentCostChanged(object o, Gtk.EditedArgs args) - { - uint newCost; - if (uint.TryParse(args.NewText, out newCost)) - { - Gtk.TreeIter iter; - reagentListStore.GetIter (out iter, new Gtk.TreePath (args.Path)); - - Reagent reagent = (Reagent) reagentListStore.GetValue (iter, 0); - if (reagent.Cost != newCost) - { - reagent.Cost = newCost; - SaveReagentSettings(); - } - } - } - - private void OnReagentQuantityChanged(object o, Gtk.EditedArgs args) - { - uint newMax; - if (uint.TryParse(args.NewText, out newMax)) - { - Gtk.TreeIter iter; - reagentListStore.GetIter (out iter, new Gtk.TreePath (args.Path)); - - Reagent reagent = (Reagent) reagentListStore.GetValue (iter, 0); - if (reagent.RecipeMax != newMax) - { - reagent.RecipeMax = newMax; - SaveReagentSettings(); - } - } - } - - private void OnReagentEnableToggled(object o, Gtk.ToggledArgs args) - { - Gtk.TreeIter iter; - reagentListStore.GetIter (out iter, new Gtk.TreePath (args.Path)); - - Reagent reagent = (Reagent) reagentListStore.GetValue (iter, 0); - reagent.Enabled = !reagent.Enabled; - SaveReagentSettings(); - } - - private void SaveReagentSettings() - { - // save out state - ReagentManager.SaveProfileReagents(profile.ReagentFile); - } - - protected void OnCopyRecipeToClipboard(object sender, EventArgs e) - { - Gtk.TreeModel model; - Gtk.TreeIter iter; - Gtk.Clipboard clipboard = recipeIngredientsView.GetClipboard(Gdk.Selection.Clipboard); - - Gtk.TreeSelection selection = recipeList.Selection; - if ((selection != null) && selection.GetSelected(out model, out iter)) - { - string colorName = (string)colorStore.GetValue(iter, 0); - PaintRecipe recipe; - if (profile.Recipes.TryGetValue(colorName, out recipe)) - { - clipboard.Text = recipe.ToString(); - } - } - } - - protected void OnCopyRecipeListToClipboard(object sender, EventArgs e) - { - Gtk.Clipboard clipboard = recipeList.GetClipboard(Gdk.Selection.Clipboard); - - StringWriter writer = new StringWriter(); - profile.ExportWikiFormat(writer); - - clipboard.Text = writer.ToString(); - } - } -} - diff --git a/RecipeSearchNode.cs b/RecipeSearchNode.cs --- a/RecipeSearchNode.cs +++ b/RecipeSearchNode.cs @@ -48,6 +48,8 @@ namespace DesertPaintLab } } + public uint MinConcentration { get; set; } = 10; + bool[] reagentInUse; List costSortedReagents; PaintRecipe testRecipe = null; @@ -64,7 +66,7 @@ namespace DesertPaintLab } public uint CurrentTargetQuantity { get; set; } - public uint MaxQuantity { get; set; } + public uint MaxConcentration { get; set; } public uint UsedQuantity { get; private set; } public uint CatalystCount { get; set; } public uint FullQuantityDepth { get; set; } @@ -111,7 +113,7 @@ namespace DesertPaintLab nextReagentPos = other.nextReagentPos; CurrentTargetQuantity = other.CurrentTargetQuantity; - MaxQuantity = other.MaxQuantity; + MaxConcentration = other.MaxConcentration; UsedQuantity = other.UsedQuantity; CatalystCount = other.CatalystCount; FullQuantityDepth = other.FullQuantityDepth; @@ -285,7 +287,7 @@ namespace DesertPaintLab { //System.Console.WriteLine("Init for quantity: {0}, reagent count: {1} ({2} catalysts)", quantity, ReagentCount, CatalystCount); CurrentTargetQuantity = quantity; - if (CurrentTargetQuantity < (10 + CatalystCount)) + if (CurrentTargetQuantity < (MinConcentration + CatalystCount)) { // invalid quantity return; @@ -342,7 +344,8 @@ namespace DesertPaintLab // pulled from parent: List costSortedReagents; // new on construct: PaintRecipe testRecipe = null; writer.WriteLine("CurrentTargetQuantity: {0}", CurrentTargetQuantity); - writer.WriteLine("MaxQuantity: {0}", MaxQuantity); + writer.WriteLine("MinConcentration: {0}", MinConcentration); + writer.WriteLine("MaxConcentration: {0}", MaxConcentration); writer.WriteLine("UsedQuantity: {0}", UsedQuantity); writer.WriteLine("CatalystCount: {0}", CatalystCount); writer.WriteLine("FullQuantity: {0}", FullQuantity); @@ -419,7 +422,19 @@ namespace DesertPaintLab case "MaxQuantity": { uint value = uint.Parse(match.Groups[2].Value); - MaxQuantity = value; + MaxConcentration = value; + } + break; + case "MinConcentration": + { + uint value = uint.Parse(match.Groups[2].Value); + MinConcentration = value; + } + break; + case "MaxConcentration": + { + uint value = uint.Parse(match.Groups[2].Value); + MaxConcentration = value; } break; case "MinReagents": diff --git a/Settings.cs b/Settings.cs --- a/Settings.cs +++ b/Settings.cs @@ -7,13 +7,13 @@ namespace DesertPaintLab { public class Settings { - private Settings() + public Settings() { } - private static Dictionary _settings = new Dictionary(); + private Dictionary _settings = new Dictionary(); - public static void Get(string key, out int value) + public void Get(string key, out int value) { value = 0; string valStr; @@ -22,7 +22,7 @@ namespace DesertPaintLab Int32.TryParse(valStr, out value); } } - public static void Get(string key, out bool value) + public void Get(string key, out bool value) { value = false; string valStr; @@ -31,18 +31,22 @@ namespace DesertPaintLab Boolean.TryParse(valStr, out value); } } - public static void Set(string key, int value) + public void Set(string key, int value) { _settings[key.ToLower()] = value.ToString(); } - public static void Get(string key, bool value) + public void Set(string key, bool value) { _settings[key.ToLower()] = value.ToString(); } - public static void Save() + public void Reset() { - string settingsPath = System.IO.Path.Combine(FileUtils.AppDataPath, "settings"); + _settings.Clear(); + } + + public void Save(string settingsPath) + { using (StreamWriter writer = new StreamWriter(settingsPath)) { foreach (KeyValuePair pair in _settings) @@ -51,12 +55,10 @@ namespace DesertPaintLab } } } - static Regex optionEntry = new Regex(@"(?[^#=][^=]*)=(?.*)$"); - public static bool Load() + public bool Load(string settingsPath) { - string settingsPath = System.IO.Path.Combine(FileUtils.AppDataPath, "settings"); if (System.IO.File.Exists(settingsPath)) { string line; diff --git a/SimulatorWindow.cs b/SimulatorWindow.cs deleted file mode 100644 --- a/SimulatorWindow.cs +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2010, Tess Snider - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -using System; -using System.Collections.Generic; - -namespace DesertPaintLab -{ - public partial class SimulatorWindow : Gtk.Window - { - Gtk.ListStore recipeData = new Gtk.ListStore(typeof(string), typeof(int)); - PaintRecipe paintRecipe; - - List missingWarned = new List(); - List> newMissing = new List>(); - - private class IngredientPair - { - public string first; - public string second; - - public IngredientPair(string first, string second) - { - this.first = first; - this.second = second; - } - } - - public SimulatorWindow(PlayerProfile profile) : base(Gtk.WindowType.Toplevel) - { - this.Build (); - - paintRecipe = new PaintRecipe(); - paintRecipe.Reactions = profile.Reactions; - - Gtk.TreeViewColumn reagentColumn = new Gtk.TreeViewColumn(); - Gtk.CellRendererText reagentColumnCell = new Gtk.CellRendererText(); - reagentColumn.PackStart(reagentColumnCell, true); - reagentColumn.Title = "Ingredient"; - - reagentListView.AppendColumn(reagentColumn); - reagentColumn.AddAttribute(reagentColumnCell, "text", 0); - - reagentListView.Model = ReagentManager.NameListModel; - - Gtk.TreeViewColumn additiveColumn = new Gtk.TreeViewColumn(); - Gtk.CellRendererText additiveColumnCell = new Gtk.CellRendererText(); - additiveColumn.PackStart(additiveColumnCell, true); - additiveColumn.Title = "Ingredient"; - - recipeView.AppendColumn(additiveColumn); - additiveColumn.AddAttribute(additiveColumnCell, "text", 0); - - Gtk.TreeViewColumn qtyColumn = new Gtk.TreeViewColumn(); - Gtk.CellRendererText qtyColumnCell = new Gtk.CellRendererText(); - qtyColumnCell.Editable = true; - qtyColumnCell.Edited += OnQtyEdited; - qtyColumn.PackStart(qtyColumnCell, true); - qtyColumn.Title = "Qty"; - - recipeView.AppendColumn(qtyColumn); - qtyColumn.AddAttribute(qtyColumnCell, "text", 1); - - recipeView.Model = recipeData; - - recipeData.RowChanged += OnRecipeChanged; - recipeData.RowDeleted += OnRecipeChanged; - recipeData.RowInserted += OnRecipeChanged; - recipeData.RowsReordered += OnRecipeChanged; - - } - - protected virtual void OnAddReagent(object sender, System.EventArgs e) - { - Gtk.TreeModel model; - Gtk.TreeIter iter; - - Gtk.TreeSelection selection = reagentListView.Selection; - if ((selection != null) && selection.GetSelected(out model, out iter)) - { - recipeData.AppendValues(model.GetValue(iter, 0).ToString(), 1); - - recipeData.IterNthChild(out iter, recipeView.Children.Length - 1); - - selection = recipeView.Selection; - selection.SelectIter(iter); - } - } - - protected void OnQtyEdited(object sender, Gtk.EditedArgs args) - { - Gtk.TreeIter iter; - recipeData.GetIter(out iter, new Gtk.TreePath(args.Path)); - - int oldValue = (int)recipeData.GetValue(iter, 1); - - try - { - recipeData.SetValue(iter, 1, int.Parse(args.NewText)); - UpdateRecipeColor(); - } - catch (Exception) - { - recipeData.SetValue(iter, 1, oldValue); - } - } - - protected void OnRecipeChanged(object sender, GLib.SignalArgs args) - { - UpdateRecipeColor(); - } - - void UpdateRecipeColor() - { - if (recipeView.Children.Length == 0) - { - paintSwatch.Clear(); - } - - paintRecipe.Clear(); - - Gtk.TreeIter iter; - string reagentName; - int qty; - - recipeData.GetIterFirst(out iter); - - do - { - reagentName = (string) recipeData.GetValue(iter, 0); - - if (reagentName == null) - { - continue; - } - - qty = (int)recipeData.GetValue(iter, 1); - for (int i = 0; i < qty; ++i) - { - paintRecipe.AddReagent(reagentName); - } - } - while (recipeData.IterNext(ref iter)); - - PaintColor resultColor = new PaintColor(paintRecipe.ReactedColor); - paintSwatch.Color = resultColor; - if (paintRecipe.CheckMissingReactions(ref newMissing)) - { - string warningMsg = ""; - - foreach (KeyValuePair newEntry in newMissing) - { - IngredientPair match = missingWarned.Find(x => (x.first.Equals(newEntry.Key) && x.second.Equals(newEntry.Value))); - if (match == null) - { - match = new IngredientPair(newEntry.Key, newEntry.Value); - missingWarned.Add(match); - warningMsg += newEntry.Key + " + " + newEntry.Value + "\n"; - } - } - if (warningMsg.Length > 0) - { - Gtk.MessageDialog md = new Gtk.MessageDialog(this, - Gtk.DialogFlags.DestroyWithParent, - Gtk.MessageType.Warning, - Gtk.ButtonsType.Ok, - "These combinations have not yet had reactions recorded:\n\n" + - warningMsg); - md.Run(); - md.Destroy(); - } - } - - } - - protected virtual void OnIncrementReagent (object sender, System.EventArgs e) - { - Gtk.TreeModel model; - Gtk.TreeIter iter; - - Gtk.TreeSelection selection = recipeView.Selection; - if ((selection != null) && selection.GetSelected(out model, out iter)) - { - int oldValue = (int)recipeData.GetValue(iter, 1); - recipeData.SetValue(iter, 1, oldValue + 1); - } - - } - - protected virtual void OnDecrementReagent (object sender, System.EventArgs e) - { - Gtk.TreeModel model; - Gtk.TreeIter iter; - - Gtk.TreeSelection selection = recipeView.Selection; - if ((selection != null) && selection.GetSelected(out model, out iter)) - { - int oldValue = (int)recipeData.GetValue(iter, 1); - if (oldValue == 1) - { - recipeData.Remove(ref iter); - } - else - { - recipeData.SetValue(iter, 1, oldValue - 1); - } - } - - } - - protected virtual void OnFlushReagents (object sender, System.EventArgs e) - { - recipeData.Clear(); - } - } -} \ No newline at end of file diff --git a/UI/CaptureView.cs b/UI/CaptureView.cs new file mode 100644 --- /dev/null +++ b/UI/CaptureView.cs @@ -0,0 +1,429 @@ +using System; + +namespace DesertPaintLab +{ + [System.ComponentModel.ToolboxItem(true)] + public partial class CaptureView : Gtk.Bin + { + + Reagent[] reagents = new Reagent[3]; + PaintRecipe recipe = new PaintRecipe(); + + PaintColor expectedColor = new PaintColor(); + PaintColor reactedColor = new PaintColor(); + + PlayerProfile profile = null; + + Gdk.Pixbuf screenBuffer = null; + + bool recordEnabled = true; + bool isCaptured = false; + + public CaptureView(PlayerProfile profile, Gdk.Pixbuf screenBuffer) : base() + { + this.profile = profile; + this.screenBuffer = screenBuffer; + + this.Build(); + + reagents[0] = null; + reagents[1] = null; + reagents[2] = null; + + if (unmodifiedSwatch != null) + { + unmodifiedSwatch.Clear(); + } + if (reactionSwatch != null) + { + reactionSwatch.Clear(); + } + + PopulateDropDowns(); + recipe.Reactions = profile.Reactions; + } + + public PlayerProfile Profile + { + set { + profile = value; + PopulateDropDowns(); + recipe.Reactions = profile.Reactions; + UpdateIngredients(); + // TODO: reset views + } + } + + public void DisableRecord() + { + recordEnabled = false; + recordButton.Sensitive = false; + } + + public void EnableRecord() + { + recordEnabled = true; + if (isCaptured) + { + recordEnabled = true; + } + UpdateIngredients(); + } + + public void PopulateDropDowns() + { + ReagentManager.PopulateReagents(ref ingredient1ComboBox); + ReagentManager.PopulateReagents(ref ingredient2ComboBox); + ReagentManager.PopulateReagents(ref ingredient3ComboBox); + + ingredient2ComboBox.Sensitive = false; + ingredient3ComboBox.Sensitive = false; + + Gtk.TreeIter iter; + ingredient1ComboBox.Model.IterNthChild(out iter, 0); + ingredient1ComboBox.SetActiveIter(iter); + ingredient2ComboBox.Model.IterNthChild(out iter, 0); + ingredient2ComboBox.SetActiveIter(iter); + ingredient3ComboBox.Model.IterNthChild(out iter, 0); + ingredient3ComboBox.SetActiveIter(iter); + } + + protected void SetExpectedColor(byte red, byte green, byte blue) + { + expectedColor.Red = red; + expectedColor.Green = green; + expectedColor.Blue = blue; + unmodifiedSwatch.Color = expectedColor; + } + + protected void SetExpectedColor(PaintColor color) + { + SetExpectedColor(color.Red, color.Green, color.Blue); + } + + protected string GetSelectedReagentName(int reagentNum) + { + Gtk.ComboBox[] comboBox = { ingredient1ComboBox, ingredient2ComboBox, ingredient3ComboBox }; + Gtk.ComboBox desired = comboBox[reagentNum-1]; + + Gtk.TreeIter selectIter; + string reagentName = null; + if (desired.GetActiveIter(out selectIter)) + { + reagentName = (string)desired.Model.GetValue(selectIter, 0); + } + if (reagentName != null && reagentName.Length == 0) + { + reagentName = null; + } + + return reagentName; + } + + protected void UpdateIngredients() + { + Reaction reaction1, reaction2; + string reagentName; + reagents[0] = null; + reagents[1] = null; + reagents[2] = null; + + bool reactionKnown = true; + + isCaptured = false; + recordButton.Sensitive = false; + clearReactionButton.Sensitive = false; + clearReactionButton.Visible = false; + + recipe.Clear(); + + if ((reagentName = GetSelectedReagentName(1)) == null) + { + // Nothing selected as reagent 1 + ingredient2ComboBox.Sensitive = false; + ingredient3ComboBox.Sensitive = false; + unmodifiedSwatch.Clear(); + reactionSwatch.Clear(); + captureButton.Sensitive = false; + return; + } + recipe.AddReagent(reagentName); + reagents[0] = ReagentManager.GetReagent(reagentName); + ingredient2ComboBox.Sensitive = true; + if ((reagentName = GetSelectedReagentName(2)) == null) + { + ingredient3ComboBox.Sensitive = false; + recordButton.Sensitive = false; + reactionKnown = false; + reactionSwatch.Clear(); + return; + } + + recipe.AddReagent(reagentName); + reagents[1] = ReagentManager.GetReagent(reagentName); + ingredient3ComboBox.Sensitive = true; + captureButton.Sensitive = true; + + reaction1 = profile.FindReaction(reagents[0], reagents[1]); + + // TODO: really should handle reagent0==reagent1 better + if ((reaction1 != null) || (reagents[0] == reagents[1])) + { + clearReactionButton.Sensitive = recordEnabled; + clearReactionButton.Visible = true; + ingredient3ComboBox.Sensitive = true; + if ((reagentName = GetSelectedReagentName(3)) != null) + { + clearReactionButton.Sensitive = false; + clearReactionButton.Visible = false; + recipe.AddReagent(reagentName); + reagents[2] = ReagentManager.GetReagent(reagentName); + + if (!reactionKnown) + { + Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, + Gtk.DialogFlags.DestroyWithParent, + Gtk.MessageType.Error, Gtk.ButtonsType.Ok, + "To do a three-ingredient reaction test, " + + "you must first recored the reaction of " + + "the first two ingredients."); + + md.Run(); + md.Destroy(); + captureButton.Sensitive = false; + } + + reaction1 = profile.FindReaction(reagents[0], reagents[2]); + reaction2 = profile.FindReaction(reagents[1], reagents[2]); + + if (reactionKnown && (reaction1 == null) && (reaction2 == null)) + { + Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, + Gtk.DialogFlags.DestroyWithParent, + Gtk.MessageType.Error, Gtk.ButtonsType.Ok, + "To do a three-ingredient reaction test, " + + "you must first record the reaction of " + + "either the first or second ingredient " + + "with the third ingredient."); + + md.Run(); + md.Destroy(); + captureButton.Sensitive = false; + } + + if ((reaction1 == null) && (reagents[0] != reagents[2])) + { + reactionKnown = false; + } + + if ((reaction2 == null) && (reagents[1] != reagents[2])) + { + reactionKnown = false; + } + } + } + else + { + reactionKnown = false; + ingredient3ComboBox.Sensitive = false; + } + + expectedColor.Set(recipe.BaseColor); + unmodifiedSwatch.Color = expectedColor; + //SetExpectedColor(recipeColor.Red, recipeColor.Green, recipeColor.Blue); + + if (reactionKnown) + { + reactedColor.Set(recipe.ReactedColor); + reactionSwatch.Color = reactedColor; + } + else + { + reactionSwatch.Clear(); + } + } + + unsafe bool CaptureReactionColor() + { + // Take a screenshot. + int screenWidth, screenHeight; + bool debugScreenshot = false; + bool enableDebugMenu = false; + Gdk.Window rootWindow = Gdk.Global.DefaultRootWindow; + DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth); + DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight); + DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu); + DesertPaintLab.AppSettings.Get("DebugScreenshot", out debugScreenshot); + Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight); + screenBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight); + //screenBuffer.GetFromDrawable(rootWindow, + // rootWindow.Colormap, 0, 0, 0, 0, screenWidth, screenHeight); + int stride = screenBuffer.Rowstride; + byte* pixBytes = (byte*)screenBuffer.Pixels; + int redPixelStart = -1; + + isCaptured = ReactionRecorder.CaptureReaction(pixBytes, screenWidth, screenHeight, stride, ref reactedColor, ref redPixelStart); + if (enableDebugMenu && debugScreenshot) + { + if (!isCaptured) + { + // write out the whole screenshot on a failure to capture + string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + string filename; + int i = 0; + do + { + ++i; + filename = System.IO.Path.Combine(screenshotDir, String.Format("DesertPaintLab_Colormatch{0}.png", i)); + } while (System.IO.File.Exists(filename)); + screenBuffer.Save(filename, "png"); + } + else + { + // record the swatch that was captured + // convert to pixel offset instead of byte + int redPixelStartX = (redPixelStart % stride) / 3; + int redPixelStartY = (redPixelStart / stride); + // write out the screenshot + string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + string filename; + int i = 0; + do + { + ++i; + filename = System.IO.Path.Combine(screenshotDir, String.Format("DesertPaintLab_Colormatch{0}.png", i)); + } while (System.IO.File.Exists(filename)); + int captureAreaWidth = Math.Min(64, screenWidth - redPixelStartX + 64); + int captureAreaHeight = Math.Min(64, screenHeight - redPixelStartY + 64); + Gdk.Pixbuf outPixBuf = new Gdk.Pixbuf(screenBuffer, Math.Max(0, redPixelStartX - 16), Math.Max(0, redPixelStartY - 16), captureAreaWidth, captureAreaHeight); + //screenBuffer.Save(filename, "png"); + outPixBuf.Save(filename, "png"); + } + } + //screenBuffer.Save("screenshot.png", "png"); + + return isCaptured; + } + + protected virtual void OnCapture(object sender, System.EventArgs e) + { + if (CaptureReactionColor()) + { + string warning = ""; + if (reactedColor.Red == 0) + { + warning = warning + "\nRed is too low."; + } + if (reactedColor.Green == 0) + { + warning = warning + "\nGreen is too low."; + } + if (reactedColor.Blue == 0) + { + warning = warning + "\nBlue is too low."; + } + if (reactedColor.Red == 255) + { + warning = warning + "\nRed is too high."; + } + if (reactedColor.Green == 255) + { + warning = warning + "\nGreen is too high."; + } + if (reactedColor.Blue == 255) + { + warning = warning + "\nBlue is too high."; + } + + if (warning.Length != 0) + { + isCaptured = true; + Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, + Gtk.DialogFlags.DestroyWithParent, + Gtk.MessageType.Error, Gtk.ButtonsType.Ok, + "Reaction clipped. You will need to do a " + + "3-way reaction to test this pair. Details: " + + warning); + + md.Run(); + md.Destroy(); + } + else + { + this.reactionSwatch.Color = reactedColor; + recordButton.Sensitive = recordEnabled; + } + } + else + { + Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, + Gtk.DialogFlags.DestroyWithParent, + Gtk.MessageType.Error, Gtk.ButtonsType.Ok, + "Pigment Lab dialog box NOT FOUND. Please ensure " + + "that there is an unobstructed view of the dialog " + + "and that your interface size is set to 'small' " + + "when you press the Capture button."); + + md.Run(); + md.Destroy(); + } + } + + protected virtual void OnRecord(object sender, System.EventArgs e) + { + if (ReactionRecorder.RecordReaction(profile, expectedColor, reactedColor, reagents)) + { + recordButton.Sensitive = false; + } + } + + protected virtual void OnChangedIngredient1(object sender, System.EventArgs e) + { + UpdateIngredients(); + } + + protected virtual void OnChangedIngredient2(object sender, System.EventArgs e) + { + UpdateIngredients(); + } + + protected virtual void OnChangedIngredient3(object sender, System.EventArgs e) + { + UpdateIngredients(); + + } + + protected void OnClearReaction(object sender, EventArgs e) + { + string reagentName1 = GetSelectedReagentName(1); + string reagentName2 = GetSelectedReagentName(2); + string reagentName3 = GetSelectedReagentName(3); + + if ((reagentName1 != null) && (reagentName2 != null) && (reagentName3 == null)) + { + Reagent reagent1 = ReagentManager.GetReagent(reagentName1); + Reagent reagent2 = ReagentManager.GetReagent(reagentName2); + + if (null != profile.FindReaction(reagent1, reagent2)) + { + Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, + Gtk.DialogFlags.DestroyWithParent, + Gtk.MessageType.Warning, Gtk.ButtonsType.OkCancel, + "This will delete the reaction status between " + + // TODO: ingredient1Name + " and " + ingredient2Name + "\n\n" + + "ARE YOU SURE?" + ); + + Gtk.ResponseType response = (Gtk.ResponseType)md.Run(); + if (response == Gtk.ResponseType.Ok) + { + // really delete it + profile.ClearReaction(reagent1, reagent2); + } + md.Destroy(); + } + } + } + } +} + diff --git a/UI/RecipeGeneratorView.cs b/UI/RecipeGeneratorView.cs new file mode 100644 --- /dev/null +++ b/UI/RecipeGeneratorView.cs @@ -0,0 +1,854 @@ +/* + * Copyright (c) 2015, Jason Maltzen + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.Concurrent; + +namespace DesertPaintLab +{ + [System.ComponentModel.ToolboxItem(true)] + public partial class RecipeGeneratorView : Gtk.Bin + { + RecipeGenerator generator; + PlayerProfile profile; + bool canceling = false; + bool running = false; + bool pauseForCheckpoint = false; + + const long RECIPE_SAVE_INTERVAL = 30000; // msec between saving recipes + const long CHECKPOINT_INTERVAL = 17000; // msec between saving out generator state + const string PAINT_STATE_FILE = "dp_generator_state"; + const string RIBBON_STATE_FILE = "dp_generator_ribbon_state"; + + static Gtk.ListStore colorStore = new Gtk.ListStore(typeof(string)); + + List> missingReactions = new List>(); + + long lastProgressUpdate; + long lastStatusUpdate; + long lastProfileSave; + long lastCheckpoint; + + public EventHandler SetStatus; + public EventHandler Started; + public EventHandler Stopped; + + static public Gtk.ListStore RecipeModel + { + get + { + return colorStore; + } + } + + Gtk.ThreadNotify notifyFinished; + Gtk.ThreadNotify notifyProgress; + Gtk.ThreadNotify notifyNewRecipe; + + ConcurrentQueue pendingNewRecipes = new ConcurrentQueue(); + + Gtk.ListStore reagentListStore; + // end reagent view + + public RecipeGeneratorView(PlayerProfile profile) : base() + { + this.profile = profile; + this.Build(); + minIngredientsSpinButton.Value = 1; // TODO: read/save profile info + maxIngredientsSpinButton.Value = 5; // TODO: read/save profile info + maxRecipeSpinButton.Value = 20; // TODO: read/save profile info + fullQuantitySpinButton.Value = 20; // TODO: read/save profile info + fullQuantityDepthSpinButton.Value = 4; // TODO: read/save profile info + + fullQuantityDepthSpinButton.SetRange(0, ReagentManager.Names.Count); + maxIngredientsSpinButton.SetRange(1, ReagentManager.Names.Count); + minIngredientsSpinButton.SetRange(1, ReagentManager.Names.Count); + + + Gtk.TreeViewColumn recipeColorColumn = new Gtk.TreeViewColumn(); + Gtk.CellRendererText recipeColumnCell = new Gtk.CellRendererText(); + recipeColorColumn.PackStart(recipeColumnCell, true); + recipeColorColumn.Title = "Color"; + + recipeList.AppendColumn(recipeColorColumn); + recipeColorColumn.AddAttribute(recipeColumnCell, "text", 0); + + colorStore.Clear(); + + colorStore.SetSortColumnId(0, Gtk.SortType.Ascending); + recipeList.Model = RecipeModel; + + recipeList.Selection.Changed += OnColorSelected; + + recipeIngredientsView.AppendColumn("Quantity", new Gtk.CellRendererText(), "text", 0); + recipeIngredientsView.AppendColumn("Ingredient", new Gtk.CellRendererText(), "text", 1); + recipeIngredientsView.Model = new Gtk.ListStore(typeof(string), typeof(string)); + + profile.LoadRecipes(); + + canceling = false; + running = false; + pauseForCheckpoint = false; + + generator = new RecipeGenerator(profile.Reactions); + int threads; + DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads); + if (threads <= 0) { threads = 15; } + generator.MaxThreads = (uint)threads; + generator.InitRecipes(profile.Recipes); + + generator.Progress += OnProgress; + generator.Finished += OnFinished; + generator.NewRecipe += OnNewRecipe; + + string stateFile = System.IO.Path.Combine(profile.Directory, PAINT_STATE_FILE); + if (System.IO.File.Exists(stateFile)) + { + generator.LoadState(stateFile); + if (generator.CanResume) + { + beginButton.Label = "Restart"; + stopResumeButton.Label = "Resume"; + stopResumeButton.Sensitive = true; + + maxRecipeSpinButton.Value = Math.Max(generator.MaxConcentration, 14); // + fullQuantitySpinButton.Value = generator.FullQuantity; // TODO: read/save profile info + fullQuantityDepthSpinButton.Value = generator.FullQuantityDepth; // TODO: read/save profile info + maxIngredientsSpinButton.Value = generator.MaxReagents; + checkButtonRibbon.Active = false; + } + } + //generator.Log = System.IO.Path.Combine(profile.Directory, "dp_log.txt"); + countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount, Palette.Count); + + Destroyed += OnDestroyed; + + notifyFinished = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleFinished)); + notifyProgress = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleProgress)); + notifyNewRecipe = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleNewRecipe)); + + // initialize reagent list + + // Add the columns to the TreeView + Gtk.TreeViewColumn reagentEnabledColumn = new Gtk.TreeViewColumn (); + reagentEnabledColumn.Title = "Enabled"; + Gtk.CellRendererToggle reagentEnabledCell = new Gtk.CellRendererToggle (); + reagentEnabledCell.Activatable = true; + reagentEnabledCell.Sensitive = true; + reagentEnabledCell.Mode = Gtk.CellRendererMode.Activatable; + reagentEnabledCell.Visible = true; + reagentEnabledCell.Toggled += new Gtk.ToggledHandler(OnReagentEnableToggled); + reagentEnabledColumn.PackStart (reagentEnabledCell, true); + //reagentEnabledColumn.AddAttribute(reagentEnabledCell, "active", 0); + + Gtk.TreeViewColumn reagentNameColumn = new Gtk.TreeViewColumn (); + reagentNameColumn.Title = "Ingredient"; + Gtk.CellRendererText reagentNameCell = new Gtk.CellRendererText (); + reagentNameCell.Mode = Gtk.CellRendererMode.Inert; + reagentNameColumn.PackStart (reagentNameCell, true); + reagentNameColumn.AddAttribute(reagentNameCell, "text", 1); + reagentNameColumn.Expand = true; + + Gtk.TreeViewColumn reagentCostColumn = new Gtk.TreeViewColumn (); + reagentCostColumn.Title = "Cost"; + Gtk.CellRendererText reagentCostCell = new Gtk.CellRendererText (); + reagentCostCell.Edited += OnReagentCostChanged; + reagentCostCell.Editable = true; + reagentCostCell.Sensitive = true; + reagentCostCell.Mode = Gtk.CellRendererMode.Editable; + reagentCostColumn.PackStart (reagentCostCell, true); + //reagentCostColumn.AddAttribute(reagentCostCell, "text", 0); + + Gtk.TreeViewColumn reagentMaxColumn = new Gtk.TreeViewColumn (); + reagentMaxColumn.Title = "Max"; + Gtk.CellRendererText reagentMaxCell = new Gtk.CellRendererText (); + reagentMaxCell.Edited += OnReagentQuantityChanged; + reagentMaxCell.Editable = true; + reagentMaxCell.Sensitive = true; + reagentCostCell.Mode = Gtk.CellRendererMode.Editable; + reagentMaxColumn.PackStart (reagentMaxCell, true); + //reagentMaxColumn.AddAttribute(reagentMaxCell, "text", 0); + + reagentListStore = new Gtk.ListStore(typeof(Reagent), typeof(string), typeof(Reagent), typeof(Reagent)); + foreach (string reagentName in ReagentManager.Names) + { + Reagent reagent = ReagentManager.GetReagent(reagentName); + reagentListStore.AppendValues(reagent, reagentName); // , reagent, reagent); + } + + reagentEnabledColumn.SetCellDataFunc (reagentEnabledCell, new Gtk.TreeCellDataFunc (RenderReagentToggle)); + reagentCostColumn.SetCellDataFunc (reagentCostCell, new Gtk.TreeCellDataFunc (RenderReagentCost)); + reagentMaxColumn.SetCellDataFunc (reagentMaxCell, new Gtk.TreeCellDataFunc (RenderReagentQuantity)); + + // Assign the model to the TreeView + reagentListView.Model = reagentListStore; + reagentListView.Sensitive = true; + + reagentListView.AppendColumn(reagentEnabledColumn); + reagentListView.AppendColumn(reagentNameColumn); + reagentListView.AppendColumn(reagentCostColumn); + reagentListView.AppendColumn(reagentMaxColumn); + + bool ribbons = false; + profile.ProfileSettings.Get("Generator.Ribbons", out ribbons); + if (ribbons) + { + checkButtonRibbon.Active = true; + InitStateForRibbons(); + } + else + { + checkButtonRibbon.Active = false; + InitStateForPaint(); + } + + ShowAll(); + } + + private void InitStateForPaint() + { + maxRecipeSpinButton.Adjustment.Lower = PaintRecipe.PAINT_RECIPE_MIN_CONCENTRATION; + fullQuantitySpinButton.Adjustment.Upper = 30; + if (generator == null) + { + generator = new RecipeGenerator(profile.Reactions); + int threads; + DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads); + if (threads <= 0) { threads = 15; } + generator.MaxThreads = (uint)threads; + + generator.Progress += OnProgress; + generator.Finished += OnFinished; + generator.NewRecipe += OnNewRecipe; + } + generator.InitRecipes(profile.Recipes); + + string stateFile = System.IO.Path.Combine(profile.Directory, PAINT_STATE_FILE); + if (System.IO.File.Exists(stateFile)) + { + generator.LoadState(stateFile); + if (generator.CanResume) + { + beginButton.Label = "Restart"; + stopResumeButton.Label = "Resume"; + stopResumeButton.Sensitive = true; + + maxRecipeSpinButton.Value = Math.Max(generator.MaxConcentration, 14); // + fullQuantitySpinButton.Value = generator.FullQuantity; // TODO: read/save profile info + fullQuantityDepthSpinButton.Value = generator.FullQuantityDepth; // TODO: read/save profile info + maxIngredientsSpinButton.Value = generator.MaxReagents; + } + } + else + { + beginButton.Label = "Start"; + stopResumeButton.Label = "Stop"; + stopResumeButton.Sensitive = false; + + maxRecipeSpinButton.Value = 14; + //fullQuantitySpinButton.Value = generator.FullQuantity; // TODO: read/save profile info + //fullQuantityDepthSpinButton.Value = generator.FullQuantityDepth; // TODO: read/save profile info + //maxIngredientsSpinButton.Value = generator.MaxReagents; + } + //generator.Log = System.IO.Path.Combine(profile.Directory, "dp_log.txt"); + countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount, Palette.Count); + + colorStore.Clear(); + foreach (KeyValuePair pair in profile.Recipes) + { + if (pair.Value.IsValidForConcentration(PaintRecipe.PAINT_RECIPE_MIN_CONCENTRATION)) + { + string colorName = pair.Key; + colorStore.AppendValues(colorName); + } + } + recipeList.Show(); + } + + private void InitStateForRibbons() + { + maxRecipeSpinButton.Adjustment.Lower = PaintRecipe.RIBBON_RECIPE_MIN_CONCENTRATION; + fullQuantitySpinButton.Adjustment.Upper = 100; + if (generator == null) + { + generator = new RecipeGenerator(profile.Reactions); + int threads; + DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads); + if (threads <= 0) { threads = 15; } + generator.MaxThreads = (uint)threads; + + generator.Progress += OnProgress; + generator.Finished += OnFinished; + generator.NewRecipe += OnNewRecipe; + } + generator.InitRecipes(profile.RibbonRecipes); + + string stateFile = System.IO.Path.Combine(profile.Directory, RIBBON_STATE_FILE); + if (System.IO.File.Exists(stateFile)) + { + generator.LoadState(stateFile); + if (generator.CanResume) + { + beginButton.Label = "Restart"; + stopResumeButton.Label = "Resume"; + stopResumeButton.Sensitive = true; + + maxRecipeSpinButton.Value = Math.Max(generator.MaxConcentration, PaintRecipe.RIBBON_RECIPE_MIN_CONCENTRATION); // + fullQuantitySpinButton.Value = generator.FullQuantity; // TODO: read/save profile info + fullQuantityDepthSpinButton.Value = generator.FullQuantityDepth; // TODO: read/save profile info + maxIngredientsSpinButton.Value = generator.MaxReagents; + } + } + else + { + beginButton.Label = "Start"; + stopResumeButton.Label = "Stop"; + stopResumeButton.Sensitive = false; + + maxRecipeSpinButton.Value = PaintRecipe.RIBBON_RECIPE_MIN_CONCENTRATION +; + //fullQuantitySpinButton.Value = generator.FullQuantity; // TODO: read/save profile info + //fullQuantityDepthSpinButton.Value = generator.FullQuantityDepth; // TODO: read/save profile info + //maxIngredientsSpinButton.Value = generator.MaxReagents; + } + + countLabel.Text = String.Format("{0} / {1}", profile.RibbonCount, Palette.Count); + + colorStore.Clear(); + foreach (KeyValuePair pair in profile.RibbonRecipes) + { + if (pair.Value.IsValidForConcentration(PaintRecipe.RIBBON_RECIPE_MIN_CONCENTRATION)) + { + string colorName = pair.Key; + colorStore.AppendValues(colorName); + } + } + recipeList.Show(); + } + + public PlayerProfile Profile { + set { + if (profile != value) { + // TODO: ensure not running + profile = value; + profile.LoadRecipes(); + + generator = new RecipeGenerator(profile.Reactions); + int threads; + DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads); + if (threads <= 0) { threads = 15; } + generator.MaxThreads = (uint)threads; + + generator.Progress += OnProgress; + generator.Finished += OnFinished; + generator.NewRecipe += OnNewRecipe; + + if (checkButtonRibbon.Active) + { + InitStateForRibbons(); + } + else + { + InitStateForPaint(); + } + } + } + } + + protected void OnMinIngredientsChanged(object sender, EventArgs e) + { + Gtk.SpinButton button = (Gtk.SpinButton) sender; + if (button.ValueAsInt > maxIngredientsSpinButton.ValueAsInt) + { + maxIngredientsSpinButton.Value = button.ValueAsInt; + } + maxIngredientsSpinButton.SetRange(button.ValueAsInt, maxIngredientsSpinButton.Adjustment.Upper); + } + + protected void OnMaxIngredientsChanged(object sender, EventArgs e) + { + Gtk.SpinButton button = (Gtk.SpinButton) sender; + if (button.ValueAsInt < minIngredientsSpinButton.ValueAsInt) + { + minIngredientsSpinButton.Value = button.ValueAsInt; + } + minIngredientsSpinButton.SetRange(1, button.ValueAsInt); + // TODO: save profile setting + // TODO: no longer permit resume + } + + protected void OnMaxRecipeChanged(object sender, EventArgs e) + { + // TODO: save profile setting + // TODO: no longer permit resume + } + + protected void OnFullQuantityDepthChanged(object sender, EventArgs e) + { + // TODO: save profile setting + // TODO: no longer permit resume + } + + protected void OnFullQuantityChanged(object sender, EventArgs e) + { + // TODO: save profile setting + // TODO: no longer permit resume + } + + protected void OnBegin(object sender, EventArgs e) + { + minIngredientsSpinButton.Sensitive = false; + maxIngredientsSpinButton.Sensitive = false; + //TODO ExportToWikiAction.Sensitive = false; + maxRecipeSpinButton.Sensitive = false; + beginButton.Sensitive = false; // TODO: change to "pause"? + stopResumeButton.Sensitive = true; + fullQuantitySpinButton.Sensitive = false; + fullQuantityDepthSpinButton.Sensitive = false; + reagentListView.Sensitive = false; + checkButtonRibbon.Sensitive = false; + + countLabel.Text = String.Format("{0} / {1}", checkButtonRibbon.Active ? profile.RibbonCount : profile.RecipeCount, Palette.Count); + + // TODO: hook up event notifications + // - progress + // - complete + // - new recipe / recipe update + + // Total recipe search count + //int current = ReagentManager.Names.Count; + //long recipePermutations = 1; + //for (int i = 0; i < maxIngredientsSpinButton.ValueAsInt; ++i) + //{ + // recipePermutations *= current; + // --current; + //} + //System.Console.WriteLine("Will search {0} reagent permutations.", recipePermutations); + + lastProgressUpdate = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; + lastStatusUpdate = lastProgressUpdate; + + lastProfileSave = lastProgressUpdate; + lastCheckpoint = lastProgressUpdate; + + running = true; + canceling = false; + pauseForCheckpoint = false; + stopResumeButton.Label = "Pause"; + + if (Started != null) + { + Started(this, null); + } + + generator.BeginRecipeGeneration((uint)(checkButtonRibbon.Active ? PaintRecipe.RIBBON_RECIPE_MIN_CONCENTRATION : PaintRecipe.PAINT_RECIPE_MIN_CONCENTRATION), (uint)maxRecipeSpinButton.ValueAsInt, (uint)minIngredientsSpinButton.Value, (uint)maxIngredientsSpinButton.ValueAsInt, (uint)fullQuantityDepthSpinButton.ValueAsInt, (uint)fullQuantitySpinButton.ValueAsInt); + } + + protected void OnStopResume(object sender, EventArgs e) + { + if (generator != null) + { + if (running) + { + canceling = true; + pauseForCheckpoint = false; + generator.Stop(); + } + else + { + // Resume previous run + //TODO ExportToWikiAction.Sensitive = false; + reagentListView.Sensitive = false; + minIngredientsSpinButton.Sensitive = false; + maxIngredientsSpinButton.Sensitive = false; + maxRecipeSpinButton.Sensitive = false; + beginButton.Sensitive = false; + stopResumeButton.Sensitive = true; + fullQuantitySpinButton.Sensitive = false; + fullQuantityDepthSpinButton.Sensitive = false; + reagentListView.Sensitive = false; + checkButtonRibbon.Sensitive = false; + + lastProgressUpdate = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; + lastStatusUpdate = lastProgressUpdate; + lastProfileSave = lastProgressUpdate; + lastCheckpoint = lastProgressUpdate; + + canceling = false; + pauseForCheckpoint = false; + running = true; + + stopResumeButton.Label = "Pause"; + + if (Started != null) + { + Started(this, null); + } + generator.ResumeRecipeGeneration(); + } + } + } + + private void HandleFinished() + { + generator.Wait(); + if (pauseForCheckpoint) + { + pauseForCheckpoint = false; + generator.SaveState(System.IO.Path.Combine(profile.Directory, checkButtonRibbon.Active ? RIBBON_STATE_FILE : PAINT_STATE_FILE)); + generator.ResumeRecipeGeneration(); + } + else + { + running = false; + beginButton.Sensitive = true; + //TODO ExportToWikiAction.Sensitive = true; + stopResumeButton.Sensitive = false; + minIngredientsSpinButton.Sensitive = true; + maxIngredientsSpinButton.Sensitive = true; + maxRecipeSpinButton.Sensitive = true; + fullQuantitySpinButton.Sensitive = true; + fullQuantityDepthSpinButton.Sensitive = true; + reagentListView.Sensitive = true; + checkButtonRibbon.Sensitive = true; + + //generator = null; // don't. Hang on to generator for resume. + profile.SaveRecipes(); + if (canceling) + { + generator.SaveState(System.IO.Path.Combine(profile.Directory, checkButtonRibbon.Active ? RIBBON_STATE_FILE : PAINT_STATE_FILE)); + stopResumeButton.Label = "Resume"; + stopResumeButton.Sensitive = true; + beginButton.Label = "Restart"; + } + else + { + System.IO.File.Delete(System.IO.Path.Combine(profile.Directory, checkButtonRibbon.Active ? RIBBON_STATE_FILE : PAINT_STATE_FILE)); + } + if (Stopped != null) + { + Stopped(this, null); + } + } + } + + protected void OnFinished(object sender, EventArgs args) + { + notifyFinished.WakeupMain(); + //Gtk.Application.Invoke(delegate { + // HandleFinished(); + //}); + } + + private void HandleNewRecipe() + { + progressBar.Pulse(); + + PaintRecipe recipe = null; + if (pendingNewRecipes.TryDequeue(out recipe)) + { + string recipeColor = Palette.FindNearest(recipe.ReactedColor); + // TODO: Add item to recipe list only if not already listed + bool exists = false; + Gtk.TreeIter iter; + if (colorStore.GetIterFirst(out iter)) + { + do + { + string color = (string)colorStore.GetValue(iter, 0); + if (color.Equals(recipeColor)) + { + exists = true; + break; + } + } while (colorStore.IterNext(ref iter)); + } + if (!exists) + { + //Console.WriteLine("Add new recipe for {0}", recipeColor); + // bool isMissingReactions = args.Recipe.CheckMissingReactions(ref missingReactions); + // string missingReactionLabel = isMissingReactions ? "X" : ""; + colorStore.AppendValues(recipeColor); // , missingReactionLabel); + countLabel.Text = String.Format("{0} / {1}", (checkButtonRibbon.Active ? profile.RibbonCount : profile.RecipeCount)+1, Palette.Count); + } + //else + //{ + // Console.WriteLine("Updated recipe for {0}", recipeColor); + //} + if (checkButtonRibbon.Active) + { + profile.SetRibbonRecipe(recipe); + } + else + { + profile.SetRecipe(recipe); + } + + long progressTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; + long delta = progressTime - lastProfileSave; + if (delta >= RECIPE_SAVE_INTERVAL) + { + profile.SaveRecipes(); + lastProfileSave = progressTime; + } + Gtk.TreeModel model; + Gtk.TreeSelection selection = recipeList.Selection; + if ((selection != null) && selection.GetSelected(out model, out iter)) + { + string colorName = (string)colorStore.GetValue(iter, 0); + if (colorName.Equals(recipeColor)) + { + ShowColor(recipe); + } + } + } + } + + protected void OnNewRecipe(object sender, NewRecipeEventArgs args) + { + PaintRecipe recipe = new PaintRecipe(args.Recipe); // copy it, so the worker thread can release + lock(this) { + pendingNewRecipes.Enqueue(recipe); + } + notifyNewRecipe.WakeupMain(); + //Gtk.Application.Invoke(delegate { + // HandleNewRecipe(); + //}); + } + + private void HandleProgress() + { + long progressTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; + long delta = progressTime - lastProgressUpdate; + if (delta > 30) + { + lastProgressUpdate = progressTime; + progressBar.Pulse(); + } + delta = progressTime - lastStatusUpdate; + if (delta > 500) + { + lastStatusUpdate = progressTime; + if (SetStatus != null) + { + SetStatus(this, new StatusUpdateEventArgs(String.Format("Recipes searched: {0:N00}", generator.RecipeCount))); + } + //TODO statusLabel.Text = String.Format("Recipes searched: {0:N00}", generator.RecipeCount); + } + delta = progressTime - lastCheckpoint; + if (delta > CHECKPOINT_INTERVAL) + { + lastCheckpoint = progressTime; + pauseForCheckpoint = true; + generator.Stop(); + } + } + + protected void OnProgress(object sender, EventArgs args) + { + notifyProgress.WakeupMain(); + } + + private void ShowColor(PaintRecipe recipe) + { + Gtk.ListStore store = (Gtk.ListStore)recipeIngredientsView.Model; + store.Clear(); + if (recipe.CheckMissingReactions(ref missingReactions)) + { + if (SetStatus != null) + { + SetStatus(this, new StatusUpdateEventArgs("WARNING: This recipe includes reactions that have not yet been recorded.")); + } + //TODO statusLabel.Text = "WARNING: This recipe includes reactions that have not yet been recorded."; + } + foreach (PaintRecipe.RecipeIngredient ingredient in recipe.Ingredients) + { + store.AppendValues(ingredient.quantity.ToString(), ingredient.name); + } + paintSwatch.Color = recipe.ReactedColor; + } + + protected void OnColorSelected(object o, EventArgs args) + { + Gtk.TreeModel model; + Gtk.TreeIter iter; + Gtk.TreeSelection selection = recipeList.Selection; + if ((selection != null) && selection.GetSelected(out model, out iter)) + { + string colorName = (string)colorStore.GetValue(iter, 0); + PaintRecipe recipe; + if (checkButtonRibbon.Active) + { + if (profile.RibbonRecipes.TryGetValue(colorName, out recipe)) + { + ShowColor(recipe); + } + } + else + { + if (profile.Recipes.TryGetValue(colorName, out recipe)) + { + ShowColor(recipe); + } + } + } + } + + protected void OnShowIngredients(object sender, EventArgs e) + { + ReagentWindow win = new ReagentWindow(profile); + win.Show(); + } + + protected void OnDestroyed(object o, EventArgs args) + { + if (running) + { + // window closed while generator running: stop and save + generator.Finished -= OnFinished; + generator.Progress -= OnProgress; + generator.NewRecipe -= OnNewRecipe; + generator.Stop(); + generator.Wait(); + generator.SaveState(System.IO.Path.Combine(profile.Directory, checkButtonRibbon.Active ? RIBBON_STATE_FILE : PAINT_STATE_FILE)); + } + } + + // Reagent view handling + private void RenderReagentToggle (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) + { + Reagent reagent = (Reagent) model.GetValue (iter, 0); + Gtk.CellRendererToggle toggle = (cell as Gtk.CellRendererToggle); + toggle.Active = reagent.Enabled; + toggle.Activatable = !reagent.IsCatalyst; + toggle.Mode = reagent.IsCatalyst ? Gtk.CellRendererMode.Inert : Gtk.CellRendererMode.Activatable; + } + private void RenderReagentCost (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) + { + Reagent reagent = (Reagent) model.GetValue (iter, 0); + (cell as Gtk.CellRendererText).Text = reagent.Cost.ToString(); + } + private void RenderReagentQuantity (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) + { + Reagent reagent = (Reagent) model.GetValue (iter, 0); + (cell as Gtk.CellRendererText).Text = reagent.RecipeMax.ToString(); + } + + private void OnReagentCostChanged(object o, Gtk.EditedArgs args) + { + uint newCost; + if (uint.TryParse(args.NewText, out newCost)) + { + Gtk.TreeIter iter; + reagentListStore.GetIter (out iter, new Gtk.TreePath (args.Path)); + + Reagent reagent = (Reagent) reagentListStore.GetValue (iter, 0); + if (reagent.Cost != newCost) + { + reagent.Cost = newCost; + SaveReagentSettings(); + } + } + } + + private void OnReagentQuantityChanged(object o, Gtk.EditedArgs args) + { + uint newMax; + if (uint.TryParse(args.NewText, out newMax)) + { + Gtk.TreeIter iter; + reagentListStore.GetIter (out iter, new Gtk.TreePath (args.Path)); + + Reagent reagent = (Reagent) reagentListStore.GetValue (iter, 0); + if (reagent.RecipeMax != newMax) + { + reagent.RecipeMax = newMax; + SaveReagentSettings(); + } + } + } + + private void OnReagentEnableToggled(object o, Gtk.ToggledArgs args) + { + Gtk.TreeIter iter; + reagentListStore.GetIter (out iter, new Gtk.TreePath (args.Path)); + + Reagent reagent = (Reagent) reagentListStore.GetValue (iter, 0); + reagent.Enabled = !reagent.Enabled; + SaveReagentSettings(); + } + + private void SaveReagentSettings() + { + // save out state + ReagentManager.SaveProfileReagents(profile.ReagentFile); + } + + protected void OnCopyRecipeToClipboard(object sender, EventArgs e) + { + Gtk.TreeModel model; + Gtk.TreeIter iter; + Gtk.Clipboard clipboard = recipeIngredientsView.GetClipboard(Gdk.Selection.Clipboard); + + Gtk.TreeSelection selection = recipeList.Selection; + if ((selection != null) && selection.GetSelected(out model, out iter)) + { + string colorName = (string)colorStore.GetValue(iter, 0); + PaintRecipe recipe; + if (checkButtonRibbon.Active) + { + if (profile.RibbonRecipes.TryGetValue(colorName, out recipe)) + { + clipboard.Text = recipe.ToString(); + } + } + else + { + if (profile.Recipes.TryGetValue(colorName, out recipe)) + { + clipboard.Text = recipe.ToString(); + } + } + } + } + + protected void OnRecipesToggled(object sender, EventArgs e) + { + if (checkButtonRibbon.Active) + { + // changed to ribbons + InitStateForRibbons(); + } + else + { + // changed to paints + InitStateForPaint(); + } + profile.ProfileSettings.Set("Generator.Ribbons", checkButtonRibbon.Active); + profile.Save(); + } + } +} + + diff --git a/UI/SimulatorView.cs b/UI/SimulatorView.cs new file mode 100644 --- /dev/null +++ b/UI/SimulatorView.cs @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2010, Tess Snider + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +using System; +using System.Collections.Generic; + + +namespace DesertPaintLab +{ + [System.ComponentModel.ToolboxItem(true)] + public partial class SimulatorView : Gtk.Bin + { + Gtk.ListStore recipeData = new Gtk.ListStore(typeof(string), typeof(int)); + PaintRecipe paintRecipe; + + List missingWarned = new List(); + List> newMissing = new List>(); + + private class IngredientPair + { + public string first; + public string second; + + public IngredientPair(string first, string second) + { + this.first = first; + this.second = second; + } + } + + public PlayerProfile Profile + { + set { + paintRecipe.Clear(); + paintRecipe.Reactions = value.Reactions; + UpdateRecipeColor(); + } + } + + public SimulatorView(PlayerProfile profile) : base() + { + this.Build (); + + paintRecipe = new PaintRecipe(); + paintRecipe.Reactions = profile.Reactions; + + Gtk.TreeViewColumn reagentColumn = new Gtk.TreeViewColumn(); + Gtk.CellRendererText reagentColumnCell = new Gtk.CellRendererText(); + reagentColumn.PackStart(reagentColumnCell, true); + reagentColumn.Title = "Ingredient"; + + reagentListView.AppendColumn(reagentColumn); + reagentColumn.AddAttribute(reagentColumnCell, "text", 0); + + reagentListView.Model = ReagentManager.NameListModel; + + Gtk.TreeViewColumn additiveColumn = new Gtk.TreeViewColumn(); + Gtk.CellRendererText additiveColumnCell = new Gtk.CellRendererText(); + additiveColumn.PackStart(additiveColumnCell, true); + additiveColumn.Title = "Ingredient"; + + recipeView.AppendColumn(additiveColumn); + additiveColumn.AddAttribute(additiveColumnCell, "text", 0); + + Gtk.TreeViewColumn qtyColumn = new Gtk.TreeViewColumn(); + Gtk.CellRendererText qtyColumnCell = new Gtk.CellRendererText(); + qtyColumnCell.Editable = true; + qtyColumnCell.Edited += OnQtyEdited; + qtyColumn.PackStart(qtyColumnCell, true); + qtyColumn.Title = "Qty"; + + recipeView.AppendColumn(qtyColumn); + qtyColumn.AddAttribute(qtyColumnCell, "text", 1); + + recipeView.Model = recipeData; + + recipeData.RowChanged += OnRecipeChanged; + recipeData.RowDeleted += OnRecipeChanged; + recipeData.RowInserted += OnRecipeChanged; + recipeData.RowsReordered += OnRecipeChanged; + + } + + protected virtual void OnAddReagent(object sender, System.EventArgs e) + { + Gtk.TreeModel model; + Gtk.TreeIter iter; + + Gtk.TreeSelection selection = reagentListView.Selection; + if ((selection != null) && selection.GetSelected(out model, out iter)) + { + recipeData.AppendValues(model.GetValue(iter, 0).ToString(), 1); + + recipeData.IterNthChild(out iter, recipeView.Children.Length - 1); + + selection = recipeView.Selection; + selection.SelectIter(iter); + } + } + + protected void OnQtyEdited(object sender, Gtk.EditedArgs args) + { + Gtk.TreeIter iter; + recipeData.GetIter(out iter, new Gtk.TreePath(args.Path)); + + int oldValue = (int)recipeData.GetValue(iter, 1); + + try + { + recipeData.SetValue(iter, 1, int.Parse(args.NewText)); + UpdateRecipeColor(); + } + catch (Exception) + { + recipeData.SetValue(iter, 1, oldValue); + } + } + + protected void OnRecipeChanged(object sender, GLib.SignalArgs args) + { + UpdateRecipeColor(); + } + + void UpdateRecipeColor() + { + if (recipeView.Children.Length == 0) + { + paintSwatch.Clear(); + } + + paintRecipe.Clear(); + + Gtk.TreeIter iter; + string reagentName; + int qty; + + recipeData.GetIterFirst(out iter); + + do + { + reagentName = (string) recipeData.GetValue(iter, 0); + + if (reagentName == null) + { + continue; + } + + qty = (int)recipeData.GetValue(iter, 1); + for (int i = 0; i < qty; ++i) + { + paintRecipe.AddReagent(reagentName); + } + } + while (recipeData.IterNext(ref iter)); + + PaintColor resultColor = new PaintColor(paintRecipe.ReactedColor); + paintSwatch.Color = resultColor; + if (paintRecipe.CheckMissingReactions(ref newMissing)) + { + string warningMsg = ""; + + foreach (KeyValuePair newEntry in newMissing) + { + IngredientPair match = missingWarned.Find(x => (x.first.Equals(newEntry.Key) && x.second.Equals(newEntry.Value))); + if (match == null) + { + match = new IngredientPair(newEntry.Key, newEntry.Value); + missingWarned.Add(match); + warningMsg += newEntry.Key + " + " + newEntry.Value + "\n"; + } + } + if (warningMsg.Length > 0) + { + Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, + Gtk.DialogFlags.DestroyWithParent, + Gtk.MessageType.Warning, + Gtk.ButtonsType.Ok, + "These combinations have not yet had reactions recorded:\n\n" + + warningMsg); + md.Run(); + md.Destroy(); + } + } + + } + + protected virtual void OnIncrementReagent (object sender, System.EventArgs e) + { + Gtk.TreeModel model; + Gtk.TreeIter iter; + + Gtk.TreeSelection selection = recipeView.Selection; + if ((selection != null) && selection.GetSelected(out model, out iter)) + { + int oldValue = (int)recipeData.GetValue(iter, 1); + recipeData.SetValue(iter, 1, oldValue + 1); + } + + } + + protected virtual void OnDecrementReagent (object sender, System.EventArgs e) + { + Gtk.TreeModel model; + Gtk.TreeIter iter; + + Gtk.TreeSelection selection = recipeView.Selection; + if ((selection != null) && selection.GetSelected(out model, out iter)) + { + int oldValue = (int)recipeData.GetValue(iter, 1); + if (oldValue == 1) + { + recipeData.Remove(ref iter); + } + else + { + recipeData.SetValue(iter, 1, oldValue - 1); + } + } + + } + + protected virtual void OnFlushReagents (object sender, System.EventArgs e) + { + recipeData.Clear(); + } + } +} \ No newline at end of file diff --git a/gtk-gui/DesertPaintLab.CaptureView.cs b/gtk-gui/DesertPaintLab.CaptureView.cs new file mode 100644 --- /dev/null +++ b/gtk-gui/DesertPaintLab.CaptureView.cs @@ -0,0 +1,292 @@ + +// This file has been generated by the GUI designer. Do not modify. +namespace DesertPaintLab +{ + public partial class CaptureView + { + private global::Gtk.HBox hbox1; + + private global::Gtk.Frame selectIngredientsFrame; + + private global::Gtk.Alignment GtkAlignment; + + private global::Gtk.VBox vbox2; + + private global::Gtk.HBox hbox2; + + private global::Gtk.Label ingredient1Label; + + private global::Gtk.ComboBox ingredient1ComboBox; + + private global::Gtk.HBox hbox3; + + private global::Gtk.Label ingredient2Label; + + private global::Gtk.ComboBox ingredient2ComboBox; + + private global::Gtk.HBox hbox4; + + private global::Gtk.Label ingredient3Label; + + private global::Gtk.ComboBox ingredient3ComboBox; + + private global::Gtk.Button clearReactionButton; + + private global::Gtk.Label selectIngredientsLabel; + + private global::Gtk.Frame unmodifiedColorFrame; + + private global::Gtk.Alignment GtkAlignment1; + + private global::Gtk.VBox vbox3; + + private global::DesertPaintLab.PaintSwatch unmodifiedSwatch; + + private global::Gtk.Button captureButton; + + private global::Gtk.Label unmodifiedLabel; + + private global::Gtk.Frame reactedColorFrame; + + private global::Gtk.Alignment GtkAlignment2; + + private global::Gtk.VBox vbox4; + + private global::DesertPaintLab.PaintSwatch reactionSwatch; + + private global::Gtk.Button recordButton; + + private global::Gtk.Label reactionLabel; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget DesertPaintLab.CaptureView + global::Stetic.BinContainer.Attach (this); + this.Name = "DesertPaintLab.CaptureView"; + // Container child DesertPaintLab.CaptureView.Gtk.Container+ContainerChild + this.hbox1 = new global::Gtk.HBox (); + this.hbox1.Name = "hbox1"; + this.hbox1.Spacing = 6; + // Container child hbox1.Gtk.Box+BoxChild + this.selectIngredientsFrame = new global::Gtk.Frame (); + this.selectIngredientsFrame.Name = "selectIngredientsFrame"; + this.selectIngredientsFrame.BorderWidth = ((uint)(4)); + // Container child selectIngredientsFrame.Gtk.Container+ContainerChild + this.GtkAlignment = new global::Gtk.Alignment (0F, 0F, 1F, 1F); + this.GtkAlignment.Name = "GtkAlignment"; + this.GtkAlignment.LeftPadding = ((uint)(6)); + this.GtkAlignment.RightPadding = ((uint)(6)); + // Container child GtkAlignment.Gtk.Container+ContainerChild + this.vbox2 = new global::Gtk.VBox (); + this.vbox2.Name = "vbox2"; + this.vbox2.Spacing = 6; + // Container child vbox2.Gtk.Box+BoxChild + this.hbox2 = new global::Gtk.HBox (); + this.hbox2.Name = "hbox2"; + this.hbox2.Spacing = 6; + // Container child hbox2.Gtk.Box+BoxChild + this.ingredient1Label = new global::Gtk.Label (); + this.ingredient1Label.Name = "ingredient1Label"; + this.ingredient1Label.LabelProp = "Ingredient 1:"; + this.hbox2.Add (this.ingredient1Label); + global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.ingredient1Label])); + w1.Position = 0; + w1.Expand = false; + w1.Fill = false; + // Container child hbox2.Gtk.Box+BoxChild + this.ingredient1ComboBox = global::Gtk.ComboBox.NewText (); + this.ingredient1ComboBox.Name = "ingredient1ComboBox"; + this.hbox2.Add (this.ingredient1ComboBox); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.ingredient1ComboBox])); + w2.Position = 1; + this.vbox2.Add (this.hbox2); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox2])); + w3.Position = 0; + w3.Expand = false; + w3.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.hbox3 = new global::Gtk.HBox (); + this.hbox3.Name = "hbox3"; + this.hbox3.Spacing = 6; + // Container child hbox3.Gtk.Box+BoxChild + this.ingredient2Label = new global::Gtk.Label (); + this.ingredient2Label.Name = "ingredient2Label"; + this.ingredient2Label.LabelProp = "Ingredient 2:"; + this.hbox3.Add (this.ingredient2Label); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.ingredient2Label])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + // Container child hbox3.Gtk.Box+BoxChild + this.ingredient2ComboBox = global::Gtk.ComboBox.NewText (); + this.ingredient2ComboBox.Name = "ingredient2ComboBox"; + this.hbox3.Add (this.ingredient2ComboBox); + global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.ingredient2ComboBox])); + w5.Position = 1; + this.vbox2.Add (this.hbox3); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox3])); + w6.Position = 1; + w6.Expand = false; + w6.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.hbox4 = new global::Gtk.HBox (); + this.hbox4.Name = "hbox4"; + this.hbox4.Spacing = 6; + // Container child hbox4.Gtk.Box+BoxChild + this.ingredient3Label = new global::Gtk.Label (); + this.ingredient3Label.Name = "ingredient3Label"; + this.ingredient3Label.LabelProp = "Ingredient 3:"; + this.hbox4.Add (this.ingredient3Label); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.ingredient3Label])); + w7.Position = 0; + w7.Expand = false; + w7.Fill = false; + // Container child hbox4.Gtk.Box+BoxChild + this.ingredient3ComboBox = global::Gtk.ComboBox.NewText (); + this.ingredient3ComboBox.Name = "ingredient3ComboBox"; + this.hbox4.Add (this.ingredient3ComboBox); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.ingredient3ComboBox])); + w8.Position = 1; + this.vbox2.Add (this.hbox4); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox4])); + w9.Position = 2; + w9.Expand = false; + w9.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.clearReactionButton = new global::Gtk.Button (); + this.clearReactionButton.Sensitive = false; + this.clearReactionButton.CanFocus = true; + this.clearReactionButton.Name = "clearReactionButton"; + this.clearReactionButton.UseUnderline = true; + this.clearReactionButton.Label = "Clear Reaction"; + this.vbox2.Add (this.clearReactionButton); + global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.clearReactionButton])); + w10.PackType = ((global::Gtk.PackType)(1)); + w10.Position = 3; + w10.Expand = false; + w10.Fill = false; + w10.Padding = ((uint)(6)); + this.GtkAlignment.Add (this.vbox2); + this.selectIngredientsFrame.Add (this.GtkAlignment); + this.selectIngredientsLabel = new global::Gtk.Label (); + this.selectIngredientsLabel.Name = "selectIngredientsLabel"; + this.selectIngredientsLabel.LabelProp = "Select Ingredients"; + this.selectIngredientsLabel.UseMarkup = true; + this.selectIngredientsFrame.LabelWidget = this.selectIngredientsLabel; + this.hbox1.Add (this.selectIngredientsFrame); + global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.selectIngredientsFrame])); + w13.Position = 0; + // Container child hbox1.Gtk.Box+BoxChild + this.unmodifiedColorFrame = new global::Gtk.Frame (); + this.unmodifiedColorFrame.Name = "unmodifiedColorFrame"; + this.unmodifiedColorFrame.BorderWidth = ((uint)(4)); + // Container child unmodifiedColorFrame.Gtk.Container+ContainerChild + this.GtkAlignment1 = new global::Gtk.Alignment (0F, 0F, 1F, 1F); + this.GtkAlignment1.Name = "GtkAlignment1"; + this.GtkAlignment1.LeftPadding = ((uint)(5)); + this.GtkAlignment1.TopPadding = ((uint)(5)); + this.GtkAlignment1.RightPadding = ((uint)(5)); + this.GtkAlignment1.BottomPadding = ((uint)(6)); + // Container child GtkAlignment1.Gtk.Container+ContainerChild + this.vbox3 = new global::Gtk.VBox (); + this.vbox3.WidthRequest = 120; + this.vbox3.Name = "vbox3"; + this.vbox3.Spacing = 6; + // Container child vbox3.Gtk.Box+BoxChild + this.unmodifiedSwatch = new global::DesertPaintLab.PaintSwatch (); + this.unmodifiedSwatch.WidthRequest = 120; + this.unmodifiedSwatch.HeightRequest = 120; + this.unmodifiedSwatch.Events = ((global::Gdk.EventMask)(256)); + this.unmodifiedSwatch.Name = "unmodifiedSwatch"; + this.vbox3.Add (this.unmodifiedSwatch); + global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.unmodifiedSwatch])); + w14.Position = 0; + // Container child vbox3.Gtk.Box+BoxChild + this.captureButton = new global::Gtk.Button (); + this.captureButton.CanFocus = true; + this.captureButton.Name = "captureButton"; + this.captureButton.UseUnderline = true; + this.captureButton.Label = "Capture"; + this.vbox3.Add (this.captureButton); + global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.captureButton])); + w15.Position = 1; + w15.Expand = false; + w15.Fill = false; + this.GtkAlignment1.Add (this.vbox3); + this.unmodifiedColorFrame.Add (this.GtkAlignment1); + this.unmodifiedLabel = new global::Gtk.Label (); + this.unmodifiedLabel.Name = "unmodifiedLabel"; + this.unmodifiedLabel.LabelProp = "Unmodified"; + this.unmodifiedLabel.UseMarkup = true; + this.unmodifiedLabel.Justify = ((global::Gtk.Justification)(2)); + this.unmodifiedColorFrame.LabelWidget = this.unmodifiedLabel; + this.hbox1.Add (this.unmodifiedColorFrame); + global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.unmodifiedColorFrame])); + w18.Position = 1; + w18.Expand = false; + w18.Fill = false; + // Container child hbox1.Gtk.Box+BoxChild + this.reactedColorFrame = new global::Gtk.Frame (); + this.reactedColorFrame.Name = "reactedColorFrame"; + this.reactedColorFrame.BorderWidth = ((uint)(4)); + // Container child reactedColorFrame.Gtk.Container+ContainerChild + this.GtkAlignment2 = new global::Gtk.Alignment (0F, 0F, 1F, 1F); + this.GtkAlignment2.Name = "GtkAlignment2"; + this.GtkAlignment2.LeftPadding = ((uint)(5)); + this.GtkAlignment2.TopPadding = ((uint)(5)); + this.GtkAlignment2.RightPadding = ((uint)(5)); + this.GtkAlignment2.BottomPadding = ((uint)(6)); + // Container child GtkAlignment2.Gtk.Container+ContainerChild + this.vbox4 = new global::Gtk.VBox (); + this.vbox4.WidthRequest = 120; + this.vbox4.Name = "vbox4"; + this.vbox4.Spacing = 6; + // Container child vbox4.Gtk.Box+BoxChild + this.reactionSwatch = new global::DesertPaintLab.PaintSwatch (); + this.reactionSwatch.WidthRequest = 120; + this.reactionSwatch.HeightRequest = 120; + this.reactionSwatch.Events = ((global::Gdk.EventMask)(256)); + this.reactionSwatch.Name = "reactionSwatch"; + this.vbox4.Add (this.reactionSwatch); + global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.reactionSwatch])); + w19.Position = 0; + // Container child vbox4.Gtk.Box+BoxChild + this.recordButton = new global::Gtk.Button (); + this.recordButton.CanFocus = true; + this.recordButton.Name = "recordButton"; + this.recordButton.UseUnderline = true; + this.recordButton.Label = "Record"; + this.vbox4.Add (this.recordButton); + global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.recordButton])); + w20.Position = 1; + w20.Expand = false; + w20.Fill = false; + this.GtkAlignment2.Add (this.vbox4); + this.reactedColorFrame.Add (this.GtkAlignment2); + this.reactionLabel = new global::Gtk.Label (); + this.reactionLabel.Name = "reactionLabel"; + this.reactionLabel.LabelProp = "Reacted"; + this.reactionLabel.UseMarkup = true; + this.reactionLabel.Justify = ((global::Gtk.Justification)(2)); + this.reactedColorFrame.LabelWidget = this.reactionLabel; + this.hbox1.Add (this.reactedColorFrame); + global::Gtk.Box.BoxChild w23 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.reactedColorFrame])); + w23.Position = 2; + w23.Expand = false; + w23.Fill = false; + this.Add (this.hbox1); + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.clearReactionButton.Hide (); + this.Hide (); + this.ingredient1ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient1); + this.ingredient2ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient2); + this.ingredient3ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient3); + this.clearReactionButton.Clicked += new global::System.EventHandler (this.OnClearReaction); + this.captureButton.Clicked += new global::System.EventHandler (this.OnCapture); + this.recordButton.Clicked += new global::System.EventHandler (this.OnRecord); + } + } +} diff --git a/gtk-gui/DesertPaintLab.RecipeGeneratorView.cs b/gtk-gui/DesertPaintLab.RecipeGeneratorView.cs new file mode 100644 --- /dev/null +++ b/gtk-gui/DesertPaintLab.RecipeGeneratorView.cs @@ -0,0 +1,507 @@ + +// This file has been generated by the GUI designer. Do not modify. +namespace DesertPaintLab +{ + public partial class RecipeGeneratorView + { + private global::Gtk.UIManager UIManager; + + private global::Gtk.VBox vbox2; + + private global::Gtk.HBox hbox1; + + private global::Gtk.VBox vbox8; + + private global::Gtk.HBox hbox2; + + private global::Gtk.SpinButton minIngredientsSpinButton; + + private global::Gtk.Label label1; + + private global::Gtk.HBox hbox7; + + private global::Gtk.SpinButton maxIngredientsSpinButton; + + private global::Gtk.Label label3; + + private global::Gtk.HSeparator hseparator3; + + private global::Gtk.CheckButton checkButtonRibbon; + + private global::Gtk.HBox hbox4; + + private global::Gtk.SpinButton maxRecipeSpinButton; + + private global::Gtk.Label label4; + + private global::Gtk.HSeparator hseparator4; + + private global::Gtk.HBox hbox5; + + private global::Gtk.SpinButton fullQuantityDepthSpinButton; + + private global::Gtk.Label label8; + + private global::Gtk.HSeparator hseparator5; + + private global::Gtk.HBox hbox6; + + private global::Gtk.SpinButton fullQuantitySpinButton; + + private global::Gtk.Label label9; + + private global::Gtk.Frame frame3; + + private global::Gtk.Alignment GtkAlignment1; + + private global::Gtk.ScrolledWindow scrolledwindow2; + + private global::Gtk.TreeView reagentListView; + + private global::Gtk.Label GtkLabel4; + + private global::Gtk.HSeparator hseparator6; + + private global::Gtk.ScrolledWindow GtkScrolledWindow1; + + private global::Gtk.TreeView recipeList; + + private global::Gtk.VBox vbox3; + + private global::Gtk.Frame frame2; + + private global::Gtk.ScrolledWindow GtkScrolledWindow; + + private global::Gtk.TreeView recipeIngredientsView; + + private global::Gtk.Label recipeLabel; + + private global::Gtk.Button button919; + + private global::DesertPaintLab.PaintSwatch paintSwatch; + + private global::Gtk.HBox hbox3; + + private global::Gtk.HSeparator hseparator2; + + private global::Gtk.Button stopResumeButton; + + private global::Gtk.Label countLabel; + + private global::Gtk.Button beginButton; + + private global::Gtk.HSeparator hseparator1; + + private global::Gtk.ProgressBar progressBar; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget DesertPaintLab.RecipeGeneratorView + Stetic.BinContainer w1 = global::Stetic.BinContainer.Attach (this); + this.UIManager = new global::Gtk.UIManager (); + global::Gtk.ActionGroup w2 = new global::Gtk.ActionGroup ("Default"); + this.UIManager.InsertActionGroup (w2, 0); + this.Name = "DesertPaintLab.RecipeGeneratorView"; + // Container child DesertPaintLab.RecipeGeneratorView.Gtk.Container+ContainerChild + this.vbox2 = new global::Gtk.VBox (); + this.vbox2.Name = "vbox2"; + this.vbox2.Spacing = 6; + this.vbox2.BorderWidth = ((uint)(8)); + // Container child vbox2.Gtk.Box+BoxChild + this.hbox1 = new global::Gtk.HBox (); + this.hbox1.Name = "hbox1"; + this.hbox1.Spacing = 6; + // Container child hbox1.Gtk.Box+BoxChild + this.vbox8 = new global::Gtk.VBox (); + this.vbox8.Name = "vbox8"; + this.vbox8.Spacing = 6; + // Container child vbox8.Gtk.Box+BoxChild + this.hbox2 = new global::Gtk.HBox (); + this.hbox2.Name = "hbox2"; + this.hbox2.Spacing = 6; + // Container child hbox2.Gtk.Box+BoxChild + this.minIngredientsSpinButton = new global::Gtk.SpinButton (1, 14, 1); + this.minIngredientsSpinButton.CanFocus = true; + this.minIngredientsSpinButton.Name = "minIngredientsSpinButton"; + this.minIngredientsSpinButton.Adjustment.PageIncrement = 10; + this.minIngredientsSpinButton.ClimbRate = 1; + this.minIngredientsSpinButton.Numeric = true; + this.minIngredientsSpinButton.Value = 1; + this.hbox2.Add (this.minIngredientsSpinButton); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.minIngredientsSpinButton])); + w3.Position = 0; + w3.Expand = false; + w3.Fill = false; + // Container child hbox2.Gtk.Box+BoxChild + this.label1 = new global::Gtk.Label (); + this.label1.Name = "label1"; + this.label1.LabelProp = "Minimum Ingredients"; + this.hbox2.Add (this.label1); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.label1])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + this.vbox8.Add (this.hbox2); + global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox2])); + w5.Position = 0; + w5.Expand = false; + w5.Fill = false; + // Container child vbox8.Gtk.Box+BoxChild + this.hbox7 = new global::Gtk.HBox (); + this.hbox7.Name = "hbox7"; + this.hbox7.Spacing = 6; + // Container child hbox7.Gtk.Box+BoxChild + this.maxIngredientsSpinButton = new global::Gtk.SpinButton (1, 14, 1); + this.maxIngredientsSpinButton.CanFocus = true; + this.maxIngredientsSpinButton.Name = "maxIngredientsSpinButton"; + this.maxIngredientsSpinButton.Adjustment.PageIncrement = 10; + this.maxIngredientsSpinButton.ClimbRate = 1; + this.maxIngredientsSpinButton.Numeric = true; + this.maxIngredientsSpinButton.Value = 5; + this.hbox7.Add (this.maxIngredientsSpinButton); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox7 [this.maxIngredientsSpinButton])); + w6.Position = 0; + w6.Expand = false; + w6.Fill = false; + // Container child hbox7.Gtk.Box+BoxChild + this.label3 = new global::Gtk.Label (); + this.label3.Name = "label3"; + this.label3.LabelProp = "Maximum Ingredients"; + this.hbox7.Add (this.label3); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox7 [this.label3])); + w7.Position = 1; + w7.Expand = false; + w7.Fill = false; + this.vbox8.Add (this.hbox7); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox7])); + w8.Position = 1; + w8.Expand = false; + w8.Fill = false; + // Container child vbox8.Gtk.Box+BoxChild + this.hseparator3 = new global::Gtk.HSeparator (); + this.hseparator3.Name = "hseparator3"; + this.vbox8.Add (this.hseparator3); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator3])); + w9.Position = 2; + w9.Expand = false; + w9.Fill = false; + // Container child vbox8.Gtk.Box+BoxChild + this.checkButtonRibbon = new global::Gtk.CheckButton (); + this.checkButtonRibbon.CanFocus = true; + this.checkButtonRibbon.Name = "checkButtonRibbon"; + this.checkButtonRibbon.Label = "Ribbon Recipes"; + this.checkButtonRibbon.DrawIndicator = true; + this.checkButtonRibbon.UseUnderline = true; + this.vbox8.Add (this.checkButtonRibbon); + global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.checkButtonRibbon])); + w10.Position = 3; + w10.Expand = false; + w10.Fill = false; + // Container child vbox8.Gtk.Box+BoxChild + this.hbox4 = new global::Gtk.HBox (); + this.hbox4.Name = "hbox4"; + this.hbox4.Spacing = 6; + // Container child hbox4.Gtk.Box+BoxChild + this.maxRecipeSpinButton = new global::Gtk.SpinButton (10, 100, 1); + this.maxRecipeSpinButton.CanFocus = true; + this.maxRecipeSpinButton.Name = "maxRecipeSpinButton"; + this.maxRecipeSpinButton.Adjustment.PageIncrement = 10; + this.maxRecipeSpinButton.ClimbRate = 1; + this.maxRecipeSpinButton.Numeric = true; + this.maxRecipeSpinButton.Value = 14; + this.hbox4.Add (this.maxRecipeSpinButton); + global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.maxRecipeSpinButton])); + w11.Position = 0; + w11.Expand = false; + w11.Fill = false; + // Container child hbox4.Gtk.Box+BoxChild + this.label4 = new global::Gtk.Label (); + this.label4.Name = "label4"; + this.label4.LabelProp = "Maximum Concentration"; + this.label4.UseMarkup = true; + this.label4.Wrap = true; + this.hbox4.Add (this.label4); + global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.label4])); + w12.Position = 1; + w12.Expand = false; + w12.Fill = false; + this.vbox8.Add (this.hbox4); + global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox4])); + w13.Position = 4; + w13.Expand = false; + w13.Fill = false; + // Container child vbox8.Gtk.Box+BoxChild + this.hseparator4 = new global::Gtk.HSeparator (); + this.hseparator4.Name = "hseparator4"; + this.vbox8.Add (this.hseparator4); + global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator4])); + w14.Position = 5; + w14.Expand = false; + w14.Fill = false; + w14.Padding = ((uint)(8)); + // Container child vbox8.Gtk.Box+BoxChild + this.hbox5 = new global::Gtk.HBox (); + this.hbox5.Name = "hbox5"; + this.hbox5.Spacing = 6; + // Container child hbox5.Gtk.Box+BoxChild + this.fullQuantityDepthSpinButton = new global::Gtk.SpinButton (0, 15, 1); + this.fullQuantityDepthSpinButton.CanFocus = true; + this.fullQuantityDepthSpinButton.Name = "fullQuantityDepthSpinButton"; + this.fullQuantityDepthSpinButton.Adjustment.PageIncrement = 10; + this.fullQuantityDepthSpinButton.ClimbRate = 1; + this.fullQuantityDepthSpinButton.Numeric = true; + this.fullQuantityDepthSpinButton.Value = 4; + this.hbox5.Add (this.fullQuantityDepthSpinButton); + global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.hbox5 [this.fullQuantityDepthSpinButton])); + w15.Position = 0; + w15.Expand = false; + w15.Fill = false; + // Container child hbox5.Gtk.Box+BoxChild + this.label8 = new global::Gtk.Label (); + this.label8.Name = "label8"; + this.label8.LabelProp = "Full Quantity Depth"; + this.hbox5.Add (this.label8); + global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.hbox5 [this.label8])); + w16.Position = 1; + w16.Expand = false; + w16.Fill = false; + this.vbox8.Add (this.hbox5); + global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox5])); + w17.Position = 6; + w17.Expand = false; + w17.Fill = false; + // Container child vbox8.Gtk.Box+BoxChild + this.hseparator5 = new global::Gtk.HSeparator (); + this.hseparator5.Name = "hseparator5"; + this.vbox8.Add (this.hseparator5); + global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator5])); + w18.Position = 7; + w18.Expand = false; + w18.Fill = false; + // Container child vbox8.Gtk.Box+BoxChild + this.hbox6 = new global::Gtk.HBox (); + this.hbox6.Name = "hbox6"; + this.hbox6.Spacing = 6; + // Container child hbox6.Gtk.Box+BoxChild + this.fullQuantitySpinButton = new global::Gtk.SpinButton (0, 30, 1); + this.fullQuantitySpinButton.CanFocus = true; + this.fullQuantitySpinButton.Name = "fullQuantitySpinButton"; + this.fullQuantitySpinButton.Adjustment.PageIncrement = 10; + this.fullQuantitySpinButton.ClimbRate = 1; + this.fullQuantitySpinButton.Numeric = true; + this.fullQuantitySpinButton.Value = 20; + this.hbox6.Add (this.fullQuantitySpinButton); + global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.fullQuantitySpinButton])); + w19.Position = 0; + w19.Expand = false; + w19.Fill = false; + // Container child hbox6.Gtk.Box+BoxChild + this.label9 = new global::Gtk.Label (); + this.label9.Name = "label9"; + this.label9.LabelProp = "FullQuantity"; + this.hbox6.Add (this.label9); + global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.label9])); + w20.Position = 1; + w20.Expand = false; + w20.Fill = false; + this.vbox8.Add (this.hbox6); + global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox6])); + w21.Position = 8; + w21.Expand = false; + w21.Fill = false; + // Container child vbox8.Gtk.Box+BoxChild + this.frame3 = new global::Gtk.Frame (); + this.frame3.Name = "frame3"; + this.frame3.ShadowType = ((global::Gtk.ShadowType)(0)); + // Container child frame3.Gtk.Container+ContainerChild + this.GtkAlignment1 = new global::Gtk.Alignment (0F, 0F, 1F, 1F); + this.GtkAlignment1.Name = "GtkAlignment1"; + this.GtkAlignment1.LeftPadding = ((uint)(12)); + // Container child GtkAlignment1.Gtk.Container+ContainerChild + this.scrolledwindow2 = new global::Gtk.ScrolledWindow (); + this.scrolledwindow2.CanFocus = true; + this.scrolledwindow2.Name = "scrolledwindow2"; + this.scrolledwindow2.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledwindow2.Gtk.Container+ContainerChild + this.reagentListView = new global::Gtk.TreeView (); + this.reagentListView.WidthRequest = 300; + this.reagentListView.CanFocus = true; + this.reagentListView.Name = "reagentListView"; + this.scrolledwindow2.Add (this.reagentListView); + this.GtkAlignment1.Add (this.scrolledwindow2); + this.frame3.Add (this.GtkAlignment1); + this.GtkLabel4 = new global::Gtk.Label (); + this.GtkLabel4.Name = "GtkLabel4"; + this.GtkLabel4.LabelProp = "Ingredients"; + this.GtkLabel4.UseMarkup = true; + this.frame3.LabelWidget = this.GtkLabel4; + this.vbox8.Add (this.frame3); + global::Gtk.Box.BoxChild w25 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.frame3])); + w25.PackType = ((global::Gtk.PackType)(1)); + w25.Position = 9; + // Container child vbox8.Gtk.Box+BoxChild + this.hseparator6 = new global::Gtk.HSeparator (); + this.hseparator6.Name = "hseparator6"; + this.vbox8.Add (this.hseparator6); + global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator6])); + w26.PackType = ((global::Gtk.PackType)(1)); + w26.Position = 10; + w26.Expand = false; + w26.Fill = false; + this.hbox1.Add (this.vbox8); + global::Gtk.Box.BoxChild w27 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox8])); + w27.Position = 0; + w27.Expand = false; + w27.Fill = false; + // Container child hbox1.Gtk.Box+BoxChild + this.GtkScrolledWindow1 = new global::Gtk.ScrolledWindow (); + this.GtkScrolledWindow1.Name = "GtkScrolledWindow1"; + this.GtkScrolledWindow1.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child GtkScrolledWindow1.Gtk.Container+ContainerChild + this.recipeList = new global::Gtk.TreeView (); + this.recipeList.WidthRequest = 300; + this.recipeList.CanFocus = true; + this.recipeList.Name = "recipeList"; + this.GtkScrolledWindow1.Add (this.recipeList); + this.hbox1.Add (this.GtkScrolledWindow1); + global::Gtk.Box.BoxChild w29 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.GtkScrolledWindow1])); + w29.Position = 1; + // Container child hbox1.Gtk.Box+BoxChild + this.vbox3 = new global::Gtk.VBox (); + this.vbox3.Name = "vbox3"; + this.vbox3.Spacing = 6; + // Container child vbox3.Gtk.Box+BoxChild + this.frame2 = new global::Gtk.Frame (); + this.frame2.WidthRequest = 200; + this.frame2.HeightRequest = 200; + this.frame2.Name = "frame2"; + this.frame2.ShadowType = ((global::Gtk.ShadowType)(0)); + // Container child frame2.Gtk.Container+ContainerChild + this.GtkScrolledWindow = new global::Gtk.ScrolledWindow (); + this.GtkScrolledWindow.Name = "GtkScrolledWindow"; + this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child GtkScrolledWindow.Gtk.Container+ContainerChild + this.recipeIngredientsView = new global::Gtk.TreeView (); + this.recipeIngredientsView.CanFocus = true; + this.recipeIngredientsView.Name = "recipeIngredientsView"; + this.GtkScrolledWindow.Add (this.recipeIngredientsView); + this.frame2.Add (this.GtkScrolledWindow); + this.recipeLabel = new global::Gtk.Label (); + this.recipeLabel.Name = "recipeLabel"; + this.recipeLabel.LabelProp = "Recipe"; + this.recipeLabel.UseMarkup = true; + this.frame2.LabelWidget = this.recipeLabel; + this.vbox3.Add (this.frame2); + global::Gtk.Box.BoxChild w32 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.frame2])); + w32.Position = 0; + // Container child vbox3.Gtk.Box+BoxChild + this.button919 = new global::Gtk.Button (); + this.button919.CanFocus = true; + this.button919.Name = "button919"; + this.button919.UseUnderline = true; + this.button919.Label = "Copy"; + this.vbox3.Add (this.button919); + global::Gtk.Box.BoxChild w33 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.button919])); + w33.Position = 1; + w33.Expand = false; + w33.Fill = false; + // Container child vbox3.Gtk.Box+BoxChild + this.paintSwatch = new global::DesertPaintLab.PaintSwatch (); + this.paintSwatch.HeightRequest = 200; + this.paintSwatch.Events = ((global::Gdk.EventMask)(256)); + this.paintSwatch.Name = "paintSwatch"; + this.vbox3.Add (this.paintSwatch); + global::Gtk.Box.BoxChild w34 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.paintSwatch])); + w34.Position = 2; + this.hbox1.Add (this.vbox3); + global::Gtk.Box.BoxChild w35 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox3])); + w35.Position = 2; + w35.Expand = false; + w35.Fill = false; + this.vbox2.Add (this.hbox1); + global::Gtk.Box.BoxChild w36 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1])); + w36.Position = 0; + // Container child vbox2.Gtk.Box+BoxChild + this.hbox3 = new global::Gtk.HBox (); + this.hbox3.Name = "hbox3"; + this.hbox3.Spacing = 6; + // Container child hbox3.Gtk.Box+BoxChild + this.hseparator2 = new global::Gtk.HSeparator (); + this.hseparator2.Name = "hseparator2"; + this.hbox3.Add (this.hseparator2); + global::Gtk.Box.BoxChild w37 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.hseparator2])); + w37.Position = 0; + // Container child hbox3.Gtk.Box+BoxChild + this.stopResumeButton = new global::Gtk.Button (); + this.stopResumeButton.Sensitive = false; + this.stopResumeButton.CanFocus = true; + this.stopResumeButton.Name = "stopResumeButton"; + this.stopResumeButton.UseUnderline = true; + this.stopResumeButton.Label = "Stop"; + this.hbox3.Add (this.stopResumeButton); + global::Gtk.Box.BoxChild w38 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.stopResumeButton])); + w38.Position = 1; + w38.Expand = false; + w38.Fill = false; + w38.Padding = ((uint)(20)); + // Container child hbox3.Gtk.Box+BoxChild + this.countLabel = new global::Gtk.Label (); + this.countLabel.Name = "countLabel"; + this.countLabel.LabelProp = "0/192"; + this.hbox3.Add (this.countLabel); + global::Gtk.Box.BoxChild w39 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.countLabel])); + w39.Position = 2; + w39.Expand = false; + w39.Fill = false; + w39.Padding = ((uint)(40)); + // Container child hbox3.Gtk.Box+BoxChild + this.beginButton = new global::Gtk.Button (); + this.beginButton.CanFocus = true; + this.beginButton.Name = "beginButton"; + this.beginButton.UseUnderline = true; + this.beginButton.Label = "Begin"; + this.hbox3.Add (this.beginButton); + global::Gtk.Box.BoxChild w40 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.beginButton])); + w40.Position = 3; + w40.Expand = false; + w40.Fill = false; + w40.Padding = ((uint)(20)); + // Container child hbox3.Gtk.Box+BoxChild + this.hseparator1 = new global::Gtk.HSeparator (); + this.hseparator1.Name = "hseparator1"; + this.hbox3.Add (this.hseparator1); + global::Gtk.Box.BoxChild w41 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.hseparator1])); + w41.Position = 4; + this.vbox2.Add (this.hbox3); + global::Gtk.Box.BoxChild w42 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox3])); + w42.Position = 1; + w42.Expand = false; + w42.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.progressBar = new global::Gtk.ProgressBar (); + this.progressBar.Name = "progressBar"; + this.vbox2.Add (this.progressBar); + global::Gtk.Box.BoxChild w43 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.progressBar])); + w43.PackType = ((global::Gtk.PackType)(1)); + w43.Position = 2; + w43.Expand = false; + w43.Fill = false; + this.Add (this.vbox2); + if ((this.Child != null)) { + this.Child.ShowAll (); + } + w1.SetUiManager (UIManager); + this.Hide (); + this.minIngredientsSpinButton.ValueChanged += new global::System.EventHandler (this.OnMinIngredientsChanged); + this.maxIngredientsSpinButton.ValueChanged += new global::System.EventHandler (this.OnMaxIngredientsChanged); + this.checkButtonRibbon.Toggled += new global::System.EventHandler (this.OnRecipesToggled); + this.maxRecipeSpinButton.ValueChanged += new global::System.EventHandler (this.OnMaxRecipeChanged); + this.fullQuantityDepthSpinButton.ValueChanged += new global::System.EventHandler (this.OnFullQuantityDepthChanged); + this.fullQuantitySpinButton.ValueChanged += new global::System.EventHandler (this.OnFullQuantityChanged); + this.button919.Clicked += new global::System.EventHandler (this.OnCopyRecipeToClipboard); + this.stopResumeButton.Clicked += new global::System.EventHandler (this.OnStopResume); + this.beginButton.Clicked += new global::System.EventHandler (this.OnBegin); + } + } +} diff --git a/gtk-gui/DesertPaintLab.RecipeGeneratorWindow.cs b/gtk-gui/DesertPaintLab.RecipeGeneratorWindow.cs deleted file mode 100644 --- a/gtk-gui/DesertPaintLab.RecipeGeneratorWindow.cs +++ /dev/null @@ -1,545 +0,0 @@ - -// This file has been generated by the GUI designer. Do not modify. -namespace DesertPaintLab -{ - public partial class RecipeGeneratorWindow - { - private global::Gtk.UIManager UIManager; - - private global::Gtk.Action ExportAction; - - private global::Gtk.Action ExportToWikiAction; - - private global::Gtk.Action SettingsAction; - - private global::Gtk.Action IngredientsAction; - - private global::Gtk.Action CopyToClipboardAction; - - private global::Gtk.VBox vbox2; - - private global::Gtk.MenuBar menubar1; - - private global::Gtk.HBox hbox1; - - private global::Gtk.VBox vbox8; - - private global::Gtk.HBox hbox2; - - private global::Gtk.SpinButton minIngredientsSpinButton; - - private global::Gtk.Label label1; - - private global::Gtk.HBox hbox7; - - private global::Gtk.SpinButton maxIngredientsSpinButton; - - private global::Gtk.Label label3; - - private global::Gtk.HSeparator hseparator3; - - private global::Gtk.HBox hbox4; - - private global::Gtk.SpinButton maxRecipeSpinButton; - - private global::Gtk.Label label4; - - private global::Gtk.HSeparator hseparator4; - - private global::Gtk.HBox hbox5; - - private global::Gtk.SpinButton fullQuantityDepthSpinButton; - - private global::Gtk.Label label8; - - private global::Gtk.HSeparator hseparator5; - - private global::Gtk.HBox hbox6; - - private global::Gtk.SpinButton fullQuantitySpinButton; - - private global::Gtk.Label label9; - - private global::Gtk.Frame frame3; - - private global::Gtk.Alignment GtkAlignment1; - - private global::Gtk.ScrolledWindow scrolledwindow2; - - private global::Gtk.TreeView reagentListView; - - private global::Gtk.Label GtkLabel4; - - private global::Gtk.HSeparator hseparator6; - - private global::Gtk.ScrolledWindow GtkScrolledWindow1; - - private global::Gtk.TreeView recipeList; - - private global::Gtk.VBox vbox3; - - private global::Gtk.Frame frame2; - - private global::Gtk.ScrolledWindow GtkScrolledWindow; - - private global::Gtk.TreeView recipeIngredientsView; - - private global::Gtk.Label recipeLabel; - - private global::Gtk.Button button919; - - private global::DesertPaintLab.PaintSwatch paintSwatch; - - private global::Gtk.HBox hbox3; - - private global::Gtk.HSeparator hseparator2; - - private global::Gtk.Button stopResumeButton; - - private global::Gtk.Label countLabel; - - private global::Gtk.Button beginButton; - - private global::Gtk.HSeparator hseparator1; - - private global::Gtk.Label statusLabel; - - private global::Gtk.ProgressBar progressBar; - - protected virtual void Build () - { - global::Stetic.Gui.Initialize (this); - // Widget DesertPaintLab.RecipeGeneratorWindow - this.UIManager = new global::Gtk.UIManager (); - global::Gtk.ActionGroup w1 = new global::Gtk.ActionGroup ("Default"); - this.ExportAction = new global::Gtk.Action ("ExportAction", "Export", null, null); - this.ExportAction.ShortLabel = "Export"; - w1.Add (this.ExportAction, null); - this.ExportToWikiAction = new global::Gtk.Action ("ExportToWikiAction", "Export to Wiki", null, null); - this.ExportToWikiAction.ShortLabel = "Export to Wiki"; - w1.Add (this.ExportToWikiAction, null); - this.SettingsAction = new global::Gtk.Action ("SettingsAction", "Settings", null, null); - this.SettingsAction.ShortLabel = "Tools"; - w1.Add (this.SettingsAction, null); - this.IngredientsAction = new global::Gtk.Action ("IngredientsAction", "Ingredients", null, null); - this.IngredientsAction.ShortLabel = "Ingredients"; - w1.Add (this.IngredientsAction, null); - this.CopyToClipboardAction = new global::Gtk.Action ("CopyToClipboardAction", "Copy to Clipboard", null, null); - this.CopyToClipboardAction.ShortLabel = "Copy to Clipboard"; - w1.Add (this.CopyToClipboardAction, null); - this.UIManager.InsertActionGroup (w1, 0); - this.AddAccelGroup (this.UIManager.AccelGroup); - this.Name = "DesertPaintLab.RecipeGeneratorWindow"; - this.Title = "Recipe Generator"; - this.WindowPosition = ((global::Gtk.WindowPosition)(4)); - // Container child DesertPaintLab.RecipeGeneratorWindow.Gtk.Container+ContainerChild - this.vbox2 = new global::Gtk.VBox (); - this.vbox2.Name = "vbox2"; - this.vbox2.Spacing = 6; - this.vbox2.BorderWidth = ((uint)(8)); - // Container child vbox2.Gtk.Box+BoxChild - this.UIManager.AddUiFromString (""); - this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar1"))); - this.menubar1.Name = "menubar1"; - this.vbox2.Add (this.menubar1); - global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.menubar1])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.hbox1 = new global::Gtk.HBox (); - this.hbox1.Name = "hbox1"; - this.hbox1.Spacing = 6; - // Container child hbox1.Gtk.Box+BoxChild - this.vbox8 = new global::Gtk.VBox (); - this.vbox8.Name = "vbox8"; - this.vbox8.Spacing = 6; - // Container child vbox8.Gtk.Box+BoxChild - this.hbox2 = new global::Gtk.HBox (); - this.hbox2.Name = "hbox2"; - this.hbox2.Spacing = 6; - // Container child hbox2.Gtk.Box+BoxChild - this.minIngredientsSpinButton = new global::Gtk.SpinButton (1, 14, 1); - this.minIngredientsSpinButton.CanFocus = true; - this.minIngredientsSpinButton.Name = "minIngredientsSpinButton"; - this.minIngredientsSpinButton.Adjustment.PageIncrement = 10; - this.minIngredientsSpinButton.ClimbRate = 1; - this.minIngredientsSpinButton.Numeric = true; - this.minIngredientsSpinButton.Value = 1; - this.hbox2.Add (this.minIngredientsSpinButton); - global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.minIngredientsSpinButton])); - w3.Position = 0; - w3.Expand = false; - w3.Fill = false; - // Container child hbox2.Gtk.Box+BoxChild - this.label1 = new global::Gtk.Label (); - this.label1.Name = "label1"; - this.label1.LabelProp = "Minimum Ingredients"; - this.hbox2.Add (this.label1); - global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.label1])); - w4.Position = 1; - w4.Expand = false; - w4.Fill = false; - this.vbox8.Add (this.hbox2); - global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox2])); - w5.Position = 0; - w5.Expand = false; - w5.Fill = false; - // Container child vbox8.Gtk.Box+BoxChild - this.hbox7 = new global::Gtk.HBox (); - this.hbox7.Name = "hbox7"; - this.hbox7.Spacing = 6; - // Container child hbox7.Gtk.Box+BoxChild - this.maxIngredientsSpinButton = new global::Gtk.SpinButton (1, 14, 1); - this.maxIngredientsSpinButton.CanFocus = true; - this.maxIngredientsSpinButton.Name = "maxIngredientsSpinButton"; - this.maxIngredientsSpinButton.Adjustment.PageIncrement = 10; - this.maxIngredientsSpinButton.ClimbRate = 1; - this.maxIngredientsSpinButton.Numeric = true; - this.maxIngredientsSpinButton.Value = 5; - this.hbox7.Add (this.maxIngredientsSpinButton); - global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox7 [this.maxIngredientsSpinButton])); - w6.Position = 0; - w6.Expand = false; - w6.Fill = false; - // Container child hbox7.Gtk.Box+BoxChild - this.label3 = new global::Gtk.Label (); - this.label3.Name = "label3"; - this.label3.LabelProp = "Maximum Ingredients"; - this.hbox7.Add (this.label3); - global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox7 [this.label3])); - w7.Position = 1; - w7.Expand = false; - w7.Fill = false; - this.vbox8.Add (this.hbox7); - global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox7])); - w8.Position = 1; - w8.Expand = false; - w8.Fill = false; - // Container child vbox8.Gtk.Box+BoxChild - this.hseparator3 = new global::Gtk.HSeparator (); - this.hseparator3.Name = "hseparator3"; - this.vbox8.Add (this.hseparator3); - global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator3])); - w9.Position = 2; - w9.Expand = false; - w9.Fill = false; - // Container child vbox8.Gtk.Box+BoxChild - this.hbox4 = new global::Gtk.HBox (); - this.hbox4.Name = "hbox4"; - this.hbox4.Spacing = 6; - // Container child hbox4.Gtk.Box+BoxChild - this.maxRecipeSpinButton = new global::Gtk.SpinButton (10, 100, 1); - this.maxRecipeSpinButton.CanFocus = true; - this.maxRecipeSpinButton.Name = "maxRecipeSpinButton"; - this.maxRecipeSpinButton.Adjustment.PageIncrement = 10; - this.maxRecipeSpinButton.ClimbRate = 1; - this.maxRecipeSpinButton.Numeric = true; - this.maxRecipeSpinButton.Value = 14; - this.hbox4.Add (this.maxRecipeSpinButton); - global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.maxRecipeSpinButton])); - w10.Position = 0; - w10.Expand = false; - w10.Fill = false; - // Container child hbox4.Gtk.Box+BoxChild - this.label4 = new global::Gtk.Label (); - this.label4.Name = "label4"; - this.label4.LabelProp = "Max Total Quantity"; - this.label4.UseMarkup = true; - this.label4.Wrap = true; - this.hbox4.Add (this.label4); - global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.label4])); - w11.Position = 1; - w11.Expand = false; - w11.Fill = false; - this.vbox8.Add (this.hbox4); - global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox4])); - w12.Position = 3; - w12.Expand = false; - w12.Fill = false; - // Container child vbox8.Gtk.Box+BoxChild - this.hseparator4 = new global::Gtk.HSeparator (); - this.hseparator4.Name = "hseparator4"; - this.vbox8.Add (this.hseparator4); - global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator4])); - w13.Position = 4; - w13.Expand = false; - w13.Fill = false; - w13.Padding = ((uint)(8)); - // Container child vbox8.Gtk.Box+BoxChild - this.hbox5 = new global::Gtk.HBox (); - this.hbox5.Name = "hbox5"; - this.hbox5.Spacing = 6; - // Container child hbox5.Gtk.Box+BoxChild - this.fullQuantityDepthSpinButton = new global::Gtk.SpinButton (0, 15, 1); - this.fullQuantityDepthSpinButton.CanFocus = true; - this.fullQuantityDepthSpinButton.Name = "fullQuantityDepthSpinButton"; - this.fullQuantityDepthSpinButton.Adjustment.PageIncrement = 10; - this.fullQuantityDepthSpinButton.ClimbRate = 1; - this.fullQuantityDepthSpinButton.Numeric = true; - this.fullQuantityDepthSpinButton.Value = 4; - this.hbox5.Add (this.fullQuantityDepthSpinButton); - global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.hbox5 [this.fullQuantityDepthSpinButton])); - w14.Position = 0; - w14.Expand = false; - w14.Fill = false; - // Container child hbox5.Gtk.Box+BoxChild - this.label8 = new global::Gtk.Label (); - this.label8.Name = "label8"; - this.label8.LabelProp = "Full Quantity Depth"; - this.hbox5.Add (this.label8); - global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.hbox5 [this.label8])); - w15.Position = 1; - w15.Expand = false; - w15.Fill = false; - this.vbox8.Add (this.hbox5); - global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox5])); - w16.Position = 5; - w16.Expand = false; - w16.Fill = false; - // Container child vbox8.Gtk.Box+BoxChild - this.hseparator5 = new global::Gtk.HSeparator (); - this.hseparator5.Name = "hseparator5"; - this.vbox8.Add (this.hseparator5); - global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator5])); - w17.Position = 6; - w17.Expand = false; - w17.Fill = false; - // Container child vbox8.Gtk.Box+BoxChild - this.hbox6 = new global::Gtk.HBox (); - this.hbox6.Name = "hbox6"; - this.hbox6.Spacing = 6; - // Container child hbox6.Gtk.Box+BoxChild - this.fullQuantitySpinButton = new global::Gtk.SpinButton (0, 30, 1); - this.fullQuantitySpinButton.CanFocus = true; - this.fullQuantitySpinButton.Name = "fullQuantitySpinButton"; - this.fullQuantitySpinButton.Adjustment.PageIncrement = 10; - this.fullQuantitySpinButton.ClimbRate = 1; - this.fullQuantitySpinButton.Numeric = true; - this.fullQuantitySpinButton.Value = 20; - this.hbox6.Add (this.fullQuantitySpinButton); - global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.fullQuantitySpinButton])); - w18.Position = 0; - w18.Expand = false; - w18.Fill = false; - // Container child hbox6.Gtk.Box+BoxChild - this.label9 = new global::Gtk.Label (); - this.label9.Name = "label9"; - this.label9.LabelProp = "FullQuantity"; - this.hbox6.Add (this.label9); - global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.label9])); - w19.Position = 1; - w19.Expand = false; - w19.Fill = false; - this.vbox8.Add (this.hbox6); - global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox6])); - w20.Position = 7; - w20.Expand = false; - w20.Fill = false; - // Container child vbox8.Gtk.Box+BoxChild - this.frame3 = new global::Gtk.Frame (); - this.frame3.Name = "frame3"; - this.frame3.ShadowType = ((global::Gtk.ShadowType)(0)); - // Container child frame3.Gtk.Container+ContainerChild - this.GtkAlignment1 = new global::Gtk.Alignment (0F, 0F, 1F, 1F); - this.GtkAlignment1.Name = "GtkAlignment1"; - this.GtkAlignment1.LeftPadding = ((uint)(12)); - // Container child GtkAlignment1.Gtk.Container+ContainerChild - this.scrolledwindow2 = new global::Gtk.ScrolledWindow (); - this.scrolledwindow2.CanFocus = true; - this.scrolledwindow2.Name = "scrolledwindow2"; - this.scrolledwindow2.ShadowType = ((global::Gtk.ShadowType)(1)); - // Container child scrolledwindow2.Gtk.Container+ContainerChild - this.reagentListView = new global::Gtk.TreeView (); - this.reagentListView.WidthRequest = 300; - this.reagentListView.CanFocus = true; - this.reagentListView.Name = "reagentListView"; - this.scrolledwindow2.Add (this.reagentListView); - this.GtkAlignment1.Add (this.scrolledwindow2); - this.frame3.Add (this.GtkAlignment1); - this.GtkLabel4 = new global::Gtk.Label (); - this.GtkLabel4.Name = "GtkLabel4"; - this.GtkLabel4.LabelProp = "Ingredients"; - this.GtkLabel4.UseMarkup = true; - this.frame3.LabelWidget = this.GtkLabel4; - this.vbox8.Add (this.frame3); - global::Gtk.Box.BoxChild w24 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.frame3])); - w24.PackType = ((global::Gtk.PackType)(1)); - w24.Position = 8; - // Container child vbox8.Gtk.Box+BoxChild - this.hseparator6 = new global::Gtk.HSeparator (); - this.hseparator6.Name = "hseparator6"; - this.vbox8.Add (this.hseparator6); - global::Gtk.Box.BoxChild w25 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator6])); - w25.PackType = ((global::Gtk.PackType)(1)); - w25.Position = 9; - w25.Expand = false; - w25.Fill = false; - this.hbox1.Add (this.vbox8); - global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox8])); - w26.Position = 0; - w26.Expand = false; - w26.Fill = false; - // Container child hbox1.Gtk.Box+BoxChild - this.GtkScrolledWindow1 = new global::Gtk.ScrolledWindow (); - this.GtkScrolledWindow1.Name = "GtkScrolledWindow1"; - this.GtkScrolledWindow1.ShadowType = ((global::Gtk.ShadowType)(1)); - // Container child GtkScrolledWindow1.Gtk.Container+ContainerChild - this.recipeList = new global::Gtk.TreeView (); - this.recipeList.WidthRequest = 300; - this.recipeList.CanFocus = true; - this.recipeList.Name = "recipeList"; - this.GtkScrolledWindow1.Add (this.recipeList); - this.hbox1.Add (this.GtkScrolledWindow1); - global::Gtk.Box.BoxChild w28 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.GtkScrolledWindow1])); - w28.Position = 1; - // Container child hbox1.Gtk.Box+BoxChild - this.vbox3 = new global::Gtk.VBox (); - this.vbox3.Name = "vbox3"; - this.vbox3.Spacing = 6; - // Container child vbox3.Gtk.Box+BoxChild - this.frame2 = new global::Gtk.Frame (); - this.frame2.WidthRequest = 200; - this.frame2.HeightRequest = 200; - this.frame2.Name = "frame2"; - this.frame2.ShadowType = ((global::Gtk.ShadowType)(0)); - // Container child frame2.Gtk.Container+ContainerChild - this.GtkScrolledWindow = new global::Gtk.ScrolledWindow (); - this.GtkScrolledWindow.Name = "GtkScrolledWindow"; - this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1)); - // Container child GtkScrolledWindow.Gtk.Container+ContainerChild - this.recipeIngredientsView = new global::Gtk.TreeView (); - this.recipeIngredientsView.CanFocus = true; - this.recipeIngredientsView.Name = "recipeIngredientsView"; - this.GtkScrolledWindow.Add (this.recipeIngredientsView); - this.frame2.Add (this.GtkScrolledWindow); - this.recipeLabel = new global::Gtk.Label (); - this.recipeLabel.Name = "recipeLabel"; - this.recipeLabel.LabelProp = "Recipe"; - this.recipeLabel.UseMarkup = true; - this.frame2.LabelWidget = this.recipeLabel; - this.vbox3.Add (this.frame2); - global::Gtk.Box.BoxChild w31 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.frame2])); - w31.Position = 0; - // Container child vbox3.Gtk.Box+BoxChild - this.button919 = new global::Gtk.Button (); - this.button919.CanFocus = true; - this.button919.Name = "button919"; - this.button919.UseUnderline = true; - this.button919.Label = "Copy"; - this.vbox3.Add (this.button919); - global::Gtk.Box.BoxChild w32 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.button919])); - w32.Position = 1; - w32.Expand = false; - w32.Fill = false; - // Container child vbox3.Gtk.Box+BoxChild - this.paintSwatch = new global::DesertPaintLab.PaintSwatch (); - this.paintSwatch.HeightRequest = 200; - this.paintSwatch.Events = ((global::Gdk.EventMask)(256)); - this.paintSwatch.Name = "paintSwatch"; - this.vbox3.Add (this.paintSwatch); - global::Gtk.Box.BoxChild w33 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.paintSwatch])); - w33.Position = 2; - this.hbox1.Add (this.vbox3); - global::Gtk.Box.BoxChild w34 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox3])); - w34.Position = 2; - w34.Expand = false; - w34.Fill = false; - this.vbox2.Add (this.hbox1); - global::Gtk.Box.BoxChild w35 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1])); - w35.Position = 1; - // Container child vbox2.Gtk.Box+BoxChild - this.hbox3 = new global::Gtk.HBox (); - this.hbox3.Name = "hbox3"; - this.hbox3.Spacing = 6; - // Container child hbox3.Gtk.Box+BoxChild - this.hseparator2 = new global::Gtk.HSeparator (); - this.hseparator2.Name = "hseparator2"; - this.hbox3.Add (this.hseparator2); - global::Gtk.Box.BoxChild w36 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.hseparator2])); - w36.Position = 0; - // Container child hbox3.Gtk.Box+BoxChild - this.stopResumeButton = new global::Gtk.Button (); - this.stopResumeButton.Sensitive = false; - this.stopResumeButton.CanFocus = true; - this.stopResumeButton.Name = "stopResumeButton"; - this.stopResumeButton.UseUnderline = true; - this.stopResumeButton.Label = "Stop"; - this.hbox3.Add (this.stopResumeButton); - global::Gtk.Box.BoxChild w37 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.stopResumeButton])); - w37.Position = 1; - w37.Expand = false; - w37.Fill = false; - w37.Padding = ((uint)(20)); - // Container child hbox3.Gtk.Box+BoxChild - this.countLabel = new global::Gtk.Label (); - this.countLabel.Name = "countLabel"; - this.countLabel.LabelProp = "0/192"; - this.hbox3.Add (this.countLabel); - global::Gtk.Box.BoxChild w38 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.countLabel])); - w38.Position = 2; - w38.Expand = false; - w38.Fill = false; - w38.Padding = ((uint)(40)); - // Container child hbox3.Gtk.Box+BoxChild - this.beginButton = new global::Gtk.Button (); - this.beginButton.CanFocus = true; - this.beginButton.Name = "beginButton"; - this.beginButton.UseUnderline = true; - this.beginButton.Label = "Begin"; - this.hbox3.Add (this.beginButton); - global::Gtk.Box.BoxChild w39 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.beginButton])); - w39.Position = 3; - w39.Expand = false; - w39.Fill = false; - w39.Padding = ((uint)(20)); - // Container child hbox3.Gtk.Box+BoxChild - this.hseparator1 = new global::Gtk.HSeparator (); - this.hseparator1.Name = "hseparator1"; - this.hbox3.Add (this.hseparator1); - global::Gtk.Box.BoxChild w40 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.hseparator1])); - w40.Position = 4; - this.vbox2.Add (this.hbox3); - global::Gtk.Box.BoxChild w41 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox3])); - w41.Position = 2; - w41.Expand = false; - w41.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.statusLabel = new global::Gtk.Label (); - this.statusLabel.Name = "statusLabel"; - this.vbox2.Add (this.statusLabel); - global::Gtk.Box.BoxChild w42 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.statusLabel])); - w42.PackType = ((global::Gtk.PackType)(1)); - w42.Position = 3; - w42.Expand = false; - w42.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.progressBar = new global::Gtk.ProgressBar (); - this.progressBar.Name = "progressBar"; - this.vbox2.Add (this.progressBar); - global::Gtk.Box.BoxChild w43 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.progressBar])); - w43.PackType = ((global::Gtk.PackType)(1)); - w43.Position = 4; - w43.Expand = false; - w43.Fill = false; - this.Add (this.vbox2); - if ((this.Child != null)) { - this.Child.ShowAll (); - } - this.DefaultWidth = 887; - this.DefaultHeight = 577; - this.Show (); - this.ExportToWikiAction.Activated += new global::System.EventHandler (this.OnExportToWiki); - this.IngredientsAction.Activated += new global::System.EventHandler (this.OnShowIngredients); - this.CopyToClipboardAction.Activated += new global::System.EventHandler (this.OnCopyRecipeListToClipboard); - this.minIngredientsSpinButton.ValueChanged += new global::System.EventHandler (this.OnMinIngredientsChanged); - this.maxIngredientsSpinButton.ValueChanged += new global::System.EventHandler (this.OnMaxIngredientsChanged); - this.maxRecipeSpinButton.ValueChanged += new global::System.EventHandler (this.OnMaxRecipeChanged); - this.fullQuantityDepthSpinButton.ValueChanged += new global::System.EventHandler (this.OnFullQuantityDepthChanged); - this.fullQuantitySpinButton.ValueChanged += new global::System.EventHandler (this.OnFullQuantityChanged); - this.button919.Clicked += new global::System.EventHandler (this.OnCopyRecipeToClipboard); - this.stopResumeButton.Clicked += new global::System.EventHandler (this.OnStopResume); - this.beginButton.Clicked += new global::System.EventHandler (this.OnBegin); - } - } -} diff --git a/gtk-gui/DesertPaintLab.SimulatorView.cs b/gtk-gui/DesertPaintLab.SimulatorView.cs new file mode 100644 --- /dev/null +++ b/gtk-gui/DesertPaintLab.SimulatorView.cs @@ -0,0 +1,201 @@ + +// This file has been generated by the GUI designer. Do not modify. +namespace DesertPaintLab +{ + public partial class SimulatorView + { + private global::Gtk.HBox hbox1; + + private global::Gtk.ScrolledWindow GtkScrolledWindow; + + private global::Gtk.TreeView reagentListView; + + private global::Gtk.VBox vbox162; + + private global::Gtk.Alignment alignment1; + + private global::Gtk.Button addReagentButton; + + private global::Gtk.Image addReagentButtonImage; + + private global::Gtk.Alignment alignment3; + + private global::Gtk.ScrolledWindow GtkScrolledWindow1; + + private global::Gtk.TreeView recipeView; + + private global::Gtk.VBox vbox3; + + private global::Gtk.Alignment alignment2; + + private global::Gtk.Button button65; + + private global::Gtk.Image image1; + + private global::Gtk.Button button66; + + private global::Gtk.Image image2; + + private global::Gtk.Button button67; + + private global::Gtk.Image image3; + + private global::Gtk.Alignment alignment4; + + private global::DesertPaintLab.PaintSwatch paintSwatch; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget DesertPaintLab.SimulatorView + global::Stetic.BinContainer.Attach (this); + this.Name = "DesertPaintLab.SimulatorView"; + // Container child DesertPaintLab.SimulatorView.Gtk.Container+ContainerChild + this.hbox1 = new global::Gtk.HBox (); + this.hbox1.Name = "hbox1"; + this.hbox1.Spacing = 6; + this.hbox1.BorderWidth = ((uint)(12)); + // Container child hbox1.Gtk.Box+BoxChild + this.GtkScrolledWindow = new global::Gtk.ScrolledWindow (); + this.GtkScrolledWindow.Name = "GtkScrolledWindow"; + this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child GtkScrolledWindow.Gtk.Container+ContainerChild + this.reagentListView = new global::Gtk.TreeView (); + this.reagentListView.CanFocus = true; + this.reagentListView.Name = "reagentListView"; + this.GtkScrolledWindow.Add (this.reagentListView); + this.hbox1.Add (this.GtkScrolledWindow); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.GtkScrolledWindow])); + w2.Position = 0; + // Container child hbox1.Gtk.Box+BoxChild + this.vbox162 = new global::Gtk.VBox (); + this.vbox162.Name = "vbox162"; + this.vbox162.Spacing = 6; + // Container child vbox162.Gtk.Box+BoxChild + this.alignment1 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); + this.alignment1.Name = "alignment1"; + this.vbox162.Add (this.alignment1); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox162 [this.alignment1])); + w3.Position = 0; + // Container child vbox162.Gtk.Box+BoxChild + this.addReagentButton = new global::Gtk.Button (); + this.addReagentButton.CanFocus = true; + this.addReagentButton.Name = "addReagentButton"; + // Container child addReagentButton.Gtk.Container+ContainerChild + this.addReagentButtonImage = new global::Gtk.Image (); + this.addReagentButtonImage.Name = "addReagentButtonImage"; + this.addReagentButtonImage.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-go-forward", global::Gtk.IconSize.Menu); + this.addReagentButton.Add (this.addReagentButtonImage); + this.vbox162.Add (this.addReagentButton); + global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox162 [this.addReagentButton])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; + // Container child vbox162.Gtk.Box+BoxChild + this.alignment3 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); + this.alignment3.Name = "alignment3"; + this.vbox162.Add (this.alignment3); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox162 [this.alignment3])); + w6.Position = 2; + this.hbox1.Add (this.vbox162); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox162])); + w7.Position = 1; + w7.Expand = false; + w7.Fill = false; + // Container child hbox1.Gtk.Box+BoxChild + this.GtkScrolledWindow1 = new global::Gtk.ScrolledWindow (); + this.GtkScrolledWindow1.Name = "GtkScrolledWindow1"; + this.GtkScrolledWindow1.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child GtkScrolledWindow1.Gtk.Container+ContainerChild + this.recipeView = new global::Gtk.TreeView (); + this.recipeView.CanFocus = true; + this.recipeView.Name = "recipeView"; + this.recipeView.EnableSearch = false; + this.recipeView.Reorderable = true; + this.GtkScrolledWindow1.Add (this.recipeView); + this.hbox1.Add (this.GtkScrolledWindow1); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.GtkScrolledWindow1])); + w9.Position = 2; + // Container child hbox1.Gtk.Box+BoxChild + this.vbox3 = new global::Gtk.VBox (); + this.vbox3.Name = "vbox3"; + this.vbox3.Spacing = 6; + // Container child vbox3.Gtk.Box+BoxChild + this.alignment2 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); + this.alignment2.Name = "alignment2"; + this.vbox3.Add (this.alignment2); + global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.alignment2])); + w10.Position = 0; + // Container child vbox3.Gtk.Box+BoxChild + this.button65 = new global::Gtk.Button (); + this.button65.CanFocus = true; + this.button65.Name = "button65"; + // Container child button65.Gtk.Container+ContainerChild + this.image1 = new global::Gtk.Image (); + this.image1.Name = "image1"; + this.image1.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-add", global::Gtk.IconSize.Menu); + this.button65.Add (this.image1); + this.vbox3.Add (this.button65); + global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.button65])); + w12.Position = 1; + w12.Expand = false; + w12.Fill = false; + // Container child vbox3.Gtk.Box+BoxChild + this.button66 = new global::Gtk.Button (); + this.button66.CanFocus = true; + this.button66.Name = "button66"; + // Container child button66.Gtk.Container+ContainerChild + this.image2 = new global::Gtk.Image (); + this.image2.Name = "image2"; + this.image2.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-remove", global::Gtk.IconSize.Menu); + this.button66.Add (this.image2); + this.vbox3.Add (this.button66); + global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.button66])); + w14.Position = 2; + w14.Expand = false; + w14.Fill = false; + // Container child vbox3.Gtk.Box+BoxChild + this.button67 = new global::Gtk.Button (); + this.button67.CanFocus = true; + this.button67.Name = "button67"; + // Container child button67.Gtk.Container+ContainerChild + this.image3 = new global::Gtk.Image (); + this.image3.Name = "image3"; + this.image3.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-goto-first", global::Gtk.IconSize.Menu); + this.button67.Add (this.image3); + this.vbox3.Add (this.button67); + global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.button67])); + w16.Position = 3; + w16.Expand = false; + w16.Fill = false; + // Container child vbox3.Gtk.Box+BoxChild + this.alignment4 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); + this.alignment4.Name = "alignment4"; + this.vbox3.Add (this.alignment4); + global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.alignment4])); + w17.Position = 4; + this.hbox1.Add (this.vbox3); + global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox3])); + w18.Position = 3; + w18.Expand = false; + w18.Fill = false; + // Container child hbox1.Gtk.Box+BoxChild + this.paintSwatch = new global::DesertPaintLab.PaintSwatch (); + this.paintSwatch.WidthRequest = 200; + this.paintSwatch.Events = ((global::Gdk.EventMask)(256)); + this.paintSwatch.Name = "paintSwatch"; + this.hbox1.Add (this.paintSwatch); + global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.paintSwatch])); + w19.Position = 4; + this.Add (this.hbox1); + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.Hide (); + this.addReagentButton.Clicked += new global::System.EventHandler (this.OnAddReagent); + this.button65.Clicked += new global::System.EventHandler (this.OnIncrementReagent); + this.button66.Clicked += new global::System.EventHandler (this.OnDecrementReagent); + this.button67.Clicked += new global::System.EventHandler (this.OnFlushReagents); + } + } +} diff --git a/gtk-gui/DesertPaintLab.SimulatorWindow.cs b/gtk-gui/DesertPaintLab.SimulatorWindow.cs deleted file mode 100644 --- a/gtk-gui/DesertPaintLab.SimulatorWindow.cs +++ /dev/null @@ -1,204 +0,0 @@ - -// This file has been generated by the GUI designer. Do not modify. -namespace DesertPaintLab -{ - public partial class SimulatorWindow - { - private global::Gtk.HBox hbox1; - - private global::Gtk.ScrolledWindow GtkScrolledWindow; - - private global::Gtk.TreeView reagentListView; - - private global::Gtk.VBox vbox162; - - private global::Gtk.Alignment alignment1; - - private global::Gtk.Button addReagentButton; - - private global::Gtk.Image addReagentButtonImage; - - private global::Gtk.Alignment alignment3; - - private global::Gtk.ScrolledWindow GtkScrolledWindow1; - - private global::Gtk.TreeView recipeView; - - private global::Gtk.VBox vbox3; - - private global::Gtk.Alignment alignment2; - - private global::Gtk.Button button65; - - private global::Gtk.Image image1; - - private global::Gtk.Button button66; - - private global::Gtk.Image image2; - - private global::Gtk.Button button67; - - private global::Gtk.Image image3; - - private global::Gtk.Alignment alignment4; - - private global::DesertPaintLab.PaintSwatch paintSwatch; - - protected virtual void Build () - { - global::Stetic.Gui.Initialize (this); - // Widget DesertPaintLab.SimulatorWindow - this.Name = "DesertPaintLab.SimulatorWindow"; - this.Title = "Simulator"; - this.WindowPosition = ((global::Gtk.WindowPosition)(4)); - // Container child DesertPaintLab.SimulatorWindow.Gtk.Container+ContainerChild - this.hbox1 = new global::Gtk.HBox (); - this.hbox1.Name = "hbox1"; - this.hbox1.Spacing = 6; - this.hbox1.BorderWidth = ((uint)(12)); - // Container child hbox1.Gtk.Box+BoxChild - this.GtkScrolledWindow = new global::Gtk.ScrolledWindow (); - this.GtkScrolledWindow.Name = "GtkScrolledWindow"; - this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1)); - // Container child GtkScrolledWindow.Gtk.Container+ContainerChild - this.reagentListView = new global::Gtk.TreeView (); - this.reagentListView.CanFocus = true; - this.reagentListView.Name = "reagentListView"; - this.GtkScrolledWindow.Add (this.reagentListView); - this.hbox1.Add (this.GtkScrolledWindow); - global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.GtkScrolledWindow])); - w2.Position = 0; - // Container child hbox1.Gtk.Box+BoxChild - this.vbox162 = new global::Gtk.VBox (); - this.vbox162.Name = "vbox162"; - this.vbox162.Spacing = 6; - // Container child vbox162.Gtk.Box+BoxChild - this.alignment1 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); - this.alignment1.Name = "alignment1"; - this.vbox162.Add (this.alignment1); - global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox162 [this.alignment1])); - w3.Position = 0; - // Container child vbox162.Gtk.Box+BoxChild - this.addReagentButton = new global::Gtk.Button (); - this.addReagentButton.CanFocus = true; - this.addReagentButton.Name = "addReagentButton"; - // Container child addReagentButton.Gtk.Container+ContainerChild - this.addReagentButtonImage = new global::Gtk.Image (); - this.addReagentButtonImage.Name = "addReagentButtonImage"; - this.addReagentButtonImage.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-go-forward", global::Gtk.IconSize.Menu); - this.addReagentButton.Add (this.addReagentButtonImage); - this.vbox162.Add (this.addReagentButton); - global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox162 [this.addReagentButton])); - w5.Position = 1; - w5.Expand = false; - w5.Fill = false; - // Container child vbox162.Gtk.Box+BoxChild - this.alignment3 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); - this.alignment3.Name = "alignment3"; - this.vbox162.Add (this.alignment3); - global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox162 [this.alignment3])); - w6.Position = 2; - this.hbox1.Add (this.vbox162); - global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox162])); - w7.Position = 1; - w7.Expand = false; - w7.Fill = false; - // Container child hbox1.Gtk.Box+BoxChild - this.GtkScrolledWindow1 = new global::Gtk.ScrolledWindow (); - this.GtkScrolledWindow1.Name = "GtkScrolledWindow1"; - this.GtkScrolledWindow1.ShadowType = ((global::Gtk.ShadowType)(1)); - // Container child GtkScrolledWindow1.Gtk.Container+ContainerChild - this.recipeView = new global::Gtk.TreeView (); - this.recipeView.CanFocus = true; - this.recipeView.Name = "recipeView"; - this.recipeView.EnableSearch = false; - this.recipeView.Reorderable = true; - this.GtkScrolledWindow1.Add (this.recipeView); - this.hbox1.Add (this.GtkScrolledWindow1); - global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.GtkScrolledWindow1])); - w9.Position = 2; - // Container child hbox1.Gtk.Box+BoxChild - this.vbox3 = new global::Gtk.VBox (); - this.vbox3.Name = "vbox3"; - this.vbox3.Spacing = 6; - // Container child vbox3.Gtk.Box+BoxChild - this.alignment2 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); - this.alignment2.Name = "alignment2"; - this.vbox3.Add (this.alignment2); - global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.alignment2])); - w10.Position = 0; - // Container child vbox3.Gtk.Box+BoxChild - this.button65 = new global::Gtk.Button (); - this.button65.CanFocus = true; - this.button65.Name = "button65"; - // Container child button65.Gtk.Container+ContainerChild - this.image1 = new global::Gtk.Image (); - this.image1.Name = "image1"; - this.image1.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-add", global::Gtk.IconSize.Menu); - this.button65.Add (this.image1); - this.vbox3.Add (this.button65); - global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.button65])); - w12.Position = 1; - w12.Expand = false; - w12.Fill = false; - // Container child vbox3.Gtk.Box+BoxChild - this.button66 = new global::Gtk.Button (); - this.button66.CanFocus = true; - this.button66.Name = "button66"; - // Container child button66.Gtk.Container+ContainerChild - this.image2 = new global::Gtk.Image (); - this.image2.Name = "image2"; - this.image2.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-remove", global::Gtk.IconSize.Menu); - this.button66.Add (this.image2); - this.vbox3.Add (this.button66); - global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.button66])); - w14.Position = 2; - w14.Expand = false; - w14.Fill = false; - // Container child vbox3.Gtk.Box+BoxChild - this.button67 = new global::Gtk.Button (); - this.button67.CanFocus = true; - this.button67.Name = "button67"; - // Container child button67.Gtk.Container+ContainerChild - this.image3 = new global::Gtk.Image (); - this.image3.Name = "image3"; - this.image3.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-goto-first", global::Gtk.IconSize.Menu); - this.button67.Add (this.image3); - this.vbox3.Add (this.button67); - global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.button67])); - w16.Position = 3; - w16.Expand = false; - w16.Fill = false; - // Container child vbox3.Gtk.Box+BoxChild - this.alignment4 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); - this.alignment4.Name = "alignment4"; - this.vbox3.Add (this.alignment4); - global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.alignment4])); - w17.Position = 4; - this.hbox1.Add (this.vbox3); - global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox3])); - w18.Position = 3; - w18.Expand = false; - w18.Fill = false; - // Container child hbox1.Gtk.Box+BoxChild - this.paintSwatch = new global::DesertPaintLab.PaintSwatch (); - this.paintSwatch.WidthRequest = 200; - this.paintSwatch.Events = ((global::Gdk.EventMask)(256)); - this.paintSwatch.Name = "paintSwatch"; - this.hbox1.Add (this.paintSwatch); - global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.paintSwatch])); - w19.Position = 4; - this.Add (this.hbox1); - if ((this.Child != null)) { - this.Child.ShowAll (); - } - this.DefaultWidth = 804; - this.DefaultHeight = 390; - this.Show (); - this.addReagentButton.Clicked += new global::System.EventHandler (this.OnAddReagent); - this.button65.Clicked += new global::System.EventHandler (this.OnIncrementReagent); - this.button66.Clicked += new global::System.EventHandler (this.OnDecrementReagent); - this.button67.Clicked += new global::System.EventHandler (this.OnFlushReagents); - } - } -} diff --git a/gtk-gui/MainWindow.cs b/gtk-gui/MainWindow.cs --- a/gtk-gui/MainWindow.cs +++ b/gtk-gui/MainWindow.cs @@ -11,87 +11,45 @@ public partial class MainWindow private global::Gtk.Action AboutAction; - private global::Gtk.Action NewProfileAction; - - private global::Gtk.Action OpenProfileAction; - private global::Gtk.Action ExitAction; - private global::Gtk.Action ExportForPracticalPaintAction; - - private global::Gtk.Action WindowAction; - - private global::Gtk.Action RunSimulatorAction; - private global::Gtk.Action DebugAction; private global::Gtk.Action ScreenshotAction; + private global::Gtk.Action ReactionStatusAction; + + private global::Gtk.Action ViewAction; + + private global::Gtk.RadioAction CaptureAction; + + private global::Gtk.RadioAction SimulatorAction; + + private global::Gtk.RadioAction RecipeGeneratorAction; + private global::Gtk.Action RecipesAction; - private global::Gtk.Action ReactionStatusAction; + private global::Gtk.Action ExportRecipesAction; + + private global::Gtk.Action CopyRecipesToClipboardAction; + + private global::Gtk.Action ProfileAction; - private global::Gtk.Action IngredientsAction; + private global::Gtk.Action NewProfileAction; + + private global::Gtk.Action OpenProfileAction; + + private global::Gtk.Action ImportProfileAction; private global::Gtk.Action ExportProfileAction; - private global::Gtk.Action ImportProfileAction; + private global::Gtk.Action ExportForPracticalPaintAction; private global::Gtk.VBox vbox1; - private global::Gtk.MenuBar menubar1; - - private global::Gtk.HBox hbox1; - - private global::Gtk.Frame frame2; - - private global::Gtk.Alignment GtkAlignment; - - private global::Gtk.VBox vbox3; - - private global::Gtk.HBox hbox6; - - private global::Gtk.Label label4; - - private global::Gtk.ComboBox ingredient1ComboBox; - - private global::Gtk.HBox hbox7; - - private global::Gtk.Label label5; - - private global::Gtk.ComboBox ingredient2ComboBox; - - private global::Gtk.HBox hbox8; - - private global::Gtk.Label label6; + private global::Gtk.MenuBar menu; - private global::Gtk.ComboBox ingredient3ComboBox; - - private global::Gtk.Label GtkLabel2; - - private global::Gtk.Frame frame3; - - private global::Gtk.Alignment GtkAlignment1; - - private global::Gtk.VBox vbox4; - - private global::DesertPaintLab.PaintSwatch unmodifiedSwatch; - - private global::Gtk.Button captureButton; - - private global::Gtk.Label GtkLabel25; - - private global::Gtk.Frame frame4; - - private global::Gtk.Alignment GtkAlignment2; - - private global::Gtk.VBox vbox5; - - private global::DesertPaintLab.PaintSwatch reactionSwatch; - - private global::Gtk.Button saveButton; - - private global::Gtk.Label GtkLabel26; + private global::Gtk.Alignment contentContainer; private global::Gtk.Statusbar statusBar; @@ -110,45 +68,60 @@ public partial class MainWindow this.AboutAction = new global::Gtk.Action ("AboutAction", "_About...", null, null); this.AboutAction.ShortLabel = "_About..."; w1.Add (this.AboutAction, "a"); - this.NewProfileAction = new global::Gtk.Action ("NewProfileAction", "_New Profile...", null, null); - this.NewProfileAction.ShortLabel = "_New Profile..."; - w1.Add (this.NewProfileAction, "n"); - this.OpenProfileAction = new global::Gtk.Action ("OpenProfileAction", "_Open Profile...", null, null); - this.OpenProfileAction.ShortLabel = "_Open Profile..."; - w1.Add (this.OpenProfileAction, "o"); this.ExitAction = new global::Gtk.Action ("ExitAction", "E_xit", null, null); this.ExitAction.ShortLabel = "E_xit"; w1.Add (this.ExitAction, "x"); - this.ExportForPracticalPaintAction = new global::Gtk.Action ("ExportForPracticalPaintAction", "Export for _PracticalPaint...", null, null); - this.ExportForPracticalPaintAction.ShortLabel = "Export for _PracticalPaint..."; - w1.Add (this.ExportForPracticalPaintAction, null); - this.WindowAction = new global::Gtk.Action ("WindowAction", "_Window", null, null); - this.WindowAction.ShortLabel = "_Window"; - w1.Add (this.WindowAction, null); - this.RunSimulatorAction = new global::Gtk.Action ("RunSimulatorAction", "_Run Simulator", null, null); - this.RunSimulatorAction.ShortLabel = "_Run Simulator"; - w1.Add (this.RunSimulatorAction, null); this.DebugAction = new global::Gtk.Action ("DebugAction", "Debug", null, null); this.DebugAction.ShortLabel = "Debug"; w1.Add (this.DebugAction, null); this.ScreenshotAction = new global::Gtk.Action ("ScreenshotAction", "Screenshot", null, null); this.ScreenshotAction.ShortLabel = "Screenshot"; w1.Add (this.ScreenshotAction, null); - this.RecipesAction = new global::Gtk.Action ("RecipesAction", "Recipes", null, null); - this.RecipesAction.ShortLabel = "Recipe Generator"; - w1.Add (this.RecipesAction, null); this.ReactionStatusAction = new global::Gtk.Action ("ReactionStatusAction", "Reaction Status", null, null); this.ReactionStatusAction.ShortLabel = "Reaction Status"; w1.Add (this.ReactionStatusAction, null); - this.IngredientsAction = new global::Gtk.Action ("IngredientsAction", "Ingredients", null, null); - this.IngredientsAction.ShortLabel = "Ingredients"; - w1.Add (this.IngredientsAction, null); + this.ViewAction = new global::Gtk.Action ("ViewAction", "View", null, null); + this.ViewAction.ShortLabel = "View"; + w1.Add (this.ViewAction, null); + this.CaptureAction = new global::Gtk.RadioAction ("CaptureAction", "Capture", null, null, 0); + this.CaptureAction.Group = new global::GLib.SList (global::System.IntPtr.Zero); + this.CaptureAction.ShortLabel = "Capture"; + w1.Add (this.CaptureAction, null); + this.SimulatorAction = new global::Gtk.RadioAction ("SimulatorAction", "Simulator", null, null, 0); + this.SimulatorAction.Group = this.CaptureAction.Group; + this.SimulatorAction.ShortLabel = "Simulator"; + w1.Add (this.SimulatorAction, null); + this.RecipeGeneratorAction = new global::Gtk.RadioAction ("RecipeGeneratorAction", "Recipe Generator", null, null, 0); + this.RecipeGeneratorAction.Group = this.SimulatorAction.Group; + this.RecipeGeneratorAction.ShortLabel = "Recipe Generator"; + w1.Add (this.RecipeGeneratorAction, null); + this.RecipesAction = new global::Gtk.Action ("RecipesAction", "Recipes...", null, null); + this.RecipesAction.ShortLabel = "Recipes..."; + w1.Add (this.RecipesAction, null); + this.ExportRecipesAction = new global::Gtk.Action ("ExportRecipesAction", "Export Recipes", null, null); + this.ExportRecipesAction.ShortLabel = "Export Recipes"; + w1.Add (this.ExportRecipesAction, null); + this.CopyRecipesToClipboardAction = new global::Gtk.Action ("CopyRecipesToClipboardAction", "Copy to Clipboard", null, null); + this.CopyRecipesToClipboardAction.ShortLabel = "Copy to Clipboard"; + w1.Add (this.CopyRecipesToClipboardAction, null); + this.ProfileAction = new global::Gtk.Action ("ProfileAction", "Profile...", null, null); + this.ProfileAction.ShortLabel = "Profile..."; + w1.Add (this.ProfileAction, null); + this.NewProfileAction = new global::Gtk.Action ("NewProfileAction", "New Profile", null, null); + this.NewProfileAction.ShortLabel = "New Profile"; + w1.Add (this.NewProfileAction, null); + this.OpenProfileAction = new global::Gtk.Action ("OpenProfileAction", "Open Profile", null, null); + this.OpenProfileAction.ShortLabel = "Open Profile"; + w1.Add (this.OpenProfileAction, null); + this.ImportProfileAction = new global::Gtk.Action ("ImportProfileAction", "Import Profile", null, null); + this.ImportProfileAction.ShortLabel = "Import Profile"; + w1.Add (this.ImportProfileAction, null); this.ExportProfileAction = new global::Gtk.Action ("ExportProfileAction", "Export Profile", null, null); this.ExportProfileAction.ShortLabel = "Export Profile"; w1.Add (this.ExportProfileAction, null); - this.ImportProfileAction = new global::Gtk.Action ("ImportProfileAction", "Import Profile", null, null); - this.ImportProfileAction.ShortLabel = "Import Profile"; - w1.Add (this.ImportProfileAction, null); + this.ExportForPracticalPaintAction = new global::Gtk.Action ("ExportForPracticalPaintAction", "Export for PracticalPaint", null, null); + this.ExportForPracticalPaintAction.ShortLabel = "Export for PracticalPaint"; + w1.Add (this.ExportForPracticalPaintAction, null); this.UIManager.InsertActionGroup (w1, 0); this.AddAccelGroup (this.UIManager.AccelGroup); this.Name = "MainWindow"; @@ -158,246 +131,54 @@ public partial class MainWindow this.vbox1 = new global::Gtk.VBox (); this.vbox1.Name = "vbox1"; // Container child vbox1.Gtk.Box+BoxChild - this.UIManager.AddUiFromString (""); - this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar1"))); - this.menubar1.Name = "menubar1"; - this.vbox1.Add (this.menubar1); - global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.menubar1])); + this.UIManager.AddUiFromString (""); + this.menu = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menu"))); + this.menu.Name = "menu"; + this.vbox1.Add (this.menu); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.menu])); w2.Position = 0; w2.Expand = false; w2.Fill = false; // Container child vbox1.Gtk.Box+BoxChild - this.hbox1 = new global::Gtk.HBox (); - this.hbox1.Name = "hbox1"; - this.hbox1.Spacing = 6; - this.hbox1.BorderWidth = ((uint)(4)); - // Container child hbox1.Gtk.Box+BoxChild - this.frame2 = new global::Gtk.Frame (); - this.frame2.Name = "frame2"; - this.frame2.BorderWidth = ((uint)(4)); - // Container child frame2.Gtk.Container+ContainerChild - this.GtkAlignment = new global::Gtk.Alignment (0F, 0F, 1F, 1F); - this.GtkAlignment.Name = "GtkAlignment"; - this.GtkAlignment.LeftPadding = ((uint)(6)); - this.GtkAlignment.RightPadding = ((uint)(6)); - // Container child GtkAlignment.Gtk.Container+ContainerChild - this.vbox3 = new global::Gtk.VBox (); - this.vbox3.Name = "vbox3"; - this.vbox3.Homogeneous = true; - this.vbox3.Spacing = 6; - // Container child vbox3.Gtk.Box+BoxChild - this.hbox6 = new global::Gtk.HBox (); - this.hbox6.Name = "hbox6"; - this.hbox6.Spacing = 6; - // Container child hbox6.Gtk.Box+BoxChild - this.label4 = new global::Gtk.Label (); - this.label4.Name = "label4"; - this.label4.LabelProp = "Ingredient 1:"; - this.hbox6.Add (this.label4); - global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.label4])); - w3.Position = 0; - w3.Expand = false; - w3.Fill = false; - // Container child hbox6.Gtk.Box+BoxChild - this.ingredient1ComboBox = global::Gtk.ComboBox.NewText (); - this.ingredient1ComboBox.Name = "ingredient1ComboBox"; - this.hbox6.Add (this.ingredient1ComboBox); - global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.ingredient1ComboBox])); - w4.Position = 1; - this.vbox3.Add (this.hbox6); - global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.hbox6])); - w5.Position = 0; - w5.Expand = false; - w5.Fill = false; - // Container child vbox3.Gtk.Box+BoxChild - this.hbox7 = new global::Gtk.HBox (); - this.hbox7.Name = "hbox7"; - this.hbox7.Spacing = 6; - // Container child hbox7.Gtk.Box+BoxChild - this.label5 = new global::Gtk.Label (); - this.label5.Name = "label5"; - this.label5.LabelProp = "Ingredient 2:"; - this.hbox7.Add (this.label5); - global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox7 [this.label5])); - w6.Position = 0; - w6.Expand = false; - w6.Fill = false; - // Container child hbox7.Gtk.Box+BoxChild - this.ingredient2ComboBox = global::Gtk.ComboBox.NewText (); - this.ingredient2ComboBox.Name = "ingredient2ComboBox"; - this.hbox7.Add (this.ingredient2ComboBox); - global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox7 [this.ingredient2ComboBox])); - w7.Position = 1; - this.vbox3.Add (this.hbox7); - global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.hbox7])); - w8.Position = 1; - w8.Expand = false; - w8.Fill = false; - // Container child vbox3.Gtk.Box+BoxChild - this.hbox8 = new global::Gtk.HBox (); - this.hbox8.Name = "hbox8"; - this.hbox8.Spacing = 6; - // Container child hbox8.Gtk.Box+BoxChild - this.label6 = new global::Gtk.Label (); - this.label6.Name = "label6"; - this.label6.LabelProp = "Ingredient 3:"; - this.hbox8.Add (this.label6); - global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.hbox8 [this.label6])); - w9.Position = 0; - w9.Expand = false; - w9.Fill = false; - // Container child hbox8.Gtk.Box+BoxChild - this.ingredient3ComboBox = global::Gtk.ComboBox.NewText (); - this.ingredient3ComboBox.Name = "ingredient3ComboBox"; - this.hbox8.Add (this.ingredient3ComboBox); - global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.hbox8 [this.ingredient3ComboBox])); - w10.Position = 1; - this.vbox3.Add (this.hbox8); - global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.hbox8])); - w11.Position = 2; - w11.Expand = false; - w11.Fill = false; - this.GtkAlignment.Add (this.vbox3); - this.frame2.Add (this.GtkAlignment); - this.GtkLabel2 = new global::Gtk.Label (); - this.GtkLabel2.Name = "GtkLabel2"; - this.GtkLabel2.LabelProp = "Select Ingredients"; - this.GtkLabel2.UseMarkup = true; - this.frame2.LabelWidget = this.GtkLabel2; - this.hbox1.Add (this.frame2); - global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.frame2])); - w14.Position = 0; - // Container child hbox1.Gtk.Box+BoxChild - this.frame3 = new global::Gtk.Frame (); - this.frame3.Name = "frame3"; - this.frame3.BorderWidth = ((uint)(4)); - // Container child frame3.Gtk.Container+ContainerChild - this.GtkAlignment1 = new global::Gtk.Alignment (0F, 0F, 1F, 1F); - this.GtkAlignment1.Name = "GtkAlignment1"; - this.GtkAlignment1.LeftPadding = ((uint)(5)); - this.GtkAlignment1.TopPadding = ((uint)(5)); - this.GtkAlignment1.RightPadding = ((uint)(5)); - this.GtkAlignment1.BottomPadding = ((uint)(6)); - // Container child GtkAlignment1.Gtk.Container+ContainerChild - this.vbox4 = new global::Gtk.VBox (); - this.vbox4.WidthRequest = 120; - this.vbox4.Name = "vbox4"; - this.vbox4.Spacing = 6; - // Container child vbox4.Gtk.Box+BoxChild - this.unmodifiedSwatch = new global::DesertPaintLab.PaintSwatch (); - this.unmodifiedSwatch.Events = ((global::Gdk.EventMask)(256)); - this.unmodifiedSwatch.Name = "unmodifiedSwatch"; - this.vbox4.Add (this.unmodifiedSwatch); - global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.unmodifiedSwatch])); - w15.Position = 0; - // Container child vbox4.Gtk.Box+BoxChild - this.captureButton = new global::Gtk.Button (); - this.captureButton.WidthRequest = 100; - this.captureButton.CanFocus = true; - this.captureButton.Name = "captureButton"; - this.captureButton.UseUnderline = true; - this.captureButton.Label = "Capture"; - this.vbox4.Add (this.captureButton); - global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.captureButton])); - w16.Position = 1; - w16.Expand = false; - w16.Fill = false; - this.GtkAlignment1.Add (this.vbox4); - this.frame3.Add (this.GtkAlignment1); - this.GtkLabel25 = new global::Gtk.Label (); - this.GtkLabel25.Name = "GtkLabel25"; - this.GtkLabel25.LabelProp = "Unmodified"; - this.GtkLabel25.UseMarkup = true; - this.frame3.LabelWidget = this.GtkLabel25; - this.hbox1.Add (this.frame3); - global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.frame3])); - w19.Position = 1; - w19.Expand = false; - w19.Fill = false; - // Container child hbox1.Gtk.Box+BoxChild - this.frame4 = new global::Gtk.Frame (); - this.frame4.Name = "frame4"; - this.frame4.BorderWidth = ((uint)(4)); - // Container child frame4.Gtk.Container+ContainerChild - this.GtkAlignment2 = new global::Gtk.Alignment (0F, 0F, 1F, 1F); - this.GtkAlignment2.WidthRequest = 130; - this.GtkAlignment2.Name = "GtkAlignment2"; - this.GtkAlignment2.LeftPadding = ((uint)(5)); - this.GtkAlignment2.TopPadding = ((uint)(5)); - this.GtkAlignment2.RightPadding = ((uint)(5)); - this.GtkAlignment2.BottomPadding = ((uint)(6)); - // Container child GtkAlignment2.Gtk.Container+ContainerChild - this.vbox5 = new global::Gtk.VBox (); - this.vbox5.WidthRequest = 120; - this.vbox5.Name = "vbox5"; - this.vbox5.Spacing = 6; - // Container child vbox5.Gtk.Box+BoxChild - this.reactionSwatch = new global::DesertPaintLab.PaintSwatch (); - this.reactionSwatch.Events = ((global::Gdk.EventMask)(256)); - this.reactionSwatch.Name = "reactionSwatch"; - this.vbox5.Add (this.reactionSwatch); - global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.reactionSwatch])); - w20.Position = 0; - // Container child vbox5.Gtk.Box+BoxChild - this.saveButton = new global::Gtk.Button (); - this.saveButton.WidthRequest = 100; - this.saveButton.CanFocus = true; - this.saveButton.Name = "saveButton"; - this.saveButton.UseUnderline = true; - this.saveButton.Label = "Record"; - this.vbox5.Add (this.saveButton); - global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.saveButton])); - w21.Position = 1; - w21.Expand = false; - w21.Fill = false; - this.GtkAlignment2.Add (this.vbox5); - this.frame4.Add (this.GtkAlignment2); - this.GtkLabel26 = new global::Gtk.Label (); - this.GtkLabel26.Name = "GtkLabel26"; - this.GtkLabel26.LabelProp = "Reaction"; - this.GtkLabel26.UseMarkup = true; - this.frame4.LabelWidget = this.GtkLabel26; - this.hbox1.Add (this.frame4); - global::Gtk.Box.BoxChild w24 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.frame4])); - w24.Position = 2; - w24.Expand = false; - w24.Fill = false; - this.vbox1.Add (this.hbox1); - global::Gtk.Box.BoxChild w25 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox1])); - w25.Position = 1; + this.contentContainer = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); + this.contentContainer.Name = "contentContainer"; + this.contentContainer.LeftPadding = ((uint)(8)); + this.contentContainer.TopPadding = ((uint)(6)); + this.contentContainer.RightPadding = ((uint)(8)); + this.contentContainer.BottomPadding = ((uint)(5)); + this.vbox1.Add (this.contentContainer); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.contentContainer])); + w3.Position = 1; // Container child vbox1.Gtk.Box+BoxChild this.statusBar = new global::Gtk.Statusbar (); this.statusBar.Name = "statusBar"; this.statusBar.Spacing = 6; this.vbox1.Add (this.statusBar); - global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.statusBar])); - w26.Position = 2; - w26.Expand = false; - w26.Fill = false; + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.statusBar])); + w4.Position = 2; + w4.Expand = false; + w4.Fill = false; this.Add (this.vbox1); if ((this.Child != null)) { this.Child.ShowAll (); } - this.DefaultWidth = 629; - this.DefaultHeight = 265; + this.DefaultWidth = 732; + this.DefaultHeight = 384; this.Show (); this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent); this.AboutAction.Activated += new global::System.EventHandler (this.OnAbout); + this.ExitAction.Activated += new global::System.EventHandler (this.OnMenuExit); + this.ScreenshotAction.Activated += new global::System.EventHandler (this.OnDebugScreenshot); + this.ReactionStatusAction.Activated += new global::System.EventHandler (this.OnShowReactionStatus); + this.CaptureAction.Toggled += new global::System.EventHandler (this.OnSelectCaptureView); + this.SimulatorAction.Toggled += new global::System.EventHandler (this.OnSelectSimulatorView); + this.RecipeGeneratorAction.Toggled += new global::System.EventHandler (this.OnSelectRecipeGeneratorView); + this.ExportRecipesAction.Activated += new global::System.EventHandler (this.OnExportRecipeListToWiki); + this.CopyRecipesToClipboardAction.Activated += new global::System.EventHandler (this.OnCopyRecipeListToClipboard); this.NewProfileAction.Activated += new global::System.EventHandler (this.OnNewProfile); this.OpenProfileAction.Activated += new global::System.EventHandler (this.OnOpenProfile); - this.ExitAction.Activated += new global::System.EventHandler (this.OnMenuExit); - this.ExportForPracticalPaintAction.Activated += new global::System.EventHandler (this.OnExport); - this.RunSimulatorAction.Activated += new global::System.EventHandler (this.RunSimulator); - this.ScreenshotAction.Activated += new global::System.EventHandler (this.OnDebugScreenshot); - this.RecipesAction.Activated += new global::System.EventHandler (this.OnOpenRecipeGenerator); - this.ReactionStatusAction.Activated += new global::System.EventHandler (this.OnShowReactionStatus); - this.IngredientsAction.Activated += new global::System.EventHandler (this.OnShowIngredients); + this.ImportProfileAction.Activated += new global::System.EventHandler (this.OnImportProfile); this.ExportProfileAction.Activated += new global::System.EventHandler (this.OnExportProfile); - this.ImportProfileAction.Activated += new global::System.EventHandler (this.OnImportProfile); - this.ingredient1ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient1); - this.ingredient2ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient2); - this.ingredient3ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient3); - this.captureButton.Clicked += new global::System.EventHandler (this.OnCaptureButton); - this.saveButton.Clicked += new global::System.EventHandler (this.OnSaveButton); + this.ExportForPracticalPaintAction.Activated += new global::System.EventHandler (this.OnExportToPracticalPaint); } } diff --git a/gtk-gui/gui.stetic b/gtk-gui/gui.stetic --- a/gtk-gui/gui.stetic +++ b/gtk-gui/gui.stetic @@ -8,7 +8,7 @@ - + Action @@ -29,20 +29,6 @@ _About... - - Action - <Alt>n - _New Profile... - _New Profile... - - - - Action - <Alt>o - _Open Profile... - _Open Profile... - - Action <Alt>x @@ -50,23 +36,6 @@ E_xit - - Action - Export for _PracticalPaint... - Export for _PracticalPaint... - - - - Action - _Window - _Window - - - Action - _Run Simulator - _Run Simulator - - Action Debug @@ -78,23 +47,86 @@ Screenshot - - Action - Recipes - Recipe Generator - - Action Reaction Status Reaction Status - + + Action + View + View + + + Radio + Capture + Capture + False + True + 0 + viewGroup + + + + Radio + Simulator + Simulator + False + False + 0 + viewGroup + + + + Radio + Recipe Generator + Recipe Generator + False + False + 0 + viewGroup + + + Action - Ingredients - Ingredients - + Recipes... + Recipes... + + + Action + Export Recipes + Export Recipes + + + + Action + Copy to Clipboard + Copy to Clipboard + + + + Action + Profile... + Profile... + + + Action + New Profile + New Profile + + + + Action + Open Profile + Open Profile + + + + Action + Import Profile + Import Profile + Action @@ -102,11 +134,11 @@ Export Profile - + Action - Import Profile - Import Profile - + Export for PracticalPaint + Export for PracticalPaint + @@ -117,22 +149,28 @@ - + - + - - - - - + + + + + + + + + + + - - - - + + + + @@ -151,293 +189,19 @@ - + - 6 - 4 + 8 + 6 + 8 + 5 - - - 4 - - - - 0 - 0 - 6 - 6 - - - - True - 6 - - - - 6 - - - - Ingredient 1: - - - 0 - True - False - False - - - - - - True - - - - - 1 - False - - - - - 0 - True - False - False - - - - - - 6 - - - - Ingredient 2: - - - 0 - True - False - False - - - - - - True - - - - - 1 - False - - - - - 1 - True - False - False - - - - - - 6 - - - - Ingredient 3: - - - 0 - True - False - False - - - - - - True - - - - - 1 - False - - - - - 2 - True - False - False - - - - - - - - - - <b>Select Ingredients</b> - True - - - label_item - - - - - 0 - False - - - - - - 4 - - - - 0 - 0 - 5 - 5 - 5 - 6 - - - - 120 - 6 - - - - ButtonPressMask - - - 0 - True - - - - - - 100 - True - TextOnly - Capture - True - - - - 1 - True - False - False - - - - - - - - - - <b>Unmodified</b> - True - - - label_item - - - - - 1 - True - False - False - - - - - - 4 - - - - 130 - 0 - 0 - 5 - 5 - 5 - 6 - - - - 120 - 6 - - - - ButtonPressMask - - - 0 - True - - - - - - 100 - True - TextOnly - Record - True - - - - 1 - True - False - False - - - - - - - - - - <b>Reaction</b> - True - - - label_item - - - - - 2 - True - False - False - + 1 - False + True @@ -763,10 +527,1162 @@ You can either import an existing Practi - + + + Screen Check + CenterOnParent + True + 9 + 1 + False + + + + + + + 20 + 20 + + + + 20 + 10 + + + + Screen Resolution + + + 0 + True + False + False + + + + + + 50 + True + True + + + + 1 + True + + + + + + 50 + True + True + + + + 2 + True + + + + + 0 + True + False + False + + + + + + 20 + 10 + + + + Game Pixel Width in Screen Pixels + + + 0 + True + False + False + + + + + + 50 + True + True + + + + 1 + False + False + False + + + + + + + + 1 + True + False + False + + + + + + + + 0 + True + + + + + + + + 10 + 5 + 1 + End + + + + True + True + True + StockItem + gtk-ok + -5 + gtk-ok + + + False + False + + + + + + + + Reaction Status + CenterOnParent + + + + True + In + + + + None + + + + 6 + + + + + + + + + + + + + + + + + + + ReagentWindow + CenterOnParent + + + + 6 + 8 + + + + None + + + + 0 + 0 + 12 + + + + 3 + 3 + 6 + 6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <b>Ingredients</b> + True + + + label_item + + + + + 0 + True + + + + + + 2 + + + + 80 + True + TextOnly + Ok + True + + + + False + False + + + + + + 80 + True + TextOnly + Cancel + True + + + + 1 + False + False + + + + + End + 1 + True + False + False + + + + + + - Simulator - CenterOnParent + False + + + + 6 + + + + 4 + + + + 0 + 0 + 6 + 6 + + + + 6 + + + + 6 + + + + Ingredient 1: + + + 0 + True + False + False + + + + + + True + + + + + 1 + False + + + + + 0 + True + False + False + + + + + + 6 + + + + Ingredient 2: + + + 0 + True + False + False + + + + + + True + + + + + 1 + False + + + + + 1 + True + False + False + + + + + + 6 + + + + Ingredient 3: + + + 0 + True + False + False + + + + + + True + + + + + 1 + False + + + + + 2 + True + False + False + + + + + + False + False + True + TextOnly + Clear Reaction + True + + + + End + 3 + True + False + False + 6 + + + + + + + + + + <b>Select Ingredients</b> + True + + + label_item + + + + + 0 + False + + + + + + 4 + + + + 0 + 0 + 5 + 5 + 5 + 6 + + + + 120 + 6 + + + + 120 + 120 + ButtonPressMask + + + 0 + True + + + + + + True + TextOnly + Capture + True + + + + 1 + True + False + False + + + + + + + + + + <b>Unmodified</b> + True + Center + + + label_item + + + + + 1 + True + False + False + + + + + + 4 + + + + 0 + 0 + 5 + 5 + 5 + 6 + + + + 120 + 6 + + + + 120 + 120 + ButtonPressMask + + + 0 + True + + + + + + True + TextOnly + Record + True + + + + 1 + True + False + False + + + + + + + + + + <b>Reacted</b> + True + Center + + + label_item + + + + + 2 + True + False + False + + + + + + + + + False + + + + 6 + 8 + + + + 6 + + + + 6 + + + + 6 + + + + True + 1 + 14 + 10 + 1 + 1 + True + 1 + + + + 0 + True + False + False + + + + + + Minimum Ingredients + + + 1 + True + False + False + + + + + 0 + True + False + False + + + + + + 6 + + + + True + 1 + 14 + 10 + 1 + 1 + True + 5 + + + + 0 + True + False + False + + + + + + Maximum Ingredients + + + 1 + True + False + False + + + + + 1 + True + False + False + + + + + + + + 2 + True + False + False + + + + + + True + Ribbon Recipes + True + True + True + + + + 3 + True + False + False + + + + + + 6 + + + + True + 10 + 100 + 10 + 1 + 1 + True + 14 + + + + 0 + True + False + False + + + + + + Maximum Concentration + True + True + + + 1 + True + False + False + + + + + 4 + True + False + False + + + + + + + + 5 + True + False + False + 8 + + + + + + 6 + + + + True + 15 + 10 + 1 + 1 + True + 4 + + + + 0 + True + False + False + + + + + + Full Quantity Depth + + + 1 + True + False + False + + + + + 6 + True + False + False + + + + + + + + 7 + True + False + False + + + + + + 6 + + + + True + 30 + 10 + 1 + 1 + True + 20 + + + + 0 + True + False + False + + + + + + FullQuantity + + + 1 + True + False + False + + + + + 8 + True + False + False + + + + + + None + + + + 0 + 0 + 12 + + + + True + In + + + + 300 + True + + + + + + + + + + <b>Ingredients</b> + True + + + label_item + + + + + End + 9 + True + + + + + + + + End + 10 + True + False + False + + + + + 0 + True + False + False + + + + + + In + + + + 300 + True + True + + + + + 1 + True + + + + + + 6 + + + + 200 + 200 + None + + + + In + + + + True + True + + + + + + + + <b>Recipe</b> + True + + + label_item + + + + + 0 + True + + + + + + True + TextOnly + Copy + True + + + + 1 + True + False + False + + + + + + 200 + ButtonPressMask + + + 2 + True + + + + + 2 + True + False + False + + + + + 0 + False + + + + + + 6 + + + + + + 0 + True + + + + + + False + True + TextOnly + Stop + True + + + + 1 + True + False + False + 20 + + + + + + 0/192 + + + 2 + True + False + False + 40 + + + + + + True + TextOnly + Begin + True + + + + 3 + True + False + False + 20 + + + + + + + + 4 + True + + + + + 1 + True + False + False + + + + + + + + End + 2 + True + False + False + + + + + + + + False @@ -974,888 +1890,4 @@ You can either import an existing Practi - - - Screen Check - CenterOnParent - True - 9 - 1 - False - - - - - - - 20 - 20 - - - - 20 - 10 - - - - Screen Resolution - - - 0 - True - False - False - - - - - - 50 - True - True - - - - 1 - True - - - - - - 50 - True - True - - - - 2 - True - - - - - 0 - True - False - False - - - - - - 20 - 10 - - - - Game Pixel Width in Screen Pixels - - - 0 - True - False - False - - - - - - 50 - True - True - - - - 1 - False - False - False - - - - - - - - 1 - True - False - False - - - - - - - - 0 - True - - - - - - - - 10 - 5 - 1 - End - - - - True - True - True - StockItem - gtk-ok - -5 - gtk-ok - - - False - False - - - - - - - - Reaction Status - CenterOnParent - - - - True - In - - - - None - - - - 6 - - - - - - - - - - - - - - - - - - - - Action - Export - Export - - - Action - Export to Wiki - Export to Wiki - - - - Action - Settings - Tools - - - Action - Ingredients - Ingredients - - - - Action - Copy to Clipboard - Copy to Clipboard - - - - - Recipe Generator - CenterOnParent - - - - 6 - 8 - - - - - - - - - - - - 0 - True - False - False - - - - - - 6 - - - - 6 - - - - 6 - - - - True - 1 - 14 - 10 - 1 - 1 - True - 1 - - - - 0 - True - False - False - - - - - - Minimum Ingredients - - - 1 - True - False - False - - - - - 0 - True - False - False - - - - - - 6 - - - - True - 1 - 14 - 10 - 1 - 1 - True - 5 - - - - 0 - True - False - False - - - - - - Maximum Ingredients - - - 1 - True - False - False - - - - - 1 - True - False - False - - - - - - - - 2 - True - False - False - - - - - - 6 - - - - True - 10 - 100 - 10 - 1 - 1 - True - 14 - - - - 0 - True - False - False - - - - - - Max Total Quantity - True - True - - - 1 - True - False - False - - - - - 3 - True - False - False - - - - - - - - 4 - True - False - False - 8 - - - - - - 6 - - - - True - 15 - 10 - 1 - 1 - True - 4 - - - - 0 - True - False - False - - - - - - Full Quantity Depth - - - 1 - True - False - False - - - - - 5 - True - False - False - - - - - - - - 6 - True - False - False - - - - - - 6 - - - - True - 30 - 10 - 1 - 1 - True - 20 - - - - 0 - True - False - False - - - - - - FullQuantity - - - 1 - True - False - False - - - - - 7 - True - False - False - - - - - - None - - - - 0 - 0 - 12 - - - - True - In - - - - 300 - True - - - - - - - - - - <b>Ingredients</b> - True - - - label_item - - - - - End - 8 - True - - - - - - - - End - 9 - True - False - False - - - - - 0 - True - False - False - - - - - - In - - - - 300 - True - True - - - - - 1 - True - - - - - - 6 - - - - 200 - 200 - None - - - - In - - - - True - True - - - - - - - - <b>Recipe</b> - True - - - label_item - - - - - 0 - True - - - - - - True - TextOnly - Copy - True - - - - 1 - True - False - False - - - - - - 200 - ButtonPressMask - - - 2 - True - - - - - 2 - True - False - False - - - - - 1 - False - - - - - - 6 - - - - - - 0 - True - - - - - - False - True - TextOnly - Stop - True - - - - 1 - True - False - False - 20 - - - - - - 0/192 - - - 2 - True - False - False - 40 - - - - - - True - TextOnly - Begin - True - - - - 3 - True - False - False - 20 - - - - - - - - 4 - True - - - - - 2 - True - False - False - - - - - - - - End - 3 - True - False - False - - - - - - - - End - 4 - True - False - False - - - - - - - - ReagentWindow - CenterOnParent - - - - 6 - 8 - - - - None - - - - 0 - 0 - 12 - - - - 3 - 3 - 6 - 6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <b>Ingredients</b> - True - - - label_item - - - - - 0 - True - - - - - - 2 - - - - 80 - True - TextOnly - Ok - True - - - - False - False - - - - - - 80 - True - TextOnly - Cancel - True - - - - 1 - False - False - - - - - End - 1 - True - False - False - - - - - \ No newline at end of file