Fix for bug when saving project files as a different name

This commit is contained in:
dexy 2020-01-15 16:06:19 +11:00
parent 2eece95fa0
commit f7c3a18681
3 changed files with 82 additions and 8 deletions

View File

@ -1878,6 +1878,70 @@ namespace CodeWalker.Project.Panels
public void UpdateYmapTreeNode(YmapFile ymap)
{
var tn = FindYmapTreeNode(ymap);
if (tn != null)
{
tn.Text = ymap.RpfFileEntry?.Name ?? ymap.Name;
}
}
public void UpdateYtypTreeNode(YtypFile ytyp)
{
var tn = FindYtypTreeNode(ytyp);
if (tn != null)
{
tn.Text = ytyp.RpfFileEntry?.Name ?? ytyp.Name;
}
}
public void UpdateYbnTreeNode(YbnFile ybn)
{
var tn = FindYbnTreeNode(ybn);
if (tn != null)
{
tn.Text = ybn.RpfFileEntry?.Name ?? ybn.Name;
}
}
public void UpdateYndTreeNode(YndFile ynd)
{
var tn = FindYndTreeNode(ynd);
if (tn != null)
{
tn.Text = ynd.RpfFileEntry?.Name ?? ynd.Name;
}
}
public void UpdateYnvTreeNode(YnvFile ynv)
{
var tn = FindYnvTreeNode(ynv);
if (tn != null)
{
tn.Text = ynv.RpfFileEntry?.Name ?? ynv.Name;
}
}
public void UpdateTrainTrackTreeNode(TrainTrack track)
{
var tn = FindTrainTrackTreeNode(track);
if (tn != null)
{
tn.Text = track.RpfFileEntry?.Name ?? track.Name;
}
}
public void UpdateScenarioTreeNode(YmtFile scenarios)
{
var tn = FindScenarioTreeNode(scenarios);
if (tn != null)
{
tn.Text = scenarios.RpfFileEntry?.Name ?? scenarios.Name;
}
}
public void UpdateAudioRelTreeNode(RelFile rel)
{
var tn = FindAudioRelTreeNode(rel);
if (tn != null)
{
tn.Text = rel.RpfFileEntry?.Name ?? rel.Name;
}
}
public void UpdateArchetypeTreeNode(Archetype archetype)
{
var tn = FindArchetypeTreeNode(archetype);

View File

@ -402,7 +402,7 @@ namespace CodeWalker.Project
newfilename = newfilename.ToLowerInvariant();
for (int i = 0; i < YmapFilenames.Count; i++)
{
if (YmapFilenames[i] == oldfilename)
if (YmapFilenames[i]?.ToLowerInvariant() == oldfilename)
{
YmapFilenames[i] = newfilename;
HasChanged = true;
@ -472,7 +472,7 @@ namespace CodeWalker.Project
newfilename = newfilename.ToLowerInvariant();
for (int i = 0; i < YtypFilenames.Count; i++)
{
if (YtypFilenames[i] == oldfilename)
if (YtypFilenames[i]?.ToLowerInvariant() == oldfilename)
{
YtypFilenames[i] = newfilename;
HasChanged = true;
@ -539,7 +539,7 @@ namespace CodeWalker.Project
newfilename = newfilename.ToLowerInvariant();
for (int i = 0; i < YbnFilenames.Count; i++)
{
if (YbnFilenames[i] == oldfilename)
if (YbnFilenames[i]?.ToLowerInvariant() == oldfilename)
{
YbnFilenames[i] = newfilename;
HasChanged = true;
@ -606,7 +606,7 @@ namespace CodeWalker.Project
newfilename = newfilename.ToLowerInvariant();
for (int i = 0; i < YndFilenames.Count; i++)
{
if (YndFilenames[i] == oldfilename)
if (YndFilenames[i]?.ToLowerInvariant() == oldfilename)
{
YndFilenames[i] = newfilename;
HasChanged = true;
@ -673,7 +673,7 @@ namespace CodeWalker.Project
newfilename = newfilename.ToLowerInvariant();
for (int i = 0; i < YnvFilenames.Count; i++)
{
if (YnvFilenames[i] == oldfilename)
if (YnvFilenames[i]?.ToLowerInvariant() == oldfilename)
{
YnvFilenames[i] = newfilename;
HasChanged = true;
@ -740,7 +740,7 @@ namespace CodeWalker.Project
newfilename = newfilename.ToLowerInvariant();
for (int i = 0; i < TrainsFilenames.Count; i++)
{
if (TrainsFilenames[i] == oldfilename)
if (TrainsFilenames[i]?.ToLowerInvariant() == oldfilename)
{
TrainsFilenames[i] = newfilename;
HasChanged = true;
@ -809,7 +809,7 @@ namespace CodeWalker.Project
newfilename = newfilename.ToLowerInvariant();
for (int i = 0; i < ScenarioFilenames.Count; i++)
{
if (ScenarioFilenames[i] == oldfilename)
if (ScenarioFilenames[i]?.ToLowerInvariant() == oldfilename)
{
ScenarioFilenames[i] = newfilename;
HasChanged = true;
@ -877,7 +877,7 @@ namespace CodeWalker.Project
newfilename = newfilename.ToLowerInvariant();
for (int i = 0; i < AudioRelFilenames.Count; i++)
{
if (AudioRelFilenames[i] == oldfilename)
if (AudioRelFilenames[i]?.ToLowerInvariant() == oldfilename)
{
AudioRelFilenames[i] = newfilename;
HasChanged = true;

View File

@ -1719,6 +1719,8 @@ namespace CodeWalker.Project
{ //couldn't rename it in the project?
//MessageBox.Show("Couldn't rename ymap in project! This shouldn't happen - check the project file XML.");
}
ProjectExplorer?.UpdateYmapTreeNode(CurrentYmapFile);
}
SetProjectHasChanged(true);
SetCurrentSaveItem();
@ -2523,6 +2525,8 @@ namespace CodeWalker.Project
{ //couldn't rename it in the project?
//MessageBox.Show("Couldn't rename ytyp in project! This shouldn't happen - check the project file XML.");
}
ProjectExplorer?.UpdateYtypTreeNode(CurrentYtypFile);
}
SetProjectHasChanged(true);
SetCurrentSaveItem();
@ -3219,6 +3223,7 @@ namespace CodeWalker.Project
{ //couldn't rename it in the project? happens when project not saved yet...
//MessageBox.Show("Couldn't rename ybn in project! This shouldn't happen - check the project file XML.");
}
ProjectExplorer?.UpdateYbnTreeNode(CurrentYbnFile);
}
SetProjectHasChanged(true);
SetCurrentSaveItem();
@ -3890,6 +3895,7 @@ namespace CodeWalker.Project
{ //couldn't rename it in the project? happens when project not saved yet...
//MessageBox.Show("Couldn't rename ynd in project! This shouldn't happen - check the project file XML.");
}
ProjectExplorer?.UpdateYndTreeNode(CurrentYndFile);
}
SetProjectHasChanged(true);
SetCurrentSaveItem();
@ -4188,6 +4194,7 @@ namespace CodeWalker.Project
{ //couldn't rename it in the project? happens when project not saved yet...
//MessageBox.Show("Couldn't rename ynv in project! This shouldn't happen - check the project file XML.");
}
ProjectExplorer?.UpdateYnvTreeNode(CurrentYnvFile);
}
SetProjectHasChanged(true);
SetCurrentSaveItem();
@ -4402,6 +4409,7 @@ namespace CodeWalker.Project
{ //couldn't rename it in the project? happens when project not saved yet...
//MessageBox.Show("Couldn't rename train track in project! This shouldn't happen - check the project file XML.");
}
ProjectExplorer?.UpdateTrainTrackTreeNode(CurrentTrainTrack);
}
SetProjectHasChanged(true);
SetCurrentSaveItem();
@ -4685,6 +4693,7 @@ namespace CodeWalker.Project
{ //couldn't rename it in the project? happens when project not saved yet...
//MessageBox.Show("Couldn't rename scenario in project! This shouldn't happen - check the project file XML.");
}
ProjectExplorer?.UpdateScenarioTreeNode(CurrentScenario);
}
SetProjectHasChanged(true);
SetCurrentSaveItem();
@ -5827,6 +5836,7 @@ namespace CodeWalker.Project
{ //couldn't rename it in the project? happens when project not saved yet...
//MessageBox.Show("Couldn't rename audio rel in project! This shouldn't happen - check the project file XML.");
}
ProjectExplorer?.UpdateAudioRelTreeNode(CurrentAudioFile);
}
SetProjectHasChanged(true);
SetCurrentSaveItem();