Beispiel #1
0
        private void UpdateNode(TreeNode node)
        {
            if (node == null || node.Tag == null)
            {
                return;
            }
            DialogTranslation.LineData tag = node.Tag as DialogTranslation.LineData;
            if (tag.isInterjection)
            {
                node.Text = "*插入对话节点*";
            }
            else if (tag.dialogueLine.Lines.Count <= 0 || string.IsNullOrEmpty(tag.dialogueLine.Lines[0].Translation))
            {
                node.Text = "<Empty>";
            }
            else
            {
                node.Text = tag.dialogueLine.Lines[0].Translation;
            }
            if (tag.isLink)
            {
                node.ForeColor = Color.Gray;
                return;
            }
            TalkerEnum item = (TalkerEnum)tag.data.idata["speaker"];

            if (tag.isInterjection)
            {
                node.BackColor = StateColours.getIntejectionColour(item);
                return;
            }
            node.ForeColor = StateColours.getTalkerColour(item);
        }
Beispiel #2
0
        private void tvDialog_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            bool state = (int)(e.State & TreeNodeStates.Selected) != 0;

            if (e.Node.Tag != null && this.currentLine != null && (e.Node.Tag as DialogTranslation.LineData).data == this.currentLine.data)
            {
                state = true;
            }
            if (state)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, this.tvDialog.Font, e.Bounds, SystemColors.HighlightText, TextFormatFlags.Default);
                return;
            }
            if (!this.tvDialog.Focused && this.tvDialog.SelectedNode == e.Node)
            {
                e.Graphics.FillRectangle(SystemBrushes.ControlLight, e.Bounds);
            }
            else if (e.Node.BackColor.IsEmpty)
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
            }
            else
            {
                using (SolidBrush solidBrush = new SolidBrush(e.Node.BackColor))
                {
                    e.Graphics.FillRectangle(solidBrush, e.Bounds);
                }
            }
            Color foreColor = e.Node.ForeColor;

            if (e.Node.Tag != null)
            {
                DialogTranslation.LineData tag = e.Node.Tag as DialogTranslation.LineData;
                if (tag.dialogueLine.State != TranslationManager.DialogueTranslationState.OK)
                {
                    using (Pen pen = new Pen(Color.Red))
                    {
                        pen.DashStyle = DashStyle.Dot;
                        Rectangle bounds = e.Bounds;
                        bounds.Size = new System.Drawing.Size(bounds.Width - 1, bounds.Height - 1);
                        e.Graphics.DrawRectangle(pen, bounds);
                    }
                }
                if (!tag.isLink)
                {
                    foreColor = StateColours.getTalkerColour((TalkerEnum)tag.data["speaker"]);
                }
            }
            TextRenderer.DrawText(e.Graphics, e.Node.Text, this.tvDialog.Font, e.Bounds, foreColor, TextFormatFlags.Default);
        }
Beispiel #3
0
        private bool findLine(string pattern, TreeNodeCollection nodes)
        {
            bool        flag;
            IEnumerator enumerator = nodes.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    TreeNode current = (TreeNode)enumerator.Current;
                    DialogTranslation.LineData tag = current.Tag as DialogTranslation.LineData;
                    List <TranslationManager.TranslationDialogueLine.Line> .Enumerator enumerator1 = tag.dialogueLine.Lines.GetEnumerator();
                    try
                    {
                        while (enumerator1.MoveNext())
                        {
                            TranslationManager.TranslationDialogueLine.Line line = enumerator1.Current;
                            if (!NavigationTranslation.contains(pattern, line.Original) && !NavigationTranslation.contains(pattern, line.Translation))
                            {
                                continue;
                            }
                            this.tvDialog.SelectedNode = current;
                            flag = true;
                            return(flag);
                        }
                    }
                    finally
                    {
                        ((IDisposable)enumerator1).Dispose();
                    }
                    if (tag.isLink || !this.findLine(pattern, current.Nodes))
                    {
                        continue;
                    }
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            return(flag);
        }
Beispiel #4
0
 private void createConversationTree(GameData.Item item, TreeNodeCollection nodes)
 {
     foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair in item.referenceData("lines", false))
     {
         GameData.Item item1 = this.gameData.getItem(keyValuePair.Key);
         if (item1 != null)
         {
             if (item1.getState() == GameData.State.REMOVED)
             {
                 continue;
             }
             bool     value    = keyValuePair.Value.v0 == 50;
             TreeNode treeNode = nodes.Add(keyValuePair.Key, string.Empty);
             DialogTranslation.LineData lineDatum = new DialogTranslation.LineData()
             {
                 data           = item1,
                 isLink         = value,
                 isInterjection = (!item1.ContainsKey("interjection") ? false : item1.bdata["interjection"]),
                 dialogueLine   = TranslationManager.DialogueLines[item1],
                 node           = treeNode,
                 multiple       = value
             };
             treeNode.Tag = lineDatum;
             this.UpdateNode(treeNode);
             if (value)
             {
                 TreeNode[] treeNodeArray = this.tvDialog.Nodes.Find(keyValuePair.Key, true);
                 for (int i = 0; i < (int)treeNodeArray.Length; i++)
                 {
                     (treeNodeArray[i].Tag as DialogTranslation.LineData).multiple = true;
                 }
             }
             if (value)
             {
                 continue;
             }
             this.createConversationTree(item1, treeNode.Nodes);
         }
         else
         {
             TreeNode red = nodes.Add(keyValuePair.Key, string.Concat("ERROR: Dialog line missing: ", keyValuePair.Key));
             red.BackColor = Color.Red;
             red.ForeColor = Color.White;
         }
     }
     this.tvDialog.ExpandAll();
 }
