Compare commits

...

10 Commits

Author SHA1 Message Date
c7b6c87d61 调整ico图片为jpg,使得更加直观 2024-10-18 11:51:21 +08:00
c5213e6804 增加提示功能 2024-10-17 19:56:23 +08:00
017edb3018 增加变量环境版本 2024-10-17 18:53:10 +08:00
f8cd167769 1-数据源模式修改为下拉菜单选择 2024-10-17 15:07:08 +08:00
e097174bb9 修复luapacka.exe删除失败问题 2024-10-17 14:05:49 +08:00
77ae838f0a 调整UI,调整编译EXE 2024-10-15 18:50:14 +08:00
c2abae6119 1-修复删除入库信息BUG问题
2-修复源删除BUG
2024-10-15 18:39:14 +08:00
6c8b430f77 增加入库源信息
增加更新功能
调整拉取信息参数
调整读取本地json函数名
删除curl全局初始化函数
2024-10-15 11:05:44 +08:00
6b9bb016c8 修复全DLC列表错误问题
修复文本描述错误问题
增加默认测试列表,并非单个
2024-10-14 18:13:16 +08:00
0b55dfd546 1-全部表单选
2-取消默认入库UID
3-对DLC信息进行增加
2024-10-14 13:38:50 +08:00
27 changed files with 555 additions and 287 deletions

View File

@ -108,7 +108,9 @@
"shared_mutex": "cpp", "shared_mutex": "cpp",
"qgroupbox": "cpp", "qgroupbox": "cpp",
"qheaderview": "cpp", "qheaderview": "cpp",
"qabstractlistmodel": "cpp" "qabstractlistmodel": "cpp",
"qtconcurrentrun": "cpp",
"*.in": "cpp"
}, },
"Codegeex.RepoIndex": true "Codegeex.RepoIndex": true
} }

View File

@ -44,8 +44,7 @@ endif()
#QT .cmake #QT .cmake
#QT #QT
SET(QT_DIR "D:/Dev/Qt/6.8.0/mingw1310_static_x64/lib/cmake") SET(QT_DIR "D:/Dev/Qt/6.8.0/mingw1310_static_x64/lib/cmake")
#Msys2
#SET(QT_DIR "D:/Dev/msys64/mingw64/qt6-static/lib/cmake")
SET(JSON ${PROJECT_SOURCE_DIR}/3rdparty/json) SET(JSON ${PROJECT_SOURCE_DIR}/3rdparty/json)
LIST(APPEND CMAKE_PREFIX_PATH ${QT_DIR} ${MSYS}) LIST(APPEND CMAKE_PREFIX_PATH ${QT_DIR} ${MSYS})
@ -151,11 +150,25 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -fstack-check")
# #
target_link_options(${PROJECT_NAME} PUBLIC -Wl,--allow-multiple-definition) target_link_options(${PROJECT_NAME} PUBLIC -Wl,--allow-multiple-definition)
#
#SET(CMAKE_EXE_LINKER_FLAGS -static)
#set_property(TARGET harfbuzz::harfbuzz PROPERTY # GCC
# IMPORTED_IMPLIB "D:/Dev/msys64/mingw64/lib/libharfbuzz.dll.a" ) message(STATUS "G++ version: ${CMAKE_CXX_COMPILER_VERSION}")
# CMAKE_
foreach(var IN LISTS CMAKE_VARIABLES)
if(var MATCHES "^CMAKE_")
message(STATUS "${var} = ${${var}}")
endif()
endforeach()
# Qt
SET(QT_VERSION_STR "${Qt6_VERSION}")
# Qt
message(STATUS "Qt Version: ${QT_VERSION_STR}")
#
configure_file (version.h.in version.h @ONLY)
#
SET(CMAKE_EXE_LINKER_FLAGS -static)
target_link_libraries( target_link_libraries(
${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets PkgConfig::LIBGIT2 PkgConfig::CURL ${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets PkgConfig::LIBGIT2 PkgConfig::CURL
) )

View File

@ -6,6 +6,7 @@
"generator": "Ninja", "generator": "Ninja",
"binaryDir": "${sourceDir}/build", "binaryDir": "${sourceDir}/build",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE":"Release",
"CMAKE_MAKE_PROGRAM": "ninja.exe", "CMAKE_MAKE_PROGRAM": "ninja.exe",
"CMAKE_C_COMPILER": "x86_64-w64-mingw32-gcc.exe", "CMAKE_C_COMPILER": "x86_64-w64-mingw32-gcc.exe",
"CMAKE_CXX_COMPILER": "x86_64-w64-mingw32-g++.exe", "CMAKE_CXX_COMPILER": "x86_64-w64-mingw32-g++.exe",

View File

@ -32,6 +32,26 @@ QGroupBox#GAME_INFO_GROUP,QGroupBox#ALL_DLC_GROUP{
QTableView#GAME_INFO_TABLE::item:selected { QTableView#GAME_INFO_TABLE::item:selected {
background-color: #0078d4; background-color: #0078d4;
} }
QMenu {
background-color: #444;
color: #fff;
border: 1px solid #666;
}
QMenu::item {
padding: 2px 20px 2px 20px;
}
QMenu::icon:checked {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:1 #fff, stop:0 #aaa);
}
QMenu::item:selected {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:1 #ffc, stop:0 #9c9);
color: black;
}
/*------------------标题栏样式 最小化 最大化 关闭---------------------*/ /*------------------标题栏样式 最小化 最大化 关闭---------------------*/
/*标题栏变量参数值定义*/ /*标题栏变量参数值定义*/
/*标题栏背景*/ /*标题栏背景*/
@ -75,6 +95,6 @@ QPushButton#min_button:hover,QPushButton#max_button:hover,QPushButton#close_butt
} }
QPushButton#min_button:pressed,QPushButton#max_button:pressed,QPushButton#close_button:pressed{ QPushButton#min_button:pressed,QPushButton#max_button:pressed,QPushButton#close_button:pressed{
padding-left:2px; padding-left:1px;
padding-top:2px; padding-top:1px;
} }

View File

@ -1,3 +1,7 @@
QWidget#m_widget{
background-color: #F3F3F3;
color:#2F4F4F;
}
QWidget#m_widget{ QWidget#m_widget{
border-radius:10px; border-radius:10px;
background-color: #F3F3F3; background-color: #F3F3F3;
@ -34,6 +38,7 @@ QGroupBox#GAME_INFO_GROUP,QGroupBox#ALL_DLC_GROUP{
QTableView#GAME_INFO_TABLE::item:selected { QTableView#GAME_INFO_TABLE::item:selected {
background-color: #0078d4; background-color: #0078d4;
} }
/*------------------标题栏样式 最小化 最大化 关闭---------------------*/ /*------------------标题栏样式 最小化 最大化 关闭---------------------*/
/*标题栏变量参数值定义*/ /*标题栏变量参数值定义*/
/*标题栏背景*/ /*标题栏背景*/
@ -77,6 +82,6 @@ QPushButton#min_button:hover,QPushButton#max_button:hover,QPushButton#close_butt
} }
QPushButton#min_button:pressed,QPushButton#max_button:pressed,QPushButton#close_button:pressed{ QPushButton#min_button:pressed,QPushButton#max_button:pressed,QPushButton#close_button:pressed{
padding-left:2px; padding-left:1px;
padding-top:2px; padding-top:1px;
} }

View File

@ -1,18 +1,16 @@
 About XSteam  作者申明
software name:XSteam
builder:JackLee_CN
github:vek-zvo
src github(don't open)
作者申明
本软件仅供学习和研究,软件内置数据仅限于测试. 本软件仅供学习和研究,软件内置数据仅限于测试.
开发者不对本软件所造成的计算机软件侵权法律问题承担任何法律责任. 开发者不对本软件所造成的计算机软件侵权法律问题承担任何法律责任.
禁止本软件源码和软件用于任何商业用途. 禁止本软件源码和软件用于任何商业用途.
禁止任何人恶意举报本软件 禁止任何人恶意举报本软件
禁止任何人恶意盗窃本软件测试数据 禁止任何人恶意盗窃本软件测试数据
鸣谢列表 鸣谢列表
皓月代码托管平台 皓月代码托管平台
倒卖商用举报黑名单 About XSteam
software name:XSteam
builder:JackLee_CN
github:vek-zvo
src github(don't open)

View File

@ -27,8 +27,8 @@ void sui::init_layout()
setWindowFlags(Qt::FramelessWindowHint); setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
setMouseTracking(true); setMouseTracking(true);
setBaseSize(660, 600); setBaseSize(800, 600);
resize(660, 600); resize(800, 600);
setLayout(m_layout); setLayout(m_layout);
} }

View File

@ -32,6 +32,12 @@ void xsteam_about_ui::load_about()
QByteArray line = file.readLine(); QByteArray line = file.readLine();
strs.append(QString::fromStdString(line.data())); strs.append(QString::fromStdString(line.data()));
} }
strs.append(QString::fromStdString("编译环境")+"\n");
strs.append("qt_version:"+QString::fromStdString(QT_VERSION_STR)+"\n");
strs.append("gcc_version:"+QString::fromStdString(GCC_GXX_VERSION_STR)+"\n");
strs.append("g++_version:"+QString::fromStdString(GCC_GXX_VERSION_STR)+"\n");
strs.append("libcurl_version:"+QString::fromStdString(LIBCURL_VERSION_STR)+"\n");
strs.append("libgit2_version:"+QString::fromStdString(LIBGIT2_VERSION_STR)+"\n");
info->setPlainText(strs); info->setPlainText(strs);
} }
} }

View File

@ -9,6 +9,7 @@
#include <QFile> #include <QFile>
#include <QIODevice> #include <QIODevice>
#include <QLabel> #include <QLabel>
#include <version.h>
class xsteam_about_ui :public QDialog{ class xsteam_about_ui :public QDialog{
Q_OBJECT Q_OBJECT
@ -34,14 +35,14 @@ private:
const xsteam_about_ui &operator=(const xsteam_about_ui &other); const xsteam_about_ui &operator=(const xsteam_about_ui &other);
static xsteam_about_ui* _instance; static xsteam_about_ui* _instance;
static QMutex mutex; static QMutex mutex;
QVBoxLayout* m_Layout=nullptr; QVBoxLayout* m_Layout={};
QHBoxLayout* f_Layout=nullptr; QHBoxLayout* f_Layout={};
QTextEdit* info=nullptr; QTextEdit* info={};
void load_about(); void load_about();
QLabel* copyright_tips_txt; QLabel* copyright_tips_txt;
QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed); QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed);
}; };
xsteam_about_ui *xsteam_about_ui::_instance = nullptr; xsteam_about_ui *xsteam_about_ui::_instance = {};
QMutex xsteam_about_ui::mutex; QMutex xsteam_about_ui::mutex;
#endif #endif

View File

