Пример #1
0
        /// <summary>
        /// Loads the specified sprite.
        /// </summary>
        /// <param name="name">The sprite file name without the extension.</param>
        private static Sprite LoadSprite(string name)
        {
            var sprite = PUIUtils.LoadSprite(BASE_PATH + name + ".png");

            sprite.name = name;
            return(sprite);
        }
 /// <summary>
 /// Loads a sprite and adds it to the master sprite list.
 /// </summary>
 /// <param name="sprite">The sprite to load.</param>
 private static void LoadAndAddSprite(string sprite)
 {
     try {
         Assets.Sprites.Add(sprite, PUIUtils.LoadSprite(BASE_PATH + sprite + ".png",
                                                        log: false));
     } catch (System.ArgumentException) {
         PUtil.LogWarning("Unable to load image " + sprite + "!");
     }
 }
Пример #3
0
        /// <summary>
        /// Fills in the mod info screen, assuming that infoAttr is non-null.
        /// </summary>
        /// <param name="dialog">The dialog to populate.</param>
        private void AddModInfoScreen(PDialog dialog)
        {
            string image = infoAttr.Image, version = GetModVersionText(optionsType);
            var    body = dialog.Body;

            // Try to load the mod image sprite if possible
            if (modImage == null && !string.IsNullOrEmpty(image))
            {
                string rootDir = modSpec.file_source?.GetRoot();
                modImage = PUIUtils.LoadSprite(rootDir == null ? image : Path.Combine(rootDir,
                                                                                      image));
            }
            var websiteButton = new PButton("ModSite")
            {
                Text    = PUIStrings.MOD_HOMEPAGE, ToolTip = PUIStrings.TOOLTIP_HOMEPAGE,
                OnClick = VisitModHomepage, Margin = PDialog.BUTTON_MARGIN
            }.SetKleiBlueStyle();
            var versionLabel = new PLabel("ModVersion")
            {
                Text = version, ToolTip = PUIStrings.TOOLTIP_VERSION, TextStyle = PUITuning.
                                                                                  Fonts.UILightStyle, Margin = new RectOffset(0, 0, OUTER_MARGIN, 0)
            };

            if (modImage != null)
            {
                // 2 rows and 1 column
                if (optionCategories.Count > 0)
                {
                    body.Direction = PanelDirection.Horizontal;
                }
                var infoPanel = new PPanel("ModInfo")
                {
                    FlexSize  = Vector2.up, Direction = PanelDirection.Vertical,
                    Alignment = TextAnchor.UpperCenter
                }.AddChild(new PLabel("ModImage")
                {
                    SpriteSize = MOD_IMAGE_SIZE, TextAlignment = TextAnchor.UpperLeft,
                    Margin     = new RectOffset(0, OUTER_MARGIN, 0, OUTER_MARGIN),
                    Sprite     = modImage
                });
                if (!string.IsNullOrEmpty(modURL))
                {
                    infoPanel.AddChild(websiteButton);
                }
                body.AddChild(infoPanel.AddChild(versionLabel));
            }
            else
            {
                if (!string.IsNullOrEmpty(modURL))
                {
                    body.AddChild(websiteButton);
                }
                body.AddChild(versionLabel);
            }
        }
Пример #4
0
        /// <summary>
        /// Loads the specified sprite into the assets.
        /// </summary>
        /// <param name="path">The image file name.</param>
        /// <param name="name">The desired sprite name.</param>
        private static void LoadImage(string path, string name)
        {
            var sprite = PUIUtils.LoadSprite("PeterHan.Resculpt." + path);

            if (sprite == null)
            {
                sprite = Assets.GetSprite(DEFAULT_SPRITE);
            }
            if (sprite != null)
            {
                sprite.name = name;
            }
            Assets.Sprites.Add(name, sprite);
        }
Пример #5
0
 /// <summary>
 /// Loads the sprites if they are not already loaded.
 /// </summary>
 private static void LoadSprites()
 {
     if (!spritesLoaded)
     {
         try {
             TOOL_ICON      = PUIUtils.LoadSprite("PeterHan.SandboxTools.Destroy.png");
             TOOL_ICON.name = SandboxToolsStrings.TOOL_DESTROY_ICON;
         } catch (ArgumentException e) {
             // Could not load the icons, but better this than crashing
             PUtil.LogException(e);
         }
         spritesLoaded = true;
     }
 }
Пример #6
0
 /// <summary>
 /// Loads the sprites if they are not already loaded.
 /// </summary>
 private static void LoadSprites()
 {
     if (!spritesLoaded)
     {
         try {
             TOOL_ICON      = PUIUtils.LoadSprite("PeterHan.SweepByType.Sweep.png");
             TOOL_ICON.name = SweepByTypeStrings.TOOL_ICON_NAME;
         } catch (ArgumentException e) {
             // Could not load the icons, but better this than crashing
             PUtil.LogException(e);
         }
         spritesLoaded = true;
     }
 }
Пример #7
0
        internal static void InitStrings()
        {
            Strings.Add(WORLD_NAME, Challenge100KStrings.NAME);
            Strings.Add("STRINGS.WORLDS.ONEHUNDREDK.DESCRIPTION", Challenge100KStrings.
                        DESCRIPTION);
            Strings.Add("STRINGS.CLUSTER_NAMES.ONEHUNDREDK.NAME", Challenge100KStrings.NAME);
            Strings.Add("STRINGS.CLUSTER_NAMES.ONEHUNDREDK.DESCRIPTION", Challenge100KStrings.
                        DESCRIPTION);
            var sprite = PUIUtils.LoadSprite("PeterHan.Challenge100K." + SPRITE + ".png");

            if (sprite != null)
            {
                Assets.Sprites.Add(SPRITE, sprite);
            }
        }
Пример #8
0
 /// <summary>
 /// Loads the sprites if they are not already loaded.
 /// </summary>
 private static void LoadSprites()
 {
     if (!spritesLoaded)
     {
         try {
             PLACE_ICON      = PUIUtils.LoadSprite("PeterHan.BulkSettingsChange.Placer.png");
             PLACE_ICON.name = BulkChangeStrings.PLACE_ICON_NAME;
             TOOL_ICON       = PUIUtils.LoadSprite("PeterHan.BulkSettingsChange.Toggle.png");
             TOOL_ICON.name  = BulkChangeStrings.TOOL_ICON_NAME;
         } catch (ArgumentException e) {
             // Could not load the icons, but better this than crashing
             PUtil.LogException(e);
         }
         spritesLoaded = true;
     }
 }