コード例 #1
0
        /// <summary>
        /// Loads the sprites used in secondary panels in TNH
        /// </summary>
        private void LoadPanelSprites(SetupStage stage)
        {
            IFileHandle file   = Source.Resources.GetFile("mag_dupe_background.png");
            Sprite      result = TNHTweakerUtils.LoadSprite(file);

            MagazinePanel.background = result;

            file   = Source.Resources.GetFile("ammo_purchase_background.png");
            result = TNHTweakerUtils.LoadSprite(file);
            AmmoPurchasePanel.background = result;

            file   = Source.Resources.GetFile("full_auto_background.png");
            result = TNHTweakerUtils.LoadSprite(file);
            FullAutoPanel.background = result;

            file   = Source.Resources.GetFile("fire_rate_background.png");
            result = TNHTweakerUtils.LoadSprite(file);
            FireRatePanel.background = result;

            file   = Source.Resources.GetFile("minus_icon.png");
            result = TNHTweakerUtils.LoadSprite(file);
            FireRatePanel.minusSprite = result;

            file   = Source.Resources.GetFile("plus_icon.png");
            result = TNHTweakerUtils.LoadSprite(file);
            FireRatePanel.plusSprite = result;
        }
コード例 #2
0
        /// <summary>
        /// Performs initial setup for TNH Tweaker
        /// </summary>
        /// <param name="stage"></param>
        private void OnSetup(SetupStage stage)
        {
            SetupOutputDirectory();
            LoadPanelSprites(stage);

            stage.SetupAssetLoaders[Source, "sosig"]      = new SosigLoader().LoadAsset;
            stage.SetupAssetLoaders[Source, "vault_file"] = new VaultFileLoader().LoadAsset;
            stage.SetupAssetLoaders[Source, "character"]  = new CharacterLoader().LoadAsset;
        }
コード例 #3
0
        // And now you can access much more of Deli
        private void OnSetup(SetupStage stage)
        {
            Logger.LogInfo("I am operating on the setup stage!");

            // Our asset loaders aren't static, so we need to construct an instance before we access them.
            var loaders = new AssetLoaders(Logger);

            // Adds the reader defined in AssetReaders.cs
            stage.ImmediateReaders.Add(AssetReaders.ExampleAssetOf);
            // Adds the loader as our mod, with the name "example_asset", for the setup stage only.
            // Mods (including our own) can use this loader via "deli.example_mod:example_asset".
            stage.SetupAssetLoaders[Source, "example_asset"] = loaders.LoadExampleAsset;

            ConstructTextResource(stage);

            // TODO: Put anything else that needs to be loaded from/into Deli here
        }
コード例 #4
0
        public void LoadExampleAsset(SetupStage stage, Mod mod, IHandle handle)
        {
            // The handle could be a directory or file, but we only want file.
            if (handle is not IFileHandle file)
            {
                throw new ArgumentException("The example loader needs a file, not directory.", nameof(handle));
            }

            // Get the reader we defined in AssetReaders.cs and registered in ExampleMod.cs
            var assetReader = stage.ImmediateReaders.Get <ExampleAsset>();

            // Run the reader
            var asset = assetReader(file);

            // Log the asset's message to our mod's logger
            _logger.LogInfo($"Read message from {mod} on line {asset.Line}: '{asset.Message}'");
        }
コード例 #5
0
        private void ConstructTextResource(SetupStage stage)
        {
            // Get the reader responsible for strings
            var reader = stage.ImmediateReaders.Get <string>();

            // Get the resource file that we want to read.
            // If not found, this will be null. Be careful (and use C# 8.0+ if possible), or you might
            // get a NullReferenceException!
            var file = Resources.GetDirectory("res")?.GetFile("ExampleTextResource.txt");

            if (file is null)
            {
                throw new InvalidOperationException("The resource file was not found!");
            }

            _textResource          = new ImmediateTypedFileHandle <string>(file, reader);
            _textResource.Updated += () => Logger.LogInfo($"Text resource updated: '{_textResource.GetOrRead()}'");
        }
コード例 #6
0
        public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
        {
            if (handle is not IFileHandle file)
            {
                throw new ArgumentException("Could not load sosig! Make sure you're pointing to a sosig template json file in the manifest");
            }

            try
            {
                SosigTemplate sosig = stage.ImmediateReaders.Get <JToken>()(file).ToObject <SosigTemplate>();
                TNHTweakerLogger.Log("TNHTweaker -- Sosig loaded successfuly : " + sosig.DisplayName, TNHTweakerLogger.LogType.File);

                LoadedTemplateManager.AddSosigTemplate(sosig);
            }
            catch (Exception e)
            {
                TNHTweakerLogger.LogError("Failed to load setup assets for sosig file! Caused Error: " + e.ToString());
            }
        }
コード例 #7
0
        public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
        {
            if (handle is not IFileHandle file)
            {
                throw new ArgumentException("Could not load vault file! Make sure you're pointing to a vault json file in the manifest");
            }

            try
            {
                SavedGunSerializable savedGun = stage.ImmediateReaders.Get <JToken>()(file).ToObject <SavedGunSerializable>();

                TNHTweakerLogger.Log("TNHTweaker -- Vault file loaded successfuly : " + savedGun.FileName, TNHTweakerLogger.LogType.File);

                LoadedTemplateManager.AddVaultFile(savedGun);
            }
            catch (Exception e)
            {
                TNHTweakerLogger.LogError("Failed to load setup assets for vault file! Caused Error: " + e.ToString());
            }
        }
コード例 #8
0
        protected string GetHeaderString(SetupStage setupStage)
        {
            string header;

            switch (setupStage)
            {
            case SetupStage.DOWNLOADING_DUMPS:
                header = WindowLocalization.DownloadingDumpsStepHeader;
                break;

            case SetupStage.CREATING_DATABASE:
                header = WindowLocalization.CreatingDatabaseStepHeader;
                break;

            case SetupStage.IMPORTING_DUMPS:
                header = WindowLocalization.ImportingDumpsStepHeader;
                break;

            default:
                throw new Exception($"Unexpected setup stage: {setupStage}.");
            }
            return(WindowLocalization.GetStepHeader((int)setupStage, TOTAL_SETUP_STAGE_COUNT, header));
        }
コード例 #9
0
ファイル: LaneSpawner.cs プロジェクト: AugustoChies/Doomcook
 void Awake()
 {
     setupper = GameObject.Find("SpawnControl").GetComponent <SetupStage>();
 }
コード例 #10
0
ファイル: Entrypoint.cs プロジェクト: WurstModders/WurstMod
 private void StagesOnSetup(SetupStage stage)
 {
     stage.SharedAssetLoaders[Source, "level"] = LevelLoader;
 }
コード例 #11
0
        public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
        {
            if (handle is not IDirectoryHandle dir)
            {
                throw new ArgumentException("Could not load character! Character should point to a folder holding the character.json and thumb.png");
            }


            try
            {
                CustomCharacter character = null;
                Sprite          thumbnail = null;

                foreach (IFileHandle file in dir.GetFiles())
                {
                    if (file.Path.EndsWith("character.json"))
                    {
                        string charString = stage.ImmediateReaders.Get <string>()(file);
                        JsonSerializerSettings settings = new JsonSerializerSettings
                        {
                            NullValueHandling = NullValueHandling.Ignore
                        };
                        character = JsonConvert.DeserializeObject <CustomCharacter>(charString, settings);
                    }
                    else if (file.Path.EndsWith("thumb.png"))
                    {
                        thumbnail = TNHTweakerUtils.LoadSprite(file);
                    }
                }

                if (character == null)
                {
                    TNHTweakerLogger.LogError("TNHTweaker -- Failed to load custom character! No character.json file found");
                    return;
                }

                else if (thumbnail == null)
                {
                    TNHTweakerLogger.LogError("TNHTweaker -- Failed to load custom character! No thumb.png file found");
                    return;
                }

                //Now we want to load the icons for each pool
                foreach (IFileHandle iconFile in dir.GetFiles())
                {
                    foreach (EquipmentPool pool in character.EquipmentPools)
                    {
                        if (iconFile.Path.EndsWith(pool.IconName))
                        {
                            pool.GetPoolEntry().TableDef.Icon = TNHTweakerUtils.LoadSprite(iconFile);
                        }
                    }
                }


                TNHTweakerLogger.Log("TNHTweaker -- Character loaded successfuly : " + character.DisplayName, TNHTweakerLogger.LogType.File);

                LoadedTemplateManager.AddCharacterTemplate(character, thumbnail);
            }
            catch (Exception e)
            {
                TNHTweakerLogger.LogError("Failed to load setup assets for character! Caused Error: " + e.ToString());
            }
        }