yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
palette_editor.cc
Go to the documentation of this file.
2
3#include <ftxui/component/component.hpp>
4#include <ftxui/component/screen_interactive.hpp>
5#include <ftxui/dom/elements.hpp>
6#include <ftxui/screen/screen.hpp>
7
8#include "absl/strings/str_format.h"
9#include "app/gfx/snes_palette.h"
10#include "cli/tui/tui.h"
11
12namespace yaze {
13namespace cli {
14
15using namespace ftxui;
16
18 // static auto palette_groups = app_context.rom.palette_group();
19 // static std::vector<gfx::PaletteGroup> ftx_palettes = {
20 // palette_groups.swords,
21 // palette_groups.shields,
22 // palette_groups.armors,
23 // palette_groups.overworld_main,
24 // palette_groups.overworld_aux,
25 // palette_groups.global_sprites,
26 // palette_groups.sprites_aux1,
27 // palette_groups.sprites_aux2,
28 // palette_groups.sprites_aux3,
29 // palette_groups.dungeon_main,
30 // palette_groups.overworld_mini_map,
31 // palette_groups.grass,
32 // palette_groups.object_3d,
33 // };
34
35 static int selected_palette_group = 0;
36 static int selected_palette = 0;
37 static int selected_color = 0;
38 static std::string r_str, g_str, b_str;
39
40 static std::vector<std::string> palette_group_names;
41 if (palette_group_names.empty()) {
42 for (size_t i = 0; i < 14; ++i) {
43 palette_group_names.push_back(gfx::kPaletteCategoryNames[i].data());
44 }
45 }
46
47 auto palette_group_menu = Menu(&palette_group_names, &selected_palette_group);
48
49 // auto save_button = Button("Save", [&] {
50 // auto& color =
51 // ftx_palettes[selected_palette_group][selected_palette][selected_color];
52 // color.set_r(std::stoi(r_str));
53 // color.set_g(std::stoi(g_str));
54 // color.set_b(std::stoi(b_str));
55 // // TODO: Implement saving the modified palette to the ROM
56 // });
57
58 // auto back_button = Button("Back", [&] {
59 // // TODO: This needs to be handled by the main TUI loop
60 // });
61
62 // auto component = Container::Vertical({
63 // palette_group_menu,
64 // save_button,
65 // back_button,
66 // });
67
68 // auto renderer = Renderer(component, [&] {
69 // auto& current_palette_group = ftx_palettes[selected_palette_group];
70 // std::vector<std::string> palette_names;
71 // for (size_t i = 0; i < current_palette_group.size(); ++i) {
72 // palette_names.push_back(absl::StrFormat("Palette %d", i));
73 // }
74 // auto palette_menu = Menu(&palette_names, &selected_palette);
75
76 // auto& current_palette = current_palette_group[selected_palette];
77 // std::vector<Elements> color_boxes;
78 // for (int i = 0; i < current_palette.size(); ++i) {
79 // auto& color = current_palette[i];
80 // Element element = text(" ") | bgcolor(Color::RGB(color.rgb().x,
81 // color.rgb().y, color.rgb().z)); if (i == selected_color) {
82 // element = element | border;
83 // }
84 // color_boxes.push_back(element);
85 // }
86
87 // auto color_grid = Wrap("color_grid", color_boxes);
88
89 // r_str = std::to_string(current_palette[selected_color].rgb().x);
90 // g_str = std::to_string(current_palette[selected_color].rgb().y);
91 // b_str = std::to_string(current_palette[selected_color].rgb().z);
92
93 // auto selected_color_view = vbox({
94 // text("Selected Color") | bold,
95 // separator(),
96 // hbox({text("R: "), Input(&r_str, "")}),
97 // hbox({text("G: "), Input(&g_str, "")}),
98 // hbox({text("B: "), Input(&b_str, "")}),
99 // save_button->Render(),
100 // });
101
102 // return vbox({
103 // text("Palette Editor") | center | bold,
104 // separator(),
105 // hbox({
106 // palette_group_menu->Render() | frame,
107 // separator(),
108 // palette_menu->Render() | frame,
109 // separator(),
110 // color_grid | frame | flex,
111 // separator(),
112 // selected_color_view | frame,
113 // }),
114 // separator(),
115 // back_button->Render() | center,
116 // }) | border;
117 // });
118
119 // return renderer;
120 return nullptr;
121}
122
123} // namespace cli
124} // namespace yaze
ftxui::Component Render() override
Definition cli.h:17