Exemplo n.º 1
0
        public void SetState(EditStates es)
        {
            if (State == es)
            {
                return;
            }

            State = es;
            ChangeCategory((int)State);
        }
Exemplo n.º 2
0
        public void ButtonFunction(string func)
        {
            switch (func)
            {
            case "Save":
                MapLuaParser.Current.SaveMap();
                break;

            case "Map":
                State = EditStates.MapStat;
                ChangeCategory(0);
                break;

            case "Terrain":
                State = EditStates.TerrainStat;
                ChangeCategory(1);
                break;

            case "Textures":
                State = EditStates.TexturesStat;
                ChangeCategory(2);
                break;

            case "Lighting":
                State = EditStates.LightingStat;
                ChangeCategory(3);
                break;

            case "Markers":
                State = EditStates.MarkersStat;
                ChangeCategory(4);
                break;

            case "Decals":
                State = EditStates.DecalsStat;
                ChangeCategory(5);
                break;

            case "Props":
                State = EditStates.PropsStat;
                ChangeCategory(6);
                break;

            case "Ai":
                State = EditStates.AIStat;
                ChangeCategory(7);
                break;
            }
        }
Exemplo n.º 3
0
		public void ButtonFunction(string func){
			switch(func){
			case "Save":
				Scenario.StartCoroutine("SaveMap");
				break;
			case "Map":
				State = EditStates.MapStat;
				ChangeCategory(0);
				EditMarkers.ClearWorkingElements();
				break;
			case "Terrain":
				State = EditStates.TerrainStat;
				ChangeCategory(1);
				EditMarkers.ClearWorkingElements();
				break;
			case "Textures":
				State = EditStates.TexturesStat;
				ChangeCategory(2);
				EditMarkers.ClearWorkingElements();
				break;
			case "Lighting":
				State = EditStates.LightingStat;
				ChangeCategory(3);
				EditMarkers.ClearWorkingElements();
				break;
			case "Markers":
				State = EditStates.MarkersStat;
				ChangeCategory(4);
				EditMarkers.GenerateAllWorkingElements();
				break;
			case "Decals":
				State = EditStates.DecalsStat;
				ChangeCategory(5);
				EditMarkers.ClearWorkingElements();
				break;
			case "Props":
				State = EditStates.PropsStat;
				ChangeCategory(6);
				EditMarkers.ClearWorkingElements();
				break;
			case "Ai":
				State = EditStates.AIStat;
				ChangeCategory(7);
				EditMarkers.ClearWorkingElements();
				break;
			}
		}
Exemplo n.º 4
0
		void OnEnable(){
			ChangeCategory(0);
			State = EditStates.MapStat;
			MirrorTolerance = PlayerPrefs.GetFloat("SymmetryTolerance", 0.4f);
		}
Exemplo n.º 5
0
 void OnEnable()
 {
     ChangeCategory(0);
     State           = EditStates.MapStat;
     MirrorTolerance = PlayerPrefs.GetFloat("SymmetryTolerance", 0.4f);
 }
Exemplo n.º 6
0
    //set the given keyconfig to be editted
    bool EditConfig(KeyConfig kc, bool forJoy = false)
    {
        if( _editting != null) return false;

        _editting = kc;
        _edittingJoy = forJoy;

        if( kc.isAxis ) _edittingState = EditStates.NegKey;
        else _edittingState = EditStates.PosKey;

        return true;
    }
