예제 #1
0
        public void Update(ref CUnit unit)
        {
            if (!addedRows)
            {
                AddRows();
            }

            if (unitPropSheet.RowCount >= 50)
            {
                SetValues(ref unit);
            }

            this.Text = string.Format("[{0}] (p{1}) {2} {{{3}}}", unitIndex.ToString("0000"),
                                      unit.playerID + 1, UnitNames.get(unit.unitType), unit.unitType);
        }
예제 #2
0
        /// <summary>The load method called to initialize this GUI</summary>
        /// <param name="sender">unused</param>
        /// <param name="e">unused</param>
        private void UnitViewerGUI_Load(object sender, EventArgs e)
        {
            SetDoubleBuffered(treeViewUnits);
            SetDoubleBuffered(treeViewDeaths);
            treePlayers      = new TreeNode[12];
            treeSelPlayers   = new TreeNode[8];
            treeDeaths       = new TreeNode[228];
            treePlayerDeaths = new TreeNode[228][];
            treeAllUnits     = treeViewUnits.Nodes.Add("AllUnits", "All Units");
            TreeNode treeByPlayers = treeViewUnits.Nodes.Add("TreeByPlayers", "Players' Units");

            for (uint i = 0; i < 12; i++)
            {
                string playerKey  = string.Format("Player{0}", i + 1);
                string playerText = string.Format("Player {0}", i + 1);
                treePlayers[i] = treeByPlayers.Nodes.Add(playerKey, playerText);
            }
            treePlayer13to256 = treeByPlayers.Nodes.Add("Player13-256", "Player 13-256");
            TreeNode treeBySelections = treeViewUnits.Nodes.Add("TreeByPlayerSel", "Selections");

            for (uint i = 0; i < 8; i++)
            {
                string playerKey  = string.Format("selPlayer{0}", i + 1);
                string playerText = string.Format("Player {0}", i + 1);
                treeSelPlayers[i] = treeBySelections.Nodes.Add(playerKey, playerText);
            }
            String[] unitNames = UnitNames.get();
            for (uint unitId = 0; unitId < 228; unitId++)
            {
                string unitKey = string.Format("unit{0}", unitId);
                treeDeaths[unitId]       = treeViewDeaths.Nodes.Add(unitKey, string.Format("[{0}] {1}", unitId.ToString("000"), unitNames[unitId]));
                treePlayerDeaths[unitId] = new TreeNode[12];
                for (uint playerId = 0; playerId < 12; playerId++)
                {
                    string playerDeathsKey  = string.Format("player{0}", playerId + 1);
                    string playerDeathsText = string.Format("Player {0}:     {1}", (playerId + 1).ToString("00"), 0.ToString());
                    treePlayerDeaths[unitId][playerId] = treeDeaths[unitId].Nodes.Add(playerDeathsKey, playerDeathsText);
                }
            }

            p       = new ProcessMod();
            updater = new Updater(this);
            updater.StartTimedUpdates(1000);
            unitViews   = new SortedDictionary <ushort, UnitView>();
            customViews = new SortedDictionary <UInt32, UnitView>();
            usedIndices = new List <ushort>();
            RefreshWindow();
        }
예제 #3
0
        private unsafe void PopulateUnitList()
        {
            List <ushort> currentlyUsedIndices = new List <ushort>();
            UnitView      unitView;

            CUnit  unit    = new CUnit();
            UInt32 unitPtr = p.val <uint>(0x00628430);

            while (unitPtr != 0)
            {
                unit = p.val <CUnit>(unitPtr);
                ushort unitIndex = unitPtrToIndex(unitPtr);
                currentlyUsedIndices.Add(unitIndex);

                string unitString = string.Format("[{0}] (p{1}) {2} {{{3}}}", unitIndex.ToString("0000"),
                                                  unit.playerID + 1, UnitNames.get(unit.unitType), unit.unitType);

                treeAllUnits.Nodes.Add(unitIndex.ToString(), unitString);

                if (unit.playerID > 11) // Player 13-256
                {
                    treePlayer13to256.Nodes.Add("ext" + unitIndex.ToString(), unitString);
                }
                else // Player 1-12
                {
                    treePlayers[unit.playerID].Nodes.Add("p" + unitIndex.ToString(), unitString);
                }

                if (unitViews.TryGetValue(unitIndex, out unitView))
                {
                    if (unitView.IsDisposed)
                    {
                        unitViews.Remove(unitIndex);
                    }
                    else
                    {
                        unitView.Update(ref unit);
                    }
                }

                unitPtr = unit.next;
            }

            for (uint player = 0; player < 8; player++)
            {
                treeSelPlayers[player].Nodes.Clear();
                for (uint sel = 0; sel < 12; sel++)
                {
                    unitPtr = p.val <UInt32>(0x006284E8 + player * 48 + sel * 4);
                    ushort unitIndex = unitPtrToIndex(unitPtr);
                    if (unitIndex != ushort.MaxValue)
                    {
                        unit = p.val <CUnit>(unitPtr);

                        string unitString = string.Format("[{0}] (p{1}) {2} {{{3}}}", unitIndex.ToString("0000"),
                                                          unit.playerID + 1, UnitNames.get(unit.unitType), unit.unitType);

                        treeSelPlayers[player].Nodes.Add("s" + unitIndex.ToString(), unitString);
                    }
                }
            }

            List <uint> toRemove = null;

            foreach (var item in customViews)
            {
                unit = p.val <CUnit>(item.Key);
                if (item.Value.IsDisposed)
                {
                    if (toRemove == null)
                    {
                        toRemove = new List <uint>();
                    }

                    toRemove.Add(item.Key);
                }
                else
                {
                    item.Value.Update(ref unit);
                }
            }
            if (toRemove != null)
            {
                foreach (uint key in toRemove)
                {
                    customViews.Remove(key);
                }
            }

            foreach (ushort unitIndex in usedIndices)
            {
                if (!currentlyUsedIndices.Contains(unitIndex))
                {
                    unitRemoved(unitIndex);
                }
            }

            usedIndices = currentlyUsedIndices;
        }