diff --git a/.DS_Store b/.DS_Store index 7f97615..6492ea0 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj index 8dfa190..16f8772 100644 --- a/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj +++ b/ArkitDoushiQi/ArkitDoushiQi.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* 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 */; }; 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 */; }; @@ -35,8 +39,6 @@ C2F015262C09D3E7000F7221 /* ProfileEdit.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F0151D2C09D3E7000F7221 /* ProfileEdit.swift */; }; C2F0152A2C09D420000F7221 /* Stub.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F015282C09D420000F7221 /* Stub.swift */; }; C2F0152B2C09D420000F7221 /* PartyEnregistery.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F015292C09D420000F7221 /* PartyEnregistery.swift */; }; - C2F015392C09D5A5000F7221 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C2F015372C09D5A5000F7221 /* Localizable.strings */; }; - C2F0153D2C09D5C0000F7221 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C2F0153B2C09D5C0000F7221 /* Localizable.strings */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -57,6 +59,12 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 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 = ""; }; 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 = ""; }; @@ -70,7 +78,7 @@ C205A2CD2BF373380097BD93 /* ArkitDoushiQiUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ArkitDoushiQiUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C205A2D12BF373380097BD93 /* WtaTennisUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WtaTennisUITests.swift; sourceTree = ""; }; C205A2D32BF373380097BD93 /* WtaTennisUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WtaTennisUITestsLaunchTests.swift; sourceTree = ""; }; - C24659E42BF5FE09004E80D5 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = ""; }; + C24659E42BF5FE09004E80D5 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = ""; usesTabs = 0; }; C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameParametersMenuView.swift; sourceTree = ""; }; C2A535D82C0F56A700503472 /* DSQ.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = DSQ.xcframework; path = ../NEPASTOUCHER/DSQ.xcframework; sourceTree = ""; }; C2F015082C09D366000F7221 /* LanguageSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LanguageSettings.swift; sourceTree = ""; }; @@ -88,8 +96,6 @@ C2F0151D2C09D3E7000F7221 /* ProfileEdit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileEdit.swift; sourceTree = ""; }; C2F015282C09D420000F7221 /* Stub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stub.swift; sourceTree = ""; }; C2F015292C09D420000F7221 /* PartyEnregistery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartyEnregistery.swift; sourceTree = ""; }; - C2F015382C09D5A5000F7221 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Localizable.strings; sourceTree = ""; }; - C2F0153C2C09D5C0000F7221 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = Localizable.strings; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -118,6 +124,23 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 165725EB2C1985920052D7EF /* Ressources */ = { + isa = PBXGroup; + children = ( + 165725EC2C1985920052D7EF /* Localizable.strings */, + 165725EF2C1985920052D7EF /* Font */, + ); + path = Ressources; + sourceTree = ""; + }; + 165725EF2C1985920052D7EF /* Font */ = { + isa = PBXGroup; + children = ( + 165725F02C1985920052D7EF /* nuku1.ttf */, + ); + path = Font; + sourceTree = ""; + }; 8203E9052BF60117005F5C4A /* Frameworks */ = { isa = PBXGroup; children = ( @@ -147,6 +170,7 @@ C205A2AA2BF373360097BD93 = { isa = PBXGroup; children = ( + 165725EB2C1985920052D7EF /* Ressources */, C205A2B52BF373360097BD93 /* ArkitDoushiQi */, C205A2C62BF373380097BD93 /* ArkitDoushiQiTests */, C205A2D02BF373380097BD93 /* ArkitDoushiQiUITests */, @@ -168,7 +192,7 @@ C205A2B52BF373360097BD93 /* ArkitDoushiQi */ = { isa = PBXGroup; children = ( - C2F015352C09D592000F7221 /* Resources */, + 16038A2A2C197DEC0074346E /* Info.plist */, C2F015072C09D366000F7221 /* Utils */, 82CE59E52C045C7500ADEE24 /* Game */, C205A2B62BF373360097BD93 /* ArkitDoushiQiApp.swift */, @@ -230,6 +254,8 @@ isa = PBXGroup; children = ( C2F015082C09D366000F7221 /* LanguageSettings.swift */, + 16038A262C197B800074346E /* FlagManager.swift */, + 165725E92C1984CC0052D7EF /* FontManager.swift */, ); path = Utils; sourceTree = ""; @@ -292,31 +318,6 @@ path = PartyEnregistery; sourceTree = ""; }; - C2F015352C09D592000F7221 /* Resources */ = { - isa = PBXGroup; - children = ( - C2F0153A2C09D5C0000F7221 /* fr.lproj */, - C2F015362C09D5A5000F7221 /* en.lproj */, - ); - path = Resources; - sourceTree = ""; - }; - C2F015362C09D5A5000F7221 /* en.lproj */ = { - isa = PBXGroup; - children = ( - C2F015372C09D5A5000F7221 /* Localizable.strings */, - ); - path = en.lproj; - sourceTree = SOURCE_ROOT; - }; - C2F0153A2C09D5C0000F7221 /* fr.lproj */ = { - isa = PBXGroup; - children = ( - C2F0153B2C09D5C0000F7221 /* Localizable.strings */, - ); - path = fr.lproj; - sourceTree = SOURCE_ROOT; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -423,8 +424,8 @@ buildActionMask = 2147483647; files = ( C205A2BE2BF373380097BD93 /* Preview Assets.xcassets in Resources */, - C2F0153D2C09D5C0000F7221 /* Localizable.strings in Resources */, - C2F015392C09D5A5000F7221 /* Localizable.strings in Resources */, + 165725F22C1985920052D7EF /* nuku1.ttf in Resources */, + 165725F12C1985920052D7EF /* Localizable.strings in Resources */, C205A2BB2BF373380097BD93 /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -457,6 +458,7 @@ C2F0150C2C09D3A4000F7221 /* KeyboardReadable.swift in Sources */, 82CE59E92C045D1100ADEE24 /* GameScene.swift in Sources */, C2F015242C09D3E7000F7221 /* ProfileComponent.swift in Sources */, + 16038A272C197B800074346E /* FlagManager.swift in Sources */, C2F0151E2C09D3E7000F7221 /* PickerComponent.swift in Sources */, C2F015212C09D3E7000F7221 /* EditImageComponent.swift in Sources */, C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */, @@ -471,6 +473,7 @@ 82CE59EB2C045E3800ADEE24 /* GameView.swift in Sources */, C2F0152B2C09D420000F7221 /* PartyEnregistery.swift in Sources */, C2F015102C09D3C3000F7221 /* Language.swift in Sources */, + 165725EA2C1984CC0052D7EF /* FontManager.swift in Sources */, C25220EE2C00AC7E0026B71F /* GameParametersMenuView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -508,18 +511,11 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - C2F015372C09D5A5000F7221 /* Localizable.strings */ = { - isa = PBXVariantGroup; - children = ( - C2F015382C09D5A5000F7221 /* en */, - ); - name = Localizable.strings; - sourceTree = ""; - }; - C2F0153B2C09D5C0000F7221 /* Localizable.strings */ = { + 165725EC2C1985920052D7EF /* Localizable.strings */ = { isa = PBXVariantGroup; children = ( - C2F0153C2C09D5C0000F7221 /* fr */, + 165725ED2C1985920052D7EF /* en */, + 165725EE2C1985920052D7EF /* fr */, ); name = Localizable.strings; sourceTree = ""; @@ -651,6 +647,7 @@ DEVELOPMENT_ASSET_PATHS = "\"ArkitDoushiQi/Views\""; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ArkitDoushiQi/Info.plist; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -679,6 +676,7 @@ DEVELOPMENT_ASSET_PATHS = "\"ArkitDoushiQi/Views\""; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ArkitDoushiQi/Info.plist; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff --git a/ArkitDoushiQi/ArkitDoushiQi/Info.plist b/ArkitDoushiQi/ArkitDoushiQi/Info.plist new file mode 100644 index 0000000..bdb00a1 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Info.plist @@ -0,0 +1,19 @@ + + + + + UTImportedTypeDeclarations + + + UTTypeIconFiles + + UTTypeTagSpecification + + + + UIAppFonts + + nuku1.ttf + + + diff --git a/ArkitDoushiQi/ArkitDoushiQi/MainMenu.swift b/ArkitDoushiQi/ArkitDoushiQi/MainMenu.swift index 15bddc3..2bbb518 100644 --- a/ArkitDoushiQi/ArkitDoushiQi/MainMenu.swift +++ b/ArkitDoushiQi/ArkitDoushiQi/MainMenu.swift @@ -4,9 +4,36 @@ // // Created by Johan LACHENAL on 16/05/2024. // - 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 @@ -14,78 +41,94 @@ struct MainMenu: View { @State private var action: Int? = 0 @AppStorage("isDarkMode") private var isDarkMode = false @State private var reloadView = false + @State private var showLanguagePicker = false + @ScaledMetric(relativeTo: .body) var scaledPadding: CGFloat = 10 + @Environment(\.colorScheme) var colorScheme var body: some View { NavigationView { ZStack { - // Ajouter l'image en arrière-plan - Image("BackGroundMenu") - .resizable() - .aspectRatio(contentMode: .fill) + // Utiliser la vue animée en arrière-plan + AnimatedCherryBlossomView() .edgesIgnoringSafeArea(.all) - .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) - VStack { - // Ajouter un HStack pour le titre et l'icône des paramètres - HStack { - - Button(action: { - isDarkMode.toggle() - }) { - Image(systemName: isDarkMode ? "sun.max.fill" : "moon.fill") - .foregroundColor(.white) - .padding() - } - - Button(action: { - // Action pour changer la langue - NotificationCenter.default.post(name: NSNotification.Name("LanguageChanged"), object: nil) - }) { - Image(systemName: "globe") - .foregroundColor(.white) - .padding() - } - - } + // Ajouter le titre du jeu + Text("DOUSHIQI") + .font(.custom("Nuku Nuku", size: 48, relativeTo: .largeTitle)) // Utilisez le nom PostScript correct + .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 + .foregroundColor(colorScheme == .dark ? .white : .black) Spacer() // Bouton "Jouer" au centre et plus grand, sans bandeau bleu - NavigationLink(destination: GameParametersMenuView()) - { + NavigationLink(destination: GameParametersMenuView()) { Text(playButtonText) - .font(.largeTitle) + .font(.custom("Nuku Nuku", size: 32, relativeTo: .title)) .bold() .frame(maxWidth: .infinity) .padding() .background(Color.white.opacity(0.2)) - .foregroundColor(.white) + .foregroundColor(colorScheme == .dark ? .white : .black) .cornerRadius(10) .overlay( RoundedRectangle(cornerRadius: 10) - .stroke(Color.white, lineWidth: 2) + .stroke(colorScheme == .dark ? Color.white : Color.black, lineWidth: 2) ) .shadow(radius: 10) + .padding(scaledPadding) } .padding(.horizontal, 50) - Spacer().frame(height: 40) // Bouton "Parties enregistrées" plus discret - NavigationLink(destination: PartyListView()) - { + NavigationLink(destination: PartyListView()) { Text(registeredGamesButtonText) - .font(.headline) + .font(.custom("Nuku Nuku", size: 18, relativeTo: .body)) .padding() .background(Color.gray.opacity(0.7)) - .foregroundColor(.white) + .foregroundColor(colorScheme == .dark ? .white : .black) .cornerRadius(10) .shadow(radius: 5) + .padding(scaledPadding) } .padding(.horizontal, 50) + Spacer().frame(height: 20) + + // Ajouter les icônes pour les paramètres en bas du bouton "Registered Games" + HStack { + Button(action: { + isDarkMode.toggle() + }) { + Image(systemName: isDarkMode ? "sun.max.fill" : "moon.fill") + .foregroundColor(colorScheme == .dark ? .white : .black) + .padding() + .scaleEffect(1.2) + } + + Button(action: { + // Afficher le sélecteur de langue + showLanguagePicker.toggle() + }) { + Image(systemName: "globe") + .foregroundColor(colorScheme == .dark ? .white : .black) + .padding() + .scaleEffect(1.2) + } + .sheet(isPresented: $showLanguagePicker) { + LanguagePickerView(showLanguagePicker: $showLanguagePicker) + .environmentObject(languageSettings) + } + } + .padding(scaledPadding) + Spacer() } .padding(EdgeInsets(top: 10, leading: 32, bottom: 10, trailing: 32)) @@ -98,6 +141,62 @@ 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") diff --git a/ArkitDoushiQi/ArkitDoushiQi/Utils/FlagManager.swift b/ArkitDoushiQi/ArkitDoushiQi/Utils/FlagManager.swift new file mode 100644 index 0000000..5401a9b --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Utils/FlagManager.swift @@ -0,0 +1,17 @@ +// +// FlagManager.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 12/06/2024. +// + +import SwiftUI + +func flag(country: String) -> String { + let base = 127397 + var usv = String.UnicodeScalarView() + for i in country.utf16 { + usv.append(UnicodeScalar(base + Int(i))!) + } + return String(usv) +} diff --git a/ArkitDoushiQi/ArkitDoushiQi/Utils/FontManager.swift b/ArkitDoushiQi/ArkitDoushiQi/Utils/FontManager.swift new file mode 100644 index 0000000..27df529 --- /dev/null +++ b/ArkitDoushiQi/ArkitDoushiQi/Utils/FontManager.swift @@ -0,0 +1,24 @@ +// +// FontManager.swift +// ArkitDoushiQi +// +// Created by Louis DUFOUR on 12/06/2024. +// + +import Foundation +import UIKit + +class AppDelegate: UIResponder, UIApplicationDelegate { + var window: UIWindow? + + func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + for family in UIFont.familyNames.sorted() { + let names = UIFont.fontNames(forFamilyName: family) + print("Family: \(family) Font names: \(names)") + } + + return true + } +} diff --git a/ArkitDoushiQi/Ressources/Font/nuku1.ttf b/ArkitDoushiQi/Ressources/Font/nuku1.ttf new file mode 100644 index 0000000..b2cc8f4 Binary files /dev/null and b/ArkitDoushiQi/Ressources/Font/nuku1.ttf differ diff --git a/ArkitDoushiQi/en.lproj/Localizable.strings b/ArkitDoushiQi/Ressources/en.lproj/Localizable.strings similarity index 100% rename from ArkitDoushiQi/en.lproj/Localizable.strings rename to ArkitDoushiQi/Ressources/en.lproj/Localizable.strings diff --git a/ArkitDoushiQi/fr.lproj/Localizable.strings b/ArkitDoushiQi/Ressources/fr.lproj/Localizable.strings similarity index 100% rename from ArkitDoushiQi/fr.lproj/Localizable.strings rename to ArkitDoushiQi/Ressources/fr.lproj/Localizable.strings