Twenty account components: SettingsList, OptionCycler, KeyBindings, ControllerMap, ProfileCard, CharacterCreator, LoginForm, PasswordGrid, SessionList, LanguagePicker, PalettePicker, VolumeMixer, DifficultySelect, AccessibilityOptions, AccountSwitcher, PlayerSelect, TwoFactor, About, PatchNotes and FeedbackForm. The components never check credentials, and no secret reaches the log: LoginForm reports Submitted and the caller counts Failures; each new failure clears the password, refocuses it, shakes the form and names no field. TwoFactor builds on input.PinInput and drains an epoch-aligned period bar. PalettePicker draws each tile in its own palette on a pixel.Pad grid. pixel.Settings.Reduce stills motion like the system preference, the micro font gains '?', display.Face draws avatar faces anywhere, and input.PinInput pastes on Cmd+V as native hosts send it.
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package account
|
||
|
||
import (
|
||
"fmt"
|
||
"log/slog"
|
||
|
||
"github.com/egoist/mygo/ui"
|
||
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/input"
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||
)
|
||
|
||
// Access is how a player wants motion and dots.
|
||
type Access struct {
|
||
// Reduce goes to pixel.Settings.Reduce, Dot to Settings.Dot.
|
||
Reduce bool
|
||
Dot int
|
||
}
|
||
|
||
type AccessibilityOptionsOptions struct {
|
||
Disabled bool
|
||
}
|
||
|
||
type AccessibilityOptionsResult struct {
|
||
Element *ui.Element
|
||
Changed bool
|
||
}
|
||
|
||
// AccessibilityOptions sets Reduce Motion and the dot size, 1–4.
|
||
func AccessibilityOptions(c *ui.Context, text string, a *Access, o AccessibilityOptionsOptions) AccessibilityOptionsResult {
|
||
k := pixel.K(c)
|
||
if a.Dot < 1 || a.Dot > 4 {
|
||
panic(fmt.Sprintf("account: AccessibilityOptions dot %d outside 1–4", a.Dot))
|
||
}
|
||
var res AccessibilityOptionsResult
|
||
res.Element = ui.Column(c).Gap(k.D(6)).Role(ui.RoleGroup).Label(text).Children(func() {
|
||
reduce := input.Switch(c, k.Msg("reduce_motion"), &a.Reduce, input.SwitchOptions{Disabled: o.Disabled}).Changed
|
||
dot, sized := a.Dot-1, false
|
||
ui.Row(c).Gap(k.D(6)).AlignItems(ui.Center).Children(func() {
|
||
mark(c, k, k.Msg("dot_size"), pixel.Ink, 0)
|
||
if input.Segmented(c, k.Msg("dot_size"), []string{"1", "2", "3", "4"}, &dot, input.SegmentedOptions{Disabled: o.Disabled}).Changed {
|
||
a.Dot, sized = dot+1, true
|
||
}
|
||
})
|
||
res.Changed = reduce || sized
|
||
})
|
||
if res.Changed {
|
||
slog.Debug("8bit: accessibility options", "label", text, "reduce", a.Reduce, "dot", a.Dot)
|
||
}
|
||
return res
|
||
}
|