forked from NaiJi/project-kyoku
Remove ticks as a concept from Editor
This commit is contained in:
parent
0cf711db94
commit
bb1bb88085
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
bool insertBPMSection(BPMSection&& section)
|
||||
{
|
||||
return _bpm_sections.insert(std::move(section)).second;
|
||||
return _bpm_sections.insert(section).second;
|
||||
}
|
||||
|
||||
bool removeBPMSectionAt(const microsec& offset)
|
||||
|
@ -78,5 +78,4 @@ public:
|
|||
|
||||
protected:
|
||||
std::set<BPMSection, BPMSectionCompt> _bpm_sections;
|
||||
std::set<microsec> _ticks;
|
||||
};
|
||||
|
|
|
@ -8,69 +8,17 @@ ClassicEditor::ClassicEditor(std::shared_ptr<ClassicGraphicsManager>&& manager)
|
|||
{
|
||||
_context.graphics_manager = _graphics_manager;
|
||||
|
||||
int basic_offset = 500000 * 6;
|
||||
std::set<MockClassicNote*, NotePtrCompt> set = {};
|
||||
|
||||
std::set<MockClassicNote*, NotePtrCompt> _set = {};
|
||||
|
||||
NoteInitializer init;
|
||||
init.context = &_context;
|
||||
init.intervals = {};
|
||||
init.perfect_offset = basic_offset + (500000 * 20);
|
||||
|
||||
ElementInitializer elem_init;
|
||||
elem_init.type = _selected_type;
|
||||
elem_init.coordinates = Coordinates{ 700 - (5 * 120), 550 };
|
||||
elem_init.falling_curve_interpolation = {};
|
||||
|
||||
MockArrowNoteInitializer mock_init;
|
||||
mock_init.elements = {elem_init};
|
||||
mock_init.initializer = init;
|
||||
_set.insert(new MockClassicNote(std::move(mock_init)));
|
||||
|
||||
_timeline.setNotes(_set, 1648648);
|
||||
_timeline.setNotes(set, 1648648);
|
||||
}
|
||||
|
||||
microsec ClassicEditor::adjustOffset(microsec offset) const noexcept
|
||||
{
|
||||
microsec left = -1;
|
||||
microsec right = -1;
|
||||
const auto& section = getBPMSectionAt(offset);
|
||||
const microsec actual_offset = offset - section.offset_start;
|
||||
|
||||
std::set<microsec>::iterator i;
|
||||
|
||||
for (i = _ticks.begin(); i != _ticks.end(); ++i)
|
||||
{
|
||||
if (*i >= offset)
|
||||
{
|
||||
right = *i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (; i != _ticks.end(); --i)
|
||||
{
|
||||
if (*i <= offset)
|
||||
{
|
||||
left = *i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (right == -1)
|
||||
offset = left;
|
||||
else if (left == -1)
|
||||
offset = right;
|
||||
else
|
||||
{
|
||||
const microsec right_distance = right - offset;
|
||||
const microsec left_distance = offset - left;
|
||||
|
||||
offset = (right_distance > left_distance)
|
||||
? left_distance
|
||||
: right_distance;
|
||||
}
|
||||
|
||||
|
||||
return offset;
|
||||
return actual_offset + (actual_offset % section.interval);
|
||||
}
|
||||
|
||||
void ClassicEditor::input(PlayerInput&& inputdata)
|
||||
|
@ -87,7 +35,7 @@ void ClassicEditor::input(PlayerInput&& inputdata)
|
|||
case sf::Event::MouseButtonPressed:
|
||||
{
|
||||
const auto note = _timeline.getNoteBy(_current_time);
|
||||
if (_timeline.isExpired(note) && !_ticks.empty())
|
||||
if (_timeline.isExpired(note) && !_bpm_sections.empty() && _current_time >= (*_bpm_sections.begin()).offset_start)
|
||||
{
|
||||
NoteInitializer init;
|
||||
init.context = &_context;
|
||||
|
|
|
@ -38,7 +38,7 @@ void EditorState::draw() const
|
|||
|
||||
void EditorState::enter()
|
||||
{
|
||||
_music.openFromFile("Uta-test.flac");
|
||||
_music.openFromFile("METEOR.flac");
|
||||
_music.setVolume(5);
|
||||
|
||||
auto& group = _group;
|
||||
|
@ -72,7 +72,9 @@ void EditorState::enter()
|
|||
button_apply->setCallback([&editor, bpm_calculator]()
|
||||
{
|
||||
BPMSection section;
|
||||
section.bpm = bpm_calculator->fetchApproximatedInfo().BPM;
|
||||
const auto& info = bpm_calculator->fetchApproximatedInfo();
|
||||
section.bpm = info.BPM;
|
||||
section.interval = info.interval;
|
||||
section.fraction = 2;
|
||||
section.offset_start = bpm_calculator->getStartingOffset();
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void BPMCalculatorWidget::setRect(const sf::FloatRect& rect)
|
|||
_window_content.getGlobalBounds().top + _window_content.getGlobalBounds().height - 40});
|
||||
|
||||
_button_apply->setRect(sf::FloatRect{0, 0, rect.width / 10 * 3, 30});
|
||||
_button_apply->setPosition({_window_content.getGlobalBounds().left + 20 + (2 * (rect.width / 7)),
|
||||
_button_apply->setPosition({_window_content.getGlobalBounds().left + 50 + (2 * (rect.width / 7)),
|
||||
_window_content.getGlobalBounds().top + _window_content.getGlobalBounds().height - 40});
|
||||
|
||||
_bpm_value.setPosition({_window_content.getGlobalBounds().left + rect.width / 8,
|
||||
|
|
Loading…
Reference in New Issue