F.E.I.S/src/chart_state.hpp

87 lines
2.7 KiB
C++
Raw Normal View History

#pragma once
2019-03-28 02:17:15 +01:00
2022-03-26 00:23:13 +01:00
#include <filesystem>
#include <optional>
#include <variant>
#include <utility>
2022-03-17 02:50:30 +01:00
#include "better_note.hpp"
2022-03-23 02:20:07 +01:00
#include "better_notes.hpp"
#include "better_song.hpp"
2022-03-26 00:23:13 +01:00
#include "generic_interval.hpp"
2021-12-31 14:59:39 +01:00
#include "history.hpp"
#include "history_actions.hpp"
2021-12-31 00:57:06 +01:00
#include "notes_clipboard.hpp"
#include "notifications_queue.hpp"
2021-12-31 00:57:06 +01:00
#include "widgets/density_graph.hpp"
2022-03-23 02:20:07 +01:00
using TapNotePair = std::pair<better::TapNote, better::TapNote>;
enum class NotesToggle {
Inserted,
Removed
};
struct ChartState {
ChartState(better::Chart& c, const std::string& name, std::filesystem::path assets);
better::Chart& chart;
const std::string& difficulty_name;
void cut(NotificationsQueue& nq);
void copy(NotificationsQueue& nq);
void paste(NotificationsQueue& nq, Fraction at_beat);
void delete_(NotificationsQueue& nq);
Interval<Fraction> visible_beats(const sf::Time& playback_position, const better::Timing& timing);
void update_visible_notes(const sf::Time& playback_position, const better::Timing& timing);
std::vector<better::Note> visible_notes;
void toggle_note(
const sf::Time& playback_position,
std::uint64_t snap,
const better::Position& button,
const better::Timing& timing
);
2022-03-23 02:20:07 +01:00
better::Notes selected_notes;
NotesClipboard notes_clipboard;
void handle_time_selection_tab(Fraction beats);
2022-03-26 00:23:13 +01:00
std::optional<Interval<Fraction>> time_selection;
2022-03-23 02:20:07 +01:00
/*
The long note currently being created, represented as a pair of tap notes.
Time span of the represented long note is the span between both taps
1st note's position defines the long note's position
2nd note's position suggests where the tail should start
*/
std::optional<TapNotePair> long_note_being_created;
// Is the user currently holding right click ? (over the playfield or not)
bool creating_long_note;
2019-03-28 02:17:15 +01:00
History<std::shared_ptr<ActionWithMessage>> history;
DensityGraph density_graph;
2019-03-28 02:17:15 +01:00
};
2022-03-23 02:20:07 +01:00
/*
2022-03-25 02:20:22 +01:00
Construct a note to be displayed on the playfield as a preview of the long note
currently being created. It's basically the same at the real long note being
created but its start time is set to exactly the (given) current beat so the
long note drawing routine of the playfield can be repurposed as-is for the
preview
2022-03-23 02:20:07 +01:00
*/
better::LongNote make_long_note_dummy(
Fraction current_beat,
const TapNotePair& long_note_being_created
);
// Turn the tap pair into the real long note the user wants to create
better::LongNote make_long_note(const TapNotePair& long_note_being_created);
better::Position closest_tail_position(
const better::Position& anchor,
const better::Position& requested_tail
);
better::Position smallest_possible_tail(const better::Position& anchor);