@ -19,6 +19,11 @@ typedef enum{
STEAMTOOLS STEAMTOOLS
}RUN_MODE; }RUN_MODE;
typedef enum
{
PUSH_ADD,
PUSH_UPDATE
} PUSH_MODE;
// vdf file read mode // vdf file read mode
typedef enum typedef enum
{ {
@ -41,6 +46,7 @@ typedef struct
std::string uid = {}; std::string uid = {};
std::string m_time = {}; std::string m_time = {};
std::string i_time = {}; std::string i_time = {};
std::string s_name = {};
std::vector<std::string> n_dlc={}; std::vector<std::string> n_dlc={};
std::vector<std::string> r_dlc={}; std::vector<std::string> r_dlc={};
std::vector<std::string> manifest = {}; std::vector<std::string> manifest = {};
@ -64,12 +70,6 @@ typedef struct
std::string steam_logo_url={}; std::string steam_logo_url={};
} XSteamConfig; } XSteamConfig;
typedef struct
{
std::string t_g_uid = {};
std::string t_s_name{};
} InputData;
// gloabal data // gloabal data
typedef struct typedef struct
{ {
@ -99,4 +99,8 @@ extern QStringList ex_in_dlc_table_head_tips;
extern QStringList ex_all_dlc_table_head_tips; extern QStringList ex_all_dlc_table_head_tips;
extern QStringList ex_default_src_name;
extern QStringList ex_default_src_url;
#endif #endif

View File

@ -9,14 +9,26 @@ QString ex_base_exe_ex;
QString ex_save_path; QString ex_save_path;
QString ex_save_path_ex; QString ex_save_path_ex;
QStringList ex_src_table_head_tips = {QStringLiteral("Src Name"), QStringLiteral("Git Mode"), QStringLiteral("Url")}; QStringList ex_src_table_head_tips = {QStringLiteral("源名称"), QStringLiteral("GIT模式"), QStringLiteral("地址")};
QStringList ex_uid_table_head_tips = {QStringLiteral("游戏ICO"),QStringLiteral("游戏UID"),QStringLiteral("游戏名"), QStringList ex_uid_table_head_tips = {QStringLiteral("游戏ICO"),QStringLiteral("游戏UID"),QStringLiteral("游戏名"),
QStringLiteral("更新时间"),QStringLiteral("入库时间")}; QStringLiteral("更新时间"),QStringLiteral("入库时间"),QStringLiteral("源服务器")};
QStringList ex_in_dlc_table_head_tips = {QStringLiteral("已增加DLC")}; QStringList ex_in_dlc_table_head_tips = {QStringLiteral("已增加DLC")};
QStringList ex_all_dlc_table_head_tips = {QStringLiteral("DLC列表")}; QStringList ex_all_dlc_table_head_tips = {QStringLiteral("DLC列表")};
QStringList ex_default_src_name = {QStringLiteral("ikun0014"),
QStringLiteral("ManifestHub "),
QStringLiteral("fast_ikun0014"),
QStringLiteral("fast_ManifestHub ")
};
QStringList ex_default_src_url = {QStringLiteral("https://github.com/ikun0014/ManifestHub"),
QStringLiteral("https://github.com/ManifestHub/ManifestHub.git"),
QStringLiteral("https://githubfast.com/ikun0014/ManifestHub.git"),
QStringLiteral("https://githubfast.com/ManifestHub/ManifestHub.git"),
};
GloablData _data; GloablData _data;
#endif // STEAM_BASE_EX_H #endif // STEAM_BASE_EX_H

View File

@ -31,7 +31,6 @@ std::string xsteam_curl::get_steam_id_info(std::string api_url,std::string _c_ui
{ {
std::string u_str = api_url + _c_uid; std::string u_str = api_url + _c_uid;
std::string strRsp; std::string strRsp;
curl_global_init(CURL_GLOBAL_DEFAULT);
init_curl(); init_curl();
CURLcode res = CURLE_QUOTE_ERROR; CURLcode res = CURLE_QUOTE_ERROR;
int retry = 3; int retry = 3;
@ -83,12 +82,11 @@ bool xsteam_curl::get_steam_header_ico(std::string logo_url,std::string _c_uid)
{ {
std::string base_str=QDir::currentPath().toStdString(); std::string base_str=QDir::currentPath().toStdString();
QDir dir(QString::fromStdString(base_str + "/save/img")); QDir dir(QString::fromStdString(base_str + "/save/img"));
std::string u_str = logo_url + _c_uid + "/logo.png"; std::string u_str = logo_url + _c_uid + "/header.jpg";
std::string s_str = base_str + "/save/img/" + _c_uid + ".png"; std::string s_str = base_str + "/save/img/" + _c_uid + ".jpg";
if(!dir.exists()){ if(!dir.exists()){
QDir().mkpath(QString::fromStdString(base_str + "/save/img")); QDir().mkpath(QString::fromStdString(base_str + "/save/img"));
} }
curl_global_init(CURL_GLOBAL_ALL);
init_curl(); init_curl();
// 访问网址 // 访问网址
curl_easy_setopt(curl, CURLOPT_URL, u_str.c_str()); curl_easy_setopt(curl, CURLOPT_URL, u_str.c_str());

View File

@ -12,7 +12,7 @@ void xsteam_init_opts()
ex_save_path = ex_base_exe_path + QStringLiteral("/save"); ex_save_path = ex_base_exe_path + QStringLiteral("/save");
// current dir+/save/ // current dir+/save/
ex_save_path_ex = ex_save_path + QStringLiteral("/"); ex_save_path_ex = ex_save_path + QStringLiteral("/");
xsteam_save_data_read(); xsteam_data_unserialize();
if (_data.s_data.size() > 0) if (_data.s_data.size() > 0)
{ {
for (auto x : _data.s_data) for (auto x : _data.s_data)
@ -152,35 +152,23 @@ void xsteam_vdf_read_key(vdf::object vdf_data, UidData &u_data)
{ {
std::cout << vdf_data.name << std::endl; std::cout << vdf_data.name << std::endl;
std::map<std::string, std::string> keys; std::map<std::string, std::string> keys;
u_data.uid_key.clear();
for (auto &k : vdf_data.childs) for (auto &k : vdf_data.childs)
{ {
std::string u_id = k.first; std::string u_id = k.first;
std::string u_key = k.second->attribs.find("DecryptionKey")->second; std::string u_key = k.second->attribs.find("DecryptionKey")->second;
if (std::to_string((std::stoi(u_data.uid) + 1)) == u_id) // 游戏UID depots的key
{ qDebug() << QString::fromStdString(u_id) << ":" << QString::fromStdString(u_key);
qDebug() << QString::fromStdString(u_id) << ":" << QString::fromStdString(u_key); u_data.uid_key.insert(std::pair<std::string, std::string>(u_id, u_key));
u_data.uid_key.insert(std::pair<std::string, std::string>(u_id, u_key));
}
else
{
// 考虑是否需要仅仅针对dlc自行保存key的值.是否全部读入data.json内
for (auto x : u_data.n_dlc)
{
if (std::to_string((std::stoi(x) + 1)) == u_id)
{
qDebug() << QString::fromStdString(u_id) << ":" << QString::fromStdString(u_key);
u_data.uid_key.insert(std::pair<std::string, std::string>(u_id, u_key));
}
}
}
} }
} }
// 读取指定uid目录下的文件名 // 读取指定uid目录下的文件名
void xsteam_vdf_manifest_name(QString uid_dir, UidData &u_data) void xsteam_vdf_manifest_name(QString uid_dir, UidData &u_data)
{ {
QDir _uid_dir(uid_dir); QDir _uid_dir(uid_dir);
QStringList _manifest_list = _uid_dir.entryList(QStringList() << "*.manifest", QDir::Files); QStringList manifest_list = _uid_dir.entryList(QStringList() << "*.manifest", QDir::Files);
for (auto &x : _manifest_list) u_data.manifest.clear();
for (auto &x : manifest_list)
{ {
u_data.manifest.push_back(x.toStdString()); u_data.manifest.push_back(x.toStdString());
} }
@ -216,10 +204,10 @@ void xsteam_vdf_edit(vdf::object, std::map<std::string, std::string> data, VDF_E
} }
} }
// curl get steam id info to _data // curl get steam id info to _data
bool xsteam_curl_steam_id_app_info(std::string uid, UidData &u_data) bool xsteam_curl_steam_id_app_info(UidData &u_data)
{ {
xsteam_curl *_x_curl = new xsteam_curl(); xsteam_curl *_x_curl = new xsteam_curl();
auto info_str = _x_curl->get_steam_id_info(_data.x_config.steam_api_url, uid); auto info_str = _x_curl->get_steam_id_info(_data.x_config.steam_api_url, u_data.uid);
delete _x_curl; delete _x_curl;
_x_curl = nullptr; _x_curl = nullptr;
if (info_str == "error" || info_str == "") if (info_str == "error" || info_str == "")
@ -237,7 +225,6 @@ bool xsteam_curl_steam_id_app_info(std::string uid, UidData &u_data)
std::cerr << "位置:字符索引 " << e.byte << std::endl; std::cerr << "位置:字符索引 " << e.byte << std::endl;
return false; return false;
} }
u_data.uid = uid;
qDebug() << QString::fromStdString(info_json.dump(4)); qDebug() << QString::fromStdString(info_json.dump(4));
for (auto &root_data : info_json.items()) for (auto &root_data : info_json.items())
{ {
@ -255,9 +242,14 @@ bool xsteam_curl_steam_id_app_info(std::string uid, UidData &u_data)
{ {
if (data.key() == "dlc") if (data.key() == "dlc")
{ {
for (auto x : data.value()) if (data.value().size() > 0)
{ {
u_data.r_dlc.push_back(x.dump());
u_data.r_dlc.clear();
for (auto x : data.value())
{
u_data.r_dlc.push_back(x.dump());
}
} }
} }
} }
@ -271,7 +263,7 @@ bool xsteam_curl_steam_id_app_info(std::string uid, UidData &u_data)
return false; return false;
} }
// 读取xsteam软件保存在save目录下的data.json并且反序列化读取到全局变量内 // 读取xsteam软件保存在save目录下的data.json并且反序列化读取到全局变量内
void xsteam_save_data_read() void xsteam_data_unserialize()
{ {
QString save_file = ex_save_path_ex + "data.json"; QString save_file = ex_save_path_ex + "data.json";
if (!QDir(ex_save_path).exists()) if (!QDir(ex_save_path).exists())
@ -322,6 +314,8 @@ void xsteam_save_data_read()
_temp_data.i_time = x.value().at("In_Time"); _temp_data.i_time = x.value().at("In_Time");
_temp_data.m_time = x.value().at("Up_Time"); _temp_data.m_time = x.value().at("Up_Time");
_temp_data.ico = x.value().at("Ico"); _temp_data.ico = x.value().at("Ico");
_temp_data.s_name = x.value().at("Src_Name");
if (x.value().contains("Manifest")) if (x.value().contains("Manifest"))
{ {
_temp_data.manifest = x.value().at("Manifest").get<std::vector<std::string>>(); _temp_data.manifest = x.value().at("Manifest").get<std::vector<std::string>>();
@ -359,14 +353,18 @@ void xsteam_save_data_read()
{ {
// 当本地保存数据文件不存在或者读取data.json文件出错或者导致用户修改配置使得读取data.json出错. // 当本地保存数据文件不存在或者读取data.json文件出错或者导致用户修改配置使得读取data.json出错.
// 默认测试数据源 // 默认测试数据源
SrcData _src_data; for (int i = 0; i <= ex_default_src_name.count() - 1; i++)
_src_data.src_name = "FastGitHud"; {
_src_data.src_url = "https://githubfast.com/ManifestHub/ManifestHub.git"; SrcData _src_data;
_src_data.src_type = GIT_MODE::TAG; _src_data.src_name = ex_default_src_name[i].toStdString();
_data.s_data.push_back(_src_data); _src_data.src_url = ex_default_src_url[i].toStdString();
_src_data.src_type = GIT_MODE::TAG;
_data.s_data.push_back(_src_data);
}
// 默认配置 // 默认配置
_data.x_config.font = 0; _data.x_config.font = 0;
_data.x_config.font_bold=0; _data.x_config.font_bold = 0;
_data.x_config.style = 1; _data.x_config.style = 1;
QSettings settings("HKEY_CURRENT_USER\\Software\\Valve\\Steam", QSettings::NativeFormat); QSettings settings("HKEY_CURRENT_USER\\Software\\Valve\\Steam", QSettings::NativeFormat);
_data.x_config.steam_dir = (settings.value("SteamPath", "").toString()).toStdString(); _data.x_config.steam_dir = (settings.value("SteamPath", "").toString()).toStdString();
@ -404,6 +402,7 @@ json xsteam_data_serialize(json jsonData)
jsonData[toStr(uid_data)][u.uid][toStr(Up_Time)] = u.m_time; jsonData[toStr(uid_data)][u.uid][toStr(Up_Time)] = u.m_time;
// 游戏ico图标参数 // 游戏ico图标参数
jsonData[toStr(uid_data)][u.uid][toStr(Ico)] = u.ico; jsonData[toStr(uid_data)][u.uid][toStr(Ico)] = u.ico;
jsonData[toStr(uid_data)][u.uid][toStr(Src_Name)] = u.s_name;
// 游戏清单列表 // 游戏清单列表
for (auto &w : u.manifest) for (auto &w : u.manifest)
{ {
@ -470,36 +469,44 @@ bool xsteam_lua_to_com(UidData u_data)
1-UID和DLC末尾为0是游戏的解锁代码 1-UID和DLC末尾为0是游戏的解锁代码
2-UID内末尾为1则是windows系统的文件包 2-UID内末尾为1则是windows系统的文件包
*/ */
// 游戏UID-0
lua_str = "addappid(" + QString::fromStdString(u_data.uid) + ",1,\"None\")"; lua_str = "addappid(" + QString::fromStdString(u_data.uid) + ",1,\"None\")";
dp << lua_str.toStdString() << "\n"; dp << lua_str.toStdString() << "\n";
qDebug() << "UID_KEY_0" << lua_str.toStdString();
// 增加已经入库的DLC的UID-0
for (auto &x : u_data.n_dlc) for (auto &x : u_data.n_dlc)
{ {
for (auto [u, w] : u_data.uid_key) // 增加DLC的uid同时必须和uid_key列表的u比对只增加远程服务器有的DLC
lua_str = "addappid(" + QString::fromStdString(x) + ",1,\"None\")";
dp << lua_str.toStdString() << "\n";
qDebug() << "DLC_KEY_0" << lua_str.toStdString();
}
for (auto &[uid, key] : u_data.uid_key)
{
if (std::to_string((std::stoi(u_data.uid) + 1)) == uid)
{ {
if (std::to_string((std::stoi(x) + 1)) == u) // 增加游戏本体的uid和key
lua_str = "addappid(" + QString::fromStdString(uid) + ",1," + "\"" + QString::fromStdString(key) + "\"" + ")";
dp << lua_str.toStdString() << "\n";
qDebug() << "UID_KEY:" << lua_str.toStdString();
}
}
for (auto &d_id : u_data.n_dlc)
{
for (auto &[uid, key] : u_data.uid_key)
{
if (std::to_string((std::stoi(d_id) + 1)) == uid)
{ {
// 增加DLC的uid同时必须和uid_key列表的u比对只增加远程服务器有的DLC // 增加DLC的uid和key
lua_str = "addappid(" + QString::fromStdString(x) + ",1,\"None\")"; lua_str = "addappid(" + QString::fromStdString(uid) + ",1," + "\"" + QString::fromStdString(key) + "\"" + ")";
dp << lua_str.toStdString() << "\n"; dp << lua_str.toStdString() << "\n";
qDebug() << "DLC_KEY:" << lua_str.toStdString();
} }
} }
} }
for (auto &[u, w] : u_data.uid_key)
{
qDebug() << "u:" << QString::fromStdString(u) << "w:" << QString::fromStdString(w);
if (std::to_string((std::stoi(u_data.uid) + 1)) == u)
{
// 增加游戏本体的uid和key
lua_str = "addappid(" + QString::fromStdString(u) + ",1," + "\"" + QString::fromStdString(w) + "\"" + ")";
}
else
{
// 增加DLC的uid和key
lua_str = "addappid(" + QString::fromStdString(u) + ",1," + "\"" + QString::fromStdString(w) + "\"" + ")";
}
dp << lua_str.toStdString() << "\n";
}
dp.close(); dp.close();
qDebug() << "n_dlc_size:" << u_data.n_dlc;
// luapacka文件不存在则释放luapacka.exe文件 // luapacka文件不存在则释放luapacka.exe文件
if (!_lua_packa_file.exists()) if (!_lua_packa_file.exists())
{ {
@ -518,14 +525,15 @@ bool xsteam_lua_to_com(UidData u_data)
m_cmd->kill(); m_cmd->kill();
delete m_cmd; delete m_cmd;
m_cmd = nullptr; m_cmd = nullptr;
std::cout <<"lua_file exists:"<<_lua_file.exists()<<std::endl; std::cout << "lua_file exists:" << _lua_file.exists() << std::endl;
std::cout <<"lua_packa_file exists:"<<_lua_packa_file.exists()<<std::endl; std::cout << "lua_packa_file exists:" << _lua_packa_file.exists() << std::endl;
if (_lua_file.exists()) if (_lua_file.exists())
{ {
_lua_file.remove(); _lua_file.remove();
}; };
if (_lua_packa_file.exists()) if (_lua_packa_file.exists())
{ {
QFile::setPermissions(lua_packa_file,QFile::ReadOther | QFile::WriteOther);
_lua_packa_file.remove(); _lua_packa_file.remove();
}; };
return true; return true;
@ -592,23 +600,26 @@ bool xsteam_steam_steamtools_exists(bool &steam_ok, bool &steamtools_ok)
} }
void xsteam_delete_uid_st(std::string uid) void xsteam_delete_uid_st(std::string uid)
{ {
for (auto it = _data.u_data.begin(); it != _data.u_data.end();) for (auto it = _data.u_data.begin(); it != _data.u_data.end(); ++it)
{ {
if (it->uid == uid) if (it->uid == uid)
{ {
it = _data.u_data.erase(it); QFile st(QString::fromStdString(_data.x_config.steamtools_st_dir + uid + ".st"));
QFile st(QString::fromStdString(_data.x_config.steamtools_st_dir+uid+".st")); if (st.exists())
if(st.exists()){ {
st.remove(); st.remove();
} }
xsteam_save_data_write(); _data.u_data.erase(it);
xsteam_save_data_write();
break; break;
} }
} }
} }
bool xsteam_src_data_exists(std::string src_name){ bool xsteam_src_data_exists(std::string src_name)
{
QString save_file_str = ex_save_path_ex + "tags_" + QString::fromStdString(src_name) + ".data"; QString save_file_str = ex_save_path_ex + "tags_" + QString::fromStdString(src_name) + ".data";
if(QFile(save_file_str).exists()){ if (QFile(save_file_str).exists())
{
return true; return true;
} }
return false; return false;

View File

@ -34,7 +34,7 @@ extern void xsteam_vdf_edit(vdf::object obj,std::map<std::string,std::string>,VD
extern void xsteam_vdf_delete(QString d_string,...); extern void xsteam_vdf_delete(QString d_string,...);
extern void xsteam_run_steam_steamtools(RUN_MODE); extern void xsteam_run_steam_steamtools(RUN_MODE);
extern bool xsteam_lua_to_com(UidData u_data); extern bool xsteam_lua_to_com(UidData u_data);
extern bool xsteam_curl_steam_id_app_info(std::string uid, UidData& u_data); extern bool xsteam_curl_steam_id_app_info(UidData& u_data);
extern void xsteam_vdf_free_dir_file(UidData u_data); extern void xsteam_vdf_free_dir_file(UidData u_data);
extern void xsteam_delete_uid_st(std::string uid); extern void xsteam_delete_uid_st(std::string uid);
@ -44,7 +44,7 @@ extern bool xsteam_uid_exists(std::string);
extern bool xsteam_steam_steamtools_exists(bool&,bool&); extern bool xsteam_steam_steamtools_exists(bool&,bool&);
extern void xsteam_save_data_read(); extern void xsteam_data_unserialize();
extern void xsteam_save_data_write(); extern void xsteam_save_data_write();
extern json xsteam_data_serialize(json); extern json xsteam_data_serialize(json);

View File

@ -32,8 +32,8 @@ private:
void free_git_ext(); void free_git_ext();
void error_git_ext(int error, QString str); void error_git_ext(int error, QString str);
git_repository *repo = nullptr; git_repository *repo = {};
git_remote *remote = nullptr; git_remote *remote = {};
std::string src_name; std::string src_name;
std::string branch_target_name; std::string branch_target_name;
std::string tag_target_name; std::string tag_target_name;

View File

@ -9,16 +9,18 @@ xsteam_git_fetch::~xsteam_git_fetch()
} }
void xsteam_git_fetch::free_git_fetch() void xsteam_git_fetch::free_git_fetch()
{ {
if(x_git!=nullptr){ if (x_git != nullptr)
{
delete x_git; delete x_git;
x_git = nullptr; x_git = nullptr;
} }
if(x_curl!=nullptr){ if (x_curl != nullptr)
{
delete x_curl; delete x_curl;
x_curl = nullptr; x_curl = nullptr;
} }
} }
void xsteam_git_fetch::fecth_uid_to_steam(InputData& i_data,UidData& u_data) void xsteam_git_fetch::fecth_uid_to_steam(UidData &u_data)
{ {
x_git = new xsteam_git(); x_git = new xsteam_git();
x_curl = new xsteam_curl(); x_curl = new xsteam_curl();
@ -34,21 +36,25 @@ void xsteam_git_fetch::fecth_uid_to_steam(InputData& i_data,UidData& u_data)
} }
} }
*/ */
emit signal_fetch_return_msg("连接Steam API获取uid对应游戏信息..."); if (u_data.name=="")
if (!xsteam_curl_steam_id_app_info(i_data.t_g_uid, u_data))
{ {
emit signal_fetch_return_msg("连接Steam API获取游戏信息失败"); emit signal_fetch_return_msg("连接Steam API获取uid对应游戏信息...");
free_git_fetch(); if (!xsteam_curl_steam_id_app_info(u_data))
return; {
} emit signal_fetch_return_msg("连接Steam API获取游戏信息失败");
else free_git_fetch();
{ return;
emit signal_fetch_return_msg("通过Steam API获取游戏信息完毕!"); }
else
{
emit signal_fetch_return_msg("通过Steam API获取游戏信息完毕!");
}
} }
emit signal_fetch_return_msg("正在uid对应文件清单..."); emit signal_fetch_return_msg("正在uid对应文件清单...");
// fetch remote library data // fetch remote library data
x_git->branch_or_tags_set_opts(i_data.t_g_uid, i_data.t_s_name); x_git->branch_or_tags_set_opts(u_data.uid, u_data.s_name);
if (!x_git->branch_or_tags_clone_ext(u_data)) if (!x_git->branch_or_tags_clone_ext(u_data))
{ {
emit signal_fetch_return_msg("拉取uid对应文件清单失败!"); emit signal_fetch_return_msg("拉取uid对应文件清单失败!");
@ -56,9 +62,9 @@ void xsteam_git_fetch::fecth_uid_to_steam(InputData& i_data,UidData& u_data)
return; return;
} }
// vdf dir & vdf file path // vdf dir & vdf file path
QString vdf_dir = ex_base_exe_ex + QString::fromStdString(i_data.t_g_uid); QString vdf_dir = ex_base_exe_ex + QString::fromStdString(u_data.uid);
QString vdf_key_file = vdf_dir + "/Key.vdf"; QString vdf_key_file = vdf_dir + "/Key.vdf";
QString vdf_config_file = QString::fromStdString(_data.x_config.steam_dir) + "/config/config.vdf"; QString vdf_config_file = QString::fromStdString(_data.x_config.steam_dir) + "/config/config.vdf";
// check fetch dir exists // check fetch dir exists
if (!QDir(vdf_dir).exists()) if (!QDir(vdf_dir).exists())
{ {
@ -102,10 +108,11 @@ void xsteam_git_fetch::fecth_uid_to_steam(InputData& i_data,UidData& u_data)
} }
// download game ico // download game ico
emit signal_fetch_return_msg("正在下载游戏ico图标..."); emit signal_fetch_return_msg("正在下载游戏ico图标...");
if(x_curl->get_steam_header_ico(_data.x_config.steam_logo_url,u_data.uid)){ if (x_curl->get_steam_header_ico(_data.x_config.steam_logo_url, u_data.uid))
{
free_git_fetch(); free_git_fetch();
} }
u_data.ico = u_data.uid+".png"; u_data.ico = u_data.uid + ".jpg";
// lua to luapaker .st to steamtools dir // lua to luapaker .st to steamtools dir
emit signal_fetch_return_msg("生成游戏入库lua脚本..."); emit signal_fetch_return_msg("生成游戏入库lua脚本...");
if (xsteam_lua_to_com(u_data)) if (xsteam_lua_to_com(u_data))
@ -116,14 +123,13 @@ void xsteam_git_fetch::fecth_uid_to_steam(InputData& i_data,UidData& u_data)
// key写入config.vdf文件 // key写入config.vdf文件
emit signal_fetch_return_msg("写入key到steam的config.vdf..."); emit signal_fetch_return_msg("写入key到steam的config.vdf...");
xsteam_vdf_write(vdf_config_file, vdf_data); xsteam_vdf_write(vdf_config_file, vdf_data);
u_data.i_time= (QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss")).toStdString(); u_data.i_time = (QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss")).toStdString();
} }
if (QDir(vdf_dir).exists()) if (QDir(vdf_dir).exists())
{ {
QDir(vdf_dir).removeRecursively(); QDir(vdf_dir).removeRecursively();
} }
free_git_fetch(); free_git_fetch();
emit signal_fetch_return_msg(u_data.uid+"入库完毕!");
emit signal_fetch_return_data(u_data); emit signal_fetch_return_data(u_data);
return; return;
} }

View File

@ -11,7 +11,7 @@ class xsteam_git_fetch : public QObject
public: public:
explicit xsteam_git_fetch(QObject *parent = nullptr); explicit xsteam_git_fetch(QObject *parent = nullptr);
~xsteam_git_fetch(); ~xsteam_git_fetch();
void fecth_uid_to_steam(InputData& i_data,UidData& _uid_data); void fecth_uid_to_steam(UidData& _uid_data);
private: private:
void free_git_fetch(); void free_git_fetch();
xsteam_git *x_git; xsteam_git *x_git;

View File

@ -10,10 +10,11 @@ xsteam_set_ui::~xsteam_set_ui()
} }
void xsteam_set_ui::init_set() void xsteam_set_ui::init_set()
{ {
setWindowTitle(tr("XSteam Options")); setWindowTitle(tr("XSteam设置"));
main_layout = new QVBoxLayout; main_layout = new QVBoxLayout;
foot_layout = new QHBoxLayout; foot_layout = new QHBoxLayout;
body_layout = new QVBoxLayout; body_layout = new QVBoxLayout;
src_group=new QGroupBox(tr("设置参数"));
steam_layout=new QHBoxLayout; steam_layout=new QHBoxLayout;
steam_path_str=new QLabel(tr("Steam路径设置:")); steam_path_str=new QLabel(tr("Steam路径设置:"));
@ -32,7 +33,7 @@ void xsteam_set_ui::init_set()
steamtools_layout->addWidget(steamtools_path_btn); steamtools_layout->addWidget(steamtools_path_btn);
steamtools_st_layout=new QHBoxLayout; steamtools_st_layout=new QHBoxLayout;
steamtools_st_path_str=new QLabel(tr("SteamTools .st路径设置:")); steamtools_st_path_str=new QLabel(tr("SteamTools .st路径设置(不建议修改):"));
steamtools_st_path_edit=new QLineEdit(); steamtools_st_path_edit=new QLineEdit();
steamtools_st_path_btn=new QPushButton(tr("浏览")); steamtools_st_path_btn=new QPushButton(tr("浏览"));
steamtools_st_layout->addWidget(steamtools_st_path_str); steamtools_st_layout->addWidget(steamtools_st_path_str);
@ -41,15 +42,15 @@ void xsteam_set_ui::init_set()
steam_api_layout=new QHBoxLayout; steam_api_layout=new QHBoxLayout;
steaminfo_api_path_str=new QLabel(tr("Steam Info Api Url:")); steaminfo_api_path_str=new QLabel(tr("Steam Info Api Url(不建议修改):"));
steaminfo_api_path_edit=new QLineEdit(tr("不建议修改")); steaminfo_api_path_edit=new QLineEdit();
steam_api_layout->addWidget(steaminfo_api_path_str); steam_api_layout->addWidget(steaminfo_api_path_str);
steam_api_layout->addWidget(steaminfo_api_path_edit); steam_api_layout->addWidget(steaminfo_api_path_edit);
steam_head_api_layout=new QHBoxLayout; steam_head_api_layout=new QHBoxLayout;
steaminfo_head_path_str=new QLabel(tr("Steam Logo Api Url:")); steaminfo_head_path_str=new QLabel(tr("Steam Logo Api Url(不建议修改):"));
steaminfo_head_path_edit=new QLineEdit(tr("不建议修改")); steaminfo_head_path_edit=new QLineEdit();
steam_head_api_layout->addWidget(steaminfo_head_path_str); steam_head_api_layout->addWidget(steaminfo_head_path_str);
steam_head_api_layout->addWidget(steaminfo_head_path_edit); steam_head_api_layout->addWidget(steaminfo_head_path_edit);
@ -58,14 +59,15 @@ void xsteam_set_ui::init_set()
body_layout->addLayout(steamtools_st_layout); body_layout->addLayout(steamtools_st_layout);
body_layout->addLayout(steam_api_layout); body_layout->addLayout(steam_api_layout);
body_layout->addLayout(steam_head_api_layout); body_layout->addLayout(steam_head_api_layout);
body_layout->addWidget(new QWidget()); body_layout->addWidget(new QWidget());
src_group->setLayout(body_layout);
_pSaveData = new QPushButton(tr("保存")); _pSaveData = new QPushButton(tr("保存"));
foot_layout->addSpacerItem(sparcer_item); foot_layout->addSpacerItem(sparcer_item);
foot_layout->addWidget(_pSaveData); foot_layout->addWidget(_pSaveData);
foot_layout->addSpacerItem(sparcer_item); foot_layout->addSpacerItem(sparcer_item);
main_layout->addLayout(body_layout); main_layout->addWidget(src_group);
main_layout->addLayout(foot_layout); main_layout->addLayout(foot_layout);
main_layout->setStretch(0, 8); main_layout->setStretch(0, 8);
main_layout->setStretch(1, 2); main_layout->setStretch(1, 2);

View File

@ -9,6 +9,7 @@
#include <QTableView> #include <QTableView>
#include <QTableWidgetItem> #include <QTableWidgetItem>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QGroupBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QPushButton> #include <QPushButton>
#include <QLabel> #include <QLabel>
@ -43,8 +44,10 @@ private:
QVBoxLayout* main_layout; QVBoxLayout* main_layout;
QVBoxLayout* body_layout; QVBoxLayout* body_layout;
QHBoxLayout* foot_layout; QHBoxLayout* foot_layout;
QGroupBox* src_group;
QPushButton* _pSaveData=nullptr; QPushButton* _pSaveData={};
QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed); QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed);
QHBoxLayout* steam_layout; QHBoxLayout* steam_layout;
@ -75,6 +78,6 @@ private slots:
//void clicked_rightMenu(const QPoint &pos); //右键信号槽函数 //void clicked_rightMenu(const QPoint &pos); //右键信号槽函数
void slotsSaveDone(); void slotsSaveDone();
}; };
xsteam_set_ui *xsteam_set_ui::_instance = nullptr; xsteam_set_ui *xsteam_set_ui::_instance = {};
QMutex xsteam_set_ui::mutex; QMutex xsteam_set_ui::mutex;
#endif #endif

View File

@ -18,8 +18,8 @@ void xsteam_src_edit_ui::init_table_view_style()
m_Table->setWordWrap(false); m_Table->setWordWrap(false);
m_Table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); m_Table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
m_Table->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); m_Table->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
m_Table->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
m_Table->setShowGrid(false); m_Table->setShowGrid(false);
m_Table->setAlternatingRowColors(true);
m_Table->setFrameShape(QFrame::NoFrame); m_Table->setFrameShape(QFrame::NoFrame);
m_Table->horizontalHeader()->setStretchLastSection(true); m_Table->horizontalHeader()->setStretchLastSection(true);
m_Table->setColumnWidth(0, m_Table->width() / 5); m_Table->setColumnWidth(0, m_Table->width() / 5);
@ -27,7 +27,9 @@ void xsteam_src_edit_ui::init_table_view_style()
void xsteam_src_edit_ui::init_src_edit_ui() void xsteam_src_edit_ui::init_src_edit_ui()
{ {
setWindowTitle(tr("XSteam源数据编辑")); setWindowTitle(tr("XSteam源数据"));
src_group = new QGroupBox(tr("数据源信息"));
gr_Layout = new QVBoxLayout();
main_Layout = new QVBoxLayout; main_Layout = new QVBoxLayout;
foot_Layout = new QHBoxLayout; foot_Layout = new QHBoxLayout;
m_Table = new QTableView; m_Table = new QTableView;
@ -35,16 +37,18 @@ void xsteam_src_edit_ui::init_src_edit_ui()
m_Model->setHorizontalHeaderLabels(ex_src_table_head_tips); m_Model->setHorizontalHeaderLabels(ex_src_table_head_tips);
m_Table->setModel(m_Model); m_Table->setModel(m_Model);
m_Save_Data = new QPushButton(tr("保存")); m_Save_Data = new QPushButton(tr("保存"));
m_Update_Src_Data = new QPushButton(tr("更新源数据")); m_Update_Src_Data = new QPushButton(tr("更新"));
foot_Layout->addSpacerItem(sparcer_Item); foot_Layout->addSpacerItem(sparcer_Item);
foot_Layout->addWidget(m_Save_Data); foot_Layout->addWidget(m_Save_Data);
foot_Layout->addWidget(m_Update_Src_Data); foot_Layout->addWidget(m_Update_Src_Data);
foot_Layout->addSpacerItem(sparcer_Item); foot_Layout->addSpacerItem(sparcer_Item);
main_Layout->addWidget(m_Table); gr_Layout->addWidget(m_Table);
main_Layout->addLayout(foot_Layout); gr_Layout->addLayout(foot_Layout);
main_Layout->setStretch(0, 8); gr_Layout->setStretch(0, 8);
main_Layout->setStretch(1, 2); gr_Layout->setStretch(1, 2);
main_Layout->setContentsMargins(2, 2, 2, 2); gr_Layout->setContentsMargins(2, 2, 2, 2);
src_group->setLayout(gr_Layout);
main_Layout->addWidget(src_group);
setLayout(main_Layout); setLayout(main_Layout);
init_table_view_style(); init_table_view_style();
connect_slots(); connect_slots();
@ -66,17 +70,17 @@ void xsteam_src_edit_ui::load_src_data_view(std::vector<SrcData> src_data)
{ {
int x = i++; int x = i++;
m_Model->setItem(x, 0, new QStandardItem(QString::fromStdString(k.src_name))); m_Model->setItem(x, 0, new QStandardItem(QString::fromStdString(k.src_name)));
QString g_mode_str; QComboBox *cmb = new QComboBox();
if (k.src_type == GIT_MODE::BRANCH) cmb->addItems(src_type);
if (k.src_type == GIT_MODE::TAG)
{ {
g_mode_str = "BRANCH"; cmb->setCurrentIndex(1);
} }
else else
{ {
g_mode_str = "TAG"; cmb->setCurrentIndex(0);
} }
QStandardItem *t_item = new QStandardItem(g_mode_str); m_Table->setIndexWidget(m_Model->index(x, 1), cmb);
m_Model->setItem(x, 1, t_item);
m_Model->setItem(x, 2, new QStandardItem(QString::fromStdString(k.src_url))); m_Model->setItem(x, 2, new QStandardItem(QString::fromStdString(k.src_url)));
} }
m_Table->setModel(m_Model); m_Table->setModel(m_Model);
@ -128,9 +132,18 @@ void xsteam_src_edit_ui::slots_on_task_event()
} }
void xsteam_src_edit_ui::object_add_src() void xsteam_src_edit_ui::object_add_src()
{ {
QAbstractItemModel *modessl = m_Table->model(); /*
modessl->insertRow(modessl->rowCount()); m_Model->insertRow(m_Model->rowCount());
m_Table->setModel(modessl); QComboBox *cmb = new QComboBox();
cmb->addItems(src_type);
m_Table->setIndexWidget(m_Model->index(4, 1), cmb);
*/
int index = m_Model->rowCount();
m_Model->setItem(index, 0, new QStandardItem(QString::fromStdString("")));
QComboBox *cmb = new QComboBox();
cmb->addItems(src_type);
m_Table->setIndexWidget(m_Model->index(index, 1), cmb);
m_Model->setItem(index, 2, new QStandardItem(QString::fromStdString("")));
} }
void xsteam_src_edit_ui::object_delete_src() void xsteam_src_edit_ui::object_delete_src()
{ {
@ -147,17 +160,24 @@ void xsteam_src_edit_ui::object_delete_src()
QAbstractItemModel *modessl = m_Table->model(); QAbstractItemModel *modessl = m_Table->model();
QModelIndex indextemp = modessl->index(curRow, 0); QModelIndex indextemp = modessl->index(curRow, 0);
QString _name = modessl->data(indextemp).value<QString>(); QString _name = modessl->data(indextemp).value<QString>();
for (auto it = _data.s_data.begin(); it != _data.s_data.end();) if (_name == "")
{ {
if (it->src_name == _name.toStdString()) modessl->removeRow(curRow);
}
else
{
for (auto it = _data.s_data.begin(); it != _data.s_data.end();)
{ {
it = _data.s_data.erase(it); if (it->src_name == _name.toStdString())
modessl->removeRow(curRow); {
m_Table->setModel(modessl); _data.s_data.erase(it);
} modessl->removeRow(curRow);
else m_Table->setModel(modessl);
{ }
++it; else
{
++it;
}
} }
} }
} }
@ -173,19 +193,27 @@ void xsteam_src_edit_ui::slots_save_done()
for (int i = 0; i <= curRow - 1; i++) for (int i = 0; i <= curRow - 1; i++)
{ {
SrcData _src_data = {}; SrcData _src_data = {};
QString dataTempA = modessl->data(modessl->index(i, 0)).value<QString>(); QString src_name = modessl->data(modessl->index(i, 0)).value<QString>();
QString dataTempB = modessl->data(modessl->index(i, 1)).value<QString>(); QComboBox *cmb = (QComboBox *)m_Table->indexWidget(modessl->index(i, 1));
QString dataTempC = modessl->data(modessl->index(i, 2)).value<QString>(); QString src_url = modessl->data(modessl->index(i, 2)).value<QString>();
_src_data.src_name = dataTempA.toStdString(); if(src_name==""){
if (dataTempB == tr("BRANCH")) xsteam_msg_tip(nullptr,""+QString::number(curRow)+"行源名字不允许为空!");
{ return;
_src_data.src_type = GIT_MODE::BRANCH;
} }
else if (dataTempB == tr("TAG")) if(src_url==""){
xsteam_msg_tip(nullptr,""+QString::number(curRow)+"行源地址不允许为空!");
return;
}
_src_data.src_name = src_name.toStdString();
if (cmb->currentIndex() == GIT_MODE::TAG)
{ {
_src_data.src_type = GIT_MODE::TAG; _src_data.src_type = GIT_MODE::TAG;
} }
_src_data.src_url = dataTempC.toStdString(); else
{
_src_data.src_type = GIT_MODE::BRANCH;
}
_src_data.src_url = src_url.toStdString();
_data.s_data.push_back(_src_data); _data.s_data.push_back(_src_data);
} }
} }

View File

@ -3,7 +3,10 @@
#include <QDialog> #include <QDialog>
#include <QMutex> #include <QMutex>
#include <QGroupBox>
#include <QTableView> #include <QTableView>
#include <QComboBox>
#include <QStringList>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QPushButton> #include <QPushButton>
@ -46,12 +49,15 @@ private:
void object_add_src(); void object_add_src();
void object_delete_src(); void object_delete_src();
void connect_slots(); void connect_slots();
QGroupBox* src_group;
QVBoxLayout *gr_Layout;
QVBoxLayout *main_Layout; QVBoxLayout *main_Layout;
QHBoxLayout *foot_Layout; QHBoxLayout *foot_Layout;
QStandardItemModel *m_Model = nullptr; QStandardItemModel *m_Model = {};
QTableView *m_Table = nullptr; QTableView *m_Table = {};
QPushButton *m_Save_Data = nullptr; QPushButton *m_Save_Data = {};
QPushButton *m_Update_Src_Data = nullptr; QPushButton *m_Update_Src_Data = {};
QStringList src_type={"BRANCH","TAG"};
QSpacerItem *sparcer_Item = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); QSpacerItem *sparcer_Item = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
private slots: private slots:
void slots_rightMenu(const QPoint &pos); void slots_rightMenu(const QPoint &pos);
@ -61,6 +67,6 @@ private slots:
signals: signals:
void signals_update(); void signals_update();
}; };
xsteam_src_edit_ui *xsteam_src_edit_ui::_instance = nullptr; xsteam_src_edit_ui *xsteam_src_edit_ui::_instance = {};
QMutex xsteam_src_edit_ui::mutex; QMutex xsteam_src_edit_ui::mutex;
#endif #endif

