Beispiel #1
0
        public void Initialize(
            string varFilePath = null,
            List <VariableGroup> allVariableGroupsNullable     = null,
            List <VariableGroup> visibleVariableGroupsNullable = null)
        {
            if (IsInitialized)
            {
                throw new ArgumentOutOfRangeException("WatchVariableFlowLayoutPanel already initialized");
            }

            List <VariableGroup> allVariableGroups = allVariableGroupsNullable ?? new List <VariableGroup>();

            if (allVariableGroups.Contains(VariableGroup.Custom))
            {
                throw new ArgumentOutOfRangeException();
            }
            allVariableGroups.Add(VariableGroup.Custom);

            List <VariableGroup> visibleVariableGroups = visibleVariableGroupsNullable ?? new List <VariableGroup>();

            if (visibleVariableGroups.Contains(VariableGroup.Custom))
            {
                throw new ArgumentOutOfRangeException();
            }
            visibleVariableGroups.Add(VariableGroup.Custom);

            _varFilePath = varFilePath;
            _allGroups.AddRange(allVariableGroups);
            _initialVisibleGroups.AddRange(visibleVariableGroups);
            _visibleGroups.AddRange(visibleVariableGroups);

            _selectionToolStripItems =
                WatchVariableSelectionUtilities.CreateSelectionToolStripItems(
                    () => new List <WatchVariableControl>(_selectedWatchVarControls), this);

            List <WatchVariableControlPrecursor> precursors = new List <WatchVariableControlPrecursor>();

            if (_varFilePath != null)
            {
                precursors = XmlConfigParser.OpenWatchVariableControlPrecursors(_varFilePath);
                //precursors = WatchVariableData.GetPrecursors(_varFilePath);
            }

            AddVariables(precursors.ConvertAll(precursor => precursor.CreateWatchVariableControl()));
            AddItemsToContextMenuStrip();

            IsInitialized = true;

            ///////////////////////////////FOR DEBUGGING///////////////////////////////////////
            //Config.Print();
            //Config.Print("[@\"" + varFilePath + "\"] = new List<WatchVariableControlPrecursor>()");
            //Config.Print("{");
            //foreach (WatchVariableControlPrecursor precursor in precursors)
            //{
            //    Config.Print("    " + precursor.ToStringForCode() + ",");
            //}
            //Config.Print("},");
            //Config.Print();
            ///////////////////////////////////////////////////////////////////////////////////
        }
        private void AddItemsToContextMenuStrip()
        {
            ToolStripMenuItem resetVariablesItem = new ToolStripMenuItem("Reset Variables");

            resetVariablesItem.Click += (sender, e) => ResetVariables();

            ToolStripMenuItem clearAllButHighlightedItem = new ToolStripMenuItem("Clear All But Highlighted");

            clearAllButHighlightedItem.Click += (sender, e) => ClearAllButHighlightedVariables();

            ToolStripMenuItem fixVerticalScrollItem = new ToolStripMenuItem("Fix Vertical Scroll");

            fixVerticalScrollItem.Click += (sender, e) => FixVerticalScroll();

            ToolStripMenuItem openSaveClearItem = new ToolStripMenuItem("Open / Save / Clear ...");

            ControlUtilities.AddDropDownItems(
                openSaveClearItem,
                new List <string>()
            {
                "Open", "Save in Place", "Save As", "Clear"
            },
                new List <Action>()
            {
                () => OpenVariables(),
                () => SaveVariablesInPlace(),
                () => SaveVariables(),
                () => ClearVariables(),
            });

            ToolStripMenuItem doToAllVariablesItem = new ToolStripMenuItem("Do to all variables...");

            WatchVariableSelectionUtilities.CreateSelectionToolStripItems(
                () => GetCurrentVariableControls(), this)
            .ForEach(item => doToAllVariablesItem.DropDownItems.Add(item));

            ToolStripMenuItem filterVariablesItem = new ToolStripMenuItem("Filter Variables...");

            _filteringDropDownItems = _allGroups.ConvertAll(varGroup => CreateFilterItem(varGroup));
            UpdateFilterItemCheckedStatuses();
            _filteringDropDownItems.ForEach(item => filterVariablesItem.DropDownItems.Add(item));
            filterVariablesItem.DropDown.AutoClose   = false;
            filterVariablesItem.DropDown.MouseLeave += (sender, e) => { filterVariablesItem.DropDown.Close(); };

            ContextMenuStrip.Items.Add(resetVariablesItem);
            ContextMenuStrip.Items.Add(clearAllButHighlightedItem);
            ContextMenuStrip.Items.Add(fixVerticalScrollItem);
            ContextMenuStrip.Items.Add(openSaveClearItem);
            ContextMenuStrip.Items.Add(doToAllVariablesItem);
            ContextMenuStrip.Items.Add(filterVariablesItem);
        }
Beispiel #3
0
        public void Initialize(string varFilePath = null)
        {
            _varFilePath = varFilePath;
            if (varFilePath != null && !System.IO.File.Exists(varFilePath))
            {
                return;
            }
            DeferActionToUpdate(nameof(Initialize), () =>
            {
                SuspendLayout();

                _selectionToolStripItems =
                    WatchVariableSelectionUtilities.CreateSelectionToolStripItems(
                        () => new List <WatchVariableControl>(_selectedWatchVarControls), this);

                List <WatchVariableControlPrecursor> precursors = _varFilePath == null
                    ? new List <WatchVariableControlPrecursor>()
                    : XmlConfigParser.OpenWatchVariableControlPrecursors(_varFilePath);

                foreach (var watchVarControl in precursors.ConvertAll(precursor => precursor.CreateWatchVariableControl()))
                {
                    _watchVarControls.Add(watchVarControl);
                    watchVarControl.SetPanel(this);
                }


                MouseDown += (_, __) => { if (__.Button == MouseButtons.Right)
                                          {
                                              ShowContextMenu();
                                          }
                };

                _allGroups.AddRange(new List <VariableGroup>(new[] { VariableGroup.Custom }));
                _initialVisibleGroups.AddRange(new List <VariableGroup>(new[] { VariableGroup.Custom }));
                _visibleGroups.AddRange(new List <VariableGroup>(new[] { VariableGroup.Custom }));
                if (!hasGroups)
                {
                    UpdateControlsBasedOnFilters();
                }

                ResumeLayout();
            });
        }
        public void Initialize(
            string varFilePath = null,
            List <VariableGroup> allVariableGroupsNullable     = null,
            List <VariableGroup> visibleVariableGroupsNullable = null)
        {
            List <VariableGroup> allVariableGroups = allVariableGroupsNullable ?? new List <VariableGroup>();

            if (allVariableGroups.Contains(VariableGroup.Custom))
            {
                throw new ArgumentOutOfRangeException();
            }
            allVariableGroups.Add(VariableGroup.Custom);

            List <VariableGroup> visibleVariableGroups = visibleVariableGroupsNullable ?? new List <VariableGroup>();

            if (visibleVariableGroups.Contains(VariableGroup.Custom))
            {
                throw new ArgumentOutOfRangeException();
            }
            visibleVariableGroups.Add(VariableGroup.Custom);

            _varFilePath = varFilePath;
            _allGroups.AddRange(allVariableGroups);
            _initialVisibleGroups.AddRange(visibleVariableGroups);
            _visibleGroups.AddRange(visibleVariableGroups);

            _selectionToolStripItems =
                WatchVariableSelectionUtilities.CreateSelectionToolStripItems(
                    () => new List <WatchVariableControl>(_selectedWatchVarControls), this);

            List <WatchVariableControlPrecursor> precursors = _varFilePath == null
                ? new List <WatchVariableControlPrecursor>()
                : XmlConfigParser.OpenWatchVariableControlPrecursors(_varFilePath);

            AddVariables(precursors.ConvertAll(precursor => precursor.CreateWatchVariableControl()));
            AddItemsToContextMenuStrip();
        }
