mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-14 15:46:17 +00:00
Rewrote SCAN asset handling + loading
This commit is contained in:
51
src/Core/Resource/Scan/CScan.cpp
Normal file
51
src/Core/Resource/Scan/CScan.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "CScan.h"
|
||||
|
||||
CScan::CScan(CResourceEntry* pEntry /*= 0*/)
|
||||
: CResource(pEntry)
|
||||
{
|
||||
CGameTemplate* pGameTemplate = NGameList::GetGameTemplate( Game() );
|
||||
mpTemplate = pGameTemplate->FindMiscTemplate("ScannableObjectInfo");
|
||||
ASSERT( mpTemplate != nullptr );
|
||||
|
||||
CStructProperty* pProperties = mpTemplate->Properties();
|
||||
mPropertyData.resize( pProperties->DataSize() );
|
||||
pProperties->Construct( mPropertyData.data() );
|
||||
}
|
||||
|
||||
CStructRef CScan::ScanData() const
|
||||
{
|
||||
return CStructRef((void*) mPropertyData.data(), mpTemplate->Properties());
|
||||
}
|
||||
|
||||
/** Convenience property accessors */
|
||||
CAssetRef CScan::ScanStringPropertyRef() const
|
||||
{
|
||||
const uint kStringIdMP1 = 0x1;
|
||||
const uint kStringIdMP2 = 0x2F5B6423;
|
||||
|
||||
IProperty* pProperty = mpTemplate->Properties()->ChildByID(
|
||||
Game() <= EGame::Prime ? kStringIdMP1 : kStringIdMP2
|
||||
);
|
||||
|
||||
return CAssetRef( (void*) mPropertyData.data(), pProperty );
|
||||
}
|
||||
|
||||
CBoolRef CScan::IsCriticalPropertyRef() const
|
||||
{
|
||||
const uint kIsCriticalIdMP1 = 0x4;
|
||||
const uint kIsCriticalIdMP2 = 0x7B714814;
|
||||
|
||||
IProperty* pProperty = mpTemplate->Properties()->ChildByID(
|
||||
Game() <= EGame::Prime ? kIsCriticalIdMP1 : kIsCriticalIdMP2
|
||||
);
|
||||
|
||||
return CBoolRef( (void*) mPropertyData.data(), pProperty );
|
||||
}
|
||||
|
||||
/** CResource interface */
|
||||
CDependencyTree* CScan::BuildDependencyTree() const
|
||||
{
|
||||
CDependencyTree* pTree = new CDependencyTree();
|
||||
pTree->ParseProperties(Entry(), ScanData().Property(), ScanData().DataPointer());
|
||||
return pTree;
|
||||
}
|
||||
34
src/Core/Resource/Scan/CScan.h
Normal file
34
src/Core/Resource/Scan/CScan.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef CSCAN_H
|
||||
#define CSCAN_H
|
||||
|
||||
#include <Common/Common.h>
|
||||
#include "Core/Resource/Animation/CAnimationParameters.h"
|
||||
#include "Core/Resource/Script/CGameTemplate.h"
|
||||
#include "Core/Resource/Script/NGameList.h"
|
||||
|
||||
/** Scannable object parameters from SCAN assets */
|
||||
class CScan : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(Scan)
|
||||
friend class CScanLoader;
|
||||
friend class CScanCooker;
|
||||
|
||||
/** Script template specifying scan data layout */
|
||||
CScriptTemplate* mpTemplate;
|
||||
|
||||
/** Scan property data */
|
||||
std::vector<uint8> mPropertyData;
|
||||
|
||||
public:
|
||||
CScan(CResourceEntry* pEntry = 0);
|
||||
CStructRef ScanData() const;
|
||||
|
||||
/** Convenience property accessors */
|
||||
CAssetRef ScanStringPropertyRef() const;
|
||||
CBoolRef IsCriticalPropertyRef() const;
|
||||
|
||||
/** CResource interface */
|
||||
virtual CDependencyTree* BuildDependencyTree() const override;
|
||||
};
|
||||
|
||||
#endif // CSCAN_H
|
||||
14
src/Core/Resource/Scan/ELogbookCategory.h
Normal file
14
src/Core/Resource/Scan/ELogbookCategory.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ELOGBOOKCATEGORY_H
|
||||
#define ELOGBOOKCATEGORY_H
|
||||
|
||||
/** Logbook category for scannable objects in MP1, used in SCAN and SAVW */
|
||||
enum class ELogbookCategory
|
||||
{
|
||||
None = 0,
|
||||
SpacePirateData = 1,
|
||||
ChozoLore = 2,
|
||||
Creatures = 3,
|
||||
Research = 4
|
||||
};
|
||||
|
||||
#endif // ELOGBOOKCATEGORY_H
|
||||
60
src/Core/Resource/Scan/SScanParametersMP1.h
Normal file
60
src/Core/Resource/Scan/SScanParametersMP1.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef SSCANPARAMETERSMP1_H
|
||||
#define SSCANPARAMETERSMP1_H
|
||||
|
||||
#include "ELogbookCategory.h"
|
||||
#include <Common/Common.h>
|
||||
|
||||
/** Struct mapping to SCAN property layout in MP1 */
|
||||
enum class EScanSpeed
|
||||
{
|
||||
Normal = 0,
|
||||
Slow = 1,
|
||||
};
|
||||
|
||||
enum class EScanImagePane
|
||||
{
|
||||
Pane0 = 0,
|
||||
Pane1 = 1,
|
||||
Pane2 = 2,
|
||||
Pane3 = 3,
|
||||
Pane01 = 4,
|
||||
Pane12 = 5,
|
||||
Pane23 = 6,
|
||||
Pane012 = 7,
|
||||
Pane123 = 8,
|
||||
Pane0123 = 9,
|
||||
Pane4 = 10,
|
||||
Pane5 = 11,
|
||||
Pane6 = 12,
|
||||
Pane7 = 13,
|
||||
Pane45 = 14,
|
||||
Pane56 = 15,
|
||||
Pane67 = 16,
|
||||
Pane456 = 17,
|
||||
Pane567 = 18,
|
||||
Pane4567 = 19,
|
||||
None = -1
|
||||
};
|
||||
|
||||
struct SScanImage
|
||||
{
|
||||
CAssetID Texture;
|
||||
float AppearPercentage;
|
||||
EScanImagePane Pane;
|
||||
int32 AnimationCellWidth;
|
||||
int32 AnimationCellHeight;
|
||||
float AnimationSwapInterval;
|
||||
float FadeDuration;
|
||||
};
|
||||
|
||||
struct SScanParametersMP1
|
||||
{
|
||||
CAssetID GuiFrame;
|
||||
CAssetID String;
|
||||
EScanSpeed Speed;
|
||||
ELogbookCategory LogbookCategory;
|
||||
bool IsCritical;
|
||||
SScanImage ScanImages[4];
|
||||
};
|
||||
|
||||
#endif // SSCANPARAMETERSMP1_H
|
||||
Reference in New Issue
Block a user