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