コード例 #1
0
        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();

            var uiResourceDepot = UIResourceManager.UIResourceDepot;
            var resourceContext = UIResourceManager.ResourceContext;
            var spriteData1     = UIResourceManager.SpriteData;
            var spriteData2     = new SpriteData("RevolutionsSpriteData");

            spriteData2.Load(uiResourceDepot);
            var texture = new TaleWorlds.TwoDimension.Texture(new EngineTexture(TaleWorlds.Engine.Texture.CreateTextureFromPath("../../Modules/Revolutions/GUI/SpriteSheets/", "revolutions-ui-1.png")));

            spriteData1.SpriteCategories.Add("revolutions_events", spriteData2.SpriteCategories["revolutions_events"]);
            spriteData1.SpriteNames.Add("Revolutions.PlottingLords", new SpriteGeneric("Revolutions.PlottingLords", spriteData2.SpritePartNames["Revolutions.PlottingLords"]));
            spriteData1.SpriteNames.Add("Revolutions.Whatever", new SpriteGeneric("Revolutions.Whatever", spriteData2.SpritePartNames["Revolutions.Whatever"]));

            var spriteCategory = spriteData1.SpriteCategories["revolutions_events"];

            spriteCategory.SpriteSheets.Add(texture);
            spriteCategory.Load(resourceContext, uiResourceDepot);
            UIResourceManager.BrushFactory.Initialize();

            var harmony = new Harmony(this.GetType().Namespace);

            harmony.PatchAll(this.GetType().Assembly);
        }
コード例 #2
0
        protected override void OnSubModuleLoad()
        {
            var rd = UIResourceManager.UIResourceDepot;
            var rc = UIResourceManager.ResourceContext;
            var sd = UIResourceManager.SpriteData;

            var spriteData = new SpriteData("BetterTimeSpriteData");

            spriteData.Load(rd);

            var texture = new TaleWorlds.TwoDimension.Texture((TaleWorlds.TwoDimension.ITexture)
                                                              new EngineTexture(
                                                                  TaleWorlds.Engine.Texture.CreateTextureFromPath(
                                                                      @"../../Modules/BetterTime/GUI/SpriteSheets/better_time_icons/", "better_time_icons_1.png")
                                                                  )
                                                              );

            //sd.SpriteCategories.Add("better_time_icons", spriteData.SpriteCategories["better_time_icons"]);
            //sd.SpritePartNames.Add("FastForward@4x", spriteData.SpritePartNames["FastForward@4x"]);
            //sd.SpriteNames.Add("FastForward@4x", new SpriteGeneric("FastForward@4x", spriteData.SpritePartNames["FastForward@4x"]));
            //sd.SpritePartNames.Add("FastForward@4x_selected", spriteData.SpritePartNames["FastForward@4x_selected"]);
            //sd.SpriteNames.Add("FastForward@4x_selected", new SpriteGeneric("FastForward@4x", spriteData.SpritePartNames["FastForward@4x_selected"]));

            var bettertimeicons = sd.SpriteCategories["better_time_icons"];

            bettertimeicons.SpriteSheets.Add(texture);
            bettertimeicons.Load((ITwoDimensionResourceContext)rc, rd);

            UIResourceManager.BrushFactory.Initialize();
            InitializeHotKeyManager();
        }
コード例 #3
0
        public static void LoadFontFromModule()
        {
            var licence = true;

            if (licence)
            {
                //load texture
                GameTex texture = new GameTex((ITexture) new EngineTexture(EngineTex.CreateTextureFromPath($"../../Modules/{ModuleName}/Font", $"{FontName}.png")));

                //set temporary sprite data
                SpriteData     spriteData    = new SpriteData("Font Atlas");
                SpriteCategory category      = new SpriteCategory($"{FontName}", spriteData, 1);
                SpritePart     spritePart    = new SpritePart($"{FontName}", category, texture.Width, texture.Height);
                SpriteGeneric  spriteGeneric = new SpriteGeneric($"{FontName}", spritePart);

                // set sprite part data. (sheetid = 1 is chinise font.)
                category.Load((IResourceContext) new TextureLoader(texture), (ResourceDepot)null);
                spritePart.SheetID = 1;
                spritePart.SheetX  = 0;
                spritePart.SheetY  = 0;
                spriteData.SpriteNames.Add($"{FontName}", (Sprite)spriteGeneric);

                Font font = new Font($"{FontName}", $"../../Modules/{ModuleName}/Font/{FontName}.fnt", spriteData);
                /* reflection font factory */
                Dictionary <string, Font> _bitmapFont =
                    typeof(FontFactory).GetField("_bitmapFonts", BindingFlags.Instance | BindingFlags.NonPublic)
                    .GetValue((object)UIResourceManager.FontFactory)
                    as Dictionary <string, Font>;


                Dictionary <string, Dictionary <string, Font> > _localizationMap =
                    typeof(FontFactory).GetField("_fontLocalizationMap", BindingFlags.Instance | BindingFlags.NonPublic)
                    .GetValue((object)UIResourceManager.FontFactory)
                    as Dictionary <string, Dictionary <string, Font> >;
                _bitmapFont[CoverFontName] = font;

                Dictionary <string, Font> _defaultFontMap =
                    typeof(FontFactory).GetField("_fontLocalizationMap", BindingFlags.Instance | BindingFlags.NonPublic)
                    .GetValue((object)UIResourceManager.FontFactory) as Dictionary <string, Font>;

                LocalizationMap = _localizationMap;
                /* cover font data. */
                foreach (string index in new List <string>((IEnumerable <string>)_localizationMap[XMLKey].Keys))
                {
                    _localizationMap[XMLKey][index] = font;
                }

                /* apply */
                UIResourceManager.FontFactory.DefaultFont = font;
                FontLoaded = true;
            }
            else
            {
                InformationManager.ShowInquiry(new InquiryData("Module Load Faile!", "failed load module.", true, false, ":(", null, null, null));
            }
        }
コード例 #4
0
        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();
            try
            {
                Settings.Load();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to load SettlementIcons settings:\n" + ex.Message);
            }
            try
            {
                SpriteData spriteData = new SpriteData("siSpriteData");

                spriteData.Load(UIResourceManager.UIResourceDepot);
                // 1.5.4 - Commented out the SpriteData loading as it's handled by the TW engine now.

                /*
                 * foreach (KeyValuePair<string, SpriteCategory> keyValuePair in spriteData.SpriteCategories)
                 * {
                 *      UIResourceManager.SpriteData.SpriteCategories.Add(keyValuePair.Key, keyValuePair.Value);
                 *      //MessageBox.Show("Pairs: " + keyValuePair.Key + " - " + keyValuePair.Value);
                 * }
                 * foreach (KeyValuePair<string, SpritePart> keyValuePair2 in spriteData.SpritePartNames)
                 * {
                 *      UIResourceManager.SpriteData.SpritePartNames.Add(keyValuePair2.Key, keyValuePair2.Value);
                 * }
                 * foreach (KeyValuePair<string, Sprite> keyValuePair3 in spriteData.SpriteNames)
                 * {
                 *      UIResourceManager.SpriteData.SpriteNames.Add(keyValuePair3.Key, keyValuePair3.Value);
                 * }
                 */
                UIResourceManager.SpriteData.SpriteCategories["ui_custom_si"].Load(UIResourceManager.ResourceContext, UIResourceManager.UIResourceDepot);
                UIResourceManager.SpriteData.SpriteCategories["ui_custom_si"].SpriteSheets.Clear();
                string folder = BasePath.Name + "/Modules/SettlementIcons/GUI/SpriteSheets/ui_custom_si/";
                TaleWorlds.TwoDimension.Texture item = new TaleWorlds.TwoDimension.Texture(new EngineTexture(TaleWorlds.Engine.Texture.LoadTextureFromPath("ui_custom_si_1.png", folder)));
                UIResourceManager.SpriteData.SpriteCategories["ui_custom_si"].SpriteSheets.Add(item);
            }
            catch (Exception ex2)
            {
                MessageBox.Show("Failed to load sprites " + ex2.Message);
            }
            try
            {
                new Harmony("com.rhokwar.bannerlord.settlementicons").PatchAll();
                bool isQuestIconEnabled      = Settings.SettlementIcons.IsQuestIconEnabled;
                bool isTournamentIconEnabled = Settings.SettlementIcons.IsTournamentIconEnabled;
            }
            catch (Exception ex3)
            {
                Exception innerException = ex3.InnerException;
                MessageBox.Show("Failed to apply the SettlementIcons patch:\n" + ex3.Message + "\n" + ((innerException != null) ? innerException.Message : null));
            }
        }
コード例 #5
0
        public void AddSprites(string spriteSheet, int sheetId = 1)
        {
            SpriteCategory spriteCategory = UIResourceManager.SpriteData.SpriteCategories[spriteSheet];

            spriteCategory.Load(UIResourceManager.ResourceContext, resourceDepot);
            var texture = TaleWorlds.Engine.Texture.LoadTextureFromPath($"{spriteSheet}_{sheetId}.png",
                                                                        BasePath.Name + "Modules/BattleStamina/Sprites/SpriteSheets/" + spriteSheet);

            texture.PreloadTexture();
            var texture2D = new TaleWorlds.TwoDimension.Texture(new EngineTexture(texture));

            UIResourceManager.SpriteData.SpriteCategories[spriteSheet].SpriteSheets[sheetId - 1] = texture2D;
        }
コード例 #6
0
 private void CheckTexture()
 {
     if (this._texture != this._characterTableau.Texture)
     {
         this._texture = this._characterTableau.Texture;
         if (this._texture != null)
         {
             EngineTexture platformTexture = new EngineTexture(this._texture);
             this._providedTexture = new TaleWorlds.TwoDimension.Texture(platformTexture);
             return;
         }
         this._providedTexture = null;
     }
 }
コード例 #7
0
        public static void Load()
        {
            var rd = UIResourceManager.UIResourceDepot;
            var rc = UIResourceManager.ResourceContext;
            var sd = UIResourceManager.SpriteData;

            var spriteData = new SpriteData("entrepreneur-ui-1");

            spriteData.Load(rd);
            var texture = new TaleWorlds.TwoDimension.Texture((TaleWorlds.TwoDimension.ITexture)
                                                              new EngineTexture(
                                                                  TaleWorlds.Engine.Texture.CreateTextureFromPath(
                                                                      @"../../Modules/Entrepreneur/GUI/SpriteSheets/", "entrepreneur-ui-1.png")
                                                                  )
                                                              );

            sd.SpriteCategories.Add("entrepreneur-ui-1", spriteData.SpriteCategories["entrepreneur-ui-1"]);


            sd.SpritePartNames.Add("FinancesIcon", spriteData.SpritePartNames["FinancesIcon"]);
            sd.SpriteNames.Add("FinancesIcon", new SpriteGeneric("FinancesIcon", spriteData.SpritePartNames["FinancesIcon"]));

            sd.SpritePartNames.Add("MapbarLeftFrame", spriteData.SpritePartNames["MapbarLeftFrame"]);
            sd.SpriteNames.Add("MapbarLeftFrame", new SpriteGeneric("MapbarLeftFrame", spriteData.SpritePartNames["MapbarLeftFrame"]));

            sd.SpritePartNames.Add("Entrepreneur.EmptyField", spriteData.SpritePartNames["Entrepreneur.EmptyField"]);
            sd.SpriteNames.Add("Entrepreneur.EmptyField", new SpriteGeneric("Entrepreneur.EmptyField", spriteData.SpritePartNames["Entrepreneur.EmptyField"]));

            sd.SpritePartNames.Add("Entrepreneur.WorkingField", spriteData.SpritePartNames["Entrepreneur.WorkingField"]);
            sd.SpriteNames.Add("Entrepreneur.WorkingField", new SpriteGeneric("Entrepreneur.WorkingField", spriteData.SpritePartNames["Entrepreneur.WorkingField"]));

            sd.SpritePartNames.Add("Entrepreneur.VillagePropertyIcon", spriteData.SpritePartNames["Entrepreneur.VillagePropertyIcon"]);
            sd.SpriteNames.Add("Entrepreneur.VillagePropertyIcon", new SpriteGeneric("Entrepreneur.VillagePropertyIcon", spriteData.SpritePartNames["Entrepreneur.VillagePropertyIcon"]));
            var bettertimeicons = sd.SpriteCategories["entrepreneur-ui-1"];

            bettertimeicons.SpriteSheets.Add(texture);
            bettertimeicons.Load((ITwoDimensionResourceContext)rc, rd);

            UIResourceManager.BrushFactory.Initialize();
        }
コード例 #8
0
 public TextureLoader(TaleWorlds.TwoDimension.Texture texture)
 {
     this.texture = texture;
 }