void TextChanged(InputWidget widget) { bool changed = false; int index = Array.IndexOf <Widget>(widgets, widget); if (index < 3) { changed |= Parse(0, ref LauncherSkin.BackgroundCol); } else if (index < 6) { changed |= Parse(3, ref LauncherSkin.ButtonBorderCol); } else if (index < 9) { changed |= Parse(6, ref LauncherSkin.ButtonHighlightCol); } else if (index < 12) { changed |= Parse(9, ref LauncherSkin.ButtonForeCol); } else if (index < 15) { changed |= Parse(12, ref LauncherSkin.ButtonForeActiveCol); } if (!changed) { return; } game.RedrawBackground(); Resize(); }
void ConstructWidgets() { input = new ChatInputWidget(game, chatFont) .SetLocation(Anchor.Min, Anchor.Max, 5, 5); altText = new SpecialInputWidget(game, chatFont, input); altText.Init(); UpdateAltTextY(); status = new TextGroupWidget(game, 5, chatFont, chatUrlFont) .SetLocation(Anchor.Max, Anchor.Min, 0, 0); status.Init(); status.SetUsePlaceHolder(0, false); status.SetUsePlaceHolder(1, false); bottomRight = new TextGroupWidget(game, 3, chatFont, chatUrlFont) .SetLocation(Anchor.Max, Anchor.Max, 0, hud.BottomOffset + 15); bottomRight.Init(); normalChat = new TextGroupWidget(game, chatLines, chatFont, chatUrlFont) .SetLocation(Anchor.Min, Anchor.Max, 10, hud.BottomOffset + 15); normalChat.Init(); clientStatus = new TextGroupWidget(game, game.Chat.ClientStatus.Length, chatFont, chatUrlFont) .SetLocation(Anchor.Min, Anchor.Max, 10, hud.BottomOffset + 15); clientStatus.Init(); announcement = TextWidget.Create(game, null, announcementFont) .SetLocation(Anchor.Centre, Anchor.Centre, 0, -game.Height / 4); }
InputWidget MakeInput(int y, bool seed, string value) { MenuInputValidator validator = seed ? new SeedValidator() : new IntegerValidator(1, 8192); InputWidget input = MenuInputWidget.Create(game, 200, 30, value, textFont, validator) .SetLocation(Anchor.Centre, Anchor.Centre, 0, y); input.MenuClick = InputClick; return(input); }
protected void OnWidgetClick(Game game, Widget widget, MouseButton btn, int x, int y) { ButtonWidget button = widget as ButtonWidget; if (btn != MouseButton.Left) { return; } if (widget == widgets[widgets.Length - 1]) { ChangeSetting(); return; } if (button == null) { return; } DisposeExtendedHelp(); int index = Array.IndexOf <Widget>(widgets, button); MenuInputValidator validator = validators[index]; if (validator is BooleanValidator) { string value = button.GetValue(game); button.SetValue(game, value == "yes" ? "no" : "yes"); UpdateDescription(button); return; } else if (validator is EnumValidator) { Type type = ((EnumValidator)validator).EnumType; HandleEnumOption(button, type); return; } targetWidget = selectedWidget; if (input != null) { input.Dispose(); } input = MenuInputWidget.Create(game, 400, 30, button.GetValue(game), regularFont, validator) .SetLocation(Anchor.Centre, Anchor.Centre, 0, 110); input.ShowCaret = true; input.OnClick = InputClick; widgets[widgets.Length - 2] = input; widgets[widgets.Length - 1] = ButtonWidget.Create(game, 40, "OK", titleFont, OnWidgetClick) .SetLocation(Anchor.Centre, Anchor.Centre, 240, 110); InputOpened(); UpdateDescription(targetWidget); }
protected override void WidgetUnclicked(Widget widget) { InputWidget input = widget as InputWidget; if (input == null) { return; } input.Active = false; RedrawWidget(input); curInput = null; game.Dirty = true; }
void DisposeInput() { if (input == null) { return; } input = null; for (int i = widgets.Length - 3; i < widgets.Length; i++) { widgets[i].Dispose(); widgets[i] = null; } }
void SetupWidgetHandlers() { InputWidget hashWidget = (InputWidget)widgets[view.hashIndex]; hashWidget.Chars.ClipboardFilter = HashFilter; widgets[view.backIndex].OnClick = SwitchToMain; widgets[view.connectIndex].OnClick = ConnectToServer; widgets[view.refreshIndex].OnClick = RefreshList; TableWidget widget = (TableWidget)widgets[view.tableIndex]; widget.NeedRedraw = MarkPendingRedraw; widget.SelectedChanged = SelectedChanged; SetupInputHandlers(); }
void SetupWidgetHandlers() { InputWidget hashWidget = (InputWidget)widgets[view.hashIndex]; hashWidget.Chars.ClipboardFilter = HashFilter; widgets[view.backIndex].OnClick = (x, y) => game.SetScreen(new MainScreen(game)); widgets[view.connectIndex].OnClick = ConnectToServer; TableWidget widget = (TableWidget)widgets[view.tableIndex]; widget.NeedRedraw = MarkPendingRedraw; widget.SelectedChanged = SelectedChanged; SetupInputHandlers(); }
protected virtual void InputClosed() { if (input != null) { input.Dispose(); } widgets[widgets.Length - 2] = null; input = null; int okIndex = widgets.Length - 1; if (widgets[okIndex] != null) { widgets[okIndex].Dispose(); } widgets[okIndex] = null; }
void DisposeWidgets() { if (input != null) { input.Dispose(); } widgets[widgets.Length - 2] = null; input = null; int okayIndex = widgets.Length - 1; if (widgets[okayIndex] != null) { widgets[okayIndex].Dispose(); } widgets[okayIndex] = null; }
protected override void ContextRecreated() { input = MenuInputWidget.Create(game, 500, 30, "", regularFont, new PathValidator()) .SetLocation(Anchor.Centre, Anchor.Centre, 0, -30); input.ShowCaret = true; widgets = new Widget[] { ButtonWidget.Create(game, 300, "Save", titleFont, SaveClassic) .SetLocation(Anchor.Centre, Anchor.Centre, 0, 20), ButtonWidget.Create(game, 200, "Save schematic", titleFont, SaveSchematic) .SetLocation(Anchor.Centre, Anchor.Centre, -150, 120), TextWidget.Create(game, "&eCan be imported into MCEdit", regularFont) .SetLocation(Anchor.Centre, Anchor.Centre, 110, 120), null, MakeBack(false, titleFont, SwitchPause), }; }
public override void Init() { base.Init(); view.Init(); widgets[view.defIndex].OnClick = ResetColours; widgets[view.defIndex + 1].OnClick = SwitchToSettings; SetupInputHandlers(); for (int i = 0; i < widgets.Length; i++) { InputWidget input = widgets[i] as InputWidget; if (input == null) { continue; } input.Chars.TextChanged = TextChanged; } Resize(); }
public override void Init() { base.Init(); view.Init(); widgets[view.defIndex].OnClick = (x, y) => ResetColours(); widgets[view.defIndex + 1].OnClick = (x, y) => game.SetScreen(new SettingsScreen(game)); SetupInputHandlers(); for (int i = 0; i < widgets.Length; i++) { InputWidget input = widgets[i] as InputWidget; if (input == null) { continue; } input.Chars.TextChanged = TextChanged; } Resize(); }
protected void OnInputClick(Game game, Widget widget) { ButtonWidget button = (ButtonWidget)widget; activeI = IndexWidget(button); DisposeExtendedHelp(); DisposeInput(); MenuInputValidator validator = validators[activeI]; input = MenuInputWidget.Create(game, 400, 30, button.GetValue(game), textFont, validator) .SetLocation(Anchor.Centre, Anchor.Centre, 0, 110); input.ShowCaret = true; widgets[widgets.Length - 1] = input; widgets[widgets.Length - 2] = ButtonWidget.Create(game, 40, "OK", titleFont, OKButtonClick) .SetLocation(Anchor.Centre, Anchor.Centre, 240, 110); widgets[widgets.Length - 3] = ButtonWidget.Create(game, 200, "Default value", titleFont, DefaultButtonClick) .SetLocation(Anchor.Centre, Anchor.Centre, 0, 150); }
protected virtual void InputClick(int mouseX, int mouseY) { InputWidget input = (InputWidget)selectedWidget; using (drawer) { drawer.SetBitmap(game.Framebuffer); if (curInput != null) { curInput.Active = false; curInput.Redraw(drawer); } input.Active = true; elapsed = 0; lastCaretShow = false; input.SetCaretToCursor(mouseX, mouseY, drawer); input.Redraw(drawer); } curInput = input; game.Dirty = true; }
InputWidget MakeInput(int y, bool seed, string value) { MenuInputValidator validator; if (seed) { validator = new SeedValidator(); } else { validator = new IntegerValidator(1, 8192); } InputWidget input = MenuInputWidget.Create(game, 200, 30, value, regularFont, validator) .SetLocation(Anchor.Centre, Anchor.Centre, 0, y); input.Active = false; input.OnClick = InputClick; return(input); }
protected void OnButtonClick(Game game, Widget widget) { ButtonWidget button = widget as ButtonWidget; if (button == null) { return; } DisposeExtendedHelp(); int index = IndexOfWidget(button); MenuInputValidator validator = validators[index]; if (validator is BooleanValidator) { string value = button.GetValue(game); SetButtonValue(button, value == "ON" ? "OFF" : "ON"); UpdateDescription(button); return; } else if (validator is EnumValidator) { Type type = ((EnumValidator)validator).EnumType; HandleEnumOption(button, type); return; } activeButton = button; InputClosed(); input = MenuInputWidget.Create(game, 400, 30, button.GetValue(game), textFont, validator) .SetLocation(Anchor.Centre, Anchor.Centre, 0, 110); input.ShowCaret = true; widgets[widgets.Length - 2] = input; widgets[widgets.Length - 1] = ButtonWidget.Create(game, 40, "OK", titleFont, OnOKButtonClick) .SetLocation(Anchor.Centre, Anchor.Centre, 240, 110); InputOpened(); UpdateDescription(activeButton); }
protected override void ContextLost() { base.ContextLost(); input = null; DisposeExtendedHelp(); }