aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author1992414357@qq.com <1992414357@qq.com>2025-06-09 10:29:05 +0800
committer1992414357@qq.com <1992414357@qq.com>2025-06-09 10:29:05 +0800
commitc8ece4c62b6f8b5165de4d9d38a467bbc1e94a53 (patch)
treea23115fef3cee8a888e43c0c245ad63d6526296f
parent7093b08b8efd6e35a434b2923c40b763b51e675b (diff)
修改了导出脚本
-rw-r--r--.cargo/config.toml14
-rw-r--r--.idea/runConfigurations/Export_Project.xml6
-rw-r--r--Config_Export.toml8
-rw-r--r--console/Cargo.toml2
-rw-r--r--core/Cargo.toml1
-rw-r--r--core/examples/connect.rs5
-rw-r--r--core/src/data/controller/runtime/implements.rs1
-rw-r--r--core/src/data/game/runtime/implements.rs4
-rw-r--r--core/src/service/cli_addition/runtime_consoles.rs10
-rw-r--r--core/src/service/tcp_network/pad_server/implements.rs2
-rw-r--r--export/Cargo.toml1
-rw-r--r--export/src/bin/export_project.rs16
-rw-r--r--src/lib.rs4
13 files changed, 48 insertions, 26 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
index cabad87..cb27ad5 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -1,10 +1,18 @@
+[alias]
+dev = ["run", "--manifest-path", "./export/Cargo.toml", "--profile", "dev", "--bin", "export_project", "dev"]
+export = ["run", "--manifest-path", "./export/Cargo.toml", "--profile", "release", "--release", "--bin", "export_project"]
+
+padc = ["run", "--manifest-path", "./console/Cargo.toml", "--profile", "dev", "--quiet", "--bin", "padc"]
+
[build]
target-dir = "./.cargo/shared/target"
[env]
+
+# Project Settings
PROJECT_VERSION = { value = "0.1.0" }
-TEST_PLAYER_ACCOUNT = { value = "Ame.Na.LISA" }
+# Pad Console Cli
+TEST_PLAYER_ACCOUNT = { value = "ame_na_lisa" }
TEST_PLAYER_PASSWORD = { value = "amenalisa@@:P_QWQ" }
-
-TEST_PLAYER_NICKNAME = { value = "ame_na_lisa" } \ No newline at end of file
+TEST_PLAYER_NICKNAME = { value = "Ame.Na.LISA" }
diff --git a/.idea/runConfigurations/Export_Project.xml b/.idea/runConfigurations/Export_Project.xml
index c0beea1..5416a16 100644
--- a/.idea/runConfigurations/Export_Project.xml
+++ b/.idea/runConfigurations/Export_Project.xml
@@ -1,11 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Export Project" type="CargoCommandRunConfiguration" factoryName="Cargo Command" folderName="Export">
<option name="buildProfileId" value="dev" />
- <option name="command" value="run --manifest-path ./export/Cargo.toml --bin export_project" />
+ <option name="command" value="run --manifest-path ./export/Cargo.toml --release --bin export_project" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
- <option name="channel" value="DEFAULT" />
+ <option name="channel" value="STABLE" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
@@ -14,7 +14,7 @@
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
- <option name="RunConfigurationTask" enabled="true" run_configuration_name="Final Build" run_configuration_type="CargoCommandRunConfiguration" />
+ <option name="RunConfigurationTask" enabled="true" run_configuration_name="Build All" run_configuration_type="CargoCommandRunConfiguration" run_configuration_target="RsBuildProfile:release" />
</method>
</configuration>
</component> \ No newline at end of file
diff --git a/Config_Export.toml b/Config_Export.toml
index 310b7f6..2c11b03 100644
--- a/Config_Export.toml
+++ b/Config_Export.toml
@@ -4,6 +4,8 @@ license = { raw = "./", target = "./", files = ["LICENSE-LGPL-2", "LICENSE-THIRD
#./.cargo/shared/target/export/deps
[release.deps]
-header = { raw = "./", target = "./bridge", files = ["nogamepads_cpp.h", "nogamepads.h"] }
-dll = { raw = "./", target = "./bridge", files = ["nogamepads_lib_c.dll"] }
-binaries = { raw = "./", target = "./bin", files = ["padc.exe"] } \ No newline at end of file
+#header = { raw = "./", target = "./bridge", files = ["nogamepads_cpp.h", "nogamepads.h"] }
+#dll = { raw = "./", target = "./bridge", files = ["nogamepads_lib_c.dll"] }
+
+padc = { raw = "./", target = "./bin", files = ["padc.exe"] }
+
diff --git a/console/Cargo.toml b/console/Cargo.toml
index b241b6b..57860c7 100644
--- a/console/Cargo.toml
+++ b/console/Cargo.toml
@@ -8,10 +8,8 @@ version.workspace = true
nogamepads = { path = "../../NoGamepads" }
nogamepads-core = { path = "../core" }
clap = { version = "4.5.38", features = ["derive"] }
-rand = { version = "0.9.1", features = [] }
serde = { version = "1.0.219", features = ["derive"] }
serde_yaml = "0.9.34"
-prettytable-rs = "0.10.0"
tokio = { version = "1.45.0", features = ["full"] }
crossterm = "0.29.0"
log = "0.4.27" \ No newline at end of file
diff --git a/core/Cargo.toml b/core/Cargo.toml
index f943cb7..6758217 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -13,7 +13,6 @@ serde = { version = "1.0.219", features = ["derive"] }
clap = { version = "4.5.38", features = ["derive"] }
sha1 = "0.10.6"
log = "0.4.27"
-prettytable-rs = "0.10.0"
shell-words = "1.1.0"
[lib]
diff --git a/core/examples/connect.rs b/core/examples/connect.rs
index c367787..1fd9bca 100644
--- a/core/examples/connect.rs
+++ b/core/examples/connect.rs
@@ -4,6 +4,7 @@ use nogamepads::logger_utils::logger_build;
use nogamepads_core::data::controller::structs::ControllerData;
use nogamepads_core::data::player::structs::Player;
use nogamepads_core::service::tcp_network::pad_client::structs::PadClientNetwork;
+use nogamepads_core::service::tcp_network::utils::tokio_utils::build_tokio_runtime;
fn main () {
logger_build(Trace);
@@ -21,5 +22,7 @@ fn main () {
let runtime = controller.runtime();
let client = PadClientNetwork::build(Arc::clone(&runtime));
- client.connect();
+ // client.connect();
+ // or
+ build_tokio_runtime("Tokio Runtime".to_string()).block_on(client.build_entry())
} \ No newline at end of file
diff --git a/core/src/data/controller/runtime/implements.rs b/core/src/data/controller/runtime/implements.rs
index 840ea2c..1f2734a 100644
--- a/core/src/data/controller/runtime/implements.rs
+++ b/core/src/data/controller/runtime/implements.rs
@@ -4,7 +4,6 @@ use log::trace;
use crate::data::controller::runtime::structs::ControllerRuntime;
use crate::data::message::enums::{ControlMessage, GameMessage};
use crate::data::message::traits::MessageManager;
-use crate::data::player::structs::Account;
use crate::service::service_types::ServiceType;
/// Message manager for controller-side runtime
diff --git a/core/src/data/game/runtime/implements.rs b/core/src/data/game/runtime/implements.rs
index 43a7dee..22b6a5d 100644
--- a/core/src/data/game/runtime/implements.rs
+++ b/core/src/data/game/runtime/implements.rs
@@ -198,10 +198,10 @@ impl GameRuntimeData {
let key = (service_type, player.account.clone());
let get_received = self.received.get_mut(&key);
let get_send = self.send.get_mut(&key);
- if let Some(mut list) = get_received {
+ if let Some(list) = get_received {
list.clear();
}
- if let Some(mut list) = get_send {
+ if let Some(list) = get_send {
list.clear();
}
diff --git a/core/src/service/cli_addition/runtime_consoles.rs b/core/src/service/cli_addition/runtime_consoles.rs
index 76ff20c..38d8404 100644
--- a/core/src/service/cli_addition/runtime_consoles.rs
+++ b/core/src/service/cli_addition/runtime_consoles.rs
@@ -1,6 +1,7 @@
use crate::service::cli_addition::utils::read_cli;
use clap::{Command, FromArgMatches};
use std::sync::{Arc, Mutex};
+use log::info;
use tokio::{join, spawn};
use crate::service::service_runner::NoGamepadsService;
@@ -9,14 +10,14 @@ where Cmd: FromArgMatches {
command: Command,
prefix: String,
service: Arc<Mutex<PadService>>,
- process_command: fn(Arc<Mutex<PadService>>, Cmd),
+ process_command: fn(Arc<Mutex<PadService>>, Cmd) -> bool,
}
impl<PadService: Send + 'static, Cmd: FromArgMatches + 'static> RuntimeConsole<PadService, Cmd> {
pub fn build(command: Command,
prefix: String,
service: Arc<Mutex<PadService>>,
- process_command: fn(Arc<Mutex<PadService>>, Cmd),
+ process_command: fn(Arc<Mutex<PadService>>, Cmd) -> bool,
) -> RuntimeConsole<PadService, Cmd> {
RuntimeConsole { command, prefix, service, process_command }
}
@@ -52,9 +53,12 @@ impl<PadService: Send + 'static, Cmd: FromArgMatches + 'static> RuntimeConsole<P
match option {
None => {}
Some(cmd) => {
- (self.process_command)(Arc::clone(&self.service), cmd);
+ if !(self.process_command)(Arc::clone(&self.service), cmd) {
+ break;
+ }
}
}
}
+ info!("[Console] Shutdown.")
}
} \ No newline at end of file
diff --git a/core/src/service/tcp_network/pad_server/implements.rs b/core/src/service/tcp_network/pad_server/implements.rs
index c4d8cfc..d4288bf 100644
--- a/core/src/service/tcp_network/pad_server/implements.rs
+++ b/core/src/service/tcp_network/pad_server/implements.rs
@@ -5,7 +5,7 @@ use std::time::Duration;
use log::{error, info, trace, warn};
use tokio::{join, select, spawn};
use tokio::net::{TcpListener, TcpStream};
-use tokio::sync::watch::{channel, Receiver, Sender};
+use tokio::sync::watch::{channel};
use tokio::time::sleep;
use nogamepads::entry_mutex;
use crate::data::game::runtime::structs::GameRuntime;
diff --git a/export/Cargo.toml b/export/Cargo.toml
index 5ddc6ca..790606c 100644
--- a/export/Cargo.toml
+++ b/export/Cargo.toml
@@ -6,5 +6,6 @@ workspace = "../../NoGamepads"
edition = "2024"
[dependencies]
+nogamepads = { path = "../../NoGamepads" }
serde = { version = "1.0.219", features = ["derive"] }
toml = "0.7.8" \ No newline at end of file
diff --git a/export/src/bin/export_project.rs b/export/src/bin/export_project.rs
index 95b3fbe..9cdf412 100644
--- a/export/src/bin/export_project.rs
+++ b/export/src/bin/export_project.rs
@@ -3,7 +3,8 @@ use std::path::PathBuf;
use serde::Deserialize;
use std::collections::HashMap;
-use std::fs;
+use std::{env, fs};
+use nogamepads::file_system_utils::open_in_explorer;
#[derive(Debug, Deserialize)]
pub struct Config {
@@ -24,7 +25,8 @@ pub struct ReleaseItem {
}
pub fn main() {
- let version = env!("PROJECT_VERSION");
+ let args: Vec<String> = env::args().collect();
+ let version = if let Some(v) = args.get(1) { v.to_string() } else { env!("PROJECT_VERSION").to_string() };
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).parent().unwrap().to_path_buf();
let toml_config = root.join("./Config_Export.toml");
@@ -35,10 +37,12 @@ pub fn main() {
root.join("export");
let export_version_dir =
- export_root.join(version);
+ export_root.join(&version);
+
+ let branch = if version.eq("dev") { "debug" } else { "release" };
let target_dir =
- root.join(".cargo").join("shared").join("target").join("release").join("deps");
+ root.join(".cargo").join("shared").join("target").join(branch).join("deps");
// 清理目录
let _ = remove_dir_all(&export_version_dir);
@@ -56,6 +60,10 @@ pub fn main() {
let target_path = export_version_dir.join(data.1.target);
copy_files(&raw_path, &target_path, data.1.files);
}
+
+ if let Ok(()) = open_in_explorer(export_version_dir) {
+ println!("DONE");
+ }
}
fn copy_files (raw: &PathBuf, target: &PathBuf, file_names: Vec<String>) {
diff --git a/src/lib.rs b/src/lib.rs
index caab871..24d3887 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,5 @@
pub mod console_utils;
pub mod logger_utils;
-pub mod convert_utils;
pub mod macros;
-pub mod string_utils; \ No newline at end of file
+pub mod string_utils;
+pub mod file_system_utils; \ No newline at end of file