mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-26 15:32:54 +08:00
Improved ymap rename/saveas experience
This commit is contained in:
parent
33072d44cb
commit
432b42504e
@ -1332,6 +1332,31 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void SetName(string newname)
|
||||||
|
{
|
||||||
|
var newnamel = newname.ToLowerInvariant();
|
||||||
|
var newnamex = newname + ".ymap";
|
||||||
|
var newnamexl = newname.ToLowerInvariant();
|
||||||
|
var newhash = JenkHash.GenHash(newnamel);
|
||||||
|
JenkIndex.Ensure(newnamel);
|
||||||
|
if (RpfFileEntry != null)
|
||||||
|
{
|
||||||
|
RpfFileEntry.Name = newnamex;
|
||||||
|
RpfFileEntry.NameLower = newnamexl;
|
||||||
|
RpfFileEntry.NameHash = JenkHash.GenHash(newnamexl);
|
||||||
|
RpfFileEntry.ShortNameHash = newhash;
|
||||||
|
}
|
||||||
|
Name = newnamex;
|
||||||
|
_CMapData.name = newhash;
|
||||||
|
}
|
||||||
|
public void SetFilePath(string filepath)
|
||||||
|
{
|
||||||
|
FilePath = filepath.ToLowerInvariant();
|
||||||
|
var newname = Path.GetFileNameWithoutExtension(filepath);
|
||||||
|
SetName(newname);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool CalcFlags()
|
public bool CalcFlags()
|
||||||
{
|
{
|
||||||
uint flags = 0;
|
uint flags = 0;
|
||||||
|
@ -362,14 +362,13 @@ namespace CodeWalker.Project.Panels
|
|||||||
{
|
{
|
||||||
lock (ProjectForm.ProjectSyncRoot)
|
lock (ProjectForm.ProjectSyncRoot)
|
||||||
{
|
{
|
||||||
string ymname = name + ".ymap";
|
Ymap.SetName(name);
|
||||||
if (Ymap.Name != ymname)
|
if (!File.Exists(Ymap.FilePath))
|
||||||
{
|
{
|
||||||
Ymap.Name = ymname;
|
Ymap.FilePath = name;
|
||||||
Ymap._CMapData.name = new MetaHash(hash);
|
|
||||||
SetYmapHasChanged(true);
|
|
||||||
UpdateFormTitle();
|
|
||||||
}
|
}
|
||||||
|
SetYmapHasChanged(true);
|
||||||
|
UpdateFormTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,10 +755,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetYmapHasChanged(YmapFile ymap, bool changed)
|
public void SetYmapHasChanged(YmapFile ymap, bool changed)
|
||||||
{
|
{
|
||||||
if (ymap != null)
|
|
||||||
{
|
|
||||||
ymap.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var pnode = ProjectTreeView.Nodes[0];
|
var pnode = ProjectTreeView.Nodes[0];
|
||||||
@ -783,10 +779,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetYtypHasChanged(YtypFile ytyp, bool changed)
|
public void SetYtypHasChanged(YtypFile ytyp, bool changed)
|
||||||
{
|
{
|
||||||
if (ytyp != null)
|
|
||||||
{
|
|
||||||
ytyp.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var pnode = ProjectTreeView.Nodes[0];
|
var pnode = ProjectTreeView.Nodes[0];
|
||||||
@ -811,10 +803,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetYbnHasChanged(YbnFile ybn, bool changed)
|
public void SetYbnHasChanged(YbnFile ybn, bool changed)
|
||||||
{
|
{
|
||||||
if (ybn != null)
|
|
||||||
{
|
|
||||||
ybn.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var pnode = ProjectTreeView.Nodes[0];
|
var pnode = ProjectTreeView.Nodes[0];
|
||||||
@ -839,10 +827,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetYndHasChanged(YndFile ynd, bool changed)
|
public void SetYndHasChanged(YndFile ynd, bool changed)
|
||||||
{
|
{
|
||||||
if (ynd != null)
|
|
||||||
{
|
|
||||||
ynd.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var pnode = ProjectTreeView.Nodes[0];
|
var pnode = ProjectTreeView.Nodes[0];
|
||||||
@ -867,10 +851,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetYnvHasChanged(YnvFile ynv, bool changed)
|
public void SetYnvHasChanged(YnvFile ynv, bool changed)
|
||||||
{
|
{
|
||||||
if (ynv != null)
|
|
||||||
{
|
|
||||||
ynv.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var pnode = ProjectTreeView.Nodes[0];
|
var pnode = ProjectTreeView.Nodes[0];
|
||||||
@ -895,10 +875,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetTrainTrackHasChanged(TrainTrack track, bool changed)
|
public void SetTrainTrackHasChanged(TrainTrack track, bool changed)
|
||||||
{
|
{
|
||||||
if (track != null)
|
|
||||||
{
|
|
||||||
track.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var pnode = ProjectTreeView.Nodes[0];
|
var pnode = ProjectTreeView.Nodes[0];
|
||||||
@ -923,10 +899,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetScenarioHasChanged(YmtFile scenario, bool changed)
|
public void SetScenarioHasChanged(YmtFile scenario, bool changed)
|
||||||
{
|
{
|
||||||
if (scenario != null)
|
|
||||||
{
|
|
||||||
scenario.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var pnode = ProjectTreeView.Nodes[0];
|
var pnode = ProjectTreeView.Nodes[0];
|
||||||
@ -951,10 +923,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetAudioRelHasChanged(RelFile rel, bool changed)
|
public void SetAudioRelHasChanged(RelFile rel, bool changed)
|
||||||
{
|
{
|
||||||
if (rel != null)
|
|
||||||
{
|
|
||||||
rel.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var pnode = ProjectTreeView.Nodes[0];
|
var pnode = ProjectTreeView.Nodes[0];
|
||||||
@ -979,10 +947,6 @@ namespace CodeWalker.Project.Panels
|
|||||||
}
|
}
|
||||||
public void SetGrassBatchHasChanged(YmapGrassInstanceBatch batch, bool changed)
|
public void SetGrassBatchHasChanged(YmapGrassInstanceBatch batch, bool changed)
|
||||||
{
|
{
|
||||||
if (batch?.Ymap != null)
|
|
||||||
{
|
|
||||||
batch.Ymap.HasChanged = true;
|
|
||||||
}
|
|
||||||
if (ProjectTreeView.Nodes.Count > 0)
|
if (ProjectTreeView.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var gbnode = FindGrassTreeNode(batch);
|
var gbnode = FindGrassTreeNode(batch);
|
||||||
|
@ -1781,13 +1781,7 @@ namespace CodeWalker.Project
|
|||||||
{ return; }
|
{ return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
filepath = filepath.ToLowerInvariant();
|
CurrentYmapFile.SetFilePath(filepath);
|
||||||
string newname = Path.GetFileNameWithoutExtension(filepath);
|
|
||||||
JenkIndex.Ensure(newname);
|
|
||||||
CurrentYmapFile.FilePath = filepath;
|
|
||||||
CurrentYmapFile.RpfFileEntry.Name = new FileInfo(filepath).Name;
|
|
||||||
CurrentYmapFile.Name = CurrentYmapFile.RpfFileEntry.Name;
|
|
||||||
CurrentYmapFile._CMapData.name = new MetaHash(JenkHash.GenHash(newname));
|
|
||||||
|
|
||||||
data = CurrentYmapFile.Save();
|
data = CurrentYmapFile.Save();
|
||||||
}
|
}
|
||||||
@ -8340,13 +8334,15 @@ namespace CodeWalker.Project
|
|||||||
{
|
{
|
||||||
if (CurrentYmapFile == null) return;
|
if (CurrentYmapFile == null) return;
|
||||||
|
|
||||||
bool changechange = changed != CurrentYmapFile.HasChanged;
|
|
||||||
if (!changechange) return;
|
|
||||||
|
|
||||||
CurrentYmapFile.HasChanged = changed;
|
CurrentYmapFile.HasChanged = changed;
|
||||||
|
|
||||||
ProjectExplorer?.SetYmapHasChanged(CurrentYmapFile, changed);
|
ProjectExplorer?.SetYmapHasChanged(CurrentYmapFile, changed);
|
||||||
|
|
||||||
|
RefreshUI();
|
||||||
|
|
||||||
|
bool changechange = changed != CurrentYmapFile.HasChanged;
|
||||||
|
if (!changechange) return;
|
||||||
|
|
||||||
PromoteIfPreviewPanelActive();
|
PromoteIfPreviewPanelActive();
|
||||||
}
|
}
|
||||||
public void SetYtypHasChanged(bool changed)
|
public void SetYtypHasChanged(bool changed)
|
||||||
|
Loading…
Reference in New Issue
Block a user