2022-01-05 23:18:13 +01:00
|
|
|
#define IMGUI_USER_CONFIG "imconfig-SFML.h"
|
|
|
|
|
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>
|
2019-01-03 23:20:35 +01:00
|
|
|
#include <imgui_stdlib.h>
|
2021-12-31 14:59:39 +01:00
|
|
|
#include <tinyfiledialogs.h>
|
2019-03-27 20:37:30 +01:00
|
|
|
#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) {
|
2019-04-04 00:26:38 +02:00
|
|
|
// 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
|
2019-01-16 01:59:02 +01:00
|
|
|
|
2022-01-04 01:31:17 +01:00
|
|
|
auto executable_folder = std::filesystem::path{whereami::executable_dir()};
|
|
|
|
auto assets_folder = executable_folder / "assets";
|
|
|
|
auto settings_folder = executable_folder / "settings";
|
2022-01-04 00:06:09 +01:00
|
|
|
|
2019-01-16 19:12:01 +01:00
|
|
|
sf::RenderWindow window(sf::VideoMode(800, 600), "FEIS");
|
|
|
|
window.setVerticalSyncEnabled(true);
|
|
|
|
window.setFramerateLimit(60);
|
2019-01-12 17:16:20 +01:00
|
|
|
|
|
|
|
ImGui::SFML::Init(window, false);
|
|
|
|
|
2022-01-06 23:19:24 +01:00
|
|
|
auto& style = ImGui::GetStyle();
|
|
|
|
style.WindowRounding = 5.f;
|
|
|
|
|
2022-01-04 17:36:53 +01:00
|
|
|
auto font_path = assets_folder / "fonts" / "NotoSans-Medium.ttf";
|
|
|
|
if (not std::filesystem::exists(font_path)) {
|
|
|
|
tinyfd_messageBox(
|
|
|
|
"Error",
|
|
|
|
("Could not open "+font_path.string()).c_str(),
|
|
|
|
"ok",
|
|
|
|
"error",
|
|
|
|
1
|
|
|
|
);
|
|
|
|
return -1;
|
|
|
|
}
|
2019-01-12 17:16:20 +01:00
|
|
|
ImGuiIO& IO = ImGui::GetIO();
|
|
|
|
IO.Fonts->Clear();
|
2022-01-04 01:31:17 +01:00
|
|
|
IO.Fonts->AddFontFromFileTTF(
|
|
|
|
(assets_folder / "fonts" / "NotoSans-Medium.ttf").c_str(),
|
|
|
|
16.f);
|
2019-01-12 17:16:20 +01:00
|
|
|
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
|
|
|
|
2019-01-17 15:37:15 +01:00
|
|
|
// Loading markers preview
|
2021-12-31 14:59:39 +01:00
|
|
|
std::map<std::filesystem::path, sf::Texture> markerPreviews;
|
2022-01-04 01:31:17 +01:00
|
|
|
for (const auto& folder :
|
|
|
|
std::filesystem::directory_iterator(assets_folder / "textures" / "markers")) {
|
2019-01-17 15:37:15 +01:00
|
|
|
if (folder.is_directory()) {
|
2019-01-19 17:12:41 +01:00
|
|
|
sf::Texture markerPreview;
|
2021-12-31 14:59:39 +01:00
|
|
|
markerPreview.loadFromFile((folder.path() / "ma15.png").string());
|
2019-01-19 17:12:41 +01:00
|
|
|
markerPreview.setSmooth(true);
|
2021-12-31 14:59:39 +01:00
|
|
|
markerPreviews.insert({folder, markerPreview});
|
2019-01-17 15:37:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-04 01:31:17 +01:00
|
|
|
Preferences preferences{assets_folder, settings_folder};
|
2019-03-28 02:16:29 +01:00
|
|
|
|
|
|
|
Marker defaultMarker = Marker(preferences.marker);
|
2019-01-17 15:37:15 +01:00
|
|
|
Marker& marker = defaultMarker;
|
2019-03-28 02:16:29 +01:00
|
|
|
MarkerEndingState markerEndingState = preferences.markerEndingState;
|
2019-01-17 15:37:15 +01:00
|
|
|
|
2022-01-04 01:31:17 +01:00
|
|
|
BlankScreen bg{assets_folder};
|
2022-03-16 02:10:18 +01:00
|
|
|
std::optional<EditorState> editor_state;
|
2019-03-02 16:06:33 +01:00
|
|
|
NotificationsQueue notificationsQueue;
|
2019-01-16 19:12:01 +01:00
|
|
|
ESHelper::NewChartDialog newChartDialog;
|
|
|
|
ESHelper::ChartPropertiesDialog chartPropertiesDialog;
|
2019-01-02 23:38:47 +01:00
|
|
|
|
2019-01-16 19:12:01 +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
|
|
|
|
2019-01-16 19:12:01 +01:00
|
|
|
switch (event.type) {
|
|
|
|
case sf::Event::Closed:
|
2019-03-28 02:16:29 +01:00
|
|
|
preferences.save();
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ESHelper::saveOrCancel(editor_state)) {
|
2019-03-28 02:16:29 +01:00
|
|
|
window.close();
|
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
break;
|
|
|
|
case sf::Event::Resized:
|
2022-01-04 01:31:17 +01:00
|
|
|
window.setView(sf::View(
|
|
|
|
sf::FloatRect(0, 0, event.size.width, event.size.height)));
|
2019-01-16 19:12:01 +01:00
|
|
|
break;
|
2019-03-28 02:16:29 +01:00
|
|
|
case sf::Event::MouseButtonPressed:
|
|
|
|
switch (event.mouseButton.button) {
|
|
|
|
case sf::Mouse::Button::Right:
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state and editor_state->chart_state) {
|
|
|
|
editor_state->chart_state->creating_long_note = true;
|
2019-03-28 02:16:29 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Event::MouseButtonReleased:
|
|
|
|
switch (event.mouseButton.button) {
|
|
|
|
case sf::Mouse::Button::Right:
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state and editor_state->chart_state) {
|
|
|
|
if (editor_state->chart_state->longNoteBeingCreated) {
|
|
|
|
auto pair = *editor_state->chart->longNoteBeingCreated;
|
2021-12-31 14:59:39 +01:00
|
|
|
Note new_note = Note(pair.first, pair.second);
|
2019-03-28 02:16:29 +01:00
|
|
|
std::set<Note> new_note_set = {new_note};
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->ref.Notes.insert(new_note);
|
|
|
|
editor_state->chart->longNoteBeingCreated.reset();
|
|
|
|
editor_state->chart->creatingLongNote = false;
|
|
|
|
editor_state->chart->history.push(
|
2022-01-04 01:31:17 +01:00
|
|
|
std::make_shared<ToggledNotes>(new_note_set, true));
|
2019-03-28 02:16:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2019-04-02 17:08:23 +02:00
|
|
|
case sf::Event::MouseWheelScrolled:
|
|
|
|
switch (event.mouseWheelScroll.wheel) {
|
2021-12-31 14:59:39 +01:00
|
|
|
case sf::Mouse::Wheel::VerticalWheel: {
|
2022-01-04 01:31:17 +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) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Move::backwardsInTime(editor_state);
|
2021-12-31 14:59:39 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < -delta; ++i) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Move::forwardsInTime(editor_state);
|
2019-04-02 17:08:23 +02:00
|
|
|
}
|
|
|
|
}
|
2021-12-31 14:59:39 +01:00
|
|
|
} break;
|
2019-04-02 17:08:23 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2019-01-16 19:12:01 +01:00
|
|
|
case sf::Event::KeyPressed:
|
|
|
|
switch (event.key.code) {
|
2019-03-27 20:37:30 +01:00
|
|
|
/*
|
|
|
|
* Selection related stuff
|
|
|
|
*/
|
|
|
|
|
2021-12-31 14:59:39 +01:00
|
|
|
// Discard, in that order : timeSelection,
|
|
|
|
// selected_notes
|
2019-03-27 20:37:30 +01:00
|
|
|
case sf::Keyboard::Escape:
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state and editor_state->chart) {
|
2022-01-04 01:31:17 +01:00
|
|
|
if (not std::holds_alternative<std::monostate>(
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->timeSelection)) {
|
|
|
|
editor_state->chart->timeSelection.emplace<std::monostate>();
|
|
|
|
} else if (not editor_state->chart->selectedNotes.empty()) {
|
|
|
|
editor_state->chart->selectedNotes.clear();
|
2019-03-27 20:37:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Modify timeSelection
|
|
|
|
case sf::Keyboard::Tab:
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state and editor_state->chart) {
|
2019-03-27 20:37:30 +01:00
|
|
|
// if no timeSelection was previously made
|
2022-01-04 01:31:17 +01:00
|
|
|
if (std::holds_alternative<std::monostate>(
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->timeSelection)) {
|
2021-12-31 14:59:39 +01:00
|
|
|
// set the start of the timeSelection to the
|
|
|
|
// current time
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->timeSelection =
|
2022-01-04 01:31:17 +01:00
|
|
|
static_cast<unsigned int>(
|
2022-03-17 02:50:30 +01:00
|
|
|
editor_state->current_tick());
|
2021-12-31 14:59:39 +01:00
|
|
|
|
|
|
|
// if the start of the timeSelection is
|
|
|
|
// already set
|
2022-01-04 01:31:17 +01:00
|
|
|
} else if (std::holds_alternative<unsigned int>(
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->timeSelection)) {
|
2022-01-04 01:31:17 +01:00
|
|
|
auto current_tick =
|
2022-03-17 02:50:30 +01:00
|
|
|
static_cast<int>(editor_state->current_tick());
|
2021-12-31 14:59:39 +01:00
|
|
|
auto selection_start =
|
2022-01-04 01:31:17 +01:00
|
|
|
static_cast<int>(std::get<unsigned int>(
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->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
|
2019-03-27 20:37:30 +01:00
|
|
|
if (current_tick == selection_start) {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->timeSelection.emplace<std::monostate>();
|
2019-03-27 20:37:30 +01:00
|
|
|
|
2021-12-31 14:59:39 +01:00
|
|
|
// else we create a full timeSelection
|
|
|
|
// while paying attention to the order
|
2019-03-27 20:37:30 +01:00
|
|
|
} else {
|
2022-01-04 01:31:17 +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));
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->timeSelection.emplace<TimeSelection>(
|
2022-01-04 01:31:17 +01:00
|
|
|
new_selection_start,
|
|
|
|
duration);
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->selectedNotes =
|
|
|
|
editor_state->chart->ref.getNotesBetween(
|
2022-01-04 01:31:17 +01:00
|
|
|
new_selection_start,
|
|
|
|
new_selection_start + duration);
|
2019-03-27 20:37:30 +01:00
|
|
|
}
|
|
|
|
|
2021-12-31 14:59:39 +01:00
|
|
|
// if a full timeSelection already exists
|
2022-01-04 01:31:17 +01:00
|
|
|
} else if (std::holds_alternative<TimeSelection>(
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->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-03-16 02:10:18 +01:00
|
|
|
editor_state->chart->timeSelection =
|
2022-01-04 01:31:17 +01:00
|
|
|
static_cast<unsigned int>(
|
2022-03-17 02:50:30 +01:00
|
|
|
editor_state->current_tick());
|
2019-03-27 20:37:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-12-31 14:59:39 +01:00
|
|
|
// Delete selected notes from the chart and discard
|
|
|
|
// timeSelection
|
2019-03-27 20:37:30 +01:00
|
|
|
case sf::Keyboard::Delete:
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::delete_(editor_state, notificationsQueue);
|
2019-03-27 20:37:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Arrow keys
|
|
|
|
*/
|
2019-01-17 01:08:38 +01:00
|
|
|
case sf::Keyboard::Up:
|
|
|
|
if (event.key.shift) {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state) {
|
|
|
|
editor_state->musicVolumeUp();
|
2019-03-24 23:19:06 +01:00
|
|
|
std::stringstream ss;
|
2022-01-04 01:31:17 +01:00
|
|
|
ss << "Music Volume : "
|
2022-03-16 02:10:18 +01:00
|
|
|
<< editor_state->musicVolume * 10 << "%";
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(
|
|
|
|
std::make_shared<TextNotification>(ss.str()));
|
2019-01-17 01:08:38 +01:00
|
|
|
}
|
|
|
|
} else {
|
2022-03-16 02:10:18 +01:00
|
|
|
Move::backwardsInTime(editor_state);
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-01-17 01:08:38 +01:00
|
|
|
case sf::Keyboard::Down:
|
|
|
|
if (event.key.shift) {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state) {
|
|
|
|
editor_state->musicVolumeDown();
|
2019-03-24 23:19:06 +01:00
|
|
|
std::stringstream ss;
|
2022-01-04 01:31:17 +01:00
|
|
|
ss << "Music Volume : "
|
2022-03-16 02:10:18 +01:00
|
|
|
<< editor_state->musicVolume * 10 << "%";
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(
|
|
|
|
std::make_shared<TextNotification>(ss.str()));
|
2019-01-17 01:08:38 +01:00
|
|
|
}
|
|
|
|
} else {
|
2022-03-16 02:10:18 +01:00
|
|
|
Move::forwardsInTime(editor_state);
|
2019-01-17 01:08:38 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::Left:
|
2019-03-24 23:19:06 +01:00
|
|
|
if (event.key.shift) {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state) {
|
|
|
|
editor_state->musicSpeedDown();
|
2019-03-24 23:19:06 +01:00
|
|
|
std::stringstream ss;
|
2022-03-16 02:10:18 +01:00
|
|
|
ss << "Speed : " << editor_state->musicSpeed * 10 << "%";
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(
|
|
|
|
std::make_shared<TextNotification>(ss.str()));
|
2019-03-24 23:19:06 +01:00
|
|
|
}
|
|
|
|
} else {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state and editor_state->chart) {
|
|
|
|
editor_state->snap = Toolbox::getPreviousDivisor(
|
|
|
|
editor_state->chart->ref.getResolution(),
|
|
|
|
editor_state->snap);
|
2019-03-24 23:19:06 +01:00
|
|
|
std::stringstream ss;
|
2022-01-04 01:31:17 +01:00
|
|
|
ss << "Snap : "
|
2022-03-16 02:10:18 +01:00
|
|
|
<< Toolbox::toOrdinal(4 * editor_state->snap);
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(
|
|
|
|
std::make_shared<TextNotification>(ss.str()));
|
2019-03-24 23:19:06 +01:00
|
|
|
}
|
2019-01-17 01:08:38 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::Right:
|
2019-03-24 23:19:06 +01:00
|
|
|
if (event.key.shift) {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->musicSpeedUp();
|
2019-03-24 21:51:33 +01:00
|
|
|
std::stringstream ss;
|
2022-03-16 02:10:18 +01:00
|
|
|
ss << "Speed : " << editor_state->musicSpeed * 10 << "%";
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(
|
|
|
|
std::make_shared<TextNotification>(ss.str()));
|
2019-03-24 23:19:06 +01:00
|
|
|
} else {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state and editor_state->chart) {
|
|
|
|
editor_state->snap = Toolbox::getNextDivisor(
|
|
|
|
editor_state->chart->ref.getResolution(),
|
|
|
|
editor_state->snap);
|
2019-03-24 23:19:06 +01:00
|
|
|
std::stringstream ss;
|
2022-01-04 01:31:17 +01:00
|
|
|
ss << "Snap : "
|
2022-03-16 02:10:18 +01:00
|
|
|
<< Toolbox::toOrdinal(4 * editor_state->snap);
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(
|
|
|
|
std::make_shared<TextNotification>(ss.str()));
|
2019-03-24 23:19:06 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-03-27 20:37:30 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* F keys
|
|
|
|
*/
|
2019-01-17 01:08:38 +01:00
|
|
|
case sf::Keyboard::F3:
|
2019-03-24 22:57:02 +01:00
|
|
|
if (beatTick.toggle()) {
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Beat tick : on"));
|
2019-03-02 16:06:33 +01:00
|
|
|
} else {
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Beat tick : off"));
|
2019-03-02 16:06:33 +01:00
|
|
|
}
|
2019-01-17 01:08:38 +01:00
|
|
|
break;
|
|
|
|
case sf::Keyboard::F4:
|
2019-03-25 19:16:45 +01:00
|
|
|
if (event.key.shift) {
|
|
|
|
if (chordTick.toggle()) {
|
|
|
|
noteTick.shouldPlay = true;
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Note+Chord tick : on"));
|
2019-03-25 19:16:45 +01:00
|
|
|
} else {
|
|
|
|
noteTick.shouldPlay = false;
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Note+Chord tick : off"));
|
2019-03-25 19:16:45 +01:00
|
|
|
}
|
2019-03-02 16:06:33 +01:00
|
|
|
} else {
|
2019-03-25 19:16:45 +01:00
|
|
|
if (noteTick.toggle()) {
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Note tick : on"));
|
2019-03-25 19:16:45 +01:00
|
|
|
} else {
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Note tick : off"));
|
2019-03-25 19:16:45 +01:00
|
|
|
}
|
2019-03-02 16:06:33 +01:00
|
|
|
}
|
2019-01-17 01:08:38 +01:00
|
|
|
break;
|
2019-01-16 19:12:01 +01:00
|
|
|
case sf::Keyboard::Space:
|
|
|
|
if (not ImGui::GetIO().WantTextInput) {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state) {
|
|
|
|
editor_state->playing = not editor_state->playing;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-03-26 00:04:29 +01:00
|
|
|
case sf::Keyboard::Add:
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state) {
|
|
|
|
editor_state->linearView.zoom_in();
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Zoom in"));
|
2019-03-26 00:04:29 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::Subtract:
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state) {
|
|
|
|
editor_state->linearView.zoom_out();
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Zoom out"));
|
2019-03-26 00:04:29 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-03-27 20:37:30 +01:00
|
|
|
/*
|
|
|
|
* Letter keys, in alphabetical order
|
|
|
|
*/
|
|
|
|
case sf::Keyboard::C:
|
|
|
|
if (event.key.control) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::copy(editor_state, notificationsQueue);
|
2019-03-27 20:37:30 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-01-16 22:10:20 +01:00
|
|
|
case sf::Keyboard::O:
|
|
|
|
if (event.key.control) {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ESHelper::saveOrCancel(editor_state)) {
|
|
|
|
ESHelper::open(editor_state, assets_folder, settings_folder);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
2019-01-16 22:10:20 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::P:
|
|
|
|
if (event.key.shift) {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->showProperties = true;
|
2019-01-16 22:10:20 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::S:
|
|
|
|
if (event.key.control) {
|
2022-03-16 02:10:18 +01:00
|
|
|
ESHelper::save(*editor_state);
|
2022-01-04 01:31:17 +01:00
|
|
|
notificationsQueue.push(std::make_shared<TextNotification>(
|
|
|
|
"Saved file"));
|
2019-01-16 22:10:20 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-03-27 20:37:30 +01:00
|
|
|
case sf::Keyboard::V:
|
|
|
|
if (event.key.control) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::paste(editor_state, notificationsQueue);
|
2019-03-27 20:37:30 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::X:
|
|
|
|
if (event.key.control) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::cut(editor_state, notificationsQueue);
|
2019-03-27 20:37:30 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-03-02 13:47:26 +01:00
|
|
|
case sf::Keyboard::Y:
|
|
|
|
if (event.key.control) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::redo(editor_state, notificationsQueue);
|
2019-03-02 13:47:26 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::Z:
|
|
|
|
if (event.key.control) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::undo(editor_state, notificationsQueue);
|
2019-03-02 13:47:26 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-01-16 22:10:20 +01:00
|
|
|
default:
|
|
|
|
break;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-01-16 22:10:20 +01:00
|
|
|
default:
|
|
|
|
break;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-14 21:43:56 +01:00
|
|
|
|
2019-01-14 04:20:30 +01:00
|
|
|
sf::Time delta = deltaClock.restart();
|
2019-01-16 19:12:01 +01:00
|
|
|
ImGui::SFML::Update(window, delta);
|
|
|
|
|
2019-02-13 00:52:52 +01:00
|
|
|
// Audio playback management
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state) {
|
|
|
|
editor_state->updateVisibleNotes();
|
|
|
|
if (editor_state->playing) {
|
|
|
|
editor_state->previousPos = editor_state->playbackPosition;
|
|
|
|
editor_state->playbackPosition += delta * (editor_state->musicSpeed / 10.f);
|
|
|
|
if (editor_state->music) {
|
|
|
|
switch (editor_state->music->getStatus()) {
|
2019-01-17 03:02:37 +01:00
|
|
|
case sf::Music::Stopped:
|
|
|
|
case sf::Music::Paused:
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->playbackPosition.asSeconds() >= 0
|
|
|
|
and editor_state->playbackPosition
|
|
|
|
< editor_state->music->getDuration()) {
|
|
|
|
editor_state->music->setPlayingOffset(editor_state->playbackPosition);
|
|
|
|
editor_state->music->play();
|
2019-01-17 03:02:37 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Music::Playing:
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->playbackPosition =
|
|
|
|
editor_state->music->getPrecisePlayingOffset();
|
2019-01-17 03:02:37 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-03-24 22:57:02 +01:00
|
|
|
if (beatTick.shouldPlay) {
|
2022-03-17 02:50:30 +01:00
|
|
|
auto previous_tick = static_cast<int>(editor_state->ticks_at(
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->previousPos.asSeconds()));
|
2022-03-17 02:50:30 +01:00
|
|
|
auto current_tick = static_cast<int>(editor_state->ticks_at(
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->playbackPosition.asSeconds()));
|
|
|
|
if (previous_tick / editor_state->getResolution()
|
|
|
|
!= current_tick / editor_state->getResolution()) {
|
2019-03-24 22:57:02 +01:00
|
|
|
beatTick.play();
|
2019-01-17 03:02:37 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2019-03-24 22:57:02 +01:00
|
|
|
if (noteTick.shouldPlay) {
|
|
|
|
int note_count = 0;
|
2022-03-16 02:10:18 +01:00
|
|
|
for (auto note : editor_state->visibleNotes) {
|
|
|
|
float noteTiming = editor_state->getSecondsAt(note.getTiming());
|
|
|
|
if (noteTiming >= editor_state->previousPos.asSeconds()
|
|
|
|
and noteTiming <= editor_state->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-01-16 19:12:01 +01:00
|
|
|
}
|
2019-03-24 22:57:02 +01:00
|
|
|
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->playbackPosition > editor_state->getPreviewEnd()) {
|
|
|
|
editor_state->playing = false;
|
|
|
|
editor_state->playbackPosition = editor_state->getPreviewEnd();
|
2019-01-17 03:02:37 +01:00
|
|
|
}
|
|
|
|
} else {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->music) {
|
|
|
|
if (editor_state->music->getStatus() == sf::Music::Playing) {
|
|
|
|
editor_state->music->pause();
|
2019-01-17 03:02:37 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-02 13:47:26 +01:00
|
|
|
// Drawing
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state) {
|
2019-01-16 19:12:01 +01:00
|
|
|
window.clear(sf::Color(0, 0, 0));
|
2019-01-03 23:20:35 +01:00
|
|
|
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showHistory) {
|
2022-03-23 02:20:07 +01:00
|
|
|
editor_state->chart_state->history.display();
|
2019-03-02 13:47:26 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showPlayfield) {
|
2022-03-23 02:20:07 +01:00
|
|
|
editor_state->display_playfield(marker, markerEndingState);
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showLinearView) {
|
2022-03-23 02:20:07 +01:00
|
|
|
editor_state->display_linear_view();
|
2019-03-26 00:04:29 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->linearView.shouldDisplaySettings) {
|
|
|
|
editor_state->linearView.displaySettings();
|
2019-03-27 20:37:30 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showProperties) {
|
2022-03-23 02:20:07 +01:00
|
|
|
editor_state->display_properties();
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showStatus) {
|
2022-03-23 02:20:07 +01:00
|
|
|
editor_state->display_status();
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showPlaybackStatus) {
|
2022-03-23 02:20:07 +01:00
|
|
|
editor_state->display_playback_status();
|
2019-01-12 17:16:20 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showTimeline) {
|
2022-03-23 02:20:07 +01:00
|
|
|
editor_state->display_timeline();
|
2019-01-16 01:59:02 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showChartList) {
|
2022-03-23 02:20:07 +01:00
|
|
|
editor_state->display_chart_list(assets_folder);
|
2019-01-16 01:59:02 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showNewChartDialog) {
|
|
|
|
std::optional<Chart> c = newChartDialog.display(*editor_state);
|
2019-01-16 19:12:01 +01:00
|
|
|
if (c) {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->showNewChartDialog = false;
|
|
|
|
if (editor_state->song.Charts.try_emplace(c->dif_name, *c).second) {
|
|
|
|
editor_state->chart.emplace(editor_state->song.Charts.at(c->dif_name), assets_folder);
|
2019-01-17 01:08:38 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2019-01-16 01:59:02 +01:00
|
|
|
} else {
|
2019-01-16 19:12:01 +01:00
|
|
|
newChartDialog.resetValues();
|
2019-01-13 03:53:42 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showChartProperties) {
|
|
|
|
chartPropertiesDialog.display(*editor_state, assets_folder);
|
2019-01-16 19:12:01 +01:00
|
|
|
} else {
|
|
|
|
chartPropertiesDialog.shouldRefreshValues = true;
|
|
|
|
}
|
2019-03-25 19:16:45 +01:00
|
|
|
|
2022-03-16 02:10:18 +01:00
|
|
|
if (editor_state->showSoundSettings) {
|
|
|
|
ImGui::Begin("Sound Settings", &editor_state->showSoundSettings, ImGuiWindowFlags_AlwaysAutoResize);
|
2019-03-25 19:16:45 +01:00
|
|
|
{
|
|
|
|
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);
|
2019-03-25 19:16:45 +01:00
|
|
|
ImGui::TreePop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::End();
|
|
|
|
}
|
|
|
|
|
2019-01-16 19:12:01 +01:00
|
|
|
} else {
|
|
|
|
bg.render(window);
|
|
|
|
}
|
2019-01-02 23:38:47 +01:00
|
|
|
|
2019-03-02 16:06:33 +01:00
|
|
|
notificationsQueue.display();
|
|
|
|
|
|
|
|
// Main Menu bar drawing
|
2019-01-16 19:12:01 +01:00
|
|
|
ImGui::BeginMainMenuBar();
|
|
|
|
{
|
2019-01-02 23:38:47 +01:00
|
|
|
if (ImGui::BeginMenu("File")) {
|
2019-01-03 23:20:35 +01:00
|
|
|
if (ImGui::MenuItem("New")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ESHelper::saveOrCancel(editor_state)) {
|
2022-01-04 01:31:17 +01:00
|
|
|
const char* _filepath =
|
|
|
|
tinyfd_saveFileDialog("New File", nullptr, 0, nullptr, nullptr);
|
2019-03-28 10:54:50 +01:00
|
|
|
if (_filepath != nullptr) {
|
|
|
|
std::filesystem::path filepath(_filepath);
|
|
|
|
try {
|
|
|
|
Fumen f(filepath);
|
|
|
|
f.autoSaveAsMemon();
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state.emplace(f, assets_folder);
|
2022-01-04 01:31:17 +01:00
|
|
|
Toolbox::pushNewRecentFile(std::filesystem::canonical(
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->song.path), settings_folder);
|
2019-03-28 10:54:50 +01:00
|
|
|
} catch (const std::exception& e) {
|
2022-01-04 01:31:17 +01:00
|
|
|
tinyfd_messageBox(
|
|
|
|
"Error",
|
|
|
|
e.what(),
|
|
|
|
"ok",
|
|
|
|
"error",
|
|
|
|
1);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
2019-01-05 00:07:52 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-03 23:20:35 +01:00
|
|
|
}
|
|
|
|
ImGui::Separator();
|
2021-12-31 14:59:39 +01:00
|
|
|
if (ImGui::MenuItem("Open", "Ctrl+O")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ESHelper::saveOrCancel(editor_state)) {
|
|
|
|
ESHelper::open(editor_state, assets_folder, settings_folder);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
2019-01-03 23:20:35 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
if (ImGui::BeginMenu("Recent Files")) {
|
|
|
|
int i = 0;
|
2022-01-04 01:31:17 +01:00
|
|
|
for (const auto& file : Toolbox::getRecentFiles(settings_folder)) {
|
2019-01-13 03:53:42 +01:00
|
|
|
ImGui::PushID(i);
|
|
|
|
if (ImGui::MenuItem(file.c_str())) {
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ESHelper::saveOrCancel(editor_state)) {
|
|
|
|
ESHelper::openFromFile(editor_state, file, assets_folder, settings_folder);
|
2019-03-28 02:16:29 +01:00
|
|
|
}
|
2019-01-13 03:53:42 +01:00
|
|
|
}
|
2019-01-03 23:20:35 +01:00
|
|
|
ImGui::PopID();
|
2019-01-13 03:53:42 +01:00
|
|
|
++i;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("Close", "", false, editor_state.has_value())) {
|
|
|
|
if (ESHelper::saveOrCancel(editor_state)) {
|
|
|
|
editor_state.reset();
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
ImGui::Separator();
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("Save", "Ctrl+S", false, editor_state.has_value())) {
|
|
|
|
ESHelper::save(*editor_state);
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("Save As", "", false, editor_state.has_value())) {
|
2021-12-31 14:59:39 +01:00
|
|
|
char const* options[1] = {"*.memon"};
|
2022-01-04 01:31:17 +01:00
|
|
|
const char* _filepath(
|
|
|
|
tinyfd_saveFileDialog("Save File", nullptr, 1, options, nullptr));
|
2019-01-03 23:20:35 +01:00
|
|
|
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 {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->song.saveAsMemon(filepath);
|
2019-01-05 00:07:52 +01:00
|
|
|
} 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-03 23:20:35 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2019-01-13 22:29:29 +01:00
|
|
|
ImGui::Separator();
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("Properties", "Shift+P", false, editor_state.has_value())) {
|
|
|
|
editor_state->showProperties = true;
|
2019-01-13 22:29:29 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2019-01-03 23:20:35 +01:00
|
|
|
if (ImGui::BeginMenu("Edit")) {
|
2019-03-28 10:54:50 +01:00
|
|
|
if (ImGui::MenuItem("Undo", "Ctrl+Z")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::undo(editor_state, notificationsQueue);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("Redo", "Ctrl+Y")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::redo(editor_state, notificationsQueue);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
|
|
|
ImGui::Separator();
|
|
|
|
if (ImGui::MenuItem("Cut", "Ctrl+X")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::cut(editor_state, notificationsQueue);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("Copy", "Ctrl+C")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::copy(editor_state, notificationsQueue);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("Paste", "Ctrl+V")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::paste(editor_state, notificationsQueue);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("Delete", "Delete")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
Edit::delete_(editor_state, notificationsQueue);
|
2019-03-28 10:54:50 +01:00
|
|
|
}
|
2019-01-12 03:13:30 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::BeginMenu("Chart", editor_state.has_value())) {
|
2019-01-16 19:12:01 +01:00
|
|
|
if (ImGui::MenuItem("Chart List")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->showChartList = true;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2022-01-04 01:31:17 +01:00
|
|
|
if (ImGui::MenuItem(
|
|
|
|
"Properties##Chart",
|
|
|
|
nullptr,
|
|
|
|
false,
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart.has_value())) {
|
|
|
|
editor_state->showChartProperties = true;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
ImGui::Separator();
|
|
|
|
if (ImGui::MenuItem("New Chart")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->showNewChartDialog = true;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
ImGui::Separator();
|
2022-01-04 01:31:17 +01:00
|
|
|
if (ImGui::MenuItem(
|
|
|
|
"Delete Chart",
|
|
|
|
nullptr,
|
|
|
|
false,
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->chart.has_value())) {
|
|
|
|
editor_state->song.Charts.erase(editor_state->chart->ref.dif_name);
|
|
|
|
editor_state->chart.reset();
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
2019-01-16 01:59:02 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::BeginMenu("View", editor_state.has_value())) {
|
|
|
|
if (ImGui::MenuItem("Playfield", nullptr, editor_state->showPlayfield)) {
|
|
|
|
editor_state->showPlayfield = not editor_state->showPlayfield;
|
2019-01-12 17:16:20 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("Linear View", nullptr, editor_state->showLinearView)) {
|
|
|
|
editor_state->showLinearView = not editor_state->showLinearView;
|
2019-03-26 00:04:29 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("Playback Status", nullptr, editor_state->showPlaybackStatus)) {
|
|
|
|
editor_state->showPlaybackStatus = not editor_state->showPlaybackStatus;
|
2019-01-13 03:53:42 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("Timeline", nullptr, editor_state->showTimeline)) {
|
|
|
|
editor_state->showTimeline = not editor_state->showTimeline;
|
2019-01-03 23:20:35 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("Editor Status", nullptr, editor_state->showStatus)) {
|
|
|
|
editor_state->showStatus = not editor_state->showStatus;
|
2019-01-13 22:29:29 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::MenuItem("History", nullptr, editor_state->showHistory)) {
|
|
|
|
editor_state->showHistory = not editor_state->showHistory;
|
2019-03-02 13:47:26 +01:00
|
|
|
}
|
2019-01-03 23:20:35 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
if (ImGui::BeginMenu("Settings", editor_state.has_value())) {
|
2019-03-25 19:16:45 +01:00
|
|
|
if (ImGui::MenuItem("Sound")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->showSoundSettings = true;
|
2019-03-25 19:16:45 +01:00
|
|
|
}
|
2019-03-27 20:37:30 +01:00
|
|
|
if (ImGui::MenuItem("Linear View")) {
|
2022-03-16 02:10:18 +01:00
|
|
|
editor_state->linearView.shouldDisplaySettings = true;
|
2019-03-27 20:37:30 +01:00
|
|
|
}
|
2019-01-17 15:37:15 +01:00
|
|
|
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})) {
|
2019-01-17 15:37:15 +01:00
|
|
|
try {
|
|
|
|
marker = Marker(tuple.first);
|
2019-03-28 02:16:29 +01:00
|
|
|
preferences.marker = tuple.first.string();
|
2019-01-17 15:37:15 +01:00
|
|
|
} catch (const std::exception& e) {
|
2022-01-04 01:31:17 +01:00
|
|
|
tinyfd_messageBox(
|
|
|
|
"Error",
|
|
|
|
e.what(),
|
|
|
|
"ok",
|
|
|
|
"error",
|
|
|
|
1);
|
2019-01-17 15:37:15 +01:00
|
|
|
marker = defaultMarker;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
i++;
|
2021-12-31 14:59:39 +01:00
|
|
|
if (i % 4 != 0) {
|
2019-01-17 15:37:15 +01:00
|
|
|
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})) {
|
2019-01-17 15:37:15 +01:00
|
|
|
markerEndingState = m.state;
|
2019-03-28 02:16:29 +01:00
|
|
|
preferences.markerEndingState = m.state;
|
2019-01-17 15:37:15 +01:00
|
|
|
}
|
|
|
|
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);
|
2019-01-16 19:12:01 +01:00
|
|
|
window.display();
|
|
|
|
}
|
2019-01-02 23:38:47 +01:00
|
|
|
|
|
|
|
ImGui::SFML::Shutdown();
|
|
|
|
return 0;
|
2017-08-17 19:10:53 +02:00
|
|
|
}
|