From 04a745703b5469c00deb552c4e407e1b2496f0fe Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 19 Apr 2022 20:38:25 +0200 Subject: [PATCH] added a custom wallpaper example --- Content/ExampleMod/Localization/En.json | 3 ++- Content/ExampleMod/Wallpapers.png | Bin 0 -> 706 bytes ExampleMod.cs | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Content/ExampleMod/Wallpapers.png diff --git a/Content/ExampleMod/Localization/En.json b/Content/ExampleMod/Localization/En.json index 69f3d79..7d22f11 100644 --- a/Content/ExampleMod/Localization/En.json +++ b/Content/ExampleMod/Localization/En.json @@ -1,6 +1,7 @@ { "BuildMode": { - "ExampleMod.CustomTable": "Custom Table" + "ExampleMod.CustomTable": "Custom Table", + "ExampleMod.CrossedWallpaper": "Crossed Wallpaper" }, "Clothes": { "ExampleMod.DarkShirt": "Dark Shirt", diff --git a/Content/ExampleMod/Wallpapers.png b/Content/ExampleMod/Wallpapers.png new file mode 100644 index 0000000000000000000000000000000000000000..b8974bf1c9167c88abbdde160feac6eeb9affa99 GIT binary patch literal 706 zcmeAS@N?(olHy`uVBq!ia0vp^4M6;XgAGWYkjVi_Fct^7J29*~C-ahlfvLvR#WAE} z&f7cQMUM;w7%upAE#-T_eRhrIs_Q3PEgHU0KH4LpY$uk`%=12UY0$!+$S>}?j6XZ1 zzt;Xw|MR_U_um~~<801fb<}2-7ra;+`=)Gn#{`b-VA(Y?KV;tgv0f^2*udp_si2@x zVyaoNc#pQ-Qj^NVb0mIN3N6e{7fy)zDEMD{cbJ!EkeATHLU+yy%+r`7PQ9(q*`qV% zQ?k%P-`^}6*MF$K;COp;%G!Tn(|0*k#!F?!-?G}c!|6xvANVxS?)jd` zw|@dQhkTIut-3(1V5>LlYr|~z6$^je-sIn~b6b7WZoN?1gmuM?yF0$gs2rHn?y$T} zEUn|4O%2-uU3boaZ7(d_wk_?Ow)1|H?1HlFlf`p=8+Q7!=l;Hx##T|BF08P<;Og&N zVy_v#{dsLLli@pGk$2sJmfx{5Oz&4FwA;NlxXBpuA$xW$o5fU}w8pa7JFF>N8MkCd z$UkSuf47QdM~PKL@L#*?8}k;k7<||}eYMqro#qu;*X!~HwmyF*sj$5`xArcd(1K-? zibbb4%C|Wht-0{z`eAR&6Sv=f`~KtOzW4jH=EeUOHIhp0cC6;8d8r|IihIxg3w_NjJ2pL9 z{(?h$L#M@>Uy@AmRyPGd*-wA8^P6l!=0pT-G@yGywoGTOKk1 literal 0 HcmV?d00001 diff --git a/ExampleMod.cs b/ExampleMod.cs index b628879..c2ea4c3 100644 --- a/ExampleMod.cs +++ b/ExampleMod.cs @@ -12,6 +12,7 @@ using TinyLife.Emotions; using TinyLife.Mods; using TinyLife.Objects; using TinyLife.Utilities; +using TinyLife.World; namespace ExampleMod; @@ -31,6 +32,7 @@ public class ExampleMod : Mod { private UniformTextureAtlas customHairs; private UniformTextureAtlas customBottoms; private UniformTextureAtlas uiTextures; + private UniformTextureAtlas wallpaperTextures; public override void AddGameContent(GameImpl game, ModInfo info) { // adding a custom furniture item @@ -92,6 +94,9 @@ public class ExampleMod : Mod { // we use this emotion modifier in SitDownOnGrassAction GrassSittingModifier = EmotionModifier.Register( new EmotionModifier("ExampleMod.GrassSitting", this.uiTextures[1, 0], EmotionType.Happy)); + + // adding a custom wallpaper (we're using the top left texture region, which is why we pass 0, 0 as the texture coordinate) + Wallpaper.Register("ExampleMod.CrossedWallpaper", 15, this.wallpaperTextures, new Point(0, 0), ColorScheme.Modern, this.Icon); } public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) { @@ -103,6 +108,8 @@ public class ExampleMod : Mod { texturePacker.Add(content.Load("CustomHairs"), r => this.customHairs = new UniformTextureAtlas(r, 4, 6)); texturePacker.Add(content.Load("CustomBottomsShoes"), r => this.customBottoms = new UniformTextureAtlas(r, 8, 6)); texturePacker.Add(content.Load("UiTextures"), r => this.uiTextures = new UniformTextureAtlas(r, 8, 8)); + // wallpaper textures require special treatment to work with openings, the x and y values are passed to the UniformTextureAtlas constructor + TextureHandler.ApplyWallpaperMasks(content.Load("Wallpapers"), 4, 5, r => this.wallpaperTextures = r); } public override IEnumerable GetCustomFurnitureTextures(ModInfo info) {