2017-08-17 19:10:53 +02:00
|
|
|
#include <SFML/Graphics.hpp>
|
2019-01-02 23:38:47 +01:00
|
|
|
#include <imgui.h>
|
|
|
|
#include <imgui-SFML.h>
|
2019-01-03 23:20:35 +01:00
|
|
|
#include <imgui_stdlib.h>
|
2019-01-13 22:29:29 +01:00
|
|
|
#include "Widgets.h"
|
2019-01-02 23:38:47 +01:00
|
|
|
#include "EditorState.h"
|
2019-01-03 23:20:35 +01:00
|
|
|
#include "tinyfiledialogs.h"
|
2019-01-13 03:53:42 +01:00
|
|
|
#include "Toolbox.h"
|
2017-08-17 19:10:53 +02:00
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
2019-03-02 14:27:36 +01:00
|
|
|
// TODO : Highlight crossing notes
|
|
|
|
// TODO : Different noise for chords
|
|
|
|
// TODO : Density graph on the timeline
|
|
|
|
// TODO : Notification System
|
2019-01-17 01:08:38 +01:00
|
|
|
// TODO : Pitch control (playback speed factor)
|
2019-03-02 14:27:36 +01:00
|
|
|
// TODO : A small preference persistency system (marker , etc ...)
|
|
|
|
// TODO : Debug Log
|
2019-01-16 01:59:02 +01:00
|
|
|
|
2019-01-16 19:12:01 +01:00
|
|
|
// Création de la fenêtre
|
|
|
|
sf::RenderWindow window(sf::VideoMode(800, 600), "FEIS");
|
|
|
|
sf::RenderWindow & ref_window = window;
|
|
|
|
window.setVerticalSyncEnabled(true);
|
|
|
|
window.setFramerateLimit(60);
|
2019-01-12 17:16:20 +01:00
|
|
|
|
|
|
|
ImGui::SFML::Init(window, false);
|
|
|
|
|
|
|
|
ImGuiIO& IO = ImGui::GetIO();
|
|
|
|
IO.Fonts->Clear();
|
|
|
|
IO.Fonts->AddFontFromFileTTF("assets/fonts/NotoSans-Medium.ttf", 16.f);
|
|
|
|
ImGui::SFML::UpdateFontTexture();
|
|
|
|
|
2019-01-14 21:43:56 +01:00
|
|
|
std::string noteTickPath = "assets/sounds/sound note tick.wav";
|
|
|
|
sf::SoundBuffer noteTick;
|
|
|
|
if (!noteTick.loadFromFile(noteTickPath)) {
|
|
|
|
std::cerr << "Unable to load sound " << noteTickPath;
|
|
|
|
throw std::runtime_error("Unable to load sound " + noteTickPath);
|
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
sf::Sound noteTickSound(noteTick);
|
2019-01-17 01:08:38 +01:00
|
|
|
int noteTickVolume = 10;
|
|
|
|
bool playNoteTick = false;
|
2019-02-09 06:26:57 +01:00
|
|
|
int lastTickTicked = -1;
|
2017-08-17 19:10:53 +02:00
|
|
|
|
2019-01-14 21:43:56 +01:00
|
|
|
std::string beatTickPath = "assets/sounds/sound beat tick.wav";
|
|
|
|
sf::SoundBuffer beatTick;
|
|
|
|
if (!beatTick.loadFromFile(beatTickPath)) {
|
|
|
|
std::cerr << "Unable to load sound " << beatTickPath;
|
|
|
|
throw std::runtime_error("Unable to load sound " + beatTickPath);
|
|
|
|
}
|
|
|
|
sf::Sound beatTickSound(beatTick);
|
2019-01-17 01:08:38 +01:00
|
|
|
int beatTickVolume = 10;
|
|
|
|
bool playBeatTick = false;
|
2019-01-17 03:02:37 +01:00
|
|
|
bool beatTicked = false;
|
2019-01-14 21:43:56 +01:00
|
|
|
|
|
|
|
|
2019-01-17 15:37:15 +01:00
|
|
|
// Loading markers preview
|
2019-01-18 01:55:41 +01:00
|
|
|
std::map<std::filesystem::path,sf::Texture> markerPreviews;
|
2019-01-17 15:37:15 +01:00
|
|
|
for (const auto& folder : std::filesystem::directory_iterator("assets/textures/markers")) {
|
|
|
|
if (folder.is_directory()) {
|
2019-01-19 17:12:41 +01:00
|
|
|
sf::Texture markerPreview;
|
|
|
|
markerPreview.loadFromFile((folder/"ma15.png").string());
|
|
|
|
markerPreview.setSmooth(true);
|
|
|
|
markerPreviews.insert({folder,markerPreview});
|
2019-01-17 15:37:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Marker defaultMarker;
|
|
|
|
Marker& marker = defaultMarker;
|
|
|
|
MarkerEndingState markerEndingState = MarkerEndingState_MISS;
|
|
|
|
|
2019-01-16 19:12:01 +01:00
|
|
|
Widgets::Ecran_attente bg;
|
|
|
|
std::optional<EditorState> editorState;
|
|
|
|
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-01-12 03:13:30 +01:00
|
|
|
window.close();
|
2019-01-16 19:12:01 +01:00
|
|
|
break;
|
|
|
|
case sf::Event::Resized:
|
2019-01-12 03:13:30 +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;
|
|
|
|
case sf::Event::KeyPressed:
|
|
|
|
switch (event.key.code) {
|
2019-01-17 01:08:38 +01:00
|
|
|
case sf::Keyboard::Up:
|
|
|
|
if (event.key.shift) {
|
|
|
|
if (editorState) {
|
|
|
|
if (editorState->musicVolume < 10) {
|
|
|
|
editorState->musicVolume++;
|
|
|
|
editorState->updateMusicVolume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2019-03-02 13:47:26 +01:00
|
|
|
if (editorState and editorState->chart) {
|
2019-01-17 01:08:38 +01:00
|
|
|
float floatTicks = editorState->getTicks();
|
|
|
|
int prevTick = static_cast<int>(floorf(floatTicks));
|
|
|
|
int step = editorState->getSnapStep();
|
|
|
|
int prevTickInSnap = prevTick;
|
|
|
|
if (prevTick%step == 0) {
|
|
|
|
prevTickInSnap -= step;
|
|
|
|
} else {
|
|
|
|
prevTickInSnap -= prevTick%step;
|
|
|
|
}
|
|
|
|
editorState->setPlaybackAndMusicPosition(sf::seconds(editorState->getSecondsAt(prevTickInSnap)));
|
|
|
|
}
|
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) {
|
|
|
|
if (editorState) {
|
|
|
|
if (editorState->musicVolume > 0) {
|
|
|
|
editorState->musicVolume--;
|
|
|
|
editorState->updateMusicVolume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2019-03-02 13:47:26 +01:00
|
|
|
if (editorState and editorState->chart) {
|
2019-01-17 01:08:38 +01:00
|
|
|
float floatTicks = editorState->getTicks();
|
|
|
|
int nextTick = static_cast<int>(ceilf(floatTicks));
|
|
|
|
int step = editorState->getSnapStep();
|
|
|
|
int nextTickInSnap = nextTick + (step - nextTick%step);
|
|
|
|
editorState->setPlaybackAndMusicPosition(sf::seconds(editorState->getSecondsAt(nextTickInSnap)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::Left:
|
2019-03-02 13:47:26 +01:00
|
|
|
if (editorState and editorState->chart) {
|
|
|
|
editorState->snap = Toolbox::getPreviousDivisor(editorState->chart->ref.getResolution(),editorState->snap);
|
2019-01-17 01:08:38 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::Right:
|
2019-03-02 13:47:26 +01:00
|
|
|
if (editorState and editorState->chart) {
|
|
|
|
editorState->snap = Toolbox::getNextDivisor(editorState->chart->ref.getResolution(),editorState->snap);
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-01-17 01:08:38 +01:00
|
|
|
case sf::Keyboard::F3:
|
|
|
|
playBeatTick = not playBeatTick;
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::F4:
|
|
|
|
playNoteTick = not playNoteTick;
|
|
|
|
break;
|
2019-01-16 19:12:01 +01:00
|
|
|
case sf::Keyboard::Space:
|
|
|
|
if (not ImGui::GetIO().WantTextInput) {
|
|
|
|
if (editorState) {
|
|
|
|
editorState->playing = not editorState->playing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-01-16 22:10:20 +01:00
|
|
|
case sf::Keyboard::O:
|
|
|
|
if (event.key.control) {
|
|
|
|
ESHelper::open(editorState);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::P:
|
|
|
|
if (event.key.shift) {
|
|
|
|
editorState->showProperties = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::S:
|
|
|
|
if (event.key.control) {
|
|
|
|
ESHelper::save(*editorState);
|
|
|
|
}
|
|
|
|
break;
|
2019-03-02 13:47:26 +01:00
|
|
|
case sf::Keyboard::Y:
|
|
|
|
if (event.key.control) {
|
|
|
|
if (editorState and editorState->chart) {
|
|
|
|
auto next = editorState->chart->history.get_next();
|
|
|
|
if (next) {
|
|
|
|
(*next)->doAction(*editorState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Keyboard::Z:
|
|
|
|
if (event.key.control) {
|
|
|
|
if (editorState and editorState->chart) {
|
|
|
|
auto previous = editorState->chart->history.get_previous();
|
|
|
|
if (previous) {
|
|
|
|
(*previous)->undoAction(*editorState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
2019-01-17 03:02:37 +01:00
|
|
|
if (editorState) {
|
2019-01-18 01:25:29 +01:00
|
|
|
editorState->updateVisibleNotes();
|
2019-01-17 03:02:37 +01:00
|
|
|
if (editorState->playing) {
|
|
|
|
editorState->previousPos = editorState->playbackPosition;
|
|
|
|
editorState->playbackPosition += delta;
|
|
|
|
if (editorState->music) {
|
|
|
|
switch(editorState->music->getStatus()) {
|
|
|
|
case sf::Music::Stopped:
|
|
|
|
case sf::Music::Paused:
|
|
|
|
if (editorState->playbackPosition.asSeconds() >= 0 and editorState->playbackPosition < editorState->music->getDuration()) {
|
|
|
|
editorState->music->setPlayingOffset(editorState->playbackPosition);
|
|
|
|
editorState->music->play();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case sf::Music::Playing:
|
|
|
|
editorState->playbackPosition = editorState->music->getPlayingOffset();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (playBeatTick) {
|
|
|
|
if (fmodf(editorState->getBeats(),1.f) < 0.5) {
|
|
|
|
if (not beatTicked) {
|
|
|
|
beatTickSound.play();
|
|
|
|
beatTicked = true;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2019-01-17 03:02:37 +01:00
|
|
|
} else {
|
|
|
|
beatTicked = false;
|
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2019-01-17 03:02:37 +01:00
|
|
|
if (playNoteTick) {
|
|
|
|
for (auto note : editorState->visibleNotes) {
|
|
|
|
float noteTiming = editorState->getSecondsAt(note.getTiming());
|
2019-02-09 06:26:57 +01:00
|
|
|
if (noteTiming >= editorState->previousPos.asSeconds()
|
|
|
|
and noteTiming <= editorState->playbackPosition.asSeconds()
|
|
|
|
and note.getTiming() > editorState->lastTimingTicked) {
|
|
|
|
noteTickSound.play();
|
|
|
|
editorState->lastTimingTicked = note.getTiming();
|
2019-01-17 03:02:37 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-09 06:26:57 +01:00
|
|
|
} else {
|
|
|
|
editorState->lastTimingTicked = -1;
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2019-01-17 03:02:37 +01:00
|
|
|
if (editorState->playbackPosition >= editorState->chartRuntime) {
|
|
|
|
editorState->playing = false;
|
|
|
|
editorState->playbackPosition = editorState->chartRuntime;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (editorState->music) {
|
|
|
|
if (editorState->music->getStatus() == sf::Music::Playing) {
|
|
|
|
editorState->music->pause();
|
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-02 13:47:26 +01:00
|
|
|
// Drawing
|
2019-01-16 19:12:01 +01:00
|
|
|
if (editorState) {
|
2019-01-14 21:43:56 +01:00
|
|
|
|
2019-01-16 19:12:01 +01:00
|
|
|
window.clear(sf::Color(0, 0, 0));
|
2019-01-03 23:20:35 +01:00
|
|
|
|
2019-03-02 13:47:26 +01:00
|
|
|
if (editorState->showHistory) {
|
|
|
|
editorState->chart->history.display(print_history_message);
|
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
if (editorState->showPlayfield) {
|
2019-01-17 15:37:15 +01:00
|
|
|
editorState->displayPlayfield(marker,markerEndingState);
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
if (editorState->showProperties) {
|
|
|
|
editorState->displayProperties();
|
|
|
|
}
|
|
|
|
if (editorState->showStatus) {
|
|
|
|
editorState->displayStatus();
|
2019-01-17 01:08:38 +01:00
|
|
|
ImGui::Begin("Status");
|
|
|
|
{
|
|
|
|
ImGui::Checkbox("Beat Tick",&playBeatTick); ImGui::SameLine();
|
|
|
|
if (ImGui::SliderInt("Beat Tick Volume",&beatTickVolume,0,10)) {
|
|
|
|
Toolbox::updateVolume(beatTickSound,beatTickVolume);
|
|
|
|
}
|
|
|
|
ImGui::Checkbox("Note Tick",&playNoteTick); ImGui::SameLine();
|
|
|
|
if (ImGui::SliderInt("Note Tick Volume",¬eTickVolume,0,10)) {
|
|
|
|
Toolbox::updateVolume(noteTickSound,noteTickVolume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::End();
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
2019-01-12 17:16:20 +01:00
|
|
|
if (editorState->showPlaybackStatus) {
|
|
|
|
editorState->displayPlaybackStatus();
|
|
|
|
}
|
2019-01-13 03:53:42 +01:00
|
|
|
if (editorState->showTimeline) {
|
|
|
|
editorState->displayTimeline();
|
2019-01-16 01:59:02 +01:00
|
|
|
}
|
|
|
|
if (editorState->showChartList) {
|
2019-01-16 19:12:01 +01:00
|
|
|
editorState->displayChartList();
|
2019-01-16 01:59:02 +01:00
|
|
|
}
|
|
|
|
if (editorState->showNewChartDialog) {
|
2019-01-16 19:12:01 +01:00
|
|
|
std::optional<Chart> c = newChartDialog.display(*editorState);
|
|
|
|
if (c) {
|
|
|
|
editorState->showNewChartDialog = false;
|
2019-01-17 01:08:38 +01:00
|
|
|
if(editorState->fumen.Charts.try_emplace(c->dif_name,*c).second) {
|
2019-03-02 13:47:26 +01:00
|
|
|
editorState->chart->ref = editorState->fumen.Charts[c->dif_name];
|
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
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
if (editorState->showChartProperties) {
|
|
|
|
chartPropertiesDialog.display(*editorState);
|
|
|
|
} else {
|
|
|
|
chartPropertiesDialog.shouldRefreshValues = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bg.render(window);
|
|
|
|
}
|
2019-01-02 23:38:47 +01:00
|
|
|
|
2019-01-16 19:12:01 +01:00
|
|
|
// Dessin de l'interface
|
|
|
|
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")) {
|
2019-01-12 03:13:30 +01:00
|
|
|
const char* _filepath = tinyfd_saveFileDialog("New File",nullptr,0,nullptr,nullptr);
|
2019-01-05 00:07:52 +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 {
|
2019-01-12 03:13:30 +01:00
|
|
|
Fumen f(filepath);
|
|
|
|
f.autoSaveAsMemon();
|
2019-01-05 00:07:52 +01:00
|
|
|
editorState.emplace(f);
|
2019-01-13 03:53:42 +01:00
|
|
|
Toolbox::pushNewRecentFile(std::filesystem::canonical(editorState->fumen.path));
|
2019-01-05 00:07:52 +01:00
|
|
|
} catch (const std::exception& e) {
|
|
|
|
tinyfd_messageBox("Error",e.what(),"ok","error",1);
|
|
|
|
}
|
|
|
|
}
|
2019-01-03 23:20:35 +01:00
|
|
|
}
|
|
|
|
ImGui::Separator();
|
2019-01-16 19:12:01 +01:00
|
|
|
if (ImGui::MenuItem("Open","Ctrl+O")) {
|
2019-01-13 22:29:29 +01:00
|
|
|
ESHelper::open(editorState);
|
2019-01-03 23:20:35 +01:00
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
if (ImGui::BeginMenu("Recent Files")) {
|
|
|
|
int i = 0;
|
|
|
|
for (const auto& file : Toolbox::getRecentFiles()) {
|
2019-01-13 03:53:42 +01:00
|
|
|
ImGui::PushID(i);
|
|
|
|
if (ImGui::MenuItem(file.c_str())) {
|
2019-01-13 22:29:29 +01:00
|
|
|
ESHelper::openFromFile(editorState,file);
|
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();
|
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("Close","",false,editorState.has_value())) {
|
|
|
|
editorState.reset();
|
|
|
|
}
|
|
|
|
ImGui::Separator();
|
|
|
|
if (ImGui::MenuItem("Save","Ctrl+S",false,editorState.has_value())) {
|
2019-01-13 22:29:29 +01:00
|
|
|
ESHelper::save(*editorState);
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("Save As","",false,editorState.has_value())) {
|
2019-01-03 23:20:35 +01:00
|
|
|
char const * options[1] = {"*.memon"};
|
|
|
|
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) {
|
|
|
|
tinyfd_messageBox("Error",e.what(),"ok","error",1);
|
|
|
|
}
|
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();
|
|
|
|
if (ImGui::MenuItem("Properties","Shift+P",false,editorState.has_value())) {
|
|
|
|
editorState->showProperties = true;
|
|
|
|
}
|
2019-01-16 19:12:01 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2019-01-03 23:20:35 +01:00
|
|
|
if (ImGui::BeginMenu("Edit")) {
|
2019-01-12 03:13:30 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2019-01-16 01:59:02 +01:00
|
|
|
if (ImGui::BeginMenu("Chart",editorState.has_value())) {
|
2019-01-16 19:12:01 +01:00
|
|
|
if (ImGui::MenuItem("Chart List")) {
|
|
|
|
editorState->showChartList = true;
|
|
|
|
}
|
2019-03-02 13:47:26 +01:00
|
|
|
if (ImGui::MenuItem("Properties##Chart",nullptr,false,editorState->chart.has_value())) {
|
2019-01-16 19:12:01 +01:00
|
|
|
editorState->showChartProperties = true;
|
|
|
|
}
|
|
|
|
ImGui::Separator();
|
|
|
|
if (ImGui::MenuItem("New Chart")) {
|
|
|
|
editorState->showNewChartDialog = true;
|
|
|
|
}
|
|
|
|
ImGui::Separator();
|
2019-03-02 13:47:26 +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();
|
2019-01-16 19:12:01 +01:00
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
2019-01-16 01:59:02 +01:00
|
|
|
}
|
2019-01-12 03:13:30 +01:00
|
|
|
if (ImGui::BeginMenu("View",editorState.has_value())) {
|
2019-01-13 22:29:29 +01:00
|
|
|
if (ImGui::MenuItem("Playfield", nullptr,editorState->showPlayfield)) {
|
|
|
|
editorState->showPlayfield = not editorState->showPlayfield;
|
2019-01-12 17:16:20 +01:00
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("Playback Status",nullptr,editorState->showPlaybackStatus)) {
|
2019-01-13 03:53:42 +01:00
|
|
|
editorState->showPlaybackStatus = not editorState->showPlaybackStatus;
|
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("Timeline",nullptr,editorState->showTimeline)) {
|
|
|
|
editorState->showTimeline = not editorState->showTimeline;
|
2019-01-03 23:20:35 +01:00
|
|
|
}
|
2019-01-13 22:29:29 +01:00
|
|
|
if (ImGui::MenuItem("Editor Status",nullptr,editorState->showStatus)) {
|
|
|
|
editorState->showStatus = not editorState->showStatus;
|
|
|
|
}
|
2019-03-02 13:47:26 +01:00
|
|
|
if (ImGui::MenuItem("History",nullptr,editorState->showHistory)) {
|
|
|
|
editorState->showHistory = not editorState->showHistory;
|
|
|
|
}
|
2019-01-03 23:20:35 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2019-01-17 15:37:15 +01:00
|
|
|
if (ImGui::BeginMenu("Settings",editorState.has_value())) {
|
|
|
|
if (ImGui::BeginMenu("Marker")) {
|
|
|
|
int i = 0;
|
|
|
|
for (auto& tuple : markerPreviews) {
|
|
|
|
ImGui::PushID(tuple.first.c_str());
|
|
|
|
if (ImGui::ImageButton(tuple.second,{100,100})) {
|
|
|
|
try {
|
|
|
|
marker = Marker(tuple.first);
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
tinyfd_messageBox("Error",e.what(),"ok","error",1);
|
|
|
|
marker = defaultMarker;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
i++;
|
|
|
|
if (i%4 != 0) {
|
|
|
|
ImGui::SameLine();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
if (ImGui::BeginMenu("Marker Ending State")) {
|
|
|
|
for (auto& m : Markers::markerStatePreviews) {
|
|
|
|
if (ImGui::ImageButton(marker.getTextures().at(m.textureName),{100,100})) {
|
|
|
|
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);
|
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
|
|
|
}
|