Commit Graph

51 Commits

Author SHA1 Message Date
Hajime Hoshi
2bdef2e8c4 restorable: Add an explicit way to detect context-lost
isTexture was used to detect context-lost and called every frame.
This was not good for performance.

This change adds a way to notify context-lost from the WebGL
handlers directly, and the package restorable uses it instead of
calling (*Image).isInvalaidated.

Fixes #1175
2020-05-30 20:29:15 +09:00
Hajime Hoshi
7ccc29e3c7 uidriver/js: Clean up 2020-05-19 04:08:33 +09:00
Hajime Hoshi
be1a8bddbf uidriver/js: Bug fix: Create goroutine for a function passed to rAF
This is necessary not to cause dead-lock.

Updates #1161
2020-05-19 03:28:20 +09:00
Hajime Hoshi
8777140e91 driver: Simplify UIContext.Update 2020-04-03 00:18:27 +09:00
Hajime Hoshi
a718ddbf7e driver: Add UIDriver.Draw
This is a preparation for XNA.

Updates #1078
2020-04-01 02:55:50 +09:00
Hajime Hoshi
7b5fb0a0d0 ui: Bug fix: The window was not shown on the secondary monitor on launching
This change changes the behavior of WindowPosition /
SetWindowPosition. The window position is now a relative position
and the origin position is the left-upper of the current monitor.

Fixes #1115
2020-03-28 19:51:47 +09:00
Hajime Hoshi
978ee26898 ui: Add function aliases *OnUnfocused for *InBackground
Now a window can be floating with SetWindowFloating, the functions
that have suffix 'IsBackground' seems misleading. However, we
cannot rename them due to backward compatibility. Then, let's add
aliases and revisit them when updating the major version of Ebiten.

Fixes #1102
2020-03-21 00:42:00 +09:00
Hajime Hoshi
56358fd0c4 ui: Rename IsForeground -> IsFocused
Updates #1102
2020-03-21 00:12:47 +09:00
Hajime Hoshi
682f454fc2 input: Refactoring: Rename variables 2020-02-19 10:52:58 +09:00
Hajime Hoshi
d59aea1db1 driver: Remove the return value from RunWithoutMainLoop 2020-02-11 23:56:53 +09:00
Hajime Hoshi
c927d33457 mobile/ebitenmobileview: Use the common uiContext for layouting
This means that the whole offscreen is cleared correctly.

This change is a little breaking change: SetScreenSize or other
functions no longer works on ebitenmobile. Use Layout instead.

Fixes #1019
2020-02-11 19:40:47 +09:00
Hajime Hoshi
099ce1b3b4 Revert "ui: Add SetInitFocused"
This reverts commit bb04fc8a29.

Reason: glfw.Focused / glfw.FocusOnShow did not work

Updates #769
2020-02-10 01:10:40 +09:00
Hajime Hoshi
bb04fc8a29 ui: Add SetInitFocused
Updates #769
2020-02-09 23:45:59 +09:00
Hajime Hoshi
32471af18f uidriver/js: Ensure that the checking-audio loop is finished when the game is finished
After the game loop is finished, any goroutines should not exist.
Otherwise, 'Go program has already exited' error can happen on
Wasm.

This change ensures that the goroutines are finished when the game
is finished. Note that time.Sleep was required to ensure that the
(*time.Ticker) ends.

