コード例 #1
0
ファイル: Data.cs プロジェクト: Temperament/FiestaShark
        public void LoadItemInfo()
        {
            if (File.Exists(@"ItemInfo.shn"))
            {
                if (!ItemsLoadet)
                {
                    ItemsByID = new Dictionary<ushort, ItemInfo>();
                    ItemsByName = new Dictionary<string, ItemInfo>();
                    using (var file = new SHNFile(@"ItemInfo.shn"))
                    {
                        using (DataTableReaderEx reader = new DataTableReaderEx(file))
                        {

                            while (reader.Read())
                            {
                                ItemInfo info = ItemInfo.Load(reader);
                                if (ItemsByID.ContainsKey(info.ItemID) || ItemsByName.ContainsKey(info.InxName))
                                {

                                    continue;
                                }
                                ItemsByID.Add(info.ItemID, info);
                                ItemsByName.Add(info.InxName, info);
                            }
                        }
                    }
                    ItemsLoadet = true;
                    MessageBox.Show("ItemInfo Load successful");
                }
            }
            else
            {
                MessageBox.Show("ItemInfo not Found in The Directory from the Program");
            }
        }
コード例 #2
0
        public QuestFile(string filePath, bool newFile = false, string mobInfo = "", string itemInfo = "")
        {
            FilePath  = filePath;
            IsSaved   = true;
            isNewFile = newFile;

            if (!newFile)
            {
                QuestDialog = new SHNFile(Path.Combine(Path.GetDirectoryName(filePath), "QuestDialog.shn"));
                MobInfo     = new SHNFile(Path.Combine(Path.GetDirectoryName(filePath), "MobInfo.shn"));

                if (!File.Exists(QuestDialog.FilePath))
                {
                    throw new Exception("QuestDialog.shn cannot be found. Make sure it is in the same directory.");
                }
            }
            else
            {
                MobInfo = new SHNFile(mobInfo);

                QuestDialog = new SHNFile("QuestDialog.shn");
                QuestDialog.CreateFile();
                QuestDialog.Columns.Add(new SHNColumn("ID", -1, SHNType.UInt32, typeof(uint)));
                QuestDialog.Columns.Add(new SHNColumn("Dialog", 50, SHNType.UInt32, typeof(uint)));
            }

            Init();
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: dakaraic/QuestEditor
        private void ParseQuestDialog(string fileName)
        {
            var path = Path.GetDirectoryName(fileName) + "/QuestDialog.shn";

            if (!File.Exists(path))
            {
                MessageBox.Show("Failed to open corresponding QuestDialog.shn.\nYou can still edit quests, just without the dialogs.");
                return;
            }

            QuestDialog = new Dictionary <uint, string>();

            using (var file = new SHNFile(path))
                using (var reader = new DataTableReader(file.Table))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            var id = Convert.ToUInt32(reader.GetValue(0));
                            QuestDialog.Remove(id);
                            QuestDialog.Add(id, reader.GetString(1));
                        }
                    }
                }
        }
コード例 #4
0
 public void LoadItemInfo()
 {
     if (File.Exists(@"ItemInfo.shn"))
     {
         if (!ItemsLoadet)
         {
             ItemsByID   = new Dictionary <ushort, ItemInfo>();
             ItemsByName = new Dictionary <string, ItemInfo>();
             using (var file = new SHNFile(@"ItemInfo.shn"))
             {
                 using (DataTableReaderEx reader = new DataTableReaderEx(file))
                 {
                     while (reader.Read())
                     {
                         ItemInfo info = ItemInfo.Load(reader);
                         if (ItemsByID.ContainsKey(info.ItemID) || ItemsByName.ContainsKey(info.InxName))
                         {
                             continue;
                         }
                         ItemsByID.Add(info.ItemID, info);
                         ItemsByName.Add(info.InxName, info);
                     }
                 }
             }
             ItemsLoadet = true;
             MessageBox.Show("ItemInfo Load successful");
         }
     }
     else
     {
         MessageBox.Show("ItemInfo not Found in The Directory from the Program");
     }
 }
