public void TestNoCrashOnMissingResources() { using (var glyphStore = new RawCachingGlyphStore(fontResourceStore, "DoesntExist") { CacheStorage = storage }) using (var fontStore = new FontStore(glyphStore, 100)) { Assert.That(glyphStore.Get('a'), Is.Null); Assert.That(fontStore.Get("DoesntExist", 'a'), Is.Null); Assert.That(fontStore.Get("OtherAttempt", 'a'), Is.Null); } }
private static void AddInfo(ref UIPanel page, string name, string value) { var label = page.AddUIComponent <UILabel>(); label.font = FontStore.Get(12); label.text = $"{name}: {value}"; }
public void TestNestedScaleAdjust() { var fontStore = new FontStore(new GlyphStore(fontResourceStore, "OpenSans") { CacheStorage = storage }, scaleAdjust: 100); var nestedFontStore = new FontStore(new GlyphStore(fontResourceStore, "OpenSans-Bold") { CacheStorage = storage }, 10); fontStore.AddStore(nestedFontStore); var normalGlyph = (TexturedCharacterGlyph)fontStore.Get("OpenSans", 'a'); var boldGlyph = (TexturedCharacterGlyph)fontStore.Get("OpenSans-Bold", 'a'); Assert.That(normalGlyph.Scale, Is.EqualTo(1f / 100)); Assert.That(boldGlyph.Scale, Is.EqualTo(1f / 10)); }
public static void Setup(ref UIPanel page) { page.padding = Helper.Padding(8, 12); var pane = ToolHelper.AddConfig( ref page, "Tree movement", "Sets the amount of tree branch movement.\nVanilla: maximum; Recommended: minimum", opts: new SliderOption <float>( minValue: 0.0f, maxValue: 1.0f, stepSize: 0.1f, defaultValue: App.Config.Graphics.treeMoveFactor, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.treeMoveFactor, value); } ) { hasField = false, }, labelPadding: 4, bullet: "InfoIconMaintenance" ); Helper.AddCheckBox( ref page, "Force stop distant trees (*)", "* restart required", initialValue: App.Config.Graphics.stopDistantTrees, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.stopDistantTrees = isChecked; } }, font: FontStore.Get(11) ); Helper.AddCheckBox( ref page, "Random tree rotation", "Close range only (technical limitation for LOD)", initialValue: App.Config.Graphics.randomTrees, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.randomTrees = isChecked; } }, font: FontStore.Get(11) ); }
public void TestNestedScaleAdjust() { using (var fontStore = new FontStore(new RawCachingGlyphStore(fontResourceStore, "Roboto-Regular") { CacheStorage = storage }, scaleAdjust: 100)) using (var nestedFontStore = new FontStore(new RawCachingGlyphStore(fontResourceStore, "Roboto-Bold") { CacheStorage = storage }, 10)) { fontStore.AddStore(nestedFontStore); var normalGlyph = (TexturedCharacterGlyph)fontStore.Get("Roboto-Regular", 'a'); Assert.That(normalGlyph, Is.Not.Null); var boldGlyph = (TexturedCharacterGlyph)fontStore.Get("Roboto-Bold", 'a'); Assert.That(boldGlyph, Is.Not.Null); Assert.That(normalGlyph.Scale, Is.EqualTo(1f / 100)); Assert.That(boldGlyph.Scale, Is.EqualTo(1f / 10)); } }
// fontStore passed in via ctor to be able to test scenarios where an animation // already has frames before load public TestAnimation(bool startFromCurrent, FontStore fontStore) : base(startFromCurrent) { Anchor = Anchor.Centre; Origin = Anchor.Centre; for (int i = 0; i < LOADABLE_FRAMES; i++) { AddFrame(new Texture(fontStore.Get(null, (char)('0' + i))?.Texture.TextureGL) { ScaleAdjust = 1 + i / 40f, }, 250); } }
private void updateTexture() { var loadableIcon = icon; if (loadableIcon.Equals(loadedIcon)) { return; } var glyph = store.Get(loadableIcon.FontName, Icon.Icon); if (glyph != null) { spriteMain.Texture = glyph.Texture; spriteShadow.Texture = glyph.Texture; if (Size == Vector2.Zero) { Size = new Vector2(glyph.Width, glyph.Height); } } loadedIcon = loadableIcon; }
public static SliderPane AddConfig <T>(ref UIPanel page, string label, string tooltip, SliderOption <T> opts, int?labelPadding = null, int?indentPadding = null, Color32?color = null, string bullet = null) { var font = FontStore.Get(11); if (opts.onSwitched != null) // has switch { var cb = Helper.AddCheckBox( ref page, label: label, tooltip: tooltip, initialValue: opts.isEnabled, (c, isEnabled) => { opts.onSwitched.Invoke(c, isEnabled); }, font, indentPadding: indentPadding ); if (labelPadding.HasValue) { cb.height += labelPadding.Value; } else { cb.height += 1; } } else { Helper.AddLabel(ref page, label, tooltip, font, Helper.Padding(0, 0, 2, 0), color: color, bullet: bullet); } var pane = Helper.AddSliderPane <T>(ref page, opts, font); return(pane); }
public static void Setup(ref UIPanel page) { page.padding = Helper.Padding(6, 2); page.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 8, 0)); page.autoFitChildrenVertically = true; { var pane = page.AddUIComponent <UIPanel>(); pane.width = pane.parent.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "Light & Shadow", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "LineDetailButton" ); ToolHelper.AddConfig( ref pane, "Light intensity", "default: ≈4.2", opts: new SliderOption <float>( minValue: 0.05f, maxValue: 8.0f, stepSize: 0.05f, defaultValue: App.Config.Graphics.lightIntensity.Value, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.lightIntensity, value); } ) { isEnabled = App.Config.Graphics.lightIntensity.Enabled, onSwitched = App.Config.Graphics.lightIntensity.LockedSwitch(App.Config.GraphicsLock), }, indentPadding: 12 ); ToolHelper.AddConfig( ref pane, "Shadow strength", "default: 0.8", opts: new SliderOption <float>( minValue: 0.1f, maxValue: 1.0f, stepSize: 0.05f, defaultValue: App.Config.Graphics.shadowStrength.Value, App.Config.Graphics.shadowStrength.LockedSlide(App.Config.GraphicsLock) ) { isEnabled = App.Config.Graphics.shadowStrength.Enabled, onSwitched = App.Config.Graphics.shadowStrength.LockedSwitch(App.Config.GraphicsLock), }, indentPadding: 12 ); ToolHelper.AddConfig( ref pane, "Self-shadow mitigation", "a.k.a. \"Shadow acne\" fix (default: minimal, recommended: 0.1-0.3)", opts: new SliderOption <float>( minValue: 0.01f, maxValue: 1.00f, stepSize: 0.01f, defaultValue: App.Config.Graphics.shadowBias.Value, App.Config.Graphics.shadowBias.LockedSlide(App.Config.GraphicsLock) ) { isEnabled = App.Config.Graphics.shadowBias.Enabled, onSwitched = App.Config.Graphics.shadowBias.LockedSwitch(App.Config.GraphicsLock), }, indentPadding: 12 ); } { var pane = page.AddUIComponent <UIPanel>(); pane.width = pane.parent.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "Postprocessing", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "LineDetailButton" ); Helper.AddCheckBox( ref pane, "SMAA", tooltip: null, initialValue: App.Config.Graphics.smaaEnabled, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.smaaEnabled = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); //var passes = ToolHelper.AddConfig( // ref pane, // "Passes", // $"default: {Mod.Config.GraphicsDefault.smaaPasses}", // opts: new SliderOption<float> { // hasField = true, // minValue = 0f, // maxValue = 8f, // stepSize = 1f, // eventValueChanged = (c, value) => { // ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.smaaPasses, (int)Math.Floor(value)); // }, // }, // color: Helper.RGB(160, 160, 160), // bullet: false //); //lock (App.Config.GraphicsLock) { // passes.slider.value = App.Config.Graphics.smaaPasses; //} Helper.AddCheckBox( ref pane, "Film grain", tooltip: null, initialValue: App.Config.Graphics.filmGrainEnabled, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.filmGrainEnabled = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); ToolHelper.AddConfig( ref pane, "Scale", $"default: {Mod.Config.GraphicsDefault.filmGrainScale}", opts: new SliderOption <float>( minValue: 0.05f, maxValue: 1f, stepSize: 0.05f, defaultValue: App.Config.Graphics.filmGrainScale, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.filmGrainScale, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Amount (scalar)", $"default: {Mod.Config.GraphicsDefault.filmGrainAmountScalar}", opts: new SliderOption <float>( minValue: 0.05f, maxValue: 1f, stepSize: 0.05f, defaultValue: App.Config.Graphics.filmGrainAmountScalar, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.filmGrainAmountScalar, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Amount (factor)", $"default: {Mod.Config.GraphicsDefault.filmGrainAmountFactor}", opts: new SliderOption <float>( minValue: 0.01f, maxValue: 1f, stepSize: 0.01f, defaultValue: App.Config.Graphics.filmGrainAmountFactor, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.filmGrainAmountFactor, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Middle range", $"default: {Mod.Config.GraphicsDefault.filmGrainMiddleRange}", opts: new SliderOption <float>( minValue: 0f, maxValue: 1f, stepSize: 0.02f, defaultValue: App.Config.Graphics.filmGrainMiddleRange, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.filmGrainMiddleRange, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); } }
/// <summary> /// Gets the texture for the given character. /// </summary> /// <param name="c">The character to get the texture for.</param> /// <returns>The texture for the given character.</returns> protected Texture GetTextureForCharacter(char c) { return(store?.Get(getTextureName(c)) ?? store?.Get(getTextureName(c, false))); }
public static void Setup(ref UIPanel page) { page.padding = Helper.Padding(6, 2); page.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 8, 0)); page.autoFitChildrenVertically = true; // info panel var citizenInfo = page.AddUIComponent <CitizenInfo>(); citizenInfo.padding = Helper.Padding(0, 10, 4, 10); var panel = page.AddUIComponent <UIPanel>(); panel.width = panel.parent.width - page.padding.horizontal - 10; panel.SetAutoLayout(LayoutDirection.Vertical); var pane = ToolHelper.AddConfig( ref panel, "Health literacy", "Let citizens stay at their home in hope of recovery, instead of calling 911.\n Requires decent healthcare system in city.", opts: new SliderOption <float>( minValue: 0.2f, maxValue: 0.95f, stepSize: 0.05f, defaultValue: App.Config.AI.regenChance.Value, (c, value) => { ToolHelper.LockedApply(App.Config.AILock, ref App.Config.AI.regenChance, value); } ) { hasField = false, isEnabled = App.Config.AI.regenChance.Enabled, onSwitched = App.Config.AI.regenChance.LockedSwitch(App.Config.AILock), }, labelPadding: 4, indentPadding: 12 ); var tipPanel = panel.AddUIComponent <UIPanel>(); tipPanel.SetAutoLayout(LayoutDirection.Horizontal); tipPanel.relativePosition = Vector2.zero; tipPanel.padding = Helper.Padding(0, 0, 0, 8); tipPanel.width = tipPanel.parent.width - (tipPanel.padding.horizontal + panel.padding.horizontal); Helper.AddIconLabel( ref tipPanel, "ambulance", "Call 911", wrapperWidth: tipPanel.width / 2, font: FontStore.Get(10), color: Helper.RGB(160, 160, 160) ); Helper.AddIconLabel( ref tipPanel, "housing", "Stay in bed", wrapperWidth: tipPanel.width / 2, font: FontStore.Get(10), color: Helper.RGB(160, 160, 160), isInverted: true ); }
public static void Setup(ref UIPanel page) { page.padding = Helper.Padding(6, 2); page.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 8, 0)); page.autoFitChildrenVertically = true; { var pane = page.AddUIComponent <UIPanel>(); pane.width = page.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 6); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddCheckBox( ref pane, "Bokeh Camera", tooltip: null, initialValue: App.Config.Graphics.dofEnabled, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.dofEnabled = isChecked; } }, font: FontStore.Get(11) ); { var cb = Helper.AddCheckBox( ref pane, "DOF Analyzer", tooltip: null, initialValue: false, // always false for debugging purpose (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.dofDebug = isChecked; } }, font: FontStore.Get(11) ); cb.label.textColor = Helper.RGB(250, 40, 40); cb.color = Helper.RGBA(255, 255, 255, 80); } } { var pane = page.AddUIComponent <UIPanel>(); pane.width = page.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "Focus & Perspective", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "LineDetailButton" ); ToolHelper.AddConfig( ref pane, "Field of view", tooltip: null, opts: new SliderOption <float>( minValue: 20f, maxValue: 178f, stepSize: 1f, defaultValue: App.Config.Graphics.fieldOfView.Value, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.fieldOfView, value); } ) { hasField = true, isEnabled = App.Config.Graphics.fieldOfView.Enabled, onSwitched = App.Config.Graphics.fieldOfView.LockedSwitch(App.Config.GraphicsLock), }, color: Helper.RGB(160, 160, 160), indentPadding: 10 ); ToolHelper.AddConfig( ref pane, "Aperture", $"default: {Mod.Config.GraphicsDefault.dofAperture}", opts: new SliderOption <float>( minValue: 0.08f, maxValue: 10f, stepSize: 0.01f, defaultValue: App.Config.Graphics.dofAperture, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofAperture, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Focal distance", $"default: {Mod.Config.GraphicsDefault.dofFocalDistance}", opts: new SliderOption <float>( minValue: 0.01f, maxValue: 20f, stepSize: 0.01f, defaultValue: App.Config.Graphics.dofFocalDistance, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofFocalDistance, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Focal range", $"default: {Mod.Config.GraphicsDefault.dofFocalRange}", opts: new SliderOption <float>( minValue: 0.5f, maxValue: 10f, stepSize: 0.02f, defaultValue: App.Config.Graphics.dofFocalRange, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofFocalRange, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Max blur size", $"default: {Mod.Config.GraphicsDefault.dofMaxBlurSize}", opts: new SliderOption <float>( minValue: 0f, maxValue: 6f, stepSize: 0.02f, defaultValue: App.Config.Graphics.dofMaxBlurSize, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofMaxBlurSize, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); } // DX11 --------------------------------------- { var pane = page.AddUIComponent <UIPanel>(); pane.width = page.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "Bokeh", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "PieChartWhiteFg" ); ToolHelper.AddConfig( ref pane, "Scale", $"default: {Mod.Config.GraphicsDefault.dofBokehScale}", opts: new SliderOption <float>( minValue: 0.1f, maxValue: 50f, stepSize: 0.02f, defaultValue: App.Config.Graphics.dofBokehScale, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofBokehScale, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Intensity", $"default: {Mod.Config.GraphicsDefault.dofBokehIntensity}", opts: new SliderOption <float>( minValue: 0.1f, maxValue: 50f, stepSize: 0.05f, defaultValue: App.Config.Graphics.dofBokehIntensity, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofBokehIntensity, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Min luminance thres.", $"default: {Mod.Config.GraphicsDefault.dofBokehMinLuminanceThreshold}", opts: new SliderOption <float>( minValue: 0.25f, maxValue: 6f, stepSize: 0.05f, defaultValue: App.Config.Graphics.dofBokehMinLuminanceThreshold, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofBokehMinLuminanceThreshold, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Spawn frequency thres.", $"default: {Mod.Config.GraphicsDefault.dofBokehSpawnHeuristic}", opts: new SliderOption <float>( minValue: 0.5f, maxValue: 6f, stepSize: 0.1f, defaultValue: App.Config.Graphics.dofBokehSpawnHeuristic, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofBokehSpawnHeuristic, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); } { var pane = page.AddUIComponent <UIPanel>(); pane.width = page.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "Foreground", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "ToolbarIconPropsPressed" ); Helper.AddCheckBox( ref pane, "Near blur", tooltip: null, initialValue: App.Config.Graphics.dofNearBlur, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.dofNearBlur = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); ToolHelper.AddConfig( ref pane, "Overlap amount", tooltip: null, opts: new SliderOption <float>( minValue: 0f, maxValue: 30f, stepSize: 0.02f, defaultValue: App.Config.Graphics.dofFGOverlap, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.dofFGOverlap, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); Helper.AddCheckBox( ref pane, "Tilt shift", tooltip: null, initialValue: App.Config.Graphics.tiltShiftEnabled, (c, isChecked) => { lock (App.Config.GraphicsLock) { App.Config.Graphics.tiltShiftEnabled = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); Helper.AddDropDown( ref pane, "Type", new[] { "Vertical", "Radial", }, initialValue: App.Config.Graphics.tiltShiftMode == TiltShiftEffect.TiltShiftMode.TiltShiftMode ? "Vertical" : "Radial", (c, i) => { var mode = TiltShiftEffect.TiltShiftMode.TiltShiftMode; switch ((c as UIDropDown).selectedValue) { case "Vertical": mode = TiltShiftEffect.TiltShiftMode.TiltShiftMode; break; case "Radial": mode = TiltShiftEffect.TiltShiftMode.IrisMode; break; } lock (App.Config.GraphicsLock) { App.Config.Graphics.tiltShiftMode = mode; } } ); ToolHelper.AddConfig( ref pane, "Max blur size", null, opts: new SliderOption <float>( minValue: 0.02f, maxValue: 12f, stepSize: 0.01f, defaultValue: App.Config.Graphics.tiltShiftMaxBlurSize, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.tiltShiftMaxBlurSize, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Area size", null, opts: new SliderOption <float>( minValue: 0.12f, maxValue: 30f, stepSize: 0.01f, defaultValue: App.Config.Graphics.tiltShiftAreaSize, (c, value) => { ToolHelper.LockedApply(App.Config.GraphicsLock, ref App.Config.Graphics.tiltShiftAreaSize, value); } ) { hasField = true, }, color: Helper.RGB(160, 160, 160) ); } }
public override void Start() { base.Start(); Title = Mod.ModInfo.ID; // Window.height = 420; Window.size = new Vector2(DefaultRect.width, DefaultRect.height); //Log.Debug($"window: {Window.size}"); //Log.Debug($"content: {Window.Content.size}"); { var page = TabPage("Graphics"); GraphicsPage.Setup(ref page); } { var page = TabPage("Camera"); CameraPage.Setup(ref page); } { var page = TabPage("Citizen"); CitizenPage.Setup(ref page); } { var page = TabPage("Nature"); NaturePage.Setup(ref page); } { var page = TabPage("Misc"); MiscPage.Setup(Window, ref page); lock (App.Config.UILock) { if (!App.Config.UI.pauseOutline) { var obj = UIView.Find <UISlicedSprite>("PauseOutline"); obj.color = Helper.RGBA(0, 0, 0, 0); } } } { var page = TabPage("About"); AboutPage.Setup(ref page); } //Log.Info($"ffff: {Config.SelectedTabIndex}"); SelectTab(Config.SelectedTabIndex); Window.Icon = Resources.shicho_logo_outline_white_24; { var disabledCover = Window.AddUIComponent <UIPanel>(); disabledCover.isVisible = false; disabledCover.pivot = UIPivotPoint.TopLeft; //disabledCover.anchor = UIAnchorStyle.Left | UIAnchorStyle.Top; disabledCover.name = "disabledCover"; disabledCover.relativePosition = new Vector2(0, Window.TitleBarHeight); //disabledCover.isVisible = !isToolActive; //disabledCover.FitTo(Window.Content); disabledCover.size = new Vector2( Window.Content.width, Window.Content.height ); disabledCover.backgroundSprite = "AssetEditorItemBackgroundPressed"; disabledCover.color = Helper.RGBA(235, 235, 255, 220); var sprite = disabledCover.AddUIComponent <UISprite>(); sprite.spriteName = "IconWarning"; sprite.pivot = UIPivotPoint.TopCenter; sprite.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical; sprite.disabledColor = Helper.RGB(0, 255, 128); sprite.size = new Vector2(64, 64); var label = Helper.AddLabel( ref disabledCover, "External tool is active", font: FontStore.Get(18), color: Helper.RGB(20, 20, 20) ); label.padding = Helper.Padding(80, 0, 0, 0); label.pivot = UIPivotPoint.TopCenter; label.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical; label.relativePosition = new Vector2(0, disabledCover.height / 2); label.textColor = Helper.RGBA(0, 0, 0, 255); //Log.Debug($"{disabledCover.position}, {disabledCover.size}"); //Window.eventPositionChanged += (c, pos) => { // disabledCover.absolutePosition = c.absolutePosition; // Log.Debug($"dc: {c.absolutePosition}, {Window.absolutePosition}"); //}; //Window.eventSizeChanged += (c, size) => { // disabledCover.size = size; // Log.Debug($"dasefawaw: {c.size}, {Window.size}"); //}; //Window.Content.eventIsEnabledChanged += (c, flag) => { // disabledCover.isVisible = isToolActive; //}; } ApplyVisibility(); //Window.Content.FitChildren(); //Log.Debug($"fff: {Window.titleBar_.size} {Window.Content.size}"); Window.Content.clipChildren = true; //Window.FitTo(Window.Content); Window.clipChildren = false; Window.Show(); }
public static void Setup(Window win, ref UIPanel page) { page.padding = Helper.Padding(6, 2); page.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 8, 0)); page.autoFitChildrenVertically = true; assetSelector_ = new AssetSelectorConfig(UIView.Find <UITabContainer>("TSContainer")); lock (App.Config.UILock) { assetSelector_.Enabled = App.Config.UI.assetSelectorEnabled; } thmBar_ = UIView.Find <UISlicedSprite>("ThumbnailBar"); tsBar_ = UIView.Find("TSBar"); infoPanel_ = UIView.Find("InfoPanel"); { var pane = page.AddUIComponent <UIPanel>(); pane.width = page.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "Crafting UI", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "IconPolicyBigBusiness" ); // debug only //UIView.Show(true); Helper.AddCheckBox( ref pane, "Master toolbar", tooltip: null, // always reset to visible at game init initialValue: true && infoPanel_.isVisible, (c, isEnabled) => { lock (App.Config.UILock) { App.Config.UI.masterToolbarVisibility = isEnabled; //var gamePanels = UIView.library.m_DynamicPanels // .Select((p) => p.instance.GetRootCustomControl()) // .Distinct() // .Where(p => // Game.Application.GamePanels.Any(name => name == p.name) // ) //; if (isEnabled) { thmBar_.Show(); tsBar_.Show(); infoPanel_.Show(); //UIView.Show(true); } else { thmBar_.Hide(); tsBar_.Hide(); infoPanel_.Hide(); //UIView.Show(false); } } }, font: FontStore.Get(11), indentPadding: 10 ); ToolHelper.AddConfig( ref pane, "Master toolbar opacity", $"default: {Mod.Config.UIDefault.masterOpacity}", opts: new SliderOption <float>( minValue: 0.05f, maxValue: 1f, stepSize: 0.05f, defaultValue: App.Config.UI.masterOpacity, (c, value) => { ToolHelper.LockedApply(App.Config.UILock, ref App.Config.UI.masterOpacity, value); SetMasterOpacity(value); } ) { hasField = false, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, $"{Mod.ModInfo.ID} opacity", $"default: {Mod.Config.UIDefault.supportToolOpacity}", opts: new SliderOption <float>( minValue: 0.05f, maxValue: 1f, stepSize: 0.05f, defaultValue: App.Config.UI.supportToolOpacity, (c, value) => { ToolHelper.LockedApply(App.Config.UILock, ref App.Config.UI.supportToolOpacity, value); win.opacity = value; } ) { hasField = false, }, color: Helper.RGB(160, 160, 160) ); Helper.AddCheckBox( ref pane, "Prop marker", tooltip: null, initialValue: App.Config.UI.propMarkersVisibility, (c, isChecked) => { lock (App.Config.UILock) { Cities::PropManager.instance.MarkersVisible = App.Config.UI.propMarkersVisibility = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); } { var pane = page.AddUIComponent <UIPanel>(); pane.width = page.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "Asset Selector EX", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "IconPolicyBigBusiness" ); Helper.AddCheckBox( ref pane, "Enable", tooltip: null, initialValue: assetSelector_.Enabled, (c, isChecked) => { assetSelector_.Enabled = isChecked; }, font: FontStore.Get(11), indentPadding: 10 ); //Helper.AddCheckBox( // ref pane, // "Sync `Find It!`", // tooltip: "Auto-adjust size & position for the mod `Find It!` (837734529) by SamsamTS", // initialValue: assetSelector_.SyncFindIt, // (c, isChecked) => { assetSelector_.SyncFindIt = isChecked; }, // font: FontStore.Get(11), // indentPadding: 10 //); Helper.AddDropDown( ref pane, "Scroll direction", new[] { "Horizontal", "Vertical", }, initialValue: App.Config.UI.assetSelectorScrollDirection == UIOrientation.Horizontal ? "Horizontal" : "Vertical", (c, i) => { switch ((c as UIDropDown).selectedValue) { case "Horizontal": assetSelector_.ScrollDirection = UIOrientation.Horizontal; break; case "Vertical": assetSelector_.ScrollDirection = UIOrientation.Vertical; break; } } ); ToolHelper.AddConfig( ref pane, "X offset", "Relative X offset from screen left", opts: new SliderOption <float>( minValue: 0.00f, maxValue: 1.00f, stepSize: 0.005f, defaultValue: assetSelector_.X, (c, value) => { assetSelector_.X = value; } ) { hasField = false, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Y offset", "Relative Y offset from screen top", opts: new SliderOption <float>( minValue: 0.00f, maxValue: 1.00f, stepSize: 0.005f, defaultValue: assetSelector_.Y, (c, value) => { assetSelector_.Y = value; } ) { hasField = false, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Width", "Relative % for screen width", opts: new SliderOption <float>( minValue: 0.20f, maxValue: 1.00f, stepSize: 0.005f, defaultValue: assetSelector_.Width, (c, value) => { assetSelector_.Width = value; } ) { hasField = false, }, color: Helper.RGB(160, 160, 160) ); ToolHelper.AddConfig( ref pane, "Height", "Relative % for screen height", opts: new SliderOption <float>( minValue: 0.10f, maxValue: 0.88f, stepSize: 0.005f, defaultValue: assetSelector_.Height, (c, value) => { assetSelector_.Height = value; } ) { hasField = false, }, color: Helper.RGB(160, 160, 160) ); } { var pane = page.AddUIComponent <UIPanel>(); pane.width = page.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "City view", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "ToolbarIconZoomOutGlobe" ); Helper.AddCheckBox( ref pane, "District name", tooltip: null, initialValue: App.Config.UI.districtNamesVisibility, (c, isChecked) => { lock (App.Config.UILock) { DistrictManager.instance.NamesVisible = App.Config.UI.districtNamesVisibility = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); Helper.AddCheckBox( ref pane, "Road name", tooltip: null, initialValue: App.Config.UI.roadNameVisibility, (c, isChecked) => { lock (App.Config.UILock) { NetManager.instance.RoadNamesVisible = App.Config.UI.roadNameVisibility = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); Helper.AddCheckBox( ref pane, "City border", tooltip: null, initialValue: App.Config.UI.areaBordersVisiblity, (c, isChecked) => { lock (App.Config.UILock) { GameAreaManager.instance.BordersVisible = App.Config.UI.areaBordersVisiblity = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); } { var pane = page.AddUIComponent <UIPanel>(); pane.width = page.width - page.padding.horizontal; pane.padding = Helper.Padding(4, 12, 4, 0); pane.SetAutoLayout(LayoutDirection.Vertical, Helper.Padding(0, 0, 2, 0)); pane.autoFitChildrenVertically = true; Helper.AddLabel( ref pane, "Game system interface", font: FontStore.Get(12), color: Helper.RGB(220, 230, 250), bullet: "InfoIconMaintenance" ); Helper.AddCheckBox( ref pane, "Notifications", tooltip: null, initialValue: App.Config.UI.notificationsVisibility, (c, isChecked) => { lock (App.Config.UILock) { NotificationManager.instance.NotificationsVisible = App.Config.UI.notificationsVisibility = isChecked; // speed up easing animation if (!NotificationManager.instance.NotificationsVisible) { var m_notificationAlpha = typeof(NotificationManager).GetField("m_notificationAlpha", BindingFlags.NonPublic | BindingFlags.Instance); m_notificationAlpha.SetValue(NotificationManager.instance, NotificationManager.instance.NotificationsVisible ? 1f : 0f); } } }, font: FontStore.Get(11), indentPadding: 10 ); Helper.AddCheckBox( ref pane, "Tutorial", tooltip: null, initialValue: !App.Config.UI.tutorialDisabled, (c, isChecked) => { lock (App.Config.UILock) { GuideManager.instance.TutorialDisabled = App.Config.UI.tutorialDisabled = !isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); Helper.AddCheckBox( ref pane, "Disaster", tooltip: null, initialValue: App.Config.UI.disasterVisibility, (c, isChecked) => { lock (App.Config.UILock) { DisasterManager.instance.MarkersVisible = App.Config.UI.disasterVisibility = isChecked; } }, font: FontStore.Get(11), indentPadding: 10 ); } }