2020-09-02 03:54:58 +00:00
|
|
|
package windows
|
|
|
|
|
|
|
|
import (
|
2021-06-20 20:21:47 +00:00
|
|
|
"strings"
|
|
|
|
|
2020-09-02 03:54:58 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/balance"
|
2022-02-20 02:25:36 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/gamepad"
|
2021-06-20 05:14:41 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/log"
|
2020-09-02 03:54:58 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/native"
|
2022-02-20 02:25:36 +00:00
|
|
|
magicform "git.kirsle.net/apps/doodle/pkg/uix/magic-form"
|
2021-06-20 05:14:41 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/usercfg"
|
|
|
|
"git.kirsle.net/apps/doodle/pkg/userdir"
|
2020-09-02 03:54:58 +00:00
|
|
|
"git.kirsle.net/go/render"
|
|
|
|
"git.kirsle.net/go/ui"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Settings window.
|
|
|
|
type Settings struct {
|
|
|
|
// Settings passed in by doodle
|
|
|
|
Supervisor *ui.Supervisor
|
|
|
|
Engine render.Engine
|
2021-06-20 05:14:41 +00:00
|
|
|
|
|
|
|
// Boolean bindings.
|
|
|
|
DebugOverlay *bool
|
|
|
|
DebugCollision *bool
|
|
|
|
HorizontalToolbars *bool
|
2021-09-12 04:18:22 +00:00
|
|
|
EnableFeatures *bool
|
2021-10-11 22:57:33 +00:00
|
|
|
CrosshairSize *int
|
|
|
|
CrosshairColor *render.Color
|
2021-10-13 03:49:48 +00:00
|
|
|
HideTouchHints *bool
|
2022-01-03 06:36:32 +00:00
|
|
|
DisableAutosave *bool
|
2022-02-20 02:25:36 +00:00
|
|
|
ControllerStyle *int
|
2021-06-20 05:14:41 +00:00
|
|
|
|
|
|
|
// Configuration options.
|
|
|
|
SceneName string // name of scene which called this window
|
|
|
|
ActiveTab string // specify the tab to open
|
|
|
|
OnApply func()
|
|
|
|
}
|
|
|
|
|
|
|
|
// MakeSettingsWindow initializes a settings window for any scene.
|
|
|
|
// The window width/height are the actual SDL2 window dimensions.
|
|
|
|
func MakeSettingsWindow(windowWidth, windowHeight int, cfg Settings) *ui.Window {
|
|
|
|
win := NewSettingsWindow(cfg)
|
|
|
|
win.Compute(cfg.Engine)
|
|
|
|
win.Supervise(cfg.Supervisor)
|
|
|
|
|
|
|
|
// Center the window.
|
|
|
|
size := win.Size()
|
|
|
|
win.MoveTo(render.Point{
|
|
|
|
X: (windowWidth / 2) - (size.W / 2),
|
|
|
|
Y: (windowHeight / 2) - (size.H / 2),
|
|
|
|
})
|
|
|
|
|
|
|
|
return win
|
2020-09-02 03:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewSettingsWindow initializes the window.
|
|
|
|
func NewSettingsWindow(cfg Settings) *ui.Window {
|
2021-06-20 05:14:41 +00:00
|
|
|
var (
|
2021-07-26 04:46:55 +00:00
|
|
|
Width = 400
|
2022-03-06 06:44:54 +00:00
|
|
|
Height = 360
|
2021-06-20 05:14:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
window := ui.NewWindow("Settings")
|
2020-09-02 03:54:58 +00:00
|
|
|
window.SetButtons(ui.CloseButton)
|
|
|
|
window.Configure(ui.Config{
|
2021-06-20 05:14:41 +00:00
|
|
|
Width: Width,
|
|
|
|
Height: Height,
|
2020-09-02 03:54:58 +00:00
|
|
|
Background: render.Grey,
|
|
|
|
})
|
|
|
|
|
2021-06-20 05:14:41 +00:00
|
|
|
///////////
|
|
|
|
// Tab Bar
|
2021-07-26 04:46:55 +00:00
|
|
|
tabFrame := ui.NewTabFrame("Tab Frame")
|
2021-06-20 05:14:41 +00:00
|
|
|
tabFrame.SetBackground(render.DarkGrey)
|
|
|
|
window.Pack(tabFrame, ui.Pack{
|
|
|
|
Side: ui.N,
|
|
|
|
FillX: true,
|
|
|
|
})
|
|
|
|
|
2021-09-12 04:18:22 +00:00
|
|
|
// Make the tabs
|
2021-07-26 04:46:55 +00:00
|
|
|
cfg.makeOptionsTab(tabFrame, Width, Height)
|
|
|
|
cfg.makeControlsTab(tabFrame, Width, Height)
|
2022-02-20 02:25:36 +00:00
|
|
|
cfg.makeControllerTab(tabFrame, Width, Height)
|
2021-09-12 04:18:22 +00:00
|
|
|
cfg.makeExperimentalTab(tabFrame, Width, Height)
|
2021-07-26 04:46:55 +00:00
|
|
|
|
|
|
|
tabFrame.Supervise(cfg.Supervisor)
|
2020-09-02 03:54:58 +00:00
|
|
|
|
2021-06-20 05:14:41 +00:00
|
|
|
return window
|
|
|
|
}
|
|
|
|
|
|
|
|
// saveGameSettings controls pkg/usercfg to write the user settings
|
|
|
|
// to disk, based on the settings toggle-able from the UI window.
|
|
|
|
func saveGameSettings() {
|
|
|
|
log.Info("Saving game settings")
|
|
|
|
if err := usercfg.Save(); err != nil {
|
|
|
|
log.Error("Couldn't save game settings: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Settings Window "Options" Tab
|
2021-07-26 04:46:55 +00:00
|
|
|
func (c Settings) makeOptionsTab(tabFrame *ui.TabFrame, Width, Height int) *ui.Frame {
|
|
|
|
tab := tabFrame.AddTab("Options", ui.NewLabel(ui.Label{
|
|
|
|
Text: "Options",
|
|
|
|
Font: balance.TabFont,
|
|
|
|
}))
|
|
|
|
tab.Resize(render.NewRect(Width-4, Height-tab.Size().H-46))
|
2021-06-20 05:14:41 +00:00
|
|
|
|
|
|
|
// Common click handler for all settings,
|
|
|
|
// so we can write the updated info to disk.
|
2022-03-06 06:44:54 +00:00
|
|
|
onClick := func() {
|
2021-06-20 05:14:41 +00:00
|
|
|
saveGameSettings()
|
|
|
|
}
|
|
|
|
|
2022-03-06 06:44:54 +00:00
|
|
|
// The CrosshairSize is ideally a 0-100 (percent) how big the editor
|
|
|
|
// crosshair is, but options now are only 0% or 100% so it presents
|
|
|
|
// this as a checkbox for now.
|
|
|
|
var crosshairEnabled = *c.CrosshairSize > 0
|
|
|
|
|
|
|
|
form := magicform.Form{
|
|
|
|
Supervisor: c.Supervisor,
|
|
|
|
Engine: c.Engine,
|
|
|
|
Vertical: true,
|
|
|
|
LabelWidth: 150,
|
|
|
|
}
|
|
|
|
form.Create(tab, []magicform.Field{
|
2021-06-20 05:14:41 +00:00
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "Game Options",
|
|
|
|
Font: balance.LabelFont,
|
2021-06-20 05:14:41 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "Hide touchscreen control hints during Play Mode",
|
|
|
|
Font: balance.UIFont,
|
|
|
|
BoolVariable: c.HideTouchHints,
|
2022-05-01 00:59:55 +00:00
|
|
|
OnClick: onClick,
|
2021-06-20 05:14:41 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "Level & Doodad Editor",
|
|
|
|
Font: balance.LabelFont,
|
2021-06-20 05:14:41 +00:00
|
|
|
},
|
2021-10-13 03:49:48 +00:00
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "Horizontal instead of vertical toolbars",
|
|
|
|
Font: balance.UIFont,
|
|
|
|
BoolVariable: c.HorizontalToolbars,
|
2022-05-01 00:59:55 +00:00
|
|
|
OnClick: onClick,
|
2022-03-06 06:44:54 +00:00
|
|
|
Tooltip: ui.Tooltip{
|
|
|
|
Text: "Note: reload your level after changing this option.\n" +
|
|
|
|
"Playtesting and returning will do.",
|
|
|
|
Edge: ui.Top,
|
|
|
|
},
|
2021-10-13 03:49:48 +00:00
|
|
|
},
|
2022-01-03 06:36:32 +00:00
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "Disable auto-save in the Editor",
|
|
|
|
Font: balance.UIFont,
|
|
|
|
BoolVariable: c.DisableAutosave,
|
2022-05-01 00:59:55 +00:00
|
|
|
OnClick: onClick,
|
2022-01-03 06:36:32 +00:00
|
|
|
},
|
2021-10-11 22:57:33 +00:00
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "Draw a crosshair at the mouse cursor.",
|
|
|
|
Font: balance.UIFont,
|
|
|
|
BoolVariable: &crosshairEnabled,
|
|
|
|
OnClick: func() {
|
|
|
|
if crosshairEnabled {
|
|
|
|
*c.CrosshairSize = 100
|
|
|
|
} else {
|
|
|
|
*c.CrosshairSize = 0
|
|
|
|
}
|
|
|
|
onClick()
|
|
|
|
},
|
2021-10-11 22:57:33 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Type: magicform.Color,
|
|
|
|
Label: "Crosshair color:",
|
|
|
|
Font: balance.UIFont,
|
2021-10-11 22:57:33 +00:00
|
|
|
Color: c.CrosshairColor,
|
2022-03-06 06:44:54 +00:00
|
|
|
OnClick: func() {
|
|
|
|
onClick()
|
|
|
|
},
|
2021-06-20 05:14:41 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "My Custom Content",
|
|
|
|
Font: balance.LabelFont,
|
2021-06-20 05:14:41 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "Levels and doodads you create in-game are placed in your\n" +
|
2022-01-03 06:36:32 +00:00
|
|
|
"Profile Directory, which you can access below:",
|
2022-03-06 06:44:54 +00:00
|
|
|
Font: balance.UIFont,
|
2021-06-20 05:14:41 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Buttons: []magicform.Field{
|
|
|
|
{
|
|
|
|
Label: "Open profile directory",
|
|
|
|
Font: balance.UIFont,
|
|
|
|
ButtonStyle: &balance.ButtonPrimary,
|
|
|
|
OnClick: func() {
|
|
|
|
path := strings.ReplaceAll(userdir.ProfileDirectory, "\\", "/")
|
|
|
|
if path[0] != '/' {
|
|
|
|
path = "/" + path
|
|
|
|
}
|
|
|
|
native.OpenURL("file://" + path)
|
|
|
|
},
|
|
|
|
},
|
2021-06-20 05:14:41 +00:00
|
|
|
},
|
|
|
|
},
|
2022-03-06 06:44:54 +00:00
|
|
|
})
|
2021-06-20 05:14:41 +00:00
|
|
|
|
|
|
|
return tab
|
|
|
|
}
|
|
|
|
|
|
|
|
// Settings Window "Controls" Tab
|
2021-07-26 04:46:55 +00:00
|
|
|
func (c Settings) makeControlsTab(tabFrame *ui.TabFrame, Width, Height int) *ui.Frame {
|
|
|
|
frame := tabFrame.AddTab("Controls", ui.NewLabel(ui.Label{
|
|
|
|
Text: "Controls",
|
|
|
|
Font: balance.TabFont,
|
|
|
|
}))
|
|
|
|
frame.Resize(render.NewRect(Width-4, Height-frame.Size().H-46))
|
|
|
|
|
2021-06-20 05:14:41 +00:00
|
|
|
var (
|
|
|
|
halfWidth = (Width - 4) / 2 // the 4 is for window borders, TODO
|
|
|
|
shortcutTabWidth = float64(halfWidth) * 0.5
|
|
|
|
infoTabWidth = float64(halfWidth) * 0.5
|
|
|
|
rowHeight = 20
|
|
|
|
|
|
|
|
shortcutTabSize = render.NewRect(int(shortcutTabWidth), rowHeight)
|
|
|
|
infoTabSize = render.NewRect(int(infoTabWidth), rowHeight)
|
|
|
|
)
|
|
|
|
|
|
|
|
controls := []struct {
|
|
|
|
Header string
|
|
|
|
Label string
|
|
|
|
Shortcut string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Header: "Universal Shortcut Keys",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Escape",
|
|
|
|
Label: "Exit game",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "F1",
|
|
|
|
Label: "Guidebook",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "`",
|
|
|
|
Label: "Dev console",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Header: "Gameplay Controls (Play Mode)",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Up or W",
|
|
|
|
Label: "Jump",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Space",
|
|
|
|
Label: "Activate",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Left or A",
|
|
|
|
Label: "Move left",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Right or D",
|
|
|
|
Label: "Move right",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Header: "Level Editor Shortcuts",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Ctrl-N",
|
|
|
|
Label: "New level",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Ctrl-O",
|
|
|
|
Label: "Open drawing",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Ctrl-S",
|
|
|
|
Label: "Save drawing",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Shift-Ctrl-S",
|
|
|
|
Label: "Save a copy",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Ctrl-Z",
|
|
|
|
Label: "Undo stroke",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "Ctrl-Y",
|
|
|
|
Label: "Redo stroke",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "P",
|
|
|
|
Label: "Playtest",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "0",
|
|
|
|
Label: "Scroll to origin",
|
|
|
|
},
|
|
|
|
{
|
2021-07-13 05:19:36 +00:00
|
|
|
Shortcut: "q",
|
2021-06-20 05:14:41 +00:00
|
|
|
Label: "Doodads",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "f",
|
|
|
|
Label: "Pencil Tool",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "l",
|
|
|
|
Label: "Line Tool",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "r",
|
|
|
|
Label: "Rectangle Tool",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "c",
|
|
|
|
Label: "Ellipse Tool",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Shortcut: "x",
|
|
|
|
Label: "Eraser Tool",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
var curFrame = ui.NewFrame("Frame")
|
|
|
|
frame.Pack(curFrame, ui.Pack{
|
|
|
|
Side: ui.N,
|
|
|
|
FillX: true,
|
2020-09-02 03:54:58 +00:00
|
|
|
})
|
2021-06-20 05:14:41 +00:00
|
|
|
var i = -1 // manually controlled
|
|
|
|
for _, row := range controls {
|
|
|
|
i++
|
|
|
|
row := row
|
2020-09-02 03:54:58 +00:00
|
|
|
|
2021-06-20 05:14:41 +00:00
|
|
|
if row.Header != "" {
|
|
|
|
// Close out a previous Frame?
|
|
|
|
if i != 0 {
|
|
|
|
curFrame = ui.NewFrame("Header Row")
|
|
|
|
frame.Pack(curFrame, ui.Pack{
|
|
|
|
Side: ui.N,
|
|
|
|
FillX: true,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
label := ui.NewLabel(ui.Label{
|
|
|
|
Text: row.Header,
|
|
|
|
Font: balance.LabelFont,
|
|
|
|
})
|
|
|
|
curFrame.Pack(label, ui.Pack{
|
|
|
|
Side: ui.W,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Set up the next series of shortcut keys.
|
|
|
|
i = -1
|
|
|
|
curFrame = ui.NewFrame("Frame")
|
|
|
|
frame.Pack(curFrame, ui.Pack{
|
|
|
|
Side: ui.N,
|
|
|
|
FillX: true,
|
|
|
|
})
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cut a new frame every 2 items.
|
|
|
|
if i > 0 && i%2 == 0 {
|
|
|
|
curFrame = ui.NewFrame("Frame")
|
|
|
|
frame.Pack(curFrame, ui.Pack{
|
|
|
|
Side: ui.N,
|
|
|
|
FillX: true,
|
2022-03-06 06:44:54 +00:00
|
|
|
PadY: 1,
|
2021-06-20 05:14:41 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
keyLabel := ui.NewLabel(ui.Label{
|
|
|
|
Text: row.Shortcut,
|
|
|
|
Font: balance.CodeLiteralFont,
|
|
|
|
})
|
|
|
|
keyLabel.Configure(ui.Config{
|
|
|
|
Background: render.RGBA(255, 255, 220, 255),
|
|
|
|
BorderSize: 1,
|
|
|
|
BorderStyle: ui.BorderSunken,
|
|
|
|
BorderColor: render.DarkGrey,
|
|
|
|
})
|
|
|
|
keyLabel.Resize(shortcutTabSize)
|
|
|
|
curFrame.Pack(keyLabel, ui.Pack{
|
|
|
|
Side: ui.W,
|
|
|
|
PadX: 1,
|
|
|
|
})
|
|
|
|
|
|
|
|
helpLabel := ui.NewLabel(ui.Label{
|
|
|
|
Text: row.Label,
|
|
|
|
Font: balance.UIFont,
|
|
|
|
})
|
|
|
|
helpLabel.Resize(infoTabSize)
|
|
|
|
curFrame.Pack(helpLabel, ui.Pack{
|
|
|
|
Side: ui.W,
|
|
|
|
PadX: 1,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return frame
|
2020-09-02 03:54:58 +00:00
|
|
|
}
|
2021-09-12 04:18:22 +00:00
|
|
|
|
|
|
|
// Settings Window "Experimental" Tab
|
|
|
|
func (c Settings) makeExperimentalTab(tabFrame *ui.TabFrame, Width, Height int) *ui.Frame {
|
|
|
|
tab := tabFrame.AddTab("Experimental", ui.NewLabel(ui.Label{
|
|
|
|
Text: "Experimental",
|
|
|
|
Font: balance.TabFont,
|
|
|
|
}))
|
|
|
|
tab.Resize(render.NewRect(Width-4, Height-tab.Size().H-46))
|
|
|
|
|
|
|
|
// Common click handler for all settings,
|
|
|
|
// so we can write the updated info to disk.
|
2022-05-01 00:59:55 +00:00
|
|
|
onClick := func() {
|
2021-09-12 04:18:22 +00:00
|
|
|
saveGameSettings()
|
|
|
|
}
|
|
|
|
|
2022-05-01 00:59:55 +00:00
|
|
|
form := magicform.Form{
|
|
|
|
Supervisor: c.Supervisor,
|
|
|
|
Engine: c.Engine,
|
|
|
|
Vertical: true,
|
|
|
|
LabelWidth: 150,
|
|
|
|
}
|
|
|
|
form.Create(tab, []magicform.Field{
|
2021-09-12 04:18:22 +00:00
|
|
|
{
|
2022-05-01 00:59:55 +00:00
|
|
|
Label: "Enable Experimental Features",
|
|
|
|
Font: balance.LabelFont,
|
2021-09-12 04:18:22 +00:00
|
|
|
},
|
|
|
|
{
|
2022-05-01 00:59:55 +00:00
|
|
|
Label: "The setting below can enable experimental features in this\n" +
|
2021-09-12 04:18:22 +00:00
|
|
|
"game. These are features which are still in development and\n" +
|
|
|
|
"may have unstable or buggy behavior.",
|
2022-05-01 00:59:55 +00:00
|
|
|
Font: balance.UIFont,
|
2021-09-12 04:18:22 +00:00
|
|
|
},
|
|
|
|
{
|
2022-05-01 00:59:55 +00:00
|
|
|
Label: "Viewport window",
|
|
|
|
Font: balance.LabelFont,
|
2021-09-12 04:18:22 +00:00
|
|
|
},
|
|
|
|
{
|
2022-05-01 00:59:55 +00:00
|
|
|
Label: "This option in the Level menu opens another view into\n" +
|
2022-01-03 06:36:32 +00:00
|
|
|
"the level. Has glitchy wallpaper problems.",
|
2022-05-01 00:59:55 +00:00
|
|
|
Font: balance.UIFont,
|
2021-09-12 04:18:22 +00:00
|
|
|
},
|
|
|
|
{
|
2022-05-01 00:59:55 +00:00
|
|
|
BoolVariable: c.EnableFeatures,
|
|
|
|
Label: "Enable experimental features",
|
|
|
|
Font: balance.UIFont,
|
|
|
|
OnClick: onClick,
|
2021-09-12 04:18:22 +00:00
|
|
|
},
|
|
|
|
{
|
2022-05-01 00:59:55 +00:00
|
|
|
Label: "Restart the game for changes to take effect.",
|
|
|
|
Font: balance.UIFont,
|
2021-09-12 04:18:22 +00:00
|
|
|
},
|
2022-05-01 00:59:55 +00:00
|
|
|
})
|
2021-09-12 04:18:22 +00:00
|
|
|
|
|
|
|
return tab
|
|
|
|
}
|
2022-02-20 02:25:36 +00:00
|
|
|
|
|
|
|
// Settings Window "Controller" Tab
|
|
|
|
func (c Settings) makeControllerTab(tabFrame *ui.TabFrame, Width, Height int) *ui.Frame {
|
|
|
|
tab := tabFrame.AddTab("Gamepad", ui.NewLabel(ui.Label{
|
|
|
|
Text: "Gamepad",
|
|
|
|
Font: balance.TabFont,
|
|
|
|
}))
|
|
|
|
tab.Resize(render.NewRect(Width-4, Height-tab.Size().H-46))
|
|
|
|
|
|
|
|
// Render the form.
|
|
|
|
form := magicform.Form{
|
|
|
|
Supervisor: c.Supervisor,
|
|
|
|
Engine: c.Engine,
|
|
|
|
Vertical: true,
|
|
|
|
LabelWidth: 150,
|
|
|
|
}
|
|
|
|
form.Create(tab, []magicform.Field{
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "Play with an Xbox or Nintendo controller!",
|
2022-02-20 02:25:36 +00:00
|
|
|
Font: balance.LabelFont,
|
|
|
|
},
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "If you have a Nintendo-style controller (your A button is on\n" +
|
|
|
|
"the right and B button on bottom), pick 'N Style' to reverse\n" +
|
|
|
|
"the A/B and X/Y buttons.",
|
2022-02-20 02:25:36 +00:00
|
|
|
Font: balance.UIFont,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "Button Style:",
|
|
|
|
Font: balance.LabelFont,
|
|
|
|
Type: magicform.Selectbox,
|
|
|
|
Options: []magicform.Option{
|
|
|
|
{
|
|
|
|
Label: "X Style (default)",
|
|
|
|
Value: int(gamepad.XStyle),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "N Style",
|
|
|
|
Value: int(gamepad.NStyle),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SelectValue: *c.ControllerStyle,
|
|
|
|
OnSelect: func(v interface{}) {
|
|
|
|
style, _ := v.(int)
|
|
|
|
log.Error("style: %d", style)
|
|
|
|
gamepad.SetStyle(gamepad.Style(style))
|
|
|
|
saveGameSettings()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-03-06 06:44:54 +00:00
|
|
|
Label: "The gamepad controls vary between two modes:",
|
2022-02-20 02:25:36 +00:00
|
|
|
Font: balance.UIFont,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "Mouse Mode (outside of gameplay)",
|
|
|
|
Font: balance.LabelFont,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "The left analog stick moves a mouse cursor around.\n" +
|
|
|
|
"The right analog stick scrolls the level around.\n" +
|
|
|
|
"A or X: Left-click B or Y: Right-click\n" +
|
|
|
|
"L1: Middle-click L2: Close window",
|
|
|
|
Font: balance.UIFont,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "Gameplay Mode",
|
|
|
|
Font: balance.LabelFont,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "Left stick or D-Pad to move the player around.\n" +
|
|
|
|
"A or X: 'Use' B or Y: 'Jump'\n" +
|
|
|
|
"R1: Toggle between Mouse and Gameplay controls.",
|
|
|
|
Font: balance.UIFont,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
return tab
|
|
|
|
}
|