BL Coding Execute functions called in XML-Prefabs

Currently viewing this thread:

Souly13

Recruit
Hey Community,

I try to implement a Button on the clan-screen, nearly like the "Leave Kingdom" button. Add this button is not the problem, but add the functionality I cant figure out. In the prefab there is the line for the leave kingdom button:

XML:
 <!--Leave Kingdom Button-->
                <ButtonWidget Id="LeaveKingdomButton" DoNotPassEventsToChildren="true" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="!CancelButton.Width" SuggestedHeight="!CancelButton.Height" HorizontalAlignment="Right" MarginRight="290" Brush="Popup.Delete.Button" Command.Click="ExecuteLeaveKingdom" IsVisible="@ClanIsInAKingdom">
                  <Children>
                    <TextWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" Brush="Popup.Button.Text" Text="@LeaveKingdomText" />
                  </Children>
                </ButtonWidget>

Here you have the attribut: Command.Click="ExecuteLeaveKingdom". Two questions for that

1. Where can I find that function? (ExecuteLeaveKingdom)

2. If I want to implement an own function, how I do this? If I use the prefab and my SubModule.dll, it is hard to me to understand, where the XML-File know, where to find my function and the origin functions. Or is it not important and I can create a function "clickMe" in my class and call that function in the prefab-xml anyway?

Maybe i lost my understanding for this, so Im glad for tips :wink:
 

Ra'Jiska

Subforum Moderator
WF&SWBNWM&BVC
I am also interested in the answer to those questions, couldn't quite figure out how the link between the GauntletUI and the VM source file was made.
 
Upvote 0
Alright, i ran into the very same issue lately while trying to modify the UI.
I don't know if you are familiar with WPF in C#, but in fact it's pretty close to it, if not exactly the same. Each XML file is tied to a class file, that is some sort of listener, and this .cs file will store all the variables you can use in your XML but also the methods you can call from it.

So basically you can add anything in your XML, if it's not properly registered in the corresponding class file, nothing will work. I'm currently trying to make some researches of exactly how it works, how to replace the calling class how to extend and how to replace on in the game by the new one. But no success currently.

So far i could add some information to a XML file, datas that are not shown in the class file, but adding your function will definitely to override the class and have a way to add it to the game.
 
Upvote 0

Souly13

Recruit
Alright, i ran into the very same issue lately while trying to modify the UI.
I don't know if you are familiar with WPF in C#, but in fact it's pretty close to it, if not exactly the same. Each XML file is tied to a class file, that is some sort of listener, and this .cs file will store all the variables you can use in your XML but also the methods you can call from it.

Yea, I thought it is like you discripe. I wondered about, how to change the called .cs. There must be a linking-file or something i guess. It is a bit unusual, that the used cs is not declared in the xml file itself. So there are two options i think: first, there is a link-file, which link the cs with the xml files and give the paths to the files. Second, the cs file self is loaded and in the cs file there is the path to the xml file. Another option i dont see.
 
Upvote 0
Well if you have any clues about it please message me cause i have the same issue. i could spot the files and how they work but couldn't so far really get how they are linked and how they are declared. And i'm looking for it for two days lol. (Of course i do not do only this ... But it start to seriously bug me).
There should be a way and it's most likely below our eyes as it's not Engine related but inside the sandbox submodule that most of this is done ... But it's quite shady i must say.
 
Upvote 0

Souly13

Recruit
Well if you have any clues about it please message me cause i have the same issue. i could spot the files and how they work but couldn't so far really get how they are linked and how they are declared. And i'm looking for it for two days lol. (Of course i do not do only this ... But it start to seriously bug me).
There should be a way and it's most likely below our eyes as it's not Engine related but inside the sandbox submodule that most of this is done ... But it's quite shady i must say.

I think I found something.

In TaleWorlds.Core -> TaleWorlds.Core there are one hand "XmlHelper" and "XmlResource". In XmlResource, there are the functions: "GetXmlListAndApply" and "InitializeXmlInformationList". I think, thats could be the holy grail xD
 
Upvote 0

Souly13

Recruit
Well if you have any clues about it please message me cause i have the same issue.

I found another thing ^^

The Mod "CharacterCreation" is open source, so I looked in some of the code-files. In the cs there is:


C#:
 // Load our XML files
        private void LoadXMLFiles(CampaignGameStarter gameInitializer)
        {
            // Load our additional strings
            gameInitializer.LoadGameTexts(BasePath.Name + "Modules/" + ModuleFolderName + "/ModuleData/" + strings + ".xml");
        }

        // Called when loading save game
        public override void OnGameLoaded(Game game, object initializerObject)
        {
            CampaignGameStarter gameInitializer = (CampaignGameStarter)initializerObject;
            this.LoadXMLFiles(gameInitializer);
            TaleWorlds.Core.FaceGen.ShowDebugValues = true;
        }

        // Called when starting new campaign
        public override void OnNewGameCreated(Game game, object initializerObject)
        {
            CampaignGameStarter gameInitializer = (CampaignGameStarter)initializerObject;
            this.LoadXMLFiles(gameInitializer);
            TaleWorlds.Core.FaceGen.ShowDebugValues = false; // Disable until after game started.
        }

I think, that is how it works
 
Upvote 0
I'm pretty sure all the cooking is made into TaleWorlds.Library.ViewModel, i still don't understand how, but every clue i get leads to this class, at least to one of it's child.

Ok i think i found how it works. But i can't make it work for now, it's really too complicated for me so far, or will need more work.
SandBoxViewCreator is called by sandboxviewsubmodule and it seem to be a class generating a few of the GUI elements.
This class is full of statics and inside you have some like CreateMapView<T> that instanciate and return a Mapview of type T
Still need to figure how it's used and where.
 
Last edited:
Upvote 0
Top Bottom