コード例 #1
0
ファイル: PropertiesForm.cs プロジェクト: sonygod/dotahit
        private void viewLoadingScreenB_Click(object sender, EventArgs e)
        {
            Form loadinScreenForm = new Form();

            loadinScreenForm.AutoScroll      = true;
            loadinScreenForm.StartPosition   = FormStartPosition.CenterScreen;
            loadinScreenForm.ShowIcon        = false;
            loadinScreenForm.ShowInTaskbar   = false;
            loadinScreenForm.MinimizeBox     = false;
            loadinScreenForm.MaximizeBox     = false;
            loadinScreenForm.FormBorderStyle = FormBorderStyle.FixedDialog;

            Bitmap topLeft     = DHRC.GetTgaImage("LoadingScreenTL.tga");
            Bitmap topRight    = DHRC.GetTgaImage("LoadingScreenTR.tga");
            Bitmap bottomLeft  = DHRC.GetTgaImage("LoadingScreenBL.tga");
            Bitmap bottomRight = DHRC.GetTgaImage("LoadingScreenBR.tga");

            Bitmap   bmp = new Bitmap(topLeft.Width + topRight.Width, topLeft.Height + bottomLeft.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Graphics g   = Graphics.FromImage(bmp);

            g.DrawImageUnscaled(topLeft, 0, 0);
            g.DrawImageUnscaled(topRight, topLeft.Width, 0);
            g.DrawImageUnscaled(bottomLeft, 0, topLeft.Height);
            g.DrawImageUnscaled(bottomRight, topLeft.Width, topLeft.Height);

            loadinScreenForm.BackgroundImage       = bmp;
            loadinScreenForm.BackgroundImageLayout = ImageLayout.None;
            loadinScreenForm.ClientSize            = bmp.Size;

            loadinScreenForm.ShowDialog();
        }
コード例 #2
0
        public void DisplayHero(Player p)
        {
            if (p.Heroes.Count == 0)
            {
                playerNameLabel.Text = p.Name;
                return;
            }

            player = p;
            hero   = p.GetMostUsedHero();

            string imagePath = DHLOOKUP.hpcUnitProfiles[hero.Name, "Art"] as string;

            if (imagePath == null)
            {
                return;
            }

            heroImagePanel.BackgroundImage = DHRC.GetImage(imagePath);

            playerNameLabel.Text = p.Name;
            heroNameLabel.Text   = DHFormatter.ToString(DHLOOKUP.hpcUnitProfiles[hero.Name, "Name"]);

            skillsDGrV.RowCount = hero.Abilities.BuildOrders.Count;
            itemsDGrV.RowCount  = player.Items.BuildOrders.Count;
        }
コード例 #3
0
        private void itemsDGrV_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            OrderItem item = player.Items.BuildOrders[e.RowIndex];

            switch (e.ColumnIndex)
            {
            case 0:     // Time
                e.Value = timeToString(item.Time);
                break;

            case 1:     // Item Image
                if (DHHELPER.IsNewVersionItem(item.Name))
                {
                    e.Value = DHRC.GetImage(DHFormatter.ToString(DHLOOKUP.hpcUnitProfiles[item.Name, "Art"]));
                }
                else
                {
                    e.Value = DHRC.GetImage(DHFormatter.ToString(DHLOOKUP.hpcItemProfiles[item.Name, "Art"]));
                }
                break;

            case 2:     // Item Name
                if (DHHELPER.IsNewVersionItem(item.Name))
                {
                    e.Value = DHFormatter.ToString(DHLOOKUP.hpcUnitProfiles[item.Name, "Name"]);
                }
                else
                {
                    e.Value = DHFormatter.ToString(DHLOOKUP.hpcItemProfiles[item.Name, "Name"]);
                }
                break;
            }
        }
コード例 #4
0
ファイル: ItemListForm.cs プロジェクト: sonygod/dotahit
        private void itemsLV_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.Graphics.DrawImage((Image)DHRC.GetImage(e.Item.ImageKey),
                                 e.Bounds.X, e.Bounds.Y, 48, 48);

            /*HabProperties hpsX = e.Item.Tag as HabProperties;
             * e.Item.Text = RecordSlotComparer.get_slot(hpsX.GetValue("Buttonpos") + "")+"";
             * e.DrawText();*/
        }
コード例 #5
0
ファイル: PropertiesForm.cs プロジェクト: sonygod/dotahit
        public PropertiesForm()
        {
            InitializeComponent();

            mapDescriptionRichText = new UIRichText(mapDescriptionRTB);

            filePathTextBox.Text = Current.map.Name;
            mapNameTextBox.Text  = DHSTRINGS.GetTriggerString(DHJassExecutor.Globals["DHMapName"].StringValue);
            mapDescriptionRichText.AddTaggedText(DHSTRINGS.GetTriggerString(DHJassExecutor.Globals["DHMapDescription"].StringValue), UIFonts.boldVerdana, Color.White);
            mapImagePanel.BackgroundImage = DHRC.GetTgaImage("war3mapPreview.tga");
        }
コード例 #6
0
 internal void ResetMpqDatabase()
 {
     if (Current.map != null)
     {
         DHRC.CloseArchive(Current.map);
         Current.player = null;
         Current.unit   = null;
         DHRC.Reset();
         DHJass.Reset();
         GC.Collect();
     }
 }
コード例 #7
0
        internal void ClearMpqDatabase()
        {
            Current.map       = null;
            mapNameLabel.Text = "";
            Current.player    = null;
            Current.unit      = null;
            DHRC.Clear();
            DHJass.Clear();
            GC.Collect();

            Current.sessionHasWar3DB = false;
        }
コード例 #8
0
        internal bool LoadMpq(string filename)
        {
            ResetMpqDatabase(); // reset everything that was loaded with previous map

            Current.map = DHRC.OpenArchive(filename, 11);

            // heroes

            splashScreen.ShowText("loading units...");
            DHMpqDatabase.LoadUnits(); splashScreen.ProgressAdd(8);

            // items

            splashScreen.ShowText("loading items...");
            DHMpqDatabase.LoadItems(); splashScreen.ProgressAdd(8);

            // abilites

            splashScreen.ShowText("loading abilities...");
            DHMpqDatabase.LoadAbilities(splashScreen);

            // upgrades

            splashScreen.ShowText("loading upgrades...");
            DHMpqDatabase.LoadUpgrades(splashScreen);

            DHLOOKUP.RefreshHotEntries();

            // jass

            try
            {
                splashScreen.ShowText("compiling jass...");
                DHJass.ReadCustom(DHRC.GetFile(Script.Custom).GetStream(), false); splashScreen.ProgressAdd(14);

                cbForm.PrepareControls();

                splashScreen.ShowText("executing jass...");
                DHJass.Config();
                DHJass.Go(); splashScreen.ProgressAdd(15);
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to load the jass script. This heavely reduces the functionality of DotaHIT, but you will still be able to use simple features like DataDump."
                                + Environment.NewLine + "Error Message: " + e.Message);
                return(false);
            }

            return(true);
        }
コード例 #9
0
        private void heroesGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            if (e.RowIndex >= heroes.Count)
            {
                return;
            }

            unit hero = heroes[e.RowIndex];

            if (hero.codeID == "AnyHero")
            {
                switch (e.ColumnIndex)
                {
                case 0:     // image
                    e.Value = null;
                    break;

                case 1:     // hero name
                    e.Value = "Any Hero (Nickname-only search)";
                    break;

                case 2:     // player
                    e.Value = hero.name;
                    break;
                }
            }
            else
            {
                HabProperties hpsHero = DHLOOKUP.hpcUnitProfiles[hero.codeID];
                switch (e.ColumnIndex)
                {
                case 0:     // image
                    e.Value = DHRC.GetImage(hpsHero.GetStringValue("Art"));
                    break;

                case 1:     // hero name
                    e.Value = hero.ID;
                    break;

                case 2:     // player
                    string nick;
                    heroNicksCache.TryGetValue(hero.codeID, out nick);
                    e.Value = nick + "";
                    break;
                }
            }
        }
コード例 #10
0
        private void unitsLV_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawBackground();

            e.Graphics.DrawImage((Image)DHRC.GetImage(e.Item.ImageKey),
                                 e.Bounds.X + borderWidth, e.Bounds.Y + borderWidth - 1 /*+ borderWidth*/,
                                 fakeImgList.ImageSize.Width - borderWidth * 2, fakeImgList.ImageSize.Height - borderWidth);

            if (e.Item.Selected)
            {
                e.Graphics.DrawRectangle(framePen,
                                         e.Bounds.X + 1, e.Bounds.Y + borderWidth - 1,
                                         fakeImgList.ImageSize.Width - borderWidth, fakeImgList.ImageSize.Height - borderWidth);
            }

            e.Graphics.DrawString(e.Item.Text, e.Item.ListView.Font, Brushes.White,
                                  e.Bounds.X + fakeImgList.ImageSize.Width, e.Bounds.Y + ((e.Bounds.Height - e.Item.ListView.Font.GetHeight()) / 2) - 1, StringFormat.GenericDefault);
        }