View File

@ -1,11 +1,11 @@
#include "xsteam_ui.h" #include "xsteam_ui.h"
xsteam_ui::xsteam_ui(QWidget *parent) : QWidget(parent), xsteam_ui::xsteam_ui(QWidget *parent) : QWidget(parent),
main_layout(new QVBoxLayout), main_layout(new QVBoxLayout),
head_layout(new QHBoxLayout), info_layout(new QHBoxLayout),
mind_layout(new QVBoxLayout), mind_layout(new QVBoxLayout),
foot_layout(new QHBoxLayout) foot_layout(new QHBoxLayout)
{ {
// xsteam_init_head_layout(); xsteam_init_info_layout();
xsteam_init_mind_layout(); xsteam_init_mind_layout();
xsteam_init_foot_layout(); xsteam_init_foot_layout();
xsteam_init_style(); xsteam_init_style();
@ -31,20 +31,17 @@ xsteam_ui::~xsteam_ui()
} }
void xsteam_ui::xsteam_init_main_layout() void xsteam_ui::xsteam_init_main_layout()
{ {
main_layout->addLayout(head_layout);
main_layout->addLayout(mind_layout); main_layout->addLayout(mind_layout);
main_layout->addLayout(foot_layout); main_layout->addLayout(foot_layout);
setLayout(main_layout); setLayout(main_layout);
} }
void xsteam_ui::xsteam_init_head_layout() void xsteam_ui::xsteam_init_info_layout()
{ {
head_tag = new QLabel(); info_layout=new QHBoxLayout();
head_tag->setText(tr("Public Steam")); info_txt_tag=new QLabel(tr("本工具建议配合SteamTools和Steam++使用"));
QFont font("Microsoft YaHei", 10, 75); info_layout->addItem(sparcer_item);
head_tag->setFont(font); info_layout->addWidget(info_txt_tag);
head_layout->addItem(sparcer_item); info_layout->addItem(sparcer_item);
head_layout->addWidget(head_tag);
head_layout->addItem(sparcer_item);
} }
void xsteam_ui::xsteam_init_mind_layout() void xsteam_ui::xsteam_init_mind_layout()
{ {
@ -62,7 +59,7 @@ void xsteam_ui::xsteam_init_mind_layout()
btn_run_steam->setObjectName("RUN_STEAM"); btn_run_steam->setObjectName("RUN_STEAM");
btn_run_steamdb = new QPushButton(tr("SteamDB")); btn_run_steamdb = new QPushButton(tr("SteamDB"));
btn_run_steamdb->setObjectName("STEAM_DB"); btn_run_steamdb->setObjectName("STEAM_DB");
server_layout->addWidget(server_tag); server_layout->addWidget(server_tag);
server_layout->addWidget(server_txt); server_layout->addWidget(server_txt);
server_layout->addWidget(btn_fetch_src_data); server_layout->addWidget(btn_fetch_src_data);
@ -79,27 +76,27 @@ void xsteam_ui::xsteam_init_mind_layout()
ip_uid_tag = new QLabel(tr("游戏UID:")); ip_uid_tag = new QLabel(tr("游戏UID:"));
ip_uid_tag->setObjectName("GAME_UID"); ip_uid_tag->setObjectName("GAME_UID");
ip_uid_edit = new QLineEdit("457140"); ip_uid_edit = new QLineEdit("");
ip_uid_edit->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9]+$"))); ip_uid_edit->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9]+$")));
ip_uid_edit->setMaxLength(8); ip_uid_edit->setMaxLength(8);
ip_layout->addWidget(ip_uid_tag); ip_layout->addWidget(ip_uid_tag);
ip_layout->addWidget(ip_uid_edit); ip_layout->addWidget(ip_uid_edit);
ip_layout->setContentsMargins(2, 2, 2, 2); ip_layout->setContentsMargins(2, 2, 2, 2);
btn_dlc_push = new QPushButton(tr("获取DLC")); btn_dlc_push = new QPushButton(tr("获取DLC列表"));
btn_dlc_push->setObjectName("SET_DLC"); btn_dlc_push->setObjectName("SET_DLC");
ip_iu_layout = new QHBoxLayout(); ip_iu_layout = new QHBoxLayout();
btn_uid_push = new QPushButton(tr("入库")); btn_uid_push = new QPushButton(tr("入库"));
btn_uid_push->setObjectName("INPUT"); btn_uid_push->setObjectName("INPUT");
btn_uid_update=new QPushButton(tr("更新")); btn_uid_update = new QPushButton(tr("更新"));
btn_uid_update->setObjectName("UPDATE"); btn_uid_update->setObjectName("UPDATE");
ip_iu_layout->addWidget(btn_uid_push); ip_iu_layout->addWidget(btn_uid_push);
ip_iu_layout->addWidget(btn_uid_update); ip_iu_layout->addWidget(btn_uid_update);
ip_iu_layout->setContentsMargins(2, 2, 2, 2); ip_iu_layout->setContentsMargins(2, 2, 2, 2);
ip_data_layout = new QHBoxLayout(); ip_data_layout = new QHBoxLayout();
// uid info // uid info
ip_uid_group_layout = new QHBoxLayout(); ip_uid_group_layout = new QHBoxLayout();
ip_uid_group = new QGroupBox(tr("游戏信息")); ip_uid_group = new QGroupBox(tr("游戏信息"));
@ -112,13 +109,15 @@ void xsteam_ui::xsteam_init_mind_layout()
ip_uid_group->setLayout(ip_uid_group_layout); ip_uid_group->setLayout(ip_uid_group_layout);
// all dlc info // all dlc info
ip_dlc_info_layout = new QVBoxLayout(); ip_dlc_info_layout = new QVBoxLayout();
ip_all_dlc_group = new QGroupBox(tr("DLC信息")); ip_all_dlc_group = new QGroupBox(tr("入库信息"));
ip_all_dlc_group->setObjectName("ALL_DLC_GROUP"); ip_all_dlc_group->setObjectName("ALL_DLC_GROUP");
ip_all_dlc_table = new xsteam_view(); ip_all_dlc_table = new xsteam_view();
ip_all_dlc_table->setObjectName("ALL_DLC_TABLE");
ip_all_dlc_table->init_view(VIEW_MODE::ALL_DLC_INFO); ip_all_dlc_table->init_view(VIEW_MODE::ALL_DLC_INFO);
ip_in_dlc_table = new xsteam_view(); ip_in_dlc_table = new xsteam_view();
ip_in_dlc_table->setObjectName("IN_DLC_TABLE");
ip_in_dlc_table->init_view(VIEW_MODE::IN_DLC_INFO); ip_in_dlc_table->init_view(VIEW_MODE::IN_DLC_INFO);
ip_dlc_info_layout->addLayout(ip_layout); ip_dlc_info_layout->addLayout(ip_layout);
ip_dlc_info_layout->addWidget(btn_dlc_push); ip_dlc_info_layout->addWidget(btn_dlc_push);
ip_dlc_info_layout->addWidget(ip_in_dlc_table); ip_dlc_info_layout->addWidget(ip_in_dlc_table);
@ -130,11 +129,12 @@ void xsteam_ui::xsteam_init_mind_layout()
ip_data_layout->addWidget(ip_uid_group); ip_data_layout->addWidget(ip_uid_group);
ip_data_layout->addWidget(ip_all_dlc_group); ip_data_layout->addWidget(ip_all_dlc_group);
ip_data_layout->setStretch(0, 7);
ip_data_layout->setStretch(1, 3);
ip_data_layout->setStretch(0, 8);
ip_data_layout->setStretch(1, 2);
mind_layout->addLayout(server_layout); mind_layout->addLayout(server_layout);
mind_layout->addLayout(info_layout);
mind_layout->addLayout(ip_data_layout); mind_layout->addLayout(ip_data_layout);
} }
void xsteam_ui::xsteam_init_foot_layout() void xsteam_ui::xsteam_init_foot_layout()
@ -178,46 +178,149 @@ void xsteam_ui::xsteam_init_style()
void xsteam_ui::xsteam_init_connect() void xsteam_ui::xsteam_init_connect()
{ {
ip_uid_table->setContextMenuPolicy(Qt::CustomContextMenu); ip_uid_table->setContextMenuPolicy(Qt::CustomContextMenu);
ip_all_dlc_table->setContextMenuPolicy(Qt::CustomContextMenu);
ip_in_dlc_table->setContextMenuPolicy(Qt::CustomContextMenu);
connect(btn_server_edit, SIGNAL(clicked()), this, SLOT(slots_open_server_edit())); connect(btn_server_edit, SIGNAL(clicked()), this, SLOT(slots_open_server_edit()));
connect(btn_xs_sets, SIGNAL(clicked()), this, SLOT(slots_open_setting())); connect(btn_xs_sets, SIGNAL(clicked()), this, SLOT(slots_open_setting()));
connect(btn_run_steam, SIGNAL(clicked()), this, SLOT(slots_run_steam_steamtools())); connect(btn_run_steam, SIGNAL(clicked()), this, SLOT(slots_run_steam_steamtools()));
connect(btn_run_steamtools, SIGNAL(clicked()), this, SLOT(slots_run_steam_steamtools())); connect(btn_run_steamtools, SIGNAL(clicked()), this, SLOT(slots_run_steam_steamtools()));
connect(btn_xs_about, SIGNAL(clicked()), this, SLOT(slots_open_about())); connect(btn_xs_about, SIGNAL(clicked()), this, SLOT(slots_open_about()));
connect(btn_fetch_src_data, SIGNAL(clicked()), this, SLOT(slots_fetch_src_data())); connect(btn_fetch_src_data, SIGNAL(clicked()), this, SLOT(slots_fetch_src_data()));
connect(btn_uid_push, SIGNAL(clicked()), this, SLOT(slots_imput_uid_push())); connect(btn_uid_push, SIGNAL(clicked()), this, SLOT(slots_imput_update_uid_push()));
connect(btn_uid_update, SIGNAL(clicked()), this, SLOT(slots_imput_update_uid_push()));
connect(btn_run_steamdb, SIGNAL(clicked()), this, SLOT(slots_open_steamdb())); connect(btn_run_steamdb, SIGNAL(clicked()), this, SLOT(slots_open_steamdb()));
connect(this, SIGNAL(signals_src_combobox_update()), this, SLOT(slots_server_combobox_load_data())); connect(this, SIGNAL(signals_src_combobox_update()), this, SLOT(slots_server_combobox_load_data()));
connect(xs_git_fetch, SIGNAL(signal_fetch_return_msg(std::string)), this, SLOT(slots_msg_text(std::string))); connect(xs_git_fetch, SIGNAL(signal_fetch_return_msg(std::string)), this, SLOT(slots_msg_text(std::string)));
connect(xs_git_fetch, SIGNAL(signal_fetch_return_data(UidData)), this, SLOT(slots_table_append(UidData))); connect(xs_git_fetch, SIGNAL(signal_fetch_return_data(UidData)), this, SLOT(slots_table_append(UidData)));
connect(ip_uid_table->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(slots_selection_row(const QItemSelection &, const QItemSelection &))); connect(ip_uid_table->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(slots_selection_row(const QItemSelection &, const QItemSelection &)));
connect(ip_uid_table, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slots_rightMenu(QPoint))); connect(ip_uid_table, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slots_rightMenu(QPoint)));
connect(ip_all_dlc_table, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slots_rightMenu(QPoint)));
connect(ip_in_dlc_table, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slots_rightMenu(QPoint)));
connect(btn_dlc_push, SIGNAL(clicked()), this, SLOT(slots_get_uid_dlcs()));
}
void xsteam_ui::slots_get_uid_dlcs()
{
UidData uid_data;
uid_data.uid = ip_uid_edit->text().toStdString();
uid_data.s_name = server_txt->currentText().toStdString();
slots_msg_text("获取DLC信息...");
ip_all_dlc_table->item_clear();
ip_in_dlc_table->item_clear();
slots_disable_enable_function(false);
QFuture<void> future = QtConcurrent::run([=](UidData uid_data)
{
if (xsteam_curl_steam_id_app_info(uid_data))
{
ip_all_dlc_table->item_append(uid_data, VIEW_MODE::ALL_DLC_INFO);
xs_data = uid_data;
slots_msg_text("DLC信息获取完毕");
slots_disable_enable_function(true);
}
else
{
slots_msg_text("获取DLC信息失败!请检查UID是否正确&网络是否畅通");
slots_disable_enable_function(true);
} }, uid_data);
} }
void xsteam_ui::slots_rightMenu(const QPoint &pos) void xsteam_ui::slots_rightMenu(const QPoint &pos)
{ {
QTableView *signalSrc = (QTableView *)sender(); // 获取到了发送该信号按钮的指针 QTableView *signalSrc = (QTableView *)sender(); // 获取到了发送该信号按钮的指针
QModelIndex index = signalSrc->indexAt(pos); QModelIndex index = signalSrc->indexAt(pos);
if (index.row() > -1) if (sender()->objectName() == "GAME_INFO_TABLE")
{ {
// 创建菜单对象 if (index.row() > -1)
QMenu *m_menu = new QMenu(this); {
QAction *delete_task = new QAction(tr("移除入库"), this); // 创建菜单对象
QAction *update_task = new QAction(tr("更新入库"), this); QMenu *m_menu = new QMenu(this);
delete_task->setData(1); QAction *delete_task = new QAction(tr("移除入库"), this);
update_task->setData(2); delete_task->setData(1);
delete_task->setObjectName(signalSrc->objectName()); delete_task->setObjectName(signalSrc->objectName());
update_task->setObjectName(signalSrc->objectName()); // 把QAction对象添加到菜单上
// 把QAction对象添加到菜单上 m_menu->addAction(delete_task);
m_menu->addAction(delete_task); // 连接鼠标右键点击信号
m_menu->addAction(update_task); connect(delete_task, SIGNAL(triggered()), this, SLOT(slots_delete_uid_st()));
// 连接鼠标右键点击信号 // 在鼠标右键点击的地方显示菜单
connect(delete_task, SIGNAL(triggered()), this, SLOT(slots_delete_uid_st())); m_menu->exec(QCursor::pos());
connect(update_task, SIGNAL(triggered()), this, SLOT(slots_updata_uid_st())); QList<QAction *> list = m_menu->actions();
// 在鼠标右键点击的地方显示菜单 foreach (QAction *pAction, list)
m_menu->exec(QCursor::pos()); {
QList<QAction *> list = m_menu->actions(); delete pAction;
foreach (QAction *pAction, list) }
delete pAction; delete m_menu;
delete m_menu; }
}
else if (sender()->objectName() == "ALL_DLC_TABLE")
{
if (index.row() > -1)
{
// 创建菜单对象
QMenu *m_menu = new QMenu(this);
QAction *add_task = new QAction(tr("增加DLC"), this);
add_task->setData(1);
add_task->setObjectName(signalSrc->objectName());
// 把QAction对象添加到菜单上
m_menu->addAction(add_task);
// 连接鼠标右键点击信号
connect(add_task, SIGNAL(triggered()), this, SLOT(slots_in_dlc_add()));
// 在鼠标右键点击的地方显示菜单
m_menu->exec(QCursor::pos());
QList<QAction *> list = m_menu->actions();
foreach (QAction *pAction, list)
{
delete pAction;
}
delete m_menu;
}
}
else if (sender()->objectName() == "IN_DLC_TABLE")
{
if (index.row() > -1)
{
// 创建菜单对象
QMenu *m_menu = new QMenu(this);
QAction *delete_task = new QAction(tr("移除DLC"), this);
delete_task->setData(1);
delete_task->setObjectName(signalSrc->objectName());
// 把QAction对象添加到菜单上
m_menu->addAction(delete_task);
// 连接鼠标右键点击信号
connect(delete_task, SIGNAL(triggered()), this, SLOT(slots_in_dlc_delete()));
// 在鼠标右键点击的地方显示菜单
m_menu->exec(QCursor::pos());
QList<QAction *> list = m_menu->actions();
foreach (QAction *pAction, list)
{
delete pAction;
}
delete m_menu;
}
}
}
void xsteam_ui::slots_in_dlc_delete()
{
int curRow = ip_in_dlc_table->currentIndex().row();
if (curRow > -1)
{
QAbstractItemModel *modessl = ip_in_dlc_table->model();
QModelIndex indextemp = modessl->index(curRow, 0);
QString dlc_id = modessl->data(indextemp).value<QString>();
modessl->removeRow(curRow);
ip_in_dlc_table->setModel(modessl);
xs_data.n_dlc.erase(std::remove(xs_data.n_dlc.begin(), xs_data.n_dlc.end(), dlc_id), xs_data.n_dlc.end());
slots_msg_text("删除DLC:" + dlc_id.toStdString() + "成功!");
}
}
void xsteam_ui::slots_in_dlc_add()
{
int curRow = ip_all_dlc_table->currentIndex().row();
if (curRow > -1)
{
QAbstractItemModel *modessl = ip_all_dlc_table->model();
QModelIndex indextemp = modessl->index(curRow, 0);
QString dlc_id = modessl->data(indextemp).value<QString>();
xs_data.n_dlc.push_back(dlc_id.toStdString());
ip_in_dlc_table->item_append(xs_data, VIEW_MODE::IN_DLC_INFO);
slots_msg_text("增加DLC:" + dlc_id.toStdString() + "成功!");
} }
} }
void xsteam_ui::slots_delete_uid_st() void xsteam_ui::slots_delete_uid_st()
@ -227,18 +330,13 @@ void xsteam_ui::slots_delete_uid_st()
{ {
QAbstractItemModel *modessl = ip_uid_table->model(); QAbstractItemModel *modessl = ip_uid_table->model();
QModelIndex indextemp = modessl->index(curRow, 1); QModelIndex indextemp = modessl->index(curRow, 1);
QString uid = modessl->data(indextemp).value<QString>(); QString d_uid = modessl->data(indextemp).value<QString>();
modessl->removeRow(curRow); modessl->removeRow(curRow);
ip_uid_table->setModel(modessl); ip_uid_table->setModel(modessl);
QFuture<void> future = QtConcurrent::run([=]() QFuture<void> future = QtConcurrent::run([=](std::string _uid)
{ { xsteam_delete_uid_st(_uid); }, d_uid.toStdString());
xsteam_delete_uid_st(uid.toStdString());
});
} }
} }
void xsteam_ui::slots_updata_uid_st()
{
}
void xsteam_ui::slots_fetch_src_data() void xsteam_ui::slots_fetch_src_data()
{ {
slots_msg_text("正在拉取" + server_txt->currentText().toStdString() + "数据..."); slots_msg_text("正在拉取" + server_txt->currentText().toStdString() + "数据...");
@ -265,17 +363,26 @@ void xsteam_ui::slots_selection_row(const QItemSelection &current, const QItemSe
QModelIndex index = indexes.first(); QModelIndex index = indexes.first();
QAbstractItemModel *model = ip_uid_table->model(); QAbstractItemModel *model = ip_uid_table->model();
std::string uid = (model->data(model->index(index.row(), 1)).value<QString>()).toStdString(); std::string uid = (model->data(model->index(index.row(), 1)).value<QString>()).toStdString();
UidData u_data;
for (auto x : _data.u_data) for (auto x : _data.u_data)
{ {
if (x.uid == uid) if (x.uid == uid)
{ {
u_data = x; xs_data = x;
break; break;
} }
} }
ip_all_dlc_table->item_append(u_data, VIEW_MODE::ALL_DLC_INFO); for (int i = 0; i < server_txt->count(); ++i)
ip_in_dlc_table->item_append(u_data, VIEW_MODE::IN_DLC_INFO); {
std::string item_str = server_txt->itemText(i).toStdString();
if (xs_data.s_name == item_str)
{
server_txt->setCurrentIndex(i);
break;
}
}
ip_uid_edit->setText(QString::fromStdString(xs_data.uid));
ip_all_dlc_table->item_append(xs_data, VIEW_MODE::ALL_DLC_INFO);
ip_in_dlc_table->item_append(xs_data, VIEW_MODE::IN_DLC_INFO);
} }
} }
@ -297,6 +404,8 @@ void xsteam_ui::slots_disable_enable_function(bool state)
btn_uid_push->setEnabled(state); btn_uid_push->setEnabled(state);
btn_run_steam->setEnabled(state); btn_run_steam->setEnabled(state);
btn_run_steamtools->setEnabled(state); btn_run_steamtools->setEnabled(state);
btn_uid_update->setEnabled(state);
btn_dlc_push->setEnabled(state);
} }
void xsteam_ui::slots_server_combobox_load_data() void xsteam_ui::slots_server_combobox_load_data()
{ {
@ -308,19 +417,12 @@ void xsteam_ui::slots_server_combobox_load_data()
server_txt->setCurrentIndex(0); server_txt->setCurrentIndex(0);
} }
void xsteam_ui::table_load_ui_data() void xsteam_ui::table_load_ui_data()
{ {
for (auto x : _data.u_data) for (auto x : _data.u_data)
{ {
ip_uid_table->item_append(x, VIEW_MODE::UID_INFO); ip_uid_table->item_append(x, VIEW_MODE::UID_INFO);
} }
} }
void xsteam_ui::slots_open_server_edit()
{
xs_src_edit_ui = xsteam_src_edit_ui::Instance();
xs_src_edit_ui->setGeometry(((QWidget *)this->parent())->geometry());
connect(xs_src_edit_ui, SIGNAL(signals_update()), this, SLOT(slots_server_combobox_load_data()));
xs_src_edit_ui->exec();
}
void xsteam_ui::slots_run_steam_steamtools() void xsteam_ui::slots_run_steam_steamtools()
{ {
@ -334,42 +436,62 @@ void xsteam_ui::slots_run_steam_steamtools()
xsteam_run_steam_steamtools(RUN_MODE::STEAMTOOLS); xsteam_run_steam_steamtools(RUN_MODE::STEAMTOOLS);
} }
} }
void xsteam_ui::slots_open_server_edit()
{
xs_src_edit_ui = xsteam_src_edit_ui::Instance();
xs_src_edit_ui->setMaximumSize(660, 580);
xs_src_edit_ui->setGeometry(((QWidget *)this->parent())->geometry());
connect(xs_src_edit_ui, SIGNAL(signals_update()), this, SLOT(slots_server_combobox_load_data()));
xs_src_edit_ui->exec();
}
void xsteam_ui::slots_open_setting() void xsteam_ui::slots_open_setting()
{ {
xs_sets_ui = xsteam_set_ui::Instance(); xs_sets_ui = xsteam_set_ui::Instance();
xs_sets_ui->setMaximumSize(660, 580);
xs_sets_ui->setGeometry(((QWidget *)this->parent())->geometry()); xs_sets_ui->setGeometry(((QWidget *)this->parent())->geometry());
xs_sets_ui->exec(); xs_sets_ui->exec();
} }
void xsteam_ui::slots_open_about() void xsteam_ui::slots_open_about()
{ {
xs_about_ui = xsteam_about_ui::Instance(); xs_about_ui = xsteam_about_ui::Instance();
xs_about_ui->setMaximumSize(440, 580);
xs_about_ui->setGeometry(((QWidget *)this->parent())->geometry()); xs_about_ui->setGeometry(((QWidget *)this->parent())->geometry());
xs_about_ui->exec(); xs_about_ui->exec();
} }
void xsteam_ui::slots_table_append(UidData u_data) void xsteam_ui::slots_table_append(UidData u_data)
{ {
// 增加条目到游戏表格 if (xs_state == PUSH_MODE::PUSH_ADD)
ip_uid_table->item_append(u_data, VIEW_MODE::UID_INFO); {
// 清空状态显示 // 增加条目到游戏表格
slots_msg_text(""); ip_uid_table->item_append(u_data, VIEW_MODE::UID_INFO);
// 增加到全局变量内 // 清空状态显示
_data.u_data.push_back(u_data); slots_msg_text(u_data.uid + "入库完毕!");
// 写入data.json->保存功能 // 增加到全局变量内
_data.u_data.push_back(u_data);
// 写入data.json->保存功能
}
else if (xs_state == PUSH_MODE::PUSH_UPDATE)
{
for (auto &x : _data.u_data)
{
if (x.uid == u_data.uid)
{
x = u_data;
break;
}
}
slots_msg_text(u_data.uid + "更新完毕!");
}
QFuture<void> future = QtConcurrent::run([=]() QFuture<void> future = QtConcurrent::run([=]()
{ xsteam_save_data_write(); }); { xsteam_save_data_write(); });
} }
void xsteam_ui::slots_imput_uid_push() void xsteam_ui::slots_imput_update_uid_push()
{ {
InputData i_data;
UidData u_data;
bool steam_ok = false; bool steam_ok = false;
bool steamtools_ok = false; bool steamtools_ok = false;
i_data.t_g_uid = ip_uid_edit->text().toStdString(); if (ip_uid_edit->text().toStdString() == "")
i_data.t_s_name = server_txt->currentText().toStdString();
if (xsteam_uid_exists(i_data.t_g_uid))
{ {
slots_msg_text("当前游戏已入库!请勿反复入库"); slots_msg_text("入库UID不能为空");
return; return;
} }
if (!xsteam_steam_steamtools_exists(steam_ok, steamtools_ok)) if (!xsteam_steam_steamtools_exists(steam_ok, steamtools_ok))
@ -377,13 +499,32 @@ void xsteam_ui::slots_imput_uid_push()
slots_msg_text("请检查steam和steamtools路径"); slots_msg_text("请检查steam和steamtools路径");
return; return;
} }
if(!xsteam_src_data_exists(i_data.t_s_name)){ if (!xsteam_src_data_exists(server_txt->currentText().toStdString()))
{
slots_msg_text("请先拉取源服务器清单列表到本地"); slots_msg_text("请先拉取源服务器清单列表到本地");
return; return;
} }
slots_disable_enable_function(false); if (sender()->objectName() == "INPUT")
QFuture<void> future = QtConcurrent::run([=](InputData i_data, UidData u_data) {
{ if (xsteam_uid_exists(ip_uid_edit->text().toStdString()))
xs_git_fetch->fecth_uid_to_steam(i_data, u_data); {
slots_disable_enable_function(true); }, i_data, u_data); slots_msg_text("当前游戏已入库!请勿反复入库");
return;
}
xs_state = PUSH_MODE::PUSH_ADD;
}
else
{
xs_state = PUSH_MODE::PUSH_UPDATE;
}
slots_imput_uid_push();
}
void xsteam_ui::slots_imput_uid_push()
{
xs_data.s_name = server_txt->currentText().toStdString();
slots_disable_enable_function(false);
QFuture<void> future = QtConcurrent::run([=](UidData u_data)
{
xs_git_fetch->fecth_uid_to_steam(xs_data);
slots_disable_enable_function(true); }, xs_data);
} }

