Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FXGLDefaultMenu layout is not responsive #1021 #1356

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

23 changes: 20 additions & 3 deletions fxgl/src/main/kotlin/com/almasb/fxgl/app/scene/FXGLDefaultMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ import java.util.function.Supplier
*
* @author Almas Baimagambetov (AlmasB) (almaslvl@gmail.com)
*/

// CONSTANTS
private const val BUTTON_WIDTH = 200; // Size from FXGLButton.java
private const val MENU_PADDING = 50;
private const val MAX_CONTENT_SIZE = 500.0 // Based on Credits Box.
open class FXGLDefaultMenu(type: MenuType) : FXGLMenu(type) {

companion object {
Expand Down Expand Up @@ -89,13 +94,25 @@ open class FXGLDefaultMenu(type: MenuType) : FXGLMenu(type) {
else
createMenuBodyGameMenu()

val menuX = 50.0
val menuY = appHeight / 2.0 - menu.layoutHeight / 2
var menuX = 0.0
val menuY = appHeight / 2.0 - menu.layoutHeight / 2;
var menuContentX = 0.0

if (appWidth >= 1200)
{
menuX = appWidth / 2.0 - BUTTON_WIDTH - MENU_PADDING;
menuContentX = appWidth / 2.0 + MENU_PADDING;
}
else
{
menuX = (appWidth - (BUTTON_WIDTH + MENU_PADDING * 2 + MAX_CONTENT_SIZE)) / 2
menuContentX = menuX + BUTTON_WIDTH + MENU_PADDING * 2
}

menuRoot.translateX = menuX
menuRoot.translateY = menuY

menuContentRoot.translateX = appWidth - 500.0
menuContentRoot.translateX = menuContentX
menuContentRoot.translateY = menuY

initParticles()
Expand Down