Arkadodge/pause.odin

81 lines
1.5 KiB
Odin

package main
import rl "vendor:raylib"
import "core:math/ease"
Pause_Buttons :: enum {
RESUME,
FULLSCREEN,
EXIT
}
pause_strings := [Pause_Buttons]cstring {
.RESUME = "Продолжить",
.FULLSCREEN = "Полный экран",
.EXIT = "Выход"
}
Pause :: struct {
using state: GameState,
list: MenuList(Pause_Buttons)
}
pause_init :: proc(prev: ^GameState = nil) -> ^GameState {
state := new(Pause)
state.variant = state
state.list = MenuList(Pause_Buttons){
position = {-300, 300},
line_size = 60,
font_size = 42,
elements = &pause_strings,
menu_pressed = pause_button_pressed
}
state.update = pause_update
state.draw = pause_draw
state.free = pause_free
state.previous = prev
tween_to(&state.list.position.x, 300, 1, ease.Ease.Back_Out)
return state
}
pause_update :: proc(state: ^GameState, delta: f32) {
menu := transmute(^Pause)state
menu_list_update(&menu.list)
}
pause_button_pressed :: proc(state: ^GameState, el: Pause_Buttons) {
switch el {
case .RESUME:
stack_pop()
case .FULLSCREEN:
case .EXIT:
stack_pop()
stack_pop()
}
}
pause_draw :: proc(state: ^GameState) {
menu := transmute(^Pause)state
if state.previous != nil {
state.previous->draw()
}
TitleFontSize :: 96
TitleSpacing :: 3
TitleText :: "ПАУЗА"
TitleSize := rl.MeasureTextEx(FontTitle, TitleText, TitleFontSize, TitleSpacing)
rl.DrawTextPro(FontTitle, "ПАУЗА", {WINDOWF.x - 50, 50}, {TitleSize.x, 0}, 0, 96, 3, rl.WHITE)
menu_list_draw(&menu.list)
}
pause_free :: proc(state: ^GameState) {
free(state)
}