コード例 #1
0
        /// <summary>
        ///     상태를 추가한다.
        /// </summary>
        private void AddState()
        {
            var state          = new List <SwitchComponentData>();
            var stateComponent = new SwitchComponentData();

            stateComponent.Operator = string.Empty;
            state.Add(stateComponent);
            _stateList.Add(state);

            var stateResultData = new SwitchStateResultData();

            _stateResultDataList.Add(stateResultData);
        }
コード例 #2
0
        /// <summary>
        ///     창을 그리는 행동
        /// </summary>
        protected override void GUIProcess()
        {
            //로고
            GUILayout.Space(10);

            GUILayout.Label(WindowTitleText, "DefaultCenteredLargeText");

            GUILayout.Space(10);

            EditorGUI.BeginDisabledGroup(_confirmState != EConfirmState.None);
            {
                Rect areaRect = position;
                areaRect.height = position.height * 0.8f;

                //스위치 아이디
                GUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginDisabledGroup(IsUpdate);
                    {
                        EditorGUILayout.PrefixLabel(SwitchIdText);
                        _descriptionData.SwitchId = GUILayout.TextField(_descriptionData.SwitchId);
                    }
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();

                //시작결과
                GUILayout.BeginHorizontal(GUILayout.Width(150));
                GUILayout.Space(position.width * 0.5f - 75);
                GUILayout.BeginVertical();
                GUILayout.Space(18);
                GUILayout.Label(StartResultText);
                GUILayout.EndVertical();
                var defaultResultText = _descriptionData.DefaultResult.ToString();
                if (GUILayout.Button(defaultResultText, "GroupBox", GUILayout.Width(100)))
                {
                    _descriptionData.DefaultResult = !_descriptionData.DefaultResult;
                }
                GUILayout.EndHorizontal();

                //스위치 설명
                GUILayout.Space(10);
                GUILayout.Label(DescriptionTextValue);
                _descriptionData.Description = GUILayout.TextArea(_descriptionData.Description, GUILayout.Height(100));


                //
                //
                //
                //

                GUILayout.Space(15);

                //팝업내용 만들기
                string[] popupTexts = new string[_stateList.Count + 1];
                int      stateIndex = 0;
                for (stateIndex = 0; stateIndex < _stateList.Count; ++stateIndex)
                {
                    popupTexts[stateIndex] = string.Format(StateFormatText, stateIndex);
                }
                popupTexts[stateIndex] = string.Format(StateAddFormatText, stateIndex);

                //팝업드랍박스
                GUILayout.BeginHorizontal();
                _stateIndex = EditorGUILayout.Popup(_stateIndex, popupTexts);
                if (_stateList.Count == _stateIndex)
                {
                    AddState();
                }

                //현재 상태 삭제하기
                EditorGUI.BeginDisabledGroup(_stateIndex == 0);
                {
                    if (GUILayout.Button(DeleteStateText, GUILayout.Width(120)))
                    {
                        _stateList.Remove(_stateList[_stateIndex]);
                        if (_stateList.Count <= _stateIndex)
                        {
                            _stateIndex = _stateList.Count - 1;
                        }
                        _stateResultDataList.Remove(_stateResultDataList[_stateIndex]);
                    }
                }
                EditorGUI.EndDisabledGroup();
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal(GUILayout.Width(150));
                GUILayout.Space(position.width * 0.5f - 75);
                GUILayout.BeginVertical();
                GUILayout.Space(18);
                GUILayout.Label(StateResultText);
                GUILayout.EndVertical();
                var resultText = _stateResultDataList[_stateIndex].Result.ToString();
                if (GUILayout.Button(resultText, "GroupBox", GUILayout.Width(100)))
                {
                    _stateResultDataList[_stateIndex].Result = !_stateResultDataList[_stateIndex].Result;
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(20);

                GUILayout.BeginVertical(GUILayout.Height(position.height - 362));

                //디폴트 퀘스트아이디 인풋
                _stateList[_stateIndex][0].QuestId = EditorGUILayout.TextField(QuestIdText, _stateList[_stateIndex][0].QuestId);
                //추가 인풋
                for (int stateComponentIndex = 1; stateComponentIndex < _stateList[_stateIndex].Count; ++stateComponentIndex)
                {
                    GUILayout.BeginHorizontal();
                    int operIndex = _stateList[_stateIndex][stateComponentIndex].Operator == _operTexts[0] ? 0 : 1;
                    operIndex = EditorGUILayout.Popup(operIndex, _operTexts, GUILayout.Width(148));
                    _stateList[_stateIndex][stateComponentIndex].Operator = _operTexts[operIndex];
                    _stateList[_stateIndex][stateComponentIndex].QuestId  = EditorGUILayout.TextField(_stateList[_stateIndex][stateComponentIndex].QuestId);
                    GUILayout.Space(10);
                    if (GUILayout.Button(string.Empty, "OL Minus", GUILayout.Width(20)))
                    {
                        _stateList[_stateIndex].Remove(_stateList[_stateIndex][stateComponentIndex]);
                    }
                    GUILayout.Space(15);
                    GUILayout.EndHorizontal();
                    GUILayout.Space(4);
                }
                //퀘스트아이디 추가 버튼
                if (GUILayout.Button(AddOperText))
                {
                    var switchComponent = new SwitchComponentData();
                    switchComponent.Operator = _operTexts[0];
                    _stateList[_stateIndex].Add(switchComponent);
                }

                GUILayout.EndVertical();

                GUILayout.BeginHorizontal();
                GUILayout.Space(position.width * 0.2f);
                //버튼 기능
                if (IsUpdate)
                {
                    if (GUILayout.Button(UpdateTextValue))
                    {
                        if (CheckProcess() && UpdateProcess())
                        {
                            _confirmState           = EConfirmState.UpdateSuccess;
                            ConfirmWindowNoticeText = UpdateSuccessTextValue;
                        }
                        else
                        {
                            _confirmState           = EConfirmState.Fail;
                            ConfirmWindowNoticeText = UpdateFailTextValue;
                        }
                    }
                    if (GUILayout.Button(DeleteTextValue))
                    {
                        //SwitchData 구성요소인지 체크
                        if (DeleteProcess())
                        {
                            _confirmState           = EConfirmState.DeleteSuccess;
                            ConfirmWindowNoticeText = DeleteSuccessTextValue;
                        }
                        else
                        {
                            _confirmState           = EConfirmState.Fail;
                            ConfirmWindowNoticeText = DeleteFaileTextValue;
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button(CreateTextValue))
                    {
                        if (CheckProcess() && CreateProcess())
                        {
                            _confirmState           = EConfirmState.CreateSuccess;
                            ConfirmWindowNoticeText = CreateSuccessTextValue;
                        }
                        else
                        {
                            _confirmState           = EConfirmState.Fail;
                            ConfirmWindowNoticeText = CreateFailTextValue;
                        }
                    }
                }
                GUILayout.Space(position.width * 0.2f);
                GUILayout.EndHorizontal();
            }
            EditorGUI.EndDisabledGroup();

            if (_confirmState != EConfirmState.None)
            {
                DrawConfirmWindow(string.Empty);
            }

            GUILayout.Space(10);
        }