Add desk components 466-485 and icon.Bomb
Twenty pieces of a retro desktop: Desktop, DesktopIcon, Taskbar, StartMenu, AppWindow, Calculator, Notepad, Minesweeper, ControlPanel, TrayIcons, ShutdownScreen, BootScreen, Screensaver, Snake, Dock, RunDialog, DiskDefrag, WallpaperPicker, ClipboardPanel and LockScreen. The calculator really adds up and calls division by zero GAME OVER; Minesweeper and Snake are playable, first click always safe; START cascades its submenus without moving the rows already open; windows drag by whole dots; the screensaver's logo changes color at each wall and sparkles in a corner; the defragmenter is oddly soothing. Clocks that step back hold at zero, and typed or copied text never reaches the log. icon.Bomb is the new 12x12 mine.
This commit is contained in:
39 files changed
+4120
-2
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package desk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||||
)
|
||||
|
||||
type ShutdownScreenOptions struct {
|
||||
// Width and Height are dots; zeros mean 320 by 200.
|
||||
Width, Height int
|
||||
}
|
||||
|
||||
// ShutdownScreen says it is safe to turn off the computer.
|
||||
func ShutdownScreen(c *ui.Context, o ShutdownScreenOptions) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := pixel.Or("ShutdownScreen Width", o.Width, 320), pixel.Or("ShutdownScreen Height", o.Height, 200)
|
||||
s := k.Msg("safe_to_turn_off")
|
||||
lines := pixel.Wrap(s, (w-16)/2, 0)
|
||||
if len(lines)*2*pixel.LineHeight > h-16 {
|
||||
panic(fmt.Sprintf("desk: ShutdownScreen %d×%d is too small for its words", w, h))
|
||||
}
|
||||
return ui.Box(c).Size(k.D(w), k.D(h)).Role(ui.RoleText).Label(s).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
g := k.Canvas(p, r)
|
||||
g.Rect(0, 0, w, h, pixel.Well)
|
||||
top := (h - len(lines)*2*pixel.LineHeight) / 2
|
||||
for i, l := range lines {
|
||||
g.Text((w-2*pixel.Measure(l))/2, top+i*2*pixel.LineHeight, l, pixel.Warn, 2)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user