コード例 #11
0
        private void heroTagGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            HabProperties hpsHero = DHLOOKUP.hpcUnitProfiles[heroes[e.RowIndex]];

            switch (e.ColumnIndex)
            {
            case 0:     // image
                e.Value = DHRC.GetImage(hpsHero.GetStringValue("Art"));
                break;

            case 1:     // tag
                e.Value = hpsHeroTags.GetStringValue(hpsHero.name).Split(';')[0];
                break;

            case 2:     // name
                int length = hpsHeroTags.GetStringValue(hpsHero.name).Split(';').Length;
                if (length < 2)
                {
                    e.Value = hpsHero.GetStringValue("Propernames").Split(',')[0];
                }
                else
                {
                    e.Value = hpsHeroTags.GetStringValue(hpsHero.name).Split(';')[1];
                }
                break;

            case 3:     // 2nd name
                int len = hpsHeroTags.GetStringValue(hpsHero.name).Split(';').Length;
                if (len < 3)
                {
                    e.Value = hpsHero.GetStringValue("Name").Trim('"');
                }
                else
                {
                    e.Value = hpsHeroTags.GetStringValue(hpsHero.name).Split(';')[2];
                }
                break;
            }
        }
コード例 #12
0
        private void skillsDGrV_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            OrderItem skill = hero.Abilities.BuildOrders[e.RowIndex];

            switch (e.ColumnIndex)
            {
            case 0:     // Time
                e.Value = timeToString(skill.Time);
                break;

            case 1:                       // Level
                e.Value = "" + skill.Tag; //(e.RowIndex + 1);
                break;

            case 2:     // Skill Image
                e.Value = DHRC.GetImage(DHFormatter.ToString(DHLOOKUP.hpcAbilityProfiles[skill.Name, "Art"]));
                break;

            case 3:     // Skill Name
                e.Value = DHFormatter.ToString(DHLOOKUP.hpcAbilityProfiles[skill.Name, "Name"]) + " - Level " + skill.Count;
                break;
            }
        }
コード例 #13
0
        internal void SaveImages(List <string> imagePathList)
        {
            foreach (string imagePath in imagePathList)
            {
                if (blpRB.Checked)
                {
                    DHMpqFile image = DHRC.GetImageFile(imagePath);
                    if (!image.IsNull)
                    {
                        image.ToFile(GetProperPath(imagePath));
                    }
                }
                else
                {
                    Bitmap image = DHRC.GetImage(imagePath);

                    if (image != null)
                    {
                        image.Save(GetProperPath(Path.ChangeExtension(imagePath, ".png")));
                    }
                }
            }
        }
コード例 #14
0
        private void creepsCmbB_SelectedIndexChanged(object sender, EventArgs e)
        {
            HabProperties hpsProfile = (sender as ComboBox).SelectedItem as HabProperties;

            if (hpsProfile != null)
            {
                creepArtPanel.BackgroundImage = DHRC.GetImage(hpsProfile.GetStringValue("Art"));

                HabProperties hpsBalance = hpcBalance[hpsProfile.name];

                int dice  = hpsBalance.GetIntValue("bountydice");
                int sides = hpsBalance.GetIntValue("bountysides");
                int plus  = hpsBalance.GetIntValue("bountyplus");

                creepGoldTextBox.Text  = "" + (dice + plus) + " - " + (dice * sides + plus);
                creepLevelTextBox.Text = hpsBalance.GetStringValue("level");
            }
            else
            {
                creepArtPanel.BackgroundImage = null;
                creepGoldTextBox.Text         = "";
                creepLevelTextBox.Text        = "";
            }
        }
コード例 #15
0
ファイル: HeroListForm.cs プロジェクト: sonygod/dotahit
 private void itemsLV_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     e.Graphics.DrawImage((Image)DHRC.GetImage(e.Item.ImageKey),
                          e.Bounds.X, e.Bounds.Y, 48, 48);
 }
