Build and run ok
Some checks failed
Build-StoryEditor / build_linux (push) Has been cancelled
Build-StoryEditor / build_win32 (push) Has been cancelled
Deploy-Documentation / deploy (push) Has been cancelled

This commit is contained in:
Anthony Rabine 2025-08-24 15:39:20 +02:00
parent 143bbfa8bc
commit 6ec0740345
10 changed files with 241 additions and 253 deletions

View file

@ -43,7 +43,7 @@ public:
virtual std::shared_ptr<IStoryProject> GetCurrentProject() = 0; virtual std::shared_ptr<IStoryProject> GetCurrentProject() = 0;
// Modules // Modules
virtual void OpenModule(const std::string &uuid) = 0; virtual std::shared_ptr<IStoryProject> OpenModule(const std::string &uuid) = 0;
// Node interaction // Node interaction
virtual void BuildNodes(bool compileonly) = 0; virtual void BuildNodes(bool compileonly) = 0;

View file

@ -122,6 +122,8 @@ set(SRCS
src/app/app_controller.cpp src/app/app_controller.cpp
src/events/event_bus.cpp
src/windows/window_base.cpp src/windows/window_base.cpp
src/windows/console_window.cpp src/windows/console_window.cpp
src/windows/library_window.cpp src/windows/library_window.cpp

View file

@ -1,6 +1,6 @@
[Window][WindowOverViewport_11111111] [Window][WindowOverViewport_11111111]
Pos=60,26 Pos=60,26
Size=1220,962 Size=1220,694
Collapsed=0 Collapsed=0
[Window][Debug##Default] [Window][Debug##Default]
@ -10,7 +10,7 @@ Collapsed=0
[Window][Library Manager] [Window][Library Manager]
Pos=878,26 Pos=878,26
Size=402,403 Size=402,694
Collapsed=0 Collapsed=0
DockId=0x00000003,0 DockId=0x00000003,0
@ -79,7 +79,7 @@ Size=60,962
Collapsed=0 Collapsed=0
[Window][QuitConfirm] [Window][QuitConfirm]
Pos=508,446 Pos=508,312
Size=264,96 Size=264,96
Collapsed=0 Collapsed=0
@ -133,11 +133,11 @@ Column 1 Width=104
Column 2 Width=120 Column 2 Width=120
[Docking][Data] [Docking][Data]
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=60,26 Size=1220,962 Split=Y DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=60,26 Size=1220,694 Split=Y
DockNode ID=0x00000007 Parent=0x08BD597D SizeRef=1220,439 Split=X DockNode ID=0x00000007 Parent=0x08BD597D SizeRef=1220,439 Split=X
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=816,694 CentralNode=1 Selected=0x93ADCAAB DockNode ID=0x00000001 Parent=0x00000007 SizeRef=816,694 CentralNode=1 Selected=0x93ADCAAB
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=402,694 Split=Y Selected=0x52EB28B5 DockNode ID=0x00000002 Parent=0x00000007 SizeRef=402,694 Split=Y Selected=0x52EB28B5
DockNode ID=0x00000003 Parent=0x00000002 SizeRef=718,250 Selected=0x4B07C626 DockNode ID=0x00000003 Parent=0x00000002 SizeRef=718,250 Selected=0x63869CAF
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=718,187 Selected=0x8C72BEA8 DockNode ID=0x00000006 Parent=0x00000002 SizeRef=718,187 Selected=0x8C72BEA8
DockNode ID=0x00000008 Parent=0x08BD597D SizeRef=1220,253 Split=X Selected=0xEA83D666 DockNode ID=0x00000008 Parent=0x08BD597D SizeRef=1220,253 Split=X Selected=0xEA83D666
DockNode ID=0x00000004 Parent=0x00000008 SizeRef=610,192 Selected=0xEA83D666 DockNode ID=0x00000004 Parent=0x00000008 SizeRef=610,192 Selected=0xEA83D666

View file

@ -279,7 +279,7 @@ void AppController::Build(bool compileonly)
} }
Chip32::Assembler::Error err; Chip32::Assembler::Error err;
// La GUI (DebuggerWindow) doit être notifiée pour effacer les erreurs. // La GUI (DebuggerWindow) doit être notifiée pour effacer les erreurs. FIXME
// m_debuggerWindow.ClearErrors(); // m_debuggerWindow.ClearErrors();
if (m_story->GenerateBinary(m_currentCode, err)) if (m_story->GenerateBinary(m_currentCode, err))
@ -302,7 +302,7 @@ void AppController::Build(bool compileonly)
else else
{ {
m_logger.Log(err.ToString(), true); m_logger.Log(err.ToString(), true);
// La GUI (DebuggerWindow) doit être notifiée pour ajouter l'erreur. // La GUI (DebuggerWindow) doit être notifiée pour ajouter l'erreur. FIXME
// m_debuggerWindow.AddError(err.line, err.message); // m_debuggerWindow.AddError(err.line, err.message);
} }
} }
@ -813,6 +813,8 @@ uint8_t AppController::Syscall(chip32_ctx_t *ctx, uint8_t code)
void AppController::UpdateVmView() void AppController::UpdateVmView()
{ {
// FIXME !!
// C'est une fonction de notification pour la GUI. // C'est une fonction de notification pour la GUI.
// AppController ne devrait pas directement manipuler les vues GUI. // AppController ne devrait pas directement manipuler les vues GUI.
// Au lieu de cela, il émettrait un signal ou appellerait un observer. // Au lieu de cela, il émettrait un signal ou appellerait un observer.
@ -884,14 +886,10 @@ void AppController::SaveProject()
} }
} }
void AppController::NewModule() std::shared_ptr<StoryProject> AppController::NewModule()
{ {
m_module = m_nodesFactory.NewModule(); m_module = m_nodesFactory.NewModule();
if (m_module) { return m_module;
// Notify GUI (e.g., m_moduleEditorWindow.Load(m_module);)
// m_moduleEditorWindow.Enable();
m_logger.Log("New module created.");
}
} }
void AppController::SaveModule() void AppController::SaveModule()
@ -900,7 +898,7 @@ void AppController::SaveModule()
m_logger.Log("Modules saved."); m_logger.Log("Modules saved.");
} }
void AppController::OpenModule(const std::string &uuid) std::shared_ptr<IStoryProject> AppController::OpenModule(const std::string &uuid)
{ {
m_module = m_nodesFactory.GetModule(uuid); m_module = m_nodesFactory.GetModule(uuid);
if (!m_module) if (!m_module)
@ -910,13 +908,12 @@ void AppController::OpenModule(const std::string &uuid)
else if (m_module->Load(m_resources, m_nodesFactory)) else if (m_module->Load(m_resources, m_nodesFactory))
{ {
m_logger.Log("Open module success: " + uuid); m_logger.Log("Open module success: " + uuid);
// Notify GUI (e.g., m_moduleEditorWindow.Load(m_module);)
// m_moduleEditorWindow.Enable();
} }
else else
{ {
m_logger.Log("Open module error: " + uuid, true); m_logger.Log("Open module error: " + uuid, true);
} }
return m_module;
} }
void AppController::CloseModule() void AppController::CloseModule()
@ -951,6 +948,10 @@ void AppController::ImportProject(const std::string &filePathName, int format)
{ {
m_logger.Log("Unknown file format for import: " + filePathName, true); m_logger.Log("Unknown file format for import: " + filePathName, true);
} }
// Send event success
m_eventBus.Emit(std::make_shared<GenericResultEvent>(true, "Import successful"));
} }
std::shared_ptr<IStoryProject> AppController::GetCurrentProject() std::shared_ptr<IStoryProject> AppController::GetCurrentProject()

