/// <summary>
    /// Check if
    /// </summary>
    void RangeCheck()
    {
        Debug.Log("LogCount :" + ViNoBackLog.GetLogList().Count);

        if (m_LogIndex <= 0)
        {
            m_LogIndex = 0;
            if (prevButton != null)
            {
                prevButton.SetActive(false);
            }
        }
        else
        {
            if (prevButton != null)
            {
                prevButton.SetActive(true);
            }
        }

        if (m_LogIndex >= ViNoBackLog.GetLogList().Count - 1)
        {
            m_LogIndex = ViNoBackLog.GetLogList().Count - 1;
        }
        else
        {
            if (nextButton != null)
            {
                nextButton.SetActive(true);
            }
        }
    }
    static public void Add(string str)
    {
        // If str equals the latest Added String , return.
        if (m_Log.Count > 1)
        {
            int lastIndex = m_Log.Count - 1;
            if (m_Log[lastIndex].Equals(str))
            {
                return;
            }
        }

        if (m_Log.Count > ViNo.backLogLimit)
        {
            m_Log.RemoveAt(0);
        }
        m_Log.Add(str);
        if (m_Instance == null)
        {
            GameObject go = new GameObject("_ViNoBackLog");
            go.hideFlags = HideFlags.HideInHierarchy;
            m_Instance   = go.AddComponent <ViNoBackLog>();
            DontDestroyOnLoad(go);
        }
    }
Beispiel #3
0
 void OnLevelWasLoaded(int index)
 {
     if (loadLevelAndClearBackLog)
     {
         ViNoBackLog.Clear();
     }
 }
Beispiel #4
0
 /// <summary>
 /// Raises the enable event.
 /// </summary>
 void OnEnable()
 {
     if (displayStyle == DisplayStyle.TEXT_ONLY)
     {
         m_AllText     = ViNoBackLog.GetAppendedText(true);
         m_ScrollPos.x = m_AllText.Length * 144f;
     }
 }
    void SetLogTextAlltoTarget( )
    {
        bool   stubLineBreak = true;
        string logStr        = ViNoBackLog.GetAppendedText(stubLineBreak);

        textTarget.gameObject.SendMessage("OnUpdateText", logStr);

        gameObject.BroadcastMessage("OnBackLogTextChanged");
    }
    void OnClickVoice()
    {
        DialogPartData data = ViNoBackLog.GetItemAt(m_LogIndex);

        if (data.isVoice && ISoundPlayer.Instance != null)
        {
            ISoundPlayer.Instance.PlayVoice(data.voiceAudioID, ViNoConfig.prefsVoiceVolume, 0f);
        }
    }
    /// <summary>
    /// Raises the click next event.
    /// </summary>
    void OnClickNext()
    {
        Debug.Log("Click Next ");
        m_LogIndex++;
        if (m_LogIndex == ViNoBackLog.GetLogList().Count)
        {
            ClosePanel();
        }
        else
        {
            RangeCheck();

            OnChangedLogIndex(m_LogIndex);
        }
    }
    /// <summary>
    /// Initialize BackLog View.
    /// </summary>
    void Initialize()
    {
        m_LogIndex = ViNoBackLog.GetLogTextCount() - 1;
        switch (displayStyle)
        {
        case DisplayStyle.DISP_A_TEXT:
            OnChangedLogIndex(m_LogIndex);
            // Activate the Buttons.
            prevButton.SetActive(true);
            nextButton.SetActive(true);
            break;

        case DisplayStyle.DISP_APPENDED_TEXT:
            SetLogTextAlltoTarget();
            break;
        }
    }
Beispiel #9
0
 public static void Add( DialogPartData unit )
 {
     // If str equals the latest Added String , return.
     /*		if( m_Log.Count > 1 ){
         int lastIndex = m_Log.Count - 1;
         if( m_Log[ lastIndex ].Equals( str ) ){
             return;
         }
     }
     //*/
     if (m_Log.Count > ViNo.backLogLimit ) m_Log.RemoveAt(0);
     m_Log.Add( unit );
     if (m_Instance == null ){
         GameObject go = new GameObject("_ViNoBackLog");
         go.hideFlags = HideFlags.HideInHierarchy;
         m_Instance = go.AddComponent<ViNoBackLog>();
         DontDestroyOnLoad(go);
     }
 }
    void Update()
    {
        m_BackLogEnabled = ViNoBackLog.IsLogStored();
        if (backLogButton != null)
        {
            if (m_PrevBackLogState != m_BackLogEnabled)
            {
                if (m_BackLogEnabled && backLogButton != null)
                {
                    backLogButton.SendMessage("SetActiveColor", SendMessageOptions.DontRequireReceiver);
                }
                else
                {
                    backLogButton.SendMessage("SetDeactiveColor", SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        m_PrevBackLogState = m_BackLogEnabled;

        if (backLogPanel != null)
        {
            if (backLogPanel.activeInHierarchy)
            {
                return;
            }
        }

/*
 *              if( currentTextBox != null && menuButton != null ){
 *                      if( ! currentTextBox.reachedEnd ){
 *                              menuButton.SetActive( false );
 *                      }
 *                      else{
 *                              menuButton.SetActive( true );
 *                      }
 *              }
 * //*/
    }
    /// <summary>
    /// SendMessage to the TextTarget.
    /// </summary>
    /// <param name='index'>
    /// Index.
    /// </param>
    void OnChangedLogIndex(int index)
    {
//		string logStr = ViNoBackLog.GetLogText( index );
        DialogPartData data = ViNoBackLog.GetItemAt(index);

        if (voiceButton != null)
        {
            voiceButton.SetActive(data.isVoice);
        }
        if (nameTextTarget != null)
        {
            if (!string.IsNullOrEmpty(data.nameText) && data.nameText.Trim() != string.Empty)
            {
                nameTextTarget.gameObject.SetActive(true);
                nameTextTarget.gameObject.SendMessage("OnUpdateText", data.nameText);
            }
            else
            {
                nameTextTarget.gameObject.SetActive(false);
            }
        }
        textTarget.gameObject.SendMessage("OnUpdateText", data.dialogText);
    }
Beispiel #12
0
    private void AddToBacklog()
    {
        if (m_MsgTargetTextBox != null)
        {
            if (!string.IsNullOrEmpty(m_MsgTargetTextBox.text))
            {
                DialogPartData data = new DialogPartData();
                data.isName = string.IsNullOrEmpty(m_CurrentText) ? false : true;
                if (data.isName)
                {
                    data.nameText = m_CurrentText;
                }
                data.dialogText    = m_MsgTargetTextBox.text;
                data.isVoice       = m_IsPlayVoice;
                data.voiceAudioID  = m_CurrentVoiceID;
                data.voiceAudioKey = m_CurrentVoiceKey;
                ViNoBackLog.Add(data);

                m_CurrentText    = "";
                m_IsPlayVoice    = false;
                m_CurrentVoiceID = 0;
            }
        }
    }
Beispiel #13
0
    static public string GetAppendedText(bool stubBr)
    {
        System.Text.StringBuilder sb   = new System.Text.StringBuilder();
        List <DialogPartData>     list = ViNoBackLog.GetLogList();

        for (int i = 0, imax = list.Count; i < imax; ++i)
        {
            if (list[i].isName)
            {
                sb.Append(list[i].nameText);
                if (stubBr)
                {
                    sb.Append("\n");
                }
            }
            sb.Append(list[i].dialogText);
            if (stubBr)
            {
                sb.Append("\n");
                sb.Append("\n");
            }
        }
        return(sb.ToString());
    }
 /// <summary>
 /// Raises the click return event.
 /// </summary>
 void OnClickReturn()
 {
     OnChangedLogIndex(ViNoBackLog.GetLogList().Count - 1);
     ClosePanel();
 }
Beispiel #15
0
 /// <summary>
 /// Toggles the show back log.
 /// </summary>
 static public void ToggleShowBackLog()
 {
     ViNoBackLog.ToggleShow();
 }
Beispiel #16
0
    public override void OnGUICustom()
    {
        List <DialogPartData> list = ViNoBackLog.GetLogList();


        GUILayout.BeginHorizontal();

        float closeBtnW = 100f;

        GUILayout.Label("BackLog", GUILayout.Width(Screen.width - 100f));

        if (GUILayout.Button("x", GUILayout.Width(closeBtnW), GUILayout.Height(50f)))
        {
            gameObject.SetActive(false);
        }

        GUILayout.Space(30f);

        GUILayout.EndHorizontal();
//*/

        m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos, false, true, GUILayout.Width(Screen.width));

        switch (displayStyle)
        {
        case DisplayStyle.TEXT_ONLY:
            GUILayout.BeginHorizontal();

            GUILayout.Space(30f);

            GUILayout.Label(m_AllText);

            GUILayout.EndHorizontal();
            break;

        case DisplayStyle.TEXT_AND_VOICE:
            for (int i = 0, imax = list.Count; i < imax; ++i)
            {
                if (nameSkin != null)
                {
                    GUI.skin = nameSkin;
                }
                if (!string.IsNullOrEmpty(list[i].nameText))
                {
                    if (list[i].nameText.Trim() != string.Empty)
                    {
                        if (GUILayout.Button(list[i].nameText, GUILayout.Width(nameWidth), GUILayout.Height(44f)))
                        {
                        }
                    }
                }

                GUILayout.BeginHorizontal();

                if (list[i].isVoice)
                {
                    if (GUILayout.Button(voiceTex, GUILayout.Width(64f), GUILayout.Height(64f)))                                       // "Voice" , GUILayout.Width( 66f ) ,  GUILayout.Height( 88f ))  ){
                    {
                        if (ISoundPlayer.Instance != null)
                        {
                            if (ISoundPlayer.Instance as ViNoSoundPlayer)
                            {
                                ISoundPlayer.Instance.PlayVoice(list[i].voiceAudioID, ViNoConfig.prefsVoiceVolume, 0f);
                            }
                            else if (ISoundPlayer.Instance as SimpleSoundPlayer)
                            {
                                ISoundPlayer.Instance.PlayVoice(list[i].voiceAudioKey, false, 0f);
                            }
                        }
                    }
                }
                else
                {
                    GUILayout.Space(66f);
                }

                if (textSkin != null)
                {
                    GUI.skin = textSkin;
                }

                if (GUILayout.Button(list[i].dialogText))                            //, GUILayout.Height( 100f ))  ){

                {
                }

                GUILayout.EndHorizontal();
            }
            break;
        }

        GUILayout.EndScrollView();

// In mobile , GUIScrollview cannot swipe. instead Show up down buttons.
#if UNITY_IPHONE || UNITY_ANDROID
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Up"))
        {
            m_ScrollPos.y -= 100f;
        }

        if (GUILayout.Button("Dwn"))
        {
            m_ScrollPos.y += 100f;
        }

        GUILayout.EndHorizontal();
#else
        if (Input.GetKey(KeyCode.UpArrow))
        {
            m_ScrollPos.y -= 10f;
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            m_ScrollPos.y += 10f;
        }
#endif
    }