|
1 | 1 | use crate::sys::{runlua::runLua, statics::*}; |
2 | | -use std::path::Path; |
| 2 | +use std::{path::Path, io::Read}; |
3 | 3 |
|
4 | 4 | pub(crate) fn try_process_input() -> std::io::Result<()> { |
5 | 5 | // Loop forever in this thread, since it is separate from Gmod, and take in user input. |
@@ -40,15 +40,50 @@ pub(crate) fn try_process_input() -> std::io::Result<()> { |
40 | 40 | } |
41 | 41 | }, |
42 | 42 |
|
| 43 | + "hide" => unsafe { |
| 44 | + use std::sync::atomic::{AtomicPtr, Ordering}; |
| 45 | + use winapi::um::{ |
| 46 | + wincon::GetConsoleWindow, |
| 47 | + winuser::{ShowWindow, SW_HIDE, SW_SHOW}, |
| 48 | + }; |
| 49 | + |
| 50 | + let wind = GetConsoleWindow(); |
| 51 | + ShowWindow(wind, SW_HIDE); |
| 52 | + |
| 53 | + let mut tray = systrayx::Application::new().unwrap(); |
| 54 | + tray.set_icon_from_buffer( |
| 55 | + &include_bytes!("../assets/run.ico")[..], |
| 56 | + 32, |
| 57 | + 32 |
| 58 | + ).expect("Failed to set icon"); |
| 59 | + |
| 60 | + let ptr = AtomicPtr::new(wind); |
| 61 | + |
| 62 | + tray.add_menu_item("Open", move |x| { |
| 63 | + let a = ptr.load(Ordering::Relaxed); |
| 64 | + ShowWindow(a, SW_SHOW); |
| 65 | + |
| 66 | + x.quit(); |
| 67 | + Ok::<_, systrayx::Error>(()) |
| 68 | + }) |
| 69 | + .unwrap(); |
| 70 | + |
| 71 | + tray.wait_for_message().unwrap(); |
| 72 | + }, |
| 73 | + |
43 | 74 | "help" => { |
44 | | - println!("Commands list:"); |
45 | | - println!("lua_run_cl <code> | Runs lua code on the currently loaded lua state. Will print if any errors occur."); |
46 | | - println!("lua_openscript_cl <file_dir> | Runs a lua script located at file_dir, this dir being an absolute directory on your pc. (Not relative)"); |
| 75 | + indoc::printdoc! {" |
| 76 | + [Commands] |
| 77 | +
|
| 78 | + lua_run_cl <code> | Runs lua code on the currently loaded lua state. Will print if any errors occur. |
| 79 | + lua_openscript_cl <file_dir> | Runs a lua script located at file_dir, this dir being an absolute directory on your pc. (Not relative) |
47 | 80 |
|
48 | | - println!("lua_run_menu <code> | Runs lua code in the menu state. Will print if any errors occur."); |
49 | | - println!("lua_openscript_menu <code> | Runs lua code in the menu state. Will print if any errors occur."); |
| 81 | + lua_run_menu <code> | Runs lua code in the menu state. Will print if any errors occur. |
| 82 | + lua_openscript_menu <code> | Runs lua code in the menu state. Will print if any errors occur. |
50 | 83 |
|
51 | | - println!("help | Prints this out."); |
| 84 | + help | Prints this out. |
| 85 | + hide | Hides the console, but remains active. |
| 86 | + "}; |
52 | 87 | } |
53 | 88 | _ => (), |
54 | 89 | } |
|
0 commit comments