Fixes #1027
2020-02-09 03:39:08 +09:00
Hajime Hoshi
d6d17a7e85 uidriver/js: Implement GamepadSDLID
Fixes #1053
2020-02-05 00:00:00 +09:00
Hajime Hoshi
38f49c3768 uidriver/js: Implement IsForeground
Updates #1037
2020-01-21 23:56:57 +09:00
Zachary Burkett
6686044452 ui: Add IsForeground API to glfw driver (#1058)
Updates #1037
2020-01-16 10:47:23 +09:00
Hajime Hoshi
b4819c4523
input: Rename GamepadGUID -> GamepadSDLID (#1049)
Gamepad GUID is a SDL specific notion and, strictly speaking,
they are not GUID (UUID) since they don't follow UUID's
specifications.

Renaming the function makes the situation clearer.

Updates #1048
2020-01-11 15:50:37 +09:00
Jake Bentvelzen
c17946bb82 ui: Add GamepadGUID and GamepadName functions (#1035)
Fixes #1034
2020-01-09 22:11:32 +09:00
Hajime Hoshi
982b7d6ddc driver: Let UI have Graphics
Now UIs own the implementation of Graphics.

Updates #1026
2020-01-03 18:32:27 +09:00
Hajime Hoshi
9ed8279fc8 driver: Add interface Window 2019-12-25 00:24:21 +09:00
Hajime Hoshi
7d56e4335e ui: Add RunGame, WindowSize and SetWindowSize
This change introduces the new APIs RunGame, WindowSize and
SetWindowSize. These new APIs hides the notion of 'scale', and is
more flexible with the outside size change. This means that we can
introduce a resizable window.

This change also adds -legacy flag to examples/windowsize. If the
flag is off, the new APIs are used.

This change deprecates these functions since the notion of 'scale'
is deprecated:

  * ScreenScale
  * ScreenSizeInFullscreen
  * SetScreenScale
  * SetScreenSize

Fixes #943, #571
Updates #320
2019-12-22 03:35:31 +09:00
Hajime Hoshi
57d527bea2 driver: Remove 'title' argument from UI.Run 2019-12-22 01:41:51 +09:00
Hajime Hoshi
8b995b086b driver: Remove some arguments from UI.Run 2019-12-21 22:52:23 +09:00
Hajime Hoshi
8013fef9ea uidriver: Bug fix: Needed to implement MonitorPosition 2019-12-21 21:15:58 +09:00
Hajime Hoshi
85cbc7e56b Enable to compile Ebiten on js/wasm with Go 1.14
Fixes #1024
2019-12-19 00:45:53 +09:00
Hajime Hoshi
bda11b0e17 driver: Add UI.SetWindowSize and UIContext.Layout
This is a preparation to introduce RunGame function.

Updates # 943 (Fix this line before committing)
2019-12-15 02:29:43 +09:00
Hajime Hoshi
d8f02cf03e uidriver/js: Bug fix: Compile error on CursorMode 2019-12-14 12:54:21 +09:00
Zachary Burkett
ed19d6fae9 Add cursor capture functionality (#1016)
Fixes #1016
2019-12-14 12:30:03 +09:00
Hajime Hoshi
8e9f5b9535 driver: Remove Suspend/ResumeAudio from UIContext 2019-12-08 16:17:02 +09:00
Hajime Hoshi
0ec447e0d0 ui: Add SetScreenTransparent / IsScreenTransparent
Fixes #1001
2019-12-01 03:31:32 +09:00
Hajime Hoshi
9b2f864fc8 ui: Add SetWindowPosition(x, y int)
Fixes #936
2019-11-30 23:22:39 +09:00
Hajime Hoshi
c021d6be6a ui: Add WindowPosition()
Fixes #936
2019-11-30 22:37:56 +09:00
Hajime Hoshi
49a5a2bf4e uidriver/js: Bug fix: Needed to initialize pseudoScale with the given scale
Updates #960, #973
2019-10-27 17:16:49 +09:00
Hajime Hoshi
e7611139c3 uidriver/js: Bug fix: Watch the state regularly instead of events
visibilitystate is sometimes not called and in this case the app
does not come back.

This fix creates another goroutine to watch the state, and remove
event handlers.

Fixes #961
2019-10-21 00:04:07 +09:00
Hajime Hoshi
43a8881ab8 uidriver/ui: Reduce calls of syscall/js 2019-10-16 02:56:58 +09:00
Hajime Hoshi
72248fa3ef ui: Bug fix: Focus canvas explicitly on input
Fixes #961
2019-10-15 23:57:16 +09:00
Hajime Hoshi
75721e6fc1 ui: Auto scaling on browsers
This change forces Ebiten apps on browsers 'fullscreen' mode.
After this change, 'scale' value is no longer used on browsers.

Note that this breaks backward compatibility, but as long as the
game works in an iframe, this should not be problematic.

Fixes #960
2019-10-15 00:02:02 +09:00
Hajime Hoshi
30c185f254 uidriver/js: Bug fix: context must not be accessed before loop 2019-10-14 02:41:04 +09:00
Hajime Hoshi
05f4ca2a4d input: Refactoring: nameToJSKeyCodes -> nameToJSKeyCode 2019-09-02 00:30:17 +09:00
Hajime Hoshi
83b2d4b112 input: driver.Key now distinguishes left/right modifier keys
This is a preparation for event package, that will have key enum.

Updates #926
2019-09-01 23:49:00 +09:00
Hajime Hoshi
10fb5e33be Replace GopherWasm with syscall/js
Fixes #857
2019-05-01 17:28:00 +09:00
Hajime Hoshi
865523048d uidriver/js: Bug fix: Touches were not updated correctly
Fixes #846
2019-04-15 03:01:02 +09:00
Hajime Hoshi
db689f4e50 driver: Remove UI.Loop and add UI.RunWithoutMainLoop 2019-04-09 21:55:59 -04:00
Hajime Hoshi
24fdcdd8e4 uidriver: Rename updateGraphics -> updateSize 2019-04-08 23:49:31 -04:00
Hajime Hoshi
f6367308fc driver: Rename GraphicsContext -> UIContext 2019-04-08 23:28:08 -04:00
Hajime Hoshi
aecfd6b13d uidriver: Remove dependency on hooks package 2019-04-08 23:13:44 -04:00
Hajime Hoshi
0aa3135082 driver: Remove UI.AdjustPosition 2019-04-07 19:31:49 +09:00
Hajime Hoshi
26c32d36b5 uidriver: Move input implementation to uidrivers 2019-04-07 19:16:00 +09:00
Hajime Hoshi
a1697feeb1 driver: Add UI.Input() 2019-04-07 18:37:54 +09:00