F.E.I.S/src/main.cpp

766 lines
33 KiB
C++
Raw Normal View History

2022-11-15 01:14:03 +01:00
#include <SFML/Window/Keyboard.hpp>
#include <exception>
2022-04-14 01:26:31 +02:00
#include <string>
2022-01-04 00:06:09 +01:00
#include <filesystem>
#include <variant>
#include <fmt/core.h>
2019-01-02 23:38:47 +01:00
#include <imgui-SFML.h>
2021-12-31 14:59:39 +01:00
#include <imgui.h>
#include <imgui_stdlib.h>
2022-04-19 23:13:18 +02:00
#include <SFML/Audio/SoundFileFactory.hpp>
#include <SFML/Audio/SoundSource.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System/Time.hpp>
2021-12-31 14:59:39 +01:00
#include <tinyfiledialogs.h>
2022-01-04 00:06:09 +01:00
#include <whereami++.hpp>
2021-12-31 14:59:39 +01:00
#include "chart_state.hpp"
#include "config.hpp"
2021-12-31 00:57:06 +01:00
#include "editor_state.hpp"
2022-04-09 00:54:06 +02:00
#include "file_dialogs.hpp"
#include "history_item.hpp"
#include "marker.hpp"
2022-04-19 23:13:18 +02:00
#include "mp3_reader.hpp"
2021-12-31 00:57:06 +01:00
#include "notifications_queue.hpp"
2021-12-31 14:59:39 +01:00
#include "sound_effect.hpp"
2022-05-11 00:09:02 +02:00
#include "src/custom_sfml_audio/synced_sound_streams.hpp"
2021-12-31 00:57:06 +01:00
#include "widgets/blank_screen.hpp"
#include "utf8_strings.hpp"
2017-08-17 19:10:53 +02:00
int main() {
// TODO : Make the playfield not appear when there's no chart selected
2022-04-19 23:13:18 +02:00
// extend SFML to be able to read mp3's
sf::SoundFileFactory::registerReader<sf::priv::SoundFileReaderMp3>();
auto executable_folder = to_path(whereami::executable_dir());
auto assets_folder = executable_folder / "assets";
auto settings_folder = executable_folder / "settings";
2022-01-04 00:06:09 +01:00
config::Config config{settings_folder};
sf::RenderWindow window(sf::VideoMode(800, 600), "FEIS");
window.setVerticalSyncEnabled(true);
window.setFramerateLimit(60);
window.setKeyRepeatEnabled(false);
ImGui::SFML::Init(window, false);
2022-01-06 23:19:24 +01:00
auto& style = ImGui::GetStyle();
style.WindowRounding = 5.f;
auto font_path = assets_folder / "fonts" / "NotoSans-Medium.ttf";
if (not std::filesystem::exists(font_path)) {
tinyfd_messageBox(
"Error",
("Could not open "+to_utf8_encoded_string(font_path)).c_str(),
"ok",
"error",
1
);
return -1;
}
ImGuiIO& IO = ImGui::GetIO();
IO.Fonts->Clear();
IO.Fonts->AddFontFromFileTTF(
to_utf8_encoded_string(assets_folder / "fonts" / "NotoSans-Medium.ttf").c_str(),
16.f
);
ImGui::SFML::UpdateFontTexture();
IO.ConfigWindowsMoveFromTitleBarOnly = true;
// Loading markers preview
2021-12-31 14:59:39 +01:00
std::map<std::filesystem::path, sf::Texture> markerPreviews;
for (const auto& folder :
std::filesystem::directory_iterator(assets_folder / "textures" / "markers")) {
if (folder.is_directory()) {
sf::Texture markerPreview;
markerPreview.loadFromFile(to_utf8_encoded_string(folder.path() / "ma15.png"));
markerPreview.setSmooth(true);
2021-12-31 14:59:39 +01:00
markerPreviews.insert({folder, markerPreview});
}
}
std::optional<Marker> default_marker_opt;
try {
default_marker_opt = first_available_marker_in(assets_folder);
} catch (const std::exception& e) {
fmt::print("Couldn't load any marker folder, aborting");
return -1;
}
Marker& default_marker = *default_marker_opt;
std::optional<Marker> marker_opt;
if (config.marker.folder) {
try {
marker_opt = Marker(*config.marker.folder);
} catch (const std::exception& e) {
fmt::print("Failed to load marker from preferences");
marker_opt = default_marker_opt;
config.marker.folder = marker_opt->get_folder();
}
} else {
marker_opt = default_marker_opt;
config.marker.folder = marker_opt->get_folder();
}
Marker& marker = *marker_opt;
if (not config.marker.ending_state) {
config.marker.ending_state = Judgement::Perfect;
}
Judgement& markerEndingState = *config.marker.ending_state;
BlankScreen bg{assets_folder};
std::optional<EditorState> editor_state;
NotificationsQueue notificationsQueue;
2022-04-02 04:10:09 +02:00
feis::NewChartDialog newChartDialog;
feis::ChartPropertiesDialog chartPropertiesDialog;
2022-11-15 01:14:03 +01:00
bool show_shortcuts_help = false;
2022-11-15 22:04:29 +01:00
bool show_about_menu = false;
2019-01-02 23:38:47 +01:00
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(event);
switch (event.type) {
case sf::Event::Closed:
2022-04-02 04:10:09 +02:00
if (editor_state) {
2022-04-09 00:54:06 +02:00
if (editor_state->save_if_needed_and_user_wants_to() != EditorState::SaveOutcome::UserCanceled) {
2022-04-02 04:10:09 +02:00
window.close();
}
2022-04-14 01:26:31 +02:00
} else {
window.close();
}
break;
case sf::Event::Resized:
window.setView(sf::View(
sf::FloatRect(0, 0, event.size.width, event.size.height)));
break;
case sf::Event::MouseButtonPressed:
switch (event.mouseButton.button) {
case sf::Mouse::Button::Right:
if (editor_state and editor_state->chart_state) {
editor_state->chart_state->creating_long_note = true;
}
break;
default:
break;
}
break;
case sf::Event::MouseButtonReleased:
switch (event.mouseButton.button) {
case sf::Mouse::Button::Right:
2022-10-26 02:08:19 +02:00
if (editor_state) {
editor_state->insert_long_note_just_created();
}
break;
default:
break;
}
break;
case sf::Event::MouseWheelScrolled:
switch (event.mouseWheelScroll.wheel) {
2021-12-31 14:59:39 +01:00
case sf::Mouse::Wheel::VerticalWheel: {
if (editor_state) {
auto delta = static_cast<int>(
std::floor(event.mouseWheelScroll.delta));
if (delta >= 0) {
for (int i = 0; i < delta; ++i) {
editor_state->move_backwards_in_time();
}
} else {
for (int i = 0; i < -delta; ++i) {
editor_state->move_forwards_in_time();
}
}
}
2021-12-31 14:59:39 +01:00
} break;
default:
break;
}
break;
case sf::Event::KeyPressed:
switch (event.key.code) {
/*
* Selection related stuff
*/
// Discard, in that order :
// - time selection
// - selected notes
case sf::Keyboard::Escape:
if (editor_state) {
editor_state->discard_selection();
}
break;
// Modify time selection
case sf::Keyboard::Tab:
if (editor_state and editor_state->chart_state) {
editor_state->chart_state->handle_time_selection_tab(
editor_state->current_exact_beats()
);
}
break;
2021-12-31 14:59:39 +01:00
// Delete selected notes from the chart and discard
// time selection
case sf::Keyboard::Delete:
if (editor_state) {
editor_state->delete_(notificationsQueue);
2022-04-06 15:47:04 +02:00
}
break;
// Arrow keys
case sf::Keyboard::Up:
if (event.key.shift) {
if (editor_state) {
editor_state->volume_up();
notificationsQueue.push(
std::make_shared<TextNotification>(fmt::format(
"Music Volume : {}%",
editor_state->get_volume() * 10
))
);
}
} else {
if (editor_state) {
editor_state->move_backwards_in_time();
}
}
break;
case sf::Keyboard::Down:
if (event.key.shift) {
if (editor_state) {
editor_state->volume_down();
notificationsQueue.push(
std::make_shared<TextNotification>(fmt::format(
"Music Volume : {}%",
editor_state->get_volume() * 10
))
);
}
} else {
if (editor_state) {
editor_state->move_forwards_in_time();
}
}
break;
case sf::Keyboard::Left:
if (not ImGui::GetIO().WantTextInput) {
if (event.key.shift) {
if (editor_state) {
editor_state->speed_down();
notificationsQueue.push(std::make_shared<TextNotification>(fmt::format(
"Speed : {}%",
editor_state->get_speed() * 10
)));
}
} else {
if (editor_state and editor_state->chart_state) {
editor_state->snap = Toolbox::getPreviousDivisor(240, editor_state->snap);
notificationsQueue.push(
std::make_shared<TextNotification>(fmt::format(
"Snap : {}",
Toolbox::toOrdinal(4 * editor_state->snap)
))
);
}
}
}
break;
case sf::Keyboard::Right:
if (not ImGui::GetIO().WantTextInput) {
if (event.key.shift) {
if (editor_state) {
editor_state->speed_up();
notificationsQueue.push(std::make_shared<TextNotification>(fmt::format(
"Speed : {}%",
editor_state->get_speed() * 10
)));
}
} else {
if (editor_state and editor_state->chart_state) {
editor_state->snap = Toolbox::getNextDivisor(240, editor_state->snap);
notificationsQueue.push(
std::make_shared<TextNotification>(fmt::format(
"Snap : {}",
Toolbox::toOrdinal(4 * editor_state->snap)
))
);
}
}
}
break;
/*
* F keys
*/
2022-11-15 01:14:03 +01:00
case sf::Keyboard::F1:
show_shortcuts_help = not show_shortcuts_help;
break;
case sf::Keyboard::F3:
2022-06-09 00:28:21 +02:00
/*
2019-03-24 22:57:02 +01:00
if (beatTick.toggle()) {
notificationsQueue.push(std::make_shared<TextNotification>(
"Beat tick : on"));
} else {
notificationsQueue.push(std::make_shared<TextNotification>(
"Beat tick : off"));
}
2022-06-09 00:28:21 +02:00
*/
break;
case sf::Keyboard::F4:
2022-06-09 00:28:21 +02:00
/*
if (event.key.shift) {
if (chordTick.toggle()) {
noteTick.shouldPlay = true;
notificationsQueue.push(std::make_shared<TextNotification>(
"Note+Chord tick : on"));
} else {
noteTick.shouldPlay = false;
notificationsQueue.push(std::make_shared<TextNotification>(
"Note+Chord tick : off"));
}
} else {
if (noteTick.toggle()) {
notificationsQueue.push(std::make_shared<TextNotification>(
"Note tick : on"));
} else {
notificationsQueue.push(std::make_shared<TextNotification>(
"Note tick : off"));
}
}
2022-06-09 00:28:21 +02:00
*/
break;
case sf::Keyboard::Space:
if (not ImGui::GetIO().WantTextInput) {
if (editor_state) {
2022-06-09 00:28:21 +02:00
editor_state->toggle_playback();
}
}
break;
2019-03-26 00:04:29 +01:00
case sf::Keyboard::Add:
if (editor_state) {
2022-04-06 15:47:04 +02:00
editor_state->linear_view.zoom_in();
notificationsQueue.push(std::make_shared<TextNotification>("Zoom in"));
2019-03-26 00:04:29 +01:00
}
break;
case sf::Keyboard::Subtract:
if (editor_state) {
2022-04-06 15:47:04 +02:00
editor_state->linear_view.zoom_out();
notificationsQueue.push(std::make_shared<TextNotification>("Zoom out"));
2019-03-26 00:04:29 +01:00
}
break;
/*
* Letter keys, in alphabetical order
*/
case sf::Keyboard::C:
if (event.key.control) {
2022-04-06 15:47:04 +02:00
if (editor_state and editor_state->chart_state) {
// Let imgui copy/paste work on its own
if (not ImGui::IsAnyItemActive()) {
editor_state->chart_state->copy(notificationsQueue);
}
2022-04-06 15:47:04 +02:00
}
}
break;
2022-11-21 23:55:25 +01:00
case sf::Keyboard::F:
if (editor_state) {
config.editor.show_free_buttons = not config.editor.show_free_buttons;
2022-11-21 23:55:25 +01:00
}
2019-01-16 22:10:20 +01:00
case sf::Keyboard::O:
if (event.key.control) {
2022-11-19 01:43:37 +01:00
feis::save_ask_open(editor_state, assets_folder, settings_folder, config);
2019-01-16 22:10:20 +01:00
}
break;
case sf::Keyboard::P:
if (event.key.shift) {
2022-10-11 21:23:29 +02:00
editor_state->show_file_properties = true;
2019-01-16 22:10:20 +01:00
}
break;
case sf::Keyboard::S:
if (event.key.control) {
2022-11-11 00:06:58 +01:00
feis::force_save(editor_state, notificationsQueue);
2019-01-16 22:10:20 +01:00
}
break;
case sf::Keyboard::V:
if (event.key.control) {
if (editor_state) {
// Let imgui copy/paste work on its own
if (not ImGui::IsAnyItemActive()) {
editor_state->paste(notificationsQueue);
}
2022-04-06 15:47:04 +02:00
}
}
break;
case sf::Keyboard::X:
if (event.key.control) {
if (editor_state) {
// Let imgui copy/paste work on its own
if (not ImGui::IsAnyItemActive()) {
editor_state->cut(notificationsQueue);
}
2022-04-06 15:47:04 +02:00
}
}
break;
case sf::Keyboard::Y:
if (event.key.control) {
2022-04-06 15:47:04 +02:00
if (editor_state) {
editor_state->redo(notificationsQueue);
}
}
break;
case sf::Keyboard::Z:
if (event.key.control) {
2022-04-06 15:47:04 +02:00
if (editor_state) {
editor_state->undo(notificationsQueue);
}
}
break;
2019-01-16 22:10:20 +01:00
default:
break;
}
break;
2022-11-21 23:55:25 +01:00
case sf::Event::KeyReleased:
switch (event.key.code) {
case sf::Keyboard::F:
if (editor_state) {
config.editor.show_free_buttons = not config.editor.show_free_buttons;
2022-11-21 23:55:25 +01:00
}
default:
break;
}
break;
2019-01-16 22:10:20 +01:00
default:
break;
}
}
2019-01-14 21:43:56 +01:00
2019-01-14 04:20:30 +01:00
sf::Time delta = deltaClock.restart();
ImGui::SFML::Update(window, delta);
// Audio playback management
if (editor_state) {
editor_state->update_visible_notes();
editor_state->update_music_preview_status();
2022-06-09 00:28:21 +02:00
if (editor_state->get_status() == sf::SoundSource::Playing) {
2022-04-06 15:47:04 +02:00
editor_state->previous_playback_position = editor_state->playback_position;
2022-10-11 01:54:43 +02:00
if (editor_state->has_any_audio()) {
editor_state->playback_position = editor_state->get_precise_playback_position();
} else {
editor_state->playback_position = editor_state->current_time() + delta * editor_state->get_pitch();
}
if (editor_state->current_time() > editor_state->get_editable_range().end) {
2022-06-09 00:28:21 +02:00
editor_state->pause();
2019-01-17 03:02:37 +01:00
}
}
}
// Drawing
if (editor_state) {
window.clear(sf::Color(0, 0, 0));
2022-10-11 21:23:29 +02:00
if (editor_state->show_history) {
editor_state->display_history();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_playfield) {
2022-03-23 02:20:07 +01:00
editor_state->display_playfield(marker, markerEndingState);
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_linear_view) {
2022-03-23 02:20:07 +01:00
editor_state->display_linear_view();
2019-03-26 00:04:29 +01:00
}
2022-04-09 00:54:06 +02:00
if (editor_state->linear_view.shouldDisplaySettings) {
2022-04-19 23:13:18 +02:00
editor_state->linear_view.display_settings();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_file_properties) {
editor_state->display_file_properties();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_status) {
2022-03-23 02:20:07 +01:00
editor_state->display_status();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_playback_status) {
2022-03-23 02:20:07 +01:00
editor_state->display_playback_status();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_timeline) {
2022-03-23 02:20:07 +01:00
editor_state->display_timeline();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_chart_list) {
2022-04-09 00:54:06 +02:00
editor_state->display_chart_list();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_new_chart_dialog) {
2022-04-09 00:54:06 +02:00
auto pair = newChartDialog.display(*editor_state);
if (pair) {
auto& [dif_name, new_chart] = *pair;
2022-10-11 21:23:29 +02:00
editor_state->show_new_chart_dialog = false;
editor_state->insert_chart_and_push_history(dif_name, new_chart);
}
} else {
newChartDialog.resetValues();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_chart_properties) {
2022-04-09 00:54:06 +02:00
chartPropertiesDialog.display(*editor_state);
} else {
chartPropertiesDialog.should_refresh_values = true;
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_sound_settings) {
2022-10-11 01:54:43 +02:00
editor_state->display_sound_settings();
}
2022-10-11 21:23:29 +02:00
if (editor_state->show_editor_settings) {
editor_state->display_editor_settings();
}
if (editor_state->show_timing_menu) {
editor_state->display_timing_menu();
2022-10-19 00:50:34 +02:00
}
} else {
bg.render(window);
}
2019-01-02 23:38:47 +01:00
2022-11-15 01:14:03 +01:00
if (show_shortcuts_help) {
feis::display_shortcuts_help(show_shortcuts_help);
}
2022-11-15 22:04:29 +01:00
if (show_about_menu) {
feis::display_about_menu(show_about_menu);
}
2022-11-15 01:14:03 +01:00
notificationsQueue.display();
// Main Menu bar drawing
ImGui::BeginMainMenuBar();
{
2019-01-02 23:38:47 +01:00
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("New")) {
2022-04-09 00:54:06 +02:00
if (not editor_state) {
2022-11-19 01:43:37 +01:00
editor_state.emplace(assets_folder, config);
2022-04-09 00:54:06 +02:00
} else {
if (editor_state->save_if_needed_and_user_wants_to() != EditorState::SaveOutcome::UserCanceled) {
2022-11-19 01:43:37 +01:00
editor_state.emplace(assets_folder, config);
2022-04-09 00:54:06 +02:00
}
2019-01-05 00:07:52 +01:00
}
}
ImGui::Separator();
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Open", "Ctrl+O")) {
2022-11-19 01:43:37 +01:00
feis::save_ask_open(editor_state, assets_folder, settings_folder, config);
}
if (ImGui::BeginMenu("Recent Files")) {
int i = 0;
for (const auto& file : Toolbox::getRecentFiles(settings_folder)) {
ImGui::PushID(i);
if (ImGui::MenuItem(file.c_str())) {
2022-11-19 01:43:37 +01:00
feis::save_open(editor_state, file, assets_folder, settings_folder, config);
}
ImGui::PopID();
++i;
}
ImGui::EndMenu();
}
if (ImGui::MenuItem("Close", "", false, editor_state.has_value())) {
2022-04-09 00:54:06 +02:00
feis::save_close(editor_state);
}
ImGui::Separator();
if (ImGui::MenuItem("Save", "Ctrl+S", false, editor_state.has_value())) {
2022-11-11 00:06:58 +01:00
feis::force_save(editor_state, notificationsQueue);
}
if (ImGui::MenuItem("Save As", "", false, editor_state.has_value())) {
2022-04-09 00:54:06 +02:00
if (editor_state) {
if (const auto& path = feis::save_file_dialog()) {
editor_state->save(*path);
2019-01-05 00:07:52 +01:00
}
}
}
2019-01-13 22:29:29 +01:00
ImGui::Separator();
if (ImGui::MenuItem("Properties", "Shift+P", false, editor_state.has_value())) {
2022-10-11 21:23:29 +02:00
editor_state->show_file_properties = true;
2019-01-13 22:29:29 +01:00
}
ImGui::EndMenu();
}
2022-11-16 02:00:09 +01:00
if (ImGui::BeginMenu("Edit", editor_state.has_value())) {
if (ImGui::MenuItem("Undo", "Ctrl+Z")) {
2022-04-09 00:54:06 +02:00
if (editor_state) {
editor_state->undo(notificationsQueue);
}
}
if (ImGui::MenuItem("Redo", "Ctrl+Y")) {
2022-04-09 00:54:06 +02:00
if (editor_state) {
editor_state->redo(notificationsQueue);
}
}
ImGui::Separator();
if (ImGui::MenuItem("Cut", "Ctrl+X")) {
if (editor_state) {
editor_state->cut(notificationsQueue);
2022-04-09 00:54:06 +02:00
}
}
if (ImGui::MenuItem("Copy", "Ctrl+C")) {
2022-04-09 00:54:06 +02:00
if (editor_state and editor_state->chart_state) {
editor_state->chart_state->copy(notificationsQueue);
}
}
if (ImGui::MenuItem("Paste", "Ctrl+V")) {
if (editor_state) {
editor_state->paste(notificationsQueue);
2022-04-09 00:54:06 +02:00
}
}
if (ImGui::MenuItem("Delete", "Delete")) {
if (editor_state) {
editor_state->delete_(notificationsQueue);
2022-04-09 00:54:06 +02:00
}
}
2019-01-12 03:13:30 +01:00
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Chart", editor_state.has_value())) {
if (ImGui::MenuItem("Chart List")) {
2022-10-11 21:23:29 +02:00
editor_state->show_chart_list = true;
}
if (ImGui::MenuItem(
"Properties##Chart",
nullptr,
false,
2022-04-09 00:54:06 +02:00
editor_state->chart_state.has_value())) {
2022-10-11 21:23:29 +02:00
editor_state->show_chart_properties = true;
}
ImGui::Separator();
if (ImGui::MenuItem("New Chart")) {
2022-10-11 21:23:29 +02:00
editor_state->show_new_chart_dialog = true;
}
ImGui::Separator();
if (ImGui::MenuItem(
"Delete Chart",
nullptr,
false,
2022-04-09 00:54:06 +02:00
editor_state->chart_state.has_value())) {
editor_state->erase_chart_and_push_history(editor_state->chart_state->difficulty_name);
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Timing", editor_state.has_value())) {
if (ImGui::MenuItem("Adjust Timing")) {
editor_state->show_timing_menu = true;
2022-10-19 00:50:34 +02:00
}
2022-12-31 23:54:59 +01:00
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Notes", editor_state.has_value())) {
if (ImGui::BeginMenu("Mirror")) {
if (ImGui::MenuItem("Horizontally")) {
if (editor_state->chart_state.has_value()) {
editor_state->chart_state->mirror_selected_horizontally(notificationsQueue);
}
}
if (ImGui::MenuItem("Vertically")) {
if (editor_state->chart_state.has_value()) {
editor_state->chart_state->mirror_selected_vertically(notificationsQueue);
}
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Rotate")) {
if (ImGui::MenuItem("90° Clockwise")) {
if (editor_state->chart_state.has_value()) {
editor_state->chart_state->rotate_selected_90_clockwise(notificationsQueue);
}
}
if (ImGui::MenuItem("90° Counter-Clockwise")) {
if (editor_state->chart_state.has_value()) {
editor_state->chart_state->rotate_selected_90_counter_clockwise(notificationsQueue);
}
}
if (ImGui::MenuItem("180°")) {
if (editor_state->chart_state.has_value()) {
editor_state->chart_state->rotate_selected_180(notificationsQueue);
}
}
ImGui::EndMenu();
}
2022-10-19 00:50:34 +02:00
ImGui::EndMenu();
}
if (ImGui::BeginMenu("View", editor_state.has_value())) {
2022-10-11 21:23:29 +02:00
if (ImGui::MenuItem("Playfield", nullptr, editor_state->show_playfield)) {
editor_state->show_playfield = not editor_state->show_playfield;
}
2022-10-11 21:23:29 +02:00
if (ImGui::MenuItem("Linear View", nullptr, editor_state->show_linear_view)) {
editor_state->show_linear_view = not editor_state->show_linear_view;
2019-03-26 00:04:29 +01:00
}
2022-10-11 21:23:29 +02:00
if (ImGui::MenuItem("Playback Status", nullptr, editor_state->show_playback_status)) {
editor_state->show_playback_status = not editor_state->show_playback_status;
}
2022-10-11 21:23:29 +02:00
if (ImGui::MenuItem("Timeline", nullptr, editor_state->show_timeline)) {
editor_state->show_timeline = not editor_state->show_timeline;
}
2022-10-11 21:23:29 +02:00
if (ImGui::MenuItem("Editor Status", nullptr, editor_state->show_status)) {
editor_state->show_status = not editor_state->show_status;
2019-01-13 22:29:29 +01:00
}
2022-10-11 21:23:29 +02:00
if (ImGui::MenuItem("History", nullptr, editor_state->show_history)) {
editor_state->show_history = not editor_state->show_history;
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Settings", editor_state.has_value())) {
if (ImGui::MenuItem("Sound")) {
2022-10-11 21:23:29 +02:00
editor_state->show_sound_settings = true;
}
if (ImGui::MenuItem("Linear View")) {
2022-04-09 00:54:06 +02:00
editor_state->linear_view.shouldDisplaySettings = true;
}
2022-10-11 21:23:29 +02:00
if (ImGui::MenuItem("Editor")) {
editor_state->show_editor_settings = true;
}
if (ImGui::BeginMenu("Marker")) {
int i = 0;
for (auto& tuple : markerPreviews) {
ImGui::PushID(tuple.first.c_str());
2021-12-31 14:59:39 +01:00
if (ImGui::ImageButton(tuple.second, {100, 100})) {
try {
marker = Marker(tuple.first);
config.marker.folder = marker.get_folder();
} catch (const std::exception& e) {
tinyfd_messageBox(
"Error",
e.what(),
"ok",
"error",
1);
marker = default_marker;
config.marker.folder = marker.get_folder();
}
}
ImGui::PopID();
i++;
2021-12-31 14:59:39 +01:00
if (i % 4 != 0) {
ImGui::SameLine();
}
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Marker Ending State")) {
for (const auto& [judgement, name] : judgement_to_name) {
2022-04-09 00:54:06 +02:00
if (ImGui::ImageButton(marker.preview(judgement), {100, 100})) {
markerEndingState = judgement;
}
ImGui::SameLine();
2022-04-09 00:54:06 +02:00
ImGui::TextUnformatted(name.c_str());
}
ImGui::EndMenu();
}
ImGui::EndMenu();
}
2022-11-15 01:14:03 +01:00
if (ImGui::BeginMenu("Help")) {
2022-11-15 22:04:29 +01:00
if (ImGui::MenuItem("Shortcuts", "F1")) {
2022-11-15 01:14:03 +01:00
show_shortcuts_help = true;
}
2022-11-15 22:04:29 +01:00
if (ImGui::MenuItem("About")) {
show_about_menu = true;
}
2022-11-15 01:14:03 +01:00
ImGui::EndMenu();
}
2019-01-02 23:38:47 +01:00
}
ImGui::EndMainMenuBar();
ImGui::SFML::Render(window);
window.display();
}
2019-01-02 23:38:47 +01:00
ImGui::SFML::Shutdown();
return 0;
2017-08-17 19:10:53 +02:00
}