Exemplo n.º 1
0
    public static void Save(List <SubMeta> meta, string path)
    {
        var writer = new StreamWriter(path);

        for (int i = 0; i < meta.Count; i++)
        {
            SubMeta m = meta[i];
            writer.WriteLine(m.Subtitle.Index);
            string time = TimeToString(m.Subtitle.Start) + " --> " + TimeToString(m.Subtitle.End);
            writer.WriteLine(time);

            writer.WriteLine("Speaker: " + m.Character);

            for (int j = 0; j < m.Subtitle.Text.Count; j++)
            {
                writer.WriteLine(m.Subtitle.Text[j]);
            }

            writer.WriteLine("");
        }

        writer.Close();

        Debug.Log("Saved SRT to: " + path);
    }
Exemplo n.º 2
0
    private void OnGUI()
    {
        SubMeta m = _metasubs[_index];

        if (m != null)
        {
            GUILayout.BeginArea(new Rect(Screen.width - 100f, 0f, 100f, Screen.height), GUI.skin.box);
            {
                GUILayout.Label(_index + "/" + _metasubs.Count);
                for (int i = 0; i < 18; i++)
                {
                    GUI.color = (DeadwoodChar)i == m.Character ? Color.blue : Color.white;
                    if (GUILayout.Button(((DeadwoodChar)i).ToString()))
                    {
                        m.Character = (DeadwoodChar)i;
                        _isDirty    = true;
                        GoTo(_index + 1);
                    }
                }
            }
            GUILayout.EndArea();

            GUILayout.BeginArea(new Rect(Screen.width / 2f - 300f, Screen.height - 100f, 600f, 100), GUI.skin.box);
            {
                GUI.color = Color.white;
                GUILayout.Label(m.Character + ": ");
                GUILayout.Space(10f);
                for (int i = 0; i < m.Subtitle.Text.Count; i++)
                {
                    GUILayout.Label(m.Subtitle.Text[i]);
                }
            }
            GUILayout.EndArea();

            GUILayout.BeginArea(new Rect(Screen.width - 100f, Screen.height - 100, 100f, 100f), GUI.skin.box);
            {
                if (GUILayout.Button("Load"))
                {
                    LoadJSON();
                }
                GUILayout.Space(32);
                if (GUILayout.Button("Save"))
                {
                    Save();
                }
            }
            GUILayout.EndArea();
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        if (!_vid.isPrepared)
        {
            return;
        }

        SubMeta m = _metasubs[_index];

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (m != null)
            {
                PlayFrom(m.Subtitle.Start);
            }
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            GoTo(_index - 1);
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            GoTo(_index - 10);
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            GoTo(_index + 1);
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            GoTo(_index + 10);
        }

        if (_vid.time >= m.Subtitle.End + 0.25f)
        {
            _vid.Pause();
        }
    }