void OnBindingClick(Game game, Widget widget, MouseButton mouseBtn) { if (mouseBtn == MouseButton.Right && (curWidget == null || curWidget == widget)) { curWidget = (ButtonWidget)widget; int index = Array.IndexOf <Widget>(widgets, curWidget); KeyBinding mapping = (KeyBinding)(index + (int)originKey); HandlesKeyDown(game.InputHandler.Keys.GetDefault(mapping)); } if (mouseBtn != MouseButton.Left) { return; } if (curWidget == widget) { curWidget = null; statusWidget.SetText(""); } else { curWidget = (ButtonWidget)widget; int index = Array.IndexOf <Widget>(widgets, curWidget); string text = "&ePress new key binding for " + descriptions[index] + ":"; statusWidget.SetText(text); } }
void OnBindingClick(Game game, Widget realWidget) { this.curWidget = (ButtonWidget)realWidget; int index = Array.IndexOf <ButtonWidget>(buttons, curWidget); string text = "&ePress new key binding for " + descriptions[index] + ":"; statusWidget.SetText(text); }
void UpdateFPS(double delta) { fpsCount++; maxDelta = Math.Max(maxDelta, delta); accumulator += delta; if (accumulator >= 1) { int index = 0; totalSeconds++; if (game.PureClassicMode) { text.Clear() .AppendNum(ref index, (int)(fpsCount / accumulator)).Append(ref index, " fps, ") .AppendNum(ref index, game.ChunkUpdates).Append(ref index, " chunk updates"); } else { text.Clear() .Append(ref index, "FPS: ").AppendNum(ref index, (int)(fpsCount / accumulator)) .Append(ref index, " (min ").AppendNum(ref index, (int)(1f / maxDelta)) .Append(ref index, "), chunks/s: ").AppendNum(ref index, game.ChunkUpdates) .Append(ref index, ", vertices: ").AppendNum(ref index, game.Vertices); } int minutes = totalSeconds / 60; if (minutes != oldMinutes && game.ShowClock) { oldMinutes = minutes; TimeSpan span = TimeSpan.FromMinutes(minutes); string format = null; if (span.TotalDays > 1) { format = "&eBeen playing for {2} day" + Q(span.Days) + ", {1} hour" + Q(span.Hours) + ", {0} min" + Q(span.Minutes); } else if (span.TotalHours > 1) { format = "&eBeen playing for {1} hour" + Q(span.Hours) + ", {0} mins" + Q(span.Minutes); } else { format = "&eBeen playing for {0} min" + Q(span.Minutes); } string spanText = String.Format(format, span.Minutes, span.Hours, span.Days); game.Chat.Add(spanText, MessageType.ClientClock); } string textString = text.GetString(); fpsTextWidget.SetText(textString); maxDelta = 0; accumulator = 0; fpsCount = 0; game.ChunkUpdates = 0; } }
public static TextWidget Create( Game game, int x, int y, string text, Docking horizontal, Docking vertical, Font font ) { TextWidget widget = new TextWidget( game, font ); widget.Init(); widget.HorizontalDocking = horizontal; widget.VerticalDocking = vertical; widget.XOffset = x; widget.YOffset = y; widget.SetText( text ); return widget; }
public override void Init() { fpsTextWidget = new TextWidget( game, font ); fpsTextWidget.Init(); fpsTextWidget.SetText( "FPS: no data yet" ); MakePosTextWidget(); hackStatesWidget = new TextWidget( game, posFont ); hackStatesWidget.YOffset = fpsTextWidget.Height + posHeight; hackStatesWidget.Init(); UpdateHackState( true ); }
public static TextWidget Create(Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font) { TextWidget widget = new TextWidget(game, font); widget.Init(); widget.HorizontalAnchor = horizontal; widget.VerticalAnchor = vertical; widget.XOffset = x; widget.YOffset = y; widget.SetText(text); return(widget); }
public override void Init() { font = new Font( "Arial", 13 ); posFont = new Font( "Arial", 12, FontStyle.Italic ); game.Events.ChatFontChanged += ChatFontChanged; fpsTextWidget = new ChatTextWidget( game, font ); fpsTextWidget.XOffset = 2; fpsTextWidget.YOffset = 2; fpsTextWidget.Init(); string fpsText = text.Length > 0 ? text.GetString() : "FPS: no data yet"; fpsTextWidget.SetText( fpsText ); MakePosTextWidget(); hackStatesWidget = new ChatTextWidget( game, posFont ); hackStatesWidget.XOffset = 2; hackStatesWidget.YOffset = fpsTextWidget.Height + posHeight + 2; hackStatesWidget.Init(); UpdateHackState( true ); }
public override void Init() { font = new Font(game.FontName, 13); posFont = new Font(game.FontName, 12, FontStyle.Italic); game.Events.ChatFontChanged += ChatFontChanged; fpsTextWidget = new ChatTextWidget(game, font); fpsTextWidget.XOffset = 2; fpsTextWidget.YOffset = 2; fpsTextWidget.Init(); string fpsText = text.Length > 0 ? text.GetString() : "FPS: no data yet"; fpsTextWidget.SetText(fpsText); MakePosTextWidget(); hackStatesWidget = new ChatTextWidget(game, posFont); hackStatesWidget.XOffset = 2; hackStatesWidget.YOffset = fpsTextWidget.Height + posHeight + 2; hackStatesWidget.Init(); UpdateHackState(true); }
void UpdateFPS(double delta) { fpsCount++; maxDelta = Math.Max(maxDelta, delta); accumulator += delta; if (accumulator >= 1) { int index = 0; text.Clear() .Append(ref index, "FPS: ").AppendNum(ref index, (int)(fpsCount / accumulator)) .Append(ref index, " (min ").AppendNum(ref index, (int)(1f / maxDelta)) .Append(ref index, "), chunks/s: ").AppendNum(ref index, game.ChunkUpdates) .Append(ref index, ", vertices: ").AppendNum(ref index, game.Vertices); string textString = text.GetString(); fpsTextWidget.SetText(textString); maxDelta = 0; accumulator = 0; fpsCount = 0; game.ChunkUpdates = 0; } }
public override void Init() { fpsTextWidget = new TextWidget( game, font ); fpsTextWidget.Init(); fpsTextWidget.SetText( "FPS: no data yet" ); }