Wywołanie_i/o #8
7 changed files with 100 additions and 74 deletions
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of VoidArchiveTool.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2025 Yanczi
|
|
||||||
*
|
|
||||||
* Void Archive Toolis free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Interface.h"
|
|
||||||
|
|
||||||
Interface::Interface() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Interface::~Interface() {
|
|
||||||
// TODO Auto-generated destructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
void Interface::TextBorder(const std::string& title, const std::string& text)
|
|
||||||
{
|
|
||||||
auto element = ftxui::window(ftxui::text(title), ftxui::paragraphAlignLeft(text));
|
|
||||||
auto screen = ftxui::Screen::Create(ftxui::Dimension::Fit(element));
|
|
||||||
ftxui::Render(screen, element);
|
|
||||||
screen.Print();
|
|
||||||
}
|
|
||||||
71
Tui.cpp
Normal file
71
Tui.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* This file is part of VoidArchiveTool.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 Yanczi
|
||||||
|
*
|
||||||
|
* Void Archive Toolis free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Tui.h"
|
||||||
|
|
||||||
|
Tui::Tui() {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Tui::~Tui() {
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tui::TextBorder(const std::string& title, const std::string& text)
|
||||||
|
{
|
||||||
|
auto element = ftxui::window(ftxui::text(title), ftxui::paragraphAlignLeft(text));
|
||||||
|
auto screen = ftxui::Screen::Create(ftxui::Dimension::Fit(element));
|
||||||
|
ftxui::Render(screen, element);
|
||||||
|
screen.Print();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tui::table(const std::vector<std::vector<std::string>>& data)
|
||||||
|
{
|
||||||
|
ftxui::Table table(data);
|
||||||
|
|
||||||
|
// Styl ogólny tabeli (ramki)
|
||||||
|
table.SelectAll().Border(ftxui::LIGHT);
|
||||||
|
|
||||||
|
// Oddzielenie nag³ówka od danych podwójn¹ lini¹
|
||||||
|
table.SelectRow(0).Border(ftxui::LIGHT);
|
||||||
|
table.SelectRow(0).Decorate(ftxui::bold); // Pogrubienie nag³ówka
|
||||||
|
table.SelectRow(0).SeparatorVertical(ftxui::LIGHT);
|
||||||
|
table.SelectRow(0).Border(ftxui::LIGHT);
|
||||||
|
|
||||||
|
table.SelectColumn(0).DecorateCells(ftxui::center);
|
||||||
|
table.SelectColumn(1).DecorateCells(ftxui::center);
|
||||||
|
|
||||||
|
table.SelectColumn(2).DecorateCells([](ftxui::Element e) {
|
||||||
|
return e | ftxui::flex;
|
||||||
|
});
|
||||||
|
|
||||||
|
table.SelectColumn(3).DecorateCells(ftxui::center);
|
||||||
|
|
||||||
|
table.SelectColumn(0).BorderRight(ftxui::LIGHT);
|
||||||
|
table.SelectColumn(1).BorderRight(ftxui::LIGHT);
|
||||||
|
table.SelectColumn(2).BorderRight(ftxui::LIGHT);
|
||||||
|
|
||||||
|
auto document = table.Render();
|
||||||
|
|
||||||
|
auto screen = ftxui::Screen::Create(ftxui::Dimension::Full(), ftxui::Dimension::Fit(document));
|
||||||
|
|
||||||
|
ftxui::Render(screen, document);
|
||||||
|
screen.Print();
|
||||||
|
}
|
||||||
|
|
@ -20,14 +20,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ftxui/dom/elements.hpp>
|
#include <ftxui/dom/elements.hpp>
|
||||||
|
#include <ftxui/dom/table.hpp>
|
||||||
#include <ftxui/screen/screen.hpp>
|
#include <ftxui/screen/screen.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Interface {
|
class Tui {
|
||||||
public:
|
public:
|
||||||
Interface();
|
Tui();
|
||||||
virtual ~Interface();
|
virtual ~Tui();
|
||||||
|
|
||||||
void TextBorder(const std::string&, const std::string&);
|
void TextBorder(const std::string&, const std::string&);
|
||||||
|
void table(const std::vector<std::vector<std::string>>&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -25,8 +25,8 @@ ViewCargo::ViewCargo()
|
||||||
, filesLen(0)
|
, filesLen(0)
|
||||||
, tablePos(0)
|
, tablePos(0)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated constructor stub
|
std::vector<std::string> header = {"Comress", "Encrypt", "Path", "RefHASH"};
|
||||||
|
list.push_back(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -55,17 +55,6 @@ bool ViewCargo::View(const std::string& path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Table Header
|
|
||||||
std::vector<ftxui::Element> headElements;
|
|
||||||
|
|
||||||
headElements.push_back(ftxui::text(" Compressed ") | ftxui::bold);
|
|
||||||
headElements.push_back(ftxui::text(" Encrypted ") | ftxui::bold);
|
|
||||||
headElements.push_back(ftxui::text("Nazwa pliku") | ftxui::bold | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 56));
|
|
||||||
headElements.push_back(ftxui::text("Hash Name") | ftxui::bold | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 20));
|
|
||||||
|
|
||||||
filesList.push_back(hbox(std::move(headElements)));
|
|
||||||
|
|
||||||
|
|
||||||
//Pobieranie listy plików
|
//Pobieranie listy plików
|
||||||
GetFileList(path);
|
GetFileList(path);
|
||||||
|
|
||||||
|
|
@ -151,6 +140,7 @@ void ViewCargo::GetFileList(const std::string& path)
|
||||||
}
|
}
|
||||||
|
|
||||||
cargo.close();
|
cargo.close();
|
||||||
|
tui.table(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -162,6 +152,9 @@ void ViewCargo::CreateTableRow(const std::string& file, const uint8_t& zip, cons
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "0x" << std::hex << std::uppercase << hash;
|
ss << "0x" << std::hex << std::uppercase << hash;
|
||||||
|
|
||||||
|
//Lista
|
||||||
|
std::vector<std::string> tmpList = { "[ ]", "[ ]", file, ss.str() };
|
||||||
|
|
||||||
std::vector<ftxui::Element> cell;
|
std::vector<ftxui::Element> cell;
|
||||||
|
|
||||||
ftxui::Element eZip;
|
ftxui::Element eZip;
|
||||||
|
|
@ -171,34 +164,28 @@ void ViewCargo::CreateTableRow(const std::string& file, const uint8_t& zip, cons
|
||||||
switch (zip)
|
switch (zip)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
eZip = ftxui::text(" [x] ") | ftxui::color(ftxui::Color::Cyan);
|
//eZip = ftxui::text(" [x] ") | ftxui::color(ftxui::Color::Cyan);
|
||||||
eEnc = ftxui::text(" [ ] ") | ftxui::color(ftxui::Color::White);
|
//eEnc = ftxui::text(" [ ] ") | ftxui::color(ftxui::Color::White);
|
||||||
|
tmpList[0] = "[x]";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
eZip = ftxui::text(" [ ] ") | ftxui::color(ftxui::Color::White);
|
tmpList[1] = "[x]";
|
||||||
eEnc = ftxui::text(" [x] ") | ftxui::color(ftxui::Color::Cyan);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
eZip = ftxui::text(" [x] ") | ftxui::color(ftxui::Color::Cyan);
|
tmpList[0] = "[x]";
|
||||||
eEnc = ftxui::text(" [x] ") | ftxui::color(ftxui::Color::Cyan);
|
tmpList[1] = "[x]";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
eZip = ftxui::text(" [ ] ") | ftxui::color(ftxui::Color::White);
|
tmpList[0] = "[ ]";
|
||||||
eEnc = ftxui::text(" [ ] ") | ftxui::color(ftxui::Color::White);
|
tmpList[1] = "[ ]";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dodawanie komurek
|
//Dodanie wiersza do listy
|
||||||
cell.push_back(eZip);
|
list.push_back(tmpList);
|
||||||
cell.push_back(eEnc | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 7));
|
|
||||||
cell.push_back(ftxui::text(file) | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 56));
|
|
||||||
cell.push_back(ftxui::text(ss.str()) | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 20));
|
|
||||||
|
|
||||||
//Konwersja komurek na wiersz
|
|
||||||
filesList.push_back(ftxui::hbox(std::move(cell)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <ftxui/dom/elements.hpp>
|
#include <ftxui/dom/elements.hpp>
|
||||||
#include <ftxui/screen/screen.hpp>
|
#include <ftxui/screen/screen.hpp>
|
||||||
|
#include <ftxui/dom/table.hpp>
|
||||||
|
|
||||||
#include "DataStruct.h"
|
#include "DataStruct.h"
|
||||||
|
#include "Tui.h"
|
||||||
|
|
||||||
class ViewCargo {
|
class ViewCargo {
|
||||||
public:
|
public:
|
||||||
|
|
@ -38,12 +40,14 @@ public:
|
||||||
bool View(const std::string&);
|
bool View(const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Tui tui;
|
||||||
const std::string signature;
|
const std::string signature;
|
||||||
const uint16_t version;
|
const uint16_t version;
|
||||||
|
|
||||||
uint32_t filesLen;
|
uint32_t filesLen;
|
||||||
uint64_t tablePos;
|
uint64_t tablePos;
|
||||||
std::vector<ftxui::Element> filesList;
|
std::vector<ftxui::Element> filesList;
|
||||||
|
std::vector<std::vector<std::string>> list;
|
||||||
|
|
||||||
bool CheckCargoFile(const std::string&);
|
bool CheckCargoFile(const std::string&);
|
||||||
void GetFileList(const std::string&);
|
void GetFileList(const std::string&);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
#include "CreateCargo.h"
|
#include "CreateCargo.h"
|
||||||
#include "ExtractCargo.h"
|
#include "ExtractCargo.h"
|
||||||
#include "ViewCargo.h"
|
#include "ViewCargo.h"
|
||||||
#include "Interface.h"
|
#include "Tui.h"
|
||||||
|
|
||||||
void RenderHelp()
|
void RenderHelp()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@
|
||||||
<ClCompile Include="CreateCargo.cpp" />
|
<ClCompile Include="CreateCargo.cpp" />
|
||||||
<ClCompile Include="EncryptionManager.cpp" />
|
<ClCompile Include="EncryptionManager.cpp" />
|
||||||
<ClCompile Include="ExtractCargo.cpp" />
|
<ClCompile Include="ExtractCargo.cpp" />
|
||||||
<ClCompile Include="Interface.cpp" />
|
<ClCompile Include="Tui.cpp" />
|
||||||
<ClCompile Include="ViewCargo.cpp" />
|
<ClCompile Include="ViewCargo.cpp" />
|
||||||
<ClCompile Include="voidcmd.cpp" />
|
<ClCompile Include="voidcmd.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -148,7 +148,7 @@
|
||||||
<ClInclude Include="DataStruct.h" />
|
<ClInclude Include="DataStruct.h" />
|
||||||
<ClInclude Include="EncryptionManager.h" />
|
<ClInclude Include="EncryptionManager.h" />
|
||||||
<ClInclude Include="ExtractCargo.h" />
|
<ClInclude Include="ExtractCargo.h" />
|
||||||
<ClInclude Include="Interface.h" />
|
<ClInclude Include="Tui.h" />
|
||||||
<ClInclude Include="ViewCargo.h" />
|
<ClInclude Include="ViewCargo.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue