Beispiel #1
0
    public override void UpdateLayoutElement()
    {
        float preferredHeight = 0.0f;

        foreach (DateUI dateUI in dateUIlist_)
        {
            float     datePreferredHeight = 0;
            Transform parent = dateUI.GetComponentInChildren <VerticalLayoutGroup>().transform;
            for (int i = 0; i < parent.childCount; ++i)
            {
                LogTree logTree = parent.GetChild(i).GetComponent <LogTree>();
                if (logTree != null && logTree.gameObject.activeInHierarchy)
                {
                    logTree.UpdateLayoutElement(applyMinHeight: false);
                    datePreferredHeight += logTree.GetComponent <LayoutElement>().preferredHeight;
                }
                else if (parent.GetChild(i).GetComponent <LogTitleText>() != null)
                {
                    datePreferredHeight += 30;
                }
            }
            datePreferredHeight = Math.Max(GameContext.Config.MinLogTreeHeight, datePreferredHeight);
            dateUI.GetComponent <LayoutElement>().preferredHeight = datePreferredHeight;
            preferredHeight += datePreferredHeight + 5;
        }
        preferredHeight        += 200;
        layout_.preferredHeight = preferredHeight;
        contentSizeFitter_.SetLayoutVertical();
    }
Beispiel #2
0
    public void OnOverflowArrowInput(LogTree tree, KeyCode key)
    {
        int index     = logTrees_.IndexOf(tree);
        int nextIndex = index + 1;

        while (nextIndex < logTrees_.Count - 1 && logTrees_[nextIndex].gameObject.activeInHierarchy == false)
        {
            ++nextIndex;
        }
        int prevIndex = index - 1;

        while (prevIndex > 0 && logTrees_[prevIndex].gameObject.activeInHierarchy == false)
        {
            --prevIndex;
        }
        switch (key)
        {
        case KeyCode.DownArrow:
        {
            Line next = (nextIndex < logTrees_.Count ? logTrees_[nextIndex].RootLine[0] : null);
            if (next != null)
            {
                next.Field.IsFocused = true;
            }
        }
        break;

        case KeyCode.UpArrow:
        {
            Line prev = (prevIndex >= 0 ? logTrees_[prevIndex].RootLine.LastVisibleLine : null);
            if (prev != null)
            {
                prev.Field.IsFocused = true;
            }
        }
        break;

        case KeyCode.RightArrow:
        {
            Line next = (nextIndex < logTrees_.Count ? logTrees_[nextIndex].RootLine[0] : null);
            if (next != null)
            {
                next.Field.CaretPosision = 0;
                next.Field.IsFocused     = true;
            }
        }
        break;

        case KeyCode.LeftArrow:
        {
            Line prev = (prevIndex >= 0 ? logTrees_[prevIndex].RootLine.LastVisibleLine : null);
            if (prev != null)
            {
                prev.Field.CaretPosision = prev.TextLength;
                prev.Field.IsFocused     = true;
            }
        }
        break;
        }
    }
Beispiel #3
0
    public override void LoadMore()
    {
        DateTime date      = endDate_;
        int      loadCount = GameContext.Config.LogLoadUnit;

        while (loadCount > 0)
        {
            DateUI dateUI = Instantiate(DateUIPrefab.gameObject, this.transform).GetComponent <DateUI>();
            dateUI.Set(date, ToColor(date));
            dateUI.SetEnableAddDateButtton(false);
            dateUIlist_.Add(dateUI);
            Transform parent = dateUI.GetComponentInChildren <VerticalLayoutGroup>().transform;
            foreach (TreeNote treeNote in GameContext.Window.MainTabGroup.TreeNotes)
            {
                LogTitleText titleText = Instantiate(TitleTextPrefab.gameObject, dateUI.GetComponentInChildren <VerticalLayoutGroup>().transform).GetComponent <LogTitleText>();
                titleTextlist_.Add(titleText);
                string  filename = ToFileName(treeNote, date);
                LogTree logTree  = null;
                if (File.Exists(filename))
                {
                    logTree = LoadLogTree(parent, date, filename);
                    logTrees_.Add(logTree);
                }
                titleText.Intialize(this, filename, logTree, treeNote.Tree.TitleText);
            }
            date = date.AddDays(-1.0);
            --loadCount;
        }
        endDate_ = date;
        UpdateLayoutElement();
    }
Beispiel #4
0
    public override void OnTabSelected()
    {
        base.OnTabSelected();

        SubscribeKeyInput();

        GameContext.Window.LogTabButton.OwnerNote = null;

        List <string> filepathList = new List <string>(EditedLogTreeDict.Keys);

        foreach (string filepath in filepathList)
        {
            string  filename = Path.GetFileName(filepath);
            LogTree logTree  = logTrees_.Find((LogTree lt) => lt.File.Name == filename);
            if (logTree != null)
            {
                logTree.ReloadFile();
                EditedLogTreeDict.Remove(logTree.File.FullName);
            }
            else
            {
                LogTitleText titleText = titleTextlist_.Find((LogTitleText tt) => tt.name == filename);
                if (titleText != null)
                {
                    logTree = InsertLogTree(titleText, titleText.GetComponentInParent <DateUI>().Date, filepath);
                    titleText.OnLoad(logTree);
                    EditedLogTreeDict.Remove(titleText.FilePath);
                }
            }
        }
    }
Beispiel #5
0
    public override void OnEdited(object sender, EventArgs e)
    {
        base.OnEdited(sender, e);
        LogTree logTree = sender as LogTree;

        if (EditedLogTreeDict.ContainsValue(logTree) == false)
        {
            EditedLogTreeDict.Add(logTree.File.FullName, logTree);
        }
    }
Beispiel #6
0
    protected LogTree LoadLogTree(Transform parent, DateTime date, string filename)
    {
        LogTree logTree = Instantiate(LogTreePrefab.gameObject, parent).GetComponent <LogTree>();

        logTree.Initialize(this, new ActionManagerProxy(actionManager_), heapManager_);
        logTree.LoadLog(new FileInfo(filename), date);
        logTree.SubscribeKeyInput();
        logTree.OnEdited += this.OnEdited;

        return(logTree);
    }
Beispiel #7
0
    public LogTree InsertLogTree(LogTitleText titleText, DateTime date, string filename)
    {
        LogTree logTree = LoadLogTree(titleText.transform.parent, date, filename);

        logTree.gameObject.transform.SetSiblingIndex(titleText.transform.GetSiblingIndex() + 1);

        // search insert index
        int  insertIndex = -1;
        bool find        = false;

        // 同じDateUIの子供から探し始める
        for (int i = 0; i < titleText.transform.parent.childCount; ++i)
        {
            LogTree existLogTree = titleText.transform.parent.GetChild(i).GetComponent <LogTree>();
            if (logTree == existLogTree)
            {
                find = true;
                if (insertIndex >= 0)
                {
                    // 直前のLogTreeが見つかってるのでここでOK
                    break;
                }
            }
            else if (existLogTree != null)
            {
                insertIndex = logTrees_.IndexOf(existLogTree) + 1;
                if (find)
                {
                    // ここが直後のLogTreeになるのでその前に差し込む
                    insertIndex -= 1;
                    break;
                }
            }
        }
        // DateUIに他のTreeが無いようなので、logTrees_で探索する
        if (insertIndex < 0)
        {
            for (int i = 0; i < logTrees_.Count; ++i)
            {
                if (logTrees_[i].Date < logTree.Date)
                {
                    insertIndex = i;
                    break;
                }
            }
        }
        logTrees_.Insert(insertIndex, logTree);

        UpdateLayoutElement();

        return(logTree);
    }
Beispiel #8
0
 public void Intialize(DiaryNote owner, string filepath, LogTree logTree, string text)
 {
     ownerNote_ = owner;
     name       = Path.GetFileName(filepath);
     filepath_  = filepath;
     logTree_   = logTree;
     GetComponentInChildren <Text>().text = text;
     graphic_ = GetComponent <Button>().targetGraphic;
     if (logTree_ == null)
     {
         graphic_.color = ColorManager.MakeAlpha(graphic_.color, 0.6f);
     }
 }
Beispiel #9
0
    protected LogTree LoadLogTree(DateTime date, string filename)
    {
        DateUI  dateUI  = Instantiate(DateUIPrefab.gameObject, this.transform).GetComponent <DateUI>();
        LogTree logTree = Instantiate(LogTreePrefab.gameObject, dateUI.transform).GetComponent <LogTree>();

        dateUI.Set(date, ToColor(date));
        dateUI.SetEnableAddDateButtton(File.Exists(ToFileName(treeNote_, date.AddDays(-1.0))) == false);
        logTree.Initialize(this, new ActionManagerProxy(actionManager_), heapManager_);
        logTree.LoadLog(new FileInfo(filename), date);
        logTree.SubscribeKeyInput();
        logTree.OnEdited += this.OnEdited;
        logTrees_.Add(logTree);
        return(logTree);
    }
Beispiel #10
0
        public void Static_SettreeViewLogTree()
        {
            LogTree.Nodes.Clear();

            if (!Directory.Exists(m_LogPathRoot) && m_LogPathRoot != string.Empty)
            {
                Directory.CreateDirectory(m_LogPathRoot);
            }

            DirectoryInfo root     = new DirectoryInfo(m_LogPathRoot);
            TreeNode      treeNode = new TreeNode(root.FullName, 0, 0);

            LogTree.Nodes.Add(treeNode);
            Static_LoopDir(root, treeNode);
            LogTree.ExpandAll();
        }
Beispiel #11
0
    public void SetSortedIndex(LogTree logTree)
    {
        if (logTrees_.Contains(logTree))
        {
            logTrees_.Remove(logTree);
        }

        int insertIndex = logTrees_.Count;

        for (int i = 0; i < logTrees_.Count; ++i)
        {
            if (logTrees_[i].Date < logTree.Date)
            {
                insertIndex = i;
                break;
            }
        }
        logTrees_.Insert(insertIndex, logTree);
        logTree.GetComponentInParent <DateUI>().transform.SetSiblingIndex(insertIndex);
        UpdateLayoutElement();
    }
Beispiel #12
0
    public override void ReloadNote()
    {
        DateTime       date           = DateTime.Now;
        List <LogTree> cachedLogTrees = new List <LogTree>(logTrees_);

        logTrees_.Clear();
        foreach (DateUI dateUI in dateUIlist_)
        {
            Transform parent = dateUI.GetComponentInChildren <VerticalLayoutGroup>().transform;
            foreach (TreeNote treeNote in GameContext.Window.MainTabGroup.TreeNotes)
            {
                string filename = ToFileName(treeNote, date);
                if (File.Exists(filename))
                {
                    LogTree existTree = cachedLogTrees.Find((LogTree lt) => lt.File.Name == Path.GetFileName(filename));
                    if (existTree != null)
                    {
                        existTree.ReloadFile();
                        logTrees_.Add(existTree);
                    }
                    else
                    {
                        Transform titleObj = parent.Find(Path.GetFileName(filename));
                        if (titleObj != null)
                        {
                            LogTree logTree = LoadLogTree(parent, date, filename);
                            logTree.gameObject.transform.SetSiblingIndex(titleObj.GetSiblingIndex() + 1);
                            logTrees_.Add(logTree);
                            titleObj.GetComponent <LogTitleText>().OnLoad(logTree);
                        }
                    }
                }
            }
        }
        UpdateLayoutElement();
    }
Beispiel #13
0
    public void Initialize(TreeNote treeNote)
    {
        treeNote_ = treeNote;

        string directoryName = ToDirectoryName(treeNote_);

        if (Directory.Exists(directoryName) == false)
        {
            Directory.CreateDirectory(directoryName);
        }
        string header = treeNote_.File.Name.Replace(".dtml", "");

        foreach (string path in Directory.GetFiles(directoryName))
        {
            // path would be like "dones-2017-01-01.dtml"
            if (Path.GetExtension(path) == ".dtml")
            {
                // splitPath would be like "[dones][2017][01][01]"
                string[] splitPath = Path.GetFileNameWithoutExtension(path).Split('-');
                int      year, month, day;
                if (splitPath.Length == 4 && splitPath[0] == header && int.TryParse(splitPath[1], out year) && int.TryParse(splitPath[2], out month) && int.TryParse(splitPath[3], out day))
                {
                    DateTime date = new DateTime(year, month, day);
                    logFileList_.Add(date, path);
                }
            }
        }

        today_     = DateTime.Now.Date;
        endDate_   = today_;
        todayTree_ = LoadLogTree(today_, ToFileName(treeNote_, today_));
        if (logFileList_.ContainsKey(today_.Date))
        {
            logFileList_.Remove(today_.Date);
        }
    }
Beispiel #14
0
 public void OnLoad(LogTree logTree)
 {
     logTree_       = logTree;
     graphic_.color = ColorManager.MakeAlpha(graphic_.color, 1.0f);
 }
Beispiel #15
0
    public void AddDate(DateTime date)
    {
        LogTree logTree = LoadLogTree(date, ToFileName(treeNote_, date));

        SetSortedIndex(logTree);
    }