mirror of
https://github.com/arabine/open-story-teller.git
synced 2025-12-07 01:15:14 +01:00
(WIP) Commercial import
This commit is contained in:
parent
6305b06d53
commit
3d9b60cb32
5 changed files with 55 additions and 41 deletions
|
|
@ -72,7 +72,7 @@ void CodeEditor::TextViewDraw()
|
||||||
|
|
||||||
|
|
||||||
CodeEditor::CodeEditor(IStoryManager &project)
|
CodeEditor::CodeEditor(IStoryManager &project)
|
||||||
: WindowBase("Code editor")
|
: WindowBase("Code viewer")
|
||||||
, m_storyManager(project)
|
, m_storyManager(project)
|
||||||
{
|
{
|
||||||
// mEditor.SetReadOnly(false);
|
// mEditor.SetReadOnly(false);
|
||||||
|
|
@ -109,19 +109,19 @@ void CodeEditor::SetScript(const std::string &txt)
|
||||||
{
|
{
|
||||||
m_text = txt;
|
m_text = txt;
|
||||||
|
|
||||||
m_text = R"(
|
// m_text = R"(
|
||||||
fdsfds
|
// fdsfds
|
||||||
fds
|
// fds
|
||||||
ffffffffffffffffffffff
|
// ffffffffffffffffffffff
|
||||||
ff
|
// ff
|
||||||
fd
|
// fd
|
||||||
feeeee
|
// feeeee
|
||||||
21234f
|
// 21234f
|
||||||
e
|
// e
|
||||||
fdsfs
|
// fdsfs
|
||||||
)";
|
// )";
|
||||||
|
|
||||||
HighlightLine(2);
|
// HighlightLine(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CodeEditor::GetScript() const
|
std::string CodeEditor::GetScript() const
|
||||||
|
|
@ -139,6 +139,7 @@ void CodeEditor::Draw()
|
||||||
// auto cpos = mEditor.GetCursorPosition();
|
// auto cpos = mEditor.GetCursorPosition();
|
||||||
|
|
||||||
ImGui::SetWindowSize(ImVec2(800, 600), ImGuiCond_FirstUseEver);
|
ImGui::SetWindowSize(ImVec2(800, 600), ImGuiCond_FirstUseEver);
|
||||||
|
/*
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenu("File"))
|
if (ImGui::BeginMenu("File"))
|
||||||
|
|
@ -156,7 +157,7 @@ void CodeEditor::Draw()
|
||||||
// if (ImGui::MenuItem("Read-only mode", nullptr, &ro))
|
// if (ImGui::MenuItem("Read-only mode", nullptr, &ro))
|
||||||
// mEditor.SetReadOnly(ro);
|
// mEditor.SetReadOnly(ro);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
/*
|
|
||||||
if (ImGui::MenuItem("Undo", "ALT-Backspace", nullptr, !ro && mEditor.CanUndo()))
|
if (ImGui::MenuItem("Undo", "ALT-Backspace", nullptr, !ro && mEditor.CanUndo()))
|
||||||
mEditor.Undo();
|
mEditor.Undo();
|
||||||
if (ImGui::MenuItem("Redo", "Ctrl-Y", nullptr, !ro && mEditor.CanRedo()))
|
if (ImGui::MenuItem("Redo", "Ctrl-Y", nullptr, !ro && mEditor.CanRedo()))
|
||||||
|
|
@ -172,7 +173,7 @@ void CodeEditor::Draw()
|
||||||
mEditor.Delete();
|
mEditor.Delete();
|
||||||
if (ImGui::MenuItem("Paste", "Ctrl-V", nullptr, !ro && ImGui::GetClipboardText() != nullptr))
|
if (ImGui::MenuItem("Paste", "Ctrl-V", nullptr, !ro && ImGui::GetClipboardText() != nullptr))
|
||||||
mEditor.Paste();
|
mEditor.Paste();
|
||||||
*/
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
|
@ -181,7 +182,7 @@ void CodeEditor::Draw()
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (ImGui::BeginMenu("View"))
|
if (ImGui::BeginMenu("View"))
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem("Dark palette"))
|
if (ImGui::MenuItem("Dark palette"))
|
||||||
|
|
@ -192,9 +193,10 @@ void CodeEditor::Draw()
|
||||||
mEditor.SetPalette(TextEditor::GetRetroBluePalette());
|
mEditor.SetPalette(TextEditor::GetRetroBluePalette());
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// ImGui::Text("%6d/%-6d %6d lines | %s | %s ", cpos.mLine + 1, cpos.mColumn + 1, mEditor.GetTotalLines(),
|
// ImGui::Text("%6d/%-6d %6d lines | %s | %s ", cpos.mLine + 1, cpos.mColumn + 1, mEditor.GetTotalLines(),
|
||||||
// mEditor.IsOverwrite() ? "Ovr" : "Ins",
|
// mEditor.IsOverwrite() ? "Ovr" : "Ins",
|
||||||
|
|
|
||||||
|
|
@ -156,25 +156,32 @@ std::vector<std::string> PackArchive::FilesToJson(const std::string &type, const
|
||||||
return resList;
|
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);
|
Unzip(packFileName, basePath);
|
||||||
Load(packFileName);
|
LoadNiFile(packFileName);
|
||||||
|
|
||||||
std::string path = mPackName + "/rf";
|
std::string path = basePath + "/" + mPackName + "/rf";
|
||||||
for (const auto & entry : std::filesystem::directory_iterator(path))
|
for (const auto & entry : std::filesystem::directory_iterator(path))
|
||||||
{
|
{
|
||||||
std::cout << entry.path() << std::endl;
|
if (entry.is_directory())
|
||||||
DecipherFiles(entry.path().generic_string(), ".bmp");
|
{
|
||||||
|
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))
|
for (const auto & entry : std::filesystem::directory_iterator(path))
|
||||||
{
|
{
|
||||||
std::cout << entry.path() << std::endl;
|
if (entry.is_directory())
|
||||||
DecipherFiles(entry.path().generic_string(), ".mp3");
|
{
|
||||||
|
std::cout << entry.path() << std::endl;
|
||||||
|
DecipherFiles(entry.path().generic_string(), ".mp3");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
|
|
@ -333,7 +340,7 @@ $MyArray DV8 10 ; array of 10 bytes
|
||||||
chip32.close();
|
chip32.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackArchive::Load(const std::string &filePath)
|
bool PackArchive::LoadNiFile(const std::string &filePath)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
mZip.Close();
|
mZip.Close();
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,11 @@ class PackArchive
|
||||||
public:
|
public:
|
||||||
PackArchive(ILogger &log);
|
PackArchive(ILogger &log);
|
||||||
|
|
||||||
bool Load(const std::string &filePath);
|
bool LoadNiFile(const std::string &filePath);
|
||||||
std::string OpenImage(const std::string &fileName);
|
std::string OpenImage(const std::string &fileName);
|
||||||
|
|
||||||
bool ImportStudioFormat(const std::string &fileName, const std::string &outputDir);
|
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 CurrentImage();
|
||||||
std::string CurrentSound();
|
std::string CurrentSound();
|
||||||
|
|
@ -31,7 +32,7 @@ public:
|
||||||
void Next();
|
void Next();
|
||||||
void Previous();
|
void Previous();
|
||||||
void Unzip(const std::string &filePath, const std::string &parent_dest_dir);
|
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);
|
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);
|
std::string HexDump(const char *desc, const void *addr, int len);
|
||||||
|
|
|
||||||
|
|
@ -348,8 +348,9 @@ inline void InfosPane(const char *vFilter, IGFDUserDatas vUserDatas, bool *vCant
|
||||||
|
|
||||||
|
|
||||||
ImGui::Text("Select file format: ");
|
ImGui::Text("Select file format: ");
|
||||||
ImGui::RadioButton("Commercial stories", &formatFilter, 0); ImGui::SameLine();
|
ImGui::RadioButton("Studio format", &formatFilter, 0); ImGui::SameLine();
|
||||||
ImGui::RadioButton("Studio format", &formatFilter, 1); ImGui::SameLine();
|
ImGui::RadioButton("Commercial stories", &formatFilter, 1); ImGui::SameLine();
|
||||||
|
|
||||||
|
|
||||||
// ImGui::Checkbox("if not checked you cant validate the dialog", &canValidateDialog);
|
// ImGui::Checkbox("if not checked you cant validate the dialog", &canValidateDialog);
|
||||||
if (vCantContinue)
|
if (vCantContinue)
|
||||||
|
|
@ -367,8 +368,6 @@ std::string LibraryWindow::ToLocalStoreFile(const std::string &url)
|
||||||
|
|
||||||
void LibraryWindow::Draw()
|
void LibraryWindow::Draw()
|
||||||
{
|
{
|
||||||
static int importFormat = 0;
|
|
||||||
|
|
||||||
WindowBase::BeginDraw();
|
WindowBase::BeginDraw();
|
||||||
ImGui::SetWindowSize(ImVec2(626, 744), ImGuiCond_FirstUseEver);
|
ImGui::SetWindowSize(ImVec2(626, 744), ImGuiCond_FirstUseEver);
|
||||||
|
|
||||||
|
|
@ -437,7 +436,7 @@ void LibraryWindow::Draw()
|
||||||
config.flags = ImGuiFileDialogFlags_Modal;
|
config.flags = ImGuiFileDialogFlags_Modal;
|
||||||
ImGuiFileDialog::Instance()->OpenDialog("ImportStoryDlgKey",
|
ImGuiFileDialog::Instance()->OpenDialog("ImportStoryDlgKey",
|
||||||
"Import story",
|
"Import story",
|
||||||
".zip, .json",
|
".zip, .json, .pk",
|
||||||
config
|
config
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -609,10 +608,8 @@ void LibraryWindow::Draw()
|
||||||
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
|
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||||
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
|
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
|
||||||
std::string filter = ImGuiFileDialog::Instance()->GetCurrentFilter();
|
std::string filter = ImGuiFileDialog::Instance()->GetCurrentFilter();
|
||||||
|
// Import "Studio" or "Commercial" format
|
||||||
m_storyManager.ImportProject(filePathName, importFormat);
|
m_storyManager.ImportProject(filePathName, formatFilter);
|
||||||
|
|
||||||
// action
|
|
||||||
}
|
}
|
||||||
// close
|
// close
|
||||||
ImGuiFileDialog::Instance()->Close();
|
ImGuiFileDialog::Instance()->Close();
|
||||||
|
|
|
||||||
|
|
@ -797,7 +797,14 @@ void MainWindow::ImportProject(const std::string &fileName, int format)
|
||||||
{
|
{
|
||||||
PackArchive archive(*this);
|
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_nodeEditorWindow.Disable();
|
||||||
m_emulatorWindow.Disable();
|
m_emulatorWindow.Disable();
|
||||||
// m_codeEditorWindow.Disable();
|
m_codeEditorWindow.Disable();
|
||||||
m_resourcesWindow.Disable();
|
m_resourcesWindow.Disable();
|
||||||
m_PropertiesWindow.Disable();
|
m_PropertiesWindow.Disable();
|
||||||
m_cpuWindow.Disable();
|
m_cpuWindow.Disable();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue