Example #1
0
        private void RenameBlock(int fileid, int blockid, string name)
        {
            TreeNode   node  = tree.Nodes[fileid].Nodes[blockid];
            QuestBlock block = (QuestBlock)node.Tag;

            block.Name = name;
            node.Text  = block.GetNodeText(blockid);
            form.SelectNode(node);
        }
Example #2
0
        private void AddBlock(int fileid, int blockid, QuestBlock block, bool Expand)
        {
            TreeNode newNode = form.AddToTree(block, tree.Nodes[fileid], blockid);

            form.SelectNode(newNode);

            if (Expand)
            {
                newNode.Expand();
            }
        }
Example #3
0
        // Clone is only to be used when the Block has been generated from a tree. Otherwise edits will be missing
        public QuestBlock Clone()
        {
            QuestBlock block = new QuestBlock();

            block.Name = this.Name;

            foreach (QuestTrigger t in this.Triggers)
            {
                block.Triggers.Add(t.Clone());
            }

            return(block);
        }
Example #4
0
        public void Load(string Filename)
        {
            this.FileName = Filename;

            FileHandler fh = new FileHandler(Filename, FileHandler.FileOpenMode.Reading, Encoding.GetEncoding("EUC-KR"));

            Version = fh.Read <int>();
            int blockCount = fh.Read <int>();

            Title = fh.Read <string>(fh.Read <short>()).Trim('\0');

            for (int i = 0; i < blockCount; i++)
            {
                QuestBlock block = new QuestBlock();

                int triggersCount = fh.Read <int>();
                block.Name = fh.Read <string>(fh.Read <short>()).Trim('\0');

                for (int j = 0; j < triggersCount; j++)
                {
                    QuestTrigger trigger = new QuestTrigger();
                    trigger.CheckNext = (fh.Read <byte>() != 0);
                    int ConditionsCount = fh.Read <int>();
                    int RewardsCount    = fh.Read <int>();
                    trigger.Name = fh.Read <string>(fh.Read <short>()).Trim('\0');

                    for (int c = 0; c < ConditionsCount; c++)
                    {
                        int    size = fh.Read <int>();
                        int    type = fh.Read <int>();
                        byte[] data = fh.Read <byte[]>(size - 8);

                        try
                        {
                            object obj = CreateObject((ConditionType)type);
                            StructReader.Convert(data, ref obj);

                            Condition condition = (Condition)obj;
                            condition.setOriginalData(data);
                            trigger.Conditions.Add(condition);
                        }
                        catch
                        {
                            object    obj       = CreateObject(ConditionType.COND000);
                            Condition condition = (Condition)obj;
                            condition.setOriginalData(data);
                            trigger.Conditions.Add(condition);
                        }
                    }

                    for (int c = 0; c < RewardsCount; c++)
                    {
                        int    size = fh.Read <int>();
                        int    type = fh.Read <int>() & 0x0ffff;
                        byte[] data = fh.Read <byte[]>(size - 8);

                        try
                        {
                            object obj = CreateObject((RewardType)type);
                            StructReader.Convert(data, ref obj);
                            Reward reward = (Reward)obj;
                            reward.setOriginalData(data);
                            trigger.Rewards.Add(reward);
                        }
                        catch
                        {
                            object obj    = CreateObject(RewardType.REWD000);
                            Reward reward = (Reward)obj;
                            reward.setOriginalData(data);
                            trigger.Rewards.Add(reward);
                        }
                    }
                    block.Triggers.Add(trigger);
                }
                this.Blocks.Add(block);
            }
            fh.Close();
        }