Skip to content

Commit fbae385

Browse files
authored
Merge pull request #38 from mimaraka/develop
v2.0-alpha2.2
2 parents b3d946e + 2399aa8 commit fbae385

File tree

154 files changed

+5910
-3038
lines changed

Some content is hidden

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

154 files changed

+5910
-3038
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
[submodule "curve_editor/external/sol2"]
2222
path = curve_editor/external/sol2
2323
url = https://github.com/ThePhD/sol2.git
24+
[submodule "curve_editor/external/magic_enum"]
25+
path = curve_editor/external/magic_enum
26+
url = https://github.com/Neargye/magic_enum

curve_editor/actctx_helper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#include "actctx_helper.hpp"
2+
#include "constants.hpp"
23
#include "resource.h"
34
#include <WinBase.h>
45

56

67

78
namespace cved {
8-
bool ActCtxHelper::init(HINSTANCE hinst) noexcept {
9+
bool ActCtxHelper::init() noexcept {
910
ACTCTXA actctx{
1011
.cbSize = sizeof(ACTCTXA),
1112
.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID,
1213
.lpResourceName = MAKEINTRESOURCEA(ID_MANIFEST_VISUALSTYLE),
13-
.hModule = hinst
14+
.hModule = ::GetModuleHandleA(global::PLUGIN_DLL_NAME)
1415
};
1516
HANDLE tmp = NULL;
1617
::GetCurrentActCtx(&tmp);

curve_editor/actctx_helper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace cved {
1010
HANDLE hactctx_ = NULL;
1111

1212
public:
13-
bool init(HINSTANCE hinst) noexcept;
13+
bool init() noexcept;
1414
bool exit();
1515
};
1616
}

curve_editor/config.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,34 @@
99

1010
namespace cved {
1111
namespace global {
12-
void Config::init(HINSTANCE hinst) noexcept {
12+
Config::Config() noexcept :
13+
edit_mode_{ EditMode::Normal },
14+
layout_mode_{ LayoutMode::Horizontal },
15+
apply_mode_{},
16+
curve_code_bezier_{ 145674282 },
17+
curve_code_elastic_{ 2554290 },
18+
curve_code_bounce_{ 10612242 },
19+
show_x_label_{ false },
20+
show_y_label_{ true },
21+
show_handle_{ true },
22+
show_library_{ true },
23+
show_velocity_graph_{ false },
24+
align_handle_{ true },
25+
ignore_autosaver_warning_{ false },
26+
separator_pos_{ 0.56 },
27+
preset_size_{ 64 }
28+
{
1329
pref_.reset();
14-
edit_mode_ = EditMode::Normal;
15-
layout_mode_ = LayoutMode::Vertical;
1630
apply_mode_.fill(ApplyMode::Normal);
1731
set_apply_mode(EditMode::Value, ApplyMode::IgnoreMidPoint);
18-
curve_code_bezier_ = 145674282;
19-
curve_code_elastic_ = 2554290;
20-
curve_code_bounce_ = 10612242;
21-
show_x_label_ = false;
22-
show_y_label_ = true;
23-
show_handle_ = true;
24-
show_library_ = true;
25-
show_velocity_graph_ = false;
26-
align_handle_ = true;
27-
ignore_autosaver_warning_ = false;
28-
separator_pos_ = 1.;
29-
preset_size_ = 50;
32+
set_apply_mode(EditMode::Script, ApplyMode::IgnoreMidPoint);
3033

3134
// AviUtlのディレクトリの取得
3235
char path_str[MAX_PATH];
3336
::GetModuleFileNameA(NULL, path_str, MAX_PATH);
3437
std::filesystem::path path_aviutl{ path_str };
3538
dir_aviutl_ = path_aviutl.parent_path();
36-
::GetModuleFileNameA(hinst, path_str, MAX_PATH);
39+
::GetModuleFileNameA(::GetModuleHandleA(global::PLUGIN_DLL_NAME), path_str, MAX_PATH);
3740
std::filesystem::path path_plugin{ path_str };
3841
dir_plugin_ = path_plugin.parent_path() / "curve_editor";
3942
}
@@ -67,9 +70,6 @@ namespace cved {
6770

6871
const char* Config::get_edit_mode_dispname(EditMode edit_mode) const noexcept {
6972
using StringId = StringTable::StringId;
70-
71-
if (!string_table.loaded()) return nullptr;
72-
7373
switch (edit_mode) {
7474
case EditMode::Normal:
7575
return string_table[StringId::LabelEditModeNormal];
@@ -138,8 +138,8 @@ namespace cved {
138138
separator_pos_ = mkaul::clamp(separator_pos, 0., 1.);
139139
}
140140

141-
void Config::set_preset_size(int) noexcept {
142-
141+
void Config::set_preset_size(int preset_size) noexcept {
142+
preset_size_ = mkaul::clamp(preset_size, 20, 200);
143143
}
144144

145145
#define GET_KEY(var) std::string{ #var, 0u, strlen(#var) - 1u}.c_str()
@@ -206,7 +206,7 @@ namespace cved {
206206

207207
std::ofstream ofs{ dir_plugin_ / CONFIG_FILE_NAME };
208208
if (!ofs) return false;
209-
ofs << data.dump(4);
209+
ofs << data.dump(2);
210210
return true;
211211
}
212212

curve_editor/config.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ namespace cved {
2020
LayoutMode layout_mode_ = LayoutMode::Vertical;
2121
std::array<ApplyMode, (size_t)EditMode::NumEditMode> apply_mode_ = {};
2222

23-
int curve_code_bezier_ = 0;
24-
int curve_code_elastic_ = 0;
25-
int curve_code_bounce_ = 0;
26-
27-
bool show_x_label_ = false;
28-
bool show_y_label_ = false;
29-
bool show_handle_ = false;
30-
bool show_library_ = false;
31-
bool show_velocity_graph_ = false;
32-
bool align_handle_ = false;
33-
bool ignore_autosaver_warning_ = false;
34-
double separator_pos_ = 0.;
35-
int preset_size_ = 0;
23+
int curve_code_bezier_;
24+
int curve_code_elastic_;
25+
int curve_code_bounce_;
26+
27+
bool show_x_label_;
28+
bool show_y_label_;
29+
bool show_handle_;
30+
bool show_library_;
31+
bool show_velocity_graph_;
32+
bool align_handle_;
33+
bool ignore_autosaver_warning_;
34+
double separator_pos_;
35+
int preset_size_;
3636

3737
std::filesystem::path dir_aviutl_;
3838
std::filesystem::path dir_plugin_;
3939

4040
public:
41-
void init(HINSTANCE hinst) noexcept;
41+
Config() noexcept;
4242

4343
auto get_language() const noexcept { return pref_.language; }
4444
bool set_language(Language language) noexcept;

curve_editor/constants.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ namespace cved {
2222
inline constexpr auto MODIFIER_NAME_SQUARE_WAVE = "square_wave";
2323

2424
inline constexpr auto PLUGIN_NAME = "Curve Editor";
25+
inline constexpr auto PLUGIN_DLL_NAME = "curve_editor.auf";
2526
inline constexpr auto PLUGIN_VERSION = mkaul::Version{
2627
mkaul::VersionNumber{2},
2728
mkaul::PreviewType{mkaul::PreviewType::Type::Alpha},
28-
mkaul::VersionNumber{2, 1, 1}
29+
mkaul::VersionNumber{2, 2}
2930
};
3031
inline constexpr auto PLUGIN_DEVELOPER = "mimaraka";
3132
inline constexpr auto PLUGIN_TRANSLATOR = "Deepdive";

curve_editor/context_menu.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "context_menu.hpp"
2+
#include <stdexcept>
3+
4+
5+
6+
namespace cved {
7+
void ContextMenu::init() noexcept {
8+
menu_ = ::CreatePopupMenu();
9+
for (size_t i = 1; auto & item : items_) {
10+
MENUITEMINFOA minfo;
11+
item.get_menu_item_info(minfo, i);
12+
::InsertMenuItemA(menu_, minfo.wID, TRUE, &minfo);
13+
i++;
14+
}
15+
}
16+
17+
bool ContextMenu::show(
18+
HWND hwnd,
19+
UINT flags,
20+
const mkaul::Point<LONG>* p_custom_pt_screen
21+
) noexcept {
22+
POINT tmp;
23+
::GetCursorPos(&tmp);
24+
if (p_custom_pt_screen) {
25+
tmp = p_custom_pt_screen->to<POINT>();
26+
}
27+
int32_t ret = ::TrackPopupMenu(
28+
menu_,
29+
flags | TPM_RETURNCMD | TPM_NONOTIFY,
30+
tmp.x,
31+
tmp.y,
32+
0, hwnd, NULL
33+
);
34+
35+
if (ret == 0) {
36+
return false;
37+
}
38+
auto root_idx = static_cast<size_t>(ret);
39+
while (MenuItem::MAX_SUB_MENU_ITEMS <= root_idx) {
40+
root_idx = root_idx / MenuItem::MAX_SUB_MENU_ITEMS;
41+
}
42+
try {
43+
return items_.at(root_idx - 1).callback(static_cast<uint32_t>(ret));
44+
}
45+
catch (const std::out_of_range&) {
46+
return false;
47+
}
48+
}
49+
}

curve_editor/context_menu.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#pragma once
2+
3+
#include "menu_item.hpp"
4+
#include <mkaul/point.hpp>
5+
6+
7+
8+
namespace cved {
9+
class ContextMenu {
10+
HMENU menu_;
11+
std::vector<MenuItem> items_;
12+
void init() noexcept;
13+
14+
public:
15+
ContextMenu(std::vector<MenuItem> vec) : items_{ vec } { init(); }
16+
ContextMenu(std::initializer_list<MenuItem> list) : items_{ list } { init(); }
17+
18+
~ContextMenu() {
19+
::DestroyMenu(menu_);
20+
}
21+
22+
bool show(
23+
HWND hwnd,
24+
UINT flags = NULL,
25+
const mkaul::Point<LONG>* p_custom_pt_screen = nullptr
26+
) noexcept;
27+
};
28+
}

curve_editor/curve_base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace cved {
2424

2525
nlohmann::json Curve::create_json() const noexcept {
2626
nlohmann::json data;
27-
data["type"] = get_type();
27+
data["type"] = get_name();
2828
return data;
2929
}
3030
}

curve_editor/curve_base.hpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,34 @@ namespace cved {
1313
const uint32_t id_;
1414

1515
public:
16+
// コンストラクタ
1617
Curve() noexcept :
1718
id_{global::id_manager.create_id(this)},
1819
locked_{false}
1920
{}
21+
// コピーコンストラクタ
22+
Curve(const Curve& curve) noexcept :
23+
id_{global::id_manager.create_id(this)},
24+
locked_{curve.locked_}
25+
{}
26+
// 仮想デストラクタ
2027
virtual ~Curve() noexcept {
2128
global::id_manager.remove_id(id_);
2229
}
2330

2431
// カーブの値を取得
25-
virtual double curve_function(double progress, double start, double end) const noexcept = 0;
26-
virtual double get_value(double progress, double start, double end) const noexcept;
27-
double get_velocity(double progress, double start, double end) const noexcept;
32+
[[nodiscard]] virtual double curve_function(double progress, double start, double end) const noexcept = 0;
33+
[[nodiscard]] virtual double get_value(double progress, double start, double end) const noexcept;
34+
[[nodiscard]] double get_velocity(double progress, double start, double end) const noexcept;
2835
virtual void clear() noexcept = 0;
2936
virtual void lock() noexcept { locked_ = true; }
3037
virtual void unlock() noexcept { locked_ = false; }
31-
auto is_locked() const noexcept { return locked_; }
32-
virtual bool is_default() const noexcept = 0;
33-
auto get_id() const noexcept { return id_; }
34-
constexpr virtual std::string get_type() const noexcept = 0;
35-
virtual nlohmann::json create_json() const noexcept;
38+
[[nodiscard]] auto is_locked() const noexcept { return locked_; }
39+
[[nodiscard]] virtual bool is_default() const noexcept = 0;
40+
[[nodiscard]] auto get_id() const noexcept { return id_; }
41+
[[nodiscard]] constexpr virtual std::string get_name() const noexcept = 0;
42+
[[nodiscard]] virtual std::string get_disp_name() const noexcept = 0;
43+
[[nodiscard]] virtual nlohmann::json create_json() const noexcept;
3644
virtual bool load_json(const nlohmann::json& data) noexcept = 0;
3745
};
3846
} // namespace cved

0 commit comments

Comments
 (0)