Ejemplo n.º 1
0
    static public void DrawLayoutDialogTextField(DialogPartData unit)
    {
        ViNoEditorUtil.BeginGreenColor();

        EditorGUILayout.BeginHorizontal();

/*					if( _DIALOG_TEX == null ){
 *                              _DIALOG_TEX = AssetDatabase.LoadAssetAtPath("Assets/017722-dialog.png", typeof(Texture2D)) as Texture2D;
 *                      }
 *                      GUILayout.Box( _DIALOG_TEX , GUILayout.Width( 54f ) , GUILayout.Height( 54f ) );
 * //*/
        GUILayout.Space(30f);
        if (!unit.isClearMessageAfter)
        {
            unit.dialogText = EditorGUILayout.TextArea(unit.dialogText, GUI.skin.textArea);
        }
        else
        {
            unit.dialogText = EditorGUILayout.TextArea(unit.dialogText, GUI.skin.textArea, GUILayout.Height(50f));
        }

        EditorGUILayout.EndHorizontal();

        ViNoEditorUtil.EndGUIColor();
    }
    static public void DrawDialogListUtil(DialogPartNode node)
    {
        GUICommon.DrawLineSpace(10f, 5f);

        ViNoEditorUtil.BeginGUIColor(Color.green, GUI.backgroundColor, GUI.contentColor);            //Color.black , Color.white );

        GUILayout.BeginHorizontal();

//			GUILayout.Space( Screen.width/2f );

        if (GUILayout.Button("+"))
        {
//			if( GUILayout.Button( ViNoEditorResources.plusIcon ) ){
//				node.AddData( new DialogPartData() );// AddData( node );
//				Debug.Log( "Register Scene Undo");
            Undo.RegisterUndo(node, node.name);
//					 Undo.SetSnapshotTarget( node , node.name );

            int itemNum = node.GetMessageNum();
            node.AddItemAt(itemNum);
            node.ReAssignDialogIDsInThisObject();
        }

        if (GUILayout.Button("-"))
        {
//			if( GUILayout.Button( ViNoEditorResources.minusIcon ) ){//} , GUILayout.Width( sa ) ) ){
            Undo.RegisterUndo(node, node.name);
//				if( EditorUtility.DisplayDialog( "Remove the Last Item ?" , "Are you sure you really want to remove?"
//					, "Yes", "Cancel" ) ){
            if (node.dlgDataList != null && node.dlgDataList.Count > 0)
            {
                node.dlgDataList.RemoveAt(node.dlgDataList.Count - 1);
            }
            node.ReAssignDialogIDsInThisObject();
//				}
        }

        GUILayout.EndHorizontal();

        ViNoEditorUtil.EndGUIColor();
    }
    void OnGUI()
    {
/*		if( m_DialogIconTex == null || m_ArrowBackTex == null || m_ArrowForwardTex == null ){
 *                      LoadIcons();
 *              }
 * //*/

#if false
        if (EditorGUIUtility.isProSkin)
        {
            ViNoEditorUtil.BeginGUIColor(GUI.color, Color.green, GUI.contentColor);
        }
        else
        {
//			ViNoEditorUtil.BeginGUIColor( Color.white , new Color( 0f , 0.8f , 0f , 1f ) , Color.black );
            ViNoEditorUtil.BeginGUIColor(Color.white, new Color(0.8f, 0.8f, 0.8f, 1f), Color.black);
        }
#endif

        m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos);

#if false
        EditorGUILayout.BeginHorizontal();
//			GUILayout.Box( m_DialogIconTex , GUILayout.Width( 44f ) , GUILayout.Height( 44f ) );
        current = EditorGUILayout.ObjectField("Target", current, typeof(DialogPartNode), true) as DialogPartNode;
//			current = EditorGUILayout.ObjectField( m_DialogIconTex , current , typeof( DialogPartNode ) , true ) as DialogPartNode;
        EditorGUILayout.EndHorizontal();

/*
 *              if( Selection.activeGameObject != null ){
 *                      if( current != null ){
 *                              if( current.gameObject != Selection.activeGameObject ){
 *                                      current = Selection.activeGameObject.GetComponent<DialogPartNode>();
 *                                      UpdateGameView();
 *                              }
 *                      }
 *                      else{
 *                              current = Selection.activeGameObject.GetComponent<DialogPartNode>();
 *                              UpdateGameView();
 *                      }
 *              }
 *              else{
 *                      m_CurrentID = 0;
 *                      current = null;
 *                      return;
 *              }
 * //*/
        if (current != null)
        {
            m_DialogItemNum = current.GetMessageNum();
            GUI.enabled     = true;
        }
        else
        {
            GUI.enabled = false;
        }

        DrawMessageControl();
#endif

        if (current != null)
        {
            if (currentData != null)
            {
                currentData.show = false;
            }

            if (current.dlgDataList.Count == 0)
            {
                ShowNotificate();
            }
            else
            {
                if (m_CurrentID >= current.dlgDataList.Count)
                {
                    m_CurrentID = 0;
                }
                currentData      = current.dlgDataList[m_CurrentID];             //current.GetItemAt( m_CurrentID );
                currentData.show = true;

                //			NodeGUI.DrawDialogItemBar( current , ref currentData , m_CurrentID , current.m_ViNoTextBox , current.m_NameTextBox  );
                switch (currentData.actionID)
                {
                case DialogPartNodeActionType.Dialog:
                    //				DrawSceneCategory( current , currentData );
                    //				DrawActorCategory( current , currentData );
                    DrawSoundCategory(current, currentData);
                    DrawDialogCategory(current, currentData);
                    break;

                case DialogPartNodeActionType.EnterActor:
                case DialogPartNodeActionType.ExitActor:
//				case DialogPartNodeActionType.Shake:
//				case DialogPartNodeActionType.ChangeState:
                case DialogPartNodeActionType.MoveActor:
                    DrawActorCategory(current, currentData);
                    break;

//				case DialogPartNodeActionType.EnterScene:
//				case DialogPartNodeActionType.ExitScene:
//					DrawSceneCategory( current , currentData );
//					break;
                }
            }
        }
        else
        {
            ShowNotificate();
        }

        // If not play mode , Change the scene  and Message .
        if (GUI.changed)          //&& ! Application.isPlaying ){
        {
            UpdateGameView();
        }

//		EditorGUILayout.LabelField( "Dialog Item Num" + m_DialogItemNum.ToString() );
        EditorGUILayout.EndScrollView();

        GUI.enabled = true;



#if false
        ViNoEditorUtil.EndGUIColor();
#endif
    }
    public void OnGUI_DialogPart(DialogPartNode targetNode)
    {
//		m_SelectedModeID = GUILayout.Toolbar( m_SelectedModeID , m_ModeItems );
//		m_CurrMode = (Mode)m_SelectedModeID;

        // ------- There are two TextBox field before ! ------.

        DrawDialogTextBoxAndNameField(targetNode);

        // ---------------------------------------------------.

//TODO : TEST SOUND DATA PROPERTY!!
#if false
        if (soundDataProp != null)
        {
            EditorGUILayout.PropertyField(soundDataProp);
        }

/*
 *                      EditorGUILayout.BeginHorizontal();
 *                              EditorGUILayout.LabelField( "SoundData", GUILayout.Width( 100f) );
 *                              soundData = EditorGUILayout.ObjectField( soundData , typeof( ScriptableSoundData ) , true ) as ScriptableSoundData;
 * //			    soundDataProp = EditorGUILayout.ObjectField( soundDataProp, typeof( ScriptableSoundData ) , true ) as ScriptableSoundData;
 *                      EditorGUILayout.EndHorizontal();
 * //*/
#endif

//		EditorGUILayout.EndVertical();
//		EditorGUILayout.BeginHorizontal();
//		EditorGUILayout.EndHorizontal();

        m_ViewMode = GUILayout.Toolbar(m_ViewMode, m_MenuItems);

//		ViNoEditorUtil.BeginGreenColor();

        string menu = m_MenuItems[m_ViewMode];

        // View Mode : XML.
        if (menu == "XML")
        {
            ViNoEditorUtil.BeginGreenColor();

            DrawImportField(targetNode);

            ViNoEditorUtil.EndGUIColor();
        }
        // Actions or Edit Text Mode.
        else
        {
#if true
            if (menu == "Actions")
            {
                EditorGUILayout.BeginHorizontal();

                /*				if( GUILayout.Button( "Open "+ System.Environment.NewLine +" Dialogs" )){
                 *                                      m_ShowAllToggle = ! m_ShowAllToggle;
                 *                                      for( int i=0;i<targetNode.dlgDataList.Count;i++){
                 *                                              targetNode.dlgDataList[ i ].show = m_ShowAllToggle;
                 *                                      }
                 *                              }
                 * //*/
                if (GUILayout.Button("Check " + System.Environment.NewLine + " ALL"))
                {
                    //				if( GUILayout.Button( new GUIContent( "All" , ViNoEditorResources.checkAllcon ) , GUILayout.Width( 62f ) , GUILayout.Height( 22f ) ) ){// "Check " + System.Environment.NewLine + " ALL" )){
                    for (int i = 0; i < targetNode.dlgDataList.Count; i++)
                    {
                        targetNode.dlgDataList[i].active = true;
                    }
                }

                if (GUILayout.Button("UNCheck" + System.Environment.NewLine + "ALL"))
                {
                    //				if( GUILayout.Button( uncheckTex ) ){
                    for (int i = 0; i < targetNode.dlgDataList.Count; i++)
                    {
                        targetNode.dlgDataList[i].active = false;
                    }
                }

                if (GUILayout.Button("Swap Checked" + System.Environment.NewLine + "2 Items"))
                {
                    DialogPartNodeUtility.Swap2Items(targetNode);
                }

                GUI.enabled = true;

                EditorGUILayout.EndHorizontal();
            }
#endif
            if (targetNode.dlgDataList != null)
            {
                for (int i = 0; i < targetNode.dlgDataList.Count; i++)
                {
                    DialogPartData unit = targetNode.dlgDataList[i];
                    if (menu == "Actions")                               //&& unit.actionID != DialogPartNodeActionType.Dialog ){
                    {
                        NodeGUI.DrawDialogItemBar(targetNode, ref unit, i, targetNode.m_ViNoTextBox, targetNode.m_NameTextBox);
                    }
                    NodeGUI.OnGUI_a(targetNode, ref unit, i, targetNode.m_ViNoTextBox, targetNode.m_NameTextBox, m_ViewMode);
                }
            }
            else
            {
                DialogPartNodeUtility.Initialize(targetNode);
            }
            DialogPartNodeInspector.DrawDialogListUtil(targetNode);
        }
//			ViNoEditorUtil.EndGUIColor();
    }