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