mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2025-02-21 20:59:46 +01:00
Marker and Marker ending state menus + selection
This commit is contained in:
parent
8ff199a7f7
commit
871cf85d9a
@ -105,7 +105,7 @@ void EditorState::setPlaybackAndMusicPosition(sf::Time newPosition) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorState::displayPlayfield() {
|
void EditorState::displayPlayfield(Marker& marker, MarkerEndingState markerEndingState) {
|
||||||
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(400,400),ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(400,400),ImGuiCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowSizeConstraints(ImVec2(0,0),ImVec2(FLT_MAX,FLT_MAX),Toolbox::CustomConstraints::ContentSquare);
|
ImGui::SetNextWindowSizeConstraints(ImVec2(0,0),ImVec2(FLT_MAX,FLT_MAX),Toolbox::CustomConstraints::ContentSquare);
|
||||||
@ -115,7 +115,7 @@ void EditorState::displayPlayfield() {
|
|||||||
if (selectedChart) {
|
if (selectedChart) {
|
||||||
int ImGuiIndex = 0;
|
int ImGuiIndex = 0;
|
||||||
for (auto note : visibleNotes) {
|
for (auto note : visibleNotes) {
|
||||||
std::optional<std::reference_wrapper<sf::Texture>> t = playfield.marker.getSprite(playfield.markerEndingState,playbackPosition.asSeconds()-getSecondsAt(note.getTiming()));
|
std::optional<std::reference_wrapper<sf::Texture>> t = marker.getSprite(markerEndingState,playbackPosition.asSeconds()-getSecondsAt(note.getTiming()));
|
||||||
if (t) {
|
if (t) {
|
||||||
int x = note.getPos()%4;
|
int x = note.getPos()%4;
|
||||||
int y = note.getPos()/4;
|
int y = note.getPos()/4;
|
||||||
@ -296,13 +296,13 @@ void EditorState::displayChartList() {
|
|||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
void EditorState::updateVisibleNotes() {
|
void EditorState::updateVisibleNotes(MarkerEndingState markerEndingState) {
|
||||||
visibleNotes.clear();
|
visibleNotes.clear();
|
||||||
|
|
||||||
if (selectedChart) {
|
if (selectedChart) {
|
||||||
|
|
||||||
float minPos;
|
float minPos;
|
||||||
if (this->playfield.markerEndingState == MISS) {
|
if (markerEndingState == MarkerEndingState_MISS) {
|
||||||
minPos = playbackPosition.asSeconds() - 8.f/30.f;
|
minPos = playbackPosition.asSeconds() - 8.f/30.f;
|
||||||
} else {
|
} else {
|
||||||
minPos = playbackPosition.asSeconds() - 16.f/30.f;
|
minPos = playbackPosition.asSeconds() - 16.f/30.f;
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
class EditorState {
|
class EditorState {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
explicit EditorState(Fumen& fumen);
|
||||||
|
|
||||||
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<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
|
||||||
Widgets::Playfield playfield;
|
Widgets::Playfield playfield;
|
||||||
@ -56,17 +59,15 @@ public:
|
|||||||
bool showNewChartDialog;
|
bool showNewChartDialog;
|
||||||
bool showChartProperties;
|
bool showChartProperties;
|
||||||
|
|
||||||
void displayPlayfield();
|
void displayPlayfield(Marker& marker, MarkerEndingState markerEndingState);
|
||||||
void displayProperties();
|
void displayProperties();
|
||||||
void displayStatus();
|
void displayStatus();
|
||||||
void displayPlaybackStatus();
|
void displayPlaybackStatus();
|
||||||
void displayTimeline();
|
void displayTimeline();
|
||||||
void displayChartList();
|
void displayChartList();
|
||||||
|
|
||||||
void updateVisibleNotes();
|
void updateVisibleNotes(MarkerEndingState markerEndingState);
|
||||||
std::vector<Note> visibleNotes;
|
std::vector<Note> visibleNotes;
|
||||||
|
|
||||||
explicit EditorState(Fumen& fumen);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ESHelper {
|
namespace ESHelper {
|
||||||
|
28
Marker.cpp
28
Marker.cpp
@ -55,23 +55,23 @@ std::optional<std::reference_wrapper<sf::Texture>> Marker::getSprite(MarkerEndin
|
|||||||
std::string frameStr = frameName.str();
|
std::string frameStr = frameName.str();
|
||||||
return textures[frameName.str()];
|
return textures[frameName.str()];
|
||||||
} else {
|
} else {
|
||||||
if (state == MISS) {
|
if (state == MarkerEndingState_MISS) {
|
||||||
if (frame >= 16 and frame <= 23) {
|
if (frame >= 16 and frame <= 23) {
|
||||||
frameName << "ma" << std::setfill('0') << std::setw(2) << frame;
|
frameName << "ma" << std::setfill('0') << std::setw(2) << frame;
|
||||||
return textures[frameName.str()];
|
return textures[frameName.str()];
|
||||||
}
|
}
|
||||||
} else if (frame >= 16 and frame <= 32) {
|
} else if (frame >= 16 and frame <= 31) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case EARLY:
|
case MarkerEndingState_EARLY:
|
||||||
frameName << "h1";
|
frameName << "h1";
|
||||||
break;
|
break;
|
||||||
case GOOD:
|
case MarkerEndingState_GOOD:
|
||||||
frameName << "h2";
|
frameName << "h2";
|
||||||
break;
|
break;
|
||||||
case GREAT:
|
case MarkerEndingState_GREAT:
|
||||||
frameName << "h3";
|
frameName << "h3";
|
||||||
break;
|
break;
|
||||||
case PERFECT:
|
case MarkerEndingState_PERFECT:
|
||||||
frameName << "h4";
|
frameName << "h4";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -84,13 +84,17 @@ std::optional<std::reference_wrapper<sf::Texture>> Marker::getSprite(MarkerEndin
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::map<std::string, sf::Texture> &Marker::getTextures() const {
|
||||||
|
return textures;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
sf::Texture Marker::getSprite(MarkerEndingState state, int frame) {
|
sf::Texture Marker::getSprite(MarkerEndingState state, int frame) {
|
||||||
|
|
||||||
int lower;
|
int lower;
|
||||||
int upper;
|
int upper;
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case MISS:
|
case MarkerEndingState_MISS:
|
||||||
lower = 16;
|
lower = 16;
|
||||||
upper = 32;
|
upper = 32;
|
||||||
break;
|
break;
|
||||||
@ -106,19 +110,19 @@ sf::Texture Marker::getSprite(MarkerEndingState state, int frame) {
|
|||||||
|
|
||||||
std::string tex_key;
|
std::string tex_key;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case MISS:
|
case MarkerEndingState_MISS:
|
||||||
tex_key += "ma";
|
tex_key += "ma";
|
||||||
break;
|
break;
|
||||||
case EARLY:
|
case MarkerEndingState_EARLY:
|
||||||
tex_key += "h1";
|
tex_key += "h1";
|
||||||
break;
|
break;
|
||||||
case GOOD:
|
case MarkerEndingState_GOOD:
|
||||||
tex_key += "h2";
|
tex_key += "h2";
|
||||||
break;
|
break;
|
||||||
case GREAT:
|
case MarkerEndingState_GREAT:
|
||||||
tex_key += "h3";
|
tex_key += "h3";
|
||||||
break;
|
break;
|
||||||
case PERFECT:
|
case MarkerEndingState_PERFECT:
|
||||||
tex_key += "h4";
|
tex_key += "h4";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
28
Marker.h
28
Marker.h
@ -12,13 +12,29 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
enum MarkerEndingState {
|
enum MarkerEndingState {
|
||||||
MISS,
|
MarkerEndingState_MISS,
|
||||||
EARLY,
|
MarkerEndingState_EARLY,
|
||||||
GOOD,
|
MarkerEndingState_GOOD,
|
||||||
GREAT,
|
MarkerEndingState_GREAT,
|
||||||
PERFECT
|
MarkerEndingState_PERFECT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MarkerStatePreview {
|
||||||
|
MarkerEndingState state;
|
||||||
|
std::string textureName;
|
||||||
|
std::string printName;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Markers {
|
||||||
|
static std::vector<MarkerStatePreview> markerStatePreviews{
|
||||||
|
{MarkerEndingState_PERFECT,"h402","PERFECT"},
|
||||||
|
{MarkerEndingState_GREAT,"h302","GREAT"},
|
||||||
|
{MarkerEndingState_GOOD,"h202","GOOD"},
|
||||||
|
{MarkerEndingState_EARLY,"h102","EARLY / LATE"},
|
||||||
|
{MarkerEndingState_MISS,"ma17","MISS"}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class Marker {
|
class Marker {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -26,6 +42,8 @@ public:
|
|||||||
Marker(std::string folder = "mk0013");
|
Marker(std::string folder = "mk0013");
|
||||||
std::optional<std::reference_wrapper<sf::Texture>> getSprite(MarkerEndingState state, float seconds);
|
std::optional<std::reference_wrapper<sf::Texture>> getSprite(MarkerEndingState state, float seconds);
|
||||||
|
|
||||||
|
const std::map<std::string, sf::Texture> &getTextures() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<std::string,sf::Texture> textures;
|
std::map<std::string,sf::Texture> textures;
|
||||||
|
@ -30,9 +30,6 @@ namespace Widgets {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Playfield();
|
Playfield();
|
||||||
|
|
||||||
Marker marker;
|
|
||||||
MarkerEndingState markerEndingState;
|
|
||||||
sf::Texture button;
|
sf::Texture button;
|
||||||
sf::Texture button_pressed;
|
sf::Texture button_pressed;
|
||||||
|
|
||||||
|
61
main.cpp
61
main.cpp
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
// TODO : Debug Log
|
||||||
// TODO : Edition des notes à la souris (mode suppression / mode ajout)
|
// TODO : Edition des notes à la souris (mode suppression / mode ajout)
|
||||||
// TODO : Marker selection
|
// TODO : Highlight des notes qui s'entrechoquent
|
||||||
// TODO : Marker ending selection
|
|
||||||
// TODO : Bruit des notes ticks
|
// TODO : Bruit des notes ticks
|
||||||
// TODO : Bruit différent si clap simple ou chord
|
// TODO : Bruit différent si clap simple ou chord
|
||||||
// TODO : Undo / Redo
|
// TODO : Undo / Redo
|
||||||
@ -55,6 +55,25 @@ int main(int argc, char** argv) {
|
|||||||
bool beatTicked = false;
|
bool beatTicked = false;
|
||||||
|
|
||||||
|
|
||||||
|
// Loading markers preview
|
||||||
|
std::map<std::string,sf::Texture> markerPreviews;
|
||||||
|
for (const auto& folder : std::filesystem::directory_iterator("assets/textures/markers")) {
|
||||||
|
if (folder.is_directory()) {
|
||||||
|
try {
|
||||||
|
sf::Texture markerPreview;
|
||||||
|
markerPreview.loadFromFile((folder/"ma15.png").string());
|
||||||
|
markerPreview.setSmooth(true);
|
||||||
|
markerPreviews.insert({folder.path().filename().string(),markerPreview});
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
// ajouter e au log
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Marker defaultMarker;
|
||||||
|
Marker& marker = defaultMarker;
|
||||||
|
MarkerEndingState markerEndingState = MarkerEndingState_MISS;
|
||||||
|
|
||||||
Widgets::Ecran_attente bg;
|
Widgets::Ecran_attente bg;
|
||||||
std::optional<EditorState> editorState;
|
std::optional<EditorState> editorState;
|
||||||
ESHelper::NewChartDialog newChartDialog;
|
ESHelper::NewChartDialog newChartDialog;
|
||||||
@ -165,7 +184,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
sf::Time delta = deltaClock.restart();
|
sf::Time delta = deltaClock.restart();
|
||||||
ImGui::SFML::Update(window, delta);
|
ImGui::SFML::Update(window, delta);
|
||||||
editorState->updateVisibleNotes();
|
editorState->updateVisibleNotes(markerEndingState);
|
||||||
|
|
||||||
// Gestion du playback
|
// Gestion du playback
|
||||||
if (editorState) {
|
if (editorState) {
|
||||||
@ -199,7 +218,6 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (playNoteTick) {
|
if (playNoteTick) {
|
||||||
int currentTick = static_cast<int>(editorState->getTicks());
|
|
||||||
for (auto note : editorState->visibleNotes) {
|
for (auto note : editorState->visibleNotes) {
|
||||||
float noteTiming = editorState->getSecondsAt(note.getTiming());
|
float noteTiming = editorState->getSecondsAt(note.getTiming());
|
||||||
if (noteTiming >= editorState->previousPos.asSeconds() and noteTiming <= editorState->playbackPosition.asSeconds()) {
|
if (noteTiming >= editorState->previousPos.asSeconds() and noteTiming <= editorState->playbackPosition.asSeconds()) {
|
||||||
@ -232,7 +250,7 @@ int main(int argc, char** argv) {
|
|||||||
window.clear(sf::Color(0, 0, 0));
|
window.clear(sf::Color(0, 0, 0));
|
||||||
|
|
||||||
if (editorState->showPlayfield) {
|
if (editorState->showPlayfield) {
|
||||||
editorState->displayPlayfield();
|
editorState->displayPlayfield(marker,markerEndingState);
|
||||||
}
|
}
|
||||||
if (editorState->showProperties) {
|
if (editorState->showProperties) {
|
||||||
editorState->displayProperties();
|
editorState->displayProperties();
|
||||||
@ -376,6 +394,39 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndMainMenuBar();
|
ImGui::EndMainMenuBar();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user