Skip to content

Commit dfcc52c

Browse files
committed
Fix more regressions, showcase reorganization
Moved showcase assets to a folder in assets Implemented Win32Window:destroy() Set window title Set polling mode to "wait" rather than "poll" (forgot to reimplement with the new arisu.lua) Close windows at the end of the windows event loop
1 parent 845421e commit dfcc52c

File tree

7 files changed

+22
-5
lines changed

7 files changed

+22
-5
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,18 @@ There are no dependencies used by the library. Pure X11/Win32 and OpenGL.
1818

1919
## Showcase
2020

21-
![showcase](./showcase.png)
21+
![v4](./assets/showcase/v0.4.0.png)
22+
![v1](./assets/showcase/v0.1.0.png)
2223

23-
![windows](./windows.png)
24+
## Running
25+
26+
Set up LuaJIT on your system, clone the repository and run this from the top level.
27+
28+
```bash
29+
luajit ./src/main.lua
30+
```
31+
32+
It should work.
2433

2534
## Attributions
2635

File renamed without changes.
File renamed without changes.

assets/showcase/v0.4.0.png

148 KB
Loading

src/arisu.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function Arisu.run(appStatic)
4646
window.Window.fromEventLoop(eventLoop)
4747

4848
eventLoop:run(function(event, handler)
49+
handler:setMode("wait")
50+
4951
local message = app:event(event, handler)
5052
if message then
5153
local task = app:update(message, event.window)

src/main.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,8 @@ end
795795
---@param window Window
796796
function App:update(message, window)
797797
if message.type == "onWindowCreate" then
798+
window:setTitle("Arisu")
799+
798800
-- Now we can initialize assets for a specific window
799801
self.plugins.render:register(window)
800802
self.plugins.overlay:register(window)

src/window/win32.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ function Win32Window:setTitle(title)
7777
end
7878

7979
function Win32Window:destroy()
80-
print("Warning: Win32Window:destroy is unimplemented")
80+
user32.destroyWindow(self.hwnd)
8181
end
8282

8383
---@class Win32EventLoop: EventLoop
84+
---@field windows table<string, Win32Window>
8485
---@field class user32.WNDCLASSEXA
8586
---@field isActive boolean
8687
---@field currentMode "poll" | "wait"
@@ -105,7 +106,6 @@ function Win32EventLoop.new()
105106
end
106107

107108
local window = self.windows[util.toPointer(hwnd)]
108-
109109
if not window then
110110
return user32.defWindowProc(hwnd, msg, wParam, lParam)
111111
end
@@ -218,7 +218,7 @@ function Win32EventLoop:run(callback)
218218
local msg = user32.newMsg()
219219
while self.isActive do
220220
if self.currentMode == "poll" then
221-
while user32.peekMessage(msg, nil, 0, 0, user32.PM_REMOVE) do
221+
if user32.peekMessage(msg, nil, 0, 0, user32.PM_REMOVE) then
222222
user32.translateMessage(msg)
223223
user32.dispatchMessage(msg)
224224
end
@@ -237,6 +237,10 @@ function Win32EventLoop:run(callback)
237237

238238
callback({ name = "aboutToWait" }, self.handler)
239239
end
240+
241+
for _, window in pairs(self.windows) do
242+
self:close(window)
243+
end
240244
end
241245

242246
return { Window = Win32Window, EventLoop = Win32EventLoop }

0 commit comments

Comments
 (0)