Skip to content

Commit 3de9212

Browse files
authored
Merge pull request #80 from mimaraka/develop
v2.0-beta1.2
2 parents 0c2c638 + 21cd955 commit 3de9212

File tree

95 files changed

+1405
-968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1405
-968
lines changed

curve_editor/config.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,16 @@ namespace curve_editor::global {
4040
::GetModuleFileNameA(util::get_hinst(), path_str, MAX_PATH);
4141
std::filesystem::path path_plugin{ path_str };
4242
dir_plugin_ = path_plugin.parent_path() / global::PLUGIN_NAME;
43+
44+
load_json();
4345
}
4446

4547
bool Config::set_language(Language language) noexcept {
46-
switch (language) {
47-
case Language::Automatic:
48-
case Language::Japanese:
49-
case Language::English:
50-
case Language::Korean:
48+
if (mkaul::in_range(static_cast<uint32_t>(language), 0u, static_cast<uint32_t>(Language::NumLanguage) - 1u)) {
5149
pref_.language = language;
5250
return true;
53-
54-
default:
55-
return false;
5651
}
52+
else return false;
5753
}
5854

5955
bool Config::set_theme(ThemeId theme) noexcept {
@@ -69,43 +65,43 @@ namespace curve_editor::global {
6965
}
7066
}
7167

72-
const char* Config::get_edit_mode_dispname(EditMode edit_mode) const noexcept {
68+
std::wstring_view Config::get_edit_mode_dispname(EditMode edit_mode) const noexcept {
7369
using StringId = StringTable::StringId;
7470
switch (edit_mode) {
7571
case EditMode::Normal:
76-
return string_table[StringId::LabelEditModeNormal];
72+
return string_table[StringId::CurveTypeNormal];
7773

7874
case EditMode::Value:
79-
return string_table[StringId::LabelEditModeValue];
75+
return string_table[StringId::CurveTypeValue];
8076

8177
case EditMode::Bezier:
82-
return string_table[StringId::LabelEditModeBezier];
78+
return string_table[StringId::CurveTypeBezier];
8379

8480
case EditMode::Elastic:
85-
return string_table[StringId::LabelEditModeElastic];
81+
return string_table[StringId::CurveTypeElastic];
8682

8783
case EditMode::Bounce:
88-
return string_table[StringId::LabelEditModeBounce];
84+
return string_table[StringId::CurveTypeBounce];
8985

9086
case EditMode::Script:
91-
return string_table[StringId::LabelEditModeScript];
87+
return string_table[StringId::CurveTypeScript];
9288

9389
default:
94-
return nullptr;
90+
return L"";
9591
}
9692
}
9793

98-
const char* Config::get_apply_mode_dispname(ApplyMode apply_mode) const noexcept {
94+
std::wstring_view Config::get_apply_mode_dispname(ApplyMode apply_mode) const noexcept {
9995
using StringId = StringTable::StringId;
10096
switch (apply_mode) {
10197
case ApplyMode::Normal:
102-
return string_table[StringId::LabelApplyModeNormal];
98+
return string_table[StringId::ApplyModeNormal];
10399
case ApplyMode::IgnoreMidPoint:
104-
return string_table[StringId::LabelApplyModeIgnoreMidPoint];
100+
return string_table[StringId::ApplyModeIgnoreMidPoint];
105101
case ApplyMode::Interpolate:
106-
return string_table[StringId::LabelApplyModeInterpolate];
102+
return string_table[StringId::ApplyModeInterpolate];
107103
default:
108-
return nullptr;
104+
return L"";
109105
}
110106
}
111107

curve_editor/config.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ namespace curve_editor::global {
3838
std::filesystem::path dir_aviutl_;
3939
std::filesystem::path dir_plugin_;
4040

41+
bool load_json();
42+
4143
public:
4244
Config() noexcept;
4345

@@ -50,8 +52,8 @@ namespace curve_editor::global {
5052
auto get_edit_mode() const noexcept { return edit_mode_; }
5153
bool set_edit_mode(EditMode edit_mode) noexcept;
5254

53-
const char* get_edit_mode_dispname(EditMode edit_mode) const noexcept;
54-
const char* get_edit_mode_dispname() const noexcept { return get_edit_mode_dispname(edit_mode_); };
55+
std::wstring_view get_edit_mode_dispname(EditMode edit_mode) const noexcept;
56+
std::wstring_view get_edit_mode_dispname() const noexcept { return get_edit_mode_dispname(edit_mode_); };
5557

5658
auto get_layout_mode() const noexcept { return layout_mode_; }
5759
bool set_layout_mode(LayoutMode layout_mode) noexcept;
@@ -61,8 +63,8 @@ namespace curve_editor::global {
6163
bool set_apply_mode(EditMode edit_mode, ApplyMode apply_mode) noexcept;
6264
bool set_apply_mode(ApplyMode apply_mode) noexcept { return set_apply_mode(get_edit_mode(), apply_mode); }
6365

64-
const char* get_apply_mode_dispname(ApplyMode apply_mode) const noexcept;
65-
const char* get_apply_mode_dispname() const noexcept { return get_apply_mode_dispname(get_apply_mode()); }
66+
std::wstring_view get_apply_mode_dispname(ApplyMode apply_mode) const noexcept;
67+
std::wstring_view get_apply_mode_dispname() const noexcept { return get_apply_mode_dispname(get_apply_mode()); }
6668

6769
const auto& get_curve_color() const noexcept { return pref_.curve_color; }
6870
void set_curve_color(mkaul::ColorF curve_color) noexcept { pref_.curve_color = curve_color; }
@@ -151,7 +153,6 @@ namespace curve_editor::global {
151153

152154
void reset_pref() noexcept { pref_.reset(); }
153155

154-
bool load_json();
155156
bool save_json();
156157
} config;
157158
} // namespace curve_editor::global

curve_editor/constants.hpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@
77
namespace curve_editor::global {
88
inline constexpr size_t CURVE_ID_MAX = 524288u;
99

10-
inline constexpr auto CURVE_NAME_NORMAL = "normal";
11-
inline constexpr auto CURVE_NAME_VALUE = "value";
12-
inline constexpr auto CURVE_NAME_BEZIER = "bezier";
13-
inline constexpr auto CURVE_NAME_ELASTIC = "elastic";
14-
inline constexpr auto CURVE_NAME_BOUNCE = "bounce";
15-
inline constexpr auto CURVE_NAME_LINEAR = "linear";
16-
inline constexpr auto CURVE_NAME_SCRIPT = "script";
10+
inline constexpr std::string_view CURVE_NAME_NORMAL = "normal";
11+
inline constexpr std::string_view CURVE_NAME_VALUE = "value";
12+
inline constexpr std::string_view CURVE_NAME_BEZIER = "bezier";
13+
inline constexpr std::string_view CURVE_NAME_ELASTIC = "elastic";
14+
inline constexpr std::string_view CURVE_NAME_BOUNCE = "bounce";
15+
inline constexpr std::string_view CURVE_NAME_LINEAR = "linear";
16+
inline constexpr std::string_view CURVE_NAME_SCRIPT = "script";
1717

18-
inline constexpr auto MODIFIER_NAME_DISCRETIZATION = "discretization";
19-
inline constexpr auto MODIFIER_NAME_NOISE = "noise";
20-
inline constexpr auto MODIFIER_NAME_SINE_WAVE = "sine_wave";
21-
inline constexpr auto MODIFIER_NAME_SQUARE_WAVE = "square_wave";
18+
inline constexpr std::string_view MODIFIER_NAME_DISCRETIZATION = "discretization";
19+
inline constexpr std::string_view MODIFIER_NAME_NOISE = "noise";
20+
inline constexpr std::string_view MODIFIER_NAME_SINE_WAVE = "sine_wave";
21+
inline constexpr std::string_view MODIFIER_NAME_SQUARE_WAVE = "square_wave";
2222

23-
inline constexpr auto PLUGIN_NAME = "curve_editor";
24-
inline constexpr auto PLUGIN_DISPLAY_NAME = "Curve Editor";
25-
inline constexpr auto PLUGIN_EXT = "auf";
23+
inline constexpr std::string_view PLUGIN_NAME = "curve_editor";
24+
inline constexpr std::wstring_view PLUGIN_DISPLAY_NAME = L"Curve Editor";
25+
inline constexpr std::string_view PLUGIN_EXT = "auf";
2626
inline constexpr auto PLUGIN_VERSION = mkaul::Version{
2727
mkaul::VersionNumber{2},
2828
mkaul::PreviewType{mkaul::PreviewType::Type::Beta},
29-
mkaul::VersionNumber{1, 1, 0}
29+
mkaul::VersionNumber{1, 2, 0}
3030
};
31-
inline constexpr auto PLUGIN_DEVELOPER = "mimaraka";
32-
inline constexpr auto PLUGIN_TRANSLATOR = "Deepdive";
33-
inline constexpr auto PLUGIN_GITHUB_URL = "https://github.com/mimaraka/aviutl-plugin-curve_editor";
31+
inline constexpr auto PLUGIN_DEVELOPER = L"mimaraka";
32+
inline constexpr auto PLUGIN_TRANSLATOR = L"Deepdive";
33+
inline constexpr auto PLUGIN_GITHUB_URL = L"https://github.com/mimaraka/aviutl-plugin-curve_editor";
3434
} // namespace curve_editor

curve_editor/context_menu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ namespace curve_editor {
77
void ContextMenu::init() noexcept {
88
menu_ = ::CreatePopupMenu();
99
for (size_t i = 1; auto & item : items_) {
10-
MENUITEMINFOA minfo;
10+
MENUITEMINFOW minfo;
1111
item.get_menu_item_info(minfo, i);
12-
::InsertMenuItemA(menu_, minfo.wID, TRUE, &minfo);
12+
::InsertMenuItemW(menu_, minfo.wID, TRUE, &minfo);
1313
i++;
1414
}
1515
}

curve_editor/curve_base.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ namespace curve_editor {
4848
[[nodiscard]] auto get_id() const noexcept { return id_; }
4949
// TODO: CurveTypeというenumにする
5050
[[nodiscard]] constexpr virtual EditMode get_type() const noexcept = 0;
51-
[[nodiscard]] constexpr virtual std::string get_name() const noexcept = 0;
52-
[[nodiscard]] virtual std::string get_disp_name() const noexcept = 0;
51+
[[nodiscard]] constexpr virtual const std::string_view& get_name() const noexcept = 0;
52+
[[nodiscard]] virtual std::wstring_view get_disp_name() const noexcept = 0;
5353
[[nodiscard]] virtual nlohmann::json create_json() const noexcept;
5454
virtual bool load_json(const nlohmann::json& data) noexcept = 0;
5555

curve_editor/curve_bezier.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ namespace curve_editor {
3838
return *this;
3939
}
4040

41+
// 等価演算子
42+
bool BezierCurve::operator==(const BezierCurve& curve) const noexcept {
43+
return NumericGraphCurve::operator==(curve) and
44+
handle_left_.pos_rel() == curve.handle_left_.pos_rel() and
45+
handle_right_.pos_rel() == curve.handle_right_.pos_rel();
46+
}
47+
4148
// カーブの値を取得
4249
double BezierCurve::curve_function(double progress, double start, double end) const noexcept {
4350
progress = mkaul::clamp(progress, anchor_start().x, anchor_end().x);

curve_editor/curve_bezier.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ namespace curve_editor {
4040
// コピー代入演算子
4141
BezierCurve& operator=(const BezierCurve& curve) noexcept;
4242

43+
// 等価演算子
44+
[[nodiscard]] bool operator==(const BezierCurve& curve) const noexcept;
45+
4346
[[nodiscard]] std::unique_ptr<GraphCurve> clone_graph() const noexcept override { return std::make_unique<BezierCurve>(*this); }
4447
[[nodiscard]] std::unique_ptr<Curve> clone() const noexcept override { return clone_graph(); }
4548

4649
[[nodiscard]] constexpr EditMode get_type() const noexcept override { return EditMode::Bezier; }
47-
[[nodiscard]] constexpr std::string get_name() const noexcept override { return global::CURVE_NAME_BEZIER; }
48-
[[nodiscard]] std::string get_disp_name() const noexcept override { return global::string_table[global::StringTable::StringId::LabelEditModeBezier]; }
50+
[[nodiscard]] constexpr const std::string_view& get_name() const noexcept override { return global::CURVE_NAME_BEZIER; }
51+
[[nodiscard]] std::wstring_view get_disp_name() const noexcept override { return global::string_table[global::StringTable::StringId::CurveTypeBezier]; }
4952

5053
// アンカーを移動する
5154
void begin_move_anchor_start(bool bound = false) noexcept override;

curve_editor/curve_bounce.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ namespace curve_editor {
4040
return *this;
4141
}
4242

43+
// 等価演算子
44+
bool BounceCurve::operator==(const BounceCurve& curve) const noexcept {
45+
return NumericGraphCurve::operator==(curve) and
46+
cor_ == curve.cor_ and
47+
period_ == curve.period_ and
48+
reversed_ == curve.reversed_;
49+
}
50+
4351
// カーブの関数
4452
double BounceCurve::curve_function(double progress, double start, double end) const noexcept {
4553
progress = mkaul::clamp((progress - anchor_start().x) / (anchor_end().x - anchor_start().x), 0., 1.);

curve_editor/curve_bounce.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ namespace curve_editor {
3535
// コピー代入演算子
3636
BounceCurve& operator=(const BounceCurve& curve) noexcept;
3737

38+
// 等価演算子
39+
[[nodiscard]] bool operator==(const BounceCurve& curve) const noexcept;
40+
3841
[[nodiscard]] std::unique_ptr<GraphCurve> clone_graph() const noexcept override { return std::make_unique<BounceCurve>(*this); }
3942
[[nodiscard]] std::unique_ptr<Curve> clone() const noexcept override { return clone_graph(); }
4043

4144
[[nodiscard]] constexpr EditMode get_type() const noexcept override { return EditMode::Bounce; }
42-
[[nodiscard]] constexpr std::string get_name() const noexcept override { return global::CURVE_NAME_BOUNCE; }
43-
[[nodiscard]] std::string get_disp_name() const noexcept override { return global::string_table[global::StringTable::StringId::LabelEditModeBounce]; }
45+
[[nodiscard]] constexpr const std::string_view& get_name() const noexcept override { return global::CURVE_NAME_BOUNCE; }
46+
[[nodiscard]] std::wstring_view get_disp_name() const noexcept override { return global::string_table[global::StringTable::StringId::CurveTypeBounce]; }
4447

4548
// カーブの値を生成
4649
[[nodiscard]] double curve_function(double progress, double start, double end) const noexcept override;

curve_editor/curve_editor.rc

72.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)