Пример #1
0
        static public void Refresh(string appDir)
        {
            DebugLogger.Log("Hardcoded", "Refreshing hardcoded data");
            string       dataDir  = Path.Combine(appDir, "data") + Path.DirectorySeparatorChar;
            string       dataFile = dataDir + "hardcoded.json";
            string       fileText = File.ReadAllText(dataFile);
            Measurements m        = JsonConvert.DeserializeObject <Measurements>(fileText);

            if (UpgradeHPTextColour != null)
            {
                DebugLogger.Log("Hardcoded", "Disposing previously loaded data");
                UsedCarListMeasurements.TextFont.Dispose();
                GarageCarListMeasurements.TextFont.Dispose();
                UpgradeHPTextColour.Dispose();
                DealershipPriceColour.Dispose();
                StandardFontColour.Dispose();
                PartFontColour.Dispose();
                EquippedPartFontColour.Dispose();
                StandardFont.Dispose();
                BigFont.Dispose();
                PartFont.Dispose();
                SmallLicenseGraphic.Dispose();
                LargeLicenseGraphic.Dispose();
                CarPicture.Dispose();
                CarLogo.Dispose();
                LicenseTrophyGraphic.Dispose();
                DrivetrainGraphic.Dispose();
                IconImages.Dispose();
            }
            UsedCarListMeasurements       = m.usedCarList;
            GarageCarListMeasurements     = m.garageCarList;
            EquippedPartsListMeasurements = m.installedCarPartsList;
            UpgradeHPTextColour           = new SolidBrush(m.upgradeHPColour);
            DealershipPriceColour         = new SolidBrush(m.dealershipPriceColour);
            StandardFontColour            = new SolidBrush(m.standardFontColour);
            PartFontColour         = new SolidBrush(m.partFontColour);
            EquippedPartFontColour = new SolidBrush(m.installedCarPartsList.TextColour);
            ColourSwatchSize       = m.colourSwatchSize;
            StandardFont           = m.standardFont;
            BigFont  = m.bigFont;
            PartFont = m.partNameFont;
            DumpFontInfo("Standard Font", StandardFont);
            DumpFontInfo("Big Font", BigFont);
            DumpFontInfo("Part Font", PartFont);
            DumpFontInfo("Installed Part Font", m.installedCarPartsList.TextFont);
            SmallLicenseGraphic  = new Bitmap(dataDir + "smalllicense.png");
            LargeLicenseGraphic  = new Bitmap(dataDir + "biglicense.png");
            CarPicture           = new Bitmap(dataDir + "carpicture.png");
            CarLogo              = MakeBlackTransparentAndDispose(new Bitmap(dataDir + "carlogo.png"));
            LicenseTrophyGraphic = MakeBlackTransparentAndDispose(new Bitmap(dataDir + "licensetrophy.png"));
            DrivetrainGraphic    = MakeBlackTransparentAndDispose(new Bitmap(dataDir + "drivetrain.png"));
            IconImages.Refresh(m.iconImageData, Globals.App.GT2Version, dataDir);
        }
Пример #2
0
        /// <summary>
        /// Adds a new object to the allObjects view.
        /// </summary>
        private void AddObject(ProjectObject obj)
        {
            if (obj.HideFromHierarchy)
            {
                return;
            }

            string parentKey = GetParentKey(obj);

            TreeNodeCollection addTo;

            if (!string.IsNullOrEmpty(parentKey))
            {
                TreeNode parentNode = GetTreeNode(parentKey, true);
                addTo = parentNode.Nodes;
            }
            else
            {
                addTo = allObjectsTreeView.Nodes;
            }

            string uniqueId = obj.UniqueId.ToString();

            // see if there is a Windows folder node that corresponds to this newly-added Unity folder node
            TreeNode    existingFolderNode = null;
            UnityFolder folderObj          = obj as UnityFolder;

            if (folderObj != null)
            {
                string folderPath = folderObj.FolderPath;
                m_treeNodes.TryGetValue(folderPath, out existingFolderNode);
            }

            // see if there is an existing node of any kind for this object
            TreeNode node;

            m_treeNodes.TryGetValue(uniqueId, out node);

            if (existingFolderNode != null)       // there is a Windows folder node
            {
                if (node == null)                 // there isn't a Unity node
                {
                    // recycle the Windows folder node as a Unity folder node
                    if (!m_treeNodes.Remove(existingFolderNode.Name))
                    {
                        throw new InvalidOperationException("Programming error");
                    }
                    m_treeNodes.Add(folderObj.UniqueId, existingFolderNode);
                    node = existingFolderNode;
                }
                else                 // there is a Unity node
                {
                    // trash the Windows folder node and use the existing Unity folder node
                    if (!m_treeNodes.Remove(existingFolderNode.Name))
                    {
                        throw new InvalidOperationException("Programming error");
                    }
                    foreach (TreeNode childNode in existingFolderNode.Nodes)
                    {
                        if (childNode != null)                         //HACK: why?
                        {
                            childNode.Remove();
                            node.Nodes.Add(childNode);
                        }
                    }
                    existingFolderNode.Remove();
                    existingFolderNode = null;
                }
            }

            if (node != null)
            {
                // ensure the existing node is parented correctly
                node.Remove();
                addTo.Add(node);

                // update node info
                node.Text = obj.ToString();
                node.Name = obj.UniqueId.ToString();
                string imageKey   = obj.GetIconKey();
                int    imageIndex = IconImages.GetImageIndex(imageKey);
                node.ImageIndex = node.SelectedImageIndex = imageIndex;
                node.ImageKey   = node.SelectedImageKey = imageKey;
            }
            else
            {
                // create a new node
                string imageKey   = obj.GetIconKey();
                int    imageIndex = IconImages.GetImageIndex(imageKey);
                node = new TreeNode(obj.ToString(), imageIndex, imageIndex)
                {
                    Name             = obj.UniqueId.ToString(),
                    ImageKey         = imageKey,
                    SelectedImageKey = imageKey,
                };
                AddTreeNode(addTo, node);
            }

            UpdateParseProgress();
        }