mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2025-02-20 20:41:21 +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::SetNextWindowSizeConstraints(ImVec2(0,0),ImVec2(FLT_MAX,FLT_MAX),Toolbox::CustomConstraints::ContentSquare);
|
||||
@ -115,7 +115,7 @@ void EditorState::displayPlayfield() {
|
||||
if (selectedChart) {
|
||||
int ImGuiIndex = 0;
|
||||
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) {
|
||||
int x = note.getPos()%4;
|
||||
int y = note.getPos()/4;
|
||||
@ -296,13 +296,13 @@ void EditorState::displayChartList() {
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
void EditorState::updateVisibleNotes() {
|
||||
void EditorState::updateVisibleNotes(MarkerEndingState markerEndingState) {
|
||||
visibleNotes.clear();
|
||||
|
||||
if (selectedChart) {
|
||||
|
||||
float minPos;
|
||||
if (this->playfield.markerEndingState == MISS) {
|
||||
if (markerEndingState == MarkerEndingState_MISS) {
|
||||
minPos = playbackPosition.asSeconds() - 8.f/30.f;
|
||||
} else {
|
||||
minPos = playbackPosition.asSeconds() - 16.f/30.f;
|
||||
|
@ -15,6 +15,9 @@
|
||||
class EditorState {
|
||||
|
||||
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
|
||||
Widgets::Playfield playfield;
|
||||
@ -56,17 +59,15 @@ public:
|
||||
bool showNewChartDialog;
|
||||
bool showChartProperties;
|
||||
|
||||
void displayPlayfield();
|
||||
void displayPlayfield(Marker& marker, MarkerEndingState markerEndingState);
|
||||
void displayProperties();
|
||||
void displayStatus();
|
||||
void displayPlaybackStatus();
|
||||
void displayTimeline();
|
||||
void displayChartList();
|
||||
|
||||
void updateVisibleNotes();
|
||||
void updateVisibleNotes(MarkerEndingState markerEndingState);
|
||||
std::vector<Note> visibleNotes;
|
||||
|
||||
explicit EditorState(Fumen& fumen);
|
||||
};
|
||||
|
||||
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();
|
||||
return textures[frameName.str()];
|
||||
} else {
|
||||
if (state == MISS) {
|
||||
if (state == MarkerEndingState_MISS) {
|
||||
if (frame >= 16 and frame <= 23) {
|
||||
frameName << "ma" << std::setfill('0') << std::setw(2) << frame;
|
||||
return textures[frameName.str()];
|
||||
}
|
||||
} else if (frame >= 16 and frame <= 32) {
|
||||
} else if (frame >= 16 and frame <= 31) {
|
||||
switch (state) {
|
||||
case EARLY:
|
||||
case MarkerEndingState_EARLY:
|
||||
frameName << "h1";
|
||||
break;
|
||||
case GOOD:
|
||||
case MarkerEndingState_GOOD:
|
||||
frameName << "h2";
|
||||
break;
|
||||
case GREAT:
|
||||
case MarkerEndingState_GREAT:
|
||||
frameName << "h3";
|
||||
break;
|
||||
case PERFECT:
|
||||
case MarkerEndingState_PERFECT:
|
||||
frameName << "h4";
|
||||
break;
|
||||
default:
|
||||
@ -84,13 +84,17 @@ std::optional<std::reference_wrapper<sf::Texture>> Marker::getSprite(MarkerEndin
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::map<std::string, sf::Texture> &Marker::getTextures() const {
|
||||
return textures;
|
||||
}
|
||||
|
||||
/*
|
||||
sf::Texture Marker::getSprite(MarkerEndingState state, int frame) {
|
||||
|
||||
int lower;
|
||||
int upper;
|
||||
switch(state) {
|
||||
case MISS:
|
||||
case MarkerEndingState_MISS:
|
||||
lower = 16;
|
||||
upper = 32;
|
||||
break;
|
||||
@ -106,19 +110,19 @@ sf::Texture Marker::getSprite(MarkerEndingState state, int frame) {
|
||||
|
||||
std::string tex_key;
|
||||
switch (state) {
|
||||
case MISS:
|
||||
case MarkerEndingState_MISS:
|
||||
tex_key += "ma";
|
||||
break;
|
||||
case EARLY:
|
||||
case MarkerEndingState_EARLY:
|
||||
tex_key += "h1";
|
||||
break;
|
||||
case GOOD:
|
||||
case MarkerEndingState_GOOD:
|
||||
tex_key += "h2";
|
||||
break;
|
||||
case GREAT:
|
||||
case MarkerEndingState_GREAT:
|
||||
tex_key += "h3";
|
||||
break;
|
||||
case PERFECT:
|
||||
case MarkerEndingState_PERFECT:
|
||||
tex_key += "h4";
|
||||
break;
|
||||
}
|
||||
|
28
Marker.h
28
Marker.h
@ -12,13 +12,29 @@
|
||||
#include <map>
|
||||
|
||||
enum MarkerEndingState {
|
||||
MISS,
|
||||
EARLY,
|
||||
GOOD,
|
||||
GREAT,
|
||||
PERFECT
|
||||
MarkerEndingState_MISS,
|
||||
MarkerEndingState_EARLY,
|
||||
MarkerEndingState_GOOD,
|
||||
MarkerEndingState_GREAT,
|
||||
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 {
|
||||
|
||||
public:
|
||||
@ -26,6 +42,8 @@ public:
|
||||
Marker(std::string folder = "mk0013");
|
||||
std::optional<std::reference_wrapper<sf::Texture>> getSprite(MarkerEndingState state, float seconds);
|
||||
|
||||
const std::map<std::string, sf::Texture> &getTextures() const;
|
||||
|
||||
private:
|
||||
|
||||
std::map<std::string,sf::Texture> textures;
|
||||
|
@ -30,9 +30,6 @@ namespace Widgets {
|
||||
public:
|
||||
|
||||
Playfield();
|
||||
|
||||
Marker marker;
|
||||
MarkerEndingState markerEndingState;
|
||||
sf::Texture button;
|
||||
sf::Texture button_pressed;
|
||||
|
||||
|
61
main.cpp
61
main.cpp
@ -9,9 +9,9 @@
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
// TODO : Debug Log
|
||||
// TODO : Edition des notes à la souris (mode suppression / mode ajout)
|
||||
// TODO : Marker selection
|
||||
// TODO : Marker ending selection
|
||||
// TODO : Highlight des notes qui s'entrechoquent
|
||||
// TODO : Bruit des notes ticks
|
||||
// TODO : Bruit différent si clap simple ou chord
|
||||
// TODO : Undo / Redo
|
||||
@ -55,6 +55,25 @@ int main(int argc, char** argv) {
|
||||
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;
|
||||
std::optional<EditorState> editorState;
|
||||
ESHelper::NewChartDialog newChartDialog;
|
||||
@ -165,7 +184,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
sf::Time delta = deltaClock.restart();
|
||||
ImGui::SFML::Update(window, delta);
|
||||
editorState->updateVisibleNotes();
|
||||
editorState->updateVisibleNotes(markerEndingState);
|
||||
|
||||
// Gestion du playback
|
||||
if (editorState) {
|
||||
@ -199,7 +218,6 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
if (playNoteTick) {
|
||||
int currentTick = static_cast<int>(editorState->getTicks());
|
||||
for (auto note : editorState->visibleNotes) {
|
||||
float noteTiming = editorState->getSecondsAt(note.getTiming());
|
||||
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));
|
||||
|
||||
if (editorState->showPlayfield) {
|
||||
editorState->displayPlayfield();
|
||||
editorState->displayPlayfield(marker,markerEndingState);
|
||||
}
|
||||
if (editorState->showProperties) {
|
||||
editorState->displayProperties();
|
||||
@ -376,6 +394,39 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user