View File

@ -16,7 +16,6 @@
#include "xsteam_about_ui.h" #include "xsteam_about_ui.h"
#include "xsteam_view.h" #include "xsteam_view.h"
#include "xsteam_git_fetch.h" #include "xsteam_git_fetch.h"
#include <iostream>
#include <version.h> #include <version.h>
class xsteam_ui:public QWidget{ class xsteam_ui:public QWidget{
@ -25,7 +24,7 @@ public:
xsteam_ui(QWidget* parent=nullptr); xsteam_ui(QWidget* parent=nullptr);
~xsteam_ui(); ~xsteam_ui();
void xsteam_init_main_layout(); void xsteam_init_main_layout();
void xsteam_init_head_layout(); void xsteam_init_info_layout();
void xsteam_init_mind_layout(); void xsteam_init_mind_layout();
void xsteam_init_foot_layout(); void xsteam_init_foot_layout();
void xsteam_init_style(); void xsteam_init_style();
@ -34,10 +33,9 @@ private:
void table_load_ui_data(); void table_load_ui_data();
private: private:
QVBoxLayout* main_layout; QVBoxLayout* main_layout;
QHBoxLayout* head_layout; QHBoxLayout* info_layout;
QVBoxLayout* mind_layout; QVBoxLayout* mind_layout;
QHBoxLayout* foot_layout; QHBoxLayout* foot_layout;
QLabel* head_tag;
//托管服务器选择 //托管服务器选择
QHBoxLayout* server_layout; QHBoxLayout* server_layout;
QLabel* server_tag; QLabel* server_tag;
@ -46,6 +44,8 @@ private:
QPushButton* btn_fetch_src_data; QPushButton* btn_fetch_src_data;
QPushButton* btn_run_steam; QPushButton* btn_run_steam;
QPushButton* btn_run_steamtools; QPushButton* btn_run_steamtools;
//头部信息
QLabel* info_txt_tag;
//入库游戏信息 //入库游戏信息
QHBoxLayout* ip_layout; QHBoxLayout* ip_layout;
QHBoxLayout* ip_iu_layout; QHBoxLayout* ip_iu_layout;
@ -80,7 +80,9 @@ private:
xsteam_about_ui* xs_about_ui; xsteam_about_ui* xs_about_ui;
xsteam_git_fetch* xs_git_fetch; xsteam_git_fetch* xs_git_fetch;
QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed); QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed);
//connect
UidData xs_data;
PUSH_MODE xs_state;
private slots: private slots:
void slots_open_server_edit(); void slots_open_server_edit();
void slots_open_setting(); void slots_open_setting();
@ -96,7 +98,10 @@ private slots:
void slots_fetch_src_data(); void slots_fetch_src_data();
void slots_rightMenu(const QPoint &pos); void slots_rightMenu(const QPoint &pos);
void slots_delete_uid_st(); void slots_delete_uid_st();
void slots_updata_uid_st(); void slots_get_uid_dlcs();
void slots_in_dlc_delete();
void slots_in_dlc_add();
void slots_imput_update_uid_push();
signals: signals:
void signals_src_combobox_update(); void signals_src_combobox_update();
}; };