View file

@ -58,10 +58,10 @@ public:
void NewStory(); void NewStory();
void CloseProject(); void CloseProject();
void SaveProject(); void SaveProject();
void NewModule(); std::shared_ptr<StoryProject> NewModule();
void SaveModule(); void SaveModule();
void CloseModule(); void CloseModule();
void OpenModule(const std::string &uuid); std::shared_ptr<IStoryProject> OpenModule(const std::string &uuid);
void OpenStory(const std::string &path = ""); void OpenStory(const std::string &path = "");
void SaveStory(const std::string &path = ""); void SaveStory(const std::string &path = "");
void ExportStory(const std::string &filename); void ExportStory(const std::string &filename);
@ -106,6 +106,9 @@ public:
std::string GetStringFromMemory(uint32_t addr); std::string GetStringFromMemory(uint32_t addr);
void ProcessStory(); void ProcessStory();
void StepInstruction(); void StepInstruction();
void StopAudio() { m_player.Stop(); }
bool IsLibraryManagerInitialized() const { return m_libraryManager.IsInitialized(); }
// Getters pour les managers gérés par AppController // Getters pour les managers gérés par AppController
ResourceManager& GetResourceManager() { return m_resources; } ResourceManager& GetResourceManager() { return m_resources; }

View file

@ -41,5 +41,18 @@ private:
std::string m_name; // Nom de la fonction à ouvrir std::string m_name; // Nom de la fonction à ouvrir
}; };
class GenericResultEvent : public Event
{
public:
GenericResultEvent(bool success, const std::string& message)
: m_success(success), m_message(message) {}
bool IsSuccess() const { return m_success; }
const std::string& GetMessage() const { return m_message; }
private:
bool m_success;
std::string m_message;
};
#endif // ALL_EVENTS_H #endif // ALL_EVENTS_H

View file

@ -0,0 +1,92 @@
#pragma once
#include "imgui.h"
#include "imgui_internal.h"
#include <string>
#include <vector>
#include <chrono>
#include "IconsMaterialDesignIcons.h"
#include "IconsFontAwesome5_c.h"
enum ToastType {
Success,
Warning,
Error
};
struct Toast {
std::string title;
std::string text;
ToastType type;
std::chrono::steady_clock::time_point startTime;
float duration;
};
class ImGuiToastNotifier {
private:
std::vector<Toast> toasts;
public:
void addToast(const std::string& title, const std::string& text, ToastType type, float duration = 3.0f) {
toasts.push_back({title, text, type, std::chrono::steady_clock::now(), duration});
}
void render() {
if (toasts.empty()) {
return;
}
ImGuiIO& io = ImGui::GetIO();
ImVec2 viewport_pos = ImGui::GetMainViewport()->Pos;
ImVec2 viewport_size = ImGui::GetMainViewport()->Size;
ImVec2 window_pos = ImVec2(viewport_pos.x + viewport_size.x - 10.0f, viewport_pos.y + 10.0f);
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, ImVec2(1.0f, 0.0f));
ImGui::SetNextWindowBgAlpha(0.75f);
if (ImGui::Begin("##ToastWindow", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing)) {
auto now = std::chrono::steady_clock::now();
auto it = toasts.begin();
while (it != toasts.end()) {
auto elapsed = std::chrono::duration<float>(now - it->startTime).count();
if (elapsed > it->duration) {
it = toasts.erase(it);
continue;
}
ImGui::PushID(it->title.c_str());
ImVec4 color;
const char* icon;
switch (it->type) {
case Success:
color = ImVec4(0.18f, 0.80f, 0.44f, 1.0f);
icon = ICON_FA_CHECK_CIRCLE; // Font Awesome 5 success icon (check-circle)
break;
case Warning:
color = ImVec4(1.0f, 0.84f, 0.0f, 1.0f);
icon = ICON_FA_EXCLAMATION_TRIANGLE; // Font Awesome 5 warning icon (exclamation-triangle)
break;
case Error:
color = ImVec4(0.94f, 0.31f, 0.31f, 1.0f);
icon = ICON_FA_TIMES_CIRCLE; // Font Awesome 5 error icon (times-circle)
break;
}
ImGui::PushStyleColor(ImGuiCol_Text, color);
ImGui::Text("%s", icon);
ImGui::PopStyleColor();
ImGui::SameLine();
ImGui::TextUnformatted(it->title.c_str());
ImGui::TextWrapped("%s", it->text.c_str());
ImGui::Separator();
ImGui::PopID();
++it;
}
ImGui::End();
}
}
};

View file

@ -12,12 +12,17 @@ int main(int, char**)
AppController appController(logger, eventBus); AppController appController(logger, eventBus);
MainWindow w(logger, eventBus, appController); auto w = std::make_shared<MainWindow>(logger, eventBus, appController);
if (w.Initialize()) bool done = false;
if (w->Initialize())
{ {
w.Loop(); while (!done)
appController.ProcessStory(); {
done = w->Loop();
appController.ProcessStory();
}
} }
return 0; return 0;

View file

@ -39,9 +39,6 @@ MainWindow::MainWindow(ILogger& logger, EventBus& eventBus, AppController& appCo
, m_variablesWindow(appController) , m_variablesWindow(appController)
, m_projectPropertiesDialog(appController, appController.GetResourceManager()) , m_projectPropertiesDialog(appController, appController.GetResourceManager())
{ {
logger.RegisterSubject(shared_from_this());
CloseProject(); CloseProject();
CloseModule(); CloseModule();
@ -58,10 +55,24 @@ MainWindow::MainWindow(ILogger& logger, EventBus& eventBus, AppController& appCo
m_eventBus.Subscribe<OpenFunctionEvent>([this](const OpenFunctionEvent &event) { m_eventBus.Subscribe<OpenFunctionEvent>([this](const OpenFunctionEvent &event) {
OpenFunction(event.GetUuid(), event.GetName()); OpenFunction(event.GetUuid(), event.GetName());
}); });
m_eventBus.Subscribe<GenericResultEvent>([this](const GenericResultEvent &event) {
// FIXME: ImGui notification widget
if (event.IsSuccess()) {
m_logger.Log("Operation successful: " + event.GetMessage());
m_toastNotifier.addToast("Success", event.GetMessage(), ToastType::Success);
} else {
m_logger.Log("Operation failed: " + event.GetMessage(), true);
m_toastNotifier.addToast("Error", event.GetMessage(), ToastType::Error);
}
});
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
m_gui.Destroy();
m_appController.SaveParams(); m_appController.SaveParams();
} }
@ -180,6 +191,8 @@ bool MainWindow::Initialize()
{ {
bool success = false; bool success = false;
m_logger.RegisterSubject(shared_from_this());
// GUI Init // GUI Init
if (m_gui.Initialize()) if (m_gui.Initialize())
{ {
@ -263,35 +276,34 @@ void MainWindow::OpenProject(const std::string &uuid)
void MainWindow::NewModule() void MainWindow::NewModule()
{ {
auto module = m_appController.NewModule(); auto module = m_appController.NewModule();
m_moduleEditorWindow.Load(module);
m_moduleEditorWindow.Enable(); if (module)
{
m_moduleEditorWindow.Load(module);
m_moduleEditorWindow.Enable();
m_logger.Log("New module created.");
}
else
{
m_logger.Log("Failed to create new module.");
}
} }
void MainWindow::SaveModule() void MainWindow::SaveModule()
{ {
m_appController.SaveAllModules(m_resources);; m_appController.SaveModule();
m_logger.Log("Modules saved"); m_logger.Log("Modules saved");
} }
void MainWindow::OpenModule(const std::string &uuid) void MainWindow::OpenModule(const std::string &uuid)
{ {
m_module = m_nodesFactory.GetModule(uuid); auto module = m_appController.OpenModule(uuid);
if (!m_module) if (module)
{ {
m_logger.Log("Cannot find module: " + uuid); std::shared_ptr<StoryProject> modulePtr = std::dynamic_pointer_cast<StoryProject>(module);
} m_moduleEditorWindow.Load(modulePtr);
else if (m_module->Load(m_resources, m_nodesFactory))
{
m_logger.Log("Open module success");
m_moduleEditorWindow.Load(m_module);
m_moduleEditorWindow.Enable(); m_moduleEditorWindow.Enable();
} }
else
{
m_logger.Log("Open module error");
}
} }
@ -333,29 +345,6 @@ void MainWindow::CloseModule()
} }
void MainWindow::ImportProject(const std::string &filePathName, int format)
{
(void) format;
PackArchive archive(*this, m_nodesFactory);
// On va déterminer le type de fichier selon l'extension
auto ext = SysLib::GetFileExtension(filePathName);
auto filename = SysLib::GetFileName(filePathName);
if ((ext == "pk") || (filename == "ni"))
{
archive.ImportCommercialFormat(filePathName, m_libraryManager.LibraryPath(), m_libraryManager.CommercialDbView());
}
else if ((ext == "json") || (ext == "zip"))
{
archive.ImportStudioFormat(filePathName, m_libraryManager.LibraryPath());
}
else
{
m_logger.Log("Unknown file format: " + filePathName);
}
}
void MainWindow::RefreshProjectInformation() void MainWindow::RefreshProjectInformation()
{ {
std::string fullText = "Story Editor " + LibraryManager::GetVersion(); std::string fullText = "Story Editor " + LibraryManager::GetVersion();
@ -392,7 +381,7 @@ void MainWindow::DrawToolBar(float topPadding)
// Ajouter des boutons à la barre d'outils // Ajouter des boutons à la barre d'outils
if (ImGui::Button(ICON_MDI_SPEAKER_STOP "##stop_sound", ImVec2(-1, 50))) { // Le bouton prend toute la largeur de la fenêtre et a une hauteur de 50 pixels if (ImGui::Button(ICON_MDI_SPEAKER_STOP "##stop_sound", ImVec2(-1, 50))) { // Le bouton prend toute la largeur de la fenêtre et a une hauteur de 50 pixels
m_player.Stop(); m_appController.StopAudio();
} }
ImGui::GetFont()->Scale = old_size; ImGui::GetFont()->Scale = old_size;
@ -405,84 +394,80 @@ void MainWindow::DrawToolBar(float topPadding)
} }
#include "imgui_internal.h" #include "imgui_internal.h"
void MainWindow::Loop() bool MainWindow::Loop()
{ {
// Main loop // Main loop
bool done = false; static bool done = false;
while (!done)
Uint64 frameStart = SDL_GetTicks();
bool aboutToClose = m_gui.PollEvent();
m_gui.StartFrame();
auto vp = ImGui::GetMainViewport();
auto pos = vp->WorkPos;
auto size = vp->WorkSize;
pos.x += 60;
size.x -= 60;
vp->WorkPos = pos;
vp->WorkSize = size;
ImGui::DockSpaceOverViewport(0, vp);
float height = DrawMainMenuBar();
// ------------ Draw all windows
m_libraryWindow.Draw();
if (m_appController.IsLibraryManagerInitialized())
{ {
Uint64 frameStart = SDL_GetTicks(); m_consoleWindow.Draw();
bool aboutToClose = m_gui.PollEvent(); m_emulatorDock.Draw();
m_debuggerWindow.Draw();
m_resourcesDock.Draw();
m_nodeEditorWindow.Draw();
m_moduleEditorWindow.Draw();
m_variablesWindow.Draw();
m_cpuWindow.Draw();
m_gui.StartFrame(); static MemoryEditor mem_edit_1;
mem_edit_1.DrawWindow("RAM view", m_appController.GetChip32Context()->ram.mem, m_appController.GetChip32Context()->ram.size);
auto vp = ImGui::GetMainViewport(); m_PropertiesWindow.SetSelectedNode(m_nodeEditorWindow.GetSelectedNode());
m_PropertiesWindow.Draw();
auto pos = vp->WorkPos;
auto size = vp->WorkSize;
pos.x += 60;
size.x -= 60;
vp->WorkPos = pos;
vp->WorkSize = size;
ImGui::DockSpaceOverViewport(0, vp);
float height = DrawMainMenuBar();
ProcessStory();
// ------------ Draw all windows
m_libraryWindow.Draw();
if (m_libraryManager.IsInitialized())
{
m_consoleWindow.Draw();
m_emulatorDock.Draw();
m_debuggerWindow.Draw();
m_resourcesDock.Draw();
m_nodeEditorWindow.Draw();
m_moduleEditorWindow.Draw();
m_variablesWindow.Draw();
m_cpuWindow.Draw();
static MemoryEditor mem_edit_1;
mem_edit_1.DrawWindow("RAM view", m_chip32_ctx.ram.mem, m_chip32_ctx.ram.size);
m_PropertiesWindow.SetSelectedNode(m_nodeEditorWindow.GetSelectedNode());
m_PropertiesWindow.Draw();
// static ImGuiAxis toolbar2_axis = ImGuiAxis_Y; // static ImGuiAxis toolbar2_axis = ImGuiAxis_Y;
// DockingToolbar("Toolbar2", &toolbar2_axis); // DockingToolbar("Toolbar2", &toolbar2_axis);
DrawToolBar(height);
}
m_aboutDialog.Draw();
m_projectPropertiesDialog.Draw();
if (aboutToClose)
{
ImGui::OpenPopup("QuitConfirm");
}
if (ShowQuitConfirm())
{
done = true;
}
m_gui.EndFrame();
// Rendering and event handling
Uint64 frameTime = SDL_GetTicks() - frameStart; // Temps écoulé pour la frame
if (frameTime < 32) { // 16 ms = 60 FPS
SDL_Delay(32 - frameTime); // Attendez pour compléter la frame
}
DrawToolBar(height);
} }
m_gui.Destroy(); m_aboutDialog.Draw();
m_projectPropertiesDialog.Draw();
m_toastNotifier.render();
if (aboutToClose)
{
ImGui::OpenPopup("QuitConfirm");
}
if (ShowQuitConfirm())
{
done = true;
}
m_gui.EndFrame();
// Rendering and event handling
Uint64 frameTime = SDL_GetTicks() - frameStart; // Temps écoulé pour la frame
if (frameTime < 32) { // 16 ms = 60 FPS
SDL_Delay(32 - frameTime); // Attendez pour compléter la frame
}
return done;
} }
@ -496,114 +481,3 @@ void MainWindow::OpenFunction(const std::string &uuid, const std::string &name)
{ {
m_nodeEditorWindow.OpenFunction(uuid, name); m_nodeEditorWindow.OpenFunction(uuid, name);
} }
void MainWindow::Build(bool compileonly)
{
m_dbg.run_result = VM_FINISHED;
m_dbg.free_run = false;
if (!compileonly)
{
// 3. Convert all media to desired type format
auto options = m_story->GetOptions();
m_resources.ConvertResources(m_story->AssetsPath(), "", options.image_format, options.sound_format); // pas de répertoire de destination
}
Chip32::Assembler::Error err;
m_debuggerWindow.ClearErrors();
if (m_story->GenerateBinary(m_currentCode, err))
{
m_result.Print();
if (m_story->CopyProgramTo(m_rom_data, sizeof (m_rom_data)))
{
// m_ramView->SetMemory(m_ram_data, sizeof(m_ram_data));
// m_romView->SetMemory(m_rom_data, m_program.size());
m_story->SaveBinary();
chip32_initialize(&m_chip32_ctx);
m_dbg.run_result = VM_READY;
UpdateVmView();
}
else
{
m_logger.Log("Program too big. Expand ROM memory.");
}
}
else
{
m_logger.Log(err.ToString(), true);
m_debuggerWindow.AddError(err.line, err.message); // show also the error in the code editor
}
}
void MainWindow::SetExternalSourceFile(const std::string &filename)
{
m_externalSourceFileName = filename;
}
void MainWindow::UpdateVmView()
{
// FIXME
// m_vmDock->updateRegistersView(m_chip32_ctx);
// Highlight next line in the test editor
uint32_t pcVal = m_chip32_ctx.registers[PC];
if (m_story->GetAssemblyLine(pcVal, m_dbg.line))
{
m_debuggerWindow.HighlightLine(m_dbg.line);
std::cout << "Executing line: " << m_dbg.line << std::endl;
}
else
{
// Not found
m_logger.Log("Reached end or instruction not found line: " + std::to_string(m_dbg.line));
}
// Refresh RAM content
// m_ramView->SetMemory(m_ram_data, m_chip32_ctx.ram.size);
}
void MainWindow::LoadParams()
{
try {
// Modules directory
std::filesystem::path dlDir = std::filesystem::path(pf::getConfigHome()) / "ost_modules";
std::filesystem::create_directories(dlDir);
m_nodesFactory.SetModulesRootDirectory(dlDir.string());
std::string loc = pf::getConfigHome() + "/ost_settings.json";
// read a JSON file
std::ifstream i(loc);
nlohmann::json j;
i >> j;
nlohmann::json recents = j["recents"];
for (auto& element : recents) {
if (std::filesystem::exists(element))
{
m_recentProjects.push_back(element);
}
}
nlohmann::json library_path = j["library_path"];
if (std::filesystem::exists(library_path))
{
m_libraryManager.Initialize(library_path);
}
nlohmann::json store_url = j.value("store_url", "https://gist.githubusercontent.com/DantSu/3aea4c1fe15070bcf394a40b89aec33e/raw/stories.json");
m_libraryManager.SetStoreUrl(store_url);
}
catch(std::exception &e)
{
m_logger.Log(e.what(), true);
}
}

View file

@ -23,7 +23,7 @@
#include "event_bus.h" #include "event_bus.h"
#include "app_controller.h" #include "app_controller.h"
#include "i_logger.h" #include "i_logger.h"
#include "imgui_toast_notifier.h"
class MainWindow : public std::enable_shared_from_this<MainWindow>, public ILogSubject class MainWindow : public std::enable_shared_from_this<MainWindow>, public ILogSubject
{ {
@ -32,7 +32,7 @@ public:
~MainWindow(); ~MainWindow();
bool Initialize(); bool Initialize();
void Loop(); bool Loop();
private: private:
enum VmEventType { EvNoEvent, EvStep, EvRun, EvOkButton, EvPreviousButton, EvNextButton, EvAudioFinished, EvStop, EvHomeButton}; enum VmEventType { EvNoEvent, EvStep, EvRun, EvOkButton, EvPreviousButton, EvNextButton, EvAudioFinished, EvStop, EvHomeButton};
@ -62,6 +62,8 @@ private:
AboutDialog m_aboutDialog; AboutDialog m_aboutDialog;
ProjectPropertiesDialog m_projectPropertiesDialog; ProjectPropertiesDialog m_projectPropertiesDialog;
ImGuiToastNotifier m_toastNotifier;
// From IStoryManager (proxy to StoryProject class) // From IStoryManager (proxy to StoryProject class)
void OpenProject(const std::string &uuid); void OpenProject(const std::string &uuid);
void CloseProject(); void CloseProject();
@ -74,15 +76,11 @@ private:
// From ILogSubject // From ILogSubject
virtual void LogEvent(const std::string &txt, bool critical) override; virtual void LogEvent(const std::string &txt, bool critical) override;
void LoadParams();
void RefreshProjectInformation(); void RefreshProjectInformation();
float DrawMainMenuBar(); float DrawMainMenuBar();
bool ShowQuitConfirm(); bool ShowQuitConfirm();
void DrawToolBar(float topPadding); void DrawToolBar(float topPadding);
void UpdateVmView(); void UpdateVmView();
void RefreshProjectIœnformation();
void Build(bool compileonly);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H