Skip to content

Commit

Permalink
Grouped analyze and train under the same menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-bovet committed May 9, 2021
1 parent a4a8f83 commit 3a88310
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Shared/Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ struct Actions {
if document.state == .play {
document.state = state
document.pgnBeforeAnalyzing = document.pgn
if state == .train {
engine.setFEN(StartPosFEN)
}
} else {
document.state = .play
analyzeReset()
Expand Down
21 changes: 14 additions & 7 deletions Shared/ActionsToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct AnalyzeBoard: View {
@Binding var document: ChessDocument
var body: some View {
Button(action: { withAnimation { Actions(document: $document).analyze() } }) {
Label("Analyze", systemImage: "magnifyingglass.circle")
Label("Analyze Game", systemImage: "magnifyingglass.circle")
}
}
}
Expand All @@ -36,7 +36,7 @@ struct TrainButton: View {
@Binding var document: ChessDocument
var body: some View {
Button(action: { withAnimation { Actions(document: $document).train() } }) {
Label("Train", systemImage: "book")
Label("Practice Openings", systemImage: "book")
}
}
}
Expand Down Expand Up @@ -146,11 +146,18 @@ struct ActionsToolbar: ToolbarContent {
var body: some ToolbarContent {
#if os(macOS)
ToolbarItemGroup(placement: .automatic) {
NewGameButton(document: $document, showNewGameSheet: $showNewGameSheet, newGameSheetEditMode: $newGameSheetEditMode)
EditGameButton(document: $document, showNewGameSheet: $showNewGameSheet, newGameSheetEditMode: $newGameSheetEditMode)

AnalyzeBoard(document: $document)
TrainButton(document: $document)
Menu {
NewGameButton(document: $document, showNewGameSheet: $showNewGameSheet, newGameSheetEditMode: $newGameSheetEditMode)
EditGameButton(document: $document, showNewGameSheet: $showNewGameSheet, newGameSheetEditMode: $newGameSheetEditMode)

Divider()

AnalyzeBoard(document: $document)
TrainButton(document: $document)
}
label: {
Label("Game", systemImage: "ellipsis.circle")
}

Menu {
UndoMoveButton(document: $document)
Expand Down
14 changes: 7 additions & 7 deletions Shared/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ struct ContentView: View {
ColorInformationView(document: $document, isWhite: document.rotated ? false: true)
}

VStack(alignment: .leading) {
if (document.state != .play) {
AnalyzeActionsView(document: $document)
}

if (showInfo) {
if (showInfo) {
VStack(alignment: .leading) {
if (document.state != .play) {
AnalyzeActionsView(document: $document)
}
InformationView(document: document)
}
.frame(minWidth: 250, idealWidth: 250, maxWidth: 250, alignment: .leading)
}
.frame(minWidth: 250, idealWidth: 250, maxWidth: 250, alignment: .leading)
}
.padding()
.toolbar {
Expand Down

0 comments on commit 3a88310

Please sign in to comment.