mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-25 15:02:56 +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()
|
||||
{
|
||||
uint flags = 0;
|
||||
|
@ -362,14 +362,13 @@ namespace CodeWalker.Project.Panels
|
||||
{
|
||||
lock (ProjectForm.ProjectSyncRoot)
|
||||
{
|
||||
string ymname = name + ".ymap";
|
||||
if (Ymap.Name != ymname)
|
||||
Ymap.SetName(name);
|
||||
if (!File.Exists(Ymap.FilePath))
|
||||
{
|
||||
Ymap.Name = ymname;
|
||||
Ymap._CMapData.name = new MetaHash(hash);
|
||||
SetYmapHasChanged(true);
|
||||
UpdateFormTitle();
|
||||
Ymap.FilePath = name;
|
||||
}
|
||||
SetYmapHasChanged(true);
|
||||
UpdateFormTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -755,10 +755,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetYmapHasChanged(YmapFile ymap, bool changed)
|
||||
{
|
||||
if (ymap != null)
|
||||
{
|
||||
ymap.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var pnode = ProjectTreeView.Nodes[0];
|
||||
@ -783,10 +779,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetYtypHasChanged(YtypFile ytyp, bool changed)
|
||||
{
|
||||
if (ytyp != null)
|
||||
{
|
||||
ytyp.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var pnode = ProjectTreeView.Nodes[0];
|
||||
@ -811,10 +803,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetYbnHasChanged(YbnFile ybn, bool changed)
|
||||
{
|
||||
if (ybn != null)
|
||||
{
|
||||
ybn.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var pnode = ProjectTreeView.Nodes[0];
|
||||
@ -839,10 +827,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetYndHasChanged(YndFile ynd, bool changed)
|
||||
{
|
||||
if (ynd != null)
|
||||
{
|
||||
ynd.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var pnode = ProjectTreeView.Nodes[0];
|
||||
@ -867,10 +851,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetYnvHasChanged(YnvFile ynv, bool changed)
|
||||
{
|
||||
if (ynv != null)
|
||||
{
|
||||
ynv.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var pnode = ProjectTreeView.Nodes[0];
|
||||
@ -895,10 +875,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetTrainTrackHasChanged(TrainTrack track, bool changed)
|
||||
{
|
||||
if (track != null)
|
||||
{
|
||||
track.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var pnode = ProjectTreeView.Nodes[0];
|
||||
@ -923,10 +899,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetScenarioHasChanged(YmtFile scenario, bool changed)
|
||||
{
|
||||
if (scenario != null)
|
||||
{
|
||||
scenario.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var pnode = ProjectTreeView.Nodes[0];
|
||||
@ -951,10 +923,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetAudioRelHasChanged(RelFile rel, bool changed)
|
||||
{
|
||||
if (rel != null)
|
||||
{
|
||||
rel.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var pnode = ProjectTreeView.Nodes[0];
|
||||
@ -979,10 +947,6 @@ namespace CodeWalker.Project.Panels
|
||||
}
|
||||
public void SetGrassBatchHasChanged(YmapGrassInstanceBatch batch, bool changed)
|
||||
{
|
||||
if (batch?.Ymap != null)
|
||||
{
|
||||
batch.Ymap.HasChanged = true;
|
||||
}
|
||||
if (ProjectTreeView.Nodes.Count > 0)
|
||||
{
|
||||
var gbnode = FindGrassTreeNode(batch);
|
||||
|
@ -1781,13 +1781,7 @@ namespace CodeWalker.Project
|
||||
{ return; }
|
||||
}
|
||||
|
||||
filepath = filepath.ToLowerInvariant();
|
||||
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));
|
||||
CurrentYmapFile.SetFilePath(filepath);
|
||||
|
||||
data = CurrentYmapFile.Save();
|
||||
}
|
||||
@ -8340,13 +8334,15 @@ namespace CodeWalker.Project
|
||||
{
|
||||
if (CurrentYmapFile == null) return;
|
||||
|
||||
bool changechange = changed != CurrentYmapFile.HasChanged;
|
||||
if (!changechange) return;
|
||||
|
||||
CurrentYmapFile.HasChanged = changed;
|
||||
|
||||
ProjectExplorer?.SetYmapHasChanged(CurrentYmapFile, changed);
|
||||
|
||||
RefreshUI();
|
||||
|
||||
bool changechange = changed != CurrentYmapFile.HasChanged;
|
||||
if (!changechange) return;
|
||||
|
||||
PromoteIfPreviewPanelActive();
|
||||
}
|
||||
public void SetYtypHasChanged(bool changed)
|
||||
|
Loading…
Reference in New Issue
Block a user