コード例 #5
0
        public void LoadItemInfo()
        {
            Dictionary <string, ItemUseEffectInfo> effectcache = new Dictionary <string, ItemUseEffectInfo>();

            ItemUseEffects = new Dictionary <ushort, ItemUseEffectInfo>();
            using (var file = new SHNFile(folder + @"\ItemUseEffect.shn"))
            {
                using (DataTableReaderEx reader = new DataTableReaderEx(file))
                {
                    while (reader.Read())
                    {
                        string            inxname;
                        ItemUseEffectInfo info = ItemUseEffectInfo.Load(reader, out inxname);
                        effectcache.Add(inxname, info);
                    }
                }
            }


            ItemsByID   = new Dictionary <ushort, ItemInfo>();
            ItemsByName = new Dictionary <string, ItemInfo>();
            using (var file = new SHNFile(folder + @"\ItemInfo.shn"))
            {
                using (DataTableReaderEx reader = new DataTableReaderEx(file))
                {
                    while (reader.Read())
                    {
                        ItemInfo info = ItemInfo.Load(reader);
                        if (ItemsByID.ContainsKey(info.ItemID) || ItemsByName.ContainsKey(info.InxName))
                        {
                            Log.WriteLine(LogLevel.Warn, "Duplicate item found ID: {0} ({1}).", info.ItemID, info.InxName);
                            continue;
                        }
                        ItemsByID.Add(info.ItemID, info);
                        ItemsByName.Add(info.InxName, info);

                        if (effectcache.ContainsKey(info.InxName))
                        {
                            if (info.Type != ItemType.Useable)
                            {
                                Log.WriteLine(LogLevel.Warn, "Invalid useable item: {0} ({1})", info.ItemID, info.InxName);
                                continue;
                            }
                            ItemUseEffectInfo effectinfo = effectcache[info.InxName];
                            effectinfo.ID = info.ItemID;
                            ItemUseEffects.Add(effectinfo.ID, effectinfo);
                        }
                    }
                }
            }
            effectcache.Clear();
            Log.WriteLine(LogLevel.Info, "Loaded {0} items.", ItemsByID.Count);
        }
コード例 #6
0
 public void LoadMiniHouseInfo()
 {
     MiniHouses = new Dictionary <ushort, MiniHouseInfo>();
     using (var file = new SHNFile(folder + @"\MiniHouse.shn"))
     {
         using (DataTableReaderEx reader = new DataTableReaderEx(file))
         {
             while (reader.Read())
             {
                 MiniHouseInfo mhi = new MiniHouseInfo(reader);
                 MiniHouses.Add(mhi.ID, mhi);
             }
         }
     }
     Log.WriteLine(LogLevel.Info, "Loaded {0} Mini Houses.", MiniHouses.Count);
 }
コード例 #7
0
ファイル: DataProvider.cs プロジェクト: Canic/Zepheus_2k15
 private void LoadBadNames()
 {
     BadNames = new List <string>();
     using (var file = new SHNFile(folder + @"\BadNameFilter.shn"))
     {
         using (DataTableReaderEx reader = new DataTableReaderEx(file))
         {
             while (reader.Read())
             {
                 // Columns: BadName Type
                 BadNames.Add(reader.GetString("BadName").ToLower());
             }
         }
     }
     Log.WriteLine(LogLevel.Info, "Loaded {0} bad names.", BadNames.Count);
 }
コード例 #8
0
        private void LoadMobs()
        {
            MobsByID   = new Dictionary <ushort, MobInfo>();
            MobsByName = new Dictionary <string, MobInfo>();
            using (var file = new SHNFile(folder + @"\MobInfo.shn"))
            {
                using (DataTableReaderEx reader = new DataTableReaderEx(file))
                {
                    while (reader.Read())
                    {
                        MobInfo info = MobInfo.Load(reader);
                        if (MobsByID.ContainsKey(info.ID) || MobsByName.ContainsKey(info.Name))
                        {
                            Log.WriteLine(LogLevel.Warn, "Duplicate mob ID found in MobInfo.shn: {0}.", info.ID);
                            continue;
                        }
                        MobsByID.Add(info.ID, info);
                        MobsByName.Add(info.Name, info);
                    }
                }
            }
            Log.WriteLine(LogLevel.Info, "Loaded {0} mobs.", MobsByID.Count);

            MobData = new Dictionary <string, MobInfoServer>();
            using (var file = new SHNFile(folder + @"\MobInfoServer.shn"))
            {
                using (DataTableReaderEx reader = new DataTableReaderEx(file))
                {
                    while (reader.Read())
                    {
                        MobInfoServer info = MobInfoServer.Load(reader);
                        if (MobData.ContainsKey(info.InxName))
                        {
                            Log.WriteLine(LogLevel.Warn, "Duplicate mob ID found in MobInfoServer.shn: {0}.", info.InxName);
                            continue;
                        }
                        MobData.Add(info.InxName, info);
                    }
                }
            }
            Log.WriteLine(LogLevel.Info, "Loaded {0} mob infos.", MobsByID.Count);
        }
