-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
166 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "CustomAction.h" | ||
|
||
CustomAction::CustomAction(const std::string& action_name, | ||
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name, | ||
MaaStringView custom_action_param, MaaRectHandle cur_box, | ||
MaaStringView cur_rec_detail, MaaTransparentArg arg)) | ||
: name_(action_name) | ||
{ | ||
custom_action_.run = action_run; | ||
} | ||
|
||
CustomAction::CustomAction(const std::string& action_name, | ||
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name, | ||
MaaStringView custom_action_param, MaaRectHandle cur_box, | ||
MaaStringView cur_rec_detail, MaaTransparentArg arg), | ||
void (*action_stop)(MaaTransparentArg arg)) | ||
: name_(action_name) | ||
{ | ||
custom_action_.run = action_run; | ||
custom_action_.stop = action_stop; | ||
} | ||
|
||
std::string CustomAction::get_name() const | ||
{ | ||
return name_; | ||
} | ||
|
||
MaaCustomActionAPI CustomAction::get_custom_action() const | ||
{ | ||
return custom_action_; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "MaaFramework/Task/MaaCustomAction.h" | ||
|
||
class CustomAction | ||
{ | ||
public: | ||
CustomAction(const std::string& action_name, | ||
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name, | ||
MaaStringView custom_action_param, MaaRectHandle cur_box, | ||
MaaStringView cur_rec_detail, MaaTransparentArg arg)); | ||
CustomAction(const std::string& action_name, | ||
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name, | ||
MaaStringView custom_action_param, MaaRectHandle cur_box, | ||
MaaStringView cur_rec_detail, MaaTransparentArg arg), | ||
void (*action_stop)(MaaTransparentArg arg)); | ||
~CustomAction() = default; | ||
|
||
public: | ||
std::string get_name() const; | ||
MaaCustomActionAPI get_custom_action() const; | ||
|
||
private: | ||
std::string name_; | ||
MaaCustomActionAPI custom_action_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "CustomActionRegistrar.h" | ||
|
||
void CustomActionRegistrar::add_action(const std::string& name, | ||
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name, | ||
MaaStringView custom_action_param, MaaRectHandle cur_box, | ||
MaaStringView cur_rec_detail, MaaTransparentArg arg)) | ||
{ | ||
actions_.emplace_back(name, action_run); | ||
} | ||
|
||
void CustomActionRegistrar::add_action(const std::string& name, | ||
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name, | ||
MaaStringView custom_action_param, MaaRectHandle cur_box, | ||
MaaStringView cur_rec_detail, MaaTransparentArg arg), | ||
void (*action_stop)(MaaTransparentArg arg)) | ||
{ | ||
actions_.emplace_back(name, action_run, action_stop); | ||
} | ||
|
||
void CustomActionRegistrar::register_actions(MaaInstanceHandle maa_handle) | ||
{ | ||
for (const auto& action : actions_) { | ||
std::shared_ptr<MaaCustomActionAPI> custom_action = | ||
std::make_shared<MaaCustomActionAPI>(action.get_custom_action()); | ||
custom_actions_.push_back(custom_action); | ||
MaaRegisterCustomAction(maa_handle, action.get_name().c_str(), custom_action.get(), nullptr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "CustomAction.h" | ||
#include "MaaFramework/Instance/MaaInstance.h" | ||
#include "MaaFramework/Task/MaaCustomAction.h" | ||
|
||
class CustomActionRegistrar | ||
{ | ||
public: | ||
CustomActionRegistrar() = default; | ||
~CustomActionRegistrar() = default; | ||
|
||
public: | ||
void add_action(const std::string& name, | ||
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name, | ||
MaaStringView custom_action_param, MaaRectHandle cur_box, | ||
MaaStringView cur_rec_detail, MaaTransparentArg arg)); | ||
void add_action(const std::string& name, | ||
MaaBool (*action_run)(MaaSyncContextHandle sync_context, MaaStringView task_name, | ||
MaaStringView custom_action_param, MaaRectHandle cur_box, | ||
MaaStringView cur_rec_detail, MaaTransparentArg arg), | ||
void (*action_stop)(MaaTransparentArg arg)); | ||
void register_actions(MaaInstanceHandle maa_handle); | ||
|
||
private: | ||
std::vector<CustomAction> actions_; | ||
std::vector<std::shared_ptr<MaaCustomActionAPI>> custom_actions_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include "Combat.h" | ||
#include "CustomAction/CustomActionRegistrar.h" | ||
|
||
void custom_action_init(CustomActionRegistrar& registrar) | ||
{ | ||
registrar.add_action("Forward", combat_forward); | ||
registrar.add_action("Backward", combat_backward); | ||
registrar.add_action("Left", combat_left); | ||
registrar.add_action("Right", combat_right); | ||
registrar.add_action("LeftForward", combat_left_forward); | ||
registrar.add_action("RightForward", combat_right_forward); | ||
registrar.add_action("LeftBackward", combat_left_backward); | ||
registrar.add_action("RightBackward", combat_right_backward); | ||
registrar.add_action("BasicATK", combat_basic_ATK); | ||
registrar.add_action("BasicATKChargeBase", combat_basic_ATK_charge_base); | ||
registrar.add_action("BasicATKCharge", combat_basic_ATK_charge); | ||
registrar.add_action("Evade", combat_evade); | ||
registrar.add_action("Ultimate", combat_ultimate); | ||
registrar.add_action("UltimateChargeBase", combat_ultimate_charge_base); | ||
registrar.add_action("UltimateCharge", combat_ultimate_charge); | ||
registrar.add_action("WeaponSkill", combat_weapon_skill); | ||
registrar.add_action("ELFSkill", combat_ELF_skill); | ||
registrar.add_action("ExtraSkill", combat_extra_skill); | ||
registrar.add_action("QTE1", combat_QTE1); | ||
registrar.add_action("QTE2", combat_QTE2); | ||
} | ||
|
||
void register_custom_action(MaaInstanceHandle maa_handle) | ||
{ | ||
CustomActionRegistrar registerar; | ||
custom_action_init(registerar); | ||
registerar.register_actions(maa_handle); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters