PlayScene: Set the Edit Button's position correctly

This commit is contained in:
Noah 2019-12-29 00:01:47 -08:00
parent b924ea9467
commit c08a1bc13e
2 changed files with 50 additions and 49 deletions

View File

@ -136,7 +136,7 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
{ {
frame := ui.NewFrame("New Level Frame") frame := ui.NewFrame("New Level Frame")
window.Pack(frame, ui.Pack{ window.Pack(frame, ui.Pack{
Side: ui.N, Side: ui.N,
Fill: true, Fill: true,
Expand: true, Expand: true,
}) })
@ -150,14 +150,14 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
Font: balance.LabelFont, Font: balance.LabelFont,
}) })
frame.Pack(label1, ui.Pack{ frame.Pack(label1, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
}) })
typeFrame := ui.NewFrame("Page Type Options Frame") typeFrame := ui.NewFrame("Page Type Options Frame")
frame.Pack(typeFrame, ui.Pack{ frame.Pack(typeFrame, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
}) })
type typeObj struct { type typeObj struct {
@ -197,7 +197,7 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
s.Supervisor.Add(radio) s.Supervisor.Add(radio)
typeFrame.Pack(radio, ui.Pack{ typeFrame.Pack(radio, ui.Pack{
Side: ui.W, Side: ui.W,
PadX: 4, PadX: 4,
}) })
}(t) }(t)
} }
@ -211,14 +211,14 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
Font: balance.LabelFont, Font: balance.LabelFont,
}) })
frame.Pack(label2, ui.Pack{ frame.Pack(label2, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
}) })
wpFrame := ui.NewFrame("Wallpaper Frame") wpFrame := ui.NewFrame("Wallpaper Frame")
frame.Pack(wpFrame, ui.Pack{ frame.Pack(wpFrame, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
}) })
type wallpaperObj struct { type wallpaperObj struct {
@ -247,7 +247,7 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
s.Supervisor.Add(radio) s.Supervisor.Add(radio)
wpFrame.Pack(radio, ui.Pack{ wpFrame.Pack(radio, ui.Pack{
Side: ui.W, Side: ui.W,
PadX: 4, PadX: 4,
}) })
}(t) }(t)
} }
@ -264,9 +264,9 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
// }) // })
// bottomFrame.SetBackground(render.Grey) // bottomFrame.SetBackground(render.Grey)
frame.Pack(bottomFrame, ui.Pack{ frame.Pack(bottomFrame, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
PadY: 8, PadY: 8,
}) })
var buttons = []struct { var buttons = []struct {
@ -310,8 +310,8 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
s.Supervisor.Add(btn) s.Supervisor.Add(btn)
bottomFrame.Pack(btn, ui.Pack{ bottomFrame.Pack(btn, ui.Pack{
Side: ui.W, Side: ui.W,
PadX: 4, PadX: 4,
PadY: 8, PadY: 8,
}) })
} }
} }
@ -333,7 +333,7 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
{ {
frame := ui.NewFrame("Open Drawing Frame") frame := ui.NewFrame("Open Drawing Frame")
window.Pack(frame, ui.Pack{ window.Pack(frame, ui.Pack{
Side: ui.N, Side: ui.N,
Fill: true, Fill: true,
Expand: true, Expand: true,
}) })
@ -347,8 +347,8 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
Font: balance.LabelFont, Font: balance.LabelFont,
}) })
frame.Pack(label1, ui.Pack{ frame.Pack(label1, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
}) })
// Get the user's levels. // Get the user's levels.
@ -360,9 +360,9 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
lvlRow := ui.NewFrame("Level Row 0") lvlRow := ui.NewFrame("Level Row 0")
frame.Pack(lvlRow, ui.Pack{ frame.Pack(lvlRow, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
PadY: 1, PadY: 1,
}) })
for i, lvl := range levels { for i, lvl := range levels {
func(i int, lvl string) { func(i int, lvl string) {
@ -380,7 +380,7 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
}) })
s.Supervisor.Add(btn) s.Supervisor.Add(btn)
lvlRow.Pack(btn, ui.Pack{ lvlRow.Pack(btn, ui.Pack{
Side: ui.W, Side: ui.W,
Expand: true, Expand: true,
Fill: true, Fill: true,
}) })
@ -389,9 +389,9 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
log.Warn("i=%d wrapped at mod 4", i) log.Warn("i=%d wrapped at mod 4", i)
lvlRow = ui.NewFrame(fmt.Sprintf("Level Row %d", i)) lvlRow = ui.NewFrame(fmt.Sprintf("Level Row %d", i))
frame.Pack(lvlRow, ui.Pack{ frame.Pack(lvlRow, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
PadY: 1, PadY: 1,
}) })
} }
}(i, lvl) }(i, lvl)
@ -409,16 +409,16 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
Font: balance.LabelFont, Font: balance.LabelFont,
}) })
frame.Pack(label2, ui.Pack{ frame.Pack(label2, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
}) })
files, _ := userdir.ListDoodads() files, _ := userdir.ListDoodads()
ddRow := ui.NewFrame("Doodad Row 0") ddRow := ui.NewFrame("Doodad Row 0")
frame.Pack(ddRow, ui.Pack{ frame.Pack(ddRow, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
PadY: 1, PadY: 1,
}) })
for i, dd := range files { for i, dd := range files {
func(i int, dd string) { func(i int, dd string) {
@ -431,7 +431,7 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
}) })
s.Supervisor.Add(btn) s.Supervisor.Add(btn)
ddRow.Pack(btn, ui.Pack{ ddRow.Pack(btn, ui.Pack{
Side: ui.W, Side: ui.W,
Expand: true, Expand: true,
Fill: true, Fill: true,
}) })
@ -439,9 +439,9 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
if i > 0 && (i+1)%4 == 0 { if i > 0 && (i+1)%4 == 0 {
ddRow = ui.NewFrame(fmt.Sprintf("Doodad Row %d", i)) ddRow = ui.NewFrame(fmt.Sprintf("Doodad Row %d", i))
frame.Pack(ddRow, ui.Pack{ frame.Pack(ddRow, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
PadY: 1, PadY: 1,
}) })
} }
}(i, dd) }(i, dd)
@ -460,9 +460,9 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
// }) // })
// bottomFrame.SetBackground(render.Grey) // bottomFrame.SetBackground(render.Grey)
frame.Pack(bottomFrame, ui.Pack{ frame.Pack(bottomFrame, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
PadY: 8, PadY: 8,
}) })
var buttons = []struct { var buttons = []struct {
@ -482,8 +482,8 @@ func (s *MenuScene) setupLoadWindow(d *Doodle) error {
s.Supervisor.Add(btn) s.Supervisor.Add(btn)
bottomFrame.Pack(btn, ui.Pack{ bottomFrame.Pack(btn, ui.Pack{
Side: ui.W, Side: ui.W,
PadX: 4, PadX: 4,
PadY: 8, PadY: 8,
}) })
} }
} }

View File

@ -199,7 +199,7 @@ func (s *PlayScene) SetupAlertbox() {
{ {
frame := ui.NewFrame("Open Drawing Frame") frame := ui.NewFrame("Open Drawing Frame")
window.Pack(frame, ui.Pack{ window.Pack(frame, ui.Pack{
Side: ui.N, Side: ui.N,
Fill: true, Fill: true,
Expand: true, Expand: true,
}) })
@ -213,9 +213,9 @@ func (s *PlayScene) SetupAlertbox() {
Font: balance.LabelFont, Font: balance.LabelFont,
}) })
frame.Pack(s.alertBoxLabel, ui.Pack{ frame.Pack(s.alertBoxLabel, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
PadY: 16, PadY: 16,
}) })
/****************** /******************
@ -224,9 +224,9 @@ func (s *PlayScene) SetupAlertbox() {
bottomFrame := ui.NewFrame("Button Frame") bottomFrame := ui.NewFrame("Button Frame")
frame.Pack(bottomFrame, ui.Pack{ frame.Pack(bottomFrame, ui.Pack{
Side: ui.N, Side: ui.N,
FillX: true, FillX: true,
PadY: 8, PadY: 8,
}) })
// Button factory for the various options. // Button factory for the various options.
@ -240,7 +240,7 @@ func (s *PlayScene) SetupAlertbox() {
}) })
bottomFrame.Pack(btn, ui.Pack{ bottomFrame.Pack(btn, ui.Pack{
Side: ui.W, Side: ui.W,
PadX: 2, PadX: 2,
}) })
s.supervisor.Add(btn) s.supervisor.Add(btn)
btn.Hide() // all buttons hidden by default btn.Hide() // all buttons hidden by default
@ -362,10 +362,11 @@ func (s *PlayScene) Draw(d *Doodle) error {
size = s.editButton.Size() size = s.editButton.Size()
padding = 8 padding = 8
) )
s.editButton.Present(d.Engine, render.Point{ s.editButton.MoveTo(render.Point{
X: canSize.W - size.W - padding, X: canSize.W - size.W - padding,
Y: canSize.H - size.H - padding, Y: canSize.H - size.H - padding,
}) })
s.editButton.Present(d.Engine, s.editButton.Point())
// Draw the alert box window. // Draw the alert box window.
if !s.alertBox.Hidden() { if !s.alertBox.Hidden() {