2021-12-17 07:03:23 +01:00
|
|
|
// Copyright 2021 The Ebiten Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
//go:build ebitencbackend
|
|
|
|
// +build ebitencbackend
|
|
|
|
|
2022-02-06 08:08:22 +01:00
|
|
|
package ui
|
2021-12-17 07:03:23 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/cbackend"
|
|
|
|
)
|
|
|
|
|
|
|
|
const deviceScaleFactor = 1
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
runtime.LockOSThread()
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserInterface struct {
|
2022-02-13 08:30:33 +01:00
|
|
|
context *contextImpl
|
|
|
|
input Input
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var theUserInterface UserInterface
|
|
|
|
|
|
|
|
func Get() *UserInterface {
|
|
|
|
return &theUserInterface
|
|
|
|
}
|
|
|
|
|
2022-02-13 12:18:41 +01:00
|
|
|
func (u *UserInterface) Run(game Game) error {
|
|
|
|
u.context = newContextImpl(game)
|
2021-12-17 07:03:23 +01:00
|
|
|
cbackend.InitializeGame()
|
|
|
|
for {
|
|
|
|
cbackend.BeginFrame()
|
2022-02-13 08:30:33 +01:00
|
|
|
u.input.update(u.context)
|
2021-12-17 07:03:23 +01:00
|
|
|
|
2022-02-13 18:48:28 +01:00
|
|
|
w, h := cbackend.ScreenSize()
|
2022-03-21 08:59:53 +01:00
|
|
|
if err := u.context.updateFrame(graphicsDriver(), float64(w), float64(h), deviceScaleFactor); err != nil {
|
2021-12-17 07:03:23 +01:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
cbackend.EndFrame()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) DeviceScaleFactor() float64 {
|
|
|
|
return deviceScaleFactor
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) IsFocused() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) ScreenSizeInFullscreen() (int, int) {
|
|
|
|
return 0, 0
|
|
|
|
}
|
|
|
|
|
2022-02-13 12:02:49 +01:00
|
|
|
func (*UserInterface) resetForTick() {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-02-06 09:43:52 +01:00
|
|
|
func (*UserInterface) CursorMode() CursorMode {
|
|
|
|
return CursorModeHidden
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-02-06 09:43:52 +01:00
|
|
|
func (*UserInterface) SetCursorMode(mode CursorMode) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-02-06 09:43:52 +01:00
|
|
|
func (*UserInterface) CursorShape() CursorShape {
|
|
|
|
return CursorShapeDefault
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-02-06 09:43:52 +01:00
|
|
|
func (*UserInterface) SetCursorShape(shape CursorShape) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) IsFullscreen() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) SetFullscreen(fullscreen bool) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) IsRunnableOnUnfocused() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) SetRunnableOnUnfocused(runnableOnUnfocused bool) {
|
|
|
|
}
|
|
|
|
|
2022-02-13 09:23:52 +01:00
|
|
|
func (*UserInterface) SetFPSMode(mode FPSModeType) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) ScheduleFrame() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) IsScreenTransparent() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) SetScreenTransparent(transparent bool) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) SetInitFocused(focused bool) {
|
|
|
|
}
|
|
|
|
|
2022-02-06 10:30:31 +01:00
|
|
|
func (*UserInterface) Input() *Input {
|
2021-12-17 07:03:23 +01:00
|
|
|
return &theUserInterface.input
|
|
|
|
}
|
|
|
|
|
2022-02-06 12:02:03 +01:00
|
|
|
func (*UserInterface) Window() *Window {
|
|
|
|
return &Window{}
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|