[WIP] Banner Editor Mod - Importing Banner From Image

Users who are viewing this thread

Drakehinst

Recruit
Hi everyone,

Based on the work from Bizzfarts (Banner Creator Web Tool and BannerPaste mod), I've been working on creating an image import mod (for those unfamiliar with the BannerPaste mod, it enables you to copy and paste your banner's code in the in-game banner editor screen).

My mod parses single pixels of an image into square icons of 1x1 and the closest RGB color from the palette Bannerlord implements to generate a banner code (for now I used an external python script to generate the banner code).

However I encountered an issue with the maximum number of icons allowed in a banner: the game doesn't seem to accept more than 400 icons (background icon included). Using a 20x20 pixels image therefore leads to losing the bottom-right corner pixel, as you can see on this image (individual square icons were scaled up from 1x1 to a larger size for better visualization):

unknown.png


I tracked down the issue until the TaleWorlds.Core.Banner.cs and TaleWorlds.MountAndBlade.View.BannerVisual.cs source files:
  • The clipboard is read entirely, never truncated, and the Banner.BannerDataList contains the right number of items.
  • When logging data from the BannerEditorView_OnTick class of the BannerPaste mod, the MetaMesh returned by Banner(clipboardText).ConvertToMultiMesh() contains 401 meshes, which is as expected if all 400 icons plus the 1 icon for the background are preserved.
Beyond this step, I lost track of where further processing is done. Would you have any idea where the truncation is happening? ?

PS:
  • Some will wonder whether the game could handle thousands of icons, e.g. if you were to import a 512x512 pixels image. I believe by looking at the source code that the game is rasterizing the "vector" banner, and therefore uses an optimized version everywhere else than on the banner editor screen. Can anyone confirm?
  • If this is the case, then there might be a way to bypass the vector-to-raster conversion entirely and instead convert the image directly into the right format.
 
Last edited:
Yes, I checked at least one such for-loop, the one which parses the "number.number.etc" string into individual coordinates, shapes and so on. The debug trace shows that the truncation happens after these icon data were interpreted and converted into meshes by ConvertToMultiMesh() in TaleWorlds.MountAndBlade.View.BannerVisual.cs.

I could not find the place in the code where the rest of the processing is done, and honestly without proper debugging capabilities this is going to be quite hard to solve...
 
Yes, if the rendering of images pixel per pixel is looking good, that'd would be the easiest way of customizing banners. Real artists have been doing incredible banners thanks to Bizzfarts tools, but I'm a programmer so I'll cheat my way through it. x)

Since the image parsing is done outside of the mod, I can give you the Nyancat banner code as shown above:

You can paste it in the banner editor screen using the BannerPaste mod. I did not make any change to it, except printing debug strings to the log file already used in the mod.

[EDIT: of course if you would like to have the decompiled source files I can provide them, but it seems most people here are familiar with dotPeek and similar softwares ?]
 
Back
Top Bottom