Display disclaimer on splash screen

This commit is contained in:
drdev
2014-02-27 05:08:17 +00:00
parent e6706d21b9
commit bf36e8bd2a
2 changed files with 24 additions and 10 deletions

View File

@@ -3,6 +3,8 @@ package forge;
import java.util.ArrayList;
import java.util.Stack;
import javax.swing.GroupLayout.Alignment;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
@@ -397,26 +399,25 @@ public class Forge implements ApplicationListener {
}
public void drawText(String text, FSkinFont skinFont, FSkinColor skinColor, float x, float y, float w, float h, boolean wrap, HAlignment horzAlignment, boolean centerVertically) {
BitmapFont font = skinFont.getFont();
font.setColor(skinColor.getColor());
drawText(text, skinFont.getFont(), skinColor.getColor(), x, y, w, h, wrap, horzAlignment, centerVertically);
}
public void drawText(String text, FSkinFont skinFont, Color color, float x, float y, float w, float h, boolean wrap, HAlignment horzAlignment, boolean centerVertically) {
drawText(text, skinFont.getFont(), color, x, y, w, h, wrap, horzAlignment, centerVertically);
}
public void drawText(String text, BitmapFont font, Color color, float x, float y, float w, float h, boolean wrap, HAlignment horzAlignment, boolean centerVertically) {
font.setColor(color);
if (wrap) {
float textHeight = font.getWrappedBounds(text, w).height;
if (h > textHeight && centerVertically) {
y += (h - textHeight) / 2;
}
else if (h == 0) {
h = textHeight;
}
font.drawWrapped(batch, text, adjustX(x), adjustY(y, h), w, horzAlignment);
font.drawWrapped(batch, text, adjustX(x), adjustY(y, 0), w, horzAlignment);
}
else {
float textHeight = font.getMultiLineBounds(text).height;
if (h > textHeight && centerVertically) {
y += (h - textHeight) / 2;
}
else if (h == 0) {
h = textHeight;
}
font.drawMultiLine(batch, text, adjustX(x), adjustY(y, 0), w, horzAlignment);
}
}

View File

@@ -1,13 +1,17 @@
package forge.screens;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.Forge.Graphics;
import forge.assets.FSkinFont;
import forge.toolbox.FContainer;
import forge.toolbox.FProgressBar;
public class SplashScreen extends FContainer {
private TextureRegion background;
private final FProgressBar progressBar;
private FSkinFont disclaimerFont;
public SplashScreen() {
progressBar = add(new FProgressBar());
@@ -29,7 +33,7 @@ public class SplashScreen extends FContainer {
protected void drawBackground(Graphics g) {
if (background == null) { return; }
g.fillRect(FProgressBar.BACK_COLOR, 0, 0, getWidth(), getHeight());
g.fillRect(FProgressBar.SEL_BACK_COLOR, 0, 0, getWidth(), getHeight());
float x, y, w, h;
float backgroundRatio = background.getRegionWidth() / background.getRegionHeight();
@@ -47,5 +51,14 @@ public class SplashScreen extends FContainer {
x = (getWidth() - w) / 2;
}
g.drawImage(background, x, y, w, h);
y += h * 2 / 3;
if (disclaimerFont == null) {
disclaimerFont = FSkinFont.get(9);
}
String disclaimer = "Forge is not affiliated in any way with Wizards of the Coast.\n"
+ "Forge is open source software, released under the GNU Public License.";
g.drawText(disclaimer, disclaimerFont, FProgressBar.SEL_FORE_COLOR,
x, y, w, 0, true, HAlignment.CENTER, false);
}
}