Add back button to Thai, Korean, and Japanese screens
This commit is contained in:
@@ -95,6 +95,20 @@ func main() {
|
|||||||
|
|
||||||
buttons := []*Button{&thaiBtn, &koreanBtn, &japaneseBtn}
|
buttons := []*Button{&thaiBtn, &koreanBtn, &japaneseBtn}
|
||||||
|
|
||||||
|
// Create back button
|
||||||
|
backBtn := Button{
|
||||||
|
Bounds: rl.Rectangle{
|
||||||
|
X: float32(20),
|
||||||
|
Y: float32(20),
|
||||||
|
Width: float32(100),
|
||||||
|
Height: float32(40),
|
||||||
|
},
|
||||||
|
Text: "Back",
|
||||||
|
Color: rl.LightGray,
|
||||||
|
Scale: 1.0,
|
||||||
|
Action: ScreenMenu,
|
||||||
|
}
|
||||||
|
|
||||||
// Current screen state
|
// Current screen state
|
||||||
currentScreen := ScreenMenu
|
currentScreen := ScreenMenu
|
||||||
prevScreen := ScreenMenu
|
prevScreen := ScreenMenu
|
||||||
@@ -226,6 +240,34 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update button states and handle clicks
|
// Update button states and handle clicks
|
||||||
|
// Handle back button on language screens
|
||||||
|
if currentScreen != ScreenMenu {
|
||||||
|
backBtn.Hovered = rl.CheckCollisionPointRec(mousePos, backBtn.Bounds)
|
||||||
|
|
||||||
|
// Handle click animation for back button
|
||||||
|
if backBtn.Clicked {
|
||||||
|
backBtn.Scale += 0.05
|
||||||
|
if backBtn.Scale >= 1.1 {
|
||||||
|
backBtn.Clicked = false
|
||||||
|
}
|
||||||
|
} else if backBtn.Scale > 1.0 {
|
||||||
|
backBtn.Scale -= 0.05
|
||||||
|
if backBtn.Scale < 1.0 {
|
||||||
|
backBtn.Scale = 1.0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
backBtn.Scale = 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle back button click
|
||||||
|
if backBtn.Hovered && rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||||
|
backBtn.Clicked = true
|
||||||
|
backBtn.Scale = 0.95
|
||||||
|
currentScreen = ScreenMenu
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update main menu buttons
|
||||||
for _, btn := range buttons {
|
for _, btn := range buttons {
|
||||||
btn.Hovered = rl.CheckCollisionPointRec(mousePos, btn.Bounds)
|
btn.Hovered = rl.CheckCollisionPointRec(mousePos, btn.Bounds)
|
||||||
|
|
||||||
@@ -291,8 +333,28 @@ func main() {
|
|||||||
// Language screens
|
// Language screens
|
||||||
state := languageStates[currentScreen]
|
state := languageStates[currentScreen]
|
||||||
|
|
||||||
|
// Draw back button
|
||||||
|
scaledWidth := backBtn.Bounds.Width * backBtn.Scale
|
||||||
|
scaledHeight := backBtn.Bounds.Height * backBtn.Scale
|
||||||
|
scaledX := backBtn.Bounds.X - (scaledWidth-backBtn.Bounds.Width)/2
|
||||||
|
scaledY := backBtn.Bounds.Y - (scaledHeight-backBtn.Bounds.Height)/2
|
||||||
|
|
||||||
|
// Draw button with animation
|
||||||
|
if backBtn.Hovered {
|
||||||
|
rl.DrawRectangleRec(rl.Rectangle{X: scaledX, Y: scaledY, Width: scaledWidth, Height: scaledHeight}, rl.DarkGray)
|
||||||
|
} else {
|
||||||
|
rl.DrawRectangleRec(rl.Rectangle{X: scaledX, Y: scaledY, Width: scaledWidth, Height: scaledHeight}, backBtn.Color)
|
||||||
|
}
|
||||||
|
rl.DrawRectangleLinesEx(rl.Rectangle{X: scaledX, Y: scaledY, Width: scaledWidth, Height: scaledHeight}, 2, rl.Black)
|
||||||
|
|
||||||
|
// Draw text
|
||||||
|
textWidth := rl.MeasureText(backBtn.Text, 20)
|
||||||
|
textX := int32(scaledX) + int32(scaledWidth)/2 - textWidth/2
|
||||||
|
textY := int32(scaledY) + int32(scaledHeight)/2 - 10
|
||||||
|
rl.DrawText(backBtn.Text, textX, textY, 20, rl.Black)
|
||||||
|
|
||||||
// Draw title
|
// Draw title
|
||||||
rl.DrawText(state.Title, 20, 20, 30, state.Color)
|
rl.DrawText(state.Title, 140, 20, 30, state.Color)
|
||||||
rl.DrawText("Press ESC to return to menu", screenWidth-200, 20, 20, rl.Black)
|
rl.DrawText("Press ESC to return to menu", screenWidth-200, 20, 20, rl.Black)
|
||||||
|
|
||||||
// Grid layout
|
// Grid layout
|
||||||
@@ -331,10 +393,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle ESC key
|
|
||||||
if rl.IsKeyPressed(rl.KeyEscape) {
|
|
||||||
currentScreen = ScreenMenu
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw scroll hint
|
// Draw scroll hint
|
||||||
rl.DrawText("Use mouse wheel to scroll", screenWidth/2-100, screenHeight-30, 16, rl.Gray)
|
rl.DrawText("Use mouse wheel to scroll", screenWidth/2-100, screenHeight-30, 16, rl.Gray)
|
||||||
|
|||||||
Reference in New Issue
Block a user