diff --git a/.github/workflows/story_editor.yml b/.github/workflows/story_editor.yml index 05022f9..27865b8 100644 --- a/.github/workflows/story_editor.yml +++ b/.github/workflows/story_editor.yml @@ -41,4 +41,5 @@ jobs: - name: build working-directory: ./story-editor run : | + ./create_docker_image_win.sh ./build_win32.sh diff --git a/.vscode/settings.json b/.vscode/settings.json index a6efe17..571b49a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -106,7 +106,8 @@ "stdfloat": "cpp", "text_encoding": "cpp", "serializers.h": "c", - "ni_parser.h": "c" + "ni_parser.h": "c", + "*.m": "cpp" } } \ No newline at end of file diff --git a/core/interfaces/i_story_project.h b/core/interfaces/i_story_project.h index 39f0b5f..238f0b5 100644 --- a/core/interfaces/i_story_project.h +++ b/core/interfaces/i_story_project.h @@ -13,6 +13,9 @@ public: virtual std::list> GetNodeConnections(const std::string &nodeId) = 0; virtual int OutputsCount(const std::string &nodeId) = 0; virtual StoryOptions GetOptions() = 0; + + /* Retourne true si la resource existe déjà et que le code a déjà été généré */ + virtual bool UseResource(const std::string &label) = 0; }; diff --git a/core/lib/sys_lib.cpp b/core/lib/sys_lib.cpp index 5f79128..a4408ea 100644 --- a/core/lib/sys_lib.cpp +++ b/core/lib/sys_lib.cpp @@ -29,7 +29,7 @@ std::string SysLib::ToLower(const std::string &input) return str; } -std::string SysLib::ReadFile(const std::string &filename) +std::string SysLib::ReadFile(const std::filesystem::path &filename) { // Open the stream to 'lock' the file. std::ifstream f(filename, std::ios::in | std::ios::binary); diff --git a/core/lib/sys_lib.h b/core/lib/sys_lib.h index 5521071..0d5936e 100644 --- a/core/lib/sys_lib.h +++ b/core/lib/sys_lib.h @@ -1,6 +1,7 @@ #pragma once #include +#include class SysLib { @@ -15,5 +16,5 @@ public: static void EraseString(std::string &theString, const std::string &toErase); static std::string ToUpper(const std::string &input); static std::string ToLower(const std::string &input); - static std::string ReadFile(const std::string &filename); + static std::string ReadFile(const std::filesystem::path &filename); }; diff --git a/core/src/base_node.h b/core/src/base_node.h index 61bd340..9f74d73 100644 --- a/core/src/base_node.h +++ b/core/src/base_node.h @@ -7,6 +7,7 @@ #include "json.hpp" #include "i_story_page.h" +#include "i_story_project.h" #include "story_options.h" class BaseNode @@ -25,7 +26,7 @@ public: virtual void Initialize() = 0; virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) = 0; - virtual std::string GenerateConstants(IStoryPage &page, const StoryOptions &options, int nb_out_conns) = 0; + virtual std::string GenerateConstants(IStoryPage &page, IStoryProject &project, int nb_out_conns) = 0; void SetPosition(float x, float y); diff --git a/core/src/compiler.cpp b/core/src/compiler.cpp index 596c5ab..bda43bd 100644 --- a/core/src/compiler.cpp +++ b/core/src/compiler.cpp @@ -2,8 +2,16 @@ #include "compiler.h" -std::string Compiler::FileToConstant(const std::string &FileName, const std::string &extension) +std::string Compiler::FileToConstant(const std::string &FileName, const std::string &extension, IStoryProject &project) { - std::string f = SysLib::RemoveFileExtension(FileName); - return "$" + FileName + " DC8 \"" + FileName + "\", 8\r\n"; + std::string label = "$" + FileName; + + if (!project.UseResource(label)) + { + std::string f = SysLib::RemoveFileExtension(FileName); + return label + " DC8 \"" + FileName + "\", 8\r\n"; + } + + // Label of file is already existing, so we do not add anything + return ""; } diff --git a/core/src/compiler.h b/core/src/compiler.h index c624e68..804eb11 100644 --- a/core/src/compiler.h +++ b/core/src/compiler.h @@ -1,6 +1,7 @@ #pragma once #include "sys_lib.h" +#include "i_story_project.h" class Compiler { @@ -9,7 +10,7 @@ public: Compiler() = default; ~Compiler() = default; - static std::string FileToConstant(const std::string &FileName, const std::string &extension); + static std::string FileToConstant(const std::string &FileName, const std::string &extension, IStoryProject &project); }; diff --git a/core/src/function_node.cpp b/core/src/function_node.cpp index 448b609..45a62c2 100644 --- a/core/src/function_node.cpp +++ b/core/src/function_node.cpp @@ -32,7 +32,7 @@ std::string FunctionNode::Build(IStoryPage &page, const StoryOptions &options, i return std::string(); } -std::string FunctionNode::GenerateConstants(IStoryPage &page, const StoryOptions &options, int nb_out_conns) +std::string FunctionNode::GenerateConstants(IStoryPage &page, IStoryProject &project, int nb_out_conns) { std::string s; diff --git a/core/src/function_node.h b/core/src/function_node.h index 9fc7393..d8cb6b1 100644 --- a/core/src/function_node.h +++ b/core/src/function_node.h @@ -13,7 +13,7 @@ public: virtual void Initialize() override; virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override; - virtual std::string GenerateConstants(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override; + virtual std::string GenerateConstants(IStoryPage &page, IStoryProject &project, int nb_out_conns) override; void StoreInternalData(); diff --git a/core/src/media_node.cpp b/core/src/media_node.cpp index 10cb03b..7691cde 100644 --- a/core/src/media_node.cpp +++ b/core/src/media_node.cpp @@ -34,17 +34,17 @@ void MediaNode::Initialize() m_sound = j["sound"].get(); } -std::string MediaNode::GenerateConstants(IStoryPage &page, const StoryOptions &options, int nb_out_conns) +std::string MediaNode::GenerateConstants(IStoryPage &page, IStoryProject &project, int nb_out_conns) { std::string s; if (m_image.size() > 0) { - s = Compiler::FileToConstant(m_image, Resource::ImageExtension(m_image, options.image_format)); + s = Compiler::FileToConstant(m_image, Resource::ImageExtension(m_image, project.GetOptions().image_format), project); } if (m_sound.size() > 0) { - s += Compiler::FileToConstant(m_sound, Resource::SoundExtension(m_sound, options.sound_format)); // FIXME: Generate the extension setup in user option of output format + s += Compiler::FileToConstant(m_sound, Resource::SoundExtension(m_sound, project.GetOptions().sound_format), project); // FIXME: Generate the extension setup in user option of output format } // Generate choice table if needed (out ports > 1) diff --git a/core/src/media_node.h b/core/src/media_node.h index 3b47a0b..39c05bf 100644 --- a/core/src/media_node.h +++ b/core/src/media_node.h @@ -13,7 +13,7 @@ public: virtual void Initialize() override; virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override; - virtual std::string GenerateConstants(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override; + virtual std::string GenerateConstants(IStoryPage &page, IStoryProject &project, int nb_out_conns) override; void SetImage(const std::string &image); std::string_view GetImage() const; diff --git a/core/src/story_page.h b/core/src/story_page.h index 61fb6bb..ab15c44 100644 --- a/core/src/story_page.h +++ b/core/src/story_page.h @@ -5,6 +5,7 @@ #include #include "i_story_page.h" +#include "i_story_project.h" #include "base_node.h" #include "connection.h" @@ -49,17 +50,17 @@ public: m_nodes.clear(); } - void Build(std::stringstream &code, const StoryOptions &options) + void Build(std::stringstream &code, IStoryProject &project) { // First generate all constants for (const auto & n : m_nodes) { - code << n->GenerateConstants(*this, options, OutputsCount(n->GetId())) << "\n"; + code << n->GenerateConstants(*this, project, OutputsCount(n->GetId())) << "\n"; } for (const auto & n : m_nodes) { - code << n->Build(*this, options, OutputsCount(n->GetId())) << "\n"; + code << n->Build(*this, project.GetOptions(), OutputsCount(n->GetId())) << "\n"; } } diff --git a/core/src/story_project.cpp b/core/src/story_project.cpp index 610d0d2..301f3de 100644 --- a/core/src/story_project.cpp +++ b/core/src/story_project.cpp @@ -340,6 +340,17 @@ int StoryProject::OutputsCount(const std::string &nodeId) return 0; } +bool StoryProject::UseResource(const std::string &label) +{ + bool used = m_usedLabels.contains(label); + + if (!used) + { + m_usedLabels.insert(label); + } + return used; +} + bool StoryProject::GenerateScript(std::string &codeStr) { std::stringstream code; @@ -359,10 +370,13 @@ bool StoryProject::GenerateScript(std::string &codeStr) code << "\tjump " << BaseNode::GetEntryLabel(firstNode) << "\r\n"; + // Empty resources usage + m_usedLabels.clear(); + // On build toutes les pages for (const auto & p : m_pages) { - p->Build(code, m_storyOptions); + p->Build(code, *this); } codeStr = code.str(); @@ -485,40 +499,7 @@ void StoryProject::Save(ResourceManager &manager) std::ofstream o(m_project_file_path); o << std::setw(4) << j << std::endl; } -/* -void StoryProject::CreateTree() -{ - // Algorithm: level order traversal of N-ary tree - std::queue nlist; - m_tree = &m_nodes[0]; - nlist.push(m_tree); - - while (!nlist.empty()) - { - StoryNode *p = nlist.front(); - std::cout << "Node: " << p->id << std::endl; - - for (size_t i = 0; i < p->jumps.size(); i++) - { - size_t jump = p->jumps[i]; - - if (jump < m_nodes.size()) - { - StoryNode *child = &m_nodes[jump]; - nlist.push(child); - p->children.push_back(child); - } - else - { - std::cout << "End node" << std::endl; - } - } - - nlist.pop(); - } -} -*/ void StoryProject::Clear() { diff --git a/core/src/story_project.h b/core/src/story_project.h index 1c69c53..460b26d 100644 --- a/core/src/story_project.h +++ b/core/src/story_project.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "json.hpp" #include "json.hpp" @@ -15,38 +16,6 @@ #include "story_page.h" #include "story_options.h" -// FIXME : Structure très proche de la boiboite, à utiliser pour la conversion peut-être ... -struct StoryNode -{ - bool auto_jump; - int sound; - int image; - int id; - std::vector jumps; - - std::vector children; - - StoryNode& operator=(const StoryNode& other) { - this->auto_jump = other.auto_jump; - this->sound = other.sound; - this->image = other.image; - this->id = other.id; - - this->jumps.clear(); - this->jumps = other.jumps; - this->children = other.children; - - return *this; - } - -// "auto_jump": false, -// "id": 0, -// "image": 0, -// "jumps": [1], -// "sound": 0 -}; - - struct StoryProject : public IStoryProject { @@ -58,14 +27,6 @@ public: bool *Selected() { return &m_selected; } -/* - std::vector m_nodes; - - std::string m_type; - std::string m_code; - - StoryNode *m_tree; -*/ std::string MainUuid() const { return "490745ab-df4d-476d-ae27-027e94b8ee0a"; @@ -128,6 +89,7 @@ public: virtual std::list> GetNodeConnections(const std::string &nodeId) override; virtual int OutputsCount(const std::string &nodeId) override; virtual StoryOptions GetOptions() override { return m_storyOptions; } + virtual bool UseResource(const std::string &label) override; // Node interaction std::shared_ptr CreatePage(const std::string &uuid); @@ -158,6 +120,8 @@ private: uint32_t m_version; bool m_selected{false}; + std::unordered_set m_usedLabels; // permet de ne pas générer un label qui existe déjà + std::filesystem::path m_assetsPath; Chip32::Assembler m_assembler; diff --git a/firmware/chip32/chip32_vm.c b/firmware/chip32/chip32_vm.c index 4e81501..8b92289 100644 --- a/firmware/chip32/chip32_vm.c +++ b/firmware/chip32/chip32_vm.c @@ -113,7 +113,12 @@ chip32_result_t chip32_run(chip32_ctx_t *ctx) chip32_result_t result = VM_OK; while ((ctx->max_instr == 0) || (ctx->instrCount < ctx->max_instr)) { - chip32_step(ctx); + result = chip32_step(ctx); + + if (result > VM_OK) + { + break; + } } return result; } @@ -193,7 +198,7 @@ chip32_result_t chip32_step(chip32_ctx_t *ctx) ctx->registers[PC] = ctx->registers[reg] - 1; // Save Tx registers on stack - _CHECK_CAN_POP(10) + _CHECK_CAN_PUSH(10) for (int i = 0; i < 10; i++) { push(ctx, ctx->registers[T0 + i]); } @@ -204,6 +209,7 @@ chip32_result_t chip32_step(chip32_ctx_t *ctx) { ctx->registers[PC] = ctx->registers[RA] - 1; + _CHECK_CAN_POP(10) // restore Tx registers from stack for (int i = 0; i < 10; i++) { ctx->registers[T9 - i] = pop(ctx); diff --git a/story-editor/CMakeLists.txt b/story-editor/CMakeLists.txt index d5e31c6..482ae45 100644 --- a/story-editor/CMakeLists.txt +++ b/story-editor/CMakeLists.txt @@ -44,7 +44,6 @@ CPMAddPackage( "ENABLE_TESTING OFF" ) -find_package(MbedTLS REQUIRED) include_directories(${mbedtls_INCLUDE_DIR}) # set(MBEDTLS_STATIC_LIBRARY ON) diff --git a/story-editor/Dockerfile b/story-editor/Dockerfile index 25a4ef3..aed3a0d 100644 --- a/story-editor/Dockerfile +++ b/story-editor/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:22.04 LABEL Description="Developer environment" -ENV HOME /root +ENV HOME=/root SHELL ["/bin/bash", "-c"] @@ -29,21 +29,22 @@ RUN mkdir /workspace # Build OpenSSL for windows # Libraries are installed in /libs/ # ======================================================================== +# Plus besoin: on utilise mBedTLS -ENV OPENSSL_VERSION="3.0.13" +# ENV OPENSSL_VERSION="3.0.13" -RUN mkdir -p /libs/openssl +# RUN mkdir -p /libs/openssl -RUN set -x \ - && wget --no-check-certificate -O /tmp/openssl-${OPENSSL_VERSION}.tar.gz "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" \ - && tar -xvf /tmp/openssl-${OPENSSL_VERSION}.tar.gz -C /tmp/ \ - && rm -rf /tmp/openssl-${OPENSSL_VERSION}.tar.gz \ - && cd /tmp/openssl-${OPENSSL_VERSION} \ - && ./Configure --cross-compile-prefix=x86_64-w64-mingw32- mingw64 --prefix=/libs/openssl \ - && make \ - && make install \ - && cd .. \ - && rm -rf openssl-${OPENSSL_VERSION} +# RUN set -x \ +# && wget --no-check-certificate -O /tmp/openssl-${OPENSSL_VERSION}.tar.gz "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" \ +# && tar -xvf /tmp/openssl-${OPENSSL_VERSION}.tar.gz -C /tmp/ \ +# && rm -rf /tmp/openssl-${OPENSSL_VERSION}.tar.gz \ +# && cd /tmp/openssl-${OPENSSL_VERSION} \ +# && ./Configure --cross-compile-prefix=x86_64-w64-mingw32- mingw64 --prefix=/libs/openssl \ +# && make \ +# && make install \ +# && cd .. \ +# && rm -rf openssl-${OPENSSL_VERSION} - ENV PATH /libs/openssl/bin:$PATH +# ENV PATH=/libs/openssl/bin:$PATH diff --git a/story-editor/build_win32.sh b/story-editor/build_win32.sh index 6f734c5..c49a413 100755 --- a/story-editor/build_win32.sh +++ b/story-editor/build_win32.sh @@ -1,4 +1,4 @@ -docker build -t cpp-dev . + docker run \ -v $(pwd)/..:/workspace \ cpp-dev \ @@ -6,8 +6,6 @@ docker run \ -c "mkdir -p /workspace/story-editor/build-win32 && \ cd /workspace/story-editor/build-win32 && \ git config --global http.sslverify false && \ - cmake -DOPENSSL_ROOT_DIR=/libs/openssl \ - -DOPENSSL_CRYPTO_LIBRARY=/libs/openssl/lib64 \ - -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-x86_64.cmake .. && \ + cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-x86_64.cmake .. && \ make && \ - make package" \ No newline at end of file + make package" diff --git a/story-editor/create_docker_image_win.sh b/story-editor/create_docker_image_win.sh new file mode 100755 index 0000000..04efd06 --- /dev/null +++ b/story-editor/create_docker_image_win.sh @@ -0,0 +1 @@ +docker build -t cpp-dev . --load diff --git a/story-editor/imgui.ini b/story-editor/imgui.ini index 705ae2c..fb65035 100644 --- a/story-editor/imgui.ini +++ b/story-editor/imgui.ini @@ -9,20 +9,20 @@ Size=32,42 Collapsed=0 [Window][Library Manager] -Pos=593,26 -Size=687,395 +Pos=552,26 +Size=728,827 Collapsed=0 DockId=0x00000003,3 [Window][Console] -Pos=60,423 -Size=1220,297 +Pos=60,855 +Size=1220,289 Collapsed=0 DockId=0x00000006,0 [Window][Emulator] -Pos=593,26 -Size=687,395 +Pos=552,26 +Size=728,827 Collapsed=0 DockId=0x00000003,2 @@ -33,35 +33,35 @@ Collapsed=0 DockId=0x00000004,0 [Window][Resources] -Pos=593,26 -Size=687,395 +Pos=552,26 +Size=728,827 Collapsed=0 DockId=0x00000003,0 [Window][Properties] -Pos=593,26 -Size=687,395 +Pos=552,26 +Size=728,827 Collapsed=0 DockId=0x00000003,1 [Window][Node editor] Pos=60,26 -Size=531,395 +Size=490,827 Collapsed=0 DockId=0x00000002,0 [Window][QuitConfirm] -Pos=479,312 +Pos=479,524 Size=321,96 Collapsed=0 [Window][ToolBar] Pos=0,26 -Size=60,694 +Size=60,1118 Collapsed=0 [Window][ProjectPropertiesPopup] -Pos=381,290 +Pos=381,236 Size=518,248 Collapsed=0 @@ -86,14 +86,14 @@ Size=951,564 Collapsed=0 [Window][CPU] -Pos=593,26 -Size=687,395 +Pos=552,26 +Size=728,827 Collapsed=0 DockId=0x00000003,4 [Window][Choose File##ChooseFileDlgKey] -Pos=121,114 -Size=1021,495 +Pos=122,114 +Size=1020,496 Collapsed=0 [Window][TOOLBAR] @@ -103,20 +103,25 @@ Collapsed=0 [Window][WindowOverViewport_11111111] Pos=60,26 -Size=1220,694 +Size=1220,1118 Collapsed=0 [Window][Code viewer] -Pos=593,26 -Size=687,395 +Pos=552,26 +Size=728,827 Collapsed=0 DockId=0x00000003,5 [Window][Import story##ImportStoryDlgKey] -Pos=246,21 +Pos=256,33 Size=916,532 Collapsed=0 +[Window][Choose a library directory##ChooseLibraryDirDialog] +Pos=216,85 +Size=874,542 +Collapsed=0 + [Table][0x54B1A511,5] RefScale=20 Column 0 Width=197 Sort=0v @@ -181,16 +186,16 @@ Column 3 Width=93 [Table][0x30BF8F98,3] RefScale=20 -Column 0 Width=267 Sort=0v +Column 0 Width=288 Sort=0v Column 1 Width=88 Column 2 Width=124 [Table][0x7728942D,5] RefScale=20 -Column 0 Width=313 Sort=0v -Column 1 Width=72 +Column 0 Width=207 Sort=0v +Column 1 Width=119 Column 2 Width=104 -Column 3 Width=54 +Column 3 Width=108 Column 4 Width=75 [Table][0x69D69F59,2] @@ -217,12 +222,52 @@ Column 0 Sort=0v RefScale=20 Column 0 Sort=0v -[Docking][Data] -DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=60,26 Size=1220,694 Split=Y - DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=1220,504 Split=X - DockNode ID=0x00000002 Parent=0x00000005 SizeRef=531,694 CentralNode=1 Selected=0xBB79A587 - DockNode ID=0x00000001 Parent=0x00000005 SizeRef=687,694 Split=Y Selected=0x63869CAF - DockNode ID=0x00000003 Parent=0x00000001 SizeRef=543,294 Selected=0x4B07C626 - DockNode ID=0x00000004 Parent=0x00000001 SizeRef=543,372 Selected=0x7563A968 - DockNode ID=0x00000006 Parent=0x08BD597D SizeRef=1220,297 Selected=0xEA83D666 +[Table][0x3B23FE46,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0xCEFF833F,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0x85A5C630,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0x13114C2E,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0x377DE807,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0x7C27AD08,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0xC21645DB,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0x894C00D4,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0x4EF24F50,4] +RefScale=20 +Column 0 Sort=0v + +[Table][0x4BB501EB,4] +RefScale=20 +Column 0 Sort=0v + +[Docking][Data] +DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=60,26 Size=1220,1118 Split=Y + DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=1220,403 Split=X + DockNode ID=0x00000002 Parent=0x00000005 SizeRef=490,694 CentralNode=1 Selected=0xBB79A587 + DockNode ID=0x00000001 Parent=0x00000005 SizeRef=728,694 Split=Y Selected=0x63869CAF + DockNode ID=0x00000003 Parent=0x00000001 SizeRef=543,294 Selected=0x52EB28B5 + DockNode ID=0x00000004 Parent=0x00000001 SizeRef=543,372 Selected=0x7563A968 + DockNode ID=0x00000006 Parent=0x08BD597D SizeRef=1220,289 Selected=0xEA83D666 diff --git a/story-editor/src/gui.cpp b/story-editor/src/gui.cpp index 7f79ca8..bbe3220 100644 --- a/story-editor/src/gui.cpp +++ b/story-editor/src/gui.cpp @@ -124,6 +124,7 @@ void Decompress(uint8_t *bmpImage, uint32_t fileSize, SDL_Texture *texture) uint32_t paletteSize = header.offset - (HEADER_SIZE + INFO_HEADER_SIZE); +#ifdef DEBUG_BITMAP printf("File size (from header):%d\r\n", (uint32_t)header.size); printf("File size (from data):%d\r\n", (uint32_t)fileSize); printf("Data offset:%d\r\n", (uint32_t)header.offset); @@ -140,7 +141,7 @@ void Decompress(uint8_t *bmpImage, uint32_t fileSize, SDL_Texture *texture) printf("Important colors:%d\r\n", (uint32_t)info_header.importantcolours); printf("RGB :%d\r\n", (uint32_t)info_header.rgb); printf("RGB2 :%d\r\n", (uint32_t)info_header.rgb2); - +#endif uint8_t *palette = &bmpImage[HEADER_SIZE + INFO_HEADER_SIZE]; // 16 * 4 bytes = 64 // buffer de sortie, bitmap décompressé @@ -189,7 +190,7 @@ void Decompress(uint8_t *bmpImage, uint32_t fileSize, SDL_Texture *texture) } else if (second == 1) { - std::cout << "End of bitmap" << std::endl; + // std::cout << "End of bitmap" << std::endl; goto end; } else if (second == 2) diff --git a/story-editor/src/importers/pack_archive.h b/story-editor/src/importers/pack_archive.h index fd43ebb..ad3d19f 100644 --- a/story-editor/src/importers/pack_archive.h +++ b/story-editor/src/importers/pack_archive.h @@ -52,7 +52,7 @@ public: { // Ici on a choisi le fichier ni, donc on prend juste le répertoire parent importBaseDir = SysLib::GetDirectory(packFileName); - std::string packDirNameOnly = SysLib::GetFileName(importBaseDir); + std::string packDirNameOnly = importBaseDir.filename().string(); // Ici on va copier le répertoire dans un dossier de travail pour éviter de corrompre le // répertoire d'origine (vu qu'on decipher tout) @@ -61,7 +61,7 @@ public: | std::filesystem::copy_options::overwrite_existing ; - std::string workingDir = std::filesystem::path(outputBaseDir) / packDirNameOnly; + std::filesystem::path workingDir = std::filesystem::path(outputBaseDir) / packDirNameOnly; std::filesystem::create_directories(workingDir); std::filesystem::copy(importBaseDir, workingDir, copyOptions); diff --git a/story-editor/src/main_window.cpp b/story-editor/src/main_window.cpp index e28b951..aeb0e4a 100644 --- a/story-editor/src/main_window.cpp +++ b/story-editor/src/main_window.cpp @@ -104,7 +104,7 @@ void MainWindow::Ok() void MainWindow::Stop() { - m_eventQueue.push({VmEventType::EvOkButton}); + m_dbg.run_result = VM_FINISHED; // better than sending an event: avoid infinite loops in assembly } void MainWindow::Pause() @@ -177,6 +177,9 @@ void MainWindow::ProcessStory() if (m_dbg.run_result == VM_READY) return; + if (m_dbg.run_result > VM_OK) + return; + // 1. First, check events if (m_dbg.run_result == VM_WAIT_EVENT) { @@ -186,7 +189,7 @@ void MainWindow::ProcessStory() if (event.type == VmEventType::EvStep) { StepInstruction(); - m_dbg.run_result = VM_OK; + m_dbg.run_result = VM_OK; // FIXME: bizarre d'écraser le code de retour... } else if (event.type == VmEventType::EvRun) { @@ -259,6 +262,10 @@ void MainWindow::ProcessStory() { m_dbg.free_run = false; } + else if (m_dbg.run_result > VM_OK) + { + Log("VM critical error", true); + } // In this case, we wait for single step debugger if ((m_dbg.run_result == VM_OK) && !m_dbg.free_run) diff --git a/story-editor/src/platform_folders.cpp b/story-editor/src/platform_folders.cpp index c9a49a4..1698a55 100644 --- a/story-editor/src/platform_folders.cpp +++ b/story-editor/src/platform_folders.cpp @@ -84,6 +84,9 @@ static std::string getHome() #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif + +#define NTDDI_VERSION 0x06000000 + // stringapiset.h depends on this #include // For SUCCEEDED macro @@ -91,7 +94,7 @@ static std::string getHome() // For WideCharToMultiByte #include -#define _WIN32_WINNT 0x0600 +// #define _WIN32_WINNT 0x0600 // For SHGetFolderPathW and various CSIDL "magic numbers" #include