fixed some UI issues

This commit is contained in:
Ell 2023-03-04 10:56:43 +01:00
parent 84e709a3f3
commit 00ca1487bc

View file

@ -19,7 +19,7 @@ using TouchyTickets.Attractions;
using TouchyTickets.Upgrades;
using Vector2 = Microsoft.Xna.Framework.Vector2;
namespace TouchyTickets;
namespace TouchyTickets;
public class Ui {
@ -149,7 +149,6 @@ public class Ui {
};
buyUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Attractions"), true) {TextScale = 0.15F});
var buyList = buyUi.AddChild(new Panel(Anchor.AutoLeft, Vector2.One, Vector2.Zero, false, true, false) {
ChildPadding = new Padding(5, 15, 5, 5),
PreventParentSpill = true
});
foreach (var attraction in AttractionType.Attractions) {
@ -221,7 +220,6 @@ public class Ui {
};
modifierUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Modifiers"), true) {TextScale = 0.15F});
var modifierList = modifierUi.AddChild(new Panel(Anchor.AutoLeft, Vector2.One, Vector2.Zero, false, true, false) {
ChildPadding = new Padding(5, 15, 5, 5),
PreventParentSpill = true
});
foreach (var modifier in AttractionModifier.Modifiers.Values) {
@ -354,7 +352,6 @@ public class Ui {
PositionOffset = new Vector2(0, 2)
});
var upgradeList = upgradeUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1), Vector2.Zero, false, true, false) {
ChildPadding = new Padding(5, 15, 5, 5),
PreventParentSpill = true
});
Ui.PopulateUpgradeList(upgradeList);
@ -367,36 +364,35 @@ public class Ui {
};
optionsUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Options"), true) {TextScale = 0.15F});
var optionList = optionsUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1), Vector2.Zero, false, true, false) {
ChildPadding = new Padding(5, 15, 5, 5),
PreventParentSpill = true
});
optionList.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("GameplayOptions"), true) {
TextScale = 0.12F
});
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 20), Localization.Get("AutoBuyEnabled"), Options.Instance.AutoBuyEnabled) {
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 24), Localization.Get("AutoBuyEnabled"), Options.Instance.AutoBuyEnabled) {
OnCheckStateChange = (_, value) => {
Options.Instance.AutoBuyEnabled = value;
Options.Save();
},
PositionOffset = new Vector2(0, 1)
PositionOffset = new Vector2(0, 2)
});
optionList.AddChild(new Paragraph(Anchor.AutoLeft, 1, Localization.Get("MinTicketsForAutoBuy") + ":"));
var num = optionList.AddChild(ElementHelper.NumberField(Anchor.AutoLeft, new Vector2(1, 20), Options.Instance.MinTicketsForAutoBuy, 1000, null, (_, value) => {
var num = optionList.AddChild(ElementHelper.NumberField(Anchor.AutoLeft, new Vector2(1, 24), Options.Instance.MinTicketsForAutoBuy, 1000, null, (_, value) => {
if (int.TryParse(value, out var ret)) {
Options.Instance.MinTicketsForAutoBuy = ret;
Options.Save();
}
}));
num.PositionOffset = new Vector2(0, 1);
num.PositionOffset = new Vector2(0, 2);
optionList.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("OtherOptions"), true) {
PositionOffset = new Vector2(0, 10),
TextScale = 0.12F
});
optionList.AddChild(new Paragraph(Anchor.AutoLeft, 1, _ => Localization.Get("RainingTicketLimit") + ": " + Options.Instance.RainingTicketLimit));
optionList.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 20), 10, 500) {
PositionOffset = new Vector2(0, 1),
optionList.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 24), 10, 500) {
PositionOffset = new Vector2(0, 2),
CurrentValue = Options.Instance.RainingTicketLimit,
OnValueChanged = (_, v) => {
Options.Instance.RainingTicketLimit = (int) v;
@ -404,23 +400,23 @@ public class Ui {
}
});
optionList.AddChild(new Paragraph(Anchor.AutoLeft, 1, _ => Localization.Get("SoundVolume") + ": " + (int) (Options.Instance.SoundVolume * 100)));
optionList.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 20), 10, 100) {
PositionOffset = new Vector2(0, 1),
optionList.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 24), 10, 100) {
PositionOffset = new Vector2(0, 2),
CurrentValue = Options.Instance.SoundVolume * 100,
OnValueChanged = (_, v) => {
Options.Instance.SoundVolume = v / 100;
Options.Save();
}
});
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 20), Localization.Get("WhileYouWereAwayMessage"), Options.Instance.WhileYouWereAwayMessage) {
PositionOffset = new Vector2(0, 1),
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 24), Localization.Get("WhileYouWereAwayMessage"), Options.Instance.WhileYouWereAwayMessage) {
PositionOffset = new Vector2(0, 2),
OnCheckStateChange = (_, value) => {
Options.Instance.WhileYouWereAwayMessage = value;
Options.Save();
}
});
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 20), Localization.Get("KeepScreenOn"), Options.Instance.KeepScreenOn) {
PositionOffset = new Vector2(0, 1),
optionList.AddChild(new Checkbox(Anchor.AutoLeft, new Vector2(1, 24), Localization.Get("KeepScreenOn"), Options.Instance.KeepScreenOn) {
PositionOffset = new Vector2(0, 2),
OnCheckStateChange = (_, value) => {
Options.Instance.KeepScreenOn = value;
Options.Save();
@ -522,6 +518,7 @@ public class Ui {
uiSystem.Style.CheckboxCheckmark = Assets.UiTexture[4, 1];
uiSystem.Style.TextScale = 0.1F;
uiSystem.Style.ActionSound = new SoundEffectInfo(Assets.ClickSound, 0.5F);
uiSystem.Style.PanelScrollerSize = new Vector2(10, 5);
uiSystem.TextFormatter.AddImage("ticket", Assets.UiTexture[2, 0]);
uiSystem.TextFormatter.AddImage("star", Assets.UiTexture[3, 0]);
}