forked from AbleOS/ableos
99 lines
2.5 KiB
Plaintext
99 lines
2.5 KiB
Plaintext
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
|
render := @use("../../../libraries/render/src/lib.hb")
|
|
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
|
|
|
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
|
.{new_label, render_label_to_surface, set_label_text, set_color} := horizon_api.widgets.label
|
|
|
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
|
.{Vec2} := stn.math
|
|
|
|
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
|
img := @embed("../../../assets/wallpaper.qoi")
|
|
|
|
main := fn(): int {
|
|
sunset.server.start()
|
|
|
|
screen := render.init(true)
|
|
render.clear(screen, render.black)
|
|
|
|
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
|
|
|
wallpaper := render.image.from(@bitcast(&img))
|
|
if wallpaper == null {
|
|
// stn.panic("Wallpaper not loaded\0")
|
|
return 1
|
|
}
|
|
|
|
mouse_x := 100
|
|
mouse_y := 100
|
|
|
|
text_label := new_label("Hi\0")
|
|
set_color(text_label, sunset.server.DECO_COLOUR, render.black)
|
|
|
|
loop {
|
|
mouse_event := intouch.recieve_mouse_event()
|
|
if mouse_event != null {
|
|
change_x := @as(i16, mouse_event.x_change)
|
|
change_x = change_x << 8
|
|
change_x = change_x >> 8
|
|
|
|
mouse_x += change_x
|
|
if mouse_x <= 0 {
|
|
mouse_x = 0
|
|
}
|
|
if mouse_x >= screen.width - 20 {
|
|
mouse_x = @intcast(screen.width - 21)
|
|
}
|
|
|
|
change_y := @as(i16, mouse_event.y_change)
|
|
change_y = change_y << 8
|
|
change_y = change_y >> 8
|
|
|
|
mouse_y -= change_y
|
|
if mouse_y < 0 {
|
|
mouse_y = 1
|
|
}
|
|
if mouse_y >= screen.height - 20 {
|
|
mouse_y = @intcast(screen.height - 21)
|
|
}
|
|
|
|
if mouse_event.left {
|
|
set_label_text(text_label, "LEFT CLICK\0")
|
|
}
|
|
if mouse_event.middle {
|
|
set_label_text(text_label, "MIDDLE CLICK\0")
|
|
}
|
|
if mouse_event.right {
|
|
set_label_text(text_label, "RIGHT CLICK\0")
|
|
}
|
|
}
|
|
{
|
|
render.clear(screen, render.black)
|
|
render.put_surface(screen, wallpaper, .(0, 0), false)
|
|
|
|
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), sunset.server.DECO_COLOUR)
|
|
}
|
|
|
|
if sunset.server.incoming() {
|
|
sunset.server.collect_frames()
|
|
sunset.server.render_clients(screen)
|
|
}
|
|
|
|
{
|
|
pos := Vec2(uint).(1, screen.height - 21)
|
|
render_label_to_surface(screen, text_label, font, pos)
|
|
render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), sunset.server.DECO_COLOUR)
|
|
}
|
|
|
|
// Mouse cursor
|
|
{
|
|
render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), sunset.server.DECO_COLOUR_DARKER)
|
|
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), sunset.server.DECO_COLOUR)
|
|
}
|
|
|
|
render.sync(screen)
|
|
}
|
|
|
|
return 0
|
|
} |