Java Code Examples for org.newdawn.slick.Graphics#setColor()
The following examples show how to use
org.newdawn.slick.Graphics#setColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FontTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { font.drawString(80, 5, "A Font Example", Color.red); font.drawString(100, 32, "We - AV - Here is a more complete line that hopefully"); font.drawString(100, 36 + font.getHeight("We Here is a more complete line that hopefully"), "will show some kerning."); font2.drawString(80, 85, "A Font Example", Color.red); font2.drawString(100, 132, "We - AV - Here is a more complete line that hopefully"); font2.drawString(100, 136 + font2.getHeight("We - Here is a more complete line that hopefully"), "will show some kerning."); image.draw(100,400); String testStr = "Testing Font"; font2.drawString(100, 300, testStr); g.setColor(Color.white); g.drawRect(100,300+font2.getYOffset(testStr),font2.getWidth(testStr),font2.getHeight(testStr)-font2.getYOffset(testStr)); font.drawString(500, 300, testStr); g.setColor(Color.white); g.drawRect(500,300+font.getYOffset(testStr),font.getWidth(testStr),font.getHeight(testStr)-font.getYOffset(testStr)); }
Example 2
Source File: TransformTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer contiainer, Graphics g) { g.translate(320,240); g.scale(scale, scale); g.setColor(Color.red); for (int x=0;x<10;x++) { for (int y=0;y<10;y++) { g.fillRect(-500+(x*100), -500+(y*100), 80, 80); } } g.setColor(new Color(1,1,1,0.5f)); g.fillRect(-320,-240,640,480); g.setColor(Color.white); g.drawRect(-320,-240,640,480); }
Example 3
Source File: SoundTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.setColor(Color.white); g.drawString("The OGG loop is now streaming from the file, woot.",100,60); g.drawString("Press space for sound effect (OGG)",100,100); g.drawString("Press P to pause/resume music (XM)",100,130); g.drawString("Press E to pause/resume engine sound (WAV)",100,190); g.drawString("Press enter for charlie (WAV)",100,160); g.drawString("Press C to change music",100,210); g.drawString("Press B to burp (AIF)",100,240); g.drawString("Press + or - to change global volume of music", 100, 270); g.drawString("Press Y or X to change individual volume of music", 100, 300); g.drawString("Press N or M to change global volume of sound fx", 100, 330); g.setColor(Color.blue); g.drawString("Global Sound Volume Level: " + container.getSoundVolume(), 150, 390); g.drawString("Global Music Volume Level: " + container.getMusicVolume(), 150, 420); g.drawString("Current Music Volume Level: " + music.getVolume(), 150, 450); }
Example 4
Source File: RotateTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void postRender(StateBasedGame game, GameContainer container, Graphics g) throws SlickException { g.translate(container.getWidth()/2, container.getHeight()/2); g.scale(scale,scale); g.rotate(0, 0, ang); g.translate(-container.getWidth()/2, -container.getHeight()/2); if (background != null) { Color c = g.getColor(); g.setColor(background); g.fillRect(0,0,container.getWidth(),container.getHeight()); g.setColor(c); } prev.render(container, game, g); g.translate(container.getWidth()/2, container.getHeight()/2); g.rotate(0, 0, -ang); g.scale(1/scale,1/scale); g.translate(-container.getWidth()/2, -container.getHeight()/2); }
Example 5
Source File: LineRenderTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.setAntiAlias(antialias); g.setLineWidth(50); g.setColor(Color.red); g.draw(path); // g.setColor(Color.red); // TextureImpl.bindNone(); // g.setLineWidth(width); // g.setAntiAlias(true); // for (int i=0;i<10;i++) { // g.translate(35,35); // g.draw(polygon); // } // g.translate(-350,-350); // // g.setColor(Color.white); // g.setLineWidth(1); // g.setAntiAlias(false); // g.draw(polygon); }
Example 6
Source File: StoryboardOverlay.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
@Override public void onRender(Graphics g) { if (!OPTION_DANCE_ENABLE_SB.state || hide) { return; } int lh = Fonts.SMALL.getLineHeight(); Fonts.SMALL.drawString(10, height - 50 + lh, "save position: ctrl+s, load position: ctrl+l", Color.cyan); Fonts.SMALL.drawString(10, height - 50, "speed: C " + (speed / 10f) + " V", Color.cyan); Fonts.SMALL.drawString(10, height - 50 - lh, "Menu: N", Color.cyan); Fonts.SMALL.drawString(10, height - 50 - lh * 2, "HIDE: H", Color.cyan); Fonts.SMALL.drawString(10, height - 50 - lh * 3, "obj: J " + index + " K", Color.cyan); g.setColor(Color.red); if (index < optionsMap.length && optionsMap[index] != null) { int i = 0; for (Object o : optionsMap[index].entrySet()) { Map.Entry<Option, String> option = (Map.Entry<Option, String>) o; Fonts.SMALL.drawString(10, 50 + i * lh, option.getKey().name, Color.cyan); Fonts.SMALL.drawString(width / 5, 50 + i * lh, option.getKey().getValueString(), Color.cyan); g.fillRect(0, 50 + i * lh + lh / 4, 10, 10); i++; } } if (gameObjects.length > 0) { int start = gameObjects[0].getTime(); int end = gameObjects[gameObjects.length - 1].getEndTime(); float curtime = (float) (MusicController.getPosition() - start) / (end - start); g.fillRect(curtime * width, height - 10f, 10f, 10f); } }
Example 7
Source File: SimpleButton.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
public void render(Graphics g) { g.setLineWidth(2f); g.setColor(bg); g.fillRect(hitbox.x, hitbox.y, hitbox.width, hitbox.height); g.setColor(fg); font.drawString(hitbox.x + 5, textY, text); if (isHovered) { g.setColor(hoverBorder); } else { g.setColor(border); } g.drawRect(hitbox.x, hitbox.y, hitbox.width, hitbox.height); }
Example 8
Source File: GeomAccuracyTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Draws arcs * @param g */ void arcTest(Graphics g) { if(hideOverlay == false) { g.setColor(overlayColor); g.drawLine(198, 100, 198, 198); g.drawLine(100, 198, 198, 198); } g.setColor(geomColor); g.drawArc(100, 100, 99, 99, 0, 90); }
Example 9
Source File: BarNotificationState.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
public void render(Graphics g) { if (timeShown >= TOTAL_TIME) { return; } timeShown += renderDelta; processAnimations(); g.setColor(bgcol); g.fillRect(0, height2 - barHalfHeight, width, barHalfHeight * 2); int y = textY; for (String line : lines) { Fonts.LARGE.drawString((width - Fonts.LARGE.getWidth(line)) / 2, y, line, textCol); y += Fonts.LARGE.getLineHeight(); } }
Example 10
Source File: FadeOutTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void postRender(StateBasedGame game, GameContainer container, Graphics g) { Color old = g.getColor(); g.setColor(color); g.fillRect(0, 0, container.getWidth() * 2, container.getHeight() * 2); g.setColor(old); }
Example 11
Source File: CopyAreaAlphaTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.clearAlphaMap(); g.setDrawMode(Graphics.MODE_NORMAL); g.setColor(Color.white); g.fillOval(100,100,150,150); textureMap.draw(10,50); g.copyArea(copy, 100,100); g.setColor(Color.red); g.fillRect(300,100,200,200); copy.draw(350,150); }
Example 12
Source File: BigImageTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { original.draw(0,0,new Color(1,1,1,0.4f)); image.draw(x,y); imageX.draw(x+400,y); imageY.draw(x,y+300); scaledSub.draw(x+300,y+300); bigSheet.getSprite(7, 5).draw(50,10); g.setColor(Color.white); g.drawRect(50,10,64,64); g.rotate(x+400, y+165, ang); g.drawImage(sub, x+300, y+100); }
Example 13
Source File: DistanceFieldTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { String text = "abc"; font.drawString(610,100,text); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.5f); font.drawString(610,150,text); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); g.translate(-50,-130); g.scale(10,10); font.drawString(0,0,text); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.5f); font.drawString(0,26,text); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); g.resetTransform(); g.setColor(Color.lightGray); g.drawString("Original Size on Sheet", 620, 210); g.drawString("10x Scale Up", 40, 575); g.setColor(Color.darkGray); g.drawRect(40, 40, 560,530); g.drawRect(610, 105, 150,100); g.setColor(Color.white); g.drawString("512x512 Font Sheet", 620, 300); g.drawString("NEHE Charset", 620, 320); g.drawString("4096x4096 (8x) Source Image", 620, 340); g.drawString("ScanSize = 20", 620, 360); }
Example 14
Source File: SoundURLTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.setColor(Color.white); g.drawString("The OGG loop is now streaming from the file, woot.",100,60); g.drawString("Press space for sound effect (OGG)",100,100); g.drawString("Press P to pause/resume music (XM)",100,130); g.drawString("Press E to pause/resume engine sound (WAV)",100,190); g.drawString("Press enter for charlie (WAV)",100,160); g.drawString("Press C to change music",100,210); g.drawString("Press B to burp (AIF)",100,240); g.drawString("Press + or - to change volume of music", 100, 270); g.setColor(Color.blue); g.drawString("Music Volume Level: " + volume / 10.0f, 150, 300); }
Example 15
Source File: TextField.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * @see org.newdawn.slick.gui.AbstractComponent#render(org.newdawn.slick.gui.GUIContext, * org.newdawn.slick.Graphics) */ @Override public void render(GUIContext container, Graphics g) { if (lastKey != -1) { if (input.isKeyDown(lastKey)) { if (repeatTimer < System.currentTimeMillis()) { repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL; keyPressed(lastKey, lastChar); } } else { lastKey = -1; } } Rectangle oldClip = g.getClip(); g.setWorldClip(x,y,width, height); // Someone could have set a color for me to blend... Color clr = g.getColor(); if (background != null) { g.setColor(background.multiply(clr)); g.fillRect(x, y, width, height); } g.setColor(text.multiply(clr)); Font temp = g.getFont(); int cpos = font.getWidth(value.substring(0, cursorPos)); int tx = 0; if (cpos > width) { tx = width - cpos - font.getWidth("_"); } g.translate(tx + 2, 0); g.setFont(font); g.drawString(value, x + 1, y + 1); if (hasFocus() && visibleCursor) { g.drawString("_", x + 1 + cpos + 2, y + 1); } g.translate(-tx - 2, 0); if (border != null) { g.setColor(border.multiply(clr)); g.drawRect(x, y, width, height); } g.setColor(clr); g.setFont(temp); g.clearWorldClip(); g.setClip(oldClip); }
Example 16
Source File: GeomTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.setColor(Color.white); g.drawString("Red indicates a collision, green indicates no collision", 50, 420); g.drawString("White are the targets", 50, 435); g.pushTransform(); g.translate(100,100); g.pushTransform(); g.translate(-50,-50); g.scale(10, 10); g.setColor(Color.red); g.fillRect(0,0,5,5); g.setColor(Color.white); g.drawRect(0,0,5,5); g.popTransform(); g.setColor(Color.green); g.fillRect(20,20,50,50); g.popTransform(); g.setColor(Color.white); g.draw(rect); g.draw(circle); g.setColor(rect1.intersects(rect) ? Color.red : Color.green); g.draw(rect1); g.setColor(rect2.intersects(rect) ? Color.red : Color.green); g.draw(rect2); g.setColor(roundRect.intersects(rect) ? Color.red : Color.green); g.draw(roundRect); g.setColor(circle1.intersects(rect) ? Color.red : Color.green); g.draw(circle1); g.setColor(circle2.intersects(rect) ? Color.red : Color.green); g.draw(circle2); g.setColor(circle3.intersects(circle) ? Color.red : Color.green); g.fill(circle3); g.setColor(circle4.intersects(circle) ? Color.red : Color.green); g.draw(circle4); g.fill(roundRect2); g.setColor(Color.blue); g.draw(roundRect2); g.setColor(Color.blue); g.draw(new Circle(100,100,50)); g.drawRect(50,50,100,100); }
Example 17
Source File: UI.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Draws loading progress (OSZ unpacking, beatmap parsing, replay importing, sound loading) * at the bottom of the screen. * @param g the graphics context * @param alpha the text alpha level */ public static void drawLoadingProgress(Graphics g, float alpha) { String text, file; int progress; // determine current action if ((file = OszUnpacker.getCurrentFileName()) != null) { text = "Unpacking new beatmaps..."; progress = OszUnpacker.getUnpackerProgress(); } else if ((file = BeatmapParser.getCurrentFileName()) != null) { text = (BeatmapParser.getStatus() == BeatmapParser.Status.INSERTING) ? "Updating database..." : "Loading beatmaps..."; progress = BeatmapParser.getParserProgress(); } else if ((file = SkinUnpacker.getCurrentFileName()) != null) { text = "Unpacking new skins..."; progress = SkinUnpacker.getUnpackerProgress(); } else if ((file = ReplayImporter.getCurrentFileName()) != null) { text = "Importing replays..."; progress = ReplayImporter.getLoadingProgress(); } else if ((file = SoundController.getCurrentFileName()) != null) { text = "Loading sounds..."; progress = SoundController.getLoadingProgress(); } else return; // draw loading info float marginX = container.getWidth() * 0.02f, marginY = container.getHeight() * 0.02f; float lineY = container.getHeight() - marginY; int lineOffsetY = Fonts.MEDIUM.getLineHeight(); float oldWhiteAlpha = Colors.WHITE_FADE.a; Colors.WHITE_FADE.a = alpha; if (Options.isLoadVerbose()) { // verbose: display percentages and file names Fonts.MEDIUM.drawString( marginX, lineY - (lineOffsetY * 2), String.format("%s (%d%%)", text, progress), Colors.WHITE_FADE ); Fonts.MEDIUM.drawString(marginX, lineY - lineOffsetY, file, Colors.WHITE_FADE); } else { // draw loading bar Fonts.MEDIUM.drawString(marginX, lineY - (lineOffsetY * 2), text, Colors.WHITE_FADE); g.setColor(Colors.WHITE_FADE); g.fillRoundRect( marginX, lineY - (lineOffsetY / 2f), (container.getWidth() - (marginX * 2f)) * progress / 100f, lineOffsetY / 4f, 4 ); } Colors.WHITE_FADE.a = oldWhiteAlpha; }
Example 18
Source File: ScoreData.java From opsu-dance with GNU General Public License v3.0 | 4 votes |
/** * Draws the score in-game (smaller and with less information). * @param g the current graphics context * @param vPos the base y position of the scoreboard * @param rank the current rank of this score * @param position the animated position offset * @param data an instance of GameData to draw rank number * @param alpha the transparency of the score * @param isActive if this score is the one currently played */ public void drawSmall(Graphics g, int vPos, int rank, float position, GameData data, float alpha, boolean isActive) { int rectWidth = (int) (145 * GameImage.getUIscale()); //135 int rectHeight = data.getScoreSymbolImage('0').getHeight(); int vertDistance = rectHeight + 10; int yPos = (int) (vPos + position * vertDistance - rectHeight / 2); int xPaddingLeft = Math.max(4, (int) (rectWidth * 0.04f)); int xPaddingRight = Math.max(2, (int) (rectWidth * 0.02f)); int yPadding = Math.max(2, (int) (rectHeight * 0.02f)); String scoreString = String.format(Locale.US, "%,d", score); String comboString = String.format("%dx", combo); String rankString = String.format("%d", rank); Color white = Colors.WHITE_ALPHA, blue = Colors.BLUE_SCOREBOARD, black = Colors.BLACK_ALPHA; float oldAlphaWhite = white.a, oldAlphaBlue = blue.a, oldAlphaBlack = black.a; // rectangle background Color rectColor = isActive ? white : blue; rectColor.a = alpha * 0.2f; g.setColor(rectColor); g.fillRect(0, yPos, rectWidth, rectHeight); black.a = alpha * 0.2f; g.setColor(black); float oldLineWidth = g.getLineWidth(); g.setLineWidth(1f); g.drawRect(0, yPos, rectWidth, rectHeight); g.setLineWidth(oldLineWidth); // rank data.drawSymbolString(rankString, rectWidth, yPos, 1.0f, alpha * 0.2f, true); white.a = blue.a = alpha * 0.75f; // player name if (playerName != null) Fonts.MEDIUMBOLD.drawString(xPaddingLeft, yPos + yPadding, playerName, white); // score Fonts.DEFAULT.drawString( xPaddingLeft, yPos + rectHeight - Fonts.DEFAULT.getLineHeight() - yPadding, scoreString, white ); // combo Fonts.DEFAULT.drawString( rectWidth - Fonts.DEFAULT.getWidth(comboString) - xPaddingRight, yPos + rectHeight - Fonts.DEFAULT.getLineHeight() - yPadding, comboString, blue ); white.a = oldAlphaWhite; blue.a = oldAlphaBlue; black.a = oldAlphaBlack; }
Example 19
Source File: ScoreData.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Draws the score data as a rectangular button. * @param g the graphics context * @param position the index (to offset the button from the topmost button) * @param rank the score rank * @param prevScore the previous (lower) score, or -1 if none * @param focus whether the button is focused * @param t the animation progress [0,1] */ public void draw(Graphics g, float position, int rank, long prevScore, boolean focus, float t) { float x = baseX - buttonWidth * (1 - AnimationEquation.OUT_BACK.calc(t)) / 2.5f; float rankX = x + buttonWidth * 0.04f; float edgeX = x + buttonWidth * 0.98f; float y = baseY + position; float midY = y + buttonHeight / 2f; float marginY = Fonts.DEFAULT.getLineHeight() * 0.01f; Color c = Colors.WHITE_FADE; float alpha = t; float oldAlpha = c.a; c.a = alpha; // rectangle outline g.setLineWidth(1f); Color rectColor = (focus) ? Colors.BLACK_BG_HOVER : Colors.BLACK_BG_NORMAL; float oldRectAlpha = rectColor.a; rectColor.a *= AnimationEquation.IN_QUAD.calc(alpha); g.setColor(rectColor); g.fillRect(x + 1, y + 1, buttonWidth - 1, buttonHeight - 1); rectColor.a *= 1.25f; g.setColor(rectColor); g.drawRect(x, y, buttonWidth, buttonHeight); rectColor.a = oldRectAlpha; // rank if (focus) { Fonts.LARGE.drawString( rankX, y + (buttonHeight - Fonts.LARGE.getLineHeight()) / 2f, Integer.toString(rank + 1), c ); } // grade image float gradeX = rankX + Fonts.LARGE.getWidth("###"); Image img = getGrade().getMenuImage(); img.setAlpha(alpha); img.draw(gradeX, midY - img.getHeight() / 2f); img.setAlpha(1f); // player float textX = gradeX + img.getWidth() * 1.2f; float textOffset = (buttonHeight - Fonts.LARGE.getLineHeight() - Fonts.MEDIUM.getLineHeight()) / 2f; if (playerName != null) Fonts.LARGE.drawString(textX, y + textOffset, playerName); textOffset += Fonts.LARGE.getLineHeight() - 4; // score Fonts.MEDIUM.drawString( textX, y + textOffset, String.format("Score: %s (%dx)", NumberFormat.getNumberInstance().format(score), combo), c ); // mods StringBuilder sb = new StringBuilder(); for (GameMod mod : GameMod.values()) { if ((mod.getBit() & mods) > 0) { sb.append(mod.getAbbreviation()); sb.append(','); } } if (sb.length() > 0) { sb.setLength(sb.length() - 1); String modString = sb.toString(); Fonts.DEFAULT.drawString(edgeX - Fonts.DEFAULT.getWidth(modString), y + marginY, modString, c); } // accuracy String accuracy = String.format("%.2f%%", getScorePercent()); Fonts.DEFAULT.drawString(edgeX - Fonts.DEFAULT.getWidth(accuracy), y + marginY + Fonts.DEFAULT.getLineHeight(), accuracy, c); // score difference String diff = (prevScore < 0 || score < prevScore) ? "-" : String.format("+%s", NumberFormat.getNumberInstance().format(score - prevScore)); Fonts.DEFAULT.drawString(edgeX - Fonts.DEFAULT.getWidth(diff), y + marginY + Fonts.DEFAULT.getLineHeight() * 2, diff, c); // time since if (getTimeSince() != null) { Image clock = GameImage.HISTORY.getImage(); clock.drawCentered(x + buttonWidth * 1.02f + clock.getWidth() / 2f, midY); Fonts.DEFAULT.drawString( x + buttonWidth * 1.03f + clock.getWidth(), midY - Fonts.DEFAULT.getLineHeight() / 2f, getTimeSince(), c ); } c.a = oldAlpha; }
Example 20
Source File: UserSelectOverlay.java From opsu with GNU General Public License v3.0 | 4 votes |
/** Renders the user creation menu. */ private void renderUserCreate(Graphics g, float alpha) { COLOR_WHITE.a = COLOR_RED.a = alpha; COLOR_GRAY.a = alpha * 0.8f; // title String title = "Add User"; Fonts.XLARGE.drawString( x + (width - Fonts.XLARGE.getWidth(title)) / 2, (int) (y + titleY), title, COLOR_WHITE ); // user button int cy = (int) (y + usersStartY); String caption = "Click the profile below to create it."; Fonts.MEDIUM.drawString(x + (width - Fonts.MEDIUM.getWidth(caption)) / 2, cy, caption, COLOR_WHITE); cy += Fonts.MEDIUM.getLineHeight(); newUserButton.draw(g, alpha); cy += UserButton.getHeight() + Fonts.MEDIUMBOLD.getLineHeight(); // user name String nameHeader = "Name"; Fonts.MEDIUMBOLD.drawString(x + (width - Fonts.MEDIUMBOLD.getWidth(nameHeader)) / 2, cy, nameHeader, COLOR_WHITE); cy += Fonts.MEDIUMBOLD.getLineHeight(); Color textColor = COLOR_WHITE; String name = newUser.getName(); if (name.isEmpty()) { name = "Type a name..."; textColor = COLOR_GRAY; } else if (!UserList.get().isValidUserName(name)) textColor = COLOR_RED; int textWidth = Fonts.LARGE.getWidth(name); int searchTextX = (int) (x + (width - textWidth) / 2); Fonts.LARGE.drawString(searchTextX, cy, name, textColor); cy += Fonts.LARGE.getLineHeight(); g.setColor(textColor); g.setLineWidth(2f); g.drawLine(searchTextX, cy, searchTextX + textWidth, cy); cy += Fonts.MEDIUMBOLD.getLineHeight(); // user icons renderUserIcons(g, newUser.getIconId(), "Icon", cy, alpha); }