From 3a88310f2715cd10e3ac0ce09a159c115eebfee8 Mon Sep 17 00:00:00 2001 From: Jean Bovet Date: Sun, 9 May 2021 11:34:16 -0700 Subject: [PATCH] Grouped analyze and train under the same menu --- Shared/Actions.swift | 3 +++ Shared/ActionsToolbar.swift | 21 ++++++++++++++------- Shared/Views/ContentView.swift | 14 +++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Shared/Actions.swift b/Shared/Actions.swift index f095f99..2de35b3 100644 --- a/Shared/Actions.swift +++ b/Shared/Actions.swift @@ -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() diff --git a/Shared/ActionsToolbar.swift b/Shared/ActionsToolbar.swift index 505c1ef..19540f3 100644 --- a/Shared/ActionsToolbar.swift +++ b/Shared/ActionsToolbar.swift @@ -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") } } } @@ -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") } } } @@ -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) diff --git a/Shared/Views/ContentView.swift b/Shared/Views/ContentView.swift index 29754c2..7acac11 100644 --- a/Shared/Views/ContentView.swift +++ b/Shared/Views/ContentView.swift @@ -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 {