Пример #1
0
    protected override void InitializeTweakables()
    {
        agility = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Agility");

        averageThrust = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Thrust");

        maxThrust = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Maximum Thrust");
        maxThrust.unit = "%";

        energyEfficiency = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Energy Efficiency");
        energyEfficiency.unit = "%";

        maxThrust.scaleMin             = false;
        maxThrust.MaxCost              = 20;
        energyEfficiency.MaxDesignCost = 15;
        energyEfficiency.MaxCost       = 15;
        energyEfficiency.MaxNetPower   = 1;
        energyEfficiency.scaleMin      = false;
        tweakables.Add(agility);
        tweakables.Add(averageThrust);
        tweakables.Add(maxThrust);
        tweakables.Add(energyEfficiency);
    }
Пример #2
0
    protected override void InitializeTweakables()
    {
        type = Tweakable.MakeTweakable(
            this,
            TweakableType.Dropdown,
            "Shield Type");

        strength = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Shield Strength");

        rechargeTime = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Recharge Time");
        rechargeTime.unit = "s";

        tweakables.Add(type);
        tweakables.Add(strength);
        tweakables.Add(rechargeTime);

        strength.MaxNetPower      = 35;
        rechargeTime.MaxNetPower  = 25;
        type.automaticCalculation = false;
        type.dropdownLabels.Add("Shield Generator");
        type.dropdownLabels.Add("Deflector Shield");
    }
    public void UpdateFromTweakable(Tweakable t)
    {
        if (!updating)
        {
            if (t.tweakableType == TweakableType.Dropdown)
            {
                SetDropdownElements(true);
                dropdownText.text = tweakable.tweakableName;
                dropdown.ClearOptions();
                foreach (string s in tweakable.dropdownLabels)
                {
                    Dropdown.OptionData option = new Dropdown.OptionData();
                    option.text = s;
                    dropdown.options.Add(option);
                }
                dropdown.value = tweakable.Value;
                dropdown.RefreshShownValue();
                dropdown.onValueChanged.AddListener(delegate { UpdateFromDropdown(); });
            }
            else if (t.tweakableType == TweakableType.Slider)
            {
                SetSliderElements(true);
                sliderText.text = tweakable.tweakableName;

                slider.minValue    = tweakable.MinValue;
                slider.maxValue    = tweakable.MaxValue;
                slider.value       = tweakable.Value;
                sliderMinText.text = slider.minValue.ToString() + tweakable.unit;
                sliderMaxText.text = slider.maxValue.ToString() + tweakable.unit;

                sliderDisplay.text = Mathf.FloorToInt(slider.value).ToString() + tweakable.unit;
                slider.onValueChanged.AddListener(delegate { UpdateFromSlider(); });
            }
        }
    }
Пример #4
0
        public void AddTweakControl(TweakControl tweakControl)
        {
            Tweakable t = new Tweakable();

            // Add label
            {
                t.Label      = new Label();
                t.Label.Text = tweakControl.Attr.Name;

                _leftPanel.Controls.Add(t.Label);

                t.Label.Left   = 0;
                t.Label.Width  = t.Label.Parent.Width;
                t.Label.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            }

            // Add tweak control
            {
                t.TweakControl = tweakControl;

                _rightPanel.Controls.Add(t.TweakControl);

                t.TweakControl.Left   = 0;
                t.TweakControl.Width  = t.TweakControl.Parent.Width;
                t.TweakControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

                //t.TweakControl.Tweak += this.HandleTweak;
                t.TweakControl.Tag = t;
            }

            _tweakables.Add(t);

            ArrangeControls();
        }
 public void DisplayTweakable(Tweakable t)
 {
     tweakable = t;
     tweakable.OnTweakableChangedEvent += UpdateFromTweakable;
     Clear();
     UpdateFromTweakable(t);
 }
        public TweakExecuteControl(Tweakable tweakable, string currentState)
            : base()
        {
            this.tweakable = tweakable;
            this.state = currentState;
            this.Padding = new Padding(0, 0, 7, 0);

            Text = "execute";

            menu = new ContextMenuStrip();
            menu.ShowCheckMargin = false;
            menu.ShowImageMargin = false;
            menu.ShowItemToolTips = false;

            foreach (string setting in tweakable.GetAvailableSettings())
            {
                ToolStripItem item = new ToolStripButton(setting);
                if (setting == currentState)
                {
                    item.Enabled = false;
                }

                item.Click += Item_Click;

                menu.Items.Add(item);
            }
        }
 public void DisplayTweakable(Tweakable t)
 {
     Clear();
     tweakable = t;
     text.text = tweakable.tweakableName + ":" + tweakable.Value.ToString();
     GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, LayoutUtility.GetPreferredWidth(text.rectTransform) + 8);
 }
 public void Dispose()
 {
     if (disposeTweakable && AutoInt != null)
     {
         AutoInt.Dispose();
     }
     else
     {
         AutoInt = null;
     }
 }
