diff --git a/DouShouQi_App/DouShouQi-App-Info.plist b/DouShouQi_App/DouShouQi-App-Info.plist
index 0c67376..b31fd90 100644
--- a/DouShouQi_App/DouShouQi-App-Info.plist
+++ b/DouShouQi_App/DouShouQi-App-Info.plist
@@ -1,5 +1,10 @@
-
+
+ UIAppFonts
+
+ samurai.ttf
+
+
diff --git a/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj b/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj
index 036d4c0..13e4fcf 100644
--- a/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj
+++ b/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj
@@ -20,6 +20,8 @@
645834892BF5FEA000E18321 /* DSQ.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 645834872BF5FEA000E18321 /* DSQ.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
645B4C202BFCCA0500FD658A /* PlayerResumeFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = 645B4C1F2BFCCA0500FD658A /* PlayerResumeFrame.swift */; };
645B4C252BFCD3C600FD658A /* ScoreBoardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 645B4C242BFCD3C600FD658A /* ScoreBoardView.swift */; };
+ 6493C1C02C046BF900B5121D /* samurai.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6493C1BF2C046BF900B5121D /* samurai.ttf */; };
+ 6493C1C22C046E5E00B5121D /* Fonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6493C1C12C046E5E00B5121D /* Fonts.swift */; };
649ABF5B2BF60D78002E8894 /* MainMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649ABF5A2BF60D78002E8894 /* MainMenuView.swift */; };
649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649ABF5F2BF60F2D002E8894 /* MainMenuButton.swift */; };
649B59A42BF64574002BAE38 /* TitlePageFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59A32BF64574002BAE38 /* TitlePageFrame.swift */; };
@@ -36,6 +38,8 @@
EC62C4FF2C0457AD0048CD0B /* TitleScreenMusic.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C4FE2C0457AD0048CD0B /* TitleScreenMusic.mp3 */; };
EC62C5012C045B590048CD0B /* SoundPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C5002C045B590048CD0B /* SoundPlayer.swift */; };
EC62C5062C045C1A0048CD0B /* TitleScreenButtonSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */; };
+ EC62C5092C0467240048CD0B /* SplashScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C5082C0467240048CD0B /* SplashScreenView.swift */; };
+ EC62C50D2C046D9E0048CD0B /* SplashScreenSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -86,6 +90,8 @@
645834872BF5FEA000E18321 /* DSQ.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = DSQ.xcframework; sourceTree = ""; };
645B4C1F2BFCCA0500FD658A /* PlayerResumeFrame.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerResumeFrame.swift; sourceTree = ""; };
645B4C242BFCD3C600FD658A /* ScoreBoardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScoreBoardView.swift; sourceTree = ""; };
+ 6493C1BF2C046BF900B5121D /* samurai.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = samurai.ttf; sourceTree = ""; };
+ 6493C1C12C046E5E00B5121D /* Fonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fonts.swift; sourceTree = ""; };
649ABF5A2BF60D78002E8894 /* MainMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuView.swift; sourceTree = ""; };
649ABF5F2BF60F2D002E8894 /* MainMenuButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuButton.swift; sourceTree = ""; };
649B59A32BF64574002BAE38 /* TitlePageFrame.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitlePageFrame.swift; sourceTree = ""; };
@@ -102,6 +108,8 @@
EC62C4FE2C0457AD0048CD0B /* TitleScreenMusic.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = TitleScreenMusic.mp3; sourceTree = ""; };
EC62C5002C045B590048CD0B /* SoundPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundPlayer.swift; sourceTree = ""; };
EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = TitleScreenButtonSound.mp3; sourceTree = ""; };
+ EC62C5082C0467240048CD0B /* SplashScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashScreenView.swift; sourceTree = ""; };
+ EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = SplashScreenSound.mp3; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -235,12 +243,21 @@
path = Player;
sourceTree = "";
};
+ 6493C1BE2C04650200B5121D /* Menu */ = {
+ isa = PBXGroup;
+ children = (
+ 649ABF5A2BF60D78002E8894 /* MainMenuView.swift */,
+ EC62C5082C0467240048CD0B /* SplashScreenView.swift */,
+ );
+ path = Menu;
+ sourceTree = "";
+ };
649ABF592BF60D13002E8894 /* Views */ = {
isa = PBXGroup;
children = (
643AB6992BFCFB480018DA73 /* Game */,
645B4C232BFCD39A00FD658A /* Player */,
- 649ABF5A2BF60D78002E8894 /* MainMenuView.swift */,
+ 6493C1BE2C04650200B5121D /* Menu */,
);
path = Views;
sourceTree = "";
@@ -289,8 +306,10 @@
649B59B02BF65360002BAE38 /* TextStyles */ = {
isa = PBXGroup;
children = (
+ 6493C1BF2C046BF900B5121D /* samurai.ttf */,
649B59B12BF65392002BAE38 /* TextStyles.swift */,
649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */,
+ 6493C1C12C046E5E00B5121D /* Fonts.swift */,
);
path = TextStyles;
sourceTree = "";
@@ -307,6 +326,7 @@
EC62C5032C045BD30048CD0B /* Sounds */ = {
isa = PBXGroup;
children = (
+ EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */,
EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */,
);
path = Sounds;
@@ -426,8 +446,10 @@
buildActionMask = 2147483647;
files = (
649B59A72BF64BA9002BAE38 /* Colors.xcassets in Resources */,
+ 6493C1C02C046BF900B5121D /* samurai.ttf in Resources */,
EC62C5062C045C1A0048CD0B /* TitleScreenButtonSound.mp3 in Resources */,
649B59AC2BF64E12002BAE38 /* Images.xcassets in Resources */,
+ EC62C50D2C046D9E0048CD0B /* SplashScreenSound.mp3 in Resources */,
645834632BF5F92500E18321 /* Preview Assets.xcassets in Resources */,
645834602BF5F92500E18321 /* Assets.xcassets in Resources */,
EC62C4FF2C0457AD0048CD0B /* TitleScreenMusic.mp3 in Resources */,
@@ -466,12 +488,14 @@
643AB6932BFCEFD00018DA73 /* GameResumeFrame.swift in Sources */,
EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */,
649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */,
+ EC62C5092C0467240048CD0B /* SplashScreenView.swift in Sources */,
EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */,
EC62C4FD2C0391D30048CD0B /* PlayerRow.swift in Sources */,
EC62C4FB2C038BD20048CD0B /* PlayersView.swift in Sources */,
6458345C2BF5F92300E18321 /* DouShouQi_AppApp.swift in Sources */,
645B4C202BFCCA0500FD658A /* PlayerResumeFrame.swift in Sources */,
649ABF5B2BF60D78002E8894 /* MainMenuView.swift in Sources */,
+ 6493C1C22C046E5E00B5121D /* Fonts.swift in Sources */,
649B59A42BF64574002BAE38 /* TitlePageFrame.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/DouShouQi_App/DouShouQi_App/Assets/Sounds/SplashScreenSound.mp3 b/DouShouQi_App/DouShouQi_App/Assets/Sounds/SplashScreenSound.mp3
new file mode 100644
index 0000000..9c5c9d1
Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Sounds/SplashScreenSound.mp3 differ
diff --git a/DouShouQi_App/DouShouQi_App/Assets/TextStyles/Fonts.swift b/DouShouQi_App/DouShouQi_App/Assets/TextStyles/Fonts.swift
new file mode 100644
index 0000000..56f2dbf
--- /dev/null
+++ b/DouShouQi_App/DouShouQi_App/Assets/TextStyles/Fonts.swift
@@ -0,0 +1,12 @@
+//
+// Fonts.swift
+// DouShouQi_App
+//
+// Created by Rémi REGNAULT on 27/05/2024.
+//
+
+import Foundation
+
+public struct Fonts {
+ static let title = "samurai"
+}
diff --git a/DouShouQi_App/DouShouQi_App/Assets/TextStyles/TextStyles.swift b/DouShouQi_App/DouShouQi_App/Assets/TextStyles/TextStyles.swift
index 59d5d13..8fd71f8 100644
--- a/DouShouQi_App/DouShouQi_App/Assets/TextStyles/TextStyles.swift
+++ b/DouShouQi_App/DouShouQi_App/Assets/TextStyles/TextStyles.swift
@@ -8,14 +8,14 @@
import Foundation
import SwiftUI
-protocol TextStyle: ViewModifier {}
+protocol TextStyles: ViewModifier {}
extension Text {
- func textStyle(T: any TextStyle) {
- modifier(T)
+ func textStyle(_ style: T) -> some View {
+ modifier(style)
}
}
-struct TextStyles {
- static let ViewTitle = ViewTitleTextStyle()
+struct CustomTextStyles {
+ static let Title = ViewTitleTextStyle()
}
diff --git a/DouShouQi_App/DouShouQi_App/Assets/TextStyles/ViewTitleTextStyle.swift b/DouShouQi_App/DouShouQi_App/Assets/TextStyles/ViewTitleTextStyle.swift
index 4e1c641..602bb67 100644
--- a/DouShouQi_App/DouShouQi_App/Assets/TextStyles/ViewTitleTextStyle.swift
+++ b/DouShouQi_App/DouShouQi_App/Assets/TextStyles/ViewTitleTextStyle.swift
@@ -8,10 +8,11 @@
import Foundation
import SwiftUI
-struct ViewTitleTextStyle: TextStyle {
+struct ViewTitleTextStyle: TextStyles {
func body(content: Content) -> some View {
content
.foregroundColor(Colors.TitleText)
.fontWeight(.bold)
+ .font(.custom(Fonts.title, size: 30))
}
}
diff --git a/DouShouQi_App/DouShouQi_App/Assets/TextStyles/samurai.ttf b/DouShouQi_App/DouShouQi_App/Assets/TextStyles/samurai.ttf
new file mode 100644
index 0000000..5de690c
Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/TextStyles/samurai.ttf differ
diff --git a/DouShouQi_App/DouShouQi_App/Components/MainMenuButton.swift b/DouShouQi_App/DouShouQi_App/Components/MainMenuButton.swift
index 4fab5d2..b421b74 100644
--- a/DouShouQi_App/DouShouQi_App/Components/MainMenuButton.swift
+++ b/DouShouQi_App/DouShouQi_App/Components/MainMenuButton.swift
@@ -15,6 +15,15 @@ struct MainMenuButton: View {
var sound: String
+ // Button Alignment
+ var horizontalAlignment: Alignment = .center
+
+ // Button corner radius
+ var topLeftCorner: CGFloat = 0
+ var topRightCorner: CGFloat = 0
+ var bottomLeftCorner: CGFloat = 0
+ var bottomRightCorner: CGFloat = 0
+
var body: some View {
NavigationLink(destination: destination) {
Text(text.uppercased())
@@ -26,15 +35,14 @@ struct MainMenuButton: View {
.background(
Color.red
.clipShape(RoundedRectangle(cornerSize: CGSize(width: 0, height: 0)))
- .mask(RoundedCornersShape(cornerRadii: (topLeft: 0, topRight: 10, bottomLeft: 0, bottomRight: 10)))
+ .mask(RoundedCornersShape(cornerRadii: (topLeft: topLeftCorner, topRight: topRightCorner, bottomLeft: bottomLeftCorner, bottomRight: bottomRightCorner)))
)
}
.simultaneousGesture(TapGesture().onEnded {
playSound(named: sound)
})
-
.frame(width: UIScreen.main.bounds.width / 1.7)
- .frame(maxWidth: .infinity, alignment: .leading)
+ .frame(maxWidth: .infinity, alignment: horizontalAlignment)
}
}
@@ -84,6 +92,6 @@ struct RoundedCornersShape: Shape {
struct MainMenuButton_Previews: PreviewProvider {
static var previews: some View {
- MainMenuButton(text: "test", destination: HistoricView(), sound: "TitleScreenButtonSound")
+ MainMenuButton(text: "test", destination: HistoricView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
}
}
diff --git a/DouShouQi_App/DouShouQi_App/Components/TitlePageFrame.swift b/DouShouQi_App/DouShouQi_App/Components/TitlePageFrame.swift
index 7f6be9c..5346fe0 100644
--- a/DouShouQi_App/DouShouQi_App/Components/TitlePageFrame.swift
+++ b/DouShouQi_App/DouShouQi_App/Components/TitlePageFrame.swift
@@ -13,8 +13,8 @@ struct TitlePageFrame: View {
var Text: String
// Image Params
- var ImageWidth: CGFloat
- var ImageHeight: CGFloat
+ var ImageWidth: CGFloat = 200
+ var ImageHeight: CGFloat = 200
var body: some View {
VStack(alignment: .leading) {
@@ -25,9 +25,7 @@ struct TitlePageFrame: View {
.frame(width: ImageWidth, height: ImageHeight)
SwiftUI.Text(self.Text)
- .foregroundColor(Colors.TitleText)
- .fontWeight(.bold)
- .font(.title)
+ .textStyle(CustomTextStyles.Title)
}
}
@@ -36,6 +34,6 @@ struct TitlePageFrame: View {
struct TitlePageFrame_Previews: PreviewProvider {
static var previews: some View {
- TitlePageFrame(Text: "DouShouQi", ImageWidth: 200, ImageHeight: 200)
+ TitlePageFrame(Text: "DouShouQi")
}
}
diff --git a/DouShouQi_App/DouShouQi_App/Views/MainMenuView.swift b/DouShouQi_App/DouShouQi_App/Views/MainMenuView.swift
deleted file mode 100644
index 58de378..0000000
--- a/DouShouQi_App/DouShouQi_App/Views/MainMenuView.swift
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// MainMenuView.swift
-// DouShouQi_App
-//
-// Created by Rémi REGNAULT on 16/05/2024.
-//
-
-import SwiftUI
-
-struct MainMenuView: View {
- var body: some View {
- NavigationView {
- VStack {
- TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200)
- Spacer()
-
- VStack {
- HStack{
- VStack(spacing: 25) {
- MainMenuButton(text: "Play", destination: ScoreBoardView(), sound: "TitleScreenButtonSound")
- MainMenuButton(text: "Historique", destination: HistoricView(), sound: "TitleScreenButtonSound")
- MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound")
- MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound")
- }
- Image(AppImages.SemiLion)
- .resizable()
- .aspectRatio(contentMode: .fit)
- .frame(width: 200, height: 500)
- }
-
- }
- Spacer()
- HStack {
- Text("Copyright @")
- .font(.headline)
- .frame(alignment: .trailing)
-
- Text("Dou Shou Qi Team")
-
- Spacer()
-
- Text("2024")
- .frame(alignment: .trailing)
- }
- .padding() // Ajout de padding pour éviter que le contenu ne touche la bordure
- .background(Color.white) // Couleur de fond pour le HStack
- .overlay(
- Rectangle()
- .stroke(Color.black, lineWidth: 1) // Couleur et épaisseur de la bordure
- )
-
- Spacer()
- .onAppear {
- MusicPlayer.shared.playBackgroundMusic(music: "TitleScreenMusic")
- }
- .onDisappear {
- MusicPlayer.shared.stopBackgroundMusic()
- }
-
- }
- }
- }
-}
-
-struct MainMenuView_Previews: PreviewProvider {
- static var previews: some View {
- MainMenuView()
- }
-}
diff --git a/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift b/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift
new file mode 100644
index 0000000..6a893d5
--- /dev/null
+++ b/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift
@@ -0,0 +1,83 @@
+//
+// MainMenuView.swift
+// DouShouQi_App
+//
+// Created by Rémi REGNAULT on 16/05/2024.
+//
+
+import SwiftUI
+
+struct MainMenuView: View {
+
+ @State private var showSplash = true
+
+ var body: some View {
+ NavigationView {
+ VStack {
+ if showSplash {
+ SplashScreenView()
+ .transition(.opacity)
+ .animation(.easeOut(duration: 3), value: showSplash)
+ .onAppear {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 8) {
+ withAnimation {
+ showSplash = false
+ }
+ }
+ }
+ } else {
+ TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200)
+ Spacer()
+
+ VStack {
+ HStack {
+ VStack(spacing: 25) {
+ MainMenuButton(text: "Play", destination: ScoreBoardView(), sound: "TitleScreenButtonSound")
+ MainMenuButton(text: "Historique", destination: HistoricView(), sound: "TitleScreenButtonSound")
+ MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound")
+ MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound")
+ }
+ Image(AppImages.SemiLion)
+ .resizable()
+ .aspectRatio(contentMode: .fit)
+ .frame(width: 200, height: 500)
+ }
+ }
+ Spacer()
+ HStack {
+ Text("Copyright @")
+ .font(.headline)
+ .frame(alignment: .trailing)
+
+ Text("Dou Shou Qi Team")
+
+ Spacer()
+
+ Text("2024")
+ .frame(alignment: .trailing)
+ }
+ .padding()
+ .background(Color.white)
+ .overlay(
+ Rectangle()
+ .stroke(Color.black, lineWidth: 1)
+ )
+
+ Spacer()
+ .onAppear {
+ MusicPlayer.shared.playBackgroundMusic(music: "TitleScreenMusic")
+ }
+ .onDisappear {
+ MusicPlayer.shared.stopBackgroundMusic()
+ }
+ }
+ }
+ }
+ }
+}
+
+struct MainMenuView_Previews: PreviewProvider {
+ static var previews: some View {
+ MainMenuView()
+ }
+}
diff --git a/DouShouQi_App/DouShouQi_App/Views/Menu/SplashScreenView.swift b/DouShouQi_App/DouShouQi_App/Views/Menu/SplashScreenView.swift
new file mode 100644
index 0000000..50919d1
--- /dev/null
+++ b/DouShouQi_App/DouShouQi_App/Views/Menu/SplashScreenView.swift
@@ -0,0 +1,23 @@
+//
+// SplashScreenView.swift
+// DouShouQi_App
+//
+// Created by étudiant on 27/05/2024.
+//
+
+import SwiftUI
+
+struct SplashScreenView: View {
+ var body: some View {
+ TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200)
+ .onAppear {
+ playSound(named: "SplashScreenSound")
+ }
+ }
+}
+
+struct SplashScreenView_Previews: PreviewProvider {
+ static var previews: some View {
+ SplashScreenView()
+ }
+}