mirror of
https://github.com/arabine/open-story-teller.git
synced 2025-12-06 17:09:06 +01:00
(wip) compilation of module
This commit is contained in:
parent
6459dba5c3
commit
da04c38dec
7 changed files with 53 additions and 26 deletions
|
|
@ -46,7 +46,7 @@ public:
|
|||
virtual std::shared_ptr<IStoryProject> OpenModule(const std::string &uuid) = 0;
|
||||
|
||||
// Node interaction
|
||||
virtual void BuildNodes(bool compileonly) = 0;
|
||||
virtual void CompileNodes(bool compileonly) = 0;
|
||||
virtual void BuildCode(bool compileonly) = 0;
|
||||
virtual void SetExternalSourceFile(const std::string &filename) = 0;
|
||||
virtual void LoadBinaryStory(const std::string &filename) = 0;
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ public:
|
|||
m_nodes.clear();
|
||||
}
|
||||
|
||||
void BuildNodesVariables(AssemblyGenerator &generator)
|
||||
void CompileNodesVariables(AssemblyGenerator &generator)
|
||||
{
|
||||
std::vector<std::shared_ptr<BaseNode>> nodes(m_nodes.begin(), m_nodes.end());
|
||||
generator.GenerateNodesVariables(nodes);
|
||||
}
|
||||
|
||||
void BuildNodes(AssemblyGenerator &generator)
|
||||
void CompileNodes(AssemblyGenerator &generator)
|
||||
{
|
||||
std::vector<std::shared_ptr<BaseNode>> nodes(m_nodes.begin(), m_nodes.end());
|
||||
std::vector<std::shared_ptr<Connection>> links(m_links.begin(), m_links.end());
|
||||
|
|
|
|||
|
|
@ -420,14 +420,14 @@ bool StoryProject::GenerateScript(std::string &codeStr)
|
|||
generator.StartSection(AssemblyGenerator::Section::TEXT);
|
||||
for (const auto & p : m_pages)
|
||||
{
|
||||
p->BuildNodes(generator);
|
||||
p->CompileNodes(generator);
|
||||
}
|
||||
|
||||
// Generate data section
|
||||
generator.StartSection(AssemblyGenerator::Section::DATA);
|
||||
for (const auto & p : m_pages)
|
||||
{
|
||||
p->BuildNodesVariables(generator);
|
||||
p->CompileNodesVariables(generator);
|
||||
}
|
||||
generator.GenerateGlobalVariables();
|
||||
|
||||
|
|
|
|||
|
|
@ -241,23 +241,35 @@ void AppController::ExportStory(const std::string &filename)
|
|||
m_logger.Log("Export story to: " + filename);
|
||||
}
|
||||
|
||||
void AppController::BuildNodes(IStoryProject::Type type)
|
||||
void AppController::CompileNodes(IStoryProject::Type type)
|
||||
{
|
||||
if (type == IStoryProject::Type::PROJECT_TYPE_STORY && m_story) {
|
||||
if (m_story->GenerateScript(m_currentCode))
|
||||
if (type == IStoryProject::Type::PROJECT_TYPE_STORY && m_story)
|
||||
{
|
||||
if (m_story->GenerateScript(m_storyAssembly))
|
||||
{
|
||||
// La GUI (DebuggerWindow) doit être notifiée de cette mise à jour.
|
||||
// Au lieu de appeler m_debuggerWindow.SetScript(m_currentCode); directement,
|
||||
// Au lieu de appeler m_debuggerWindow.SetScript(m_storyAssembly); directement,
|
||||
// AppController pourrait émettre un événement ou un callback.
|
||||
// Pour l'instant, on suppose une notification ou que la GUI tire les données.
|
||||
m_logger.Log("Nodes script generated for story.");
|
||||
Build(true); // Compile seulement par défaut
|
||||
}
|
||||
} else if (type == IStoryProject::Type::PROJECT_TYPE_MODULE && m_module) {
|
||||
// Logique de génération de script pour le module
|
||||
// Similaire à BuildNodes pour le projet principal.
|
||||
else
|
||||
{
|
||||
m_logger.Log("Failed to generate script for story.", true);
|
||||
}
|
||||
}
|
||||
else if (type == IStoryProject::Type::PROJECT_TYPE_MODULE && m_module)
|
||||
{
|
||||
if (m_module->GenerateScript(m_storyAssembly))
|
||||
{
|
||||
m_logger.Log("Nodes script generated for module.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_logger.Log("Failed to generate script for module.", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppController::Build(bool compileonly)
|
||||
|
|
@ -282,7 +294,7 @@ void AppController::Build(bool compileonly)
|
|||
// La GUI (DebuggerWindow) doit être notifiée pour effacer les erreurs. FIXME
|
||||
// m_debuggerWindow.ClearErrors();
|
||||
|
||||
if (m_story->GenerateBinary(m_currentCode, err))
|
||||
if (m_story->GenerateBinary(m_storyAssembly, err))
|
||||
{
|
||||
m_result.Print(); // Imprime le résultat de l'assemblage (Debug uniquement)
|
||||
|
||||
|
|
@ -310,11 +322,11 @@ void AppController::Build(bool compileonly)
|
|||
void AppController::BuildCode(std::shared_ptr<StoryProject> story, bool compileonly, bool force)
|
||||
{
|
||||
// Note: Dans le code original, BuildCode lisait m_externalSourceFileName.
|
||||
// Il faut s'assurer que m_currentCode est bien défini avant d'appeler Build.
|
||||
// Il faut s'assurer que m_storyAssembly est bien défini avant d'appeler Build.
|
||||
if (story) {
|
||||
m_currentCode = SysLib::ReadFile(story->GetProjectFilePath()); // Simplifié pour l'exemple
|
||||
m_storyAssembly = SysLib::ReadFile(story->GetProjectFilePath()); // Simplifié pour l'exemple
|
||||
// La GUI (DebuggerWindow) doit être notifiée pour SetScript.
|
||||
// m_debuggerWindow.SetScript(m_currentCode);
|
||||
// m_debuggerWindow.SetScript(m_storyAssembly);
|
||||
Build(compileonly);
|
||||
} else {
|
||||
m_logger.Log("No story provided for BuildCode.", true);
|
||||
|
|
@ -324,17 +336,17 @@ void AppController::BuildCode(std::shared_ptr<StoryProject> story, bool compileo
|
|||
|
||||
void AppController::BuildCode(bool compileonly)
|
||||
{
|
||||
m_currentCode = SysLib::ReadFile(m_externalSourceFileName);
|
||||
// m_debuggerWindow.SetScript(m_currentCode); // FIXME: GUI event
|
||||
m_storyAssembly = SysLib::ReadFile(m_externalSourceFileName);
|
||||
// m_debuggerWindow.SetScript(m_storyAssembly); // FIXME: GUI event
|
||||
Build(compileonly);
|
||||
}
|
||||
|
||||
|
||||
void AppController::BuildNodes(bool compileonly)
|
||||
void AppController::CompileNodes(bool compileonly)
|
||||
{
|
||||
if (m_story->GenerateScript(m_currentCode))
|
||||
if (m_story->GenerateScript(m_storyAssembly))
|
||||
{
|
||||
// m_debuggerWindow.SetScript(m_currentCode); // FIXME: GUI event
|
||||
// m_debuggerWindow.SetScript(m_storyAssembly); // FIXME: GUI event
|
||||
Build(compileonly);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public:
|
|||
void ExportStory(const std::string &filename);
|
||||
std::shared_ptr<StoryProject> GetCurrentStory() const { return m_story; }
|
||||
std::shared_ptr<StoryProject> GetCurrentModule() const { return m_module; }
|
||||
void BuildNodes(IStoryProject::Type type);
|
||||
void CompileNodes(IStoryProject::Type type);
|
||||
void Build(bool compileonly);
|
||||
void BuildCode(std::shared_ptr<StoryProject> story, bool compileonly, bool force = false);
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ public:
|
|||
virtual void Next() override;
|
||||
virtual void Previous() override;
|
||||
virtual std::string VmState() const override;
|
||||
virtual void BuildNodes(bool compileonly);
|
||||
virtual void CompileNodes(bool compileonly);
|
||||
virtual void BuildCode(bool compileonly);
|
||||
virtual std::shared_ptr<IStoryProject> GetCurrentProject() override;
|
||||
|
||||
|
|
@ -133,7 +133,8 @@ private:
|
|||
chip32_ctx_t m_chip32_ctx;
|
||||
Chip32::Result m_result;
|
||||
DebugContext m_dbg; // Contexte de débogage
|
||||
std::string m_currentCode;
|
||||
std::string m_storyAssembly;
|
||||
std::string m_moduleAssembly;
|
||||
std::string m_externalSourceFileName;
|
||||
std::vector<std::string> m_recentProjects;
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void EmulatorDock::Draw()
|
|||
|
||||
if (ImGui::Button("Build nodes"))
|
||||
{
|
||||
m_story.BuildNodes(true);
|
||||
m_story.CompileNodes(true);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Build code"))
|
||||
|
|
|
|||
|
|
@ -399,6 +399,20 @@ void MainWindow::DrawToolBar(float topPadding)
|
|||
m_appController.StopAudio();
|
||||
}
|
||||
|
||||
if (ImGui::Button(ICON_MDI_HAMMER "##build_project", ImVec2(-1, 50))) { // Le bouton prend toute la largeur de la fenêtre et a une hauteur de 50 pixels
|
||||
|
||||
// Compile story if window focused, otherwise module
|
||||
if (m_nodeEditorWindow.IsFocused())
|
||||
{
|
||||
m_appController.CompileNodes(IStoryProject::PROJECT_TYPE_STORY);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_appController.CompileNodes(IStoryProject::PROJECT_TYPE_MODULE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ImGui::GetFont()->Scale = old_size;
|
||||
ImGui::PopFont();
|
||||
ImGui::PopStyleColor();
|
||||
|
|
|
|||
Loading…
Reference in a new issue