Beispiel #5
0
 private void tvDialog_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (this.tvDialog.SelectedNode == null)
     {
         return;
     }
     DialogTranslation.LineData tag = this.tvDialog.SelectedNode.Tag as DialogTranslation.LineData;
     if (tag != null)
     {
         this.ShowLine(tag);
         if (tag.multiple || this.multipleSelected)
         {
             this.tvDialog.Refresh();
         }
         this.multipleSelected = tag.multiple;
     }
     this.btnAddLine.Enabled = tag != null;
 }
Beispiel #6
0
        private void ShowLine(DialogTranslation.LineData line)
        {
            TalkerEnum item;

            PropertyGrid.PropertyGrid.Item item1;
            int num;

            this.currentLine = line;
            if (!line.data.idata.ContainsKey("speaker"))
            {
                this.lbSpeaker.Text = "-";
            }
            else
            {
                Label str = this.lbSpeaker;
                item     = (TalkerEnum)line.data.idata["speaker"];
                str.Text = item.ToString();
            }
            if (!line.data.idata.ContainsKey("target is type"))
            {
                this.lbTarget.Text = "-";
            }
            else
            {
                Label             label             = this.lbTarget;
                CharacterTypeEnum characterTypeEnum = (CharacterTypeEnum)line.data.idata["target is type"];
                label.Text = characterTypeEnum.ToString();
            }
            this.lvConditions.Items.Clear();
            foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair in line.data.referenceData("conditions", false))
            {
                GameData.Item item2 = this.gameData.getItem(keyValuePair.Key);
                if (item2.sdata.ContainsKey("compare by"))
                {
                    string        str1  = item2.sdata["compare by"];
                    GameData.Item item3 = item2;
                    if (str1 == "==")
                    {
                        num = 0;
                    }
                    else
                    {
                        num = (str1 == "<" ? 1 : 2);
                    }
                    item3["compare by"] = num;
                }
                DialogConditionEnum dialogConditionEnum = (DialogConditionEnum)item2.idata["condition name"];
                int value = keyValuePair.Value.v0;
                if (!item2.idata.ContainsKey("who"))
                {
                    item2.idata["who"] = 0;
                }
                string[] strArrays = new string[] { "==", "<", ">" };
                ListView.ListViewItemCollection items = this.lvConditions.Items;
                item = (TalkerEnum)item2.idata["who"];
                ListViewItem listViewItem = items.Add(item.ToString());
                listViewItem.SubItems.Add(dialogConditionEnum.ToString());
                listViewItem.SubItems.Add(strArrays[item2.idata["compare by"]]);
                listViewItem.SubItems.Add(value.ToString());
                if (dialogConditionEnum == DialogConditionEnum.DC_HAS_TAG)
                {
                    ListViewItem.ListViewSubItemCollection subItems = listViewItem.SubItems;
                    CharacterPerceptionTags_LongTerm       characterPerceptionTagsLongTerm = (CharacterPerceptionTags_LongTerm)item2.idata["tag"];
                    subItems.Add(characterPerceptionTagsLongTerm.ToString());
                }
                if (dialogConditionEnum < DialogConditionEnum.DC_PERSONALITY_TAG)
                {
                    continue;
                }
                ListViewItem.ListViewSubItemCollection listViewSubItemCollections = listViewItem.SubItems;
                PersonalityTags personalityTag = (PersonalityTags)item2.idata["tag"];
                listViewSubItemCollections.Add(personalityTag.ToString());
            }
            this.lvEffects.Items.Clear();
            foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair1 in line.data.referenceData("effects", false))
            {
                GameData.Item item4 = this.gameData.getItem(keyValuePair1.Key);
                if (item4 == null || item4.getState() == GameData.State.REMOVED)
                {
                    this.lvEffects.Items.Add("Error - invalid reference").ForeColor = Color.Red;
                }
                else if (!item4.sdata.ContainsKey("action name"))
                {
                    DialogActionEnum dialogActionEnum = (DialogActionEnum)item4.idata["action name"];
                    this.lvEffects.Items.Add(dialogActionEnum.ToString()).SubItems.Add(keyValuePair1.Value.v0.ToString());
                }
                else
                {
                    this.lvEffects.Items.Add(item4.sdata["action name"]).SubItems.Add(keyValuePair1.Value.v0.ToString());
                }
            }
            this.referenceList1.refresh(line.data);
            this.grid.clear();
            ExtendedTranslationText extendedTranslationText = new ExtendedTranslationText();

            if ((!line.data.ContainsKey("interjection") ? false : line.data.bdata["interjection"]))
            {
                return;
            }
            foreach (TranslationManager.TranslationDialogueLine.Line line1 in line.dialogueLine.Lines)
            {
                if (!line1.IsUser)
                {
                    item1 = this.grid.addItem(line1.Key, "Translation", line1.Translation, string.Empty, new Color?(this.stateColors[(int)line1.State]), true);
                    this.grid.addItem(line1.Key, "Original", line1.Original, string.Empty, new Color?(this.stateColors[0]), false).Data = line1;
                }
                else
                {
                    item1 = this.grid.addItem("Text", line1.Key, line1.Translation, string.Empty, new Color?(this.stateColors[(int)line1.State]), true);
                }
                item1.Data     = line1;
                item1.Property = extendedTranslationText;
            }
        }