Пример #9
0
    public static Tweakable MakeTweakable(
        Part _part,
        TweakableType _tweakableType,
        string _tweakableName)
    {
        Tweakable t = new Tweakable(_tweakableName);

        t.part                     = _part;
        t.tweakableType            = _tweakableType;
        t.value                    = t.MinValue;
        t.OnTweakableChangedEvent += t.part.TweakableUpdate;
        return(t);
    }
Пример #10
0
    protected override void InitializeTweakables()
    {
        range = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Range");
        resolution = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Resolution");

        tweakables.Add(range);
        tweakables.Add(resolution);
    }
Пример #11
0
    protected override void InitializeTweakables()
    {
        caliber = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Caliber");
        caliber.unit = "mm";

        reload = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Reload Time");
        reload.unit = "s";

        turrets = Tweakable.MakeTweakable(
            this,
            TweakableType.Dropdown,
            "Turret Setup");

        weaponType = Tweakable.MakeTweakable(
            this,
            TweakableType.Dropdown,
            "Weapon Type");

        tweakables.Add(weaponType);
        tweakables.Add(turrets);
        tweakables.Add(caliber);
        tweakables.Add(reload);

        caliber.MaxCost              = 25;
        caliber.MaxWeight            = 30;
        reload.ReverseScaling        = true; //because reloading faster is worth more;
        reload.MaxNetPower           = 25;
        turrets.automaticCalculation = false;
        turrets.dropdownLabels.Add("Centerline Mounted");
        turrets.dropdownLabels.Add("Single Turret");
        turrets.dropdownLabels.Add("Dual Turret");
        turrets.dropdownLabels.Add("Triple Turret");
        turrets.dropdownLabels.Add("Quadruple Turret");
        weaponType.dropdownLabels.Add("Laser");
        weaponType.dropdownLabels.Add("Railgun");
        weaponType.automaticCalculation = false;
    }
Пример #12
0
    public override Part Clone()
    {
        Shield           part          = (Shield)MemberwiseClone();
        List <Tweakable> newTweakables = new List <Tweakable>();

        part.Manufacturer = Manufacturer;
        foreach (Tweakable t in tweakables)
        {
            Tweakable newt = Tweakable.MakeTweakable(
                part,
                t.tweakableType,
                t.tweakableName);
            newt.Value          = t.Value;
            newt.dropdownLabels = new List <string>(t.dropdownLabels);
            newTweakables.Add(newt);
        }
        part.tweakables = newTweakables;
        part.UpdateProperties();
        return(part);
    }
Пример #13
0
    protected override void InitializeTweakables()
    {
        tracking = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Tracking");

        accuracy = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Accuracy");
        range = Tweakable.MakeTweakable(
            this,
            TweakableType.Slider,
            "Range");
        tweakables.Add(tracking);
        tweakables.Add(accuracy);
        tweakables.Add(range);
        tracking.MaxCost       = 20;
        accuracy.MaxDesignCost = 20;
        range.MaxWeight        = 30;
    }
Пример #14
0
 protected void Update()
 {
     if (m_listTodo.Count > 0)
     {
         Tweakable tweakable = m_listTodo[m_listTodo.Count - 1];
         m_listTodo.RemoveAt(m_listTodo.Count - 1);
         if (tweakable.GetType() == typeof(TweakableLabel))
         {
             CreateLabel((TweakableLabel)tweakable);
         }
         if (tweakable.GetType() == typeof(TweakableInputField))
         {
             CreateInputField((TweakableInputField)tweakable);
         }
         else if (tweakable.GetType() == typeof(TweakableBool))
         {
             CreateBool((TweakableBool)tweakable);
         }
         else if (tweakable.GetType() == typeof(TweakableInt))
         {
             CreateInt((TweakableInt)tweakable);
         }
         else if (tweakable.GetType() == typeof(TweakableFloat))
         {
             CreateFloat((TweakableFloat)tweakable);
         }
         else if (tweakable.GetType() == typeof(TweakableTrigger))
         {
             CreateTrigger((TweakableTrigger)tweakable);
         }
     }
     if (UnityEngine.Input.GetKeyUp(KeyCode.Escape))
     {
         base.gameObject.SetActive(value: false);
     }
 }
