-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jan Steinke
committed
Feb 11, 2024
1 parent
c4f90b2
commit db5fe38
Showing
4 changed files
with
70 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,6 @@ func NewLogic() *logic { | |
} | ||
|
||
type logic struct { | ||
app.Compo | ||
|
||
sequence []int64 | ||
clicks int | ||
stage int | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/maxence-charriere/go-app/v9/pkg/app" | ||
) | ||
|
||
type menu struct { | ||
app.Compo | ||
selectedDifficulty difficulty | ||
} | ||
|
||
func NewMenu() *menu { | ||
return &menu{} | ||
} | ||
|
||
func (g *menu) Render() app.UI { | ||
return app.Div().Body( | ||
|
||
app.Button(). | ||
Class("simon-button", "new-game"). | ||
Body(app.Span().Text("New Game")). | ||
OnClick(func(ctx app.Context, _ app.Event) { | ||
ctx.NewActionWithValue(eventNewGame, g.selectedDifficulty) | ||
}), | ||
app.Div().ID("difficulty").Body( | ||
app.Label().Body( | ||
app.Input().Type("radio").Name("difficulty-setting").ID("difficulty%d", easy).Value(easy).Checked(true).OnClick(func(ctx app.Context, _ app.Event) { | ||
val := ctx.JSSrc().Get("value").String() | ||
d, err := strconv.Atoi(val) | ||
if err != nil { | ||
fmt.Println("failed parsing", val) | ||
return | ||
} | ||
g.selectedDifficulty = difficulty(d) | ||
}), | ||
app.Text("easy"), | ||
), | ||
app.Label().Body( | ||
app.Input().Type("radio").Name("difficulty-setting").ID("difficulty%d", medium).Value(medium).OnClick(func(ctx app.Context, _ app.Event) { | ||
val := ctx.JSSrc().Get("value").String() | ||
d, err := strconv.Atoi(val) | ||
if err != nil { | ||
fmt.Println("failed parsing", val) | ||
return | ||
} | ||
g.selectedDifficulty = difficulty(d) | ||
}), | ||
app.Text("medium"), | ||
), | ||
app.Label().Body( | ||
app.Input().Type("radio").Name("difficulty-setting").ID("difficulty%d", hard).Value(hard).OnClick(func(ctx app.Context, _ app.Event) { | ||
val := ctx.JSSrc().Get("value").String() | ||
d, err := strconv.Atoi(val) | ||
if err != nil { | ||
fmt.Println("failed parsing", val) | ||
return | ||
} | ||
g.selectedDifficulty = difficulty(d) | ||
}), | ||
app.Text("hard"), | ||
), | ||
), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters