Esempio n. 1
0
        private void removeAll_Click(object sender, EventArgs e)
        {
            bool doRemove = confirm("Confirmation", "Are you sure you would like to remove all flag overrides?");

            if (doRemove)
            {
                foreach (string flagName in flagRegistry.GetSubKeyNames())
                {
                    if (flagLookup.ContainsKey(flagName))
                    {
                        int       index = flagLookup[flagName];
                        FVariable flag  = flags[index];
                        flag.ClearEditor();
                    }

                    flagRegistry.DeleteSubKey(flagName);
                }

                overrideStatus.Text      = OVERRIDE_STATUS_OFF;
                overrideStatus.ForeColor = Color.Black;

                overrideTable.Rows.Clear();
                overrideRowLookup.Clear();
            }
        }
        private void addCustom_Click(object sender, EventArgs e)
        {
            using (FlagCreator flagCreator = new FlagCreator())
            {
                Enabled       = false;
                UseWaitCursor = true;

                flagCreator.BringToFront();
                flagCreator.ShowDialog();

                Enabled       = true;
                UseWaitCursor = false;

                if (flagCreator.DialogResult == DialogResult.OK)
                {
                    var    customFlag = flagCreator.Result;
                    string flagType   = customFlag.Type;

                    string flagValue = flagTypes
                                       .Select(pair => pair.Key)
                                       .Where(key => flagType.EndsWith(key, Program.StringFormat))
                                       .Select(key => flagTypes[key])
                                       .FirstOrDefault();

                    string flagName = flagType + customFlag.Name;
                    var    newFlag  = new FVariable(flagName, flagValue, true);

                    lastCustomFlag = newFlag;
                    addFlagOverride(newFlag);
                }
            }
        }
Esempio n. 3
0
        private void removeSelected_Click(object sender, EventArgs e)
        {
            var selectedRows = overrideDataGridView.SelectedRows;

            if (selectedRows.Count > 0)
            {
                var    selectedRow = selectedRows[0];
                string flagKey     = getFlagKeyByRow(selectedRow);

                if (flagLookup.ContainsKey(flagKey))
                {
                    int       index = flagLookup[flagKey];
                    FVariable flag  = flags[index];
                    flag.ClearEditor();
                }

                if (overrideRowLookup.ContainsKey(flagKey))
                {
                    DataRow rowToDelete = overrideRowLookup[flagKey];
                    overrideRowLookup.Remove(flagKey);
                    rowToDelete.Delete();
                }

                selectedRow.Visible = false;
                selectedRow.Dispose();

                flagRegistry.DeleteSubKey(flagKey);
            }

            if (overrideDataGridView.Rows.Count == 0)
            {
                overrideStatus.Text      = OVERRIDE_STATUS_OFF;
                overrideStatus.ForeColor = Color.Black;
            }
        }
 private void overrideSelected_Click(object sender, EventArgs e)
 {
     if (flagDataGridView.SelectedRows.Count == 1)
     {
         var       selectedRow  = flagDataGridView.SelectedRows[0];
         FVariable selectedFlag = flags[selectedRow.Index];
         addFlagOverride(selectedFlag);
     }
 }
        private void addFlagOverride(FVariable flag, bool init = false)
        {
            string key = flag.Key;

            if (!overrideRowLookup.ContainsKey(key))
            {
                RegistryKey editor = flagRegistry.GetSubKey(key);
                flag.SetEditor(editor);

                if (!init && flag.Type.EndsWith("Flag", Program.StringFormat) && !flag.Custom)
                {
                    if (bool.TryParse(flag.Value, out bool value))
                    {
                        string str = (!value)
                                     .ToString(Program.Format)
                                     .ToLower(Program.Format);

                        flag.SetValue(str);
                    }
                }

                DataRow row = overrideTable.Rows.Add
                              (
                    flag.Name,
                    flag.Type,
                    flag.Value.ToLower(Program.Format)
                              );

                overrideRowLookup.Add(key, row);
            }

            overrideStatus.Text      = OVERRIDE_STATUS_ON;
            overrideStatus.ForeColor = Color.Red;

            if (!init)
            {
                // Find the row that corresponds to the flag we added.
                var query = overrideDataGridView.Rows
                            .Cast <DataGridViewRow>()
                            .Where(rowMatchesSelectedRow);

                if (query.Any())
                {
                    // Select it.
                    var overrideRow = query.First();
                    overrideDataGridView.CurrentCell = overrideRow.Cells[0];
                }

                // Clear last custom flag.
                lastCustomFlag = null;

                // Switch to the overrides tab.
                tabs.SelectedTab = overridesTab;
            }
        }
