private UITextureAtlas GetAtlas() { if (laneArrowButtonAtlas_ != null) { return(laneArrowButtonAtlas_); } // Create base atlas with backgrounds and no foregrounds ButtonSkin backgroundOnlySkin = ButtonSkin.CreateDefaultNoForeground("LaneArrow"); var futureAtlas = new U.AtlasBuilder(); backgroundOnlySkin.UpdateAtlasBuilder( atlasBuilder: futureAtlas, spriteSize: new IntVector2(64)); // Merge names of all foreground sprites for 3 directions into atlasKeySet foreach (string prefix in new[] { "LaneArrowLeft", "LaneArrowRight", "LaneArrowForward" }) { ButtonSkin skin = ButtonSkin.CreateDefaultNoBackground(prefix); // Create keysets for lane arrow button icons and merge to the shared atlas skin.UpdateAtlasBuilder( atlasBuilder: futureAtlas, spriteSize: new IntVector2(64)); } // Load actual graphics into an atlas laneArrowButtonAtlas_ = futureAtlas.CreateAtlas( atlasName: "LaneArrowsTool_Atlas", loadingPath: "LaneArrows", atlasSizeHint: new IntVector2(256)); return(laneArrowButtonAtlas_); }
private UITextureAtlas GetUiAtlas() { if (guiAtlas_ != null) { return(guiAtlas_); } // Create base atlas with backgrounds and no foregrounds var futureAtlas = new AtlasBuilder( atlasName: "SpeedLimits_Atlas", loadingPath: "SpeedLimits", sizeHint: new IntVector2(512)); // Merge names of all button sprites atlasBuilder foreach (string prefix in new[] { "MphToggle", "EditSegments", "EditLanes", "EditDefaults" }) { ButtonSkin skin = ButtonSkin.CreateSimple( foregroundPrefix: prefix, backgroundPrefix: UConst.MAINMENU_ROUND_BUTTON_BG) .CanActivate(background: false) .CanHover(foreground: false); // Create keysets for lane arrow button icons and merge to the shared atlas skin.UpdateAtlasBuilder( atlasBuilder: futureAtlas, spriteSize: new IntVector2(50)); } // Load actual graphics into an atlas return(futureAtlas.CreateAtlas()); }
private UILabel SetupControls_TopRow(UiBuilder <MainMenuWindow> builder, U.AtlasBuilder atlasBuilder) { UILabel versionLabel; using (var versionLabelB = builder.Label <U.ULabel>(TrafficManagerMod.ModName)) { versionLabelB.ResizeFunction(r => r.Stack(UStackMode.Below)); this.VersionLabel = versionLabel = versionLabelB.Control; } using (var btnBuilder = builder.Button <U.UButton>()) { UButton control = btnBuilder.Control; this.toggleOsdButton_ = control; control.atlas = this.allButtonsAtlas_; control.name = "TMPE_MainMenu_HelpButton"; // Texture for Help will be included in the `allButtonsAtlas_` ButtonSkin skin = new ButtonSkin { BackgroundPrefix = "RoundButton", Prefix = "Help", BackgroundHovered = true, BackgroundActive = true, ForegroundActive = true, }; skin.UpdateAtlasBuilder( atlasBuilder, spriteSize: new IntVector2(50)); control.Skin = skin; control.UpdateButtonImage(); // This has to be done later when form setup is done: // helpB.Control.atlas = allButtonsAtlas_; btnBuilder.ResizeFunction( resizeFn: r => { r.Control.isVisible = true; // not sure why its hidden on create? TODO r.Stack(mode: UStackMode.ToTheRight, spacing: UConst.UIPADDING * 3f, stackRef: versionLabel); r.Width(UValue.FixedSize(18f)); // assume Version label is 18pt high r.Height(UValue.FixedSize(18f)); }); control.uCanActivate = c => true; control.uTooltip = Translation.Menu.Get("Tooltip:Toggle onscreen display panel"); control.uIsActive = c => GlobalConfig.Instance.Main.KeybindsPanelVisible; control.uOnClick += (component, eventParam) => { ModUI.Instance.MainMenu.OnToggleOsdButtonClicked(component as U.UButton); }; } return(versionLabel); }
private UITextureAtlas GetAtlas() { if (laneArrowButtonAtlas_ != null) { return(laneArrowButtonAtlas_); } // Create base atlas with backgrounds and no foregrounds ButtonSkin backgroundOnlySkin = ButtonSkin.CreateSimple( foregroundPrefix: "LaneArrow", backgroundPrefix: "LaneArrow") .CanHover(foreground: false) .CanActivate(foreground: false) .NormalForeground(false); var futureAtlas = new AtlasBuilder( atlasName: "TMPE_LaneArrowsTool_Atlas", loadingPath: "LaneArrows", sizeHint: new IntVector2(256)); backgroundOnlySkin.UpdateAtlasBuilder( atlasBuilder: futureAtlas, spriteSize: new IntVector2(64)); // Merge names of all foreground sprites for 3 directions into atlasKeySet foreach (string prefix in new[] { "LaneArrowLeft", "LaneArrowRight", "LaneArrowForward" }) { ButtonSkin skin = ButtonSkin.CreateSimple( foregroundPrefix: prefix, backgroundPrefix: string.Empty) .CanActivate(background: false); // Create keysets for lane arrow button icons and merge to the shared atlas skin.UpdateAtlasBuilder( atlasBuilder: futureAtlas, spriteSize: new IntVector2(64)); } // Load actual graphics into an atlas laneArrowButtonAtlas_ = futureAtlas.CreateAtlas(); return(laneArrowButtonAtlas_); }