(WIP) Commercial import
Some checks failed
build-story-editor / build_linux (push) Has been cancelled
build-story-editor / build_win32 (push) Has been cancelled
Deploy / deploy (push) Has been cancelled

This commit is contained in:
anthony@rabine.fr 2024-12-30 15:50:14 +01:00
parent 6305b06d53
commit 3d9b60cb32
5 changed files with 55 additions and 41 deletions

View file

@ -72,7 +72,7 @@ void CodeEditor::TextViewDraw()
CodeEditor::CodeEditor(IStoryManager &project)
: WindowBase("Code editor")
: WindowBase("Code viewer")
, m_storyManager(project)
{
// mEditor.SetReadOnly(false);
@ -109,19 +109,19 @@ void CodeEditor::SetScript(const std::string &txt)
{
m_text = txt;
m_text = R"(
fdsfds
fds
ffffffffffffffffffffff
ff
fd
feeeee
21234f
e
fdsfs
)";
// m_text = R"(
// fdsfds
// fds
// ffffffffffffffffffffff
// ff
// fd
// feeeee
// 21234f
// e
// fdsfs
// )";
HighlightLine(2);
// HighlightLine(2);
}
std::string CodeEditor::GetScript() const
@ -139,6 +139,7 @@ void CodeEditor::Draw()
// auto cpos = mEditor.GetCursorPosition();
ImGui::SetWindowSize(ImVec2(800, 600), ImGuiCond_FirstUseEver);
/*
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("File"))
@ -156,7 +157,7 @@ void CodeEditor::Draw()
// if (ImGui::MenuItem("Read-only mode", nullptr, &ro))
// mEditor.SetReadOnly(ro);
ImGui::Separator();
/*
if (ImGui::MenuItem("Undo", "ALT-Backspace", nullptr, !ro && mEditor.CanUndo()))
mEditor.Undo();
if (ImGui::MenuItem("Redo", "Ctrl-Y", nullptr, !ro && mEditor.CanRedo()))
@ -172,7 +173,7 @@ void CodeEditor::Draw()
mEditor.Delete();
if (ImGui::MenuItem("Paste", "Ctrl-V", nullptr, !ro && ImGui::GetClipboardText() != nullptr))
mEditor.Paste();
*/
ImGui::Separator();
@ -181,7 +182,7 @@ void CodeEditor::Draw()
ImGui::EndMenu();
}
/*
if (ImGui::BeginMenu("View"))
{
if (ImGui::MenuItem("Dark palette"))
@ -192,9 +193,10 @@ void CodeEditor::Draw()
mEditor.SetPalette(TextEditor::GetRetroBluePalette());
ImGui::EndMenu();
}
*/
ImGui::EndMenuBar();
}
*/
// ImGui::Text("%6d/%-6d %6d lines | %s | %s ", cpos.mLine + 1, cpos.mColumn + 1, mEditor.GetTotalLines(),
// mEditor.IsOverwrite() ? "Ovr" : "Ins",

View file

@ -156,25 +156,32 @@ std::vector<std::string> PackArchive::FilesToJson(const std::string &type, const
return resList;
}
void PackArchive::DecipherAll(const std::string &packFileName, const std::string &parent_dest_dir)
void PackArchive::ImportCommercialFormat(const std::string &packFileName, const std::string &outputDir)
{
// return;
auto uuid = Uuid().String();
std::string basePath = outputDir + "/" + uuid;
Unzip(packFileName, parent_dest_dir);
Load(packFileName);
Unzip(packFileName, basePath);
LoadNiFile(packFileName);
std::string path = mPackName + "/rf";
std::string path = basePath + "/" + mPackName + "/rf";
for (const auto & entry : std::filesystem::directory_iterator(path))
{
std::cout << entry.path() << std::endl;
DecipherFiles(entry.path().generic_string(), ".bmp");
if (entry.is_directory())
{
std::cout << entry.path() << std::endl;
DecipherFiles(entry.path().generic_string(), ".bmp");
}
}
path = mPackName + "/sf";
path = basePath + "/" + mPackName + "/sf";
for (const auto & entry : std::filesystem::directory_iterator(path))
{
std::cout << entry.path() << std::endl;
DecipherFiles(entry.path().generic_string(), ".mp3");
if (entry.is_directory())
{
std::cout << entry.path() << std::endl;
DecipherFiles(entry.path().generic_string(), ".mp3");
}
}
nlohmann::json j;
@ -333,7 +340,7 @@ $MyArray DV8 10 ; array of 10 bytes
chip32.close();
}
bool PackArchive::Load(const std::string &filePath)
bool PackArchive::LoadNiFile(const std::string &filePath)
{
bool success = false;
mZip.Close();

View file

@ -13,10 +13,11 @@ class PackArchive
public:
PackArchive(ILogger &log);
bool Load(const std::string &filePath);
bool LoadNiFile(const std::string &filePath);
std::string OpenImage(const std::string &fileName);
bool ImportStudioFormat(const std::string &fileName, const std::string &outputDir);
void ImportCommercialFormat(const std::string &packFileName, const std::string &outputDir);
std::string CurrentImage();
std::string CurrentSound();
@ -31,7 +32,7 @@ public:
void Next();
void Previous();
void Unzip(const std::string &filePath, const std::string &parent_dest_dir);
void DecipherAll(const std::string &packFileName, const std::string &parent_dest_dir);
bool ConvertJsonStudioToOst(const std::string &basePath, const std::string &uuid, const std::string &outputDir);
std::string HexDump(const char *desc, const void *addr, int len);

View file

@ -348,8 +348,9 @@ inline void InfosPane(const char *vFilter, IGFDUserDatas vUserDatas, bool *vCant
ImGui::Text("Select file format: ");
ImGui::RadioButton("Commercial stories", &formatFilter, 0); ImGui::SameLine();
ImGui::RadioButton("Studio format", &formatFilter, 1); ImGui::SameLine();
ImGui::RadioButton("Studio format", &formatFilter, 0); ImGui::SameLine();
ImGui::RadioButton("Commercial stories", &formatFilter, 1); ImGui::SameLine();
// ImGui::Checkbox("if not checked you cant validate the dialog", &canValidateDialog);
if (vCantContinue)
@ -367,8 +368,6 @@ std::string LibraryWindow::ToLocalStoreFile(const std::string &url)
void LibraryWindow::Draw()
{
static int importFormat = 0;
WindowBase::BeginDraw();
ImGui::SetWindowSize(ImVec2(626, 744), ImGuiCond_FirstUseEver);
@ -437,7 +436,7 @@ void LibraryWindow::Draw()
config.flags = ImGuiFileDialogFlags_Modal;
ImGuiFileDialog::Instance()->OpenDialog("ImportStoryDlgKey",
"Import story",
".zip, .json",
".zip, .json, .pk",
config
);
}
@ -609,10 +608,8 @@ void LibraryWindow::Draw()
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
std::string filter = ImGuiFileDialog::Instance()->GetCurrentFilter();
m_storyManager.ImportProject(filePathName, importFormat);
// action
// Import "Studio" or "Commercial" format
m_storyManager.ImportProject(filePathName, formatFilter);
}
// close
ImGuiFileDialog::Instance()->Close();

View file

@ -797,7 +797,14 @@ void MainWindow::ImportProject(const std::string &fileName, int format)
{
PackArchive archive(*this);
archive.ImportStudioFormat(fileName, m_libraryManager.LibraryPath());
if (format == 0)
{
archive.ImportStudioFormat(fileName, m_libraryManager.LibraryPath());
}
else
{
archive.ImportCommercialFormat(fileName, m_libraryManager.LibraryPath());
}
}
@ -831,7 +838,7 @@ void MainWindow::CloseProject()
m_nodeEditorWindow.Disable();
m_emulatorWindow.Disable();
// m_codeEditorWindow.Disable();
m_codeEditorWindow.Disable();
m_resourcesWindow.Disable();
m_PropertiesWindow.Disable();
m_cpuWindow.Disable();