Skip to content

Commit

Permalink
Fix multiple crashes and better management of the songdict
Browse files Browse the repository at this point in the history
  • Loading branch information
0auBSQ committed May 29, 2022
1 parent 12a465e commit 39b8e7a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
18 changes: 18 additions & 0 deletions TJAPlayer3/Common/CSongDict.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ public static void tAddSongNode(string id, C曲リストノード node)
nodes.Add(id, node.Clone());
}

public static void tAddSongUrl(string url, C曲リストノード node)
{

}

public static void tRemoveSongNode(CSongUniqueID sid)
{
if (sid != null && nodes.ContainsKey(sid.data.id))
{
nodes.Remove(sid.data.id);
}
}

public static void tClearSongNodes()
{
nodes.Clear();
}

#endregion

#region [Extra methods]
Expand Down
1 change: 1 addition & 0 deletions TJAPlayer3/Songs/CSongUniqueID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace TJAPlayer3
{
[Serializable()]
internal class CSongUniqueID
{
public CSongUniqueID(string path)
Expand Down
15 changes: 15 additions & 0 deletions TJAPlayer3/Songs/CSong管理.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using TJAPlayer3.C曲リストノードComparers;
using FDK;
Expand Down Expand Up @@ -112,19 +113,25 @@ public void UpdateDownloadBox()

if (downloadBox != null)
{

var flatten = TJAPlayer3.stage選曲.act曲リスト.flattenList(downloadBox.list子リスト);

// Works because flattenList creates a new List
for (int i = 0; i < downloadBox.list子リスト.Count; i++)
{
CSongDict.tRemoveSongNode(downloadBox.list子リスト[i].uniqueId);
downloadBox.list子リスト.Remove(downloadBox.list子リスト[i]);
i--;
}


var path = downloadBox.arスコア[0].ファイル情報.フォルダの絶対パス;

if (flatten.Count > 0)
{
int index = list曲ルート.IndexOf(flatten[0]);

/*
if (!list曲ルート.Contains(downloadBox))
{
for (int i = 0; i < flatten.Count; i++)
Expand All @@ -133,6 +140,13 @@ public void UpdateDownloadBox()
}
list曲ルート.Insert(index, downloadBox);
}
*/

if (!list曲ルート.Contains(downloadBox))
{
this.list曲ルート = this.list曲ルート.Except(flatten).ToList();
list曲ルート.Insert(index, downloadBox);
}

t曲を検索してリストを作成する(path, true, downloadBox.list子リスト, downloadBox);
this.t曲リストへ後処理を適用する(downloadBox.list子リスト, $"/{downloadBox.strタイトル}/");
Expand Down Expand Up @@ -436,6 +450,7 @@ private void t曲を検索してリストを作成する( string str基点フォ
c曲リストノード.uniqueId = dtx.uniqueID;

CSongDict.tAddSongNode(c曲リストノード.uniqueId.data.id, c曲リストノード);
CSongDict.tAddSongUrl(c曲リストノード.uniqueId.data.url, c曲リストノード);

c曲リストノード.arスコア[ n ] = new Cスコア();
c曲リストノード.arスコア[ n ].ファイル情報.ファイルの絶対パス = str基点フォルダ + fileinfo.Name;
Expand Down
1 change: 1 addition & 0 deletions TJAPlayer3/Stages/02.Title/CEnumSongs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ private void t曲リストの構築2()
{
if ( !string.IsNullOrEmpty( TJAPlayer3.ConfigIni.str曲データ検索パス ) )
{
CSongDict.tClearSongNodes();
string[] strArray = TJAPlayer3.ConfigIni.str曲データ検索パス.Split( new char[] { ';' } );
if ( strArray.Length > 0 )
{
Expand Down
13 changes: 1 addition & 12 deletions TJAPlayer3/Stages/05.SongSelect/CActSelect曲リスト.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,7 @@ public void tReturnToRootBox()

public bool tBOXを出る()
{
//Trace.TraceInformation( "box exit" );
//Trace.TraceInformation( "Skin現在Current : " + CDTXMania.Skin.GetCurrentSkinSubfolderFullName(false) );
//Trace.TraceInformation( "Skin現在System : " + CSkin.strSystemSkinSubfolderFullName );
//Trace.TraceInformation( "Skin現在BoxDef : " + CSkin.strBoxDefSkinSubfolderFullName );
//Trace.TraceInformation( "Skin現在: " + CSkin.GetSkinName( CDTXMania.Skin.GetCurrentSkinSubfolderFullName(false) ) );
//Trace.TraceInformation( "Skin現pt: " + CDTXMania.Skin.GetCurrentSkinSubfolderFullName(false) );
//Trace.TraceInformation( "Skin指定: " + CSkin.GetSkinName( this.r現在選択中の曲.strSkinPath ) );
//Trace.TraceInformation( "Skinpath: " + this.r現在選択中の曲.strSkinPath );

bool ret = false;
if ( CSkin.GetSkinName( TJAPlayer3.Skin.GetCurrentSkinSubfolderFullName( false ) ) != CSkin.GetSkinName( this.r現在選択中の曲.strSkinPath )
&& CSkin.bUseBoxDefSkin )
Expand All @@ -328,10 +321,6 @@ public bool tBOXを出る()
// tBoxに入る()とは処理が微妙に異なるので注意
TJAPlayer3.Skin.SetCurrentSkinSubfolderFullName(
( this.r現在選択中の曲.strSkinPath == "" ) ? "" : TJAPlayer3.Skin.GetSkinSubfolderFullNameFromSkinName( CSkin.GetSkinName( this.r現在選択中の曲.strSkinPath ) ), false );
//Trace.TraceInformation( "SKIN変更: " + CSkin.GetSkinName( CDTXMania.Skin.GetCurrentSkinSubfolderFullName(false) ) );
//Trace.TraceInformation( "SKIN変更Current : "+ CDTXMania.Skin.GetCurrentSkinSubfolderFullName(false) );
//Trace.TraceInformation( "SKIN変更System : "+ CSkin.strSystemSkinSubfolderFullName );
//Trace.TraceInformation( "SKIN変更BoxDef : "+ CSkin.strBoxDefSkinSubfolderFullName );

// Complete list of songs
List<C曲リストノード> list = TJAPlayer3.Songs管理.list曲ルート;
Expand Down

0 comments on commit 39b8e7a

Please sign in to comment.