mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-15 19:22:25 +08:00
parent
f72aaa23cf
commit
ea65a3dd4b
|
@ -179,6 +179,7 @@ Item {
|
|||
Image {
|
||||
id: generalImage
|
||||
width: deputyGeneral ? parent.width / 2 : parent.width
|
||||
Behavior on width { NumberAnimation { duration: 100 } }
|
||||
height: parent.height
|
||||
smooth: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
|
@ -259,7 +260,8 @@ Item {
|
|||
anchors.fill: photoMaskEffect
|
||||
source: photoMaskEffect
|
||||
saturation: 0
|
||||
visible: root.dead || root.surrendered
|
||||
opacity: (root.dead || root.surrendered) ? 1 : 0
|
||||
Behavior on opacity { NumberAnimation { duration: 300 } }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
@ -269,9 +271,10 @@ Item {
|
|||
height: 222
|
||||
radius: 8
|
||||
|
||||
visible: root.drank > 0
|
||||
// visible: root.drank > 0
|
||||
color: "red"
|
||||
opacity: 0.4 + Math.log(root.drank) * 0.12
|
||||
opacity: (root.drank <= 0 ? 0 : 0.4) + Math.log(root.drank) * 0.12
|
||||
Behavior on opacity { NumberAnimation { duration: 300 } }
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
|
|
|
@ -107,6 +107,10 @@
|
|||
<source>[%1/%2] upgrading package '%3'</source>
|
||||
<translation>[%1/%2] 更新拓展包 '%3'</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>packages/%1: some error occured.</source>
|
||||
<translation>拓展包 %1 出了点问题,尝试在管理拓展包中删除之再试试</translation>
|
||||
</message>
|
||||
</context>
|
||||
|
||||
<context>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
---@field public exit_func fun(self: GameEvent) @ 事件结束后执行的函数
|
||||
---@field public extra_exit_funcs fun(self:GameEvent)[] @ 事件结束后执行的自定义函数
|
||||
---@field public exec_ret boolean? @ exec函数的返回值,可能不存在
|
||||
---@field public status string @ ready, running, exiting, dead
|
||||
---@field public interrupted boolean @ 事件是否是因为被中断而结束的,可能是防止事件或者被杀
|
||||
---@field public killed boolean @ 事件因为终止一切结算而被中断(所谓的“被杀”)
|
||||
local GameEvent = class("GameEvent")
|
||||
|
@ -49,6 +50,7 @@ function GameEvent:initialize(event, ...)
|
|||
self.extra_clear_funcs = Util.DummyTable
|
||||
self.exit_func = GameEvent.exit_funcs[event] or dummyFunc
|
||||
self.extra_exit_funcs = Util.DummyTable
|
||||
self.status = "ready"
|
||||
self.interrupted = false
|
||||
end
|
||||
|
||||
|
@ -166,6 +168,8 @@ end
|
|||
function GameEvent:exec()
|
||||
local room = self.room
|
||||
local logic = room.logic
|
||||
if self.status ~= "ready" then return true end
|
||||
|
||||
self.parent = logic:getCurrentEvent()
|
||||
|
||||
if self:prepare_func() then return true end
|
||||
|
@ -174,6 +178,7 @@ function GameEvent:exec()
|
|||
|
||||
local co = coroutine.create(self.main_func)
|
||||
self._co = co
|
||||
self.status = "running"
|
||||
|
||||
coroutine.yield(self, "__newEvent")
|
||||
|
||||
|
@ -188,6 +193,7 @@ function GameEvent:exec()
|
|||
end
|
||||
|
||||
function GameEvent:shutdown()
|
||||
if self.status ~= "running" then return end
|
||||
-- yield to self and break
|
||||
coroutine.yield(self, "__breakEvent")
|
||||
end
|
||||
|
|
|
@ -441,6 +441,7 @@ function GameLogic:start()
|
|||
e.killed = e ~= jump_to
|
||||
self:clearEvent(e)
|
||||
coroutine.close(e._co)
|
||||
e.status = "dead"
|
||||
if e == jump_to then jump_to = nil end -- shutdown结束了
|
||||
e = self:getCurrentCleaner()
|
||||
end
|
||||
|
@ -460,6 +461,7 @@ function GameLogic:start()
|
|||
e.interrupted = ret
|
||||
self:clearEvent(e)
|
||||
coroutine.close(e._co)
|
||||
e.status = "dead"
|
||||
elseif ret == true then
|
||||
-- 跳到越早发生的事件越好
|
||||
if not jump_to then
|
||||
|
@ -543,6 +545,8 @@ end
|
|||
---@param event GameEvent
|
||||
function GameLogic:clearEvent(event)
|
||||
if event.event == GameEvent.ClearEvent then return end
|
||||
if event.status == "exiting" then return end
|
||||
event.status = "exiting"
|
||||
local ce = GameEvent(GameEvent.ClearEvent, event)
|
||||
ce.id = self.current_event_id
|
||||
local co = coroutine.create(ce.main_func)
|
||||
|
@ -657,6 +661,7 @@ end
|
|||
|
||||
function GameLogic:breakTurn()
|
||||
local event = self:getCurrentEvent():findParent(GameEvent.Turn)
|
||||
if not event then return end
|
||||
event:shutdown()
|
||||
end
|
||||
|
||||
|
|
|
@ -169,7 +169,11 @@ void PackMan::updatePack(const QString &pack) {
|
|||
int error;
|
||||
error = status(pack);
|
||||
if (error != 0) {
|
||||
qCritical("packages/%s: Workspace is dirty, or some error occured.", pack.toLatin1().constData());
|
||||
#ifndef FK_SERVER_ONLY
|
||||
if (Backend != nullptr) {
|
||||
Backend->showToast(tr("packages/%1: some error occured.").arg(pack));
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
error = pull(pack);
|
||||
|
@ -187,7 +191,11 @@ void PackMan::upgradePack(const QString &pack) {
|
|||
return;
|
||||
error = status(pack);
|
||||
if (error != 0) {
|
||||
qCritical("Workspace is dirty, or some error occured.");
|
||||
#ifndef FK_SERVER_ONLY
|
||||
if (Backend != nullptr) {
|
||||
Backend->showToast(tr("packages/%1: some error occured.").arg(pack));
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
error = pull(pack);
|
||||
|
@ -219,6 +227,12 @@ QString PackMan::listPackages() {
|
|||
const git_error *e = git_error_last(); \
|
||||
qCritical("Error %d/%d: %s\n", error, e->klass, e->message)
|
||||
|
||||
#define GIT_CHK_CLEAN \
|
||||
if (error < 0) { \
|
||||
GIT_FAIL; \
|
||||
goto clean; \
|
||||
}
|
||||
|
||||
static int transfer_progress_cb(const git_indexer_progress *stats,
|
||||
void *payload) {
|
||||
(void)payload;
|
||||
|
@ -290,37 +304,22 @@ int PackMan::pull(const QString &name) {
|
|||
opt2.checkout_strategy = GIT_CHECKOUT_FORCE;
|
||||
|
||||
error = git_repository_open(&repo, path);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
|
||||
// first git fetch origin
|
||||
error = git_remote_lookup(&remote, repo, "origin");
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_remote_fetch(remote, NULL, &opt, NULL);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
|
||||
// then git checkout FETCH_HEAD
|
||||
error = git_repository_set_head(repo, "FETCH_HEAD");
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_checkout_head(repo, &opt2);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
} else {
|
||||
if (Backend == nullptr)
|
||||
printf("\n");
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
|
||||
if (Backend == nullptr)
|
||||
printf("\n");
|
||||
|
||||
clean:
|
||||
git_remote_free(remote);
|
||||
|
@ -337,25 +336,13 @@ int PackMan::checkout(const QString &name, const QString &hash) {
|
|||
auto path = QString("packages/%1").arg(name).toUtf8();
|
||||
auto sha = hash.toLatin1();
|
||||
error = git_repository_open(&repo, path);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_oid_fromstr(&oid, sha);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_repository_set_head_detached(repo, &oid);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_checkout_head(repo, &opt);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
|
||||
clean:
|
||||
git_repository_free(repo);
|
||||
|
@ -369,20 +356,11 @@ int PackMan::checkout_branch(const QString &name, const QString &branch) {
|
|||
git_object *obj = NULL;
|
||||
auto path = QString("packages/%1").arg(name).toUtf8();
|
||||
error = git_repository_open(&repo, path);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_revparse_single(&obj, repo, branch.toUtf8());
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_checkout_tree(repo, obj, NULL);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
|
||||
clean:
|
||||
git_object_free(obj);
|
||||
|
@ -398,21 +376,19 @@ int PackMan::status(const QString &name) {
|
|||
const git_status_entry *s;
|
||||
auto path = QString("packages/%1").arg(name).toUtf8();
|
||||
error = git_repository_open(&repo, path);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_status_list_new(&status_list, repo, NULL);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
goto clean;
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
maxi = git_status_list_entrycount(status_list);
|
||||
for (i = 0; i < maxi; ++i) {
|
||||
char *istatus = NULL;
|
||||
s = git_status_byindex(status_list, i);
|
||||
if (s->status != GIT_STATUS_CURRENT && s->status != GIT_STATUS_IGNORED)
|
||||
if (s->status != GIT_STATUS_CURRENT && s->status != GIT_STATUS_IGNORED) {
|
||||
git_status_list_free(status_list);
|
||||
git_repository_free(repo);
|
||||
qCritical("Workspace is dirty.");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
clean:
|
||||
|
@ -425,28 +401,25 @@ QString PackMan::head(const QString &name) {
|
|||
git_repository *repo = NULL;
|
||||
int error;
|
||||
git_object *obj = NULL;
|
||||
const git_oid *oid;
|
||||
char buf[42] = {0};
|
||||
auto path = QString("packages/%1").arg(name).toUtf8();
|
||||
error = git_repository_open(&repo, path);
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
git_object_free(obj);
|
||||
git_repository_free(repo);
|
||||
return QString();
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
error = git_revparse_single(&obj, repo, "HEAD");
|
||||
if (error < 0) {
|
||||
GIT_FAIL;
|
||||
git_object_free(obj);
|
||||
git_repository_free(repo);
|
||||
return QString();
|
||||
}
|
||||
GIT_CHK_CLEAN;
|
||||
|
||||
const git_oid *oid = git_object_id(obj);
|
||||
char buf[42];
|
||||
oid = git_object_id(obj);
|
||||
git_oid_tostr(buf, 41, oid);
|
||||
git_object_free(obj);
|
||||
git_repository_free(repo);
|
||||
return QString(buf);
|
||||
|
||||
clean:
|
||||
git_object_free(obj);
|
||||
git_repository_free(repo);
|
||||
return QString();
|
||||
}
|
||||
|
||||
#undef GIT_FAIL
|
||||
#undef GIT_CHK_CLEAN
|
||||
|
|
Loading…
Reference in New Issue
Block a user