Пример #15
0
 private void UpdateKeyShortCut(Tweakable tw)
 {
     (tw as TweakableTrigger)?.UpdateKeyShortCut();
 }
Пример #16
0
        private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (exitCode == 99)
            {
                DialogResult r = MessageBox.Show("We were unable to check the integrity of the tweak. Are you connected to the internet?\n\n"
                               + "You can continue without an integrity check, but this is a SECURITY RISK! "
                               + "We do not recommend to continue without an integrity check!!! "
                               + "In theory somebody could have tampered with the tweak files of this program "
                               + "and can now execute abitrary code on your computer if you continue!\n\n"
                               + "Do you want to continue without an integrity check? (not recommended)",
                               "Security Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (r == DialogResult.Yes)
                {
                    GC.Collect();
                    this.noIntegrityCheck = true;
                    worker.RunWorkerAsync();
                    return;
                }
            }

            form.TopMost = false;
            form.Focus();
            this.noIntegrityCheck = false;

            int row = this.tweakables.IndexOf(this.executeTweakable) + 1;
            Control progressbar = tableLayoutPanel.GetControlFromPosition(5, row);
            tableLayoutPanel.Controls.Remove(progressbar);

            progressbar.Dispose();

            tableLayoutPanel.Controls.Add(this.executeControl, 5, row);
            (this.executeControl as TweakExecuteControl).UpdateMenu(tweakableStates[executeTweakable]);

            if (exitCode == 100)
            {
                MessageBox.Show("The result of the integrity check of the tweak was negative.\n\n"
                               +"Possible causes for this problem are:\n"
                               +"- Your Program is not up to date\n"
                               +"  Try to download the newest version from http://privacytweak.me\n"
                               +"- Somebody modified your tweak files\n\n"
                               +"Because modified tweak files are a security risk "
                               +"the execution of the tweak was aborted!", "Integrity Check Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (exitCode != 0 && exitCode != 99)
            {
                MessageBox.Show("Failed to execute tweak. Did you cancel the UAC dialog?", "Tweak failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Label label = tableLayoutPanel.GetControlFromPosition(4, row) as Label;
            label.Text = tweakableStates[executeTweakable];

            if (tweakableStates[executeTweakable] != executeTweakable.GetRecommendedSetting())
            {
                label.ForeColor = Color.OrangeRed;
            }
            else
            {
                label.ForeColor = Color.Green;
            }

            this.exitCode = 0;
            this.executeState = null;
            this.executeTweakable = null;
            this.executeControl = null;

            GC.Collect();
            form.Focus();
        }
Пример #17
0
        private void ExecuteControl_OnTweakExecute(object source, TweakExecuteEventArgs args)
        {
            if (this.executeState != null || this.executeTweakable != null || this.executeControl != null)
            {
                return;
            }
            form.TopMost = true;
            ProgressBar progressbar = new ProgressBar();
            progressbar.Style = ProgressBarStyle.Marquee;
            progressbar.Dock = DockStyle.Fill;

            int row = this.tweakables.IndexOf(args.GetTweakable()) + 1;
            this.executeControl = tableLayoutPanel.GetControlFromPosition(5, row);
            tableLayoutPanel.Controls.Remove(this.executeControl);

            tableLayoutPanel.Controls.Add(progressbar, 5, row);

            Debug.WriteLine("we need to execute " + args.GetTweakable().GetName() + ". The new state should be " + args.GetState());
            this.executeTweakable = args.GetTweakable();
            this.executeState = args.GetState();
            worker.RunWorkerAsync();
        }
 public void Clear()
 {
     tweakable = null;
     text.text = "";
 }
 internal TweakExecuteEventArgs(Tweakable tweakable, string state)
     : base()
 {
     this.tweakable = tweakable;
     this.state = state;
 }
Пример #20
0
 public virtual void TweakableUpdate(Tweakable t)
 {
     UpdateProperties();
     OnPartChangeEvent?.Invoke(this);
 }
Пример #21
0
 public static void RegisterTweakable(Tweakable tweakable)
 {
     m_listTodo.Add(tweakable);
 }