Skip to content

Commit

Permalink
Moved touchpad size to be set in draw method.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanceewing committed Mar 18, 2024
1 parent d54144d commit 5358bb5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
6 changes: 0 additions & 6 deletions core/src/main/java/com/agifans/agile/Detection.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ else if (game.v3GameSig != null) {
// value for the game ID.
gameId = md5HashString.substring(0, 6).toUpperCase();
}

System.out.print("MD5 Hash: " + md5HashString);
System.out.print(", Game Name: " + gameName);
System.out.print(", Game ID (detected): " + gameId);
System.out.print(", Game ID (in game): " + game.gameId);
System.out.println(", V3 Sig: " + game.v3GameSig);
}
catch (Exception e) {
// Failure in game detection code. Continue with the default unrecognised game values.
Expand Down
24 changes: 13 additions & 11 deletions core/src/main/java/com/agifans/agile/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public GameScreen(Agile agile, AgileRunner agileRunner, DialogHandler dialogHand
fullScreenIcon = new Texture("png/full_screen.png");

// Create the portrait and landscape joystick touchpads.
portraitTouchpad = createTouchpad(200);
landscapeTouchpad = createTouchpad(150);
portraitTouchpad = createTouchpad();
landscapeTouchpad = createTouchpad();

viewportManager = ViewportManager.getInstance();

Expand All @@ -137,7 +137,7 @@ public GameScreen(Agile agile, AgileRunner agileRunner, DialogHandler dialogHand
landscapeInputProcessor.addProcessor(gameScreenInputProcessor);
}

protected Touchpad createTouchpad(int size) {
protected Touchpad createTouchpad() {
Skin touchpadSkin = new Skin();
touchpadSkin.add("touchBackground", new Texture("png/touchBackground.png"));
touchpadSkin.add("touchKnob", new Texture("png/touchKnob.png"));
Expand All @@ -146,9 +146,7 @@ protected Touchpad createTouchpad(int size) {
Drawable touchKnob = touchpadSkin.getDrawable("touchKnob");
touchpadStyle.background = touchBackground;
touchpadStyle.knob = touchKnob;
Touchpad touchpad = new Touchpad(10, touchpadStyle);
touchpad.setSize(size, size);
return touchpad;
return new Touchpad(10, touchpadStyle);
}

public boolean copyPixels() {
Expand Down Expand Up @@ -307,19 +305,23 @@ private void draw(float delta) {
float joyX = 0;
float joyY = 0;
if (viewportManager.isPortrait()) {
// Top of keyboard is: 765 + 125 = 890. Touchpad is 200 high.
// Top of keyboard is: 765 + 125 = 890.
int joyWidth = 200;
int agiScreenBase = (int)(viewportManager.getHeight() - (viewportManager.getWidth() / 1.32));
int midBetweenKeybAndPic = ((agiScreenBase + 890) / 2);
portraitTouchpad.setY(midBetweenKeybAndPic - 100);
portraitTouchpad.setX(1080 - 200 - 10);
portraitTouchpad.setSize(joyWidth, joyWidth);
portraitTouchpad.setY(midBetweenKeybAndPic - (joyWidth / 2));
portraitTouchpad.setX(1080 - joyWidth - 10);
portraitTouchpadStage.act(delta);
portraitTouchpadStage.draw();
joyX = portraitTouchpad.getKnobPercentX();
joyY = portraitTouchpad.getKnobPercentY();
} else {
// Landscape
landscapeTouchpad.setY(viewportManager.getHeight() - (viewportManager.getHeight() / 2) - 75);
landscapeTouchpad.setX(1920 - 150);
int joyWidth = 96;//150;
landscapeTouchpad.setSize(joyWidth, joyWidth);
landscapeTouchpad.setY(viewportManager.getHeight() - (viewportManager.getHeight() / 2) - (joyWidth / 2));
landscapeTouchpad.setX(1920 - joyWidth - 8);
landscapeTouchpadStage.act(delta);
landscapeTouchpadStage.draw();
joyX = landscapeTouchpad.getKnobPercentX();
Expand Down

0 comments on commit 5358bb5

Please sign in to comment.