private void SetupControls_ExtraPanel(UiBuilder <UPanel> innerPanelB, U.AtlasBuilder atlasBuilder, AddButtonsResult toolButtonsResult) { // This is toggle despawn and clear traffic panel using (UiBuilder <UPanel> rightPanelB = innerPanelB.ChildPanel <U.UPanel>( setupFn: p => { p.name = "TMPE_MainMenu_ExtraPanel"; // Silver background panel p.atlas = TextureUtil.FindAtlas("Ingame"); p.backgroundSprite = "GenericPanel"; // The panel will be Dark Silver at 50% dark 100% alpha p.color = new Color32(128, 128, 128, 255); })) { rightPanelB.ResizeFunction(r => { // Step to the right by 4px r.Stack(mode: UStackMode.ToTheRight, spacing: UConst.UIPADDING); r.FitToChildren(); }); // Place two extra buttons (despawn & clear traffic). // Use as many rows as in the other panel. var extraButtonsResult = AddButtonsFromButtonDefinitions( builder: rightPanelB, atlasBuilder: atlasBuilder, buttonDefs: EXTRA_BUTTON_DEFS, minRowLength: toolButtonsResult.Layout.Rows == 2 ? 1 : 2); ExtraButtonsList = extraButtonsResult.Buttons; } }
public void SetupExtraButtons(MainMenuWindow window, UBuilder builder, AddButtonsResult toolButtonsResult) { this.name = "TMPE_MainMenu_ExtraPanel"; // Silver background panel this.atlas = TextureUtil.Ingame; this.backgroundSprite = "GenericPanel"; // The panel will be Dark Silver at 50% dark 100% alpha this.color = new Color32(128, 128, 128, 255); this.ResizeFunction( resizeFn: (UResizer r) => { // Step to the right by 4px r.Stack( mode: UStackMode.ToTheRight, spacing: UConst.UIPADDING); r.FitToChildren(); }); // Place two extra buttons (despawn & clear traffic). // Use as many rows as in the other panel. var extraButtonsResult = AddButtonsFromButtonDefinitions( window, parentComponent: this, builder, buttonDefs: EXTRA_BUTTON_DEFS, minRowLength: toolButtonsResult.Layout.Rows == 2 ? 1 : 2); window.ExtraButtonsList = extraButtonsResult.Buttons; }
/// <summary>Called from ModUI to setup children for the window.</summary> /// <param name="builder">The UI Builder.</param> public void SetupControls(UiBuilder <MainMenuWindow> builder) { // Create and populate list of background atlas keys, used by all buttons // And also each button will have a chance to add their own atlas keys for loading. var tmpSkin = new U.ButtonSkin { Prefix = "MainMenuPanel", BackgroundPrefix = "RoundButton", ForegroundNormal = false, BackgroundHovered = true, BackgroundActive = true, }; // By default the atlas will include backgrounds: DefaultRound-bg-normal var atlasBuilder = new U.AtlasBuilder(); tmpSkin.UpdateAtlasBuilder( atlasBuilder: atlasBuilder, spriteSize: new IntVector2(50)); // Create Version Label and Help button: // [ TM:PE 11.x ] [?] UILabel versionLabel = SetupControls_TopRow(builder, atlasBuilder); // Main menu contains 2 panels side by side, one for tool buttons and another for // despawn & clear buttons. ButtonsDict = new Dictionary <ToolMode, BaseMenuButton>(); // U.UPanel leftPanel; using (var innerPanelB = builder.ChildPanel <U.UPanel>(setupFn: p => { p.name = "TMPE_MainMenu_InnerPanel"; })) { innerPanelB.ResizeFunction(r => { r.Stack(mode: UStackMode.Below, spacing: 0f, stackRef: versionLabel); r.FitToChildren(); }); AddButtonsResult toolButtonsResult = SetupControls_ToolPanel(innerPanelB, atlasBuilder); SetupControls_ExtraPanel(innerPanelB, atlasBuilder, toolButtonsResult); } // Create atlas and give it to all buttons allButtonsAtlas_ = atlasBuilder.CreateAtlas( atlasName: "MainMenu_Atlas", loadingPath: "MainMenu.Tool", atlasSizeHint: new IntVector2(512)); foreach (BaseMenuButton b in ToolButtonsList) { b.atlas = allButtonsAtlas_; } foreach (BaseMenuButton b in ExtraButtonsList) { b.atlas = allButtonsAtlas_; } this.toggleOsdButton_.atlas = allButtonsAtlas_; //------------------------------------------------------------------------- // Foldable panel with keybinds, starts hidden below or above the main menu //------------------------------------------------------------------------- SetupControls_OnscreenDisplayPanel(builder); // Floating labels under TM:PE window SetupControls_DebugLabels(builder, this.OnscreenDisplayPanel); }