粒子连接器修改
This commit is contained in:
1 parent
bd0771747d
commit
8ab3672c4e
5 files changed
+170
-6
No files matched your search
@@ -141,13 +141,18 @@ std::wstring field_text(HWND field) {
|
||||
}
|
||||
|
||||
void refresh_status() {
|
||||
const bool owns_port = service.running();
|
||||
const bool port_occupied = owns_port || connector::connector_port_in_use();
|
||||
std::wstring status;
|
||||
if (!startup_error.empty()) {
|
||||
if (!startup_error.empty() && !port_occupied) {
|
||||
status = L"● 连接器未启动 · " + wide(startup_error);
|
||||
status_color = kErrorText;
|
||||
} else if (!service.running()) {
|
||||
} else if (!port_occupied) {
|
||||
status = L"● 连接器已断开";
|
||||
status_color = kSecondaryText;
|
||||
} else if (!owns_port) {
|
||||
status = L"● 端口 27843 正在运行 · 可停止连接";
|
||||
status_color = kSuccessText;
|
||||
} else if (connector::find_spine_executable().empty()) {
|
||||
status = L"● 连接器运行中 · 未找到 Spine";
|
||||
status_color = kWarningText;
|
||||
@@ -157,7 +162,7 @@ void refresh_status() {
|
||||
}
|
||||
SetWindowTextW(status_label, status.c_str());
|
||||
InvalidateRect(status_label, nullptr, TRUE);
|
||||
SetWindowTextW(connection_button, service.running() ? L"断开连接" : L"启动连接");
|
||||
SetWindowTextW(connection_button, port_occupied ? L"停止连接" : L"启动连接");
|
||||
const bool show_path = connector::find_spine_executable().empty();
|
||||
for (HWND control : {path_label, path_field, browse_button, automatic_button, save_button}) {
|
||||
if (control) ShowWindow(control, show_path ? SW_SHOW : SW_HIDE);
|
||||
@@ -246,6 +251,9 @@ LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lp
|
||||
if (service.running()) {
|
||||
service.stop();
|
||||
startup_error.clear();
|
||||
} else if (connector::connector_port_in_use()) {
|
||||
startup_error.clear();
|
||||
connector::stop_connector_port(startup_error);
|
||||
} else {
|
||||
startup_error.clear();
|
||||
service.start(startup_error);
|
||||
|
||||
Reference in new issue
Block a user