<commit_before>/**
 * User: booster
 * Date: 05/03/15
 * Time: 16:38
 */
package tire.ui {
import feathers.controls.Button;
import feathers.controls.Header;
import feathers.controls.List;
import feathers.controls.PanelScreen;
import feathers.controls.Slider;
import feathers.controls.ToggleSwitch;
import feathers.controls.renderers.DefaultListItemRenderer;
import feathers.controls.renderers.IListItemRenderer;
import feathers.data.ListCollection;
import feathers.layout.AnchorLayout;
import feathers.layout.AnchorLayoutData;

import starling.display.DisplayObject;
import starling.events.Event;

import tire.TirePhysics;

public class WheelDataScreen extends PanelScreen {
    private var _wheelMassSlider:Slider;
    private var _wheelRadiusSlider:Slider;
    private var _wheelInertiaLocked:ToggleSwitch;
    private var _wheelInertiaSlider:Slider;
    private var _loadMassSlider:Slider;
    private var _frontalAreaSlider:Slider;
    private var _maxAccTorqueSlider:Slider;
    private var _maxBrakingTorqueSlider:Slider;

    private var _list:List;

    private var _tirePhysics:TirePhysics;

    public function get tirePhysics():TirePhysics { return _tirePhysics; }
    public function set tirePhysics(value:TirePhysics):void { _tirePhysics = value; }


    override protected function initialize():void {
        super.initialize();

        layout = new AnchorLayout();

        title = "Wheel settings";

        _wheelMassSlider = new Slider();
        _wheelMassSlider.minimum = 5;
        _wheelMassSlider.maximum = 30;
        _wheelMassSlider.step = 0.1;
        _wheelMassSlider.value = _tirePhysics.wheelMass;
        _wheelMassSlider.addEventListener(Event.CHANGE, function (e:Event):void {
            _tirePhysics.wheelMass = _wheelMassSlider.value;

            if(_wheelInertiaLocked.isSelected)
                _tirePhysics.validateInertia();
        });
        UiHelper.setupSlider(_wheelMassSlider);

        _wheelRadiusSlider = new Slider();
        _wheelRadiusSlider.minimum = 0.1;
        _wheelRadiusSlider.maximum = 5;
        _wheelRadiusSlider.step = 0.1;
        _wheelRadiusSlider.value = tirePhysics.wheelRadius;
        _wheelRadiusSlider.addEventListener(Event.CHANGE, function (e:Event):void {
            _tirePhysics.wheelRadius = _wheelRadiusSlider.value;

            if(_wheelInertiaLocked.isSelected)
                _tirePhysics.validateInertia();
        });
        UiHelper.setupSlider(_wheelRadiusSlider);

        _wheelInertiaSlider = new SecretSlider();
        _wheelInertiaSlider.minimum = 0.1;
        _wheelInertiaSlider.maximum = 50;
        _wheelInertiaSlider.step = 0.1;
        _wheelInertiaSlider.value = 20;
        _wheelInertiaSlider.isEnabled = _tirePhysics.wheelInertiaLocked;
        _wheelInertiaSlider.addEventListener(Event.CHANGE, function (e:Event):void {
            _tirePhysics.wheelInertia = _wheelInertiaSlider.value;
        });
        UiHelper.setupSlider(_wheelInertiaSlider);

        _wheelInertiaLocked = new ToggleSwitch();
        _wheelInertiaLocked.onText = "Yes";
        _wheelInertiaLocked.offText = "No";
        _wheelInertiaLocked.isSelected = _tirePhysics.wheelInertiaLocked;
        _wheelInertiaLocked.addEventListener(Event.CHANGE, function (e:Event):void {
            var sliderItem:Object = null, sliderIndex:int = -1;

            var count:int = _list.dataProvider.length;
            for(var i:int = 0; i < count; ++i) {
                var item:Object = _list.dataProvider.getItemAt(i);

                if(item.accessory != _wheelInertiaSlider)
                    continue;

                sliderItem = item;<commit_msg>Initialize slider with current inertia instead of constant<commit_after>/**
 * User: booster
 * Date: 05/03/15
 * Time: 16:38
 */
package tire.ui {
import feathers.controls.Button;
import feathers.controls.Header;
import feathers.controls.List;
import feathers.controls.PanelScreen;
import feathers.controls.Slider;
import feathers.controls.ToggleSwitch;
import feathers.controls.renderers.DefaultListItemRenderer;
import feathers.controls.renderers.IListItemRenderer;
import feathers.data.ListCollection;
import feathers.layout.AnchorLayout;
import feathers.layout.AnchorLayoutData;

import starling.display.DisplayObject;
import starling.events.Event;

import tire.TirePhysics;

public class WheelDataScreen extends PanelScreen {
    private var _wheelMassSlider:Slider;
    private var _wheelRadiusSlider:Slider;
    private var _wheelInertiaLocked:ToggleSwitch;
    private var _wheelInertiaSlider:Slider;
    private var _loadMassSlider:Slider;
    private var _frontalAreaSlider:Slider;
    private var _maxAccTorqueSlider:Slider;
    private var _maxBrakingTorqueSlider:Slider;

    private var _list:List;

    private var _tirePhysics:TirePhysics;

    public function get tirePhysics():TirePhysics { return _tirePhysics; }
    public function set tirePhysics(value:TirePhysics):void { _tirePhysics = value; }


    override protected function initialize():void {
        super.initialize();

        layout = new AnchorLayout();

        title = "Wheel settings";

        _wheelMassSlider = new Slider();
        _wheelMassSlider.minimum = 5;
        _wheelMassSlider.maximum = 30;
        _wheelMassSlider.step = 0.1;
        _wheelMassSlider.value = _tirePhysics.wheelMass;
        _wheelMassSlider.addEventListener(Event.CHANGE, function (e:Event):void {
            _tirePhysics.wheelMass = _wheelMassSlider.value;

            if(_wheelInertiaLocked.isSelected)
                _tirePhysics.validateInertia();
        });
        UiHelper.setupSlider(_wheelMassSlider);

        _wheelRadiusSlider = new Slider();
        _wheelRadiusSlider.minimum = 0.1;
        _wheelRadiusSlider.maximum = 5;
        _wheelRadiusSlider.step = 0.1;
        _wheelRadiusSlider.value = tirePhysics.wheelRadius;
        _wheelRadiusSlider.addEventListener(Event.CHANGE, function (e:Event):void {
            _tirePhysics.wheelRadius = _wheelRadiusSlider.value;

            if(_wheelInertiaLocked.isSelected)
                _tirePhysics.validateInertia();
        });
        UiHelper.setupSlider(_wheelRadiusSlider);

        _wheelInertiaSlider = new SecretSlider();
        _wheelInertiaSlider.minimum = 0.1;
        _wheelInertiaSlider.maximum = 50;
        _wheelInertiaSlider.step = 0.1;
        _wheelInertiaSlider.value = tirePhysics.wheelInertia;
        _wheelInertiaSlider.isEnabled = _tirePhysics.wheelInertiaLocked;
        _wheelInertiaSlider.addEventListener(Event.CHANGE, function (e:Event):void {
            _tirePhysics.wheelInertia = _wheelInertiaSlider.value;
        });
        UiHelper.setupSlider(_wheelInertiaSlider);

        _wheelInertiaLocked = new ToggleSwitch();
        _wheelInertiaLocked.onText = "Yes";
        _wheelInertiaLocked.offText = "No";
        _wheelInertiaLocked.isSelected = _tirePhysics.wheelInertiaLocked;
        _wheelInertiaLocked.addEventListener(Event.CHANGE, function (e:Event):void {
            var sliderItem:Object = null, sliderIndex:int = -1;

            var count:int = _list.dataProvider.length;
            for(var i:int = 0; i < count; ++i) {
                var item:Object = _list.dataProvider.getItemAt(i);

                if(item.accessory != _wheelInertiaSlider)
                    continue;

                sliderItem = item;
{'fraction_non_alphanumeric': 0.08463949843260188, 'fraction_numerical': 0.007905138339920948, 'mean_word_length': 3.2440717177559284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7125564', 'n_tokens_mistral': 2194, 'n_tokens_neox': 2174, 'n_words': 378}