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

673 lines
32 KiB
C++
Raw Normal View History

2017-08-17 19:10:53 +02:00
#include <SFML/Graphics.hpp>
2022-01-04 00:06:09 +01:00
#include <filesystem>
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>
2021-12-31 14:59:39 +01:00
#include <tinyfiledialogs.h>
#include <variant>
2022-01-04 00:06:09 +01:00
#include <whereami++.hpp>
2021-12-31 14:59:39 +01:00
2021-12-31 00:57:06 +01:00
#include "editor_state.hpp"
2021-12-31 14:59:39 +01:00
#include "editor_state_actions.hpp"
2021-12-31 00:57:06 +01:00
#include "notifications_queue.hpp"
#include "preferences.hpp"
2021-12-31 14:59:39 +01:00
#include "sound_effect.hpp"
2021-12-31 00:57:06 +01:00
#include "widgets/blank_screen.hpp"
2017-08-17 19:10:53 +02:00
int main(int argc, char** argv) {
// TODO : Make the playfield not appear when there's no chart selected
2019-04-09 23:07:22 +02:00
// TODO : Make the linear preview display the end of the chart
// TODO : Make the linear preview timebar height movable
2022-01-04 00:06:09 +01:00
auto assets_folder = std::filesystem::path {whereami::executable_dir()} / "assets";
sf::RenderWindow window(sf::VideoMode(800, 600), "FEIS");
2022-01-04 00:06:09 +01:00
// sf::RenderWindow& ref_window = window;
window.setVerticalSyncEnabled(true);
window.setFramerateLimit(60);
ImGui::SFML::Init(window, false);
ImGuiIO& IO = ImGui::GetIO();
IO.Fonts->Clear();
2022-01-04 00:06:09 +01:00
IO.Fonts->AddFontFromFileTTF((assets_folder / "fonts" / "NotoSans-Medium.ttf").c_str(), 16.f);
ImGui::SFML::UpdateFontTexture();
2022-01-04 00:06:09 +01:00
SoundEffect beatTick {assets_folder / "sounds" / "beat.wav"};
SoundEffect noteTick {assets_folder / "sounds" / "note.wav"};
SoundEffect chordTick {assets_folder / "sounds" / "chord.wav"};
2019-01-14 21:43:56 +01:00
// Loading markers preview
2021-12-31 14:59:39 +01:00
std::map<std::filesystem::path, sf::Texture> markerPreviews;
2022-01-04 00:06:09 +01:00
for (const auto& folder : std::filesystem::directory_iterator(assets_folder / "textures" / "markers")) {
if (folder.is_directory()) {
sf::Texture markerPreview;
2021-12-31 14:59:39 +01:00
markerPreview.loadFromFile((folder.path() / "ma15.png").string());
markerPreview.setSmooth(true);
2021-12-31 14:59:39 +01:00
markerPreviews.insert({folder, markerPreview});
}
}
Preferences preferences;
Marker defaultMarker = Marker(preferences.marker);
Marker& marker = defaultMarker;
MarkerEndingState markerEndingState = preferences.markerEndingState;
BlankScreen bg;
std::optional<EditorState> editorState;
NotificationsQueue notificationsQueue;
ESHelper::NewChartDialog newChartDialog;
ESHelper::ChartPropertiesDialog chartPropertiesDialog;
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);
2019-01-02 23:38:47 +01:00
switch (event.type) {
case sf::Event::Closed:
preferences.save();
if (ESHelper::saveOrCancel(editorState)) {
window.close();
}
break;
case sf::Event::Resized:
2022-01-04 00:06:09 +01:00
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 (editorState and editorState->chart) {
editorState->chart->creatingLongNote = true;
}
break;
default:
break;
}
break;
case sf::Event::MouseButtonReleased:
switch (event.mouseButton.button) {
case sf::Mouse::Button::Right:
if (editorState and editorState->chart) {
if (editorState->chart->longNoteBeingCreated) {
auto pair = *editorState->chart->longNoteBeingCreated;
2021-12-31 14:59:39 +01:00
Note new_note = Note(pair.first, pair.second);
std::set<Note> new_note_set = {new_note};
editorState->chart->ref.Notes.insert(new_note);
editorState->chart->longNoteBeingCreated.reset();
editorState->chart->creatingLongNote = false;
2022-01-04 00:06:09 +01:00
editorState->chart->history.push(std::make_shared<ToggledNotes>(new_note_set, true));
}
}
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: {
2022-01-04 00:06:09 +01:00
auto delta = static_cast<int>(std::floor(event.mouseWheelScroll.delta));
2021-12-31 14:59:39 +01:00
if (delta >= 0) {
for (int i = 0; i < delta; ++i) {
Move::backwardsInTime(editorState);
}
} else {
for (int i = 0; i < -delta; ++i) {
Move::forwardsInTime(editorState);
}
}
2021-12-31 14:59:39 +01:00
} break;
default:
break;
}
break;
case sf::Event::KeyPressed:
switch (event.key.code) {
/*
* Selection related stuff
*/
2021-12-31 14:59:39 +01:00
// Discard, in that order : timeSelection,
// selected_notes
case sf::Keyboard::Escape:
if (editorState and editorState->chart) {
2022-01-04 00:06:09 +01:00
if (not std::holds_alternative<std::monostate>(editorState->chart->timeSelection)) {
editorState->chart->timeSelection.emplace<std::monostate>();
} else if (not editorState->chart->selectedNotes.empty()) {
editorState->chart->selectedNotes.clear();
}
}
break;
// Modify timeSelection
case sf::Keyboard::Tab:
if (editorState and editorState->chart) {
// if no timeSelection was previously made
2022-01-04 00:06:09 +01:00
if (std::holds_alternative<std::monostate>(editorState->chart->timeSelection)) {
2021-12-31 14:59:39 +01:00
// set the start of the timeSelection to the
// current time
2022-01-04 00:06:09 +01:00
editorState->chart->timeSelection = static_cast<unsigned int>(editorState->getCurrentTick());
2021-12-31 14:59:39 +01:00
// if the start of the timeSelection is
// already set
2022-01-04 00:06:09 +01:00
} else if (std::holds_alternative<unsigned int>(editorState->chart->timeSelection)) {
auto current_tick = static_cast<int>(editorState->getCurrentTick());
2021-12-31 14:59:39 +01:00
auto selection_start =
2022-01-04 00:06:09 +01:00
static_cast<int>(std::get<unsigned int>(editorState->chart->timeSelection));
2021-12-31 14:59:39 +01:00
// if we are on the same tick as the
// timeSelection start we discard the
// timeSelection
if (current_tick == selection_start) {
editorState->chart->timeSelection.emplace<std::monostate>();
2021-12-31 14:59:39 +01:00
// else we create a full timeSelection
// while paying attention to the order
} else {
2022-01-04 00:06:09 +01:00
auto new_selection_start =
static_cast<unsigned int>(std::min(current_tick, selection_start));
auto duration = static_cast<unsigned int>(std::abs(current_tick - selection_start));
editorState->chart->timeSelection.emplace<TimeSelection>(new_selection_start, duration);
2021-12-31 14:59:39 +01:00
editorState->chart->selectedNotes =
2022-01-04 00:06:09 +01:00
editorState->chart->ref.getNotesBetween(new_selection_start, new_selection_start + duration);
}
2021-12-31 14:59:39 +01:00
// if a full timeSelection already exists
2022-01-04 00:06:09 +01:00
} else if (std::holds_alternative<TimeSelection>(editorState->chart->timeSelection)) {
2021-12-31 14:59:39 +01:00
// discard the current timeSelection and set
// the start of the timeSelection to the
// current time
2022-01-04 00:06:09 +01:00
editorState->chart->timeSelection = static_cast<unsigned int>(editorState->getCurrentTick());
}
}
break;
2021-12-31 14:59:39 +01:00
// Delete selected notes from the chart and discard
// timeSelection
case sf::Keyboard::Delete:
Edit::delete_(editorState, notificationsQueue);
break;
/*
* Arrow keys
*/
case sf::Keyboard::Up:
if (event.key.shift) {
if (editorState) {
editorState->musicVolumeUp();
std::stringstream ss;
2022-01-04 00:06:09 +01:00
ss << "Music Volume : " << editorState->musicVolume * 10 << "%";
notificationsQueue.push(std::make_shared<TextNotification>(ss.str()));
}
} else {
Move::backwardsInTime(editorState);
}
break;
case sf::Keyboard::Down:
if (event.key.shift) {
if (editorState) {
editorState->musicVolumeDown();
std::stringstream ss;
2022-01-04 00:06:09 +01:00
ss << "Music Volume : " << editorState->musicVolume * 10 << "%";
notificationsQueue.push(std::make_shared<TextNotification>(ss.str()));
}
} else {
Move::forwardsInTime(editorState);
}
break;
case sf::Keyboard::Left:
if (event.key.shift) {
if (editorState) {
editorState->musicSpeedDown();
std::stringstream ss;
2021-12-31 14:59:39 +01:00
ss << "Speed : " << editorState->musicSpeed * 10 << "%";
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>(ss.str()));
}
} else {
if (editorState and editorState->chart) {
2022-01-04 00:06:09 +01:00
editorState->snap =
Toolbox::getPreviousDivisor(editorState->chart->ref.getResolution(), editorState->snap);
std::stringstream ss;
2022-01-04 00:06:09 +01:00
ss << "Snap : " << Toolbox::toOrdinal(4 * editorState->snap);
notificationsQueue.push(std::make_shared<TextNotification>(ss.str()));
}
}
break;
case sf::Keyboard::Right:
if (event.key.shift) {
editorState->musicSpeedUp();
std::stringstream ss;
2021-12-31 14:59:39 +01:00
ss << "Speed : " << editorState->musicSpeed * 10 << "%";
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>(ss.str()));
} else {
if (editorState and editorState->chart) {
2022-01-04 00:06:09 +01:00
editorState->snap =
Toolbox::getNextDivisor(editorState->chart->ref.getResolution(), editorState->snap);
std::stringstream ss;
2022-01-04 00:06:09 +01:00
ss << "Snap : " << Toolbox::toOrdinal(4 * editorState->snap);
notificationsQueue.push(std::make_shared<TextNotification>(ss.str()));
}
}
break;
/*
* F keys
*/
case sf::Keyboard::F3:
2019-03-24 22:57:02 +01:00
if (beatTick.toggle()) {
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>("Beat tick : on"));
} else {
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>("Beat tick : off"));
}
break;
case sf::Keyboard::F4:
if (event.key.shift) {
if (chordTick.toggle()) {
noteTick.shouldPlay = true;
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>("Note+Chord tick : on"));
} else {
noteTick.shouldPlay = false;
2022-01-04 00:06:09 +01:00
notificationsQueue.push(
std::make_shared<TextNotification>("Note+Chord tick : off"));
}
} else {
if (noteTick.toggle()) {
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>("Note tick : on"));
} else {
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>("Note tick : off"));
}
}
break;
case sf::Keyboard::Space:
if (not ImGui::GetIO().WantTextInput) {
if (editorState) {
editorState->playing = not editorState->playing;
}
}
break;
2019-03-26 00:04:29 +01:00
case sf::Keyboard::Add:
if (editorState) {
editorState->linearView.zoom_in();
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>("Zoom in"));
2019-03-26 00:04:29 +01:00
}
break;
case sf::Keyboard::Subtract:
if (editorState) {
editorState->linearView.zoom_out();
2022-01-04 00:06:09 +01:00
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) {
Edit::copy(editorState, notificationsQueue);
}
break;
2019-01-16 22:10:20 +01:00
case sf::Keyboard::O:
if (event.key.control) {
if (ESHelper::saveOrCancel(editorState)) {
2022-01-04 00:06:09 +01:00
ESHelper::open(editorState, assets_folder);
}
2019-01-16 22:10:20 +01:00
}
break;
case sf::Keyboard::P:
if (event.key.shift) {
editorState->showProperties = true;
}
break;
case sf::Keyboard::S:
if (event.key.control) {
ESHelper::save(*editorState);
2022-01-04 00:06:09 +01:00
notificationsQueue.push(std::make_shared<TextNotification>("Saved file"));
2019-01-16 22:10:20 +01:00
}
break;
case sf::Keyboard::V:
if (event.key.control) {
Edit::paste(editorState, notificationsQueue);
}
break;
case sf::Keyboard::X:
if (event.key.control) {
Edit::cut(editorState, notificationsQueue);
}
break;
case sf::Keyboard::Y:
if (event.key.control) {
Edit::redo(editorState, notificationsQueue);
}
break;
case sf::Keyboard::Z:
if (event.key.control) {
Edit::undo(editorState, notificationsQueue);
}
break;
2019-01-16 22:10:20 +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
2019-01-17 03:02:37 +01:00
if (editorState) {
editorState->updateVisibleNotes();
2019-01-17 03:02:37 +01:00
if (editorState->playing) {
editorState->previousPos = editorState->playbackPosition;
2021-12-31 14:59:39 +01:00
editorState->playbackPosition += delta * (editorState->musicSpeed / 10.f);
2019-01-17 03:02:37 +01:00
if (editorState->music) {
2021-12-31 14:59:39 +01:00
switch (editorState->music->getStatus()) {
2019-01-17 03:02:37 +01:00
case sf::Music::Stopped:
case sf::Music::Paused:
2021-12-31 14:59:39 +01:00
if (editorState->playbackPosition.asSeconds() >= 0
2022-01-04 00:06:09 +01:00
and editorState->playbackPosition < editorState->music->getDuration()) {
2019-01-17 03:02:37 +01:00
editorState->music->setPlayingOffset(editorState->playbackPosition);
editorState->music->play();
}
break;
case sf::Music::Playing:
2022-01-04 00:06:09 +01:00
editorState->playbackPosition = editorState->music->getPlayingOffset();
2019-01-17 03:02:37 +01:00
break;
default:
break;
}
}
2019-03-24 22:57:02 +01:00
if (beatTick.shouldPlay) {
2022-01-04 00:06:09 +01:00
auto previous_tick = static_cast<int>(editorState->getTicksAt(editorState->previousPos.asSeconds()));
auto current_tick = static_cast<int>(editorState->getTicksAt(editorState->playbackPosition.asSeconds()));
if (previous_tick / editorState->getResolution() != current_tick / editorState->getResolution()) {
2019-03-24 22:57:02 +01:00
beatTick.play();
2019-01-17 03:02:37 +01:00
}
}
2019-03-24 22:57:02 +01:00
if (noteTick.shouldPlay) {
int note_count = 0;
2019-01-17 03:02:37 +01:00
for (auto note : editorState->visibleNotes) {
float noteTiming = editorState->getSecondsAt(note.getTiming());
if (noteTiming >= editorState->previousPos.asSeconds()
and noteTiming <= editorState->playbackPosition.asSeconds()) {
2019-03-24 22:57:02 +01:00
note_count++;
2019-01-17 03:02:37 +01:00
}
}
2019-03-24 22:57:02 +01:00
if (chordTick.shouldPlay) {
if (note_count > 1) {
chordTick.play();
} else if (note_count == 1) {
noteTick.play();
}
} else if (note_count >= 1) {
noteTick.play();
}
}
2019-03-24 22:57:02 +01:00
2019-04-09 23:07:22 +02:00
if (editorState->playbackPosition > editorState->getPreviewEnd()) {
2019-01-17 03:02:37 +01:00
editorState->playing = false;
2019-04-09 23:07:22 +02:00
editorState->playbackPosition = editorState->getPreviewEnd();
2019-01-17 03:02:37 +01:00
}
} else {
if (editorState->music) {
if (editorState->music->getStatus() == sf::Music::Playing) {
editorState->music->pause();
}
}
}
}
// Drawing
if (editorState) {
window.clear(sf::Color(0, 0, 0));
if (editorState->showHistory) {
2020-05-22 11:02:47 +02:00
editorState->chart->history.display(get_message);
}
if (editorState->showPlayfield) {
2021-12-31 14:59:39 +01:00
editorState->displayPlayfield(marker, markerEndingState);
}
2019-03-26 00:04:29 +01:00
if (editorState->showLinearView) {
editorState->displayLinearView();
}
if (editorState->linearView.shouldDisplaySettings) {
editorState->linearView.displaySettings();
}
if (editorState->showProperties) {
editorState->displayProperties();
}
if (editorState->showStatus) {
editorState->displayStatus();
}
if (editorState->showPlaybackStatus) {
editorState->displayPlaybackStatus();
}
if (editorState->showTimeline) {
editorState->displayTimeline();
}
if (editorState->showChartList) {
editorState->displayChartList();
}
if (editorState->showNewChartDialog) {
std::optional<Chart> c = newChartDialog.display(*editorState);
if (c) {
editorState->showNewChartDialog = false;
2021-12-31 14:59:39 +01:00
if (editorState->fumen.Charts.try_emplace(c->dif_name, *c).second) {
editorState->chart.emplace(editorState->fumen.Charts.at(c->dif_name));
}
}
} else {
newChartDialog.resetValues();
}
if (editorState->showChartProperties) {
chartPropertiesDialog.display(*editorState);
} else {
chartPropertiesDialog.shouldRefreshValues = true;
}
if (editorState->showSoundSettings) {
2021-12-31 14:59:39 +01:00
ImGui::Begin("Sound Settings", &editorState->showSoundSettings, ImGuiWindowFlags_AlwaysAutoResize);
{
if (ImGui::TreeNode("Beat Tick")) {
beatTick.displayControls();
ImGui::TreePop();
}
if (ImGui::TreeNode("Note Tick")) {
noteTick.displayControls();
2021-12-31 14:59:39 +01:00
ImGui::Checkbox("Chord sound", &chordTick.shouldPlay);
ImGui::TreePop();
}
}
ImGui::End();
}
} else {
bg.render(window);
}
2019-01-02 23:38:47 +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")) {
if (ESHelper::saveOrCancel(editorState)) {
2022-01-04 00:06:09 +01:00
const char* _filepath = tinyfd_saveFileDialog("New File", nullptr, 0, nullptr, nullptr);
if (_filepath != nullptr) {
std::filesystem::path filepath(_filepath);
try {
Fumen f(filepath);
f.autoSaveAsMemon();
2022-01-04 00:06:09 +01:00
editorState.emplace(f, assets_folder);
Toolbox::pushNewRecentFile(std::filesystem::canonical(editorState->fumen.path));
} catch (const std::exception& e) {
2022-01-04 00:06:09 +01:00
tinyfd_messageBox("Error", e.what(), "ok", "error", 1);
}
2019-01-05 00:07:52 +01:00
}
}
}
ImGui::Separator();
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Open", "Ctrl+O")) {
if (ESHelper::saveOrCancel(editorState)) {
2022-01-04 00:06:09 +01:00
ESHelper::open(editorState, assets_folder);
}
}
if (ImGui::BeginMenu("Recent Files")) {
int i = 0;
for (const auto& file : Toolbox::getRecentFiles()) {
ImGui::PushID(i);
if (ImGui::MenuItem(file.c_str())) {
if (ESHelper::saveOrCancel(editorState)) {
2022-01-04 00:06:09 +01:00
ESHelper::openFromFile(editorState, file, assets_folder);
}
}
ImGui::PopID();
++i;
}
ImGui::EndMenu();
}
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Close", "", false, editorState.has_value())) {
if (ESHelper::saveOrCancel(editorState)) {
editorState.reset();
}
}
ImGui::Separator();
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Save", "Ctrl+S", false, editorState.has_value())) {
2019-01-13 22:29:29 +01:00
ESHelper::save(*editorState);
}
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Save As", "", false, editorState.has_value())) {
char const* options[1] = {"*.memon"};
2022-01-04 00:06:09 +01:00
const char* _filepath(tinyfd_saveFileDialog("Save File", nullptr, 1, options, nullptr));
if (_filepath != nullptr) {
2019-01-12 03:13:30 +01:00
std::filesystem::path filepath(_filepath);
2019-01-05 00:07:52 +01:00
try {
editorState->fumen.saveAsMemon(filepath);
} catch (const std::exception& e) {
2021-12-31 14:59:39 +01:00
tinyfd_messageBox("Error", e.what(), "ok", "error", 1);
2019-01-05 00:07:52 +01:00
}
}
}
2019-01-13 22:29:29 +01:00
ImGui::Separator();
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Properties", "Shift+P", false, editorState.has_value())) {
2019-01-13 22:29:29 +01:00
editorState->showProperties = true;
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Edit")) {
if (ImGui::MenuItem("Undo", "Ctrl+Z")) {
Edit::undo(editorState, notificationsQueue);
}
if (ImGui::MenuItem("Redo", "Ctrl+Y")) {
Edit::redo(editorState, notificationsQueue);
}
ImGui::Separator();
if (ImGui::MenuItem("Cut", "Ctrl+X")) {
Edit::cut(editorState, notificationsQueue);
}
if (ImGui::MenuItem("Copy", "Ctrl+C")) {
Edit::copy(editorState, notificationsQueue);
}
if (ImGui::MenuItem("Paste", "Ctrl+V")) {
Edit::paste(editorState, notificationsQueue);
}
if (ImGui::MenuItem("Delete", "Delete")) {
Edit::delete_(editorState, notificationsQueue);
}
2019-01-12 03:13:30 +01:00
ImGui::EndMenu();
}
2021-12-31 14:59:39 +01:00
if (ImGui::BeginMenu("Chart", editorState.has_value())) {
if (ImGui::MenuItem("Chart List")) {
editorState->showChartList = true;
}
2022-01-04 00:06:09 +01:00
if (ImGui::MenuItem("Properties##Chart", nullptr, false, editorState->chart.has_value())) {
editorState->showChartProperties = true;
}
ImGui::Separator();
if (ImGui::MenuItem("New Chart")) {
editorState->showNewChartDialog = true;
}
ImGui::Separator();
2022-01-04 00:06:09 +01:00
if (ImGui::MenuItem("Delete Chart", nullptr, false, editorState->chart.has_value())) {
editorState->fumen.Charts.erase(editorState->chart->ref.dif_name);
editorState->chart.reset();
}
ImGui::EndMenu();
}
2021-12-31 14:59:39 +01:00
if (ImGui::BeginMenu("View", editorState.has_value())) {
if (ImGui::MenuItem("Playfield", nullptr, editorState->showPlayfield)) {
2019-01-13 22:29:29 +01:00
editorState->showPlayfield = not editorState->showPlayfield;
}
2019-03-26 00:04:29 +01:00
if (ImGui::MenuItem("Linear View", nullptr, editorState->showLinearView)) {
editorState->showLinearView = not editorState->showLinearView;
}
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Playback Status", nullptr, editorState->showPlaybackStatus)) {
editorState->showPlaybackStatus = not editorState->showPlaybackStatus;
}
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Timeline", nullptr, editorState->showTimeline)) {
editorState->showTimeline = not editorState->showTimeline;
}
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("Editor Status", nullptr, editorState->showStatus)) {
2019-01-13 22:29:29 +01:00
editorState->showStatus = not editorState->showStatus;
}
2021-12-31 14:59:39 +01:00
if (ImGui::MenuItem("History", nullptr, editorState->showHistory)) {
editorState->showHistory = not editorState->showHistory;
}
ImGui::EndMenu();
}
2021-12-31 14:59:39 +01:00
if (ImGui::BeginMenu("Settings", editorState.has_value())) {
if (ImGui::MenuItem("Sound")) {
editorState->showSoundSettings = true;
}
if (ImGui::MenuItem("Linear View")) {
editorState->linearView.shouldDisplaySettings = 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);
preferences.marker = tuple.first.string();
} catch (const std::exception& e) {
2022-01-04 00:06:09 +01:00
tinyfd_messageBox("Error", e.what(), "ok", "error", 1);
marker = defaultMarker;
}
}
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 (auto& m : Markers::markerStatePreviews) {
2021-12-31 14:59:39 +01:00
if (ImGui::ImageButton(marker.getTextures().at(m.textureName), {100, 100})) {
markerEndingState = m.state;
preferences.markerEndingState = m.state;
}
ImGui::SameLine();
ImGui::TextUnformatted(m.printName.c_str());
}
ImGui::EndMenu();
}
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
}