예제 #1
0
    static public void AddStageAtIndex(FStage stageToAdd, int newIndex)
    {
        int stageIndex = _stages.IndexOf(stageToAdd);

        if (newIndex > _stages.Count)         //if it's past the end, make it at the end
        {
            newIndex = _stages.Count;
        }

        if (stageIndex == newIndex)
        {
            return;                   //if it's already at the right index, just leave it there
        }
        if (stageIndex == -1)         //add it if it's not in the stages already
        {
            stageToAdd.HandleAddedToFutile();

            _stages.Insert(newIndex, stageToAdd);
        }
        else         //if stage is already in the stages, move it to the desired index
        {
            _stages.RemoveAt(stageIndex);

            if (stageIndex < newIndex)
            {
                _stages.Insert(newIndex - 1, stageToAdd);                 //gotta subtract 1 to account for it moving in the order
            }
            else
            {
                _stages.Insert(newIndex, stageToAdd);
            }
        }

        UpdateStageIndices();
    }
예제 #2
0
    static public void AddStage(FStage stageToAdd)
    {
        int stageIndex = _stages.IndexOf(stageToAdd);

        if (stageIndex == -1)         //add it if it's not a stage
        {
            stageToAdd.HandleAddedToFutile();
            _stages.Add(stageToAdd);
            UpdateStageIndices();
        }
        else if (stageIndex != _stages.Count - 1)         //if stage is already in the stages, put it at the top of the stages if it's not already
        {
            _stages.RemoveAt(stageIndex);
            _stages.Add(stageToAdd);
            UpdateStageIndices();
        }
    }
예제 #3
0
파일: Futile.cs 프로젝트: MattRix/Madness
    public static void AddStageAtIndex(FStage stageToAdd, int newIndex)
    {
        int stageIndex = _stages.IndexOf(stageToAdd);

        if(newIndex > _stages.Count) //if it's past the end, make it at the end
        {
            newIndex = _stages.Count;
        }

        if(stageIndex == newIndex) return; //if it's already at the right index, just leave it there

        if(stageIndex == -1) //add it if it's not in the stages already
        {
            stageToAdd.HandleAddedToFutile();

            _stages.Insert(newIndex, stageToAdd);
        }
        else //if stage is already in the stages, move it to the desired index
        {
            _stages.RemoveAt(stageIndex);

            if(stageIndex < newIndex)
            {
                _stages.Insert(newIndex-1, stageToAdd); //gotta subtract 1 to account for it moving in the order
            }
            else
            {
                _stages.Insert(newIndex, stageToAdd);
            }
        }

        UpdateStageIndices();
    }
예제 #4
0
파일: Futile.cs 프로젝트: MattRix/Madness
    public static void AddStage(FStage stageToAdd)
    {
        int stageIndex = _stages.IndexOf(stageToAdd);

        if(stageIndex == -1) //add it if it's not a stage
        {
            stageToAdd.HandleAddedToFutile();
            _stages.Add(stageToAdd);
            UpdateStageIndices();
        }
        else if(stageIndex != _stages.Count-1) //if stage is already in the stages, put it at the top of the stages if it's not already
        {
            _stages.RemoveAt(stageIndex);
            _stages.Add(stageToAdd);
            UpdateStageIndices();
        }
    }