コード例 #1
0
        public void SaveToDisk()
        {
            DateTime stamp        = DateTime.Now;
            string   backupFolder = Path.Combine(Directory.GetParent(Executable.Path).ToString(), "HeroesResourceManagerBackups", stamp.ToString("yyyy-MM-dd-HHmmss"));

            Directory.CreateDirectory(backupFolder);

            SaveHeroExeData(backupFolder);

            if (CreatureManager.AnyChanges)
            {
                CreatureManager.SaveLocalChanges(this);
            }

            if (HeroesManager.AnyChanges)
            {
                HeroesManager.SaveLocalChanges(this);
            }

            if (HeroClass.AnyChanges)
            {
                HeroClass.SaveLocalChanges(this);
            }

            if (Spell.AnyChanges)
            {
                Spell.SaveLocalChanges(this);
            }


            foreach (var lodFile in ResourceFiles)
            {
                lodFile.SaveToDiskBackupAndSwap(backupFolder);
            }
        }
コード例 #2
0
        public void RefreshData()
        {
            routingCache  = new Dictionary <string, LodFile>();
            BackupManager = new BackupManager();

            Resource.Unload();
            CreatureAnimationLoop.Unload();
            BitmapCache.UnloadCachedDrawItems();

            HeroesManager.LoadInfo(this);
            HeroClass.LoadInfo(this);
            CreatureManager.LoadInfo(this);
            Spell.LoadInfo(this);
            SecondarySkill.LoadInfo(this);
            StringsData.LoadInfo(this);

            Speciality.LoadInfo(this);
            Town.LoadInfo(this);
            HeroExeData.LoadInfo(this);

            BackupManager.LoadData(this);
        }
コード例 #3
0
        //331 288
        public void LoadHero(int heroIndex, Heroes3Master master)
        {
            HeroIndex = heroIndex;
            Hero      = null;
            if (heroIndex > -1 && heroIndex < HeroesManager.HeroesOrder.Length && master != null)
            {
                var hs = HeroesManager.AllHeroes[heroIndex];

                var bckgImage = HeroesManager.GetBackground(master);

                var canvas = new Bitmap(bckgImage);

                var g = Graphics.FromImage(canvas);

                /*    g.InterpolationMode = InterpolationMode.High;
                 *  g.SmoothingMode = SmoothingMode.HighQuality;
                 *  g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                 *  g.CompositingQuality = CompositingQuality.HighQuality;*/

                g.DrawImage(bckgImage, Point.Empty);

                var portrait = master.ResolveWith(HeroesManager.HeroesOrder[hs.ImageIndex]).GetBitmap();
                g.DrawImage(portrait, new Point(4, 3));

                var heroData = HeroExeData.Data[heroIndex];

                var z = Speciality.GetImage(master, heroData.Index);
                g.DrawImage(z, new Point(4, 166));

                Hero = heroData;
                if (heroData.Skill1 != null)
                {
                    g.DrawImage(heroData.Skill1.GetImage(master, heroData.FirstSkillLevel), new Point(5, 213));
                }

                if (heroData.Skill2 != null)
                {
                    g.DrawImage(heroData.Skill2.GetImage(master, heroData.SecondSkillLevel), new Point(148, 213));
                }

                var img1 = CreatureManager.GetImage(master, heroData.Unit1Index);
                g.DrawImage(img1, new Point(5, 262));
                var img2 = CreatureManager.GetImage(master, heroData.Unit2Index);
                g.DrawImage(img2, new Point(68, 262));
                var img3 = CreatureManager.GetImage(master, heroData.Unit3Index);
                g.DrawImage(img3, new Point(129, 262));

                if (heroData.Spell != null)
                {
                    g.DrawImage(heroData.Spell.GetImage(master), 192, 262);
                }

                DrawData(g, heroData);


                //heroData.Class.Stats

                /*
                 *  g.DrawImage(ps.GetSprite(0), new Point(18, 97));
                 *  g.DrawImage(ps.GetSprite(1), new Point(88, 97));
                 *  g.DrawImage(ps.GetSprite(2), new Point(158, 97));
                 *  g.DrawImage(ps.GetSprite(5), new Point(228, 97));
                 */
                g.Dispose();
                PictureBox.Image = canvas;
                CalculateRatio();
            }
        }
コード例 #4
0
        private void GenerateControls()
        {
            if (!controlsCreated)
            {
                cbAggression.Items.AddRange(Aggression);
                SuspendLayout();
                var bmp = SecondarySkill.GetSkillTreeForHeroClass(Heroes3Master.Master);
                pbSkillTree.Width  = bmp.Width;
                pbSkillTree.Height = bmp.Height;
                pbSkillTree.Image  = bmp;


                int itemWidth  = pbSkillTree.Width / 7;
                int itemHeight = pbSkillTree.Height / 4;

                var bmp2 = HeroesManager.GetPrimarySkillsPanel(Heroes3Master.Master);
                pbPrimarySkills.Image = bmp2;


                int totalCount = HeroClass.Stats.Length - 9;
                int offset     = 2;
                int maxTab     = Controls.Cast <Control>().Max(s => s.TabIndex) - 1;
                for (int i = offset; i < totalCount; i++)
                {
                    var ctrl = new NumericUpDown();

                    ((ISupportInitialize)ctrl).BeginInit();
                    ctrl.Name      = "nmStat" + i;
                    ctrl.TextAlign = HorizontalAlignment.Center;
                    ctrl.Maximum   = 99;
                    ctrl.TabIndex  = i + maxTab;

                    int row, col;
                    if (i < offset + 12)
                    {
                        ctrl.Size = new Size(42, 20);
                        row       = (i - 2) / 4;
                        col       = (i - 2) % 4;

                        int y = pbPrimarySkills.Top + pbPrimarySkills.Height + 3 + row * (20 + 5);
                        ctrl.Location = new Point(pbPrimarySkills.Left + col * 42, y);

                        if (row == 0)
                        {
                            ctrl.Font = new Font(ctrl.Font, FontStyle.Bold);
                        }
                        if (col == 0)
                        {
                            var lbl = Controls.Find("lbl0" + (row + 1), false).FirstOrDefault() as Label;
                            if (lbl != null)
                            {
                                lbl.Top = y + (ctrl.Height - lbl.Height) / 2;
                            }
                        }
                    }
                    else
                    {
                        ctrl.Size = new Size(itemWidth, 24);
                        row       = (i - 14) / 7;
                        col       = (i - 14) % 7;

                        ctrl.Width    = itemWidth;
                        ctrl.Location = new Point(pbSkillTree.Left + itemWidth * col, pbSkillTree.Top + (itemHeight) * (row + 1) - 19);
                    }

                    Controls.Add(ctrl);
                    ((ISupportInitialize)ctrl).EndInit();
                }

                pbSkillTree.SendToBack();
                ResumeLayout(false);
                PerformLayout();
                controlsCreated = true;
            }
        }