Beispiel #5
0
        private void AddItemsToContextMenuStrip()
        {
            ToolStripMenuItem resetVariablesItem = new ToolStripMenuItem("Reset Variables");

            resetVariablesItem.Click += (sender, e) => ResetVariables();

            ToolStripMenuItem clearAllButHighlightedItem = new ToolStripMenuItem("Clear All But Highlighted");

            clearAllButHighlightedItem.Click += (sender, e) => ClearAllButHighlightedVariables();

            ToolStripMenuItem fixVerticalScrollItem = new ToolStripMenuItem("Fix Vertical Scroll");

            fixVerticalScrollItem.Click += (sender, e) => FixVerticalScroll();

            ToolStripMenuItem addCustomVariablesItem = new ToolStripMenuItem("Add Custom Variables");

            addCustomVariablesItem.Click += (sender, e) =>
            {
                VariableCreationForm form = new VariableCreationForm();
                form.Initialize(this);
                form.Show();
            };

            ToolStripMenuItem addMappingVariablesItem = new ToolStripMenuItem("Add Mapping Variables");

            addMappingVariablesItem.Click += (sender, e) => AddVariables(MappingConfig.GetVariables());

            ToolStripMenuItem addDummyVariableItem = new ToolStripMenuItem("Add Dummy Variable...");
            List <string>     types = new List <string>(TypeUtilities.InGameTypeList);

            types.Add("string");
            foreach (string typeString in types)
            {
                ToolStripMenuItem typeItem = new ToolStripMenuItem(typeString);
                addDummyVariableItem.DropDownItems.Add(typeItem);
                typeItem.Click += (sender, e) =>
                {
                    int numEntries = 1;
                    if (KeyboardUtilities.IsCtrlHeld())
                    {
                        string numEntriesString = DialogUtilities.GetStringFromDialog(labelText: "Enter Num Vars:");
                        if (numEntriesString == null)
                        {
                            return;
                        }
                        int parsed = ParsingUtilities.ParseInt(numEntriesString);
                        parsed     = Math.Max(parsed, 0);
                        numEntries = parsed;
                    }

                    List <WatchVariableControl> controls = new List <WatchVariableControl>();
                    for (int i = 0; i < numEntries; i++)
                    {
                        string        specialType   = WatchVariableSpecialUtilities.AddDummyEntry(typeString);
                        WatchVariable watchVariable =
                            new WatchVariable(
                                name: specialType,
                                memoryTypeName: null,
                                specialType: specialType,
                                baseAddressType: BaseAddressTypeEnum.None,
                                offsetUS: null,
                                offsetJP: null,
                                offsetSH: null,
                                offsetEU: null,
                                offsetDefault: null,
                                mask: null,
                                shift: null,
                                handleMapping: true);
                        WatchVariableControlPrecursor precursor =
                            new WatchVariableControlPrecursor(
                                name: specialType,
                                watchVar: watchVariable,
                                subclass: typeString == "string" ? WatchVariableSubclass.String : WatchVariableSubclass.Number,
                                backgroundColor: null,
                                displayType: null,
                                roundingLimit: null,
                                useHex: null,
                                invertBool: null,
                                isYaw: null,
                                coordinate: null,
                                groupList: new List <VariableGroup>()
                        {
                            VariableGroup.Custom
                        });
                        WatchVariableControl control = precursor.CreateWatchVariableControl();
                        controls.Add(control);
                    }
                    AddVariables(controls);
                };
            }

            ToolStripMenuItem openSaveClearItem = new ToolStripMenuItem("Open / Save / Clear ...");

            ControlUtilities.AddDropDownItems(
                openSaveClearItem,
                new List <string>()
            {
                "Open", "Open as Pop Out", "Save in Place", "Save As", "Clear"
            },
                new List <Action>()
            {
                () => OpenVariables(),
                () => OpenVariablesAsPopOut(),
                () => SaveVariablesInPlace(),
                () => SaveVariables(),
                () => ClearVariables(),
            });

            ToolStripMenuItem doToAllVariablesItem = new ToolStripMenuItem("Do to all variables...");

            WatchVariableSelectionUtilities.CreateSelectionToolStripItems(
                () => GetCurrentVariableControls(), this)
            .ForEach(item => doToAllVariablesItem.DropDownItems.Add(item));

            ToolStripMenuItem filterVariablesItem = new ToolStripMenuItem("Filter Variables...");

            _filteringDropDownItems = _allGroups.ConvertAll(varGroup => CreateFilterItem(varGroup));
            UpdateFilterItemCheckedStatuses();
            _filteringDropDownItems.ForEach(item => filterVariablesItem.DropDownItems.Add(item));
            filterVariablesItem.DropDown.MouseEnter += (sender, e) =>
            {
                filterVariablesItem.DropDown.AutoClose = false;
            };
            filterVariablesItem.DropDown.MouseLeave += (sender, e) =>
            {
                filterVariablesItem.DropDown.AutoClose = true;
                filterVariablesItem.DropDown.Close();
            };

            ContextMenuStrip.Items.Add(resetVariablesItem);
            ContextMenuStrip.Items.Add(clearAllButHighlightedItem);
            ContextMenuStrip.Items.Add(fixVerticalScrollItem);
            ContextMenuStrip.Items.Add(addCustomVariablesItem);
            ContextMenuStrip.Items.Add(addMappingVariablesItem);
            ContextMenuStrip.Items.Add(addDummyVariableItem);
            ContextMenuStrip.Items.Add(openSaveClearItem);
            ContextMenuStrip.Items.Add(doToAllVariablesItem);
            ContextMenuStrip.Items.Add(filterVariablesItem);
        }