コード例 #16
0
        internal void LoadWar3Mpq()
        {
            if (Current.map != null)
            {
                hlForm.Reset();
                DHMpqDatabase.UnitSlkDatabase.Clear();

                ilForm.Reset();
                DHMpqDatabase.ItemSlkDatabase.Clear();

                hlForm.Minimize(true);
                ilForm.Minimize(true);
            }

            ClearMpqDatabase();

            string w3path = DHCFG.Items["Path"].GetStringValue("War3");

            if (string.IsNullOrEmpty(w3path))
            {
                w3path = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Blizzard Entertainment\Warcraft III", "InstallPath", null) as string;
            }

            string war3_not_located = "Unable to locate Warcraft III installation path. For this tool to work correctly, it is required that you have all Warcraft III .mpq files in one directory." +
                                      "Would you like to specify that directory? Example: 'C:\\Games\\WarCraft III'";

            string error_no_mpqs = "The specified directory for WarCraft III files does not contain any .mpq files, which will cause maps not to load correctly." +
                                   "\nWould you like to specify another directory? Example: 'C:\\Games\\WarCraft III'";

            while (String.IsNullOrEmpty(w3path) || !Directory.Exists(w3path))
            {
                switch (MessageBox.Show(war3_not_located, UIStrings.Warning, MessageBoxButtons.YesNo))
                {
                case DialogResult.Yes:
                    if (browseForFolder())
                    {
                        w3path = folderBrowserDialogWrapper.SelectedPath;
                    }
                    break;

                case DialogResult.No:
                    return;
                }
            }

            string[] files;
            while ((files = Directory.GetFiles(Path.GetFullPath(w3path), "*.mpq")).Length == 0)
            {
                switch (MessageBox.Show(error_no_mpqs, UIStrings.Warning, MessageBoxButtons.YesNo))
                {
                case DialogResult.Yes:
                    if (browseForFolder())
                    {
                        w3path = folderBrowserDialogWrapper.SelectedPath;
                    }
                    break;

                case DialogResult.No:
                    return;
                }
            }

            DHCFG.Items["Path"]["War3"] = w3path; // save the correct war3 path

            foreach (string file in files)
            {
                int index = MpqArchive.List.IndexOf(Path.GetFileName(file.ToLower()));
                if (index != -1)
                {
                    DHRC.OpenArchive(file, (uint)index);
                }
                else
                {
                    DHRC.OpenArchive(file, 10);
                }
            }

            ///////// editor data //////////
            DHMpqDatabase.LoadEditorData();

            //////// jass //////////////////
            MemoryStream jassStream; DHJassExecutor.ShowMissingFunctions = true;

            jassStream = DHRC.GetFile(Script.Common).GetStream();
            DHJass.ReadWar3Ex(jassStream, true);

            jassStream = DHRC.GetFile(Script.Blizzard).GetStream();
            DHJass.ReadWar3(jassStream, false);

            DHJass.CompleteWar3Init();

            Current.sessionHasWar3DB = true;
        }
コード例 #17
0
        internal void PrepareCreepsList()
        {
            DHMpqFile    jScript = DHRC.GetFile(MpqPath.Script.Custom);
            MemoryStream ms      = jScript.GetStream();

            byte[] buffer = ms.GetBuffer();
            string script;

            unsafe
            {
                fixed(byte *ptr = buffer)
                {
                    script = new string((sbyte *)ptr);
                }
            }

            List <HabProperties> list = new List <HabProperties>();

            foreach (HabProperties hpsUnit in hpcData)
            {
                HabProperties hpsBalance = hpcBalance[hpsUnit.name];
                if (hpsBalance.GetStringValue("Primary").Length > 1)
                {
                    continue;
                }

                HabProperties hpsProfile = hpcProfile[hpsUnit.name];
                if (hpsProfile == null)
                {
                    continue;
                }

                if (hpsUnit.GetStringValue("targType") != "ground")
                {
                    continue;
                }

                HabProperties hpsWeapons = hpcWeapons[hpsUnit.name];
                if (hpsWeapons == null)
                {
                    continue;
                }

                if (hpsWeapons.GetStringValue("weapTp1") == "_")
                {
                    continue;
                }

                HabProperties hpsUI = hpcUI[hpsUnit.name];
                if (hpsUI == null)
                {
                    continue;
                }

                if (!hpsUI.GetStringValue("file").StartsWith("units", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                if (!hpsWeapons.ContainsKey("mindmg1"))
                {
                    continue;
                }

                if (!script.Contains("'" + hpsUnit.name + "'") && !script.Contains(DHJassInt.id2int(hpsUnit.name) + ""))
                {
                    continue;
                }

                list.Add(hpsProfile);
            }

            creepsCmbB.DataSource = list;
        }
コード例 #18
0
        internal void LoadUIThemeFromWar3(Theme theme)
        {
            try
            {
                // Example path: UI\Console\Human\HumanUITile01.blp

                Bitmap bmp01 = DHRC.GetImage(@"UI\Console\" + theme + "\\" + theme + "UITile01.blp", PixelFormat.Format32bppArgb);
                Bitmap bmp02 = DHRC.GetImage(@"UI\Console\" + theme + "\\" + theme + "UITile02.blp", PixelFormat.Format32bppArgb);
                Bitmap bmp03 = DHRC.GetImage(@"UI\Console\" + theme + "\\" + theme + "UITile03.blp", PixelFormat.Format32bppArgb);
                Bitmap bmp04 = DHRC.GetImage(@"UI\Console\" + theme + "\\" + theme + "UITile04.blp", PixelFormat.Format32bppArgb);

                Brush brush = new SolidBrush(Color.Black);

                int    w       = 361;
                int    h       = 339;
                Bitmap bmpInfo = new Bitmap(w, h, bmp01.PixelFormat);

                Graphics gInfo = Graphics.FromImage(bmpInfo);

                // fill rectangle inside the info panel with black color, to make it nontransparent
                gInfo.FillRectangle(brush, 0, 74, bmpInfo.Width, bmpInfo.Height);

                // now draw the transparent image of the info panel
                gInfo.DrawImageUnscaled(bmp01,
                                        new Point(0, -(bmp01.Height - h)));

                heroInfoPanel.BackgroundImageLayout = ImageLayout.Zoom;
                heroInfoPanel.BackgroundImage       = bmpInfo;

                w = 372;
                Bitmap bmpSkill = new Bitmap(w, h, bmp03.PixelFormat);

                Graphics gSkill = Graphics.FromImage(bmpSkill);

                // fill rectangle inside the skill panel with black color, to make it nontransparent
                gSkill.FillRectangle(brush, 0, 74, bmpSkill.Width, bmpSkill.Height);

                // now draw the transparent image of the skill panel
                gSkill.DrawImageUnscaled(bmp04,
                                         new Point(bmpSkill.Width - bmp04.Width, bmpSkill.Height - bmp04.Height));

                gSkill.DrawImage(bmp03, 0, 0,
                                 new Rectangle(
                                     bmp03.Width - (bmpSkill.Width - bmp04.Width), bmp03.Height - bmpSkill.Height,
                                     (bmpSkill.Width - bmp04.Width), bmpSkill.Height),
                                 GraphicsUnit.Pixel);

                heroSkillsPanel.BackgroundImageLayout = ImageLayout.Zoom;
                heroSkillsPanel.BackgroundImage       = bmpSkill;

                w = 867;
                Bitmap bmpMain = new Bitmap(w, h, PixelFormat.Format32bppRgb);

                Graphics gMain = Graphics.FromImage(bmpMain);

                gMain.DrawImageUnscaled(bmp01,
                                        new Point(-bmpInfo.Width, -(bmp01.Height - bmpMain.Height)));

                gMain.DrawImageUnscaled(bmp02,
                                        new Point(bmp01.Width - bmpInfo.Width, -(bmp02.Height - bmpMain.Height)));

                gMain.DrawImageUnscaled(bmp03,
                                        new Point((bmp01.Width - bmpInfo.Width) + bmp02.Width, -(bmp03.Height - bmpMain.Height)));

                heroStatsPanel.BackgroundImageLayout = ImageLayout.Zoom;
                heroStatsPanel.BackgroundImage       = new Bitmap(bmpMain, heroStatsPanel.Size);

                inventoryBgPanel.BackgroundImage = heroStatsPanel.BackgroundImage;

                // save images to disk

                string skinPath = Application.StartupPath + "\\Skins\\" + theme;

                if (!Directory.Exists(skinPath))
                {
                    Directory.CreateDirectory(skinPath);
                }

                heroInfoPanel.BackgroundImage.Save(skinPath + "\\Info.png");
                heroSkillsPanel.BackgroundImage.Save(skinPath + "\\Skills.png");
                heroStatsPanel.BackgroundImage.Save(skinPath + "\\Stats.png");
            }
            catch
            {
                MessageBox.Show("An error occured while loading theme '" + theme + "' from WarCraft datafiles", "Error");
            }
        }