Exemplo n.º 7
0
    //edit the current key if a keycode was pressed
    bool EditKey( KeyConfig config, EditStates es, KeyCode kc)
    {
        if( ( es == EditStates.VertNegKey || es == EditStates.VertPosKey ) && config._biDirLink == null) return false;

        KeyConfig HorizConfig;
        KeyConfig VertConfig;

        if( config._biDirLink == null || config.Direction == BiDir.Horizontal ){
            HorizConfig = config;
            VertConfig = config._biDirLink;
        }else{
            VertConfig = config;
            HorizConfig = config._biDirLink;
        }

        int ikc = (int) kc;

        //check for dupes in this keyconfig alone
        if(config.isAxis && config._biDirLink != null)
        {
            switch(es){
            case EditStates.VertNegKey:
                if(ikc == HorizConfig._key) return false;
                goto case EditStates.PosKey;
            case EditStates.PosKey:
                if(ikc == VertConfig._key) return false;
                goto case EditStates.VertPosKey;
            case EditStates.VertPosKey:
                if(ikc == HorizConfig._negKey) return false;
                goto case EditStates.NegKey;
            case EditStates.NegKey:
                break;
            }
        }
        else if(config.isAxis)
        {
            switch(es){
            case EditStates.PosKey:
                if(ikc == HorizConfig._negKey) return false;
                goto case EditStates.NegKey;
            case EditStates.NegKey:
                break;
            }
        }

        // SET the correct key
        switch(es){
        case EditStates.PosKey:
            ClearKeys(HorizConfig,es);
            HorizConfig._key = ikc;
            break;
        case EditStates.NegKey:
            ClearKeys(HorizConfig,es);
            HorizConfig._negKey = ikc;
            break;
        case EditStates.VertPosKey:
            ClearKeys(VertConfig,es);
            VertConfig._key = ikc;
            break;
        case EditStates.VertNegKey:
            ClearKeys(VertConfig,es);
            VertConfig._negKey = ikc;
            break;
        }
        return true;
    }
Exemplo n.º 8
0
    //reassign the keys to what the player presses if the player is editting a config
    void DoEditKeyWork()
    {
        if(_editting == null || !_editorOpen)return;

        //stop editting if escape is pressed
        if( _prevKeyPressed == KeyCode.Escape && (( _edittingState == EditStates.NegKey && _editting.isAxis) || (_edittingState == EditStates.PosKey && !_editting.isAxis)) ) {
            _editting = null;
            return;
        }else if(_prevKeyPressed == KeyCode.Escape){
            return;
        }

        //get the keys that were pressed
        bool keychanged = false;
        bool axischanged = false;

        //if the player is editting the joystick keys
        if(_edittingJoy)
        {
            // Joycode
            int JCPlayer = -1;
            JoyCode JCPressed = ControllerManager.Get().GetKeyPressed(out JCPlayer);

            // Joystick Axis
            int JAPlayer = -1;
            JoyAnalog JAChanged = JoyAnalog.None;

            //check if an analog button was pressed
            for(int i = 1 ; i <= 4 ; i ++){
                ControllerManager.JoyInterface joy = CMRef.GetController(i);
                if(joy == null) continue;

                //check each analog axis
                foreach(JoyAnalog ja in JoyCode.GetValues(typeof(JoyAnalog))){
                    if(joy.GetAnalogValue(ja) != 0){
                        JAChanged = ja;
                        JAPlayer = i;
                        break;
                    }
                }
            }

            //if and analog value was changed
            if( JAChanged != JoyAnalog.None && JAChanged != JoyAnalog.LeftTrigger && JAChanged != JoyAnalog.RightTrigger)
            {
                axischanged = EditKey( _editting, _edittingState, JAChanged, JAPlayer );
            }

            //if a button was pressed
            if( JCPressed != JoyCode.None && !axischanged)
            {
                keychanged = EditKey( _editting, _edittingState, JCPressed, JCPlayer);
            }
            else if( !axischanged )
            {
                return;
            }

        }
        //otherwise if the player is editting the keyboard bindings
        else
        {
            // Keycode
            KeyCode KCPressed = _prevKeyPressed;

            // Mouse Axis
            MouseAxes MAChanged = MouseAxes.None;
            float mX = Mathf.Abs(Input.GetAxis("MouseX"));
            float mY = Mathf.Abs(Input.GetAxis("MouseY"));
            float ms = Mathf.Abs(Input.GetAxis("MouseScrollWheel"));

            //scroll wheel and movement change checks
            if(ms > .2f) MAChanged = MouseAxes.ScrollWheel;
            else if(mX > 3 && mX > mY) MAChanged = MouseAxes.MoveHorizontal;
            else if(mY > 3 && mY > mX) MAChanged = MouseAxes.MoveVertical;

            // Mouse Buttons
            int MPressed = -1;
            for(int i = 0 ; i < 3 ; i ++){
                if(GetMouseButtonDown(i)) MPressed = i;
            }

            // if the mouse axis changed
            if( MAChanged != MouseAxes.None )
            {
                axischanged = EditKey( _editting, _edittingState, MAChanged);
            }
            //if a button was pressed
            else if( MPressed != -1)
            {
                keychanged = EditMouseKey( _editting, _edittingState, MPressed);
            }
            //if a key was pressed
            else if( KCPressed != KeyCode.None )
            {
                keychanged = EditKey( _editting, _edittingState, KCPressed);
            }
            else
            {
                return;
            }

        }

        //if an axis was changed
        if( axischanged ){
            _editting = null;
        //if a key changed
        }else if(keychanged){
            //cycle the editted key forward
            if(_editting.isAxis && _editting._biDirLink != null)
            {

                switch(_edittingState){
                case EditStates.NegKey: //left
                    _edittingState = EditStates.VertPosKey;
                    break;
                case EditStates.VertPosKey: //up
                    _edittingState = EditStates.PosKey;
                    break;
                case EditStates.PosKey: //right
                    _edittingState = EditStates.VertNegKey;
                    break;
                case EditStates.VertNegKey: //down
                    _editting = null;
                    break;
                default:
                    _editting = null;
                    break;
                }

            }
            else if(_editting.isAxis)
            {
                switch(_edittingState){
                case EditStates.NegKey:
                    _edittingState = EditStates.PosKey;
                    break;
                case EditStates.PosKey:
                    _editting = null;
                    break;
                default:
                    _editting = null;
                    break;
                }
            }
            else
            {
                _editting = null;
            }
        }
    }
Exemplo n.º 9
0
    //clears the key assignments for the editstate es, and whether or not it's for a joystick
    void ClearKeys(KeyConfig kc, EditStates es, bool forjoy = false)
    {
        if(kc == null) return;

        if( !forjoy )
        {
            switch( es ){
            case EditStates.NegKey:
            case EditStates.VertNegKey:
                kc._negKey = 0;
                kc._negMouseKey = -1;
                break;
            case EditStates.PosKey:
            case EditStates.VertPosKey:
                kc._key = 0;
                kc._mouseKey = -1;
                break;
            }
            kc.MouseAxis = MouseAxes.None;
        }
        else
        {
            switch( es ){
            case EditStates.NegKey:
            case EditStates.VertNegKey:
                kc._negJoyKey = 0;
                kc._negJoyKeyPlayer = 0;
                break;
            case EditStates.PosKey:
            case EditStates.VertPosKey:
                kc._joyKey = 0;
                kc._joyKeyPlayer = 0;
                break;
            }
            kc.JoystickAxis = JoyAnalog.None;
            kc._joyAxisPlayer = 0;
        }
    }
Exemplo n.º 10
0
    //edit the current config if a analog joystick input was changed
    bool EditKey( KeyConfig config, EditStates es, JoyAnalog ja, int jplayer)
    {
        if( !( (es == EditStates.PosKey && !config.isAxis) || (es == EditStates.NegKey && config.isAxis) ) || !config.isAxis ) return false;

        config._joyAxisPlayer = jplayer;
        config.JoystickAxis = ja;

        if(config._biDirLink != null){

            KeyConfig HorizConfig;
            KeyConfig VertConfig;

            if( config.Direction == BiDir.Horizontal ){
                HorizConfig = config;
                VertConfig = config._biDirLink;
            }else{
                VertConfig = config;
                HorizConfig = config._biDirLink;
            }

            // SET
            switch(ja){
            case JoyAnalog.DPadHorizontal:
            case JoyAnalog.DPadVertical:
                ClearKeys(HorizConfig, true);
                ClearKeys(VertConfig, true);

                HorizConfig._joyAxisPlayer = jplayer;
                HorizConfig.JoystickAxis = JoyAnalog.DPadHorizontal;
                VertConfig._joyAxisPlayer = jplayer;
                VertConfig.JoystickAxis = JoyAnalog.DPadVertical;
                break;
            case JoyAnalog.LeftStickHorizontal:
            case JoyAnalog.LeftStickVertical:
                ClearKeys(HorizConfig, true);
                ClearKeys(VertConfig, true);

                HorizConfig._joyAxisPlayer = jplayer;
                HorizConfig.JoystickAxis = JoyAnalog.LeftStickHorizontal;
                VertConfig._joyAxisPlayer = jplayer;
                VertConfig.JoystickAxis = JoyAnalog.LeftStickVertical;
                break;
            case JoyAnalog.RightStickHorizontal:
            case JoyAnalog.RightStickVertical:
                ClearKeys(HorizConfig, true);
                ClearKeys(VertConfig, true);

                HorizConfig._joyAxisPlayer = jplayer;
                HorizConfig.JoystickAxis = JoyAnalog.RightStickHorizontal;
                VertConfig._joyAxisPlayer = jplayer;
                VertConfig.JoystickAxis = JoyAnalog.RightStickVertical;
                break;
            default:
                return false;
            }
        }
        else
        {
            // SET
            ClearKeys(config, true);
            config._joyAxisPlayer = jplayer;
            config.JoystickAxis = ja;
        }
        return true;
    }
