Skip to content

Commit

Permalink
Song score saving (scuffed)
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Feb 11, 2023
1 parent 5c4429d commit ba6b3d5
Show file tree
Hide file tree
Showing 18 changed files with 497 additions and 58 deletions.
4 changes: 2 additions & 2 deletions Assets/Prefabs/UI/SongView.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ GameObject:
- component: {fileID: 7898971487434874996}
- component: {fileID: 1200385484507932754}
m_Layer: 5
m_Name: Length Text
m_Name: Score Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -760,7 +760,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
songName: {fileID: 6846856528720448031}
artist: {fileID: 7006697502306556741}
lengthText: {fileID: 1200385484507932754}
scoreText: {fileID: 1200385484507932754}
--- !u!225 &215129106566158253
CanvasGroup:
m_ObjectHideFlags: 0
Expand Down
168 changes: 163 additions & 5 deletions Assets/Scenes/MenuScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -3811,7 +3811,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -7.9999695, y: -30.500004}
m_AnchoredPosition: {x: -7.9999084, y: -52.5}
m_SizeDelta: {x: 125, y: 11}
m_Pivot: {x: 0.9999996, y: 1}
--- !u!114 &1886399724
Expand Down Expand Up @@ -4116,7 +4116,7 @@ GameObject:
- component: {fileID: 1986583193}
- component: {fileID: 1986583192}
m_Layer: 5
m_Name: Length Text
m_Name: Score Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand All @@ -4140,7 +4140,7 @@ RectTransform:
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -7.9999695, y: -12.5}
m_SizeDelta: {x: 125, y: 29}
m_SizeDelta: {x: 125, y: 20}
m_Pivot: {x: 0.9999996, y: 1}
--- !u!114 &1986583192
MonoBehaviour:
Expand Down Expand Up @@ -4182,7 +4182,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: N/A
m_text: 1:23
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ae170e91fd29a90479e906ddffb1d8ee, type: 2}
m_sharedMaterial: {fileID: 2100000, guid: 97a4ac31562f98641a2b7822989f607a, type: 2}
Expand Down Expand Up @@ -4292,6 +4292,7 @@ RectTransform:
m_Children:
- {fileID: 1844302445}
- {fileID: 1986583191}
- {fileID: 2086297276}
- {fileID: 1886399723}
- {fileID: 1330867043}
- {fileID: 80151784}
Expand Down Expand Up @@ -4358,13 +4359,170 @@ MonoBehaviour:
m_EditorClassIdentifier:
songName: {fileID: 149797927}
artist: {fileID: 1290299072}
lengthText: {fileID: 1986583193}
scoreText: {fileID: 1986583193}
lengthText: {fileID: 2086297278}
supportText: {fileID: 1886399725}
albumCover: {fileID: 1330867046}
albumCoverAlt: {fileID: 1876917083}
difficultyContainer: {fileID: 332568989}
difficultyView: {fileID: 397774209812536635, guid: 53438a07c6e5ec5409d5bde8514761ca,
type: 3}
--- !u!1 &2086297275
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2086297276}
- component: {fileID: 2086297279}
- component: {fileID: 2086297278}
- component: {fileID: 2086297277}
m_Layer: 5
m_Name: Length Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2086297276
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2086297275}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2044165073}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -7.9999084, y: -32.5}
m_SizeDelta: {x: 125, y: 20}
m_Pivot: {x: 0.9999996, y: 1}
--- !u!114 &2086297277
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2086297275}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: 0
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!114 &2086297278
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2086297275}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: N/A
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ae170e91fd29a90479e906ddffb1d8ee, type: 2}
m_sharedMaterial: {fileID: 2100000, guid: 97a4ac31562f98641a2b7822989f607a, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 16
m_fontSizeBase: 16
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 4
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 0
m_wordWrappingRatios: 0.4
m_overflowMode: 1
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &2086297279
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2086297275}
m_CullTransparentMesh: 1
--- !u!1 &2115213575
GameObject:
m_ObjectHideFlags: 0
Expand Down
9 changes: 9 additions & 0 deletions Assets/Script/Data/SongInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public class SongInfo {
[JsonConverter(typeof(DirectoryInfoConverter))]
public DirectoryInfo folder;

/// <summary>
/// For remote mode only.
/// </summary>
public DirectoryInfo realFolderRemote;

public bool BassPedal2xExpertPlus {
private set;
get;
Expand Down Expand Up @@ -163,5 +168,9 @@ public SongInfo(DirectoryInfo folder) {

partDifficulties = new(DEFAULT_DIFFS);
}

public SongInfo Duplicate() {
return (SongInfo) MemberwiseClone();
}
}
}
15 changes: 15 additions & 0 deletions Assets/Script/Data/SongScore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;

namespace YARG.Data {
[JsonObject(MemberSerialization.Fields)]
public class SongScore {
public DateTime lastPlayed;
public int timesPlayed;

public float TotalHighestPercent => highestPercent.Max(i => i.Value);
public Dictionary<string, float> highestPercent;
}
}
11 changes: 11 additions & 0 deletions Assets/Script/Data/SongScore.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Assets/Script/PlayMode/AbstractTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ private void Start() {
player.inputStrategy.StarpowerEvent += StarpowerAction;
Play.Instance.BeatEvent += BeatAction;

player.lastScore = null;

GameUI.Instance.AddTrackImage(trackCamera.targetTexture);

// Adjust hit window
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/PlayMode/DrumsTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected override void OnDestroy() {

// Set score
player.lastScore = new PlayerManager.Score {
percentage = (float) notesHit / Chart.Count,
percentage = notesHit == 0 ? 1f : (float) notesHit / Chart.Count,
notesHit = notesHit,
notesMissed = Chart.Count - notesHit
};
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/PlayMode/FiveFretTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override void OnDestroy() {

// Set score
player.lastScore = new PlayerManager.Score {
percentage = (float) notesHit / Chart.Count,
percentage = notesHit == 0 ? 1f : (float) notesHit / Chart.Count,
notesHit = notesHit,
notesMissed = Chart.Count - notesHit
};
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/PlayMode/RealGuitarTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected override void OnDestroy() {

// Set score
player.lastScore = new PlayerManager.Score {
percentage = (float) notesHit / Chart.Count,
percentage = notesHit == 0 ? 1f : (float) notesHit / Chart.Count,
notesHit = notesHit,
notesMissed = Chart.Count - notesHit
};
Expand Down
Loading

0 comments on commit ba6b3d5

Please sign in to comment.