add main logic
This commit is contained in:
51
Classes/LayerConfig.as
Normal file
51
Classes/LayerConfig.as
Normal file
@@ -0,0 +1,51 @@
|
||||
class LayerConfig {
|
||||
string Name;
|
||||
string Path;
|
||||
|
||||
CGameUILayer::EUILayerType LayerType = CGameUILayer::EUILayerType::Normal;
|
||||
string AttachId = '';
|
||||
|
||||
LayerConfig() {}
|
||||
|
||||
LayerConfig(const string &in _ParentPath, const Json::Value &in _Data) {
|
||||
Path = Path::Join(_ParentPath, _Data['Path']);
|
||||
|
||||
const string Manialink = GetManialink();
|
||||
Name = InterfacesManager::GetLayerName(Manialink);
|
||||
|
||||
if (_Data.HasKey('LayerType') && _Data['LayerType'].GetType() == Json::Type::String) {
|
||||
LayerType = CastEUILayerType(_Data['LayerType']);
|
||||
}
|
||||
|
||||
if (_Data.HasKey('AttachId') && _Data['AttachId'].GetType() == Json::Type::String) {
|
||||
AttachId = _Data['AttachId'];
|
||||
}
|
||||
}
|
||||
|
||||
string GetManialink() const {
|
||||
if (!IO::FileExists(Path)) {
|
||||
throw('Invalid Layer: Can\'t find "' + Path + '"');
|
||||
}
|
||||
|
||||
IO::File File(Path, IO::FileMode::Read);
|
||||
const string Manialink = File.ReadToEnd();
|
||||
return Manialink;
|
||||
}
|
||||
|
||||
CGameUILayer::EUILayerType CastEUILayerType(const string &in _LayerType) {
|
||||
if (_LayerType == 'Normal') return CGameUILayer::EUILayerType::Normal;
|
||||
if (_LayerType == 'ScoresTable') return CGameUILayer::EUILayerType::ScoresTable;
|
||||
if (_LayerType == 'ScreenIn3d') return CGameUILayer::EUILayerType::ScreenIn3d;
|
||||
if (_LayerType == 'AltMenu') return CGameUILayer::EUILayerType::AltMenu;
|
||||
if (_LayerType == 'Markers') return CGameUILayer::EUILayerType::Markers;
|
||||
if (_LayerType == 'CutScene') return CGameUILayer::EUILayerType::CutScene;
|
||||
if (_LayerType == 'InGameMenu') return CGameUILayer::EUILayerType::InGameMenu;
|
||||
if (_LayerType == 'EditorPlugin') return CGameUILayer::EUILayerType::EditorPlugin;
|
||||
if (_LayerType == 'ManiaplanetPlugin') return CGameUILayer::EUILayerType::ManiaplanetPlugin;
|
||||
if (_LayerType == 'ManiaplanetMenu') return CGameUILayer::EUILayerType::ManiaplanetMenu;
|
||||
if (_LayerType == 'LoadingScreen') return CGameUILayer::EUILayerType::LoadingScreen;
|
||||
|
||||
throw('Invalid EUILayerType: '+ _LayerType);
|
||||
return CGameUILayer::EUILayerType::Normal;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user