AlekseyAfonin / EquipBestItem

Mount & Blade: Bannerlord mod
https://www.nexusmods.com/mountandblade2bannerlord/mods/369/
MIT License
6 stars 3 forks source link

Request for Help #5

Closed Will-GuiSKJ closed 4 years ago

Will-GuiSKJ commented 4 years ago

Hi Aleksey, I am trying to learn how to mod bannerlord and I have been trying to rebuilt your mod myself, though much simpler.

I am having the hardest time figuring out why my Inventory prefab is not showing in the screen even though I now my Layer is being added.

If you wouldn't mind helping me, it would be great help. Documentation online is so sparse that I don't know what else to try.

AlekseyAfonin commented 4 years ago

Hi William,

Perhaps there are some mistakes in your movie file. Then it will not be displayed. To test this, try replacing the movie with another one that works. I checked the functionality of the simplest layer, which had a single button. To display a layer you need to:

  1. Movie must be in the way ..\ModuleName\GUI\Prefabs\
  2. Catch the event when the layer should be added, or catch the upper screen to which the layer should be added. (ScreenManager.TopScreens)
  3. Prepare the layer by creating a new instance and uploading the Movie to it, and bind the ViewModel to it. (The ViewModel is responsible for the display logic and command processing)
  4. Add a layer to the top screen by setting the display order.

You may find useful information here:

https://docs.bannerlordmodding.com/_tutorials/modding-gauntlet-without-csharp.html#important https://docs.bannerlordmodding.com/_gauntlet/screenbase.html

Will-GuiSKJ commented 4 years ago

I know that all my Behaviour, Layer and ViewModel C# logic is running, but nothing shows up.

I have a simple Prefab and Brush based on your earlier work, when you just had those "troope_tier_2" buttons on each slot. Here is my current prefab

<?xml version="1.0" encoding="utf-8" ?>
<Prefab>
  <Constants />
  <VisualDefinitions />
  <Window>
    <Widget DoNotAcceptEvents="true" WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent">
      <Children>

        <ButtonWidget Id="HelmButton" Command.Click="ExecuteEquipBestHelm" IsEnabled="@IsHelmButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Left" MarginLeft="585" MarginTop="250" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="CloakButton" Command.Click="ExecuteEquipBestCloak" IsEnabled="@IsCloakButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Left" MarginLeft="585" MarginTop="335" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="ArmorButton" Command.Click="ExecuteEquipBestArmor" IsEnabled="@IsArmorButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Left" MarginLeft="585" MarginTop="420" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="GloveButton" Command.Click="ExecuteEquipBestGlove" IsEnabled="@IsGloveButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Left" MarginLeft="585" MarginTop="505" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="BootButton" Command.Click="ExecuteEquipBestBoot" IsEnabled="@IsBootButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Left" MarginLeft="585" MarginTop="590" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="MountButton" Command.Click="ExecuteEquipBestMount" IsEnabled="@IsMountButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Left" MarginLeft="585" MarginTop="710" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="HarnessButton" Command.Click="ExecuteEquipBestHarness" IsEnabled="@IsHarnessButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Left" MarginLeft="585" MarginTop="795" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="Weapon1Button" Command.Click="ExecuteEquipBestWeapon1" IsEnabled="@IsWeapon1ButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Right" MarginRight="670" MarginTop="335" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="Weapon2Button" Command.Click="ExecuteEquipBestWeapon2" IsEnabled="@IsWeapon2ButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Right" MarginRight="670" MarginTop="420" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="Weapon3Button" Command.Click="ExecuteEquipBestWeapon3" IsEnabled="@IsWeapon3ButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Right" MarginRight="670" MarginTop="505" Brush="Inventory.UpgradeButton"/>
        <ButtonWidget Id="Weapon4Button" Command.Click="ExecuteEquipBestWeapon4" IsEnabled="@IsWeapon4ButtonEnabled" WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="35" SuggestedHeight="35" HorizontalAlignment="Right" MarginRight="670" MarginTop="590" Brush="Inventory.UpgradeButton"/>

      </Children>
    </Widget>
  </Window>
</Prefab>
AlekseyAfonin commented 4 years ago

Sorry for the long answer. Show the xml code in which you describe the brush "Inventory.Upgrade Button". Also make sure that all variables specified in IsEnabled="" are true, otherwise the buttons will be disabled (visibility depends on the brush description). I checked myself, everything is correct, so the problem is in the description of the brush, or in the variables.