Exemplo n.º 11
0
    //edit the current config if a mouse axis changed
    bool EditKey( KeyConfig config, EditStates es, MouseAxes ma)
    {
        if( !( (es == EditStates.PosKey && !config.isAxis) || (es == EditStates.NegKey && config.isAxis) ) ) return false;

        if(config.isAxis && config._biDirLink != null){

            KeyConfig HorizConfig;
            KeyConfig VertConfig;

            if( config.Direction == BiDir.Horizontal ){
                HorizConfig = config;
                VertConfig = config._biDirLink;
            }else{
                VertConfig = config;
                HorizConfig = config._biDirLink;
            }

            // SET
            switch(ma){
            case MouseAxes.MoveHorizontal:
            case MouseAxes.MoveVertical:
                ClearKeys(HorizConfig);
                ClearKeys(VertConfig);

                HorizConfig.MouseAxis = MouseAxes.MoveHorizontal;
                VertConfig.MouseAxis = MouseAxes.MoveVertical;
                break;
            case MouseAxes.None:
                ClearKeys(HorizConfig);
                ClearKeys(VertConfig);

                HorizConfig.MouseAxis = MouseAxes.None;
                VertConfig.MouseAxis = MouseAxes.None;
                break;
            default:
                return false;
            }
        }
        else if(config.isAxis)
        {
            ClearKeys(config);
            config.MouseAxis = ma;
        }
        else
        {
            return false;
        }

        return true;
    }
Exemplo n.º 12
0
    // edit the current key if a joystick key was pressed
    bool EditKey( KeyConfig config, EditStates es, JoyCode jc, int jplayer)
    {
        if( ( es == EditStates.VertNegKey || es == EditStates.VertPosKey ) && config._biDirLink == null) return false;

        KeyConfig HorizConfig;
        KeyConfig VertConfig;

        if( config._biDirLink == null || config.Direction == BiDir.Horizontal ){
            HorizConfig = config;
            VertConfig = config._biDirLink;
        }else{
            VertConfig = config;
            HorizConfig = config._biDirLink;
        }

        int ijc = (int) jc;

        //check for dupes in this joyconfig alone
        if(config.isAxis && config._biDirLink != null)
        {
            switch(es){
            case EditStates.VertNegKey:
                if(ijc == HorizConfig._joyKey && jplayer == HorizConfig._joyKeyPlayer) return false;
                goto case EditStates.PosKey;
            case EditStates.PosKey:
                if(ijc == VertConfig._joyKey && jplayer == VertConfig._joyKeyPlayer) return false;
                goto case EditStates.VertPosKey;
            case EditStates.VertPosKey:
                if(ijc == HorizConfig._negJoyKey && jplayer == HorizConfig._negJoyKeyPlayer) return false;
                goto case EditStates.NegKey;
            case EditStates.NegKey:
                break;
            }
        }
        else if(config.isAxis)
        {
            switch(es){
            case EditStates.PosKey:
                if(ijc == HorizConfig._negJoyKey && jplayer == HorizConfig._negJoyKeyPlayer) return false;
                goto case EditStates.NegKey;
            case EditStates.NegKey:
                break;
            }
        }

        // SET the key

        switch(es){
        case EditStates.PosKey:
            ClearKeys(HorizConfig, es, true);
            HorizConfig._joyKeyPlayer = jplayer;
            HorizConfig._joyKey = ijc;
            break;
        case EditStates.NegKey:
            ClearKeys(HorizConfig, es, true);
            HorizConfig._negJoyKeyPlayer = jplayer;
            HorizConfig._negJoyKey = ijc;
            break;
        case EditStates.VertPosKey:
            ClearKeys(VertConfig, es, true);
            VertConfig._joyKeyPlayer = jplayer;
            VertConfig._joyKey = ijc;
            break;
        case EditStates.VertNegKey:
            ClearKeys(VertConfig, es, true);
            VertConfig._negJoyKeyPlayer = jplayer;
            VertConfig._negJoyKey = ijc;
            break;
        }

        return true;
    }