public override void Render() { if (!isVisible) { return; } bool highlight = currentState == State.Hovered || currentState == State.Pressed; RB.DrawRectFill(new Rect2i(pos, size), currentState == State.Pressed ? Color.yellow : castable ? Color.white : Color.cyan); RB.Print(pos + new Vector2i(2, 2), Color.black, spell.GetName()); ElementDisplay[] displays = spell.GetElementDisplays(battle.BuildContext(screen.GetCurrentTargetPawnId())); int px = pos.x + 2; int py = pos.y + size.height - 18; for (int i = 0; i < displays.Length; i++) { displays[i].Render(px + i * 18, py); } if (highlight) { RB.DrawRect(new Rect2i(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2), Color.yellow); } else { RB.DrawRect(new Rect2i(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2), Color.black); } }
/// <summary> /// Render /// </summary> public void Render() { Vector2i labelSize = RB.PrintMeasure(mLabel); int yPos; if (mLabelBottomAligned) { yPos = mRect.y + mRect.height - labelSize.y - 4; } else { yPos = mRect.y + (mRect.height / 2) - (labelSize.y / 2); } if (mPressed) { RB.DrawRectFill(new Rect2i(mRect.x + 2, mRect.y + 2, mRect.width - 2, mRect.height - 2), Color.gray); RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2) + 1, yPos + 1), Color.black, mLabel); } else { RB.DrawRectFill(mRect, Color.gray); RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2), yPos), Color.black, mLabel); RB.DrawRect(mRect, Color.white); } mHitRect = new Rect2i(-RB.CameraGet().x + mHotZone.x, -RB.CameraGet().y + mHotZone.y, mHotZone.width, mHotZone.height); }
public override void Render() { if (!isVisible) { return; } int off = 0; if (currentState != State.Pressed) { RB.DrawRectFill(new Rect2i(pos.x + 1, pos.y + 1, size.x - 1, size.y - 1), Color.black); } else { off = 1; } Color backgroundHighlight = Color.white; Color backgroundDefault = Color.gray; Color foregroundHighlight = Color.yellow; Color foregroundDefault = Color.white; bool highlight = currentState == State.Hovered || currentState == State.Pressed; RB.DrawRectFill(new Rect2i(pos.x + off, pos.y + off, size.x - 1, size.y - 1), highlight ? backgroundHighlight : backgroundDefault); RB.DrawRect(new Rect2i(pos.x + 1 + off, pos.y + 1 + off, size.width - 3, size.height - 3), highlight ? foregroundHighlight : foregroundDefault); RB.Print(new Vector2i(pos.x + 4 + off, pos.y + 4 + off), Color.black, RB.NO_INLINE_COLOR, text); if (currentState != State.Disabled) { RB.Print(new Vector2i(pos.x + 3 + off, pos.y + 3 + off), highlight ? foregroundHighlight : foregroundDefault, text); } }
public override void Render() { Rect2i rect = new Rect2i(pos, size); RB.DrawRectFill(rect, boxBackgroundColor); RB.DrawRect(rect, boxOutlineColor); rect.Expand(-4); if ((effect & Shadow) == Shadow) { RB.Print(rect.Offset(new Vector2i(1, 1)), Color.black, RB.NO_INLINE_COLOR | flags, text); } else if ((effect & Outline) == Outline) { for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { RB.Print(rect.Offset(new Vector2i(dx, dy)), Color.black, RB.NO_INLINE_COLOR | flags, text); } } } RB.Print(rect, color, flags, text); foreach (TextButton button in buttons) { button.Render(); } }
private void RenderCard(int xPos, int w, LobbyPlayer player, bool self) { int topLeftX = xPos - w / 2 + 2; int topLeftY = 32; RB.DrawRectFill(new Rect2i(topLeftX - 1, topLeftY - 1, new Vector2i(w, size.height - 90)), Color.black); RB.DrawRectFill(new Rect2i(topLeftX - 2, topLeftY - 2, new Vector2i(w, size.height - 90)), Color.green); RB.DrawRect(new Rect2i(topLeftX, topLeftY, new Vector2i(w - 4, size.height - 94)), Color.gray); if (self) { if (!nameInput.isVisible) { nameInput.SetText(player.charName); } readyButton.isVisible = true; nameInput.isVisible = true; prevClassButton.isVisible = true; nextClassButton.isVisible = true; } else { RB.Print(new Rect2i(topLeftX + 1, topLeftY + 49, w - 4, 12), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_TOP, player.charName); RB.Print(new Rect2i(topLeftX, topLeftY + 48, w - 4, 12), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_TOP, player.charName); RB.Print(new Vector2i(xPos - 26, topLeftY + size.height - 115), Color.black, RB.NO_INLINE_COLOR, "Ready?"); RB.Print(new Vector2i(xPos - 27, topLeftY + size.height - 116), Color.white, "Ready?"); } RB.Print(new Rect2i(topLeftX + 11, topLeftY + 71, w - 24, 20), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, DB.Classes[player.charClass].GetName()); RB.Print(new Rect2i(topLeftX + 10, topLeftY + 70, w - 24, 20), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, DB.Classes[player.charClass].GetName()); RB.DrawEllipseFill(new Vector2i(xPos + 16, topLeftY - 2 + size.height - 110), new Vector2i(5, 5), Color.black); RB.DrawEllipseFill(new Vector2i(xPos + 15, topLeftY - 3 + size.height - 110), new Vector2i(5, 5), player.ready ? Color.green : Color.red); RB.DrawEllipse(new Vector2i(xPos + 15, topLeftY - 3 + size.height - 110), new Vector2i(5, 5), Color.white); }
private void DrawGamepadDPad(int x, int y, int pressedMask, int color, int colorOutline) { var demo = (DemoReel)RB.Game; int pressedColor = 5; int size = 10; RB.DrawRect(new Rect2i(x + size, y, size, size * 3), DemoUtil.IndexToRGB(colorOutline)); RB.DrawRect(new Rect2i(x, y + size, size * 3, size), DemoUtil.IndexToRGB(colorOutline)); RB.DrawRectFill(new Rect2i(x + size + 1, y + 1, size - 2, (size * 3) - 2), DemoUtil.IndexToRGB(color)); RB.DrawRectFill(new Rect2i(x + 1, y + size + 1, (size * 3) - 2, size - 2), DemoUtil.IndexToRGB(color)); // Up mFormatStr.Set((char)127); RB.DrawRectFill(new Rect2i(x + size + 1, y + 1, size - 2, size), (pressedMask & RB.BTN_UP) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color)); RB.Print(new Vector2i(x + size + (size / 2) - 3, y + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr); // Down mFormatStr.Set((char)128); RB.DrawRectFill(new Rect2i(x + size + 1, y + (size * 2) - 1, size - 2, size), (pressedMask & RB.BTN_DOWN) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color)); RB.Print(new Vector2i(x + size + (size / 2) - 3, y + 2 + (size * 2)), DemoUtil.IndexToRGB(colorOutline), mFormatStr); // Left mFormatStr.Set((char)129); RB.DrawRectFill(new Rect2i(x + 1, y + size + 1, size, size - 2), (pressedMask & RB.BTN_LEFT) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color)); RB.Print(new Vector2i(x + 2, y + size + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr); // Right mFormatStr.Set((char)130); RB.DrawRectFill(new Rect2i(x + (size * 2) - 1, y + size + 1, size, size - 2), (pressedMask & RB.BTN_RIGHT) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color)); RB.Print(new Vector2i(x + (size * 2) + 3, y + size + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr); }
public override void Render() { if (!isVisible) { return; } bool highlight = currentState == State.Hovered || currentState == State.Pressed; bool disabled = currentState == State.Disabled || blocked; RB.DrawRectFill(new Rect2i(pos, size), currentState == State.Pressed ? Color.yellow : disabled ? Color.gray : Color.white); RB.Print(pos + new Vector2i(2, 2), Color.black, spell.GetName()); ElementDisplay[] displays = spell.GetElementDisplays(RollContext.Null); int px = pos.x + 2; int py = pos.y + size.height - 18; for (int i = 0; i < displays.Length; i++) { displays[i].Render(px + i * 18, py); } if (highlight) { RB.DrawRect(new Rect2i(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2), Color.yellow); } else { RB.DrawRect(new Rect2i(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2), Color.black); } }
public virtual void Render() { var display = RB.DisplaySize; var menuRect = new Rect2i(display.width / 2 - MENU_WIDTH / 2, display.height / 2, MENU_WIDTH, 24); var summarySize = RB.PrintMeasure(menuRect, RB.ALIGN_H_CENTER | RB.TEXT_OVERFLOW_WRAP, Summary); menuRect.height += summarySize.height; // header var headerSize = RB.PrintMeasure(Header); headerSize.width += 8; var headerRect = new Rect2i(menuRect.x + menuRect.width / 2 - headerSize.width / 2, menuRect.y - 6, headerSize.width, MIN_HEADER_HEIGHT); var summaryRect = new Rect2i(menuRect.x + BORDER_PADDING, menuRect.y + BORDER_PADDING + 8, menuRect.width - BORDER_PADDING, menuRect.height - BORDER_PADDING); RB.DrawRectFill(menuRect, C.MenuBG); RB.DrawRect(menuRect, Color.white); RB.DrawRectFill(headerRect, Color.black); RB.DrawRect(headerRect, Color.white); RB.Print(headerRect, Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, Header); RB.Print(summaryRect, Color.white, SummaryPrintFlags, Summary); }
private void DrawInputString(int x, int y) { var demo = (DemoReel)RB.Game; RB.CameraSet(new Vector2i(-x, -y)); int width = 612; int height = 32; RB.DrawRect(new Rect2i(0, 0, width, height), DemoUtil.IndexToRGB(25)); RB.DrawRectFill(new Rect2i(1, 1, width - 2, height - 2), DemoUtil.IndexToRGB(27)); RB.ClipSet(new Rect2i(x + 4, y + 4, width - 8, height - 2)); if (RB.Ticks % 30 < 15) { RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(23), RB.NO_ESCAPE_CODES, mInputString); } else { mInputString.Append('|'); RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(23), RB.NO_ESCAPE_CODES, mInputString); mInputString.Truncate(mInputString.Length - 1); } RB.CameraReset(); RB.ClipReset(); }
/// <summary> /// Render /// </summary> public void Render() { var demo = (DemoReel)RB.Game; Vector2i labelSize = RB.PrintMeasure(mLabel); int yPos; if (mLabelBottomAligned) { yPos = mRect.y + mRect.height - labelSize.y - 4; } else { yPos = mRect.y + (mRect.height / 2) - (labelSize.y / 2); } if (mPressed) { RB.DrawRectFill(new Rect2i(mRect.x + 2, mRect.y + 2, mRect.width - 2, mRect.height - 2), DemoUtil.IndexToRGB(5)); RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2) + 1, yPos + 1), DemoUtil.IndexToRGB(mLabelColor), mLabel); } else { RB.DrawRectFill(mRect, DemoUtil.IndexToRGB(mFaceColor)); RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2), yPos), DemoUtil.IndexToRGB(mLabelColor), mLabel); RB.DrawRect(mRect, DemoUtil.IndexToRGB(5)); } mHitRect = new Rect2i(-RB.CameraGet().x + mHotZone.x, -RB.CameraGet().y + mHotZone.y, mHotZone.width, mHotZone.height); }
private static void RenderMouseHover() { var tilePos = SceneGame.GetMouseTilePos(); if (tilePos.x == -1) { return; } EntityFunctions.GetEntitiesStringAtTile(tilePos, C.FSTR); if (C.FSTR.Length > 0) { // Preserve camera location var cameraPos = RB.CameraGet(); RB.CameraReset(); var mousePos = RB.PointerPos(); var anchorPos = new Vector2i(mousePos.x + 4, mousePos.y + 12); var textSize = RB.PrintMeasure(C.FONT_SMALL, C.FSTR); var textRect = new Rect2i(anchorPos.x, anchorPos.y, textSize.width, textSize.height); var textFrameRect = new Rect2i(textRect.x - 4, textRect.y - 4, textRect.width + 8, textRect.height + 8); RB.DrawRectFill(textFrameRect, C.COLOR_MENU_BACKGROUND); RB.DrawRect(textFrameRect, Color.white); RB.Print(C.FONT_SMALL, textRect, Color.white, 0, C.FSTR); RB.CameraSet(cameraPos); } }
/// <summary> /// Render /// </summary> public override void Render() { if (mShowingMessageBox) { RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height), new Color32(0, 0, 0, 200)); mMenuMessageBox.Render(); } }
private void DrawTMX() { var demo = (DemoReel)RB.Game; int spriteFrame = (RB.Ticks % 40) > 20 ? 1 : 0; Rect2i clipRect = new Rect2i(0, 0, 0, 0); int cameraYOffset = 0; int cameraXOffset = 0; int cameraYRange = 16; if (mStyle == RB.PixelStyle.Wide) { clipRect = new Rect2i((RB.DisplaySize.width / 2) - 100, RB.DisplaySize.height - 220, 200, 200); } else if (mStyle == RB.PixelStyle.Tall) { clipRect = new Rect2i((RB.DisplaySize.width / 2) - 200, RB.DisplaySize.height - 110, 400, 100); cameraYOffset = 150; cameraXOffset = -120; cameraYRange = 8; } if (mMap != null) { int scrollPos = -(int)RB.Ticks % (mMapSize.width * RB.SpriteSize().width); Vector2i cameraPos = new Vector2i((int)((Mathf.Sin(RB.Ticks / 100.0f) * 420) + 450 + cameraXOffset), (int)((Mathf.Sin(RB.Ticks / 10.0f) * cameraYRange) + cameraYOffset)); RB.ClipSet(clipRect); RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22)); RB.CameraSet(cameraPos); RB.DrawMapLayer(0, new Vector2i(scrollPos, 0)); RB.DrawMapLayer(0, new Vector2i(scrollPos + (mMapSize.width * RB.SpriteSize().width), 0)); RB.DrawMapLayer(1); RB.DrawMapLayer(2); RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16)); RB.DrawSprite(RB.SpriteIndex(6, 10) + spriteFrame, new Vector2i(67 * 16, 14 * 16)); RB.CameraReset(); } else { RB.Print(new Vector2i(clipRect.x + 2, clipRect.y + 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map\nDemos/DemoReel/Tilemap.tmx in Unity"); } RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21)); RB.ClipReset(); mFormatStr.Set("@C// Use ").Append(mStyle == RB.PixelStyle.Wide ? "wide" : "tall").Append(" pixel format\n"); mFormatStr.Append("@Kpublic @MHardwareSettings @NQueryHardware() {\n"); mFormatStr.Append(" @Kvar @Nhw = @Knew @MHardwareSettings@N();\n"); mFormatStr.Append(" @Nhw.DisplaySize = @Knew @MVector2i@N(@L").Append(RB.DisplaySize.width).Append("@N, @L").Append(RB.DisplaySize.height).Append("@N);\n"); mFormatStr.Append(" @Nhw.PixelStyle = @KRetroBlit@N.@EPixelStyle@N.").Append(mStyle == RB.PixelStyle.Wide ? "Wide" : "Tall").Append(";\n"); mFormatStr.Append(" @Kreturn @Nhw;\n"); mFormatStr.Append("}"); RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
/// <summary> /// Draw information overlay /// </summary> protected override void Overlay() { mString.Set("Text Stress Test\n@7F7F7FStrings: @FFFFFF").Append(mStressLevel).Append("\n@7F7F7FFPS: @FFFFFF").Append(mFPS, 2).Append("\n\n@FFFFFF"); mString.Append("\u2191 \u2193 @7F7F7FChange Stress Level\n").Append("@FFFFFF"); mString.Append("\u2190 \u2192 @7F7F7FChange Test"); RB.DrawRectFill(new Rect2i(4, 4, 115, 51), new Color32(32, 32, 32, 255)); RB.Print(new Vector2i(6, 6), Color.white, mString); }
private void DrawTMX(int x, int y) { var demo = (DemoReel)RB.Game; Rect2i clipRect = new Rect2i(x + 16, y + 142, 310, 207); Vector2i cameraPos = new Vector2i((int)(Mathf.Sin(RB.Ticks / 100.0f) * 450) + 200, (int)Mathf.Sin(RB.Ticks / 10.0f) * 16); int spriteFrame = (RB.Ticks % 40) > 20 ? 1 : 0; if (mMap != null && mMap.status == RB.AssetStatus.Ready) { int scrollPos = -(int)RB.Ticks % (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width); RB.ClipSet(clipRect); RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22)); RB.CameraSet(cameraPos); RB.DrawMapLayer(1, new Vector2i(scrollPos, 0)); RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width), 0)); RB.DrawMapLayer(2); RB.DrawMapLayer(3); RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16)); RB.DrawSprite(RB.SpriteIndex(6, 10) + spriteFrame, new Vector2i(67 * 16, 14 * 16)); } else { RB.CameraReset(); RB.ClipReset(); RB.Print(new Vector2i(x + 18, y + 144), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity"); } RB.CameraReset(); RB.ClipReset(); RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21)); mMap.Load("Demos/DemoReel/Tilemap"); mFormatStr.Set("@C// Load a map from a TMX file\n"); mFormatStr.Append("@NmyTMXMap.Load(@S\"Demos/Demo/Tilemap\"@N);\n"); mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Clouds\"@N, @L1@N);\n"); mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Decoration\"@N, @L2@N);\n"); mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Terrain\"@N, @L3@N);\n"); mFormatStr.Append("@[email protected](@Knew @MRect2i(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N));\n"); mFormatStr.Append("@[email protected](@Knew@N @MRect2i@N(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N), @I22);\n"); mFormatStr.Append("@[email protected](@Knew @MVector2i@N(@L").Append(cameraPos.x).Append("@N, @L").Append(cameraPos.y).Append("@N));\n"); mFormatStr.Append("@Kint@N pos = @L").Append(-(int)RB.Ticks).Append("@N % (myMap.size.width * @[email protected]);\n"); mFormatStr.Append("@[email protected](@L1@N, @Knew @MVector2i@N(pos, @L0@N));\n"); mFormatStr.Append("@[email protected](@L1@N, @Knew @MVector2i@N(pos + (myMap.size.width * @[email protected])), @L0@N));\n"); mFormatStr.Append("@[email protected](@L2@N);\n"); mFormatStr.Append("@[email protected](@L3@N);\n"); mFormatStr.Append("@[email protected](@L").Append(0 + spriteFrame).Append("@N, @Knew@N @MVector2i@N(@L").Append(13 * 16).Append("@N, @L").Append(16 * 16).Append("@N));\n"); mFormatStr.Append("@[email protected](@L").Append(RB.SpriteIndex(6, 10) + spriteFrame).Append("@N, @Knew @MVector2i@N(@L").Append(67 * 16).Append("@N, @L").Append(14 * 16).Append("@N));\n"); mFormatStr.Append("@[email protected]();\n"); mFormatStr.Append("@[email protected](@Knew @MRect2i(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N), @I21);\n"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(22)); int spriteFrame = ((int)RB.Ticks % 40) > 20 ? 1 : 0; if (mMap != null) { RB.DrawMapLayer(0); RB.DrawMapLayer(1); } RB.EffectSet(RB.Effect.Noise, 0.15f); RB.EffectSet(RB.Effect.Scanlines, 1.0f); RB.EffectSet(RB.Effect.Desaturation, (Mathf.Sin(RB.Ticks / 50.0f) * 0.5f) + 0.5f); RB.EffectApplyNow(); RB.EffectReset(); if (mMap != null) { RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16)); } else { RB.Print(new Vector2i(2, 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity"); } mFormatStr.Set("@C// Specify when post-processing effects should be applied\n"); mFormatStr.Append("@[email protected](@L0@N);\n"); mFormatStr.Append("@[email protected](@L1@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L0.15f@N);\n"); mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L1.0f@N);\n"); mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L").Append((Mathf.Sin(RB.Ticks / 50.0f) * 0.5f) + 0.5f, 2).Append("f@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected]();\n"); mFormatStr.Append("@[email protected]();\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@L").Append(0 + spriteFrame).Append("@N, @Knew@N Vector2i(@L").Append(13 * 16).Append("@N, @L").Append(16 * 16).Append("@N));"); var size = RB.PrintMeasure(DemoUtil.HighlightCode(mFormatStr, mFinalStr)); size.x += 4; size.y += 4; var rect = new Rect2i((RB.DisplaySize.width / 2) - (size.x / 2), (RB.DisplaySize.height / 2) - (size.y / 2), size.x, size.y); rect.y -= 64; RB.DrawRectFill(rect, DemoUtil.IndexToRGB(1)); RB.DrawRect(rect, DemoUtil.IndexToRGB(4)); RB.Print(new Vector2i(rect.x + 2, rect.y + 2), DemoUtil.IndexToRGB(0), mFinalStr); }
private static void RenderBar(Vector2i pos, Vector2i size, int value, int maxvalue, Color32 barColour, Color32 backColor) { var barWidth = (int)((float)value / maxvalue * size.width); // draw background bar RB.DrawRectFill(new Rect2i(pos, size), backColor); // draw foreground bar RB.DrawRectFill(new Rect2i(pos, barWidth, size.height), barColour); }
private void DrawCode(int x, int y) { var demo = (DemoReel)RB.Game; RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), "Source code:"); RB.DrawRectFill(new Rect2i(x, y + 10, 315, 270), DemoUtil.IndexToRGB(1)); mFormatStr.Set(mMarkedUpCode); DemoUtil.HighlightCode(mFormatStr, mFinalStr); RB.Print(new Vector2i(x + 4, y + 14), DemoUtil.IndexToRGB(5), mFinalStr); }
private void DrawTilemap(int x, int y) { var demo = (DemoReel)RB.Game; RB.Offscreen(spriteSheet1); RB.SpriteSheetSet(spriteSheet2); mWaveOffset = (int)((RB.Ticks / 2) % 16); mFishFrame = (int)((RB.Ticks / 6) % 32); RB.DrawCopy(new Rect2i(mWaveOffset, 0, RB.SpriteSheetGet().grid.cellSize), new Vector2i(48, 192)); RB.Clear(new Color32(0, 0, 0, 0), new Rect2i(80, 192, RB.SpriteSheetGet().grid.cellSize)); if (mFishFrame < 7) { RB.DrawCopy(new Rect2i(mFishFrame * RB.SpriteSheetGet().grid.cellSize.width, RB.SpriteSheetGet().grid.cellSize.height, RB.SpriteSheetGet().grid.cellSize), new Vector2i(80, 192)); } RB.Onscreen(); Rect2i clipRect = new Rect2i(x, y + (RB.DisplaySize.height / 2) - 8, 632, 180); if (mMap != null) { RB.ClipSet(clipRect); RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22)); RB.CameraSet(new Vector2i(0, 0)); RB.DrawMapLayer(2); RB.DrawMapLayer(3); RB.TintColorSet(Color.black); RB.AlphaSet(32); int scrollPos = -(int)RB.Ticks % (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width); RB.DrawMapLayer(1, new Vector2i(scrollPos + 8, 8)); RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width) + 8, 8)); RB.TintColorSet(Color.white); RB.AlphaSet(196); RB.DrawMapLayer(1, new Vector2i(scrollPos, 0)); RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width), 0)); RB.AlphaSet(255); RB.CameraReset(); RB.ClipReset(); RB.SpriteSheetSet(spriteSheet1); } else { RB.Print(new Vector2i(clipRect.x + 2, clipRect.y + 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/TilemapOcean.tmx in Unity"); } RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21)); }
private void DrawPiano(int x, int y) { var demo = (DemoReel)RB.Game; RB.CameraSet(new Vector2i(-x, -y)); mFormatStr.Set("@C// Play sound at specific volume and pitch\n"); mFormatStr.Append("@NsoundC5Note.Load(@S\"Demos/Demo/C5Note\"@N);\n"); mFormatStr.Append("@[email protected](soundC5Note, @L0.@L5f@N, @L1.@L2f@N);\n"); RB.Print(new Vector2i(0, 0), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); RB.CameraSet(new Vector2i(-x, -y - 35)); Rect2i pianoRect = mPianoRect; Rect2i holeRect = pianoRect; pianoRect = pianoRect.Expand(8); holeRect = holeRect.Expand(2); int cornerSize = 8; RB.DrawEllipseFill(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3)); RB.DrawEllipse(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2)); RB.DrawEllipseFill(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3)); RB.DrawEllipse(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2)); RB.DrawEllipseFill(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3)); RB.DrawEllipse(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2)); RB.DrawEllipseFill(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3)); RB.DrawEllipse(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2)); RB.DrawRect(new Rect2i(pianoRect.x + cornerSize, pianoRect.y, pianoRect.width - (cornerSize * 2), pianoRect.height), DemoUtil.IndexToRGB(2)); RB.DrawRectFill(new Rect2i(pianoRect.x + cornerSize, pianoRect.y + 1, pianoRect.width - (cornerSize * 2), pianoRect.height - 2), DemoUtil.IndexToRGB(3)); RB.DrawRect(new Rect2i(pianoRect.x, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2)); RB.DrawRectFill(new Rect2i(pianoRect.x + 1, pianoRect.y + cornerSize, cornerSize - 1, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3)); RB.DrawRect(new Rect2i(pianoRect.x + pianoRect.width - cornerSize, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2)); RB.DrawRectFill(new Rect2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3)); RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(2)); for (int i = 0; i < mPianoButtons.Length; i++) { mPianoButtons[i].Render(); } RB.CameraReset(); }
private void DrawTextFrame(Rect2i rect, FastString subTitle) { var demo = (DemoReel)RB.Game; RB.DrawRectFill(rect, DemoUtil.IndexToRGB(1)); RB.DrawRect(rect, DemoUtil.IndexToRGB(2)); if (subTitle != null) { var subTitleRect = new Rect2i(rect.x, rect.y + rect.height + 5, rect.width, rect.height); RB.Print(subTitleRect, DemoUtil.IndexToRGB(3), RB.ALIGN_H_CENTER | RB.TEXT_OVERFLOW_WRAP, subTitle); } }
private void DrawGamepadShoulder(int x, int y, string label, bool pressed, int color, int colorOutline) { var demo = (DemoReel)RB.Game; int faceColor = pressed ? 5 : color; int offset = pressed ? 3 : 0; RB.DrawRectFill(new Rect2i(x, y + offset + 1, 16, 12), DemoUtil.IndexToRGB(faceColor)); RB.DrawRect(new Rect2i(x + 1, y + offset, 14, 1), DemoUtil.IndexToRGB(colorOutline)); RB.DrawRect(new Rect2i(x, y + offset + 1, 1, 12), DemoUtil.IndexToRGB(colorOutline)); RB.DrawRect(new Rect2i(x + 15, y + offset + 1, 1, 12), DemoUtil.IndexToRGB(colorOutline)); RB.Print(new Vector2i(x + 4, y + 2 + offset), DemoUtil.IndexToRGB(colorOutline), label); }
/// <summary> /// Draw output frame /// </summary> /// <param name="rect">Rectangle</param> /// <param name="frameOuter">Outer frame color</param> /// <param name="frameInner">Inner frame color</param> /// <param name="fillColorIndex">Fill color</param> public static void DrawOutputFrame(Rect2i rect, int frameOuter, int frameInner, int fillColorIndex) { var demo = (DemoReel)RB.Game; if (frameOuter != -1) { RB.DrawRect(new Rect2i(rect.x - 2, rect.y - 2, rect.width + 4, rect.height + 4), IndexToRGB(frameOuter)); } if (frameInner != -1) { RB.DrawRect(new Rect2i(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2), IndexToRGB(frameInner)); } RB.DrawRectFill(rect, IndexToRGB(fillColorIndex)); }
/// <summary> /// Run the stress test /// </summary> protected override void StressTest() { var game = (StressTest)RB.Game; Random.InitState(0); for (int i = 0; i < mStressLevel; i++) { var wiggle = GetWiggle(); var randRect = new Rect2i( (int)(Random.Range(-game.spriteSheet.grid.cellSize.width * 0.75f, RB.DisplaySize.width - (game.spriteSheet.grid.cellSize.width * 0.25f)) + wiggle.x), (int)(Random.Range(-game.spriteSheet.grid.cellSize.height * 0.75f, RB.DisplaySize.height - (game.spriteSheet.grid.cellSize.height * 0.25f)) + wiggle.y), Random.Range(8, 64), Random.Range(8, 64)); int type = Random.Range(0, 5); if (type == 0) { RB.DrawLine(new Vector2i(randRect.x, randRect.y), new Vector2i(randRect.x + randRect.width, randRect.y + randRect.height), mRandomColor[i]); } else if (type == 1) { RB.DrawRect(randRect, mRandomColor[i]); } else if (type == 2) { RB.DrawRectFill(randRect, mRandomColor[i]); } else if (type == 3) { RB.DrawTriangleFill( new Vector2i(randRect.x, randRect.y), new Vector2i(randRect.x + randRect.width, randRect.y), new Vector2i(randRect.x + (randRect.width / 2), randRect.y + randRect.height), mRandomColor[i]); } else if (type == 4) { RB.DrawTriangle( new Vector2i(randRect.x, randRect.y), new Vector2i(randRect.x + randRect.width, randRect.y), new Vector2i(randRect.x + (randRect.width / 2), randRect.y + randRect.height), mRandomColor[i]); } } }
private static void RenderBar(Vector2i pos, Vector2i size, string name, int value, int maximum, Color32 barColor, Color32 backColor, Color32 frameColor) { int barWidth = (int)((float)value / maximum * (size.width - 2)); RB.DrawRectFill(new Rect2i(pos.x, pos.y, size.width, size.height), backColor); if (barWidth > 0) { RB.DrawRectFill(new Rect2i(pos.x + 1, pos.y, barWidth, size.height), barColor); } RB.DrawRect(new Rect2i(pos.x, pos.y, size.width, size.height), frameColor); C.FSTR.Set(name).Append(": ").Append(value).Append(" / ").Append(maximum); RB.Print(C.FONT_SMALL, new Rect2i(pos.x, pos.y + 1, size.width, size.height), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, C.FSTR); }
public static void Render(int x, int y, Element element, bool large = false, bool optional = false, int extension = -1) { if (element == null) { return; } string name = element.GetName(); if (!large) { name = name.Substring(0, 1); } Rect2i rect = new Rect2i(x, y, large ? 32 : 16, large ? 32 : 16); Rect2i innerRect = new Rect2i(x + (large ? 10 : 2), y + (large ? 4 : 2), 12, 12); if (optional || extension >= 0) { RB.AlphaSet(127); } RB.DrawRectFill(rect, Color.black); RB.DrawRectFill(rect.Expand(-1), Color.white); RB.AlphaSet(255); RB.DrawSprite(element.GetName(), innerRect); if (extension > 0) { Vector2i measure = RB.PrintMeasure(extension.ToString()); Rect2i extRect = new Rect2i(rect.x + rect.width, rect.y + rect.height / 2 - measure.height / 2, measure).Offset(new Vector2i(1, 0)); extRect.Expand(2); RB.DrawRectFill(extRect, Color.white); RB.DrawRect(extRect, Color.black); RB.Print(extRect, Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, extension.ToString()); } if (large) { rect = rect.Offset(new Vector2i(0, 8)); rect.Expand(0, -4); for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { RB.Print(rect.Offset(new Vector2i(dx, dy)), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, name); } } RB.Print(rect, element.GetColor(), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, name); } }
private void DrawGamepad(int x, int y, int playerNum) { var demo = (DemoReel)RB.Game; RB.CameraSet(new Vector2i(-x, -y)); int color1 = playerNum == RB.PLAYER_ONE ? 22 : 15; int color2 = playerNum == RB.PLAYER_ONE ? 21 : 14; int colorOutline = 0; DrawGamepadShoulder(25, -9, "LS", RB.ButtonDown(RB.BTN_LS, playerNum), color2, colorOutline); DrawGamepadShoulder(88, -9, "RS", RB.ButtonDown(RB.BTN_RS, playerNum), color2, colorOutline); RB.DrawEllipseFill(new Vector2i(26, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(color1)); RB.DrawEllipseFill(new Vector2i(102, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(color1)); RB.DrawEllipse(new Vector2i(26, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(colorOutline)); RB.DrawEllipse(new Vector2i(102, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(colorOutline)); RB.DrawRect(new Rect2i(26, 0, 76, 57), DemoUtil.IndexToRGB(colorOutline)); RB.DrawRectFill(new Rect2i(26, 1, 76, 55), DemoUtil.IndexToRGB(color1)); #if ABXY_SWITCHED DrawGamepadABXY(87, 29, "Y", RB.ButtonDown(RB.BTN_Y, playerNum), color2, colorOutline); DrawGamepadABXY(113, 29, "A", RB.ButtonDown(RB.BTN_A, playerNum), color2, colorOutline); DrawGamepadABXY(100, 16, "X", RB.ButtonDown(RB.BTN_X, playerNum), color2, colorOutline); DrawGamepadABXY(100, 41, "B", RB.ButtonDown(RB.BTN_B, playerNum), color2, colorOutline); #else DrawGamepadABXY(100, 16, "Y", RB.ButtonDown(RB.BTN_Y, playerNum), color2, colorOutline); DrawGamepadABXY(100, 41, "A", RB.ButtonDown(RB.BTN_A, playerNum), color2, colorOutline); DrawGamepadABXY(87, 29, "X", RB.ButtonDown(RB.BTN_X, playerNum), color2, colorOutline); DrawGamepadABXY(113, 29, "B", RB.ButtonDown(RB.BTN_B, playerNum), color2, colorOutline); #endif DrawGamepadMenu(55, 20, RB.ButtonDown(RB.BTN_MENU, playerNum), color2, colorOutline); DrawGamepadSystem(57, 37, RB.ButtonDown(RB.BTN_SYSTEM, playerNum), color2, colorOutline); DrawGamepadDPad( 10, 14, (RB.ButtonDown(RB.BTN_UP, playerNum) ? RB.BTN_UP : 0) | (RB.ButtonDown(RB.BTN_DOWN, playerNum) ? RB.BTN_DOWN : 0) | (RB.ButtonDown(RB.BTN_LEFT, playerNum) ? RB.BTN_LEFT : 0) | (RB.ButtonDown(RB.BTN_RIGHT, playerNum) ? RB.BTN_RIGHT : 0), color2, colorOutline); RB.CameraReset(); }
public override void RenderForeground() { for (int i = 0; i < battle.rolls.Length; i++) { if (battle.locks[i]) { RB.DrawSprite("Lock", lockPositions[i] - new Vector2i(6, 6)); //RB.Print(new Rect2i(lockPositions[i] - new Vector2i(16, 8), new Vector2i(32, 16)), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, "Locked"); } } for (int i = 0; i < battle.rollsLeft; i++) { RB.DrawEllipseFill(new Vector2i(size.x / 5 - 10 + i * 10, size.y / 2 + 44), new Vector2i(4, 4), Color.white); RB.DrawEllipse(new Vector2i(size.x / 5 - 10 + i * 10, size.y / 2 + 44), new Vector2i(4, 4), Color.black); } if (infoPane.GetOpenTabIndex() == 1) { ElementDisplay[] displays = viewedSpell.GetElementDisplays(battle.BuildContext()); for (int i = 0; i < displays.Length; i++) { displays[i].Render(size.width / 2 + 5 + i * 18, size.height - 50); } } if (renderTargeting) { if (targetPawn != null) { RB.AlphaSet(96); RB.DrawRectFill(new Rect2i(0, 0, size), Color.black); RB.AlphaSet(255); pawnCards[targetPawn].Render(); RB.DrawRect(targetRect, Color.yellow); RB.DrawPixel(targetPoint - new Vector2i(1, 0), Color.white); //RB.DrawRect(targetRect.Offset(new Vector2i(0, 0)).Expand(1), Color.black); originButton.Render(); } RB.DrawPixel(originPoint + new Vector2i(1, 0), Color.white); //RB.DrawRect(new Rect2i(originButton.pos, originButton.size).Expand(2), Color.black); RB.DrawLine(originPoint + new Vector2i(0, 1), targetPoint + new Vector2i(0, 1), Color.yellow); RB.DrawLine(originPoint, targetPoint, Color.white); RB.DrawLine(originPoint - new Vector2i(0, 1), targetPoint - new Vector2i(0, 1), Color.yellow); } }
private void DrawGamepadSystem(int x, int y, bool pressed, int color, int colorOutline) { var demo = (DemoReel)RB.Game; int faceColor = pressed ? 5 : color; RB.DrawEllipseFill(new Vector2i(x, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(faceColor)); RB.DrawEllipseFill(new Vector2i(x + 6, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(faceColor)); RB.DrawEllipse(new Vector2i(x, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(colorOutline)); RB.DrawEllipse(new Vector2i(x + 6, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(colorOutline)); RB.DrawRect(new Rect2i(x - 1, y - 7, 10, 15), DemoUtil.IndexToRGB(colorOutline)); RB.DrawRectFill(new Rect2i(x - 1, y - 6, 10, 13), DemoUtil.IndexToRGB(faceColor)); RB.Print(new Vector2i(x - 4, y - 3), DemoUtil.IndexToRGB(colorOutline), "SYS"); }
public virtual void Render() { foreach (UIObj uiObj in uiObjs) { if (uiObj.isVisible) { uiObj.Render(); } } RenderForeground(); if (currentMsgBox != null) { RB.AlphaSet(120); RB.DrawRectFill(new Rect2i(0, 0, size.width, size.height), Color.black); RB.AlphaSet(255); currentMsgBox.Render(); } if (tooltip.Length > 0) { Vector2i tooltipSize = RB.PrintMeasure(tooltip) + new Vector2i(6, 6); Vector2i topRightPos = RB.PointerPos() - new Vector2i(0, tooltipSize.y); if (topRightPos.y >= 0) { if (topRightPos.x + tooltipSize.width < RB.DisplaySize.width) { RenderTooltip(new Rect2i(topRightPos, tooltipSize), tooltip); } else { RenderTooltip(new Rect2i(RB.PointerPos() - tooltipSize, tooltipSize), tooltip); } } else { if (topRightPos.x + tooltipSize.width < RB.DisplaySize.width) { RenderTooltip(new Rect2i(RB.PointerPos(), tooltipSize), tooltip); } else { RenderTooltip(new Rect2i(RB.PointerPos() - new Vector2i(tooltipSize.x, 0), tooltipSize), tooltip); } } } }