mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-05-25 00:31:24 +00:00
Fixed crash after generating asset names, added MP2 auto-generated names to the map
This commit is contained in:
parent
eca833cf89
commit
b3a0e52b6f
File diff suppressed because it is too large
Load Diff
@ -252,6 +252,10 @@ TWideString MakeRelative(const TWideString& rkPath, const TWideString& rkRelativ
|
|||||||
for (; PathIter != PathComponents.end(); PathIter++)
|
for (; PathIter != PathComponents.end(); PathIter++)
|
||||||
Out += *PathIter + L"\\";
|
Out += *PathIter + L"\\";
|
||||||
|
|
||||||
|
// Attempt to detect if this path is a file as opposed to a directory; if so, remove trailing backslash
|
||||||
|
if (PathComponents.back().Contains(L'.') && !rkPath.EndsWith(L'/') && !rkPath.EndsWith(L'\\'))
|
||||||
|
Out = Out.ChopBack(1);
|
||||||
|
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "Core/Resource/Script/CScriptLayer.h"
|
#include "Core/Resource/Script/CScriptLayer.h"
|
||||||
#include <Math/MathUtil.h>
|
#include <Math/MathUtil.h>
|
||||||
|
|
||||||
|
#define PROCESS_PACKAGES 1
|
||||||
#define PROCESS_WORLDS 1
|
#define PROCESS_WORLDS 1
|
||||||
#define PROCESS_AREAS 1
|
#define PROCESS_AREAS 1
|
||||||
#define PROCESS_MODELS 1
|
#define PROCESS_MODELS 1
|
||||||
@ -94,10 +95,9 @@ TWideString MakeWorldName(EGame Game, TWideString RawName)
|
|||||||
{
|
{
|
||||||
RawName = RawName.ChopBack(RawName.Size() - LastUnderscore);
|
RawName = RawName.ChopBack(RawName.Size() - LastUnderscore);
|
||||||
RawName = RawName.ChopFront(FirstUnderscore + 1);
|
RawName = RawName.ChopFront(FirstUnderscore + 1);
|
||||||
}
|
|
||||||
|
|
||||||
RawName.Remove(L'_');
|
RawName.Remove(L'_');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DKCR - Remove text after second-to-last underscore
|
// DKCR - Remove text after second-to-last underscore
|
||||||
else if (Game == eReturns)
|
else if (Game == eReturns)
|
||||||
@ -116,7 +116,8 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||||||
// todo: CAUD/CSMP
|
// todo: CAUD/CSMP
|
||||||
CResourceStore *pStore = pProj->ResourceStore();
|
CResourceStore *pStore = pProj->ResourceStore();
|
||||||
|
|
||||||
// Generate names for package named resources first
|
#if PROCESS_PACKAGES
|
||||||
|
// Generate names for package named resources
|
||||||
for (u32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++)
|
for (u32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++)
|
||||||
{
|
{
|
||||||
CPackage *pPkg = pProj->PackageByIndex(iPkg);
|
CPackage *pPkg = pProj->PackageByIndex(iPkg);
|
||||||
@ -135,6 +136,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if PROCESS_WORLDS
|
#if PROCESS_WORLDS
|
||||||
// Generate world/area names
|
// Generate world/area names
|
||||||
@ -171,7 +173,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||||||
{
|
{
|
||||||
// Move sky model
|
// Move sky model
|
||||||
CResourceEntry *pSkyEntry = pSkyModel->Entry();
|
CResourceEntry *pSkyEntry = pSkyModel->Entry();
|
||||||
ApplyGeneratedName(pSkyEntry, WorldDir + L"sky\\cooked\\", L"sky");
|
ApplyGeneratedName(pSkyEntry, WorldDir + L"sky\\cooked\\", WorldName + L"_" + L"sky");
|
||||||
|
|
||||||
// Move sky textures
|
// Move sky textures
|
||||||
for (u32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++)
|
for (u32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++)
|
||||||
@ -484,8 +486,8 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||||||
// Generate string names
|
// Generate string names
|
||||||
for (TResourceIterator<eStringTable> It(pStore); It; ++It)
|
for (TResourceIterator<eStringTable> It(pStore); It; ++It)
|
||||||
{
|
{
|
||||||
|
if (It->IsNamed()) continue;
|
||||||
CStringTable *pString = (CStringTable*) It->Load();
|
CStringTable *pString = (CStringTable*) It->Load();
|
||||||
if (pString->Entry()->IsNamed()) continue;
|
|
||||||
TWideString String;
|
TWideString String;
|
||||||
|
|
||||||
for (u32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++)
|
for (u32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++)
|
||||||
@ -556,7 +558,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||||||
CTexture *pFontTex = pFont->Texture();
|
CTexture *pFontTex = pFont->Texture();
|
||||||
|
|
||||||
if (pFontTex)
|
if (pFontTex)
|
||||||
ApplyGeneratedName(pFontTex->Entry(), pFont->Entry()->DirectoryPath(), pFont->Entry()->Name());
|
ApplyGeneratedName(pFontTex->Entry(), pFont->Entry()->DirectoryPath(), pFont->Entry()->Name() + L"_tex");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -321,7 +321,7 @@ bool CResourceEntry::Move(const TWideString& rkDir, const TWideString& rkName)
|
|||||||
TString NewCookedPath = CookedAssetPath();
|
TString NewCookedPath = CookedAssetPath();
|
||||||
TString NewRawPath = RawAssetPath();
|
TString NewRawPath = RawAssetPath();
|
||||||
|
|
||||||
Log::Write("MOVING RESOURCE: " + OldCookedPath + " --> " + NewCookedPath);
|
Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->CookedDir(false)).ToUTF8() + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->CookedDir(false)).ToUTF8());
|
||||||
|
|
||||||
// If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false
|
// If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false
|
||||||
ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath);
|
ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath);
|
||||||
|
@ -582,6 +582,9 @@ bool CResourceStore::DeleteResourceEntry(CResourceEntry *pEntry)
|
|||||||
mLoadedResources.erase(It);
|
mLoadedResources.erase(It);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pEntry->Directory())
|
||||||
|
pEntry->Directory()->RemoveChildResource(pEntry);
|
||||||
|
|
||||||
auto It = mResourceEntries.find(ID);
|
auto It = mResourceEntries.find(ID);
|
||||||
ASSERT(It != mResourceEntries.end());
|
ASSERT(It != mResourceEntries.end());
|
||||||
mResourceEntries.erase(It);
|
mResourceEntries.erase(It);
|
||||||
|
@ -183,6 +183,16 @@ void CResourceBrowser::RefreshResources()
|
|||||||
mpUI->ResourceTableView->setSpan(iDir, 0, 1, 3);
|
mpUI->ResourceTableView->setSpan(iDir, 0, 1, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CResourceBrowser::RefreshDirectories()
|
||||||
|
{
|
||||||
|
mpDirectoryModel->SetRoot(mpStore->RootDirectory());
|
||||||
|
|
||||||
|
// Clear selection. This function is called when directories are created/deleted and our current selection might not be valid anymore
|
||||||
|
QModelIndex RootIndex = mpDirectoryModel->index(0, 0, QModelIndex());
|
||||||
|
mpUI->DirectoryTreeView->selectionModel()->setCurrentIndex(RootIndex, QItemSelectionModel::ClearAndSelect);
|
||||||
|
mpUI->DirectoryTreeView->setExpanded(RootIndex, true);
|
||||||
|
}
|
||||||
|
|
||||||
void CResourceBrowser::UpdateDescriptionLabel()
|
void CResourceBrowser::UpdateDescriptionLabel()
|
||||||
{
|
{
|
||||||
QString Desc;
|
QString Desc;
|
||||||
@ -299,12 +309,14 @@ void CResourceBrowser::OnImportPakContentsTxt()
|
|||||||
mpStore->ImportNamesFromPakContentsTxt(TO_TSTRING(rkPath), false);
|
mpStore->ImportNamesFromPakContentsTxt(TO_TSTRING(rkPath), false);
|
||||||
|
|
||||||
RefreshResources();
|
RefreshResources();
|
||||||
|
RefreshDirectories();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::OnGenerateAssetNames()
|
void CResourceBrowser::OnGenerateAssetNames()
|
||||||
{
|
{
|
||||||
GenerateAssetNames(mpStore->Project());
|
GenerateAssetNames(mpStore->Project());
|
||||||
RefreshResources();
|
RefreshResources();
|
||||||
|
RefreshDirectories();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::OnImportNamesFromAssetNameMap()
|
void CResourceBrowser::OnImportNamesFromAssetNameMap()
|
||||||
@ -322,6 +334,7 @@ void CResourceBrowser::OnImportNamesFromAssetNameMap()
|
|||||||
|
|
||||||
mpStore->ConditionalSaveStore();
|
mpStore->ConditionalSaveStore();
|
||||||
RefreshResources();
|
RefreshResources();
|
||||||
|
RefreshDirectories();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::ExportAssetNames()
|
void CResourceBrowser::ExportAssetNames()
|
||||||
@ -358,6 +371,7 @@ void CResourceBrowser::ResetTypeFilter()
|
|||||||
|
|
||||||
void CResourceBrowser::OnFilterTypeBoxTicked(bool Checked)
|
void CResourceBrowser::OnFilterTypeBoxTicked(bool Checked)
|
||||||
{
|
{
|
||||||
|
// NOTE: there should only be one CResourceBrowser; if that ever changes for some reason change this to a member
|
||||||
static bool ReentrantGuard = false;
|
static bool ReentrantGuard = false;
|
||||||
if (ReentrantGuard) return;
|
if (ReentrantGuard) return;
|
||||||
ReentrantGuard = true;
|
ReentrantGuard = true;
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void RefreshResources();
|
void RefreshResources();
|
||||||
|
void RefreshDirectories();
|
||||||
void UpdateDescriptionLabel();
|
void UpdateDescriptionLabel();
|
||||||
void UpdateStore();
|
void UpdateStore();
|
||||||
void OnDisplayModeChanged(int Index);
|
void OnDisplayModeChanged(int Index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user