ebiten: replace alias types with ints for better documentation

This commit is contained in:
Hajime Hoshi 2024-09-15 17:17:10 +09:00
parent e90f99bd4a
commit ab414558e8
5 changed files with 30 additions and 30 deletions

View File

@ -19,17 +19,17 @@ import (
) )
// CursorModeType represents a render and coordinate mode of a mouse cursor. // CursorModeType represents a render and coordinate mode of a mouse cursor.
type CursorModeType = ui.CursorMode type CursorModeType int
// CursorModeTypes // CursorModeTypes
const ( const (
CursorModeVisible CursorModeType = ui.CursorModeVisible CursorModeVisible CursorModeType = CursorModeType(ui.CursorModeVisible)
CursorModeHidden CursorModeType = ui.CursorModeHidden CursorModeHidden CursorModeType = CursorModeType(ui.CursorModeHidden)
CursorModeCaptured CursorModeType = ui.CursorModeCaptured CursorModeCaptured CursorModeType = CursorModeType(ui.CursorModeCaptured)
) )
// CursorShapeType represents a shape of a mouse cursor. // CursorShapeType represents a shape of a mouse cursor.
type CursorShapeType = ui.CursorShape type CursorShapeType int
// CursorShapeTypes // CursorShapeTypes
const ( const (

View File

@ -350,7 +350,7 @@ func UpdateStandardGamepadLayoutMappings(mappings string) (bool, error) {
} }
// TouchID represents a touch's identifier. // TouchID represents a touch's identifier.
type TouchID = ui.TouchID type TouchID int
// AppendTouchIDs appends the current touch states to touches, and returns the extended buffer. // AppendTouchIDs appends the current touch states to touches, and returns the extended buffer.
// Giving a slice that already has enough capacity works efficiently. // Giving a slice that already has enough capacity works efficiently.
@ -446,7 +446,7 @@ func (i *inputState) appendTouchIDs(touches []TouchID) []TouchID {
defer i.m.Unlock() defer i.m.Unlock()
for _, t := range i.state.Touches { for _, t := range i.state.Touches {
touches = append(touches, t.ID) touches = append(touches, TouchID(t.ID))
} }
return touches return touches
} }
@ -456,7 +456,7 @@ func (i *inputState) touchPosition(id TouchID) (int, int) {
defer i.m.Unlock() defer i.m.Unlock()
for _, t := range i.state.Touches { for _, t := range i.state.Touches {
if id != t.ID { if id != TouchID(t.ID) {
continue continue
} }
return t.X, t.Y return t.X, t.Y

View File

@ -19,7 +19,7 @@ import (
) )
// A MouseButton represents a mouse button. // A MouseButton represents a mouse button.
type MouseButton = ui.MouseButton type MouseButton int
// MouseButtons // MouseButtons
const ( const (
@ -27,10 +27,10 @@ const (
MouseButtonMiddle MouseButton = MouseButton1 MouseButtonMiddle MouseButton = MouseButton1
MouseButtonRight MouseButton = MouseButton2 MouseButtonRight MouseButton = MouseButton2
MouseButton0 MouseButton = ui.MouseButton0 MouseButton0 MouseButton = MouseButton(ui.MouseButton0)
MouseButton1 MouseButton = ui.MouseButton1 MouseButton1 MouseButton = MouseButton(ui.MouseButton1)
MouseButton2 MouseButton = ui.MouseButton2 MouseButton2 MouseButton = MouseButton(ui.MouseButton2)
MouseButton3 MouseButton = ui.MouseButton3 MouseButton3 MouseButton = MouseButton(ui.MouseButton3)
MouseButton4 MouseButton = ui.MouseButton4 MouseButton4 MouseButton = MouseButton(ui.MouseButton4)
MouseButtonMax MouseButton = MouseButton4 MouseButtonMax MouseButton = MouseButton4
) )

20
run.go
View File

@ -384,7 +384,7 @@ func ScreenSizeInFullscreen() (int, int) {
// //
// CursorMode is concurrent-safe. // CursorMode is concurrent-safe.
func CursorMode() CursorModeType { func CursorMode() CursorModeType {
return ui.Get().CursorMode() return CursorModeType(ui.Get().CursorMode())
} }
// SetCursorMode sets the render and capture mode of the mouse cursor. // SetCursorMode sets the render and capture mode of the mouse cursor.
@ -406,7 +406,7 @@ func CursorMode() CursorModeType {
// //
// SetCursorMode is concurrent-safe. // SetCursorMode is concurrent-safe.
func SetCursorMode(mode CursorModeType) { func SetCursorMode(mode CursorModeType) {
ui.Get().SetCursorMode(mode) ui.Get().SetCursorMode(ui.CursorMode(mode))
} }
// CursorShape returns the current cursor shape. // CursorShape returns the current cursor shape.
@ -415,7 +415,7 @@ func SetCursorMode(mode CursorModeType) {
// //
// CursorShape is concurrent-safe. // CursorShape is concurrent-safe.
func CursorShape() CursorShapeType { func CursorShape() CursorShapeType {
return ui.Get().CursorShape() return CursorShapeType(ui.Get().CursorShape())
} }
// SetCursorShape sets the cursor shape. // SetCursorShape sets the cursor shape.
@ -424,7 +424,7 @@ func CursorShape() CursorShapeType {
// //
// SetCursorShape is concurrent-safe. // SetCursorShape is concurrent-safe.
func SetCursorShape(shape CursorShapeType) { func SetCursorShape(shape CursorShapeType) {
ui.Get().SetCursorShape(shape) ui.Get().SetCursorShape(ui.CursorShape(shape))
} }
// IsFullscreen reports whether the current mode is fullscreen or not. // IsFullscreen reports whether the current mode is fullscreen or not.
@ -528,14 +528,14 @@ func SetVsyncEnabled(enabled bool) {
// FPSModeType is a type of FPS modes. // FPSModeType is a type of FPS modes.
// //
// Deprecated: as of v2.5. Use SetVsyncEnabled instead. // Deprecated: as of v2.5. Use SetVsyncEnabled instead.
type FPSModeType = ui.FPSModeType type FPSModeType int
const ( const (
// FPSModeVsyncOn indicates that the game tries to sync the display's refresh rate. // FPSModeVsyncOn indicates that the game tries to sync the display's refresh rate.
// FPSModeVsyncOn is the default mode. // FPSModeVsyncOn is the default mode.
// //
// Deprecated: as of v2.5. Use SetVsyncEnabled(true) instead. // Deprecated: as of v2.5. Use SetVsyncEnabled(true) instead.
FPSModeVsyncOn FPSModeType = ui.FPSModeVsyncOn FPSModeVsyncOn FPSModeType = FPSModeType(ui.FPSModeVsyncOn)
// FPSModeVsyncOffMaximum indicates that the game doesn't sync with vsync, and // FPSModeVsyncOffMaximum indicates that the game doesn't sync with vsync, and
// the game is updated whenever possible. // the game is updated whenever possible.
@ -546,7 +546,7 @@ const (
// The game's Update is called based on the specified TPS. // The game's Update is called based on the specified TPS.
// //
// Deprecated: as of v2.5. Use SetVsyncEnabled(false) instead. // Deprecated: as of v2.5. Use SetVsyncEnabled(false) instead.
FPSModeVsyncOffMaximum FPSModeType = ui.FPSModeVsyncOffMaximum FPSModeVsyncOffMaximum FPSModeType = FPSModeType(ui.FPSModeVsyncOffMaximum)
// FPSModeVsyncOffMinimum indicates that the game doesn't sync with vsync, and // FPSModeVsyncOffMinimum indicates that the game doesn't sync with vsync, and
// the game is updated only when necessary. // the game is updated only when necessary.
@ -559,7 +559,7 @@ const (
// //
// Deprecated: as of v2.5. Use SetScreenClearedEveryFrame(false) instead. // Deprecated: as of v2.5. Use SetScreenClearedEveryFrame(false) instead.
// See examples/skipdraw for GPU optimization with SetScreenClearedEveryFrame(false). // See examples/skipdraw for GPU optimization with SetScreenClearedEveryFrame(false).
FPSModeVsyncOffMinimum FPSModeType = ui.FPSModeVsyncOffMinimum FPSModeVsyncOffMinimum FPSModeType = FPSModeType(ui.FPSModeVsyncOffMinimum)
) )
// FPSMode returns the current FPS mode. // FPSMode returns the current FPS mode.
@ -568,7 +568,7 @@ const (
// //
// Deprecated: as of v2.5. Use SetVsyncEnabled instead. // Deprecated: as of v2.5. Use SetVsyncEnabled instead.
func FPSMode() FPSModeType { func FPSMode() FPSModeType {
return ui.Get().FPSMode() return FPSModeType(ui.Get().FPSMode())
} }
// SetFPSMode sets the FPS mode. // SetFPSMode sets the FPS mode.
@ -578,7 +578,7 @@ func FPSMode() FPSModeType {
// //
// Deprecated: as of v2.5. Use SetVsyncEnabled instead. // Deprecated: as of v2.5. Use SetVsyncEnabled instead.
func SetFPSMode(mode FPSModeType) { func SetFPSMode(mode FPSModeType) {
ui.Get().SetFPSMode(mode) ui.Get().SetFPSMode(ui.FPSModeType(mode))
} }
// ScheduleFrame schedules a next frame when the current FPS mode is FPSModeVsyncOffMinimum. // ScheduleFrame schedules a next frame when the current FPS mode is FPSModeVsyncOffMinimum.

View File

@ -25,21 +25,21 @@ import (
// //
// Regardless of the resizing mode, an Ebitengine application can still change the window size or make // Regardless of the resizing mode, an Ebitengine application can still change the window size or make
// the window fullscreen by calling Ebitengine functions. // the window fullscreen by calling Ebitengine functions.
type WindowResizingModeType = ui.WindowResizingMode type WindowResizingModeType int
// WindowResizingModeTypes // WindowResizingModeTypes
const ( const (
// WindowResizingModeDisabled indicates the mode to disallow resizing the window by a user. // WindowResizingModeDisabled indicates the mode to disallow resizing the window by a user.
WindowResizingModeDisabled WindowResizingModeType = ui.WindowResizingModeDisabled WindowResizingModeDisabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeDisabled)
// WindowResizingModeOnlyFullscreenEnabled indicates the mode to disallow resizing the window, // WindowResizingModeOnlyFullscreenEnabled indicates the mode to disallow resizing the window,
// but allow to make the window fullscreen by a user. // but allow to make the window fullscreen by a user.
// This works only on macOS so far. // This works only on macOS so far.
// On the other platforms, this is the same as WindowResizingModeDisabled. // On the other platforms, this is the same as WindowResizingModeDisabled.
WindowResizingModeOnlyFullscreenEnabled WindowResizingModeType = ui.WindowResizingModeOnlyFullscreenEnabled WindowResizingModeOnlyFullscreenEnabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeOnlyFullscreenEnabled)
// WindowResizingModeEnabled indicates the mode to allow resizing the window by a user. // WindowResizingModeEnabled indicates the mode to allow resizing the window by a user.
WindowResizingModeEnabled WindowResizingModeType = ui.WindowResizingModeEnabled WindowResizingModeEnabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeEnabled)
) )
// IsWindowDecorated reports whether the window is decorated. // IsWindowDecorated reports whether the window is decorated.
@ -67,14 +67,14 @@ func SetWindowDecorated(decorated bool) {
// //
// WindowResizingMode is concurrent-safe. // WindowResizingMode is concurrent-safe.
func WindowResizingMode() WindowResizingModeType { func WindowResizingMode() WindowResizingModeType {
return ui.Get().Window().ResizingMode() return WindowResizingModeType(ui.Get().Window().ResizingMode())
} }
// SetWindowResizingMode sets the mode in which a user resizes the window. // SetWindowResizingMode sets the mode in which a user resizes the window.
// //
// SetWindowResizingMode is concurrent-safe. // SetWindowResizingMode is concurrent-safe.
func SetWindowResizingMode(mode WindowResizingModeType) { func SetWindowResizingMode(mode WindowResizingModeType) {
ui.Get().Window().SetResizingMode(mode) ui.Get().Window().SetResizingMode(ui.WindowResizingMode(mode))
} }
// IsWindowResizable reports whether the window is resizable by the user's dragging on desktops. // IsWindowResizable reports whether the window is resizable by the user's dragging on desktops.