コード例 #9
0
 private void LoadActiveSkills()
 {
     ActiveSkillsByID   = new Dictionary <ushort, ActiveSkillInfo>();
     ActiveSkillsByName = new Dictionary <string, ActiveSkillInfo>();
     using (var file = new SHNFile(folder + @"\ActiveSkill.shn"))
     {
         using (DataTableReaderEx reader = new DataTableReaderEx(file))
         {
             while (reader.Read())
             {
                 ActiveSkillInfo info = ActiveSkillInfo.Load(reader);
                 if (ActiveSkillsByID.ContainsKey(info.ID) || ActiveSkillsByName.ContainsKey(info.Name))
                 {
                     Log.WriteLine(LogLevel.Warn, "Duplicate ActiveSkill found: {0} ({1})", info.ID, info.Name);
                     continue;
                 }
                 ActiveSkillsByID.Add(info.ID, info);
                 ActiveSkillsByName.Add(info.Name, info);
             }
         }
     }
     Log.WriteLine(LogLevel.Info, "Loaded {0} ActiveSkills.", ActiveSkillsByID.Count);
 }
コード例 #10
0
        public void LoadMaps(List <ushort> toload = null)
        {
            MapsByID   = new Dictionary <ushort, MapInfo>();
            MapsByName = new Dictionary <string, MapInfo>();
            using (var file = new SHNFile(folder + @"\MapInfo.shn"))
            {
                using (DataTableReaderEx reader = new DataTableReaderEx(file))
                {
                    while (reader.Read())
                    {
                        MapInfo info = MapInfo.Load(reader);
                        info.NPCs = new List <ShineNPC>();
                        if (MapsByID.ContainsKey(info.ID))
                        {
                            Log.WriteLine(LogLevel.Debug, "Duplicate map ID {0} ({1})", info.ID, info.FullName);
                            MapsByID.Remove(info.ID);
                            MapsByName.Remove(info.ShortName);
                        }
                        if (toload == null || toload.Contains(info.ID))
                        {
                            MapsByID.Add(info.ID, info);
                            MapsByName.Add(info.ShortName, info);
                        }
                    }
                }
            }

            Blocks = new Dictionary <ushort, BlockInfo>();
            foreach (var map in MapsByID.Values)
            {
                string renderpath = folder + @"\BlockInfo\" + map.ShortName + ".shbd";
                if (File.Exists(renderpath))
                {
                    BlockInfo info = new BlockInfo(renderpath, map.ID);
                    Blocks.Add(map.ID, info);
                }
            }


            using (var tables = new ShineReader(folder + @"\NPC.txt"))
            {
                NpcLinkTable = new Dictionary <string, LinkTable>();
                using (DataTableReaderEx reader = new DataTableReaderEx(tables["LinkTable"]))
                {
                    while (reader.Read())
                    {
                        LinkTable link = LinkTable.Load(reader);
                        if (Program.IsLoaded(GetMapidFromMapShortName(link.MapClient)))
                        {
                            NpcLinkTable.Add(link.argument, link);
                        }
                    }
                }

                using (DataTableReaderEx reader = new DataTableReaderEx(tables["ShineNPC"]))
                {
                    while (reader.Read())
                    {
                        ShineNPC npc = ShineNPC.Load(reader);
                        MapInfo  mi  = null;
                        if (Program.IsLoaded(GetMapidFromMapShortName(npc.Map)) && MapsByName.TryGetValue(npc.Map, out mi))
                        {
                            mi.NPCs.Add(npc);
                        }
                    }
                }
            }

            Log.WriteLine(LogLevel.Info, "Loaded {0} maps.", MapsByID.Count);
        }
コード例 #11
0
ファイル: frmMain.cs プロジェクト: roknus/Spark-Editor
        private async void openFile(string fileName)
        {
            try
            {
                dynamic file = null;
                var     dgv  = new DataGridView();

                // Display the hidden progressbar in the statusbar.
                pbProgress.Visible = true;

                // Determine what file type it is and cast to the appropriate type.
                switch (Path.GetExtension(fileName))
                {
                case ".shn":
                    if (Path.GetFileNameWithoutExtension(fileName).ToLower() == "questdata")
                    {
                        file = new QuestFile(fileName);
                        Program.LoadedFiles.Add(file);
                        Extensions.FileType = FileType.QuestFile;

                        var mainTab = new TabPage("QuestFile");
                        var qTab    = new TabPage("Quests");
                        var dTab    = new TabPage("Dialouges");
                        mainTab.BackColor = Color.White;
                        dTab.BackColor    = Color.White;
                        qTab.BackColor    = Color.White;

                        var tc = new TabControl();
                        tc.Dock         = DockStyle.Fill;
                        qTab.Padding    = new Padding(0, 5, 0, 0);
                        dTab.Padding    = new Padding(0, 5, 0, 0);
                        mainTab.Padding = new Padding(0, 5, 0, 0);

                        tc.TabPages.Add(qTab);
                        tc.TabPages.Add(dTab);

                        mainTab.Controls.Add(tc);

                        var qPanel = new QuestPanel(file);
                        qPanel.Dock    = DockStyle.Fill;
                        qTab.BackColor = Color.White;
                        qTab.Controls.Add(qPanel);

                        tcFiles.TabPages.Add(mainTab);
                        tcFiles.SelectedIndex = tcFiles.TabPages.Count - 1;

                        pbProgress.Visible = false;
                        pbProgress.Value   = 0;
                        lblStatus.Text     = "Ready";
                        updateFileInfo();

                        return;
                    }

                    file = new SHNFile(fileName);
                    Extensions.FileType = FileType.SHNFile;

                    break;

                case ".txt":
                    file = new ShineFile(fileName);
                    Extensions.FileType = FileType.ShineFile;

                    break;

                default:
                    throw new Exception("File type not supported");
                }

                lblStatus.Text = "Reading " + Path.GetFileName(fileName);

                // Await the asynchronous Load method and display the reported progress in our progressbar.
                await Task.Run(() => file.Load(new Progress <int>(value =>
                                                                  mainStatusStrip.Invoke(new MethodInvoker(() =>
                {
                    pbProgress.Value = value;
                }))
                                                                  )));

                Program.LoadedFiles.Add(file);

                if (file.GetType() == typeof(SHNFile))
                {
                    dgv                 = new DataGridView();
                    dgv.Dock            = DockStyle.Fill;
                    dgv.BackgroundColor = Color.WhiteSmoke;
                    dgv.DoubleBuffered(true);
                    dgv.DataSource = file;

                    dgv.CellEnter += File_CellEnter;

                    var tab = new TabPage(file.TableName);
                    file.RowChanged += new DataRowChangeEventHandler(File_RowChanged);
                    tab.Controls.Add(dgv);

                    tcFiles.TabPages.Add(tab);
                    tcFiles.SelectedIndex = tcFiles.TabPages.Count - 1;
                }

                else if (file.GetType() == typeof(ShineFile))
                {
                    var mainTab  = new TabPage(file.DataSetName);
                    var tcTables = new TabControl();
                    tcTables.Dock = DockStyle.Fill;

                    tcTables.SelectedIndexChanged += new EventHandler((object s, EventArgs e) =>
                    {
                        file.SelectedIndex = tcTables.SelectedIndex;
                    });

                    mainTab.Controls.Add(tcTables);
                    tcFiles.TabPages.Add(mainTab);
                    mainTab.BackColor = Color.White;

                    tcFiles.SelectedIndex = tcFiles.TabCount - 1;

                    foreach (var table in file.Tables)
                    {
                        dgv                 = new DataGridView();
                        dgv.Dock            = DockStyle.Fill;
                        dgv.BackgroundColor = Color.WhiteSmoke;
                        dgv.DoubleBuffered(true);
                        dgv.DataSource = table;

                        dgv.CellEnter += File_CellEnter;

                        var tab = new TabPage(table.TableName);
                        table.RowChanged += new DataRowChangeEventHandler(File_RowChanged);
                        tab.Controls.Add(dgv);

                        tcTables.TabPages.Add(tab);
                    }
                }


                // Hide and reset the progressbar.
                pbProgress.Visible = false;
                pbProgress.Value   = 0;
                lblStatus.Text     = "Ready";
                updateFileInfo();
            }
            catch (Exception ex)
            {
                pbProgress.Visible = false;
                pbProgress.Value   = 0;
                lblStatus.Text     = "Ready";
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }