Space Engineers

Space Engineers

Colorful Icons
Rayshader 28 SEP 2022 a las 13:55
Request to reuse textures
Hi,

Thank you for this mod and colors !

I've been writing a script to monitor stuff on LCD.
I currently use vanilla textures to display ores, ingots & components.

Is it possible to expose the textures of your mod to scripts / other mods?
When using the Ingame Api, I found sprite ID of other mods (when listing them), but not from Colorful Icons.

I was wondering if you would allow me to reuse your textures in my mod?
I'll write my own (based on my script) to provide direct LCD script instead of using a Programmable Block. In doing so, I'd be able to include a set of textures with my mod and reuse them. Of course, I'd give credits to your work and mod in my description.

Good day!
< >
Mostrando 1-9 de 9 comentarios
typekcz  [desarrollador] 29 SEP 2022 a las 5:19 
Hello,

yes, you can use my icons.
Take a look at Inventory Viewer. They also used my icons for LCDs.
If there is way to expose the icon sprites, let me know how and I will add it in so you and other modders can easilly access it.
Rayshader 29 SEP 2022 a las 15:16 
Hello,

Great, thank you :)
I didn't know this one, thanks for sharing!
For sure, I'll let you know.
Rayshader 1 OCT 2022 a las 9:02 
I found a way to expose your textures to LCD sprites :D
You can add a <filename.sbc> file along your scripts (Data\Scripts\<Mod>\.) to declare LCD Textures as Sprites.

I've made this file[pastebin.com] so far and put it manually in your mod where its installed on my machine.

It does declare sprites and I can reuse them from my homemade mod.

It implements Ores, Ingots, Components, Physical Guns (aka Weapons / Tools) and Ammo. I'm not sure about the binding of all AmmoMagazine (between in game name and your icons).

Syntax is simple:
  • SubtitleId tag is the SpriteId to use in scripts / mods (listed with IMyTextSurface.GetSprites).
  • TexturePath and SpritePath tags is the URL path to your DDS file. I set the same URL each time as I'm not sure about the difference between these tags.

I named SubtitleId with in game SubtitleId from existing items such as: CFI/<Type>/<Name>

CFI to tell it comes from your mod.
Type can be Ore, Ingot, Component, PhysicalGunObject, AmmoMagazine, etc. like defined in the game engine.
Name can be Cobalt, Ice, SolarCell, etc. like defined in the game engine.

Using this format, it is easy to bind items between code and sprite id.

As I have not implemented binding for all your icons, feel free to double check and add binding for the rest ;)
typekcz  [desarrollador] 11 OCT 2022 a las 5:11 
Looks good. I would only add <Selectable>false</Selectable> so that it won't be in LCD image menu.
I will make some script so that this file can be auto generated.
Rayshader 12 OCT 2022 a las 16:16 
Cool, good point.
You could even split into multiple files per type to still allow easy reading / custom edition such as Ores.sbc, Ingots.sbc...
Thanks, I'm looking forward to the next update.
typekcz  [desarrollador] 13 OCT 2022 a las 1:58 
So I added the definitions: https://github.com/typekcz/SpaceEngineersColorfulIcons/tree/master/ColorfulItems/Data

Check them out, try if they work.

Also if you could provide short code snippet of usage, I'll add a section about this in the mod descriptions, thanks.
Rayshader 15 OCT 2022 a las 14:18 
Great!

I've tested with my mod.
I found two bugs:

Old Components
There is two files: LCDTextures_Components.sbc and LCDTextures_OldComponents.sbc.
However in both files, SubtypeId is declared with the same prefix `ColorfulIcons_Component/`.
When game load assets, it seems to only keep the latest loaded SubtypeId, in this case path to old component textures.

I've tried on my machine, removing LCDTextures_OldComponents.sbc does load colorful icons.
Fix suggestion: use `ColorfulIcons_OldComponent/` prefix as a SubtypeId in this file.

Scrap
You define Scrap in Components variable in your Config.cs file.
But with these definitions `MyObjectBuilder_Ore/Scrap` and `MyObjectBuilder_Iron/Scrap`.
So far I've been using `MyObjectBuilder_Component/ScrapMetal` as a definition. `ScrapMetal` is the name I got from Game engine.
I'm not sure about this one, if it is an old "definition" from the game kept as a backward-compatibility...

I didn't try for Cubes, Ammo, PhysicalGuns.

Code snippet

/// List loaded sprites and check if one sprite from Colorful Icons is present. bool DetectColorfulIcons(IMyTextSurface surface) { List<string> sprites = new List<string>(); surface.GetSprites(sprites); return sprites.Contains("ColorfulIcons_Ingot/Iron"); } /// Draw an icon based on item's type and name at given position on LCD surface. /// Fallback to default icons if Colorful Icons is not detected. void DrawIcon(MySpriteDrawFrame frame, Vector2 position, string type, string name, bool hasColorfulIcons) { string spriteId = hasColorfulIcons ? $"ColorfulIcons_{Type}/{Name}" : $"MyObjectBuilder_{Type}/{Name}"; MySprite icon = new MySprite() { Type = SpriteType.TEXTURE, Data = spriteId, Position = position, Size = new Vector2(128f, 128f), Color = new Color(127, 127, 127), }; frame.Add(icon); } /// Usage /// /// Colorful Icons provide sprite ids by reusing game engine type and name. /// So you can easily reuse definitions from code and expect a match. /// bool hasColorfulIcons = DetectColorfulIcons(Surface); MySpriteDrawFrame frame = Surface.DrawFrame(); DrawIcon(frame, new Vector2(0, 0), "Ore", "Ingot", hasColorfulIcons); DrawIcon(frame, new Vector2(128, 0), "Ingot", "Gold", hasColorfulIcons); DrawIcon(frame, new Vector2(256, 0), "Component", "PowerCell", hasColorfulIcons); DrawIcon(frame, new Vector2(384, 0), "OldComponent", "PowerCell", hasColorfulIcons); DrawIcon(frame, new Vector2(0, 128), "CubeBlock", "LargeHydrogenEngine", hasColorfulIcons); frame.Dispose();
Última edición por Rayshader; 16 OCT 2022 a las 10:30
typekcz  [desarrollador] 16 OCT 2022 a las 0:31 
Ok, I'll fix the subid prefix for old components.
Looking at the scrap situation:
There is Ore/Scrap and Ingot/Scrap both in PhysicalItems.sbc.
Ingot/Scrap is commented with: "Old definition for backwards compatibility"
But I can't find reference to Component/ScrapMetal in the game's definitions, so that's weird.
Rayshader 16 OCT 2022 a las 10:28 
Great.
Ok fine, so Ore/Scrap seems to be the one to use.
I'll come back to you if I ever find an issue with other sprites.

PS: I fixed previous code snippet.
Última edición por Rayshader; 16 OCT 2022 a las 10:30
< >
Mostrando 1-9 de 9 comentarios
Por página: 1530 50