|
|
|
@ -49,8 +49,8 @@ struct NewGameView: View {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button("newGame.play", systemImage: "play") {
|
|
|
|
|
// TODO: yes
|
|
|
|
|
NavigationLink(destination: IngameView(settings: vm, player1: p1, player2: p2)/*.navigationTitle("inGame.title")*/) {
|
|
|
|
|
Label("newGame.play", systemImage: "play")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -66,17 +66,15 @@ private struct PlayerSectionView: View {
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
Picker("newGame.player.type", selection: $settings.type) {
|
|
|
|
|
Text("generic.player.type.human").tag(PlayerType.Human)
|
|
|
|
|
Text("generic.player.type.aiRandom").tag(PlayerType.AIRandom)
|
|
|
|
|
Text("generic.player.type.aiFinnishHim").tag(PlayerType.AIFinnishHim)
|
|
|
|
|
Text("generic.player.type.aiSimpleNegaMax").tag(PlayerType.AISimpleNegaMax)
|
|
|
|
|
ForEach(PlayerType.allCases) {
|
|
|
|
|
Text(LocalizedStringKey($0.baseTranslationKey)).tag($0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let binding: Binding<String> = if (settings.type == .Human) {
|
|
|
|
|
$name
|
|
|
|
|
} else {
|
|
|
|
|
// FIXME: make text field readonly
|
|
|
|
|
.constant("TODO constant name")
|
|
|
|
|
.constant(String(localized: String.LocalizationValue("\(settings.type.baseTranslationKey).name" as String)))
|
|
|
|
|
}
|
|
|
|
|
TextField("newGame.player.name", text: binding)
|
|
|
|
|
// TODO: MacOS
|
|
|
|
@ -97,6 +95,17 @@ private struct PlayerSectionView: View {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension PlayerType {
|
|
|
|
|
var baseTranslationKey: String {
|
|
|
|
|
return switch (self) {
|
|
|
|
|
case .Human: "generic.player.type.human"
|
|
|
|
|
case .AIRandom: "generic.player.type.aiRandom"
|
|
|
|
|
case .AIFinnishHim: "generic.player.type.aiFinnishHim"
|
|
|
|
|
case .AISimpleNegaMax: "generic.player.type.aiSimpleNegaMax"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#Preview {
|
|
|
|
|
NewGameView()
|
|
|
|
|
}
|
|
|
|
|