示例#1
0
        internal Dictionary<string, List<KeyValuePair<string, AbilityAffinityType>>> CollectAffinedAbilities()
        {
            SplashScreen splashScreen = new SplashScreen();
            splashScreen.Show();
            splashScreen.ShowText("Collecting affined abilities...");

            int progressCounter = 0;
            Dictionary<string, List<KeyValuePair<string, AbilityAffinityType>>> result = new Dictionary<string, List<KeyValuePair<string, AbilityAffinityType>>>((IEqualityComparer<string>)StringComparer.OrdinalIgnoreCase);
            foreach (string heroID in DHLOOKUP.dcHeroesTaverns.Keys)
            {
                HabProperties hpsHeroAbilities = DHLOOKUP.hpcUnitAbilities[heroID];

                List<string> abilList = hpsHeroAbilities.GetStringListValue("heroAbilList");
                foreach (string abilID in abilList)
                    if (!result.ContainsKey(abilID))
                    {
                        HabProperties hpsAbilityProfile = DHLOOKUP.hpcAbilityProfiles[abilID];

                        string name = hpsAbilityProfile.GetStringValue("Name");
                        string hotkey = hpsAbilityProfile.GetStringValue("Hotkey");
                        if (hotkey == "") hotkey = hpsAbilityProfile.GetStringValue("Researchhotkey").Trim('"');
                        string buttonPos = hpsAbilityProfile.GetStringValue("Buttonpos");

                        List<KeyValuePair<string, AbilityAffinityType>> affinedAbilities = new List<KeyValuePair<string, AbilityAffinityType>>();
                        foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
                            if (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name))
                            {
                                AbilityAffinityType affinityType = CheckAbilityAffinity(hpsAbility, name, hotkey, buttonPos);

                                if (affinityType != AbilityAffinityType.None)
                                    affinedAbilities.Add(new KeyValuePair<string, AbilityAffinityType>(hpsAbility.name, affinityType));
                            }

                        // save affined abilities for current ability
                        result.Add(abilID, affinedAbilities);
                    }

                splashScreen.ShowProgress((double)progressCounter++, (double)DHLOOKUP.dcHeroesTaverns.Keys.Count);
            }

            splashScreen.Close();

            return result;
        }
示例#2
0
        public MainForm(bool smoothWakeUp)
        {
            Current.mainForm = this;

            this.SuspendLayout();

            hlForm = new HeroListForm();
            ilForm = new ItemListForm();
            cbForm = new ControlBarForm();

            splashScreen = new SplashScreen();
            splashScreen.Show();
            splashScreen.ShowText("Initializing...");

            DHRC.pfStartCount();
            Control.CheckForIllegalCrossThreadCalls = false;

            FloatingForms.AddRange(new FloatingListForm[] { hlForm, ilForm });

            splashScreen.ProgressAdd(30);

            InitializeComponent(); splashScreen.ProgressAdd(30);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.OptimizedDoubleBuffer, true);

            this.Icon = Properties.Resources.Icon;

            this.CenterToScreen();
            this.Top = this.Top + (hlForm.Height / 2);

            GatherAbilitySlots(); splashScreen.ProgressAdd(10);

            heroInfoPanel.Visible = false;
            heroSkillsPanel.Visible = false;

            hlForm.SetParent(this);

            ilForm.SetParent(this);
            ilForm.ItemActivate += new ItemListForm.ItemActivateEvent(ilForm_ItemActivate);

            cbForm.SetParent(this, FloatingForms);

            splashScreen.ProgressAdd(30);

            splashScreen.Close();

            DisplayUnit();

            cbForm.ApplyConfig();

            int hlX = hlForm.Left;
            hlForm.Left = -this.Width; // hide it to avoid flickering

            int ilX = ilForm.Left;
            ilForm.Left = -this.Width;

            hlForm.Display();
            ilForm.Display();

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

            hlForm.Left = hlX;
            ilForm.Left = ilX;

            mapNameLabel.Text = "";
            statusTS.Renderer = UIRenderers.NoBorderRenderer;

            saveFileDialog.InitialDirectory = Application.StartupPath;

            ApplyConfig();

            this.themeToolStripMenuItem.Enabled = false;

            this.ResumeLayout(false);

            if (!File.Exists(DHCFG.FileName))
            {
                this.Show();

                List<string> fileTypes = new List<string>(new string[] { ".dhb" });
                DHCFG.Items["Settings"]["FileTypes"] = fileTypes;
                DHFILE.AssociateFileTypes(fileTypes);

                MessageBox.Show("Hi. Configuration file (dotahit.cfg) was not found so you're probably running this program for the first time." +
                    "\nTo start working you need to open a DotA map file (like 'Dota Allstars 6.43b.w3x') by using the 'DotA map'->'Open...' option." +
                    "\nAlternatively you can just drag a map file onto the main window and it will be opened automatically.", "Introduction");
            }

            Theme theme = (Theme)DHCFG.Items["UI"].GetIntValue("Theme", (int)Theme.None);
            if (IsThemeAvailableOnDisk(theme))
                SetUITheme(theme);

            if (smoothWakeUp)
            {
                wakeupTimer = new System.Windows.Forms.Timer();
                wakeupTimer.Interval = 100;
                wakeupTimer.Tick += new EventHandler(wakeupTimer_Tick);
                wakeupTimer.Start();
            }
            else
                wakeUpThreadProcedure();

            //DHRC.timeCounter = 0;
            GC.Collect();
            DHRC.pfEndCount();
            DHRC.pfPrintCount("Initialization");
            DHRC.pfResetCount();
        }
示例#3
0
        public void CollectItemCombiningData()
        {
            if (MorphingItems != null)
            {
                return;
            }

            sameLookingComplexItems = null;

            Current.player.AcceptMessages = false;

            Dictionary <string, widget> dcItems = new Dictionary <string, widget>();

            foreach (unit shop in DHLOOKUP.shops)
            {
                if (DHHELPER.IsNewVersionItemShop(shop))
                {
                    foreach (string unitID in shop.sellunits)
                    {
                        if (!dcItems.ContainsKey(unitID))
                        {
                            unit u = new unit(unitID);
                            u.DoSummon = true;
                            u.set_owningPlayer(Current.player);

                            dcItems.Add(unitID, u);
                        }
                    }
                }
                else
                {
                    foreach (string itemID in shop.sellitems)
                    {
                        if (!dcItems.ContainsKey(itemID))
                        {
                            dcItems.Add(itemID, new item(itemID));
                        }
                    }
                }
            }

            unit test_unit = new unit();

            test_unit.codeID = "test";
            test_unit.Inventory.init(0, 10);

            test_unit.set_owningPlayer(Current.player);

            DHJassExecutor.CaughtReferences.Clear();
            DHJassExecutor.CatchArrayReference = true;

            DBINVENTORY inventory = test_unit.Inventory;

            List <widget> itemList = new List <widget>(dcItems.Values);

            MorphingItems = new Dictionary <string, string>(itemList.Count);

            SplashScreen splashScreen = new SplashScreen();

            splashScreen.Show();
            splashScreen.ShowText("Collecting item combining data...");

            for (int i = 0; i < itemList.Count; i++)
            {
                widget item = itemList[i];

                if (DHHELPER.IsNewVersionItem(item.codeID))
                {
                    test_unit.OnSell(item as unit);
                    Thread.Sleep(2); // to pass control to item handling script thread
                }
                else
                {
                    test_unit.OnSellItem(item as item, test_unit);
                    inventory.put_item(item as item);
                }

                item result = inventory[0].Item;
                if (result != null)
                {
                    if (result.codeID != item.codeID)
                    {
                        MorphingItems.Add(result.codeID, item.codeID);
                    }
                    inventory[0].drop_item();
                }

                splashScreen.ShowProgress((double)i, (double)itemList.Count);
            }

            Current.player.remove_unit(test_unit);
            test_unit.destroy();

            List <string> arrays = DHJassExecutor.CaughtReferences;

            if (arrays.Count == 6)
            {
                Dictionary <int, DHJassValue> dcA = (DHJassExecutor.Globals[arrays[0]] as DHJassArray).Array;
                Dictionary <int, DHJassValue> dcB = (DHJassExecutor.Globals[arrays[1]] as DHJassArray).Array;
                Dictionary <int, DHJassValue> dcC = (DHJassExecutor.Globals[arrays[2]] as DHJassArray).Array;
                Dictionary <int, DHJassValue> dcD = (DHJassExecutor.Globals[arrays[3]] as DHJassArray).Array;

                Dictionary <int, DHJassValue> dcCombined = (DHJassExecutor.Globals[arrays[4]] as DHJassArray).Array;

                ComplexItems = new Dictionary <string, List <List <string> > >(dcA.Count);

                int value;
                foreach (int key in dcA.Keys)
                {
                    List <string> components = new List <string>(4);

                    value = dcA[key].IntValue;
                    if (value != 0)
                    {
                        components.Add(DHJassInt.int2id(value));
                    }

                    value = dcB[key].IntValue;
                    if (value != 0)
                    {
                        components.Add(DHJassInt.int2id(value));
                    }

                    value = dcC[key].IntValue;
                    if (value != 0)
                    {
                        components.Add(DHJassInt.int2id(value));
                    }

                    value = dcD[key].IntValue;
                    if (value != 0)
                    {
                        components.Add(DHJassInt.int2id(value));
                    }

                    value = dcCombined[key].IntValue;
                    if (value != 0)
                    {
                        string strValue = DHJassInt.int2id(value);

                        List <List <string> > componentsList;
                        if (!ComplexItems.TryGetValue(strValue, out componentsList))
                        {
                            componentsList = new List <List <string> >(1);
                            ComplexItems.Add(strValue, componentsList);
                        }

                        componentsList.Add(components);
                    }
                }
            }

            splashScreen.Close();

            Current.player.AcceptMessages = true;
        }