Ejemplo n.º 1
0
        // ------------------------------------------------------------------------------------
        // Content & State

        // Enable or disable the settings menu
        public void SetState(bool state)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Setting state to " + state); // Write to console
            if (state == true)                                                                      // If enabling window
            {
                tempSettings = CloneSettings(Configuration.Instance.settings);                      // Clone configuration settings to temp
                SetUiState();                                                                       // Set UI State
            }
            menuSettingsParent.SetActive(state);                                                    // Set state
        }
Ejemplo n.º 2
0
        Configuration.Settings CloneSettings(Configuration.Settings input)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Cloning configuration settings");                                      // Write to console
            Configuration.Settings output       = new Configuration.Settings();                                                               // Create new instance
            BindingFlags           bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; // Set binding flags

            FieldInfo[] settingsFields = typeof(Configuration.Settings).GetFields(bindingFlags);                                              // Get fields
            for (int i = 0; i < settingsFields.Length; i++)
            {
                FieldInfo field = input.GetType().GetField(settingsFields[i].Name);        // Geyt field info
                var       value = field.GetValue(input);                                   // Get value from  local temp
                field.SetValue(output, System.Convert.ChangeType(value, field.FieldType)); // Set value to configuration
            }
            return(output);                                                                // Return
        }