mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2024-11-14 11:07:44 +01:00
YOU CAN NOW EDIT NOTES WITH THE MOUSE
THIS MEANS WE'RE IN 0.1.0 :toot:
This commit is contained in:
parent
871cf85d9a
commit
ff55b28109
@ -134,7 +134,9 @@ void EditorState::displayPlayfield(Marker& marker, MarkerEndingState markerEndin
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(0,0,0,0));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(0,0,1.f,0.1f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(0,0,1.f,0.5f));
|
||||
ImGui::ImageButton(playfield.button,{squareSize,squareSize},0);
|
||||
if (ImGui::ImageButton(playfield.button,{squareSize,squareSize},0)) {
|
||||
toggleNoteAtCurrentTime(x+4*y);
|
||||
}
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::PopID();
|
||||
}
|
||||
@ -219,7 +221,7 @@ void EditorState::displayPlaybackStatus() {
|
||||
);
|
||||
{
|
||||
if (selectedChart) {
|
||||
ImGui::Text("%s %d",selectedChart->dif_name.c_str(),selectedChart->level); ImGui::SameLine();
|
||||
ImGui::Text("%s %d",selectedChart->get().dif_name.c_str(),selectedChart->get().level); ImGui::SameLine();
|
||||
} else {
|
||||
ImGui::TextDisabled("No chart selected"); ImGui::SameLine();
|
||||
}
|
||||
@ -283,7 +285,7 @@ void EditorState::displayChartList() {
|
||||
ImGui::TextDisabled("Note Count"); ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
for (auto tuple : fumen.Charts) {
|
||||
if (ImGui::Selectable(tuple.first.c_str(), selectedChart ? *selectedChart==tuple.second : false , ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
if (ImGui::Selectable(tuple.first.c_str(), selectedChart ? selectedChart->get()==tuple.second : false , ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
selectedChart = tuple.second;
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
@ -296,31 +298,41 @@ void EditorState::displayChartList() {
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
void EditorState::updateVisibleNotes(MarkerEndingState markerEndingState) {
|
||||
void EditorState::updateVisibleNotes() {
|
||||
visibleNotes.clear();
|
||||
|
||||
if (selectedChart) {
|
||||
|
||||
float minPos;
|
||||
if (markerEndingState == MarkerEndingState_MISS) {
|
||||
minPos = playbackPosition.asSeconds() - 8.f/30.f;
|
||||
} else {
|
||||
minPos = playbackPosition.asSeconds() - 16.f/30.f;
|
||||
}
|
||||
|
||||
float minPos = playbackPosition.asSeconds() - 16.f/30.f;
|
||||
float maxPos = playbackPosition.asSeconds() + 16.f/30.f;
|
||||
|
||||
int min_exclusive = static_cast<int>(getTicksAt(minPos));
|
||||
int max_exclusive = static_cast<int>(getTicksAt(maxPos));
|
||||
|
||||
for (auto note : selectedChart->Notes) {
|
||||
for (auto note : selectedChart->get().Notes) {
|
||||
if (note.getTiming() > min_exclusive and note.getTiming() < max_exclusive) {
|
||||
visibleNotes.push_back(note);
|
||||
visibleNotes.insert(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If a note is visible for the given pos, delete it
|
||||
* Otherwise create note at nearest tick
|
||||
*/
|
||||
void EditorState::toggleNoteAtCurrentTime(int pos) {
|
||||
if (selectedChart) {
|
||||
for (auto note : visibleNotes) {
|
||||
if (note.getPos() == pos) {
|
||||
selectedChart->get().Notes.erase(note);
|
||||
return;
|
||||
}
|
||||
}
|
||||
selectedChart->get().Notes.emplace(pos,static_cast<int>(roundf(getTicks())));
|
||||
}
|
||||
}
|
||||
|
||||
void ESHelper::save(EditorState& ed) {
|
||||
try {
|
||||
ed.fumen.autoSaveAsMemon();
|
||||
@ -445,8 +457,8 @@ void ESHelper::ChartPropertiesDialog::display(EditorState &editorState) {
|
||||
shouldRefreshValues = false;
|
||||
|
||||
difNamesInUse.clear();
|
||||
this->level = editorState.selectedChart->level;
|
||||
this->difficulty = editorState.selectedChart->dif_name;
|
||||
this->level = editorState.selectedChart->get().level;
|
||||
this->difficulty = editorState.selectedChart->get().dif_name;
|
||||
std::set<std::string> difNames{"BSC","ADV","EXT"};
|
||||
showCustomDifName = (difNames.find(difficulty) == difNames.end());
|
||||
|
||||
@ -509,9 +521,9 @@ void ESHelper::ChartPropertiesDialog::display(EditorState &editorState) {
|
||||
} else {
|
||||
if (ImGui::Button("Apply##New Chart")) {
|
||||
try {
|
||||
editorState.fumen.Charts.erase(editorState.selectedChart->dif_name);
|
||||
editorState.selectedChart->dif_name = this->difficulty;
|
||||
editorState.selectedChart->level = this->level;
|
||||
editorState.fumen.Charts.erase(editorState.selectedChart->get().dif_name);
|
||||
editorState.selectedChart->get().dif_name = this->difficulty;
|
||||
editorState.selectedChart->get().level = this->level;
|
||||
if (not (editorState.fumen.Charts.emplace(this->difficulty,editorState.selectedChart.value())).second) {
|
||||
throw std::runtime_error("Could not insert modified chart in fumen");
|
||||
} else {
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
explicit EditorState(Fumen& fumen);
|
||||
|
||||
Fumen fumen;
|
||||
std::optional<Chart> selectedChart; // Ok this was a pretty terrible design choice, be EXTRA careful about this still being in sync with what's actually in the std::map of fumen
|
||||
std::optional<std::reference_wrapper<Chart>> selectedChart;
|
||||
Widgets::Playfield playfield;
|
||||
int snap = 1;
|
||||
|
||||
@ -42,7 +42,7 @@ public:
|
||||
float getTicks() {return getTicksAt(playbackPosition.asSeconds());};
|
||||
float getTicksAt(float seconds) {return getBeatsAt(seconds) * getResolution();}
|
||||
float getSecondsAt(int tick) {return (60.f * tick)/(fumen.BPM * getResolution()) - fumen.offset;};
|
||||
int getResolution() {return selectedChart ? selectedChart->getResolution() : 240;};
|
||||
int getResolution() {return selectedChart ? selectedChart->get().getResolution() : 240;};
|
||||
int getSnapStep() {return getResolution() / snap;};
|
||||
|
||||
void reloadFromFumen();
|
||||
@ -66,8 +66,10 @@ public:
|
||||
void displayTimeline();
|
||||
void displayChartList();
|
||||
|
||||
void updateVisibleNotes(MarkerEndingState markerEndingState);
|
||||
std::vector<Note> visibleNotes;
|
||||
void updateVisibleNotes();
|
||||
std::set<Note> visibleNotes;
|
||||
|
||||
void toggleNoteAtCurrentTime(int pos);
|
||||
};
|
||||
|
||||
namespace ESHelper {
|
||||
|
2
Note.h
2
Note.h
@ -18,7 +18,7 @@ class Note {
|
||||
public:
|
||||
|
||||
|
||||
Note(int pos, int timing, int length, int trail_pos);
|
||||
Note(int pos, int timing, int length = 0, int trail_pos = 0);
|
||||
static bool trail_pos_correct(int pos,int trail_pos);
|
||||
|
||||
bool operator==(const Note &rhs) const;
|
||||
|
13
main.cpp
13
main.cpp
@ -9,12 +9,11 @@
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
// TODO : Debug Log
|
||||
// TODO : Edition des notes à la souris (mode suppression / mode ajout)
|
||||
// TODO : Highlight des notes qui s'entrechoquent
|
||||
// TODO : Undo / Redo
|
||||
// TODO : Debug Log
|
||||
// TODO : Bruit des notes ticks
|
||||
// TODO : Bruit différent si clap simple ou chord
|
||||
// TODO : Undo / Redo
|
||||
// TODO : Density graph sur la timeline
|
||||
// TODO : Système de notifs
|
||||
// TODO : Pitch control (playback speed factor)
|
||||
@ -137,12 +136,12 @@ int main(int argc, char** argv) {
|
||||
break;
|
||||
case sf::Keyboard::Left:
|
||||
if (editorState and editorState->selectedChart) {
|
||||
editorState->snap = Toolbox::getPreviousDivisor(editorState->selectedChart->getResolution(),editorState->snap);
|
||||
editorState->snap = Toolbox::getPreviousDivisor(editorState->selectedChart->get().getResolution(),editorState->snap);
|
||||
}
|
||||
break;
|
||||
case sf::Keyboard::Right:
|
||||
if (editorState and editorState->selectedChart) {
|
||||
editorState->snap = Toolbox::getNextDivisor(editorState->selectedChart->getResolution(),editorState->snap);
|
||||
editorState->snap = Toolbox::getNextDivisor(editorState->selectedChart->get().getResolution(),editorState->snap);
|
||||
}
|
||||
break;
|
||||
case sf::Keyboard::F3:
|
||||
@ -184,7 +183,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
sf::Time delta = deltaClock.restart();
|
||||
ImGui::SFML::Update(window, delta);
|
||||
editorState->updateVisibleNotes(markerEndingState);
|
||||
editorState->updateVisibleNotes();
|
||||
|
||||
// Gestion du playback
|
||||
if (editorState) {
|
||||
@ -374,7 +373,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Delete Chart",nullptr,false,editorState->selectedChart.has_value())) {
|
||||
editorState->fumen.Charts.erase(editorState->selectedChart->dif_name);
|
||||
editorState->fumen.Charts.erase(editorState->selectedChart->get().dif_name);
|
||||
editorState->selectedChart.reset();
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
|
Loading…
Reference in New Issue
Block a user