mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
完善公开招募基本功能,初始化界面
This commit is contained in:
@@ -36,17 +36,23 @@ namespace asst {
|
||||
|
||||
bool print_window(const std::string& filename, bool block = true);
|
||||
|
||||
// for debug
|
||||
bool find_text_and_click(const std::string& text, bool block = true);
|
||||
// for debug
|
||||
void find_and_clac_tags(bool need_click = true);
|
||||
// 计算公开招募,需要当前处在选择公招Tag的页面
|
||||
// 参数:
|
||||
// required_level:需要的等级,最优组合的最低等级,在required_level中,才会进行点击
|
||||
// set_time:是否自动设置时间(9小时)
|
||||
// 返回值:
|
||||
// std::vector< std::pair < Tags名vector,这个Tags组合可能出的干员组合 > >
|
||||
std::optional<std::vector<std::pair<std::vector<std::string>, OperCombs>>>
|
||||
open_recruit(const std::vector<int>& required_level, bool set_time = true);
|
||||
private:
|
||||
static void working_proc(Assistance* pThis);
|
||||
|
||||
// pair<scale, image>
|
||||
cv::Mat get_format_image();
|
||||
void set_control_scale(int cur_width, int cur_height);
|
||||
|
||||
// for debug
|
||||
bool find_text_and_click(const std::string& text, bool block = true);
|
||||
|
||||
std::shared_ptr<WinMacro> m_pWindow = nullptr;
|
||||
std::shared_ptr<WinMacro> m_pView = nullptr;
|
||||
std::shared_ptr<WinMacro> m_pCtrl = nullptr;
|
||||
|
||||
@@ -46,9 +46,9 @@ namespace asst {
|
||||
return buff;
|
||||
}
|
||||
|
||||
static std::string GbkToUtf8(const std::string & gbk_str)
|
||||
static std::string GbkToUtf8(const std::string& gbk_str)
|
||||
{
|
||||
const char * src_str = gbk_str.c_str();
|
||||
const char* src_str = gbk_str.c_str();
|
||||
int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0);
|
||||
wchar_t* wstr = new wchar_t[len + 1];
|
||||
memset(wstr, 0, len + 1);
|
||||
@@ -63,7 +63,7 @@ namespace asst {
|
||||
return strTemp;
|
||||
}
|
||||
|
||||
static std::string Utf8ToGbk(const std::string & utf8_str)
|
||||
static std::string Utf8ToGbk(const std::string& utf8_str)
|
||||
{
|
||||
const char* src_str = utf8_str.c_str();
|
||||
int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0);
|
||||
@@ -79,4 +79,46 @@ namespace asst {
|
||||
if (szGBK) delete[] szGBK;
|
||||
return strTemp;
|
||||
}
|
||||
|
||||
|
||||
template<typename T,
|
||||
typename = typename std::enable_if<std::is_constructible<T, std::string>::value>::type>
|
||||
std::string VectorToString(const std::vector<T>& vector, bool to_gbk = false) {
|
||||
if (vector.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
static const std::string inter = " ,";
|
||||
std::string str;
|
||||
for (const T& ele : vector) {
|
||||
if (to_gbk) {
|
||||
str += Utf8ToGbk(ele) + inter;
|
||||
}
|
||||
else {
|
||||
str += ele + inter;
|
||||
}
|
||||
}
|
||||
|
||||
if (!str.empty()) {
|
||||
str.erase(str.size() - inter.size(), inter.size());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
template<typename T,
|
||||
typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
|
||||
std::string VectorToString(const std::vector<T>& vector) {
|
||||
if (vector.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
static const std::string inter = " ,";
|
||||
std::string str;
|
||||
for (const T& ele : vector) {
|
||||
str += std::to_string(ele) + inter;
|
||||
}
|
||||
|
||||
if (!str.empty()) {
|
||||
str.erase(str.size() - inter.size(), inter.size());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern MEOAPI_PORT asst::Assistance* CreateAsst();
|
||||
extern MEOAPI_PORT void DestoryAsst(asst::Assistance* p_asst);
|
||||
extern MEOAPI_PORT bool AsstCatchEmulator(asst::Assistance* p_asst);
|
||||
extern MEOAPI_PORT void AsstStart(asst::Assistance* p_asst, const char* task);
|
||||
extern MEOAPI_PORT void AsstStop(asst::Assistance* p_asst);
|
||||
extern MEOAPI_PORT bool AsstSetParam(asst::Assistance* p_asst, const char* type, const char* param, const char* value);
|
||||
extern MEOAPI_PORT bool AsstGetParam(asst::Assistance* p_asst, const char* type, const char* param, char * buffer, int buffer_size);
|
||||
extern MEOAPI_PORT bool CheckVersionUpdate(char * tag_buffer, int tag_bufsize, char * html_url_buffer, int html_bufsize, char * body_buffer, int body_bufsize);
|
||||
MEOAPI_PORT asst::Assistance* CreateAsst();
|
||||
MEOAPI_PORT void DestoryAsst(asst::Assistance* p_asst);
|
||||
MEOAPI_PORT bool AsstCatchEmulator(asst::Assistance* p_asst);
|
||||
MEOAPI_PORT void AsstStart(asst::Assistance* p_asst, const char* task);
|
||||
MEOAPI_PORT void AsstStop(asst::Assistance* p_asst);
|
||||
MEOAPI_PORT bool AsstSetParam(asst::Assistance* p_asst, const char* type, const char* param, const char* value);
|
||||
MEOAPI_PORT bool AsstGetParam(asst::Assistance* p_asst, const char* type, const char* param, char * buffer, int buffer_size);
|
||||
MEOAPI_PORT bool AsstRunOpenRecruit(asst::Assistance* p_asst, const int required_level[], bool set_time, char * result_buffer, int bufsize, int& maybe_level);
|
||||
|
||||
MEOAPI_PORT bool CheckVersionUpdate(char* tag_buffer, int tag_bufsize, char* html_url_buffer, int html_bufsize, char* body_buffer, int body_bufsize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@ namespace asst {
|
||||
PrintWindow,
|
||||
ClickSelf = 8 | BasicClick,
|
||||
ClickRect = 16 | BasicClick,
|
||||
ClickRand = 32 | BasicClick
|
||||
ClickRand = 32 | BasicClick,
|
||||
Ocr = 64,
|
||||
OcrAndClick = Ocr | BasicClick
|
||||
};
|
||||
static bool operator&(const TaskType& lhs, const TaskType& rhs)
|
||||
{
|
||||
@@ -102,15 +104,14 @@ namespace asst {
|
||||
TextArea() = default;
|
||||
TextArea(const TextArea&) = default;
|
||||
TextArea(TextArea&&) = default;
|
||||
template<typename TextArg, typename ...RectArgs>
|
||||
TextArea(TextArg&& text_arg, RectArgs &&... rect_args)
|
||||
: text(std::forward<TextArg>(text_arg)),
|
||||
template<typename ...RectArgs>
|
||||
TextArea(std::string text, RectArgs &&... rect_args)
|
||||
: text(std::move(text)),
|
||||
rect(std::forward<RectArgs>(rect_args)...) {
|
||||
static_assert(std::is_constructible<std::string, TextArg>::value,
|
||||
"Parameter can't be used to construct a std::string");
|
||||
static_assert(std::is_constructible<asst::Rect, RectArgs...>::value,
|
||||
"Parameter can't be used to construct a asst::Rect");
|
||||
}
|
||||
operator std::string() const { return text; }
|
||||
std::string text;
|
||||
Rect rect;
|
||||
};
|
||||
@@ -158,6 +159,7 @@ namespace asst {
|
||||
asst::Rect specific_area; // 指定区域,目前仅针对ClickRect任务有用,会点这个区域
|
||||
int pre_delay = 0; // 执行该任务前的延时
|
||||
int rear_delay = 0; // 执行该任务后的延时
|
||||
int retry_times = INT_MAX; // 未找到图像时的重试次数
|
||||
};
|
||||
|
||||
struct Options {
|
||||
@@ -188,5 +190,6 @@ namespace asst {
|
||||
std::vector<OperInfo> opers;
|
||||
int max_level = 0;
|
||||
int min_level = 0;
|
||||
bool has_level_1 = false; // 是否有一星干员
|
||||
};
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
|
||||
#include "AsstAux.h"
|
||||
#include "AsstPort.h"
|
||||
|
||||
@@ -198,7 +198,8 @@ bool asst::Assistance::find_text_and_click(const std::string& text, bool block)
|
||||
return m_pCtrl->click(result.value());
|
||||
}
|
||||
|
||||
void asst::Assistance::find_and_clac_tags(bool need_click)
|
||||
std::optional<std::vector<std::pair<std::vector<std::string>, OperCombs>>>
|
||||
asst::Assistance::open_recruit(const std::vector<int>& required_level, bool set_time)
|
||||
{
|
||||
DebugTraceFunction;
|
||||
|
||||
@@ -206,44 +207,39 @@ void asst::Assistance::find_and_clac_tags(bool need_click)
|
||||
|
||||
const cv::Mat& image = get_format_image();
|
||||
set_control_scale(image.cols, image.rows);
|
||||
lock.unlock(); // 后面的计算耗时太长,先解锁
|
||||
|
||||
lock.unlock();
|
||||
|
||||
if (need_click) {
|
||||
if (set_time) {
|
||||
start("RecruitTime");
|
||||
}
|
||||
|
||||
std::vector<TextArea> ider_result = m_pIder->ocr_detect(image);
|
||||
std::vector<TextArea> filt_result;
|
||||
std::string ider_str;
|
||||
//DebugTrace("All ocr text: ", ider_result);
|
||||
|
||||
std::vector<TextArea> filt_result; // 识别的文字中,是tag名的结果
|
||||
for (TextArea& res : ider_result) {
|
||||
// 替换一些常见的文字识别错误
|
||||
// TODO: 这块时间复杂度有点高,待优化
|
||||
for (const auto& [src, cor] : m_configer.m_ocr_replace) {
|
||||
res.text = StringReplaceAll(res.text, src, cor);
|
||||
}
|
||||
ider_str += res.text + " ,";
|
||||
for (const std::string& t : m_recruit_configer.m_all_tags) {
|
||||
if (res.text == t) {
|
||||
filt_result.emplace_back(std::move(res));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ider_str.back() == ',') {
|
||||
ider_str.pop_back();
|
||||
|
||||
if (filt_result.size() != 5) {
|
||||
DebugTraceError("Error, Tags recognition error!!!");
|
||||
return std::nullopt;
|
||||
}
|
||||
DebugTrace("All ocr text: ", Utf8ToGbk(ider_str));
|
||||
|
||||
std::vector<std::string> tags;
|
||||
std::string tags_str;
|
||||
for (const TextArea& t_a : filt_result) {
|
||||
tags.emplace_back(t_a.text);
|
||||
tags_str += t_a.text + " ,";
|
||||
}
|
||||
if (tags_str.back() == ',') {
|
||||
tags_str.pop_back();
|
||||
}
|
||||
DebugTraceInfo("All Tags", Utf8ToGbk(tags_str));
|
||||
DebugTraceInfo("All Tags", VectorToString(tags, true));
|
||||
|
||||
// Tags全组合
|
||||
std::vector<std::vector<std::string>> all_combs;
|
||||
@@ -299,6 +295,9 @@ void asst::Assistance::find_and_clac_tags(bool need_click)
|
||||
if (oper_combs.max_level == 0 || oper_combs.max_level < cur_oper.level) {
|
||||
oper_combs.max_level = cur_oper.level;
|
||||
}
|
||||
if (cur_oper.level == 1) {
|
||||
oper_combs.has_level_1 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,13 +323,12 @@ void asst::Assistance::find_and_clac_tags(bool need_click)
|
||||
}
|
||||
});
|
||||
|
||||
#ifdef LOG_TRACE
|
||||
for (const auto& [combs, oper_combs] : result_vector) {
|
||||
std::string tag_str;
|
||||
for (const std::string& tag : combs) {
|
||||
tag_str += tag + " ,";
|
||||
}
|
||||
if (tags_str.back() == ',') {
|
||||
if (tag_str.back() == ',') {
|
||||
tag_str.pop_back();
|
||||
}
|
||||
|
||||
@@ -341,11 +339,15 @@ void asst::Assistance::find_and_clac_tags(bool need_click)
|
||||
if (opers_str.back() == ',') {
|
||||
opers_str.pop_back();
|
||||
}
|
||||
DebugTraceInfo("Tags:", Utf8ToGbk(tag_str), "May be recruited: ", Utf8ToGbk(opers_str));
|
||||
DebugTraceInfo("Tags:", VectorToString(combs, true), "May be recruited: ", Utf8ToGbk(opers_str));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (need_click && !result_vector.empty()) {
|
||||
stop(true);
|
||||
if (!required_level.empty() && !result_vector.empty()) {
|
||||
if (std::find(required_level.cbegin(), required_level.cend(), result_vector[0].second.min_level)
|
||||
== required_level.cend()) {
|
||||
return result_vector;
|
||||
}
|
||||
const std::vector<std::string>& final_tags = result_vector[0].first;
|
||||
std::vector<TextArea> final_text_areas;
|
||||
|
||||
@@ -359,6 +361,7 @@ void asst::Assistance::find_and_clac_tags(bool need_click)
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
return result_vector;
|
||||
}
|
||||
|
||||
void Assistance::working_proc(Assistance* pThis)
|
||||
@@ -398,7 +401,7 @@ void Assistance::working_proc(Assistance* pThis)
|
||||
if (algorithm == AlgorithmType::JustReturn ||
|
||||
(algorithm == AlgorithmType::MatchTemplate && value >= threshold)
|
||||
|| (algorithm == AlgorithmType::CompareHist && value >= cache_threshold)) {
|
||||
matched_task = std::move(task_name);
|
||||
matched_task = task_name;
|
||||
matched_rect = std::move(rect);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "AsstCaller.h"
|
||||
#include "Updater.h"
|
||||
#include "AsstAux.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -24,7 +25,7 @@ bool AsstCatchEmulator(asst::Assistance* p_asst)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto && ret = p_asst->catch_emulator();
|
||||
auto&& ret = p_asst->catch_emulator();
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
@@ -59,12 +60,12 @@ bool AsstSetParam(asst::Assistance* p_asst, const char* type, const char* param,
|
||||
return p_asst->set_param(type, param, value);
|
||||
}
|
||||
|
||||
bool AsstGetParam(asst::Assistance* p_asst, const char* type, const char* param, char * buffer, int buffer_size)
|
||||
bool AsstGetParam(asst::Assistance* p_asst, const char* type, const char* param, char* buffer, int buffer_size)
|
||||
{
|
||||
if (p_asst == NULL) {
|
||||
return false;
|
||||
}
|
||||
auto && ret = p_asst->get_param(type, param);
|
||||
auto&& ret = p_asst->get_param(type, param);
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
@@ -72,13 +73,48 @@ bool AsstGetParam(asst::Assistance* p_asst, const char* type, const char* param,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AsstRunOpenRecruit(asst::Assistance* p_asst, const int required_level[], bool set_time, char* result_buffer, int bufsize, int& maybe_level)
|
||||
{
|
||||
if (p_asst == NULL) {
|
||||
return false;
|
||||
}
|
||||
int len = sizeof required_level / sizeof(int);
|
||||
std::vector<int> level_vector;
|
||||
level_vector.assign(required_level, required_level + len);
|
||||
auto&& ret = p_asst->open_recruit(level_vector, set_time);
|
||||
if (ret) {
|
||||
// <std::vector<std::pair<std::vector<std::string>, OperCombs>>>
|
||||
std::string result_str;
|
||||
maybe_level = 0;
|
||||
for (auto&& [tags, oper_combs] : ret.value())
|
||||
{
|
||||
result_str += std::to_string(oper_combs.min_level) + "ÐÇTags: "
|
||||
+ asst::VectorToString(tags, true) + "\n\t";
|
||||
for (auto&& oper : oper_combs.opers)
|
||||
{
|
||||
result_str += std::to_string(oper.level) + " - " + asst::Utf8ToGbk(oper.name) + " ";
|
||||
}
|
||||
result_str += "\n\n";
|
||||
if (maybe_level == 0) {
|
||||
maybe_level = oper_combs.min_level;
|
||||
}
|
||||
}
|
||||
strcpy_s(result_buffer, bufsize, result_str.c_str());
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CheckVersionUpdate(char* tag_buffer, int tag_bufsize, char* html_url_buffer, int html_bufsize, char* body_buffer, int body_bufsize)
|
||||
{
|
||||
bool ret = asst::Updater::get_instance().has_new_version();
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
const asst::VersionInfo & info = asst::Updater::get_instance().get_version_info();
|
||||
const asst::VersionInfo& info = asst::Updater::get_instance().get_version_info();
|
||||
strcpy_s(tag_buffer, tag_bufsize, info.tag_name.c_str());
|
||||
strcpy_s(html_url_buffer, html_bufsize, info.html_url.c_str());
|
||||
strcpy_s(body_buffer, body_bufsize, info.body.c_str());
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<TextBox x:Name="textBox_useStone" HorizontalAlignment="Left" Height="23" Margin="112,148,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="47" TextChanged="textBox_useStone_TextChanged" InputMethod.IsInputMethodEnabled="False"/>
|
||||
<Label x:Name="label_stoneNumber" Content="颗" HorizontalAlignment="Left" Margin="164,144,0,0" VerticalAlignment="Top" RenderTransformOrigin="-5.771,-6.291"/>
|
||||
<Button x:Name="button_startSanity" Content="开始刷理智" HorizontalAlignment="Left" Margin="50,300,0,0" VerticalAlignment="Top" Width="120" Height="50" Click="button_Click_startSanity"/>
|
||||
<Button x:Name="button_stop" Content="停止" HorizontalAlignment="Left" Margin="50,380,0,0" VerticalAlignment="Top" Width="300" Height="50" Click="button_Click_stop"/>
|
||||
<Button x:Name="button_stop" Content="停止" HorizontalAlignment="Left" Margin="230,380,0,0" VerticalAlignment="Top" Width="120" Height="50" Click="button_Click_stop"/>
|
||||
<Label x:Name="catch_status" Content="" HorizontalAlignment="Left" Margin="50,30,0,0" VerticalAlignment="Top"/>
|
||||
<Button x:Name="button_visit" Content="访问基建" HorizontalAlignment="Left" Margin="230,300,0,0" VerticalAlignment="Top" Width="120" Height="50" Click="button_Click_visit"/>
|
||||
<Label x:Name="exec_times" Content="" HorizontalAlignment="Left" Margin="230,60,0,0" VerticalAlignment="Top"/>
|
||||
@@ -20,7 +20,8 @@
|
||||
<CheckBox x:Name="checkBox_maxTimes" Content="指定次数" HorizontalAlignment="Left" Margin="50,200,0,0" VerticalAlignment="Top" Checked="checkBox_maxTimes_Checked" Unchecked="checkBox_maxTimes_Checked"/>
|
||||
<TextBox x:Name="textBox_maxTimes" HorizontalAlignment="Left" Height="23" Margin="124,198,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="47" TextChanged="textBox_maxTimes_TextChanged" InputMethod.IsInputMethodEnabled="False"/>
|
||||
<Label x:Name="label" Content="次" HorizontalAlignment="Left" Margin="176,193,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.397,-0.745"/>
|
||||
<CheckBox x:Name="checkBox_shutdown" Content="刷完自动关机" HorizontalAlignment="Left" Margin="50,250,0,0" VerticalAlignment="Top" Checked="checkBox_shutdown_Checked"/>
|
||||
<CheckBox x:Name="checkBox_shutdown" Content="刷完自动关机" HorizontalAlignment="Left" Margin="50,250,0,0" VerticalAlignment="Top"/>
|
||||
<Label x:Name="label_status" Content="" HorizontalAlignment="Left" Margin="230,30,0,0" VerticalAlignment="Top"/>
|
||||
<Button x:Name="button_recruit" Content="全自动公招" HorizontalAlignment="Left" Margin="50,380,0,0" VerticalAlignment="Top" Width="120" Height="50" Click="button_recruit_Click" RenderTransformOrigin="-0.598,0.641"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -1,186 +1,189 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
|
||||
[DllImport("MeoAssistance.dll")] static private extern IntPtr CreateAsst();
|
||||
[DllImport("MeoAssistance.dll")] static private extern void DestoryAsst(IntPtr ptr);
|
||||
[DllImport("MeoAssistance.dll")] static private extern bool AsstCatchEmulator(IntPtr ptr);
|
||||
[DllImport("MeoAssistance.dll")] static private extern void AsstStart(IntPtr ptr, string task);
|
||||
[DllImport("MeoAssistance.dll")] static private extern void AsstStop(IntPtr ptr);
|
||||
[DllImport("MeoAssistance.dll")] static private extern bool AsstSetParam(IntPtr p_asst, string type, string param, string value);
|
||||
[DllImport("MeoAssistance.dll")]
|
||||
static private extern bool AsstGetParam(
|
||||
IntPtr p_asst, string type, string param,
|
||||
[In, Out] StringBuilder lp_string, int buffer_size);
|
||||
|
||||
|
||||
private IntPtr p_asst;
|
||||
UpdateDialog updateDialog;
|
||||
private DispatcherTimer update_times = new DispatcherTimer();
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
~MainWindow()
|
||||
{
|
||||
DestoryAsst(p_asst);
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
p_asst = CreateAsst();
|
||||
update_times.Tick += new EventHandler(updateExecTimes);
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
|
||||
[DllImport("MeoAssistance.dll")] static private extern IntPtr CreateAsst();
|
||||
[DllImport("MeoAssistance.dll")] static private extern void DestoryAsst(IntPtr ptr);
|
||||
[DllImport("MeoAssistance.dll")] static private extern bool AsstCatchEmulator(IntPtr ptr);
|
||||
[DllImport("MeoAssistance.dll")] static private extern void AsstStart(IntPtr ptr, string task);
|
||||
[DllImport("MeoAssistance.dll")] static private extern void AsstStop(IntPtr ptr);
|
||||
[DllImport("MeoAssistance.dll")] static private extern bool AsstSetParam(IntPtr p_asst, string type, string param, string value);
|
||||
[DllImport("MeoAssistance.dll")]
|
||||
static private extern bool AsstGetParam(
|
||||
IntPtr p_asst, string type, string param,
|
||||
[In, Out] StringBuilder lp_string, int buffer_size);
|
||||
|
||||
|
||||
private IntPtr p_asst;
|
||||
private UpdateDialog updateDialog;
|
||||
private RecruitWindow recuitWindow;
|
||||
private DispatcherTimer update_times = new DispatcherTimer();
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
~MainWindow()
|
||||
{
|
||||
DestoryAsst(p_asst);
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
p_asst = CreateAsst();
|
||||
update_times.Tick += new EventHandler(updateExecTimes);
|
||||
update_times.Interval = TimeSpan.FromSeconds(1);
|
||||
|
||||
updateDialog = new UpdateDialog();
|
||||
updateDialog.CheckUpdateAndShowDialog();
|
||||
updateDialog.Close();
|
||||
}
|
||||
private void button_Click_startSanity(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool catched = AsstCatchEmulator(p_asst);
|
||||
catch_status.Content = "捕获模拟器窗口:" + catched;
|
||||
AsstStart(p_asst, "SanityBegin");
|
||||
update_times.Start();
|
||||
}
|
||||
|
||||
private void button_Click_stop(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AsstStop(p_asst);
|
||||
catch_status.Content = "";
|
||||
update_times.Stop();
|
||||
exec_times.Content = "";
|
||||
stone_times.Content = "";
|
||||
label_status.Content = "";
|
||||
}
|
||||
|
||||
private void checkBox_useMedicine_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (checkBox_useMedicine.IsChecked == true)
|
||||
{
|
||||
AsstSetParam(p_asst, "task.type", "UseMedicine", "doNothing");
|
||||
}
|
||||
else
|
||||
{
|
||||
AsstSetParam(p_asst, "task.type", "UseMedicine", "stop");
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_useStone_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (checkBox_useStone.IsChecked == true)
|
||||
{
|
||||
String text = textBox_useStone.Text != String.Empty ? textBox_useStone.Text : "0";
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StoneConfirm", text);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBox_useStone_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (checkBox_useStone.IsChecked == true)
|
||||
{
|
||||
AsstSetParam(p_asst, "task.type", "UseStone", "doNothing");
|
||||
String text = textBox_useStone.Text != String.Empty ? textBox_useStone.Text : "0";
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StoneConfirm", text);
|
||||
}
|
||||
else
|
||||
{
|
||||
AsstSetParam(p_asst, "task.type", "UseStone", "stop");
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StoneConfirm", "0");
|
||||
}
|
||||
}
|
||||
|
||||
private void button_Click_visit(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool catched = AsstCatchEmulator(p_asst);
|
||||
catch_status.Content = "捕获模拟器窗口:" + catched;
|
||||
AsstStart(p_asst, "VisitBegin");
|
||||
}
|
||||
|
||||
private void updateExecTimes(object sender, EventArgs e)
|
||||
{
|
||||
StringBuilder buff_start = new StringBuilder(16);
|
||||
AsstGetParam(p_asst, "task.execTimes", "StartButton2", buff_start, 16);
|
||||
exec_times.Content = "已开始行动 " + buff_start + " 次";
|
||||
|
||||
if (checkBox_useStone.IsChecked == true)
|
||||
{
|
||||
StringBuilder buff_stone = new StringBuilder(16);
|
||||
AsstGetParam(p_asst, "task.execTimes", "StoneConfirm", buff_stone, 16);
|
||||
stone_times.Content = "已碎石 " + buff_stone + " 个";
|
||||
}
|
||||
|
||||
|
||||
StringBuilder buff_running = new StringBuilder(4);
|
||||
AsstGetParam(p_asst, "status", "running", buff_running, 4);
|
||||
if (int.Parse(buff_running.ToString()) == 0)
|
||||
{
|
||||
update_times.Stop();
|
||||
label_status.Content = "已刷完,自动停止";
|
||||
if (checkBox_shutdown.IsChecked == true)
|
||||
{
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-s -t 60");
|
||||
|
||||
MessageBoxResult result = MessageBox.Show("已刷完,即将关机,是否取消?", "提示", MessageBoxButton.OK);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-a");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label_status.Content = "正在运行中……";
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBox_maxTimes_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (checkBox_maxTimes.IsChecked == true)
|
||||
{
|
||||
String text = textBox_maxTimes.Text != String.Empty ? textBox_maxTimes.Text : "0";
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StartButton1", text);
|
||||
}
|
||||
else
|
||||
{
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StartButton1", int.MaxValue.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_maxTimes_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (checkBox_maxTimes.IsChecked == true)
|
||||
{
|
||||
String text = textBox_maxTimes.Text != String.Empty ? textBox_maxTimes.Text : "0";
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StartButton1", text);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBox_shutdown_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
updateDialog = new UpdateDialog();
|
||||
updateDialog.CheckUpdateAndShowDialog();
|
||||
updateDialog.Close();
|
||||
}
|
||||
private void button_Click_startSanity(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool catched = AsstCatchEmulator(p_asst);
|
||||
catch_status.Content = "捕获模拟器窗口:" + catched;
|
||||
AsstStart(p_asst, "SanityBegin");
|
||||
update_times.Start();
|
||||
}
|
||||
|
||||
private void button_Click_stop(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AsstStop(p_asst);
|
||||
catch_status.Content = "";
|
||||
update_times.Stop();
|
||||
exec_times.Content = "";
|
||||
stone_times.Content = "";
|
||||
label_status.Content = "";
|
||||
}
|
||||
|
||||
private void checkBox_useMedicine_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (checkBox_useMedicine.IsChecked == true)
|
||||
{
|
||||
AsstSetParam(p_asst, "task.type", "UseMedicine", "doNothing");
|
||||
}
|
||||
else
|
||||
{
|
||||
AsstSetParam(p_asst, "task.type", "UseMedicine", "stop");
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_useStone_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (checkBox_useStone.IsChecked == true)
|
||||
{
|
||||
String text = textBox_useStone.Text != String.Empty ? textBox_useStone.Text : "0";
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StoneConfirm", text);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBox_useStone_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (checkBox_useStone.IsChecked == true)
|
||||
{
|
||||
AsstSetParam(p_asst, "task.type", "UseStone", "doNothing");
|
||||
String text = textBox_useStone.Text != String.Empty ? textBox_useStone.Text : "0";
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StoneConfirm", text);
|
||||
}
|
||||
else
|
||||
{
|
||||
AsstSetParam(p_asst, "task.type", "UseStone", "stop");
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StoneConfirm", "0");
|
||||
}
|
||||
}
|
||||
|
||||
private void button_Click_visit(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool catched = AsstCatchEmulator(p_asst);
|
||||
catch_status.Content = "捕获模拟器窗口:" + catched;
|
||||
AsstStart(p_asst, "VisitBegin");
|
||||
}
|
||||
|
||||
private void updateExecTimes(object sender, EventArgs e)
|
||||
{
|
||||
StringBuilder buff_start = new StringBuilder(16);
|
||||
AsstGetParam(p_asst, "task.execTimes", "StartButton2", buff_start, 16);
|
||||
exec_times.Content = "已开始行动 " + buff_start + " 次";
|
||||
|
||||
if (checkBox_useStone.IsChecked == true)
|
||||
{
|
||||
StringBuilder buff_stone = new StringBuilder(16);
|
||||
AsstGetParam(p_asst, "task.execTimes", "StoneConfirm", buff_stone, 16);
|
||||
stone_times.Content = "已碎石 " + buff_stone + " 个";
|
||||
}
|
||||
|
||||
|
||||
StringBuilder buff_running = new StringBuilder(4);
|
||||
AsstGetParam(p_asst, "status", "running", buff_running, 4);
|
||||
if (int.Parse(buff_running.ToString()) == 0)
|
||||
{
|
||||
update_times.Stop();
|
||||
label_status.Content = "已刷完,自动停止";
|
||||
if (checkBox_shutdown.IsChecked == true)
|
||||
{
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-s -t 60");
|
||||
|
||||
MessageBoxResult result = MessageBox.Show("已刷完,即将关机,是否取消?", "提示", MessageBoxButton.OK);
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-a");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label_status.Content = "正在运行中……";
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBox_maxTimes_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (checkBox_maxTimes.IsChecked == true)
|
||||
{
|
||||
String text = textBox_maxTimes.Text != String.Empty ? textBox_maxTimes.Text : "0";
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StartButton1", text);
|
||||
}
|
||||
else
|
||||
{
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StartButton1", int.MaxValue.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_maxTimes_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (checkBox_maxTimes.IsChecked == true)
|
||||
{
|
||||
String text = textBox_maxTimes.Text != String.Empty ? textBox_maxTimes.Text : "0";
|
||||
AsstSetParam(p_asst, "task.maxTimes", "StartButton1", text);
|
||||
}
|
||||
}
|
||||
|
||||
private void button_recruit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
recuitWindow = new RecruitWindow(p_asst);
|
||||
recuitWindow.ShowDialog();
|
||||
recuitWindow.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,9 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="RecruitWindow.xaml.cs">
|
||||
<DependentUpon>RecruitWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UpdateDialog.xaml.cs">
|
||||
<DependentUpon>UpdateDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -91,6 +94,10 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="RecruitWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UpdateDialog.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
19
MeoAsstGui/RecruitWindow.xaml
Normal file
19
MeoAsstGui/RecruitWindow.xaml
Normal file
@@ -0,0 +1,19 @@
|
||||
<Window x:Class="MeoAsstGui.RecruitWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:MeoAsstGui"
|
||||
mc:Ignorable="d"
|
||||
Title="全自动公开招募计算器" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Label x:Name="info" Content="计算结果" HorizontalAlignment="Left" Margin="30,10,-467.667,0" VerticalAlignment="Top" Height="270" Width="1231"/>
|
||||
<Button x:Name="button_start" Content="开始计算" HorizontalAlignment="Left" Margin="600,0,0,30" VerticalAlignment="Bottom" Width="150" Height="60" Click="button_start_Click"/>
|
||||
<CheckBox x:Name="checkBox_time" Content="自动设置时间" HorizontalAlignment="Left" Margin="30,0,0,80" VerticalAlignment="Bottom" IsChecked="True"/>
|
||||
<CheckBox x:Name="checkBox_level_3" Content="自动选择3星Tags" HorizontalAlignment="Left" Margin="150,0,0,120" VerticalAlignment="Bottom"/>
|
||||
<CheckBox x:Name="checkBox_level_4" Content="自动选择4星Tags" HorizontalAlignment="Left" Margin="150,0,0,90" VerticalAlignment="Bottom" IsChecked="True"/>
|
||||
<CheckBox x:Name="checkBox_level_5" Content="自动选择5星Tags" HorizontalAlignment="Left" Margin="150,0,0,60" VerticalAlignment="Bottom"/>
|
||||
<CheckBox x:Name="checkBox_level_6" Content="自动选择6星Tags" HorizontalAlignment="Left" Margin="150,0,0,30" VerticalAlignment="Bottom"/>
|
||||
<Label x:Name="prompt" Content="提示:本辅助仅会帮你选择最优Tags,
但是不会帮你点击确定按钮!!!
请自行检查辅助选择的是否正确,
若辅助出现识别错误,遗漏了高星干员,
作者概不负责哦__(:з」∠)_" HorizontalAlignment="Left" Margin="300,0,0,10" VerticalAlignment="Bottom" Height="121" Width="292" FontSize="16"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
76
MeoAsstGui/RecruitWindow.xaml.cs
Normal file
76
MeoAsstGui/RecruitWindow.xaml.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
/// <summary>
|
||||
/// RecruitWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class RecruitWindow : Window
|
||||
{
|
||||
[DllImport("MeoAssistance.dll")] static private extern bool AsstCatchEmulator(IntPtr ptr);
|
||||
[DllImport("MeoAssistance.dll")] static private extern bool AsstRunOpenRecruit(IntPtr ptr, int[] required_level, bool set_time, [In, Out] StringBuilder result, int buffer_size, ref int maybe_level);
|
||||
|
||||
private IntPtr p_asst;
|
||||
public RecruitWindow(IntPtr ptr)
|
||||
{
|
||||
InitializeComponent();
|
||||
p_asst = ptr;
|
||||
}
|
||||
|
||||
private void button_start_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
info.Content = "正在计算……";
|
||||
|
||||
if (!AsstCatchEmulator(p_asst))
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<int> level_list = new List<int>();
|
||||
|
||||
if (checkBox_level_3.IsChecked == true)
|
||||
{
|
||||
level_list.Add(3);
|
||||
}
|
||||
if (checkBox_level_4.IsChecked == true)
|
||||
{
|
||||
level_list.Add(4);
|
||||
}
|
||||
if (checkBox_level_5.IsChecked == true)
|
||||
{
|
||||
level_list.Add(5);
|
||||
}
|
||||
if (checkBox_level_6.IsChecked == true)
|
||||
{
|
||||
level_list.Add(6);
|
||||
}
|
||||
StringBuilder result_buff = new StringBuilder(16384);
|
||||
int maybe_level = 0;
|
||||
bool set_time = checkBox_time.IsChecked == true ? true : false;
|
||||
if (AsstRunOpenRecruit(p_asst, level_list.ToArray(), set_time, result_buff, 16384, ref maybe_level))
|
||||
{
|
||||
info.Content = result_buff;
|
||||
if (maybe_level > 3)
|
||||
{
|
||||
MessageBox.Show("出" + maybe_level + "星了哦!", "公招提示");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info.Content = "识别错误!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ void asst_ocr_test()
|
||||
std::string person_name;
|
||||
ifs >> person_name;
|
||||
|
||||
asst.find_and_clac_tags();
|
||||
asst.open_recruit({ 4, 5 });
|
||||
|
||||
c = getchar();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user