Ejemplo n.º 1
0
        /// <summary>
        /// Helps to pick a variable
        /// </summary>
        /// <returns>returns a string that contains a variable name</returns>
        public static VariableCollectionModel Pick()
        {
            VariablePicker variablePicker = new VariablePicker();

            new MetroWindow()
            {
                //Owner=;
                Content = variablePicker,
                Height  = 350,
                Width   = 300,
                ShowMaxRestoreButton = false,
                ShowMinButton        = false,
                ShowCloseButton      = false,
                //Top = Cursor.Position.X,
                //Left = Cursor.Position.Y
            }
            .ShowDialog();

            if (variablePicker.selectedVariable != null)
            {
                return(variablePicker.selectedVariable);
            }

            return(null);
        }
Ejemplo n.º 2
0
        private void variable_picker_Click(object sender, RoutedEventArgs e)
        {
            VariablePicker variablePicker = new VariablePicker();

            new MetroWindow()
            {
                Content = variablePicker, Height = 350, Width = 300, ShowMaxRestoreButton = false, ShowMinButton = false, ShowCloseButton = false, WindowStartupLocation = WindowStartupLocation.Manual
            }.ShowDialog();

            if (variablePicker.selectedVariable != null)
            {
                // textToParse_text.Text = variablePicker.selectedVariable.VariableName;
            }
        }
Ejemplo n.º 3
0
        private void variableToolStripMenuItem_Click(object sender, EventArgs e)
        {
            VariablePicker variablePicker = new VariablePicker(ScopeVariables, Variable);

            if (variablePicker.ShowDialog() == DialogResult.OK)
            {
                if (variablePicker.Variable == null)
                {
                    return;
                }
                VariableDataControl vvariable = new VariableDataControl(variablePicker.Variable, ScopeVariables);
                SingleInstruction.Instruction = variablePicker.Variable;
                Panel.Controls.Clear();
                Panel.Controls.Add(vvariable);
            }
        }
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            VariablePicker variablePicker = new VariablePicker(LocalVariables, SelectetVariable);

            if (variablePicker.ShowDialog() == DialogResult.OK)
            {
                if (variablePicker.Variable == null)
                {
                    return;
                }
                VariableDataControl vvariable = new VariableDataControl(variablePicker.Variable, LocalVariables);
                ThreeAddressInstruction.RightInstruction = variablePicker.Variable;
                RightPanel.Controls.Clear();
                RightPanel.Controls.Add(vvariable);
            }
        }
Ejemplo n.º 5
0
        public List <BaseWidget> CreateWindow(dynamic Utility)
        {
            this.Text = new List <string>();
            foreach (object o in Utility.ParamAsArray("choices"))
            {
                this.Text.Add((string)o);
            }
            if (this.Text.Count < 8)
            {
                this.Text.AddRange(new string[8 - this.Text.Count]);
            }
            this.Conditions = Utility.HasParam("conditions") ? Utility.ParamAsArray("conditions") : new List <dynamic>();
            DisallowCancel  = Utility.ParamIsString("cancel") && Utility.ParamAsString("cancel") == ":disallow";
            BranchCancel    = Utility.ParamIsString("cancel") && Utility.ParamAsString("cancel") == ":branch";
            ChoiceCancel    = Utility.ParamIsInt("cancel") ? Utility.ParamAsInt("cancel") : -1;

            TabView         = new TabView("tabview");
            TabView.X       = 1;
            TabView.Y       = 24;
            TabView.Width   = 345;
            TabView.Height  = 306;
            SimpleContainer = TabView.NewTab("Simple");

            SimpleTooAdvancedLabel         = new MultilineLabel("tooadvanced", SimpleContainer);
            SimpleTooAdvancedLabel.X       = 30;
            SimpleTooAdvancedLabel.Y       = 105;
            SimpleTooAdvancedLabel.Width   = 285;
            SimpleTooAdvancedLabel.Text    = "There are active options in the Advanced tab. Please disable the advanced features, or use the Advanced tab.";
            SimpleTooAdvancedLabel.Visible = false;
            SimpleCancelLabel         = new Label("simplecancellabel", SimpleContainer);
            SimpleCancelLabel.X       = 252;
            SimpleCancelLabel.Y       = 4;
            SimpleCancelLabel.Text    = "On Cancel:";
            SimpleDisallowButton      = new RadioButton("simpledisallow", SimpleContainer);
            SimpleDisallowButton.X    = 252;
            SimpleDisallowButton.Y    = 21;
            SimpleDisallowButton.Text = "Disallow";
            SimpleDisallowButton.OnSelectionChanged += delegate()
            {
                if (SimpleDisallowButton.Selected)
                {
                    DisallowCancel = true;
                    BranchCancel   = false;
                    ChoiceCancel   = -1;
                    return(Sync(Utility));
                }
                return(Refresh());
            };
            SimpleBranchButton      = new RadioButton("simplebranch", SimpleContainer);
            SimpleBranchButton.X    = 252;
            SimpleBranchButton.Y    = 41;
            SimpleBranchButton.Text = "Branch";
            SimpleBranchButton.OnSelectionChanged += delegate()
            {
                if (SimpleBranchButton.Selected)
                {
                    DisallowCancel = false;
                    BranchCancel   = true;
                    ChoiceCancel   = -1;
                    return(Sync(Utility));
                }
                return(Refresh());
            };

            this.SimpleChoiceLabels    = new List <Label>();
            this.SimpleChoiceTextBoxes = new List <TextBox>();
            this.SimpleChoiceButtons   = new List <RadioButton>();

            List <object> choices = Utility.ParamAsArray("choices");

            for (int i = 0; i < 8; i++)
            {
                Label       label   = new Label($"choice{i + 1}label", SimpleContainer);
                TextBox     textbox = new TextBox($"choice{i + 1}text", SimpleContainer);
                RadioButton choice  = new RadioButton($"choice{i + 1}button", SimpleContainer);

                label.X    = 18;
                label.Y    = 14 + 33 * i;
                label.Text = $"Choice {i + 1}:";
                SimpleChoiceLabels.Add(label);

                textbox.X              = 77;
                textbox.Y              = 9 + 33 * i;
                textbox.Width          = 150;
                textbox.Height         = 27;
                textbox.OnTextChanged += delegate()
                {
                    choice.Enabled = !string.IsNullOrEmpty(textbox.Text);
                    this.Text[SimpleChoiceTextBoxes.IndexOf(textbox)] = textbox.Text;
                    int index = SimpleChoiceTextBoxes.IndexOf(textbox);
                    if (string.IsNullOrEmpty(textbox.Text))
                    {
                        this.Text.RemoveAt(index);
                        if (index < this.Conditions.Count)
                        {
                            this.Conditions.RemoveAt(index);
                        }
                    }
                    return(Refresh(choice, Sync(Utility)));
                };
                SimpleChoiceTextBoxes.Add(textbox);

                choice.X    = 252;
                choice.Y    = 61 + 20 * i;
                choice.Text = $"Choice {i + 1}";
                choice.OnSelectionChanged += delegate()
                {
                    if (choice.Selected)
                    {
                        DisallowCancel = false;
                        BranchCancel   = false;
                        ChoiceCancel   = SimpleChoiceButtons.IndexOf(choice);
                        return(Sync(Utility));
                    }
                    return(Refresh());
                };
                SimpleChoiceButtons.Add(choice);
            }

            AdvContainer                = TabView.NewTab("Advanced");
            AdvChoiceLabel              = new Label("choiceslabel", AdvContainer);
            AdvChoiceLabel.X            = 11;
            AdvChoiceLabel.Text         = "Choices:";
            AdvList                     = new List("choicelist", AdvContainer);
            AdvList.X                   = 8;
            AdvList.Y                   = 17;
            AdvList.Width               = 141;
            AdvList.Height              = 121;
            AdvList.OnSelectionChanged += delegate()
            {
                return(UpdateSelection());
            };
            for (int i = 0; i < choices.Count; i++)
            {
                AdvList.Items.Add((string)choices[i]);
            }
            AdvAddButton                   = new Button("add", AdvContainer);
            AdvAddButton.X                 = 4;
            AdvAddButton.Y                 = 138;
            AdvAddButton.Width             = 74;
            AdvAddButton.Height            = 31;
            AdvAddButton.Text              = "Add";
            AdvRemoveButton                = new Button("remove", AdvContainer);
            AdvRemoveButton.X              = 78;
            AdvRemoveButton.Y              = 138;
            AdvRemoveButton.Width          = 74;
            AdvRemoveButton.Height         = 31;
            AdvRemoveButton.Text           = "Remove";
            AdvEntryTextLabel              = new Label("textlabel", AdvContainer);
            AdvEntryTextLabel.X            = 157;
            AdvEntryTextLabel.Y            = 22;
            AdvEntryTextLabel.Text         = "Text:";
            AdvEntryTextLabel.Enabled      = false;
            AdvEntryTextBox                = new TextBox("textbox", AdvContainer);
            AdvEntryTextBox.X              = 187;
            AdvEntryTextBox.Y              = 17;
            AdvEntryTextBox.Width          = 150;
            AdvEntryTextBox.Height         = 27;
            AdvEntryTextBox.Enabled        = false;
            AdvEntryTextBox.OnTextChanged += delegate()
            {
                if (AdvList.Index == -1)
                {
                    return(Refresh());
                }
                AdvList.Items[AdvList.Index] = AdvEntryTextBox.Text;
                AdvTreatAsChoiceBox.Items    = AdvList.Items;
                this.Text[AdvList.Index]     = AdvEntryTextBox.Text;
                return(Refresh(AdvList, AdvTreatAsChoiceBox, Sync(Utility)));
            };
            AdvShowIfButton                 = new CheckBox("showif", AdvContainer);
            AdvShowIfButton.X               = 158;
            AdvShowIfButton.Y               = 49;
            AdvShowIfButton.Text            = "Show if:";
            AdvShowIfButton.Enabled         = false;
            AdvShowIfButton.OnCheckChanged += delegate()
            {
                AdvConditions.Enabled = AdvShowIfButton.Checked;
                if (!AdvShowIfButton.Checked)
                {
                    AdvConditions.Conditions = null;
                    if (AdvList.Index < this.Conditions.Count)
                    {
                        this.Conditions[AdvList.Index] = null;
                    }
                }
                AdvEditConditionsButton.Enabled = AdvShowIfButton.Checked;
                return(Refresh(AdvConditions, AdvEditConditionsButton, Sync(Utility)));
            };
            AdvConditions                      = new ConditionBox("conditions", AdvContainer);
            AdvConditions.X                    = 178;
            AdvConditions.Y                    = 68;
            AdvConditions.Width                = 159;
            AdvConditions.Height               = 65;
            AdvConditions.Enabled              = false;
            AdvConditions.OnConditionsChanged += delegate()
            {
                if (AdvConditions.Conditions.Count == 0)
                {
                    AdvShowIfButton.Checked = false;
                    if (AdvList.Index < Conditions.Count)
                    {
                        Conditions[AdvList.Index] = null;
                    }
                }
                else
                {
                    if (AdvList.Index < Conditions.Count)
                    {
                        Conditions[AdvList.Index] = AdvConditions.Conditions;
                    }
                    else
                    {
                        for (int i = Conditions.Count; i < AdvList.Index; i++)
                        {
                            Conditions.Add(null);
                        }
                        Conditions.Add(AdvConditions.Conditions);
                    }
                }
                return(Refresh(AdvShowIfButton, Sync(Utility)));
            };
            AdvEditConditionsButton            = new Button("editconditions", AdvContainer);
            AdvEditConditionsButton.X          = 282;
            AdvEditConditionsButton.Y          = 133;
            AdvEditConditionsButton.Width      = 59;
            AdvEditConditionsButton.Height     = 31;
            AdvEditConditionsButton.Text       = "Edit";
            AdvEditConditionsButton.Enabled    = false;
            AdvEditConditionsButton.OnPressed += delegate()
            {
                AdvConditions.Open();
                return(Refresh());
            };
            AdvCancelLabel         = new Label("advcancellabel", AdvContainer);
            AdvCancelLabel.X       = 8;
            AdvCancelLabel.Y       = 172;
            AdvCancelLabel.Text    = "When cancelled:";
            AdvDisallowButton      = new RadioButton("advdisallow", AdvContainer);
            AdvDisallowButton.X    = 9;
            AdvDisallowButton.Y    = 192;
            AdvDisallowButton.Text = "Disallow";
            AdvDisallowButton.OnSelectionChanged += delegate()
            {
                if (AdvDisallowButton.Selected)
                {
                    DisallowCancel = true;
                    BranchCancel   = false;
                    ChoiceCancel   = -1;
                    return(Sync(Utility));
                }
                return(Refresh());
            };
            AdvBranchButton      = new RadioButton("advbranch", AdvContainer);
            AdvBranchButton.X    = 9;
            AdvBranchButton.Y    = 212;
            AdvBranchButton.Text = "Branch";
            AdvBranchButton.OnSelectionChanged += delegate()
            {
                if (AdvBranchButton.Selected)
                {
                    DisallowCancel = false;
                    BranchCancel   = true;
                    ChoiceCancel   = -1;
                    return(Sync(Utility));
                }
                return(Refresh());
            };
            AdvTreatAsChoiceButton      = new RadioButton("advtreataschoice", AdvContainer);
            AdvTreatAsChoiceButton.X    = 9;
            AdvTreatAsChoiceButton.Y    = 232;
            AdvTreatAsChoiceButton.Text = "Treat as choice";
            AdvTreatAsChoiceButton.OnSelectionChanged += delegate()
            {
                if (AdvTreatAsChoiceButton.Selected)
                {
                    DisallowCancel = false;
                    BranchCancel   = false;
                    ChoiceCancel   = 0;
                    return(Sync(Utility));
                }
                return(Refresh());
            };
            AdvTreatAsChoiceBox                    = new Dropdown("advchoicebox", AdvContainer);
            AdvTreatAsChoiceBox.X                  = 30;
            AdvTreatAsChoiceBox.Y                  = 251;
            AdvTreatAsChoiceBox.Width              = 123;
            AdvTreatAsChoiceBox.Height             = 25;
            AdvTreatAsChoiceBox.Items              = AdvList.Items;
            AdvOutcomeLabel                        = new Label("outcome", AdvContainer);
            AdvOutcomeLabel.X                      = 172;
            AdvOutcomeLabel.Y                      = 195;
            AdvOutcomeLabel.Text                   = "Outcome:";
            AdvBranchCommandButton                 = new CheckBox("branchcommand", AdvContainer);
            AdvBranchCommandButton.X               = 173;
            AdvBranchCommandButton.Y               = 212;
            AdvBranchCommandButton.Text            = "Branch this command";
            AdvBranchCommandButton.Checked         = true;
            AdvBranchCommandButton.OnCheckChanged += delegate()
            {
                return(Sync(Utility));
            };
            if (Utility.HasParam("branch") && !Utility.ParamAsBool("branch"))
            {
                AdvBranchCommandButton.Checked = false;
            }
            AdvStoreInVariableButton      = new CheckBox("storeinvar", AdvContainer);
            AdvStoreInVariableButton.X    = 173;
            AdvStoreInVariableButton.Y    = 232;
            AdvStoreInVariableButton.Text = "Store in Game Variable";
            if (Utility.HasParam("variable") && Utility.ParamIsHash("variable"))
            {
                AdvStoreInVariableButton.Checked = true;
            }
            AdvStoreInVariableButton.OnCheckChanged += delegate()
            {
                AdvVariablePicker.Enabled = AdvStoreInVariableButton.Checked;
                return(Sync(Utility));
            };
            AdvVariablePicker         = new VariablePicker("variablepicker", AdvContainer);
            AdvVariablePicker.X       = 194;
            AdvVariablePicker.Y       = 251;
            AdvVariablePicker.Width   = 143;
            AdvVariablePicker.Height  = 25;
            AdvVariablePicker.Enabled = false;
            if (AdvStoreInVariableButton.Checked)
            {
                AdvVariablePicker.GroupID    = (int)Utility.ParamAsHash("variable")[":group_id"];
                AdvVariablePicker.VariableID = (int)Utility.ParamAsHash("variable")[":variable_id"];
                AdvVariablePicker.Enabled    = true;
            }

            return(Refresh(TabView,
                           SimpleContainer,
                           SimpleTooAdvancedLabel, SimpleCancelLabel, SimpleDisallowButton, SimpleBranchButton, SimpleChoiceLabels, SimpleChoiceTextBoxes, SimpleChoiceButtons,
                           AdvContainer,
                           AdvChoiceLabel, AdvAddButton, AdvRemoveButton, AdvEntryTextLabel, AdvShowIfButton, AdvConditions, AdvEditConditionsButton,
                           AdvCancelLabel, AdvOutcomeLabel, AdvBranchCommandButton, AdvStoreInVariableButton, AdvVariablePicker, Sync(Utility)));
        }