能增删新mod了,先就这样
This commit is contained in:
notify 2023-05-27 21:59:31 +08:00 committed by GitHub
parent beaaa09fbe
commit 9876becf2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 3 deletions

View File

@ -45,7 +45,28 @@ Item {
ListView { ListView {
anchors.fill: parent anchors.fill: parent
model: modConfig.modList model: modConfig.modList
delegate: Text { text: modelData } delegate: SwipeDelegate {
width: root.width
text: modelData
swipe.right: Label {
id: deleteLabel
text: qsTr("Delete")
color: "white"
verticalAlignment: Label.AlignVCenter
padding: 12
height: parent.height
anchors.right: parent.right
opacity: swipe.complete ? 1 : 0
Behavior on opacity { NumberAnimation { } }
SwipeDelegate.onClicked: deleteMod(modelData);
background: Rectangle {
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
}
}
}
} }
} }
@ -110,4 +131,9 @@ Item {
ModBackend.commitChanges(name, "Initial commit", modConfig.userName, modConfig.email); ModBackend.commitChanges(name, "Initial commit", modConfig.userName, modConfig.email);
modConfig.addMod(name); modConfig.addMod(name);
} }
function deleteMod(name) {
ModBackend.removeMod(name);
modConfig.removeMod(name);
}
} }

View File

@ -158,7 +158,7 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.leftMargin: 12 anchors.leftMargin: 12
anchors.bottomMargin: 12 anchors.bottomMargin: 12
text: "FreeKill " + FkVersion text: qsTr("FreeKill") + " v" + FkVersion
font.pixelSize: 16 font.pixelSize: 16
font.bold: true font.bold: true
} }
@ -188,6 +188,7 @@ Item {
text: qsTr("Mod Making") text: qsTr("Mod Making")
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: Debugging
onClicked: { onClicked: {
mainStack.push(modMaker); mainStack.push(modMaker);
} }

View File

@ -59,6 +59,10 @@
<context> <context>
<name>Init</name> <name>Init</name>
<message>
<source>FreeKill</source>
<translation></translation>
</message>
<message> <message>
<source>Username</source> <source>Username</source>
<translation></translation> <translation></translation>
@ -227,6 +231,10 @@
<source>ModMaker</source> <source>ModMaker</source>
<translation>Mod制作器 - </translation> <translation>Mod制作器 - </translation>
</message> </message>
<message>
<source>Delete</source>
<translation></translation>
</message>
<message> <message>
<source>config is incomplete</source> <source>config is incomplete</source>
<translation> <translation>

BIN
lib/android/libgit2.so Normal file → Executable file

Binary file not shown.

BIN
lib/android/libssh2.so Executable file

Binary file not shown.

View File

@ -49,10 +49,11 @@ elseif (ANDROID)
set(SQLITE3_LIB ${PROJECT_SOURCE_DIR}/lib/android/libsqlite3.so) set(SQLITE3_LIB ${PROJECT_SOURCE_DIR}/lib/android/libsqlite3.so)
set(CRYPTO_LIB ${PROJECT_SOURCE_DIR}/lib/android/libcrypto.so) set(CRYPTO_LIB ${PROJECT_SOURCE_DIR}/lib/android/libcrypto.so)
set(SSL_LIB ${PROJECT_SOURCE_DIR}/lib/android/libssl.so) set(SSL_LIB ${PROJECT_SOURCE_DIR}/lib/android/libssl.so)
set(SSH_LIB ${PROJECT_SOURCE_DIR}/lib/android/libssh2.so)
set(GIT_LIB ${PROJECT_SOURCE_DIR}/lib/android/libgit2.so) set(GIT_LIB ${PROJECT_SOURCE_DIR}/lib/android/libgit2.so)
set_target_properties(FreeKill PROPERTIES set_target_properties(FreeKill PROPERTIES
QT_ANDROID_PACKAGE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/android QT_ANDROID_PACKAGE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/android
QT_ANDROID_EXTRA_LIBS "${LUA_LIB};${SQLITE3_LIB};${CRYPTO_LIB};${SSL_LIB};${GIT_LIB}" QT_ANDROID_EXTRA_LIBS "${LUA_LIB};${SQLITE3_LIB};${CRYPTO_LIB};${SSL_LIB};${SSH_LIB};${GIT_LIB}"
) )
list(REMOVE_ITEM QT_LIB Qt6::QuickControls2) list(REMOVE_ITEM QT_LIB Qt6::QuickControls2)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
@ -88,6 +89,7 @@ target_link_libraries(FreeKill PRIVATE
${SSL_LIB} ${SSL_LIB}
${READLINE_LIB} ${READLINE_LIB}
${QT_LIB} ${QT_LIB}
${SSH_LIB}
${GIT_LIB} ${GIT_LIB}
${IDBFS_LIB} ${IDBFS_LIB}
) )

View File

@ -8,6 +8,8 @@
#include <qobject.h> #include <qobject.h>
#include <qversionnumber.h> #include <qversionnumber.h>
#include <openssl/bn.h>
#include "client_socket.h" #include "client_socket.h"
#include "packman.h" #include "packman.h"
#include "player.h" #include "player.h"

View File

@ -125,6 +125,10 @@ void ModMaker::createMod(const QString &name) {
init(name); init(name);
} }
void ModMaker::removeMod(const QString &name) {
QDir("mymod/" + name).removeRecursively();
}
void ModMaker::commitChanges(const QString &name, const QString &msg, void ModMaker::commitChanges(const QString &name, const QString &msg,
const QString &user, const QString &email) const QString &user, const QString &email)
{ {

View File

@ -16,6 +16,7 @@ public:
Q_INVOKABLE void saveToFile(const QString &fileName, const QString &content); Q_INVOKABLE void saveToFile(const QString &fileName, const QString &content);
Q_INVOKABLE void createMod(const QString &name); Q_INVOKABLE void createMod(const QString &name);
Q_INVOKABLE void removeMod(const QString &name);
Q_INVOKABLE void stageFiles(const QString &name) { add(name); } Q_INVOKABLE void stageFiles(const QString &name) { add(name); }
Q_INVOKABLE void commitChanges(const QString &name, const QString &msg, Q_INVOKABLE void commitChanges(const QString &name, const QString &msg,
const QString &user, const QString &email); const QString &user, const QString &email);