diff --git a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj index 16f8772..ccfb273 100644 --- a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj +++ b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj @@ -9,12 +9,15 @@ /* Begin PBXBuildFile section */ 16038A272C197B800074346E /* FlagManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16038A262C197B800074346E /* FlagManager.swift */; }; 165725EA2C1984CC0052D7EF /* FontManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 165725E92C1984CC0052D7EF /* FontManager.swift */; }; - 165725F12C1985920052D7EF /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 165725EC2C1985920052D7EF /* Localizable.strings */; }; 165725F22C1985920052D7EF /* nuku1.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 165725F02C1985920052D7EF /* nuku1.ttf */; }; + 16FA058C2C1C14F50042D688 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 16FA058A2C1C14F50042D688 /* Localizable.strings */; }; + 16FA05902C1C14FD0042D688 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 16FA058E2C1C14FD0042D688 /* Localizable.strings */; }; + 16FA05922C1C154A0042D688 /* LanguagePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16FA05912C1C154A0042D688 /* LanguagePickerView.swift */; }; + 16FA05942C1C1A380042D688 /* Rules.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16FA05932C1C1A380042D688 /* Rules.swift */; }; + 16FA05962C1C1A5F0042D688 /* GameType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16FA05952C1C1A5F0042D688 /* GameType.swift */; }; 82CE59E92C045D1100ADEE24 /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59E82C045D1100ADEE24 /* GameScene.swift */; }; 82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59EA2C045E3800ADEE24 /* GameView.swift */; }; 82CE59EF2C0460E500ADEE24 /* SpriteMoople.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CE59EE2C0460E500ADEE24 /* SpriteMoople.swift */; }; - C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */; }; C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C205A2B62BF373360097BD93 /* ArkitDoushiQiApp.swift */; }; C205A2BB2BF373380097BD93 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C205A2BA2BF373380097BD93 /* Assets.xcassets */; }; C205A2BE2BF373380097BD93 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C205A2BD2BF373380097BD93 /* Preview Assets.xcassets */; }; @@ -62,13 +65,15 @@ 16038A262C197B800074346E /* FlagManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlagManager.swift; sourceTree = ""; }; 16038A2A2C197DEC0074346E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 165725E92C1984CC0052D7EF /* FontManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontManager.swift; sourceTree = ""; }; - 165725ED2C1985920052D7EF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; - 165725EE2C1985920052D7EF /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; 165725F02C1985920052D7EF /* nuku1.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = nuku1.ttf; sourceTree = ""; }; + 16FA058B2C1C14F50042D688 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Localizable.strings; sourceTree = ""; }; + 16FA058F2C1C14FD0042D688 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = Localizable.strings; sourceTree = ""; }; + 16FA05912C1C154A0042D688 /* LanguagePickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguagePickerView.swift; sourceTree = ""; }; + 16FA05932C1C1A380042D688 /* Rules.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Rules.swift; sourceTree = ""; }; + 16FA05952C1C1A5F0042D688 /* GameType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameType.swift; sourceTree = ""; }; 82CE59E82C045D1100ADEE24 /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = ""; }; 82CE59EA2C045E3800ADEE24 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = ""; }; 82CE59EE2C0460E500ADEE24 /* SpriteMoople.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpriteMoople.swift; sourceTree = ""; }; - C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralParametersMenuView.swift; sourceTree = ""; }; C205A2B32BF373360097BD93 /* ArkitDoushiQi.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ArkitDoushiQi.app; sourceTree = BUILT_PRODUCTS_DIR; }; C205A2B62BF373360097BD93 /* ArkitDoushiQiApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArkitDoushiQiApp.swift; sourceTree = ""; }; C205A2BA2BF373380097BD93 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -127,7 +132,8 @@ 165725EB2C1985920052D7EF /* Ressources */ = { isa = PBXGroup; children = ( - 165725EC2C1985920052D7EF /* Localizable.strings */, + 16FA058D2C1C14FD0042D688 /* fr.lproj */, + 16FA05892C1C14F50042D688 /* en.lproj */, 165725EF2C1985920052D7EF /* Font */, ); path = Ressources; @@ -141,6 +147,22 @@ path = Font; sourceTree = ""; }; + 16FA05892C1C14F50042D688 /* en.lproj */ = { + isa = PBXGroup; + children = ( + 16FA058A2C1C14F50042D688 /* Localizable.strings */, + ); + path = en.lproj; + sourceTree = ""; + }; + 16FA058D2C1C14FD0042D688 /* fr.lproj */ = { + isa = PBXGroup; + children = ( + 16FA058E2C1C14FD0042D688 /* Localizable.strings */, + ); + path = fr.lproj; + sourceTree = ""; + }; 8203E9052BF60117005F5C4A /* Frameworks */ = { isa = PBXGroup; children = ( @@ -206,12 +228,12 @@ C205A2BC2BF373380097BD93 /* Views */ = { isa = PBXGroup; children = ( - C2F015272C09D420000F7221 /* PartyEnregistery */, + C2F015292C09D420000F7221 /* PartyEnregistery.swift */, + C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */, C2F015122C09D3E7000F7221 /* Components */, C2F0150D2C09D3C3000F7221 /* Enum */, C2F0150A2C09D3A4000F7221 /* EventTriggers */, - C25220EC2C00AC530026B71F /* GameParametersMenu */, - C25220EB2C00A9230026B71F /* GeneralParametersMenu */, + C25220EC2C00AC530026B71F /* Data */, C205A2BD2BF373380097BD93 /* Preview Assets.xcassets */, ); path = Views; @@ -234,20 +256,12 @@ path = ArkitDoushiQiUITests; sourceTree = ""; }; - C25220EB2C00A9230026B71F /* GeneralParametersMenu */ = { - isa = PBXGroup; - children = ( - C20310D72BFCC2410031657D /* GeneralParametersMenuView.swift */, - ); - path = GeneralParametersMenu; - sourceTree = ""; - }; - C25220EC2C00AC530026B71F /* GameParametersMenu */ = { + C25220EC2C00AC530026B71F /* Data */ = { isa = PBXGroup; children = ( - C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */, + C2F015282C09D420000F7221 /* Stub.swift */, ); - path = GameParametersMenu; + path = Data; sourceTree = ""; }; C2F015072C09D366000F7221 /* Utils */ = { @@ -273,6 +287,8 @@ children = ( C2F0150E2C09D3C3000F7221 /* Language.swift */, C2F0150F2C09D3C3000F7221 /* AI.swift */, + 16FA05932C1C1A380042D688 /* Rules.swift */, + 16FA05952C1C1A5F0042D688 /* GameType.swift */, ); path = Enum; sourceTree = ""; @@ -293,8 +309,9 @@ C2F015152C09D3E7000F7221 /* ToggleComponent.swift */, C2F015162C09D3E7000F7221 /* ButtonComponent.swift */, C2F015172C09D3E7000F7221 /* EditImageComponent.swift */, - C2F015182C09D3E7000F7221 /* PhotoButtonComponent.swift */, C2F015192C09D3E7000F7221 /* EditTextComponent.swift */, + 16FA05912C1C154A0042D688 /* LanguagePickerView.swift */, + C2F015182C09D3E7000F7221 /* PhotoButtonComponent.swift */, ); path = Controls; sourceTree = ""; @@ -309,15 +326,6 @@ path = Visuals; sourceTree = ""; }; - C2F015272C09D420000F7221 /* PartyEnregistery */ = { - isa = PBXGroup; - children = ( - C2F015282C09D420000F7221 /* Stub.swift */, - C2F015292C09D420000F7221 /* PartyEnregistery.swift */, - ); - path = PartyEnregistery; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -423,9 +431,10 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 16FA05902C1C14FD0042D688 /* Localizable.strings in Resources */, C205A2BE2BF373380097BD93 /* Preview Assets.xcassets in Resources */, + 16FA058C2C1C14F50042D688 /* Localizable.strings in Resources */, 165725F22C1985920052D7EF /* nuku1.ttf in Resources */, - 165725F12C1985920052D7EF /* Localizable.strings in Resources */, C205A2BB2BF373380097BD93 /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -462,14 +471,16 @@ C2F0151E2C09D3E7000F7221 /* PickerComponent.swift in Sources */, C2F015212C09D3E7000F7221 /* EditImageComponent.swift in Sources */, C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */, - C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */, + 16FA05962C1C1A5F0042D688 /* GameType.swift in Sources */, C2F0151F2C09D3E7000F7221 /* ToggleComponent.swift in Sources */, C2F015202C09D3E7000F7221 /* ButtonComponent.swift in Sources */, C2F015262C09D3E7000F7221 /* ProfileEdit.swift in Sources */, + 16FA05942C1C1A380042D688 /* Rules.swift in Sources */, C205A2B72BF373360097BD93 /* ArkitDoushiQiApp.swift in Sources */, C2F015232C09D3E7000F7221 /* EditTextComponent.swift in Sources */, C2F015222C09D3E7000F7221 /* PhotoButtonComponent.swift in Sources */, C2F015092C09D366000F7221 /* LanguageSettings.swift in Sources */, + 16FA05922C1C154A0042D688 /* LanguagePickerView.swift in Sources */, 82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */, C2F0152B2C09D420000F7221 /* PartyEnregistery.swift in Sources */, C2F015102C09D3C3000F7221 /* Language.swift in Sources */, @@ -511,11 +522,18 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - 165725EC2C1985920052D7EF /* Localizable.strings */ = { + 16FA058A2C1C14F50042D688 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 16FA058B2C1C14F50042D688 /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; + 16FA058E2C1C14FD0042D688 /* Localizable.strings */ = { isa = PBXVariantGroup; children = ( - 165725ED2C1985920052D7EF /* en */, - 165725EE2C1985920052D7EF /* fr */, + 16FA058F2C1C14FD0042D688 /* fr */, ); name = Localizable.strings; sourceTree = ""; diff --git a/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift b/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift index f244895..18a5811 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/ArkitDoushiQiApp.swift @@ -21,8 +21,7 @@ struct ArkitDoushiQiApp: App { @StateObject private var languageSettings = LanguageSettings(selectedLanguage: .English) var body: some Scene { WindowGroup { - MainMenu( - playButtonText: "Play", registeredGamesButtonText: "Registered Games") + MainMenu() .environmentObject(LanguageSettings(selectedLanguage: .French) ) .environmentObject(languageSettings) diff --git a/ArkitDoushiQi/ArkitDoushiQi/MainMenu.swift b/ArkitDoushiQi/ArkitDoushiQi/MainMenu.swift index 2bbb518..eb7a5d9 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/MainMenu.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/MainMenu.swift @@ -6,38 +6,8 @@ // import SwiftUI -struct AnimatedCherryBlossomView: View { - @State private var moveTrees = false - @Environment(\.colorScheme) var colorScheme - - var body: some View { - ZStack { - // Arbre gauche - Image(colorScheme == .dark ? "cherry_tree_dark" : "cherry_tree_light") - .resizable() - .scaledToFit() - .frame(width: 200, height: 400) - .offset(x: moveTrees ? -20 : -40, y: moveTrees ? 10 : 30) - .animation(Animation.easeInOut(duration: 3).repeatForever(autoreverses: true)) - - // Arbre droit - Image(colorScheme == .dark ? "cherry_tree_dark" : "cherry_tree_light") - .resizable() - .scaledToFit() - .frame(width: 200, height: 400) - .offset(x: moveTrees ? 20 : 40, y: moveTrees ? 10 : 30) - .animation(Animation.easeInOut(duration: 3).repeatForever(autoreverses: true)) - } - .onAppear { - moveTrees.toggle() - } - } -} - struct MainMenu: View { @EnvironmentObject var languageSettings: LanguageSettings - let playButtonText: String - let registeredGamesButtonText: String @State private var action: Int? = 0 @AppStorage("isDarkMode") private var isDarkMode = false @State private var reloadView = false @@ -48,27 +18,21 @@ struct MainMenu: View { var body: some View { NavigationView { ZStack { - // Utiliser la vue animée en arrière-plan - AnimatedCherryBlossomView() - .edgesIgnoringSafeArea(.all) - VStack { - // Ajouter le titre du jeu Text("DOUSHIQI") - .font(.custom("Nuku Nuku", size: 48, relativeTo: .largeTitle)) // Utilisez le nom PostScript correct + .font(.custom("Nuku Nuku", size: 48, relativeTo: .largeTitle)) .padding() .foregroundColor(colorScheme == .dark ? .white : .black) .offset(x: 0, y: 15) Text("GAME") - .font(.custom("Nuku Nuku", size: 48, relativeTo: .largeTitle)) // Utilisez le nom PostScript correct + .font(.custom("Nuku Nuku", size: 48, relativeTo: .largeTitle)) .foregroundColor(colorScheme == .dark ? .white : .black) Spacer() - // Bouton "Jouer" au centre et plus grand, sans bandeau bleu NavigationLink(destination: GameParametersMenuView()) { - Text(playButtonText) + Text(LocalizedStringKey("Play")) .font(.custom("Nuku Nuku", size: 32, relativeTo: .title)) .bold() .frame(maxWidth: .infinity) @@ -87,9 +51,8 @@ struct MainMenu: View { Spacer().frame(height: 40) - // Bouton "Parties enregistrées" plus discret NavigationLink(destination: PartyListView()) { - Text(registeredGamesButtonText) + Text(LocalizedStringKey("Registered Games")) .font(.custom("Nuku Nuku", size: 18, relativeTo: .body)) .padding() .background(Color.gray.opacity(0.7)) @@ -102,7 +65,6 @@ struct MainMenu: View { Spacer().frame(height: 20) - // Ajouter les icônes pour les paramètres en bas du bouton "Registered Games" HStack { Button(action: { isDarkMode.toggle() @@ -141,65 +103,9 @@ struct MainMenu: View { } } -struct LanguagePickerView: View { - @Binding var showLanguagePicker: Bool - @EnvironmentObject var languageSettings: LanguageSettings - @Environment(\.colorScheme) var colorScheme - - var body: some View { - VStack(spacing: 30) { - Text("Choose Language") - .font(.headline) - .padding() - .foregroundColor(colorScheme == .dark ? .white : .black) - - HStack(spacing: 50) { - Button(action: { - languageSettings.selectedLanguage = .French - showLanguagePicker = false - }) { - VStack { - Text(flag(country: "FR")) - .font(.system(size: 50)) - Text("French") - .font(.title2) - .foregroundColor(colorScheme == .dark ? .white : .black) - } - } - - Button(action: { - languageSettings.selectedLanguage = .English - showLanguagePicker = false - }) { - VStack { - Text(flag(country: "GB")) - .font(.system(size: 50)) - Text("English") - .font(.title2) - .foregroundColor(colorScheme == .dark ? .white : .black) - } - } - } - - Button(action: { - showLanguagePicker = false - }) { - Text("Cancel") - .font(.title2) - .padding() - .background(Color.red.opacity(0.7)) - .foregroundColor(.white) - .cornerRadius(10) - } - .padding(.top, 20) - } - .padding() - } -} - struct MainMenu_Previews: PreviewProvider { static var previews: some View { - MainMenu(playButtonText: "Play", registeredGamesButtonText: "Registered Games") + MainMenu() .environmentObject(LanguageSettings(selectedLanguage: .French)) } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift index ed86c3f..1d8b452 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/ButtonComponent.swift @@ -7,21 +7,20 @@ import SwiftUI -struct ButtonComponent: View { +struct ButtonComponent: View { let content: Content - let title: String + let title: LocalizedStringKey - init(title: String, @ViewBuilder content: () -> Content) { - self.title = title - self.content = content() - } + init(title: LocalizedStringKey, @ViewBuilder content: () -> Content) { + self.title = title + self.content = content() + } var body: some View { NavigationLink { - // ici mettre la vue sur les parties enregistrées à la place du texte n'hésite pas à tester sur la preview la navigation ça marche, faire pareil pour les autres content } label: { - Text(title) + Text(title) .frame(maxWidth: .infinity) .padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) .controlSize(.large) @@ -35,12 +34,12 @@ struct ButtonComponent: View { struct ButtonComponent_Previews: PreviewProvider { static var previews: some View { - NavigationView { - VStack { - ButtonComponent(title: "Parties enregistrées") { - Text("Je suis un test") - } + NavigationView { + VStack { + ButtonComponent(title: LocalizedStringKey("Parties enregistrées")) { + Text("Je suis un test") } } } + } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditImageComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditImageComponent.swift index 113e6dd..8d49488 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditImageComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditImageComponent.swift @@ -15,10 +15,10 @@ struct EditImageComponent: View { let profileWidth: CGFloat let profileHeight: CGFloat let defaultImage: Image - let imageTextChange: String + let imageTextChange: LocalizedStringKey + var body: some View { HStack { - VStack { HStack { GeometryReader { geometry in @@ -27,8 +27,7 @@ struct EditImageComponent: View { color // Profile Image - ProfileComponent(color: color, profileWidth: profileWidth, profileHeight: profileHeight, image: avatarImage ?? defaultImage - ) + ProfileComponent(color: color, profileWidth: profileWidth, profileHeight: profileHeight, image: avatarImage ?? defaultImage) } // Ensure the ZStack takes the size of the GeometryReader .frame(width: geometry.size.width, height: geometry.size.height) @@ -65,10 +64,9 @@ struct EditImageComponent_Previews: PreviewProvider { profileWidth: 100, profileHeight: 100, defaultImage: Image("profil"), - imageTextChange: "Changer d'avatar" + imageTextChange: LocalizedStringKey("Changer d'avatar") ) .previewLayout(.sizeThatFits) .padding() } } - diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditTextComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditTextComponent.swift index a16a7fb..e605652 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditTextComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/EditTextComponent.swift @@ -8,16 +8,18 @@ import SwiftUI struct EditTextComponent: View { - let explanation : String - @State private var name : String - init(explanation: String, value: String) { + let explanation: LocalizedStringKey + @State private var name: String + + init(explanation: LocalizedStringKey, value: String) { self.explanation = explanation - self.name = value + self._name = State(initialValue: value) } + var body: some View { Form { - Section(header : Text(explanation)) { - TextField(name, text : $name) + Section(header: Text(explanation)) { + TextField("", text: $name) } } } @@ -25,6 +27,6 @@ struct EditTextComponent: View { struct EditTextComponent_Previews: PreviewProvider { static var previews: some View { - EditTextComponent(explanation: "Nom du Joueur 1", value: "Joueur 1") + EditTextComponent(explanation: LocalizedStringKey("Nom du Joueur 1"), value: "Joueur 1") } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/LanguagePickerView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/LanguagePickerView.swift new file mode 100644 index 0000000..93a8e63 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/LanguagePickerView.swift @@ -0,0 +1,64 @@ +// +// LanguagePickerView.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 14/06/2024. +// + +import SwiftUI + +struct LanguagePickerView: View { + @Binding var showLanguagePicker: Bool + @EnvironmentObject var languageSettings: LanguageSettings + @Environment(\.colorScheme) var colorScheme + + var body: some View { + VStack(spacing: 30) { + Text(LocalizedStringKey("Choose Language")) + .font(.custom("Nuku Nuku", size: 38, relativeTo: .headline)) + .padding() + .foregroundColor(colorScheme == .dark ? .white : .black) + + HStack(spacing: 50) { + Button(action: { + languageSettings.selectedLanguage = .French + showLanguagePicker = false + }) { + VStack { + Text(flag(country: "FR")) + .font(.system(size: 50)) + Text(LocalizedStringKey("French")) + .font(.custom("Nuku Nuku", size: 28, relativeTo: .title2)) + .foregroundColor(colorScheme == .dark ? .white : .black) + } + } + + Button(action: { + languageSettings.selectedLanguage = .English + showLanguagePicker = false + }) { + VStack { + Text(flag(country: "GB")) + .font(.system(size: 50)) + Text(LocalizedStringKey("English")) + .font(.custom("Nuku Nuku", size: 28, relativeTo: .title2)) + .foregroundColor(colorScheme == .dark ? .white : .black) + } + } + } + + Button(action: { + showLanguagePicker = false + }) { + Text(LocalizedStringKey("Cancel")) + .font(.custom("Nuku Nuku", size: 28, relativeTo: .title2)) + .padding() + .background(Color.red.opacity(0.7)) + .foregroundColor(.white) + .cornerRadius(10) + } + .padding(.top, 20) + } + .padding() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift index 94d431f..9f8e774 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Controls/PickerComponent.swift @@ -24,7 +24,7 @@ struct PickerComponent: Vi Menu { Picker(title, selection: $selectedOption) { ForEach(options) { option in - Text(option.rawValue.description) + Text(LocalizedStringKey(option.rawValue.description)) .tag(option) .padding() } @@ -37,7 +37,7 @@ struct PickerComponent: Vi .padding() .foregroundColor(.primary) Spacer() - Text(selectedOption.rawValue.description) + Text(LocalizedStringKey(selectedOption.rawValue.description)) .padding() .foregroundColor(.primary) } @@ -48,14 +48,3 @@ struct PickerComponent: Vi } } } - -struct PickerComponent_Previews: PreviewProvider { - @State static var selectedItem = Language.English - static var previews: some View { - PickerComponent( - title: "Select Language:", - selectedOption: $selectedItem, - options: Language.allCases - ) - } -} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileComponent.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileComponent.swift index 96e5811..ca88f96 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileComponent.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileComponent.swift @@ -12,6 +12,7 @@ struct ProfileComponent: View { let profileWidth : CGFloat let profileHeight : CGFloat let image : Image + var body: some View { GeometryReader { geometry in ZStack { diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileEdit.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileEdit.swift index 4da9202..bc309c6 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileEdit.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Components/Visuals/ProfileEdit.swift @@ -8,23 +8,26 @@ import SwiftUI struct ProfileEdit: View { - let color : Color - let profileWidth : CGFloat - let profileHeight : CGFloat + let color: Color + let profileWidth: CGFloat + let profileHeight: CGFloat let defaultImage: Image - let imageTextChange : String + let imageTextChange: LocalizedStringKey + let playerNameKey: LocalizedStringKey + var body: some View { VStack(alignment: .leading) { - EditImageComponent( - color: color, - profileWidth: profileWidth, - profileHeight: profileHeight, - defaultImage: defaultImage, - imageTextChange: imageTextChange - ).padding(EdgeInsets(top: 0, leading: 32, bottom: 0, trailing: 32)) + EditImageComponent( + color: color, + profileWidth: profileWidth, + profileHeight: profileHeight, + defaultImage: defaultImage, + imageTextChange: imageTextChange + ).padding(EdgeInsets(top: 0, leading: 32, bottom: 0, trailing: 32)) + VStack(alignment: .trailing) { HStack { - EditTextComponent(explanation: "Nom du Joueur 1", value: "Joueur 1") + EditTextComponent(explanation: playerNameKey, value: playerNameKey == "Nom du Joueur 1" ? "Joueur 1" : "Joueur 2") } } } @@ -33,11 +36,13 @@ struct ProfileEdit: View { struct ProfileEdit_Previews: PreviewProvider { static var previews: some View { - ProfileEdit(color: Color(.red), - profileWidth: 100, - profileHeight: 100, - defaultImage: Image("profil"), - imageTextChange: "Changer d'avatar" + ProfileEdit( + color: Color(.red), + profileWidth: 100, + profileHeight: 100, + defaultImage: Image("profil"), + imageTextChange: LocalizedStringKey("Changer d'avatar"), + playerNameKey: LocalizedStringKey("Nom du Joueur 1") ) } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/Stub.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Data/Stub.swift similarity index 100% rename from ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/Stub.swift rename to ArkitDoushiQi/ArkitDoushiQi/Views/Data/Stub.swift diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/AI.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/AI.swift index 2569afe..3148fcd 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/AI.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/AI.swift @@ -6,6 +6,7 @@ // import Foundation +import SwiftUI enum AI: String, CaseIterable, Identifiable, Hashable { case RandomAction = "IA Random" @@ -13,4 +14,8 @@ enum AI: String, CaseIterable, Identifiable, Hashable { case MediumTrainedAI = "IA Intermédiaire" var id: String { self.rawValue } + + var localized: LocalizedStringKey { + LocalizedStringKey(self.rawValue) + } } diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/GameType.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/GameType.swift new file mode 100644 index 0000000..537390a --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/GameType.swift @@ -0,0 +1,20 @@ +// +// GameType.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 14/06/2024. +// + +import Foundation +import SwiftUI + +enum GameType: String, CaseIterable, Identifiable, Hashable { + case PvP = "Joueur contre Joueur" + case PvAI = "Joueur contre IA" + + var id: String { self.rawValue } + + var localized: LocalizedStringKey { + LocalizedStringKey(self.rawValue) + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/Rules.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/Rules.swift new file mode 100644 index 0000000..b7343a5 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/Enum/Rules.swift @@ -0,0 +1,20 @@ +// +// Rules.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 14/06/2024. +// + +import Foundation +import SwiftUI + +enum Rules: String, CaseIterable, Identifiable, Hashable { + case Easy = "Simplifié" + case Regular = "Normal" + + var id: String { self.rawValue } + + var localized: LocalizedStringKey { + LocalizedStringKey(self.rawValue) + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift deleted file mode 100644 index 13d6346..0000000 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenu/GameParametersMenuView.swift +++ /dev/null @@ -1,61 +0,0 @@ -// -// GameParametersMenuView.swift -// ArkitDoushiQi -// -// Created by Johan LACHENAL on 24/05/2024. -// - -import SwiftUI -import PhotosUI - -enum AIT: String, CaseIterable, Identifiable, Hashable { - case RandomAction = "IA Random" - case EasyTrainedAI = "IA Facile" - case MediumTrainedAI = "IA Intermédiaire" - - var id: String { self.rawValue } -} - -enum Rules: String, CaseIterable, Identifiable, Hashable { - case Easy = "Simplifié" - case Regular = "Normal" - var id: String { self.rawValue } -} - -struct GameParametersMenuView: View, KeyboardReadable { - @State private var selectedAIOption: AIT = .RandomAction - @State private var selectedRulesOption: Rules = .Regular - @State private var isKeyboardVisible = false - var body: some View { - NavigationView { - VStack(alignment: .leading) { - HStack(alignment: .center) { - Text("Paramètres de partie").bold().font(.title) - }.frame(maxWidth: .infinity) - PickerComponent(title: "Sélectionne les règles :", - selectedOption: $selectedRulesOption, - options: Rules.allCases) - PickerComponent(title: "Sélectionne une IA :", - selectedOption: $selectedAIOption, - options: AIT.allCases) - ProfileEdit(color: Color(.red), profileWidth: 100, profileHeight: 100, defaultImage: Image("profil"), imageTextChange: "changer l'avatar du joueur 1") - ProfileEdit(color: Color(.blue), profileWidth: 100, profileHeight: 100, defaultImage: Image("profil"), imageTextChange: "changer l'avatar du joueur 2") - if !isKeyboardVisible - { - ButtonComponent(title: "Lancer la partie") { - GameView() - }.padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) - } - } - .onReceive(keyboardPublisher) { value in isKeyboardVisible = value } - .frame(maxHeight: .infinity, alignment: .top) - } - } - -} - -struct GameParametersMenuView_Previews: PreviewProvider { - static var previews: some View { - GameParametersMenuView() - } -} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenuView.swift new file mode 100644 index 0000000..6bffc7f --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/GameParametersMenuView.swift @@ -0,0 +1,61 @@ +// +// GameParametersMenuView.swift +// ArkitDoushiQi +// +// Created by Johan LACHENAL on 24/05/2024. +// + +import SwiftUI +import PhotosUI + +struct GameParametersMenuView: View, KeyboardReadable { + @State private var selectedGameType: GameType = .PvP + @State private var selectedAIOption: AI = .RandomAction + @State private var selectedRulesOption: Rules = .Regular + @State private var isKeyboardVisible = false + + var body: some View { + NavigationView { + VStack(alignment: .leading) { + HStack(alignment: .center) { + Text(LocalizedStringKey("Paramètres de partie")).bold().font(.title) + }.frame(maxWidth: .infinity) + + // Sélecteur pour le type de partie + PickerComponent(title: LocalizedStringKey("Sélectionne le type de partie :"), + selectedOption: $selectedGameType, + options: GameType.allCases) + + PickerComponent(title: LocalizedStringKey("Sélectionne les règles :"), + selectedOption: $selectedRulesOption, + options: Rules.allCases) + + if selectedGameType == .PvAI { + PickerComponent(title: LocalizedStringKey("Sélectionne une IA :"), + selectedOption: $selectedAIOption, + options: AI.allCases) + } + + ProfileEdit(color: Color(.red), profileWidth: 100, profileHeight: 100, defaultImage: Image("profil"), imageTextChange: LocalizedStringKey("changer l'avatar du joueur 1"), playerNameKey: LocalizedStringKey("Nom du Joueur 1")) + + if selectedGameType == .PvP { + ProfileEdit(color: Color(.blue), profileWidth: 100, profileHeight: 100, defaultImage: Image("profil"), imageTextChange: LocalizedStringKey("changer l'avatar du joueur 2"), playerNameKey: LocalizedStringKey("Nom du Joueur 2")) + } + + if !isKeyboardVisible { + ButtonComponent(title: LocalizedStringKey("Lancer la partie")) { + GameView() + }.padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) + } + } + .onReceive(keyboardPublisher) { value in isKeyboardVisible = value } + .frame(maxHeight: .infinity, alignment: .top) + } + } +} + +struct GameParametersMenuView_Previews: PreviewProvider { + static var previews: some View { + GameParametersMenuView() + } +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift deleted file mode 100644 index 1a0862c..0000000 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/GeneralParametersMenu/GeneralParametersMenuView.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// ParametersMenuView.swift -// ArkitDoushiQi -// -// Created by Johan LACHENAL on 21/05/2024. -// - -import SwiftUI - -struct GeneralParametersMenuView: View { - @EnvironmentObject var languageSettings: LanguageSettings - @State private var selectedAIOption: AI - @State private var selectedRulesOption: Rules - - let parametersTitle = LocalizedStringKey("ParametersTitle") - let darkModeDescription = LocalizedStringKey("DarkModeDescription") - let darkModeBooleanName: String = "isDarkMode" - let darkModeDefaultValue: Bool = false - let languagePickerTitle = LocalizedStringKey("LanguagePickerTitle") - - init(selectedAIOption: AI, selectedRulesOption: Rules) { - self._selectedAIOption = State(initialValue: selectedAIOption) - self._selectedRulesOption = State(initialValue: selectedRulesOption) - } - - var body: some View { - VStack(alignment: .leading) { - HStack(alignment: .center) { - Text(parametersTitle).bold().font(.title) - }.frame(maxWidth: .infinity) - Spacer().frame(maxHeight: 30) - ToggleComponent(description: darkModeDescription, booleanName: darkModeBooleanName, booleanDefaultValue: darkModeDefaultValue) - PickerComponent(title: languagePickerTitle, - selectedOption: $languageSettings.selectedLanguage, - options: Language.allCases) - .onChange(of: languageSettings.selectedLanguage) { newLanguage in - languageSettings.changeLanguage(to: newLanguage) - } - } - .frame(maxHeight: .infinity, alignment: .top) - } -} - -struct GeneralParametersMenuView_Previews: PreviewProvider { - static var previews: some View { - let languageSettings = LanguageSettings(selectedLanguage: .French) - GeneralParametersMenuView( - selectedAIOption: .RandomAction, - selectedRulesOption: .Regular - ) - .environmentObject(languageSettings) - } -} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/PartyEnregistery.swift b/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery.swift similarity index 98% rename from ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/PartyEnregistery.swift rename to ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery.swift index d036c61..73aeaaa 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery/PartyEnregistery.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/Views/PartyEnregistery.swift @@ -7,8 +7,6 @@ import SwiftUI -import SwiftUI - struct PartyListView: View { let parties: [Party] = [ Party(player1Name: "Jack", player1Score: "Défaite", player1Image: "Perceval", player2Name: "Le gars du dimanche", player2Score: "Victoire", player2Image: "Perceval", date: "Samedi soir"), diff --git a/ArkitDoushiQi/Ressources/en.lproj/Localizable.strings b/ArkitDoushiQi/Ressources/en.lproj/Localizable.strings index 86edfa0..ed69893 100644 --- a/ArkitDoushiQi/Ressources/en.lproj/Localizable.strings +++ b/ArkitDoushiQi/Ressources/en.lproj/Localizable.strings @@ -9,3 +9,30 @@ "ParametersTitle" = "Parameters"; "DarkModeDescription" = "Dark Mode"; "LanguagePickerTitle" = "Language"; +"DOUSHIQI" = "DOUSHIQI"; +"GAME" = "GAME"; +"Play" = "Play"; +"Registered Games" = "Registered Games"; +"Choose Language" = "Choose Language"; +"French" = "French"; +"English" = "English"; +"Cancel" = "Cancel"; +"Paramètres de partie" = "Game Settings"; +"Sélectionne le type de partie :" = "Select Game Type:"; +"Joueur contre Joueur" = "Player vs Player"; +"Joueur contre IA" = "Player vs AI"; +"Sélectionne les règles :" = "Select Rules:"; +"Simplifié" = "Easy"; +"Normal" = "Regular"; +"Sélectionne une IA :" = "Select AI:"; +"IA Random" = "Random AI"; +"IA Facile" = "Easy AI"; +"IA Intermédiaire" = "Medium AI"; +"changer l'avatar du joueur 1" = "Change Player 1 Avatar"; +"changer l'avatar du joueur 2" = "Change Player 2 Avatar"; +"Nom du Joueur 1" = "Player 1 Name"; +"Nom du Joueur 2" = "Player 2 Name"; +"Lancer la partie" = "Start Game"; +"Changer d'avatar" = "Change Avatar"; + + diff --git a/ArkitDoushiQi/Ressources/fr.lproj/Localizable.strings b/ArkitDoushiQi/Ressources/fr.lproj/Localizable.strings index e309b3b..f045190 100644 --- a/ArkitDoushiQi/Ressources/fr.lproj/Localizable.strings +++ b/ArkitDoushiQi/Ressources/fr.lproj/Localizable.strings @@ -9,3 +9,28 @@ "ParametersTitle" = "Paramètres"; "DarkModeDescription" = "Mode sombre"; "LanguagePickerTitle" = "Langue"; +"DOUSHIQI" = "DOUSHIQI"; +"GAME" = "JEU"; +"Play" = "Jouer"; +"Registered Games" = "Parties Enregistrees"; +"Choose Language" = "Choisissez la Langue"; +"French" = "Francais"; +"English" = "Anglais"; +"Cancel" = "Annuler"; +"Paramètres de partie" = "Paramètres de partie"; +"Sélectionne le type de partie :" = "Sélectionne le type de partie :"; +"Joueur contre Joueur" = "Joueur contre Joueur"; +"Joueur contre IA" = "Joueur contre IA"; +"Sélectionne les règles :" = "Sélectionne les règles :"; +"Simplifié" = "Simplifié"; +"Normal" = "Normal"; +"Sélectionne une IA :" = "Sélectionne une IA :"; +"IA Random" = "IA Random"; +"IA Facile" = "IA Facile"; +"IA Intermédiaire" = "IA Intermédiaire"; +"changer l'avatar du joueur 1" = "changer l'avatar du joueur 1"; +"changer l'avatar du joueur 2" = "changer l'avatar du joueur 2"; +"Nom du Joueur 1" = "Nom du Joueur 1"; +"Nom du Joueur 2" = "Nom du Joueur 2"; +"Lancer la partie" = "Lancer la partie"; +"Changer d'avatar" = "Changer d'avatar";