mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-17 23:45:22 +01:00
Center title above high scores for both orientations
This commit is contained in:
parent
f10c0260c9
commit
2d9de31a38
1 changed files with 16 additions and 3 deletions
|
@ -238,8 +238,14 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
// Remove tetrominos that fell off the screen
|
// Remove tetrominos that fell off the screen
|
||||||
tetrominos.removeAll(tetrominosToRemove)
|
tetrominos.removeAll(tetrominosToRemove)
|
||||||
|
|
||||||
// Draw title with "mint" in mint color
|
// Position title based on orientation for optimal positioning
|
||||||
val titleY = height * 0.4f
|
val titleY = if (resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
// In landscape mode, position in upper third of screen
|
||||||
|
height * 0.3f
|
||||||
|
} else {
|
||||||
|
// In portrait mode, center above high scores
|
||||||
|
height * 0.35f
|
||||||
|
}
|
||||||
|
|
||||||
// Measure each word without spaces
|
// Measure each word without spaces
|
||||||
val pixelWidth = titlePaint.measureText("pixel")
|
val pixelWidth = titlePaint.measureText("pixel")
|
||||||
|
@ -271,7 +277,14 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
|
|
||||||
// Draw high scores using pre-allocated manager
|
// Draw high scores using pre-allocated manager
|
||||||
val highScores: List<HighScore> = highScoreManager.getHighScores()
|
val highScores: List<HighScore> = highScoreManager.getHighScores()
|
||||||
val highScoreY = height * 0.5f
|
|
||||||
|
// Adjust high scores position based on title position
|
||||||
|
val highScoreY = if (resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
height * 0.45f // In landscape, position high scores below title with more space
|
||||||
|
} else {
|
||||||
|
height * 0.5f // In portrait, keep in middle of screen
|
||||||
|
}
|
||||||
|
|
||||||
var lastHighScoreY = highScoreY
|
var lastHighScoreY = highScoreY
|
||||||
if (highScores.isNotEmpty()) {
|
if (highScores.isNotEmpty()) {
|
||||||
// Calculate the starting X position to center the entire block of scores
|
// Calculate the starting X position to center the entire block of scores
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue