Aragas/Bannerlord.MBOptionScreen

View on GitHub
src/MCM.UI/GUI/Prefabs/ModOptionsPageView.xml

Summary

Maintainability
Test Coverage
<Prefab>
  <Constants>

    <Constant Name="CancelButton.Width" BrushLayer="Default" BrushName="MCM.Cancel.Button" BrushValueType="Width" />
    <Constant Name="CancelButton.Height" BrushLayer="Default" BrushName="MCM.Cancel.Button" BrushValueType="Height" />

  </Constants>
  <Window>
    <Widget WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent">
      <Children>

        <!-- Main screen section -->
        <ListPanel Id="MainSection" WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent">
          <Children>

            <!--Left Side-->
            <BrushWidget Id="ModsListSection" WidthSizePolicy="Fixed" HeightSizePolicy="StretchToParent" SuggestedWidth="600" HorizontalAlignment="Left" VerticalAlignment="Top"
                         Brush="MCM.CharacterCreation.Panel" DoNotUseCustomScaleAndChildren="true" >
              <Children>

                <ListPanel WidthSizePolicy="StretchToParent" HeightSizePolicy="CoverChildren" LayoutImp.LayoutMethod="HorizontalLeftToRight">
                  <Children>
                    <!-- Title -->
                    <TextWidget Text="@ModsText" WidthSizePolicy="StretchToParent" HeightSizePolicy="CoverChildren" HorizontalAlignment="Center" VerticalAlignment="Top" MarginRight="22" MarginTop="5"
                                Brush="MCM.Title.Text" ClipContents="false" />
                    <ButtonWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="40" SuggestedHeight="40" MarginLeft="10" MarginRight="30"
                                  HorizontalAlignment="Right" VerticalAlignment="Center" Brush="MCM.Settings" Command.Click="ExecuteManageSettingsPack" >
                    </ButtonWidget>
                  </Children>
                </ListPanel>

                <!-- Mods Listing Section Inner Panel-->
                <Widget Id="InnerPanel" HeightSizePolicy="Fixed" WidthSizePolicy="Fixed" HorizontalAlignment="Left" VerticalAlignment="Center" SuggestedWidth="508" SuggestedHeight="635" PositionXOffset="27" PositionYOffset="25">
                  <Children>

                    <!-- Format for a list is: ScrollPanel -> Widget ClipRect -> ListPanel/Widget InnerPanel -> Items-->
                    <!-- ScrollablePanel needs: Reference to ClipRect, reference to ElementsList, reference to a scroll bar-->
                    <!-- Widget ClipRect needs width size policy to be CoverChildren and height size to be StretchToParent -->
                    <!-- ListPanel/Widget InnerPanel needs LayoutImp.LayoutMethod. Search for LayoutMethod in dnSpy for options. Size policies need to be CoverChildren -->
                    <!-- ListPanel Items needs ItemTemplate containing the screen to be used for each item. Size policies need to be CoverChildren.
                         DataSource property must be assigned using the {} braces. Example: DataSource="{DataSourcePropertyName}" -->
                    <ScrollablePanel Id="ModElementsScrollablePanel" WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" HorizontalAlightment="Left" VerticalAlignment="Bottom"
                                     AutoHideScrollBars="true" ClipRect="ModsListClipRect" InnerPanel="ModsListClipRect\ModList" VerticalScrollbar="..\ModsScrollbar\Scrollbar" MouseScrollAxis="Vertical">
                      <Children>

                        <!--Left Panel-->
                        <Widget Id="ModsListClipRect" WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" ClipContents="true" >
                          <Children>

                            <ListPanel Id="ModList" DataSource="{ModSettingsList}" WidthSizePolicy="StretchToParent" HeightSizePolicy="CoverChildren" LayoutImp.LayoutMethod="VerticalTopToBottom">
                              <ItemTemplate>
                                <SettingsItemView DoNotUseCustomScaleAndChildren="true" />
                              </ItemTemplate>
                            </ListPanel>

                          </Children>
                        </Widget>

                      </Children>
                    </ScrollablePanel>

                    <!-- Mod list scroll bar -->
                    <Standard.VerticalScrollbar Id="ModsScrollbar" HeightSizePolicy="StretchToParent" HorizontalAlignment="Right" VerticalAlignment="Bottom" MarginLeft="2" MarginTop="1" MarginBottom="1"/>

                  </Children>
                </Widget>

              </Children>
            </BrushWidget>


            <!-- Selected Mod Settings Section on the right -->
            <Widget WidthSizePolicy="Fixed" HeightSizePolicy="StretchToParent" MarginLeft="40" IsVisible="@SomethingSelected"
                    SuggestedWidth="1270" HorizontalAlignment="Right" VerticalAlignment="Top" MarginRight="10" MarginBottom="50">
              <Children>

                <ListPanel WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" LayoutImp.LayoutMethod="VerticalBottomToTop">
                  <Children>
                    <!-- Title Section -->
                    <ListPanel WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="80" LayoutImp.LayoutMethod="HorizontalLeftToRight"
                               HorizontalAlignment="Center" VerticalAlignment="Top">
                      <Children>
                        <!-- Dropdown Presets -->
                        <Widget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="300" SuggestedHeight="42" HorizontalAlignment="Left"
                                VerticalAlignment="Center" MarginLeft="20" IsVisible="@IsPresetsSelectorVisible">
                          <Children>
                            <Standard.DropdownWithHorizontalControl HorizontalAlignment="Center" Parameter.SelectorDataSource="{PresetsSelectorCopy}"
                                                                    Parameter.ShowNextAndPrevious="false" />
                          </Children>
                        </Widget>

                        <!-- Manage Presets -->
                        <ButtonWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="40" SuggestedHeight="40" MarginLeft="10" MarginRight="30"
                                      HorizontalAlignment="Right" VerticalAlignment="Center" Brush="MCM.Settings" Command.Click="ExecuteManagePresets" >
                        </ButtonWidget>

                        <!-- Title -->
                        <RichTextWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="80" Brush="MCM.Title.Text"
                                        Text="@SelectedDisplayName" HorizontalAlignment="Center" VerticalAlignment="Top"/>

                        <!-- Search box -->
                        <BrushWidget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="350" SuggestedHeight="40" VerticalAlignment="Center" HorizontalAlignment="Right" MarginLeft="40" MarginRight="20"
                                     DoNotAcceptEvents="true" Brush="MCM.Input.String">
                          <Children>
                            <EditableTextWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" VerticalAlignment="Center" HorizontalAlignment="Center" Brush="MCM.Text" RealText="@SearchText" IsObfuscationEnabled="false"  Command.FocusGained="StartTyping" Command.FocusLost="StopTyping" />
                            <Widget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="25" SuggestedHeight="24" HorizontalAlignment="Right" VerticalAlignment="Center" MarginRight="10" Sprite="mcm_icon_search" IsDisabled="true" />
                          </Children>
                        </BrushWidget>

                      </Children>
                    </ListPanel>

                    <!-- Separator -->
                    <BrushWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="2"  VerticalAlignment="Top" Brush="MCM.Divider.Yellow" MarginLeft="15" MarginRight="15"/>

                    <Widget WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" MarginRight="30" MarginLeft="30" IsVisible="@IsSettingVisible">
                      <Children>

                        <ScrollablePanel WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" ClipRect="SettingsClipRect" MarginRight="20"
                                         InnerPanel="SettingsClipRect\SettingsInnerPanel" AutoHideScrollBars="true" VerticalScrollbar="..\SettingsScrollBar\Scrollbar">
                          <Children>

                            <Widget Id="SettingsClipRect" WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" ClipContents="true">
                              <Children>

                                <Widget Id="SettingsInnerPanel" WidthSizePolicy="StretchToParent" HeightSizePolicy="CoverChildren">
                                  <Children>

                                    <SettingsView DataSource="{SelectedMod}" HeightSizePolicy="CoverChildren" WidthSizePolicy="StretchToParent" />

                                  </Children>
                                </Widget>

                              </Children>
                            </Widget>

                          </Children>
                        </ScrollablePanel>

                        <Standard.VerticalScrollbar Id="SettingsScrollBar" HeightSizePolicy="StretchToParent" HorizontalAlignment="Right" VerticalAlignment="Bottom"
                                                    MarginTop="2"/>

                      </Children>
                    </Widget>

                    <Widget HeightSizePolicy="StretchToParent" WidthSizePolicy="StretchToParent" MarginRight="30" MarginLeft="30" IsVisible="@IsSettingUnavailableVisible">
                      <Children>
                        <TextWidget Text="@UnavailableText" HeightSizePolicy="CoverChildren" WidthSizePolicy="CoverChildren" HorizontalAlignment="Left" VerticalAlignment="Center"
                                    Brush="MCM.Item.Name" MarginLeft="10" DoNotAcceptEvents="true" ClipContents="true" />
                      </Children>
                    </Widget>

                    <!-- Setting Hint Information Section -->
                    <ListPanel WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="100" VerticalAlignment="Bottom" LayoutImp.LayoutMethod="VerticalBottomToTop" MarginTop="1">
                      <Children>

                        <BrushWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="2"  VerticalAlignment="Top" Brush="MCM.Divider.Yellow" MarginLeft="15" MarginRight="15" MarginBottom="2"/>

                        <RichTextWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" Text="@HintText" IsVisible="@IsHintVisible"
                                    HorizontalAlignment="Left" VerticalAlignment="Center" MarginLeft="20" MarginRight="10" Brush="MCM.Hint.Text"/>

                      </Children>
                    </ListPanel>

                  </Children>
                </ListPanel>

              </Children>
            </Widget>

          </Children>
        </ListPanel>

      </Children>
    </Widget>
  </Window>
</Prefab>