Esempio n. 6
0
        private bool rowMatchesSelectedRow(DataGridViewRow row)
        {
            if (flagDataGridView.SelectedRows.Count == 1)
            {
                DataGridViewRow selectedRow  = flagDataGridView.SelectedRows[0];
                FVariable       selectedFlag = flags[selectedRow.Index];

                return(selectedFlag.Key == getFlagKeyByRow(row));
            }

            return(false);
        }
        private bool rowMatchesSelectedRow(DataGridViewRow row)
        {
            FVariable selectedFlag = lastCustomFlag;

            if (selectedFlag == null && flagDataGridView.SelectedRows.Count == 1)
            {
                DataGridViewRow selectedRow = flagDataGridView.SelectedRows[0];
                selectedFlag = flags[selectedRow.Index];
            }

            return(selectedFlag?.Key == getFlagKeyByRow(row));
        }
        private void overrideDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row     = overrideDataGridView.Rows[e.RowIndex];
            string          flagKey = getFlagKeyByRow(row);

            DataGridViewCell cell  = row.Cells[e.ColumnIndex];
            string           value = cell.Value as string;

            var cells    = row.Cells;
            var flagType = cells[1].Value as string;

            // Check if this input should be cancelled.
            var  format   = Program.StringFormat;
            bool badInput = false;

            if (flagType.EndsWith("Flag", format))
            {
                string test = value
                              .ToUpperInvariant()
                              .Trim();

                badInput = (test != "FALSE" && test != "TRUE");
            }
            else if (flagType.EndsWith("Int", format))
            {
                badInput = !int.TryParse(value, out int _);
            }
            else if (flagType.EndsWith("Log", format))
            {
                badInput = !byte.TryParse(value, out byte _);
            }

            if (flagLookup.ContainsKey(flagKey))
            {
                int       index = flagLookup[flagKey];
                FVariable flag  = flags[index];

                if (!badInput)
                {
                    flag.SetValue(value);
                    return;
                }

                // If we have bad input, reset the value to the original value.
                cell.Value = flag.Reset;
            }
        }
Esempio n. 9
0
        private void refreshFlags()
        {
            string search = flagSearchFilter.Text;

            flags = allFlags
                    .Where(flag => flag.Name.Contains(search))
                    .OrderBy(flag => flag.Name)
                    .ToList();

            flagLookup.Clear();

            for (int i = 0; i < flags.Count; i++)
            {
                FVariable flag = flags[i];
                flagLookup[flag.Key] = i;
                flag.Dirty           = true;
            }

            // Start populating flag browser rows.
            flagDataGridView.RowCount = flags.Count;
        }
Esempio n. 10
0
        private void addFlagOverride(FVariable flag, bool init = false)
        {
            string key = flag.Key;

            if (!overrideRowLookup.ContainsKey(key))
            {
                RegistryKey editor = flagRegistry.GetSubKey(key);
                flag.SetEditor(editor);

                DataRow row = overrideTable.Rows.Add
                              (
                    flag.Name,
                    flag.Type,
                    flag.Value
                              );

                overrideRowLookup.Add(key, row);
            }

            overrideStatus.Text      = OVERRIDE_STATUS_ON;
            overrideStatus.ForeColor = Color.Red;

            if (!init)
            {
                // Find the row that corresponds to the flag we added.
                var query = overrideDataGridView.Rows
                            .Cast <DataGridViewRow>()
                            .Where(rowMatchesSelectedRow);

                if (query.Count() > 0)
                {
                    // Select it.
                    var overrideRow = query.First();
                    overrideDataGridView.CurrentCell = overrideRow.Cells[0];
                }

                // Switch to the overrides tab.
                tabs.SelectedTab = overridesTab;
            }
        }
Esempio n. 11
0
        private void flagDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            int       index = e.RowIndex;
            FVariable flag  = flags[index];

            if (flag.Dirty)
            {
                var row = flagDataGridView.Rows[index];

                if (flag.Editor != null)
                {
                    var valueCell = row.Cells[2];
                    valueCell.Value = flag.Value;
                    applyRowColor(row, Color.Pink);
                }
                else
                {
                    applyRowColor(row, Color.White);
                }

                flag.Dirty = false;
            }
        }
Esempio n. 12
0
        private void flagDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            int row = e.RowIndex;
            int col = e.ColumnIndex;

            FVariable flag  = flags[row];
            string    value = "?";

            if (col == 0)
            {
                value = flag.Name;
            }
            else if (col == 1)
            {
                value = flag.Type;
            }
            else if (col == 2)
            {
                value = flag.Value;
            }

            e.Value = value;
        }
Esempio n. 13
0
        private async void initializeEditor()
        {
            string localAppData = Environment.GetEnvironmentVariable("LocalAppData");

            string settingsDir  = Path.Combine(localAppData, "Roblox", "ClientSettings");
            string settingsPath = Path.Combine(settingsDir, "StudioAppSettings.json");

            string lastExecVersion = versionRegistry.GetString("LastExecutedVersion");
            string versionGuid     = versionRegistry.GetString("VersionGuid");

            if (lastExecVersion != versionGuid)
            {
                // Reset the settings file.
                Directory.CreateDirectory(settingsDir);
                File.WriteAllText(settingsPath, "");

                // Create some system events for studio so we can hide the splash screen.
                SystemEvent start = new SystemEvent("FFlagExtract");
                SystemEvent show  = new SystemEvent("NoSplashScreen");

                // Run Roblox Studio briefly so we can update the settings file.
                ProcessStartInfo studioStartInfo = new ProcessStartInfo()
                {
                    FileName  = StudioBootstrapper.GetStudioPath(),
                    Arguments = $"-startEvent {start.Name} -showEvent {show.Name}"
                };

                Process studio = Process.Start(studioStartInfo);
                await start.WaitForEvent();

                FileInfo info = new FileInfo(settingsPath);

                // Wait for the settings path to be written.
                while (info.Length == 0)
                {
                    await Task.Delay(30);

                    info.Refresh();
                }

                // Nuke studio and flag the version we updated with.
                versionRegistry.SetValue("LastExecutedVersion", versionGuid);
                studio.Kill();
            }

            // Initialize flag browser
            string[] flagNames = flagRegistry.GetSubKeyNames();

            string settings = File.ReadAllText(settingsPath);
            var    json     = Program.ReadJsonDictionary(settings);

            int numFlags  = json.Count;
            var flagSetup = new List <FVariable>(numFlags);

            var autoComplete = new AutoCompleteStringCollection();

            foreach (var pair in json)
            {
                string key     = pair.Key,
                         value = pair.Value;

                FVariable flag = new FVariable(key, value);
                autoComplete.Add(flag.Name);
                flagSetup.Add(flag);

                if (flagNames.Contains(flag.Name))
                {
                    // Update what the flag should be reset to if removed?
                    RegistryKey flagKey = flagRegistry.GetSubKey(flag.Name);
                    flagKey.SetValue("Reset", value);

                    // Set the flag's editor.
                    flag.SetEditor(flagKey);
                }
            }

            flagSearchFilter.AutoCompleteCustomSource = autoComplete;

            allFlags = flagSetup
                       .OrderBy(flag => flag.Name)
                       .ToList();

            refreshFlags();

            // Initialize override table.
            overrideTable = new DataTable();

            foreach (DataGridViewColumn column in overrideDataGridView.Columns)
            {
                overrideTable.Columns.Add(column.DataPropertyName);
            }

            DataView overrideView = new DataView(overrideTable);

            overrideView.Sort = "Name";

            foreach (string flagName in flagNames)
            {
                if (flagLookup.ContainsKey(flagName))
                {
                    int       index = flagLookup[flagName];
                    FVariable flag  = flags[index];
                    addFlagOverride(flag, true);
                }
            }

            overrideStatus.Visible          = true;
            overrideDataGridView.DataSource = overrideView;
        }