Adds support for Android
This commit is contained in:
@@ -181,7 +181,7 @@ public class CalibrateInputScreen extends BaseAppState
|
||||
this.introCont.attachChild(text);
|
||||
|
||||
this.startButton =
|
||||
GUIUtils.createButton(app.getAssetManager(), this.guiFont,
|
||||
GUIUtils.createButton(app.getAssetManager(), this.guiFont, app.getContext().getTouchInput() != null,
|
||||
"start", "Start");
|
||||
// this.startButton.addClickCommands(this);
|
||||
this.introCont.attachChild(this.startButton);
|
||||
@@ -193,16 +193,16 @@ public class CalibrateInputScreen extends BaseAppState
|
||||
"on the controller you want to calibrate."));
|
||||
|
||||
this.skipButton =
|
||||
GUIUtils.createButton(app.getAssetManager(), this.guiFont,
|
||||
GUIUtils.createButton(app.getAssetManager(), this.guiFont, app.getContext().getTouchInput() != null,
|
||||
"skip", "Skip");
|
||||
|
||||
this.cancelButton =
|
||||
GUIUtils.createButton(app.getAssetManager(), this.guiFont,
|
||||
GUIUtils.createButton(app.getAssetManager(), this.guiFont, app.getContext().getTouchInput() != null,
|
||||
"cancel", "Cancel");
|
||||
this.introCont.attachChild(this.cancelButton);
|
||||
|
||||
this.restartButton =
|
||||
GUIUtils.createButton(app.getAssetManager(), this.guiFont,
|
||||
GUIUtils.createButton(app.getAssetManager(), this.guiFont, app.getContext().getTouchInput() != null,
|
||||
"close", "Close Application");
|
||||
|
||||
this.gui.attachChild(this.introCont);
|
||||
|
||||
@@ -42,18 +42,24 @@ public class GUIUtils
|
||||
* to trigger events.
|
||||
* @param assets - The application asset manager.
|
||||
* @param guiFont - The font to use for the button.
|
||||
* @param isMobile - Whether or not the mobile size increase should be used.
|
||||
* @param id - The button ID. This is used to identify which button was
|
||||
* pressed later on.
|
||||
* @param content - The text that will display in the button.
|
||||
* @return A node containing the button elements.
|
||||
*/
|
||||
public static Node createButton(AssetManager assets, BitmapFont guiFont,
|
||||
String id, String content)
|
||||
boolean isMobile, String id, String content)
|
||||
{
|
||||
final float MOBILE_SIZE = 30F;
|
||||
BitmapText buttonText;
|
||||
Geometry buttonBackground;
|
||||
Node button = new Node();
|
||||
buttonText = guiFont.createLabel(content);
|
||||
if (isMobile)
|
||||
{
|
||||
buttonText.setSize(MOBILE_SIZE);
|
||||
}
|
||||
buttonText.setUserData(BUTTON_ID, id);
|
||||
buttonText.setBox(new Rectangle(0, 0, buttonText.getLineWidth(),
|
||||
buttonText.getLineHeight()));
|
||||
@@ -78,7 +84,7 @@ public class GUIUtils
|
||||
/**
|
||||
* Call this method from a mouse listener to search the provided node for
|
||||
* any buttons created with
|
||||
* {@link #createButton(AssetManager, BitmapFont, String, String)} and
|
||||
* {@link #createButton(AssetManager, BitmapFont, boolean, String, String)} and
|
||||
* returns their ID.
|
||||
* @param gui - The GUI to search.
|
||||
* @param cursor - The position of the mouse cursor.
|
||||
@@ -112,7 +118,7 @@ public class GUIUtils
|
||||
|
||||
results = new CollisionResults();
|
||||
ray = new Ray(new Vector3f(cursor.x, cursor.y, 0),
|
||||
new Vector3f(cursor.x, cursor.y, 1));
|
||||
new Vector3f(0, 0, 1));
|
||||
gui.collideWith(ray, results);
|
||||
for (CollisionResult result : results)
|
||||
{
|
||||
@@ -190,9 +196,9 @@ public class GUIUtils
|
||||
{
|
||||
Quad quad = ((Quad) ((Geometry) ((Node) node).getChild(0))
|
||||
.getMesh());
|
||||
node.setLocalTranslation(-quad.getWidth() / 2F,
|
||||
-totalHeight - 10, 0);
|
||||
totalHeight += quad.getHeight() + 10;
|
||||
node.setLocalTranslation(-quad.getWidth() / 2F,
|
||||
-totalHeight - 10, 0);
|
||||
totalHeight += quad.getHeight() + 10;
|
||||
}
|
||||
}
|
||||
return totalHeight;
|
||||
|
||||
@@ -689,6 +689,7 @@ public class JoystickPreviewScreen extends BaseAppState
|
||||
{
|
||||
this.gamepadHeaders[i] = GUIUtils.createButton(
|
||||
this.getApplication().getAssetManager(), this.guiFont,
|
||||
this.getApplication().getContext().getTouchInput() != null,
|
||||
"gamepad" + i, "Gamepad " +
|
||||
this.getApplication().getInputManager()
|
||||
.getJoysticks()[i].getJoyId());
|
||||
@@ -741,6 +742,7 @@ public class JoystickPreviewScreen extends BaseAppState
|
||||
*/
|
||||
private void setLabels(Joystick joy)
|
||||
{
|
||||
int offset = this.getApplication().getContext().getTouchInput() != null ? 10: 0;
|
||||
/*
|
||||
* Removes the old labels.
|
||||
*/
|
||||
@@ -761,9 +763,11 @@ public class JoystickPreviewScreen extends BaseAppState
|
||||
/*
|
||||
* The name of the gamepad.
|
||||
*/
|
||||
this.labels[joy.getJoyId()][0] = this.guiFont.createLabel(
|
||||
"Gamepad " + joy.getJoyId() + ": " + joy.getName());
|
||||
this.labels[joy.getJoyId()][0].setLocalTranslation(20, -25, 0);
|
||||
// this.labels[joy.getJoyId()][0] = this.guiFont.createLabel(
|
||||
// "Gamepad " + joy.getJoyId() + ": " + joy.getName());
|
||||
this.labels[joy.getJoyId()][0] =
|
||||
this.guiFont.createLabel(joy.getName());
|
||||
this.labels[joy.getJoyId()][0].setLocalTranslation(20, -25 - offset, 0);
|
||||
this.gamepadCont[joy.getJoyId()]
|
||||
.attachChild(this.labels[joy.getJoyId()][0]);
|
||||
/*
|
||||
@@ -771,11 +775,12 @@ public class JoystickPreviewScreen extends BaseAppState
|
||||
* index of the axis, its given name, its logical ID after
|
||||
* joystick remapping has occurred, and the axis index again.
|
||||
* TODO - Whenever I add the " Gamepad X: " part to the previous
|
||||
* label, this one displays all funky.
|
||||
* label, this one displays all funky. Also, the lag gets really
|
||||
* bad.
|
||||
*/
|
||||
this.labels[joy.getJoyId()][1] = this.guiFont
|
||||
.createLabel("Axis Index: Axis Name (logical ID, axis ID)");
|
||||
this.labels[joy.getJoyId()][1].setLocalTranslation(20, -50, 0);
|
||||
this.labels[joy.getJoyId()][1].setLocalTranslation(20, -50 - offset, 0);
|
||||
this.gamepadCont[joy.getJoyId()]
|
||||
.attachChild(this.labels[joy.getJoyId()][1]);
|
||||
/*
|
||||
@@ -793,7 +798,7 @@ public class JoystickPreviewScreen extends BaseAppState
|
||||
(i) + ": " + axis.getName() + " (" +
|
||||
axis.getLogicalId() + ", " +
|
||||
axis.getAxisId() + "): ");
|
||||
label.setLocalTranslation(20, -25 * (i + 3), 0);
|
||||
label.setLocalTranslation(20, -25 * (i + 3) - offset, 0);
|
||||
this.labels[joy.getJoyId()][i * 2 + 1] = label;
|
||||
|
||||
/*
|
||||
@@ -835,7 +840,7 @@ public class JoystickPreviewScreen extends BaseAppState
|
||||
this.labels[joy.getJoyId()][firstButtonIndex].setLocalTranslation(
|
||||
this.getScreenSize().x -
|
||||
this.labels[joy.getJoyId()][firstButtonIndex]
|
||||
.getLineWidth(), -50, 0);
|
||||
.getLineWidth(), -50 - offset, 0);
|
||||
this.gamepadCont[joy.getJoyId()]
|
||||
.attachChild(this.labels[joy.getJoyId()][firstButtonIndex]);
|
||||
|
||||
@@ -855,7 +860,7 @@ public class JoystickPreviewScreen extends BaseAppState
|
||||
BitmapText label2 = this.guiFont.createLabel("false");
|
||||
label2.setLocalTranslation(
|
||||
this.getScreenSize().x - label2.getLineWidth(),
|
||||
-25 * (i + 3), 0);
|
||||
-25 * (i + 3) - offset, 0);
|
||||
|
||||
/*
|
||||
* The name and information for the button.
|
||||
@@ -914,7 +919,7 @@ public class JoystickPreviewScreen extends BaseAppState
|
||||
for (int i = 0, l = this.gamepadHeaders.length; i < l; i++)
|
||||
{
|
||||
button = this.gamepadHeaders[i];
|
||||
button.setLocalTranslation(128 * i, 0, 0);
|
||||
button.setLocalTranslation((this.getApplication().getContext().getTouchInput() != null ? 192 : 128) * i, 0, 0);
|
||||
}
|
||||
}
|
||||
if (this.gamepadView != null)
|
||||
|
||||
Reference in New Issue
Block a user