rename interfaces to packs

This commit is contained in:
Beu
2024-12-19 16:09:13 +01:00
parent 2d847fa666
commit d6f4413ea9
5 changed files with 22 additions and 23 deletions

View File

@@ -11,7 +11,7 @@ class LayerConfig {
Path = Path::Join(_ParentPath, _Data['Path']); Path = Path::Join(_ParentPath, _Data['Path']);
const string Manialink = GetManialink(); const string Manialink = GetManialink();
Name = InterfacesManager::GetLayerName(Manialink); Name = PacksManager::GetLayerName(Manialink);
if (Name.Length == 0) { if (Name.Length == 0) {
throw('Can\'t find Manialink name'); throw('Can\'t find Manialink name');

View File

@@ -1,4 +1,4 @@
class InterfacesConfig { class PackConfig {
string Name; string Name;
string Author; string Author;
string Version; string Version;
@@ -6,9 +6,9 @@ class InterfacesConfig {
array<LayerConfig> Layers; array<LayerConfig> Layers;
array<string> UnloadModules; array<string> UnloadModules;
InterfacesConfig() {} PackConfig() {}
InterfacesConfig(const string &in _ParentPath, const string &in _Json) { PackConfig(const string &in _ParentPath, const string &in _Json) {
const Json::Value@ Data = Json::Parse(_Json); const Json::Value@ Data = Json::Parse(_Json);
Name = Data['Name']; Name = Data['Name'];

View File

@@ -1,4 +1,4 @@
namespace InterfacesManager { namespace PacksManager {
uint G_UILayersCount; uint G_UILayersCount;
dictionary G_Configs; dictionary G_Configs;
array<string> G_EnabledConfigs; array<string> G_EnabledConfigs;
@@ -23,30 +23,29 @@ namespace InterfacesManager {
} }
if (IO::FileExists(Path)) { if (IO::FileExists(Path)) {
trace('Invalid Interface Config: "' + Path + '" is a file'); trace('Invalid Pack Config: "' + Path + '" is a file');
continue; continue;
} }
const string InfoFile = Path::Join(Path, 'info.json'); const string InfoFile = Path::Join(Path, 'info.json');
if (!IO::FileExists(InfoFile)) { if (!IO::FileExists(InfoFile)) {
trace('Invalid Interface Config: "' + Path + '" has no info.json file'); trace('Invalid Pack Config: "' + Path + '" has no info.json file');
continue; continue;
} }
IO::File File(InfoFile, IO::FileMode::Read); IO::File File(InfoFile, IO::FileMode::Read);
if (File.Size() <= 0) { if (File.Size() <= 0) {
trace('Invalid Interface Config: "' + Path + '" is not readable'); trace('Invalid Pack Config: "' + InfoFile + '" is not readable');
continue; continue;
} }
const string FileContent = File.ReadToEnd(); const string FileContent = File.ReadToEnd();
try { try {
const InterfacesConfig Config(Path, FileContent); const PackConfig Config(Path, FileContent);
G_Configs[Id] = Config; G_Configs[Id] = Config;
} catch { } catch {
warn('Invalid Interface Config: "'+ Path +'" is an invalid\nException Message: '+ getExceptionInfo()); warn('Invalid Pack Config: "'+ Path +'" is an invalid\nException Message: '+ getExceptionInfo());
} }
} }
@@ -78,7 +77,7 @@ namespace InterfacesManager {
for (uint i = 0; i < G_EnabledConfigs.Length; i++) { for (uint i = 0; i < G_EnabledConfigs.Length; i++) {
const string Id = G_EnabledConfigs[i]; const string Id = G_EnabledConfigs[i];
const InterfacesConfig@ Config = InterfacesManager::GetConfig(Id); const PackConfig@ Config = PacksManager::GetConfig(Id);
// TODO Check ModePattern // TODO Check ModePattern
if (Regex::IsMatch(ServerInfo.CurScriptRelName, Config.ModePattern)) { if (Regex::IsMatch(ServerInfo.CurScriptRelName, Config.ModePattern)) {
@@ -150,9 +149,9 @@ namespace InterfacesManager {
S_EnabledConfigs = string::Join(G_EnabledConfigs, ','); S_EnabledConfigs = string::Join(G_EnabledConfigs, ',');
} }
InterfacesConfig@ GetConfig(const string &in _Id) { PackConfig@ GetConfig(const string &in _Id) {
if (InterfacesManager::G_Configs.Exists(_Id)) { if (PacksManager::G_Configs.Exists(_Id)) {
return cast<InterfacesConfig>(InterfacesManager::G_Configs[_Id]); return cast<PackConfig>(PacksManager::G_Configs[_Id]);
} }
return null; return null;
} }

View File

@@ -12,7 +12,7 @@ namespace RenderManager {
UI::SameLine(); UI::SameLine();
if (UI::Button('Reload')) { if (UI::Button('Reload')) {
InterfacesManager::LoadConfigs(); PacksManager::LoadConfigs();
} }
if (UI::BeginTable('configs', 5, UI::TableFlags(UI::TableFlags::Resizable | UI::TableFlags::Sortable | UI::TableFlags::NoSavedSettings | UI::TableFlags::BordersInnerV | UI::TableFlags::SizingStretchProp | UI::TableFlags::ScrollY))) { if (UI::BeginTable('configs', 5, UI::TableFlags(UI::TableFlags::Resizable | UI::TableFlags::Sortable | UI::TableFlags::NoSavedSettings | UI::TableFlags::BordersInnerV | UI::TableFlags::SizingStretchProp | UI::TableFlags::ScrollY))) {
@@ -23,11 +23,11 @@ namespace RenderManager {
UI::TableSetupColumn("Enable", UI::TableFlags(UI::TableColumnFlags::NoResize | UI::TableColumnFlags::WidthFixed), 60.); UI::TableSetupColumn("Enable", UI::TableFlags(UI::TableColumnFlags::NoResize | UI::TableColumnFlags::WidthFixed), 60.);
UI::TableHeadersRow(); UI::TableHeadersRow();
const array<string> ConfigIds = InterfacesManager::G_Configs.GetKeys(); const array<string> ConfigIds = PacksManager::G_Configs.GetKeys();
for (uint i = 0; i < ConfigIds.Length; i++) { for (uint i = 0; i < ConfigIds.Length; i++) {
const string Id = ConfigIds[i]; const string Id = ConfigIds[i];
const InterfacesConfig@ Config = InterfacesManager::GetConfig(Id); const PackConfig@ Config = PacksManager::GetConfig(Id);
UI::TableNextRow(); UI::TableNextRow();
UI::TableNextColumn(); UI::TableNextColumn();
@@ -40,14 +40,14 @@ namespace RenderManager {
UI::Text(Config.ModePattern); UI::Text(Config.ModePattern);
UI::TableNextColumn(); UI::TableNextColumn();
const int index = InterfacesManager::G_EnabledConfigs.Find(Id); const int index = PacksManager::G_EnabledConfigs.Find(Id);
const bool enabled = (index >= 0); const bool enabled = (index >= 0);
const bool newValue = UI::Checkbox('###'+ Id, enabled); const bool newValue = UI::Checkbox('###'+ Id, enabled);
if (newValue != enabled) { if (newValue != enabled) {
if (enabled) { if (enabled) {
InterfacesManager::DisableInterface(Id); PacksManager::DisableInterface(Id);
} else { } else {
InterfacesManager::EnableInterface(Id); PacksManager::EnableInterface(Id);
} }
} }
} }

View File

@@ -1,9 +1,9 @@
void Main() { void Main() {
InterfacesManager::LoadConfigs(); PacksManager::LoadConfigs();
while (true) { while (true) {
yield(); yield();
InterfacesManager::Yield(); PacksManager::Yield();
} }
} }