public override void Init() { DrawTextArgs caretArgs = new DrawTextArgs("_", boldFont, false); chatCaretTexture = game.Drawer2D.MakeTextTexture(ref caretArgs, 0, 0); SetText(chatInputText.GetString()); }
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; } }
void RecreateBlockInfoTexture() { if (selIndex == lastCreatedIndex) { return; } lastCreatedIndex = selIndex; graphicsApi.DeleteTexture(ref blockInfoTexture); if (selIndex == -1) { return; } Block block = blocksTable[selIndex]; UpdateBlockInfoString(block); string value = buffer.GetString(); DrawTextArgs args = new DrawTextArgs(value, font, true); Size size = game.Drawer2D.MeasureChatSize(ref args); int x = startX + (blockSize * blocksPerRow) / 2 - size.Width / 2; int y = startY - size.Height - 5; args.SkipPartsCheck = true; blockInfoTexture = game.Drawer2D.MakeChatTextTexture(ref args, x, y); }
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; } }