refactor(codestyle): Add clang-format and re-format all existing files
parent
ea71de96b5
commit
d6818bbd2f
@ -0,0 +1,18 @@
|
|||||||
|
IndentWidth: 4
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignArrayOfStructures: Right
|
||||||
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: true
|
||||||
|
AfterControlStatement: true
|
||||||
|
AfterEnum: true
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterObjCDeclaration: true
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: true
|
||||||
|
BeforeCatch: true
|
||||||
|
BeforeElse: true
|
||||||
|
IndentBraces: true
|
@ -1,44 +1,53 @@
|
|||||||
#include "classicmode/classicfactory.h"
|
#include "classicmode/classicfactory.h"
|
||||||
|
|
||||||
|
#include "graphics/classicgraphicsfactory.h"
|
||||||
#include "graphics/classicscenegraphicsmanager.h"
|
#include "graphics/classicscenegraphicsmanager.h"
|
||||||
#include "graphics/classictimelinegraphicsmanager.h"
|
#include "graphics/classictimelinegraphicsmanager.h"
|
||||||
#include "graphics/classicgraphicsfactory.h"
|
|
||||||
|
|
||||||
#include "core/timeline.h"
|
#include "core/timeline.h"
|
||||||
#include "game/classicgame.h"
|
|
||||||
#include "game/gamecontext.h"
|
|
||||||
#include "game/holdmanager.h"
|
|
||||||
#include "editor/classiceditor.h"
|
#include "editor/classiceditor.h"
|
||||||
#include "editor/editorcontext.h"
|
#include "editor/editorcontext.h"
|
||||||
#include "editor/selectionmanager.h"
|
#include "editor/selectionmanager.h"
|
||||||
|
#include "game/classicgame.h"
|
||||||
|
#include "game/gamecontext.h"
|
||||||
|
#include "game/holdmanager.h"
|
||||||
|
|
||||||
|
std::unique_ptr<kku::Game>
|
||||||
std::unique_ptr<kku::Game> classic::getGame(const std::shared_ptr<kku::CoreFactory>& core_factory)
|
classic::getGame(const std::shared_ptr<kku::CoreFactory> &core_factory)
|
||||||
{
|
{
|
||||||
const kku::microsec visibility_offset = 1648648;
|
const kku::microsec visibility_offset = 1648648;
|
||||||
|
|
||||||
const auto factory = std::make_shared<ClassicGraphicsFactory>(core_factory);
|
const auto factory = std::make_shared<ClassicGraphicsFactory>(core_factory);
|
||||||
const auto timeline = std::make_shared<kku::Timeline<ClassicNote>>();
|
const auto timeline = std::make_shared<kku::Timeline<ClassicNote>>();
|
||||||
const auto graphics_manager = std::make_shared<ClassicSceneGraphicsManager>(timeline, factory, visibility_offset);
|
const auto graphics_manager = std::make_shared<ClassicSceneGraphicsManager>(
|
||||||
|
timeline, factory, visibility_offset);
|
||||||
const auto hold_manager = std::make_shared<HoldManager>();
|
const auto hold_manager = std::make_shared<HoldManager>();
|
||||||
|
|
||||||
const auto context = std::make_shared<GameContext>(hold_manager, graphics_manager);
|
const auto context =
|
||||||
|
std::make_shared<GameContext>(hold_manager, graphics_manager);
|
||||||
|
|
||||||
return std::make_unique<ClassicGame>(timeline, context);
|
return std::make_unique<ClassicGame>(timeline, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<kku::Editor> classic::getEditor(const std::shared_ptr<kku::CoreFactory>& core_factory)
|
std::unique_ptr<kku::Editor>
|
||||||
|
classic::getEditor(const std::shared_ptr<kku::CoreFactory> &core_factory)
|
||||||
{
|
{
|
||||||
const kku::microsec visibility_offset = 1648648;
|
const kku::microsec visibility_offset = 1648648;
|
||||||
|
|
||||||
const auto factory = std::make_shared<ClassicGraphicsFactory>(core_factory);
|
const auto factory = std::make_shared<ClassicGraphicsFactory>(core_factory);
|
||||||
const auto timeline = std::make_shared<kku::Timeline<ClassicNote>>();
|
const auto timeline = std::make_shared<kku::Timeline<ClassicNote>>();
|
||||||
const auto selection_manager = std::make_shared<SelectionManager<ClassicNote>>();
|
const auto selection_manager =
|
||||||
|
std::make_shared<SelectionManager<ClassicNote>>();
|
||||||
std::vector<std::shared_ptr<ClassicGraphicsManager>> graphics_managers;
|
std::vector<std::shared_ptr<ClassicGraphicsManager>> graphics_managers;
|
||||||
graphics_managers.emplace_back(std::make_shared<ClassicSceneGraphicsManager>(timeline, factory, visibility_offset));
|
graphics_managers.emplace_back(
|
||||||
graphics_managers.emplace_back(std::make_shared<ClassicTimelineGraphicsManager>(timeline, factory, visibility_offset * 2));
|
std::make_shared<ClassicSceneGraphicsManager>(timeline, factory,
|
||||||
|
visibility_offset));
|
||||||
const auto context = std::make_shared<EditorContext>(selection_manager, std::move(graphics_managers));
|
graphics_managers.emplace_back(
|
||||||
|
std::make_shared<ClassicTimelineGraphicsManager>(
|
||||||
|
timeline, factory, visibility_offset * 2));
|
||||||
|
|
||||||
|
const auto context = std::make_shared<EditorContext>(
|
||||||
|
selection_manager, std::move(graphics_managers));
|
||||||
|
|
||||||
return std::make_unique<ClassicEditor>(timeline, context);
|
return std::make_unique<ClassicEditor>(timeline, context);
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,21 @@
|
|||||||
#include "tools/beatutils.h"
|
#include "tools/beatutils.h"
|
||||||
#include <numeric>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
auto beat_utils::calculateBeatRateInfo(const std::vector<kku::microsec>& approximate_deltas) -> BeatInfo
|
auto beat_utils::calculateBeatRateInfo(
|
||||||
|
const std::vector<kku::microsec> &approximate_deltas) -> BeatInfo
|
||||||
{
|
{
|
||||||
if (approximate_deltas.empty())
|
if (approximate_deltas.empty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const long double sum = std::accumulate(approximate_deltas.begin(), approximate_deltas.end(), 0);
|
const long double sum = std::accumulate(approximate_deltas.begin(),
|
||||||
|
approximate_deltas.end(), 0);
|
||||||
const long double amount = approximate_deltas.size();
|
const long double amount = approximate_deltas.size();
|
||||||
|
|
||||||
long double average = sum / amount;
|
long double average = sum / amount;
|
||||||
|
|
||||||
const int bpm = static_cast<int>(60000000. / average);
|
const int bpm = static_cast<int>(60000000. / average);
|
||||||
|
|
||||||
|
return BeatInfo{bpm, static_cast<kku::microsec>(
|
||||||
return BeatInfo
|
1. / static_cast<long double>(bpm) * 60000000.)};
|
||||||
{
|
|
||||||
bpm,
|
|
||||||
static_cast<kku::microsec>(1. / static_cast<long double>(bpm) * 60000000.)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue