/
676767ap
/
AstroCatGame
Обзор
Документация
Войти
/
676767ap
/
AstroCatGame
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
resolution/linux.go
60 строк
1 KB
Anton Polikarpov
Screens refactoring
02 мар 2024, 17:15
02 мар 2024, 17:15
aa8f287
Код
Авторство
О чём код?
package resolution import ( "astrogame/config" "github.com/hajimehoshi/ebiten/v2" ) type MonitorLinux struct { ResIdx int ResIdxInit int InitWidth int InitHeight int Res *ScreenRes FullScreen bool } func NewMonitorLinux() (*MonitorLinux, bool) { var monitorL MonitorLinux w, h := monitorL.GetResolution() monitorL.ResIdx = 0 monitorL.ResIdxInit = 0 monitorL.InitWidth = w monitorL.InitHeight = h monitorL.Res = &ScreenRes{ Width: config.ScreenWidth, Height: config.ScreenHeight, } monitorL.FullScreen = false ress := ListResolutionsLinux() canSwitch := false for _, res := range ress.Resolutions { if res.Width == config.ScreenWidth && res.Height == config.ScreenHeight { canSwitch = true } } return &monitorL, canSwitch } func (m *MonitorLinux) IsFullScreen() bool { return m.FullScreen } func (m *MonitorLinux) SetFullScreen(b bool) { if b { ebiten.SetFullscreen(true) } else { ebiten.SetFullscreen(false) } m.FullScreen = b } func (m *MonitorLinux) GetCurResolution() (int, *ScreenRes) { return m.ResIdx, m.Res } func (m *MonitorLinux) GetInitResolution() (int, int) { return m.InitWidth, m.InitHeight }