View File

@ -29,30 +29,33 @@ void xsteam_view::init_view(VIEW_MODE view_mode)
m_model->setColumnCount(ex_in_dlc_table_head_tips.count()); m_model->setColumnCount(ex_in_dlc_table_head_tips.count());
m_model->setHorizontalHeaderLabels(ex_in_dlc_table_head_tips); m_model->setHorizontalHeaderLabels(ex_in_dlc_table_head_tips);
} }
setSelectionMode(QAbstractItemView::SingleSelection);
horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionBehavior(QAbstractItemView::SelectRows);
setEditTriggers(QAbstractItemView::NoEditTriggers); setEditTriggers(QAbstractItemView::NoEditTriggers);
verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); // 自动设置行高 verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); // 自动设置行高
setFocusPolicy(Qt::NoFocus);
verticalHeader()->hide(); verticalHeader()->hide();
setModel(m_model); setModel(m_model);
} }
void xsteam_view::item_append(UidData& data, VIEW_MODE mode) void xsteam_view::item_append(UidData& data, VIEW_MODE mode)
{ {
QList<QStandardItem *> rows; QList<QStandardItem *> d_rows;
std::vector<std::string> dlc_uid; std::vector<std::string> dlc_uid;
if (mode == VIEW_MODE::UID_INFO) if (mode == VIEW_MODE::UID_INFO)
{ {
rows.push_back(new QStandardItem(QString::fromStdString(data.ico))); d_rows.push_back(new QStandardItem(QString::fromStdString(data.ico)));
rows.push_back(new QStandardItem(QString::fromStdString(data.uid))); d_rows.push_back(new QStandardItem(QString::fromStdString(data.uid)));
rows.push_back(new QStandardItem(QString::fromStdString(data.name))); d_rows.push_back(new QStandardItem(QString::fromStdString(data.name)));
rows.push_back(new QStandardItem(QString::fromStdString(data.m_time))); d_rows.push_back(new QStandardItem(QString::fromStdString(data.m_time)));
rows.push_back(new QStandardItem(QString::fromStdString(data.i_time))); d_rows.push_back(new QStandardItem(QString::fromStdString(data.i_time)));
for (auto row : rows) d_rows.push_back(new QStandardItem(QString::fromStdString(data.s_name)));
for (auto d_row : d_rows)
{ {
row->setTextAlignment(Qt::AlignCenter); d_row->setTextAlignment(Qt::AlignCenter);
} }
m_model->appendRow(rows); m_model->appendRow(d_rows);
} }
else else
{ {
@ -67,9 +70,9 @@ void xsteam_view::item_append(UidData& data, VIEW_MODE mode)
} }
for (auto x : dlc_uid) for (auto x : dlc_uid)
{ {
rows.clear(); d_rows.clear();
rows.push_back(new QStandardItem(QString::fromStdString(x))); d_rows.push_back(new QStandardItem(QString::fromStdString(x)));
m_model->appendRow(rows); m_model->appendRow(d_rows);
} }
} }
} }

View File

@ -7,6 +7,7 @@
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QLabel> #include <QLabel>
#include <QComboBox>
#include <QStandardItemModel> #include <QStandardItemModel>
#include "xsteam_view_item.h" #include "xsteam_view_item.h"
#include "xsteam_base.h" #include "xsteam_base.h"
@ -25,7 +26,6 @@ public:
~xsteam_view(); ~xsteam_view();
void init_view(VIEW_MODE); void init_view(VIEW_MODE);
void item_append(UidData& data,VIEW_MODE mode); void item_append(UidData& data,VIEW_MODE mode);
private:
void item_clear(); void item_clear();
private: private:
QStandardItemModel* m_model; QStandardItemModel* m_model;

View File

@ -27,8 +27,7 @@ void xsteam_view_item::paint(QPainter *painter,
} }
QRect rect = option.rect; QRect rect = option.rect;
pic = pic.scaled(rect.width(), rect.height(), pic = pic.scaled(rect.width(), rect.height(),Qt::KeepAspectRatio);
Qt::KeepAspectRatio);
int width = pic.width(); int width = pic.width();
int height = pic.height(); int height = pic.height();

View File

@ -7,4 +7,8 @@
#define PROJECT_MINOR_VERSION "@PROJECT_VERSION_MINOR@" #define PROJECT_MINOR_VERSION "@PROJECT_VERSION_MINOR@"
#define PROJECT_PATCH_VERSION "@PROJECT_VERSION_PATCH@" #define PROJECT_PATCH_VERSION "@PROJECT_VERSION_PATCH@"
#define QT_VERSION_STR "@QT_VERSION_STR@"
#define GCC_GXX_VERSION_STR "@CMAKE_CXX_COMPILER_VERSION@"
#define LIBCURL_VERSION_STR "@CURL_VERSION@"
#define LIBGIT2_VERSION_STR "@LIBGIT2_VERSION@"
#endif // VERSION_H #endif // VERSION_H