Skip to content

Commit

Permalink
Upgrade rmkit for ui::DropdownMenu
Browse files Browse the repository at this point in the history
... and use it for the presets menu
  • Loading branch information
mrichards42 committed Mar 4, 2021
1 parent 4deee8d commit ab215c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
25 changes: 12 additions & 13 deletions src/ui/game_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ extern "C" {

constexpr int TIMER_INTERVAL = 100;

void init_presets_menu(ui::TextDropdown * presets_menu, midend * me)
void init_presets_menu(ui::DropdownMenu * menu, midend * me)
{
// reset the dropdown
presets_menu->scene = NULL;
presets_menu->options.clear();
presets_menu->sections.clear();
menu->scene = NULL;
menu->options.clear();
menu->sections.clear();
// fill in preset names
auto section = presets_menu->add_section("Presets");
std::vector<std::string> names;
auto menu = midend_get_presets(me, NULL);
auto menu_cfg = midend_get_presets(me, NULL);
int preset_id = midend_which_preset(me);
for (int i = 0; i < menu->n_entries; i++) {
auto entry = menu->entries[i];
names.push_back(entry.title);
for (int i = 0; i < menu_cfg->n_entries; i++) {
auto entry = menu_cfg->entries[i];
if (entry.id == preset_id)
presets_menu->text = entry.title;
names.push_back("» " + std::string(entry.title) + " «");
else
names.push_back(" " + std::string(entry.title) + " ");
}
section->add_options(names);
menu->add_options(names);
}

GameScene::GameScene() : frontend()
Expand Down Expand Up @@ -72,8 +72,7 @@ GameScene::GameScene() : frontend()
restart_btn = new ui::Button(0, 0, 276, tb_h, "Restart");
toolbar.pack_start(restart_btn);

presets_menu = new ui::TextDropdown(0, 0, 276, tb_h, "Presets");
presets_menu->dir = ui::DropdownButton::DOWN;
presets_menu = new ui::DropdownMenu(0, 0, 276, tb_h, "Presets");
toolbar.pack_start(presets_menu);

help_btn = new ui::Button(0, 0, 100, tb_h, "?");
Expand Down
2 changes: 1 addition & 1 deletion src/ui/game_scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GameScene : public frontend {

ui::Button * new_game_btn;
ui::Button * restart_btn;
ui::TextDropdown * presets_menu;
ui::DropdownMenu * presets_menu;
ui::Button * back_btn;
ui::Button * undo_btn;
ui::Button * redo_btn;
Expand Down

0 comments on commit ab215c9

Please sign in to comment.