3#include "absl/strings/str_format.h"
7#include "imgui/imgui.h"
15 ImGui::TextDisabled(
"No project loaded");
18 "Open a .yaze project file or create a new project to access "
19 "project management features.");
36 ImGui::PopStyleColor();
43 ImGuiSelectableFlags_None,
44 ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
50 if (ImGui::IsItemHovered()) {
51 ImGui::SetTooltip(
"Click to copy path");
58 static char name_buffer[256] = {};
60 strncpy(name_buffer,
project_->
name.c_str(),
sizeof(name_buffer) - 1);
62 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
63 if (ImGui::InputText(
"##project_name", name_buffer,
sizeof(name_buffer))) {
70 static char author_buffer[256] = {};
73 sizeof(author_buffer) - 1);
75 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
76 if (ImGui::InputText(
"##author", author_buffer,
sizeof(author_buffer))) {
83 static char desc_buffer[1024] = {};
86 sizeof(desc_buffer) - 1);
88 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
89 if (ImGui::InputTextMultiline(
"##description", desc_buffer,
90 sizeof(desc_buffer), ImVec2(0, 60))) {
101 ImGui::PopStyleColor();
112 size_t pos = filename.find_last_of(
"/\\");
113 if (pos != std::string::npos) {
114 filename = filename.substr(pos + 1);
116 ImGui::Text(
"%s", filename.c_str());
117 if (ImGui::IsItemHovered()) {
126 ImGui::Text(
"%s",
rom_->
title().c_str());
130 ImGui::Text(
"%.2f MB",
static_cast<float>(
rom_->
size()) / (1024 * 1024));
142 float button_width = (ImGui::GetContentRegionAvail().x - 8) / 2;
149 if (ImGui::IsItemHovered()) {
150 ImGui::SetTooltip(
"Replace the ROM file for this project");
155 if (ImGui::Button(
ICON_MD_REFRESH " Reload", ImVec2(button_width, 0))) {
160 if (ImGui::IsItemHovered()) {
161 ImGui::SetTooltip(
"Reload ROM from disk");
170 ImGui::PopStyleColor();
174 ImGui::TextDisabled(
"Version manager not available");
180 if (!git_initialized) {
182 "Git is not initialized for this project. Initialize Git to enable "
183 "version control and snapshots.");
187 ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
197 absl::StrFormat(
"Failed to initialize Git: %s", status.message()),
207 if (!current_hash.empty()) {
210 ImGui::Text(
"%s", current_hash.substr(0, 7).c_str());
216 ImGui::Text(
"Create Snapshot:");
217 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
218 ImGui::InputTextWithHint(
"##snapshot_msg",
"Snapshot message...",
222 ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
229 absl::StrFormat(
"Snapshot created: %s", result->commit_hash),
237 absl::StrFormat(
"Snapshot failed: %s", result.status().message()),
242 if (ImGui::IsItemHovered()) {
244 "Create a snapshot of your project (Git commit + ROM backup)");
257 if (ImGui::CollapsingHeader(
ICON_MD_LIST " Recent Snapshots",
258 ImGuiTreeNodeFlags_DefaultOpen)) {
266 ImGui::TextDisabled(
"No snapshots yet");
270 size_t space_pos = entry.find(
' ');
272 space_pos != std::string::npos ? entry.substr(0, 7) : entry;
273 std::string message =
274 space_pos != std::string::npos ? entry.substr(space_pos + 1) :
"";
277 ImGui::Text(
"%s", hash.c_str());
278 ImGui::PopStyleColor();
280 ImGui::TextWrapped(
"%s", message.c_str());
289 ImGui::PopStyleColor();
292 float button_width = ImGui::GetContentRegionAvail().x;
302 if (ImGui::Button(
ICON_MD_SAVE " Save Project", ImVec2(button_width, 0))) {
313 static char code_buffer[512] = {};
316 sizeof(code_buffer) - 1);
318 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - 32);
319 if (ImGui::InputText(
"##code_folder", code_buffer,
sizeof(code_buffer))) {
329 if (ImGui::IsItemHovered()) {
330 ImGui::SetTooltip(
"Browse for code folder");
335 static char assets_buffer[512] = {};
338 sizeof(assets_buffer) - 1);
340 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - 32);
341 if (ImGui::InputText(
"##assets_folder", assets_buffer,
342 sizeof(assets_buffer))) {
352 if (ImGui::IsItemHovered()) {
353 ImGui::SetTooltip(
"Browse for assets folder");
358 static char build_buffer[256] = {};
361 sizeof(build_buffer) - 1);
363 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
364 if (ImGui::InputText(
"##build_target", build_buffer,
sizeof(build_buffer))) {
371 static char script_buffer[512] = {};
374 sizeof(script_buffer) - 1);
376 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
377 if (ImGui::InputText(
"##build_script", script_buffer,
378 sizeof(script_buffer))) {
std::vector< std::string > GetHistory(int limit=10) const
absl::Status InitializeGit()
std::string GetCurrentHash() const
absl::StatusOr< SnapshotResult > CreateSnapshot(const std::string &message)
bool IsGitInitialized() const
char snapshot_message_[256]
SwapRomCallback swap_rom_callback_
void DrawProjectOverview()
SaveProjectCallback save_project_callback_
core::VersionManager * version_manager_
void DrawVersionControl()
ToastManager * toast_manager_
project::YazeProject * project_
ReloadRomCallback reload_rom_callback_
void DrawSnapshotHistory()
std::vector< std::string > history_cache_
BrowseFolderCallback browse_folder_callback_
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f)
const Theme & GetCurrentTheme() const
static ThemeManager & Get()
#define ICON_MD_FOLDER_OPEN
#define ICON_MD_FOLDER_SPECIAL
#define ICON_MD_CAMERA_ALT
#define ICON_MD_SWAP_HORIZ
ImVec4 ConvertColorToImVec4(const Color &color)
ImVec4 GetTextSecondaryVec4()
std::string assets_folder