update viewer and client
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include "src/app/delta/delta.grpc.pb.h"
|
||||
#include "src/app/delta/delta.pb.h"
|
||||
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace delta {
|
||||
@@ -28,6 +27,7 @@ using grpc::Status;
|
||||
|
||||
class Client {
|
||||
public:
|
||||
Client() = default;
|
||||
void CreateChannel();
|
||||
absl::Status InitRepo(std::string author_name, std::string project_name);
|
||||
|
||||
|
||||
@@ -38,40 +38,122 @@ void NewMasterFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
bool BeginCentered(const char* name) {
|
||||
ImGuiIO const& io = ImGui::GetIO();
|
||||
ImVec2 pos(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGuiWindowFlags flags =
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings;
|
||||
return ImGui::Begin(name, nullptr, flags);
|
||||
}
|
||||
|
||||
void DisplayStatus(absl::Status& status) {
|
||||
if (BeginCentered("StatusWindow")) {
|
||||
ImGui::Text("%s", status.ToString().c_str());
|
||||
ImGui::Spacing();
|
||||
ImGui::NextColumn();
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
ImGui::NewLine();
|
||||
ImGui::SameLine(270);
|
||||
if (ImGui::Button("OK", ImVec2(200, 0))) {
|
||||
status = absl::OkStatus();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void Viewer::Update() {
|
||||
NewMasterFrame();
|
||||
DrawYazeMenu();
|
||||
DrawFileDialog();
|
||||
|
||||
ImGui::Text(ICON_MD_CHANGE_HISTORY);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", rom_.GetTitle());
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Button(ICON_MD_SYNC);
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_MD_ARROW_UPWARD);
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_MD_ARROW_DOWNWARD);
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_MD_MERGE);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Button(ICON_MD_MANAGE_HISTORY);
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_MD_LAN);
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_MD_COMMIT);
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_MD_DIFFERENCE);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::SetNextItemWidth(75.f);
|
||||
ImGui::Button(ICON_MD_SEND);
|
||||
ImGui::SameLine();
|
||||
ImGui::InputText("Server Address", &client_address_);
|
||||
|
||||
ImGui::SetNextItemWidth(75.f);
|
||||
ImGui::Button(ICON_MD_DOWNLOAD);
|
||||
ImGui::SameLine();
|
||||
ImGui::InputText("Repository Source", &client_address_);
|
||||
|
||||
ImGui::Separator();
|
||||
DrawBranchTree();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void Viewer::DrawFileDialog() {
|
||||
if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey")) {
|
||||
if (ImGuiFileDialog::Instance()->IsOk()) {
|
||||
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
rom_.LoadFromFile(filePathName);
|
||||
}
|
||||
ImGuiFileDialog::Instance()->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::DrawYazeMenu() {
|
||||
MENU_BAR()
|
||||
DrawFileMenu();
|
||||
DrawViewMenu();
|
||||
END_MENU_BAR()
|
||||
}
|
||||
|
||||
void Viewer::DrawFileMenu() const {
|
||||
if (ImGui::BeginMenu("File")) {
|
||||
if (ImGui::MenuItem("Open", "Ctrl+O")) {
|
||||
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Open ROM",
|
||||
".sfc,.smc", ".");
|
||||
}
|
||||
|
||||
MENU_ITEM2("Save", "Ctrl+S") {}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::DrawViewMenu() {
|
||||
static bool show_imgui_metrics = false;
|
||||
static bool show_imgui_style_editor = false;
|
||||
static bool show_memory_editor = false;
|
||||
static bool show_imgui_demo = false;
|
||||
|
||||
if (show_imgui_metrics) {
|
||||
ImGui::ShowMetricsWindow(&show_imgui_metrics);
|
||||
}
|
||||
|
||||
if (show_memory_editor) {
|
||||
static MemoryEditor mem_edit;
|
||||
mem_edit.DrawWindow("Memory Editor", (void*)&rom_, rom_.GetSize());
|
||||
}
|
||||
|
||||
if (show_imgui_demo) {
|
||||
ImGui::ShowDemoWindow();
|
||||
}
|
||||
|
||||
if (show_imgui_style_editor) {
|
||||
ImGui::Begin("Style Editor (ImGui)", &show_imgui_style_editor);
|
||||
ImGui::ShowStyleEditor();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("View")) {
|
||||
ImGui::MenuItem("HEX Editor", nullptr, &show_memory_editor);
|
||||
ImGui::MenuItem("ImGui Demo", nullptr, &show_imgui_demo);
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("GUI Tools")) {
|
||||
ImGui::MenuItem("Metrics (ImGui)", nullptr, &show_imgui_metrics);
|
||||
ImGui::MenuItem("Style Editor (ImGui)", nullptr,
|
||||
&show_imgui_style_editor);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::DrawBranchTree() {
|
||||
static ImGuiTableFlags flags =
|
||||
ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH |
|
||||
@@ -125,15 +207,16 @@ void Viewer::DrawBranchTree() {
|
||||
}
|
||||
};
|
||||
static const MyTreeNode nodes[] = {
|
||||
{"Root", "Folder", -1, 1, 3}, // 0
|
||||
{"Music", "Folder", -1, 4, 2}, // 1
|
||||
{"Textures", "Folder", -1, 6, 3}, // 2
|
||||
{"desktop.ini", "System file", 1024, -1, -1}, // 3
|
||||
{"File1_a.wav", "Audio file", 123000, -1, -1}, // 4
|
||||
{"File1_b.wav", "Audio file", 456000, -1, -1}, // 5
|
||||
{"Image001.png", "Image file", 203128, -1, -1}, // 6
|
||||
{"Copy of Image001.png", "Image file", 203256, -1, -1}, // 7
|
||||
{"Copy of Image001 (Final2).png", "Image file", 203512, -1, -1}, // 8
|
||||
{"lttp-redux", "Repository", -1, 1, 3},
|
||||
{"main", "Branch", -1, 4, 2},
|
||||
{"hyrule-castle", "Branch", -1, 4, 2},
|
||||
{"lost-woods", "Branch", -1, 6, 3},
|
||||
{"Added some bushes", "Commit", 1024, -1, -1},
|
||||
{"Constructed a new house", "Commit", 123000, -1, -1},
|
||||
{"File1_b.wav", "Commit", 456000, -1, -1},
|
||||
{"Image001.png", "Commit", 203128, -1, -1},
|
||||
{"Copy of Image001.png", "Commit", 203256, -1, -1},
|
||||
{"Copy of Image001 (Final2).png", "Commit", 203512, -1, -1},
|
||||
};
|
||||
|
||||
MyTreeNode::DisplayNode(&nodes[0], nodes);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/constants.h"
|
||||
#include "app/delta/client.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
@@ -24,7 +25,18 @@ class Viewer {
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void DrawFileDialog();
|
||||
|
||||
void DrawYazeMenu();
|
||||
void DrawFileMenu() const;
|
||||
void DrawViewMenu();
|
||||
|
||||
void DrawBranchTree();
|
||||
|
||||
std::string client_address_;
|
||||
|
||||
ROM rom_;
|
||||
Client client_;
|
||||
};
|
||||
} // namespace delta
|
||||
} // namespace app
|
||||
|
||||
Reference in New Issue
Block a user