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"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/cbackend"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
|
|
|
)
|
|
|
|
|
|
|
|
const deviceScaleFactor = 1
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
runtime.LockOSThread()
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserInterface struct {
|
|
|
|
input Input
|
|
|
|
}
|
|
|
|
|
|
|
|
var theUserInterface UserInterface
|
|
|
|
|
|
|
|
func Get() *UserInterface {
|
|
|
|
return &theUserInterface
|
|
|
|
}
|
|
|
|
|
2022-02-06 09:43:52 +01:00
|
|
|
func (u *UserInterface) Run(context Context) error {
|
2021-12-17 07:03:23 +01:00
|
|
|
cbackend.InitializeGame()
|
|
|
|
for {
|
|
|
|
w, h := cbackend.ScreenSize()
|
|
|
|
context.Layout(float64(w), float64(h))
|
|
|
|
|
|
|
|
cbackend.BeginFrame()
|
|
|
|
u.input.update(context)
|
|
|
|
|
|
|
|
if err := context.UpdateFrame(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
cbackend.EndFrame()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-06 09:43:52 +01:00
|
|
|
func (*UserInterface) RunWithoutMainLoop(context Context) {
|
2022-02-06 08:08:22 +01:00
|
|
|
panic("ui: RunWithoutMainLoop is not implemented")
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) DeviceScaleFactor() float64 {
|
|
|
|
return deviceScaleFactor
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) IsFocused() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) ScreenSizeInFullscreen() (int, int) {
|
|
|
|
return 0, 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) ResetForFrame() {
|
|
|
|
}
|
|
|
|
|
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-06 09:43:52 +01:00
|
|
|
func (*UserInterface) FPSMode() FPSMode {
|
|
|
|
return FPSModeVsyncOn
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-02-06 09:43:52 +01:00
|
|
|
func (*UserInterface) SetFPSMode(mode FPSMode) {
|
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-01-10 20:12:02 +01:00
|
|
|
func (*UserInterface) Vibrate(duration time.Duration, magnitude float64) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-02-06 10:30:31 +01:00
|
|
|
func (*UserInterface) Input() *Input {
|
2021-12-17 07:03:23 +01:00
|
|
|
return &theUserInterface.input
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*UserInterface) Window() driver.Window {
|
|
|
|
return nil
|
|
|
|
}
|