diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..618090a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +EVE-X-Preview.json diff --git a/Lib/DefaultJSON.ahk b/Lib/DefaultJSON.ahk index 19da04b..0005640 100644 --- a/Lib/DefaultJSON.ahk +++ b/Lib/DefaultJSON.ahk @@ -2,6 +2,8 @@ ( { "global_Settings": { + "CharScreenHotkey":"", + "DisableLiveThumbnail": 0, "Suspend_Hotkeys_Hotkey": "", "Global_Hotkeys": 1, "LastUsedProfile": "Default", diff --git a/Main.ahk b/Main.ahk index 4d7d95d..302d2f2 100644 --- a/Main.ahk +++ b/Main.ahk @@ -26,7 +26,7 @@ A_MaxHotKeysPerInterval := 10000 TODO ######################### */ -;@Ahk2Exe-Let U_version = 1.0.4. +;@Ahk2Exe-Let U_version = 1.0.5. ;@Ahk2Exe-SetVersion %U_version% ;@Ahk2Exe-SetFileVersion %U_version% ;@Ahk2Exe-SetCopyright gonzo83 @@ -45,12 +45,11 @@ if !(A_IsCompiled) TraySetIcon("icon.ico",,true) ; Catch all unhandled Errors to prevent the Script from stopping -OnError(Error_Handler) + +;OnError(Error_Handler) Call := Main_Class() - - Load_JSON() { DJSON := JSON.Load(default_JSON) if !(FileExist("EVE-X-Preview.json")) { @@ -60,10 +59,6 @@ Load_JSON() { } else { Try { - if (FileExist("EVE-X-Preview.json")) { - ;if needed because of Backward combativity from the alpha versions - MergeJson() - } _JSON := JsonMergeNoOverwrite( DJSON, JSON.Load(FileRead("EVE-X-Preview.json")) @@ -97,57 +92,6 @@ JsonMergeNoOverwrite(obj1, obj2) { return obj2 } - -;THis function is only used to merge the Json from old versions into the new one -MergeJson(Settingsfile := "EVE-X-Preview.json", dJson := JSON.Load(default_JSON)) { - ;Load the content from the existing Json File - fileObj := FileOpen(Settingsfile,"r", "Utf-8") - JsonRaw := fileObj.Read(), fileObj.Close() - OldJson := JSON.Load(JsonRaw) - savetofile := 0 - - - for Profiles, settings in OldJson["_Profiles"] { - if (Profiles = "Default") { - continue - } - dJson["_Profiles"][Profiles] := Map() - for k, v in settings { - if (OldJson["_Profiles"][Profiles].Has("ClientPossitions")) { - savetofile := 1 - if (k = "ClientPossitions") - dJson["_Profiles"][Profiles]["Client Possitions"] := v - else if (k = "ClientSettings") - dJson["_Profiles"][Profiles]["Client Settings"] := v - else if (k = "ThumbnailSettings") - dJson["_Profiles"][Profiles]["Thumbnail Settings"] := v - else if (k = "ThumbnailPositions") - dJson["_Profiles"][Profiles]["Thumbnail Positions"] := v - else if (k = "Thumbnail_visibility") - dJson["_Profiles"][Profiles]["Thumbnail Visibility"] := v - else if (k = "Custom_Colors") - dJson["_Profiles"][Profiles]["Custom Colors"] := dJson["_Profiles"]["Default"]["Custom Colors"] - else if (k = "Hotkey_Groups") - dJson["_Profiles"][Profiles]["Hotkey Groups"] := v - else if (k = "Hotkeys") { - if (Type(v) = "Map") { - Arr := [] - for char, hotkey in v - Arr.Push(Map(char, hotkey)) - dJson["_Profiles"][Profiles]["Hotkeys"] := Arr - } - } - } - } - } - if savetofile { - dJson["global_Settings"] := OldJson["global_Settings"] - - fileObj := FileOpen(Settingsfile,"w", "Utf-8") - fileObj.Write(JSON.Dump(dJson,, " ")), fileObj.Close() - } -} - ; Hanles unmanaged Errors Error_Handler(Thrown, Mode) { return -1 diff --git a/src/Main_Class.ahk b/src/Main_Class.ahk index 059f34f..2ebb31b 100644 --- a/src/Main_Class.ahk +++ b/src/Main_Class.ahk @@ -68,6 +68,7 @@ Class Main_Class extends ThumbWindow { ; The Timer property for Asycn Minimizing. this.timer := ObjBindMethod(this, "EVEMinimize") + This.Register_CharSelectionScreen_Hotkeys() ;margins for DwmExtendFrameIntoClientArea. higher values extends the shadow This.margins := Buffer(16, 0) @@ -90,6 +91,7 @@ Class Main_Class extends ThumbWindow { ;Register the Hotkeys for cycle groups This.Register_Hotkey_Groups() This.BorderActive := 0 + This.ClientsInCharScreen := Map() return This } @@ -102,26 +104,42 @@ Class Main_Class extends ThumbWindow { return ; If any EVE Window exist if (WinList.Length) { - try { - ;Check if a window exist without Thumbnail and if the user is in Character selection screen or not - for index, hwnd in WinList { - WinList.%hwnd% := { Title: This.CleanTitle(WinGetTitle(hwnd)) } - if !This.ThumbWindows.HasProp(hwnd) { - This.EVE_WIN_Created(hwnd, WinList.%hwnd%.title) - if (!This.HideThumbnailsOnLostFocus) - This.ShowThumb(hwnd, "Show") - HideShowToggle := 1 - } - ;if in Character selection screen - else if (This.ThumbWindows.HasProp(hwnd)) { - if (This.ThumbWindows.%hwnd%["Window"].Title != WinList.%hwnd%.Title) { - This.EVENameChange(hwnd, WinList.%hwnd%.Title) - } - } + ;Check if a window exist without Thumbnail and if the user is in Character selection screen or not + for index, hwnd in WinList { + WinList.%hwnd% := { Title: This.CleanTitle(WinGetTitle(hwnd)) } + + if (WinList.%hwnd%.Title == "") { + This.ClientsInCharScreen[hwnd] := WinList.%hwnd%.Title + } + ;if the User disables the Thumbnails we can skip all the code below this + if (This.DisableLiveThumbnail) { + This.DisableLiveThumb(hwnd, WinList.%hwnd%.Title, WinList) + continue + } + + if !This.ThumbWindows.HasProp(hwnd) { + This.EVE_WIN_Created(hwnd, WinList.%hwnd%.title) + if (!This.HideThumbnailsOnLostFocus) + This.ShowThumb(hwnd, "Show") + HideShowToggle := 1 + } + ;if in Character selection screen + else if (This.ThumbWindows.HasProp(hwnd)) { + if (This.ThumbWindows.%hwnd%["Window"].Title != WinList.%hwnd%.Title && WinList.%hwnd%.Title = "") { + This.ThumbWindows.%hwnd%["Window"].Title := "Char Screen" + ;This.ThumbWindows.%hwnd%["TextOverlay"]["OverlayText"].value := "Char Screen" + if (This.ThumbWindows.%hwnd%["Window"].Title == "Char Screen" && WinList.%hwnd%.Title != "") { + This.EVENameChange(hwnd, WinList.%hwnd%.Title) + } + } + else if (This.ThumbWindows.%hwnd%["Window"].Title != WinList.%hwnd%.Title) { + This.EVENameChange(hwnd, WinList.%hwnd%.Title) + } + + } } - catch - return + try { ;if HideThumbnailsOnLostFocus is selectet check if a eve window is still in foreground, runs a timer once with a delay to prevent stuck thumbnails @@ -214,6 +232,52 @@ Class Main_Class extends ThumbWindow { } } + Register_CharSelectionScreen_Hotkeys(){ + if (This.CharScreenHotkey != "" ) { + HotIf (*) => WinExist("ahk_exe " This.EVEExe) + try { + Hotkey(This.CharScreenHotkey, ObjBindMethod(This, "CycleCharScreen"),"P1" ) + } + } + } + + CycleCharScreen(*){ + static Index := 1 + Arr := [] + list := "" + + WinList := WinGetList(This.EVEExe) + if (WinList != "") { + for index, hwnd in WinList { + if (This.CleanTitle(WinGetTitle(hwnd)) = "") + Arr.Push(hwnd) + } + + if (Arr.Length >= 1 ) { + for i, hwnds in Arr { + list .= hwnds "," + } + list := Sort(list, "N D,") + Arr := StrSplit(list, ",") + Arr.Pop() + + for i, hwnds in Arr { + index := i + if (WinActive("ahk_id " hwnds)) { + index := i + 1 + if (index > Arr.Length) + index := 1 + break + } + else { + index := 1 + } + } + This.ActivateEVEWindow(Arr[index],,) + } + } + } + ;Register the Hotkeys for cycle Groups if any set Register_Hotkey_Groups() { static Fkey := "", BKey := "", Arr := [] @@ -321,6 +385,18 @@ Class Main_Class extends ThumbWindow { return false } } + DisableLiveThumb(hwnd, title, arr) { + for hwnds, name in This.ThumbWindows.Clone().OwnProps() { + if (!arr.HasProp(hwnds)) { + This.ThumbWindows.DeleteProp(hwnds) + } + } + + if !(This.ThumbWindows.HasProp(hwnd)) { + This.ThumbWindows.%hwnd% := "" + This.RegisterHotkeys(title, hwnd) + } + } ; To Check if atleast One Win stil Exist in the Array for the cycle groups hotkeys OnWinExist(Arr, *) { @@ -551,7 +627,7 @@ Class Main_Class extends ThumbWindow { ; gets called by the timer to run async EVEMinimize() { for EveHwnd, GuiObj in This.ThumbWindows.OwnProps() { - ThumbHwnd := GuiObj["Window"].Hwnd + ;ThumbHwnd := GuiObj["Window"].Hwnd try WinTitle := WinGetTitle("Ahk_Id " EveHwnd) catch diff --git a/src/Propertys.ahk b/src/Propertys.ahk index bc20319..27ccfc2 100644 --- a/src/Propertys.ahk +++ b/src/Propertys.ahk @@ -33,11 +33,19 @@ class Propertys extends TrayMenu { ;###################### ;## global Settings + + CharScreenHotkey { + get => This._JSON["global_Settings"]["CharScreenHotkey"] + set => This._JSON["global_Settings"]["CharScreenHotkey"] := value + } + DisableLiveThumbnail { + get => This._JSON["global_Settings"]["DisableLiveThumbnail"] + set => This._JSON["global_Settings"]["DisableLiveThumbnail"] := value + } + ThumbnailStartLocation[key] { get => This._JSON["global_Settings"]["ThumbnailStartLocation"][key] set => This._JSON["global_Settings"]["ThumbnailStartLocation"][key] := value - - } Minimizeclients_Delay { diff --git a/src/Settings_Gui.ahk b/src/Settings_Gui.ahk index c82f0d1..975bbf0 100644 --- a/src/Settings_Gui.ahk +++ b/src/Settings_Gui.ahk @@ -108,8 +108,9 @@ Global_Settings(visible?) { This.S_Gui.Controls.Global_Settings := [] This.S_Gui.SetFont("s10 w400") - This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("GroupBox", "x20 y80 h280 w500") + This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("GroupBox", "x20 y80 h340 w500") This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xp+15 yp+20 Section", "Suspend Hotkeys - Hotkey:") + This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xs y+20 Section", "Char selection Screen- Hotkey:") This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xs y+15", "Hotkey activation Scope:") This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xs y+15", "Thumbnail Background Color:") This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xs y+15", "Thumbnail Default Location:") @@ -117,9 +118,13 @@ This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xs y+15", "Thumbnail Snap:") This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xs y+15", "Thumbnail Snap Distance:") This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xs y+15", "Minimize EVE Window Delay:") + This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Text", "xs y+15", "Disable Live Thumbnail") + - This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Edit", "xs+230 ys-3 w150 Section vSuspend_Hotkeys_Hotkey", This.Suspend_Hotkeys_Hotkey) + This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Edit", "xs+230 ys-37 w150 Section vSuspend_Hotkeys_Hotkey", This.Suspend_Hotkeys_Hotkey) This.S_Gui["Suspend_Hotkeys_Hotkey"].OnEvent("Change", (obj, *) => gSettings_EventHandler(obj)) + This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Edit", "xp y+10 w150 Section vCharScreenHotkey", This.CharScreenHotkey) + This.S_Gui["CharScreenHotkey"].OnEvent("Change", (obj, *) => gSettings_EventHandler(obj)) This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("DDL", "xp y+5 w180 vTTT vHotkey_Scoope Choose" (This.Global_Hotkeys ? 1 : 2), ["Global", "If an EVE window is Active"]) This.S_Gui["Hotkey_Scoope"].OnEvent("Change", (obj, *) => gSettings_EventHandler(obj)) @@ -164,6 +169,9 @@ This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("Edit", "xp+80 yp-3 w40 vMinimizeclients_Delay", This.Minimizeclients_Delay) This.S_Gui["Minimizeclients_Delay"].OnEvent("Change", (obj, *) => gSettings_EventHandler(obj)) + This.S_Gui.Controls.Global_Settings.Push This.S_Gui.Add("CheckBox", "xs y+10 vDisableLiveThumbnail Checked" This.DisableLiveThumbnail) + This.S_Gui["DisableLiveThumbnail"].OnEvent("Click", (obj, *) => gSettings_EventHandler(obj)) + gSettings_EventHandler(obj) { if (obj.name = "Suspend_Hotkeys_Hotkey") { This.Suspend_Hotkeys_Hotkey := Trim(obj.value, "`n ") @@ -208,6 +216,14 @@ This.Minimizeclients_Delay := obj.value This.NeedRestart := 1 } + else if (obj.name = "DisableLiveThumbnail") { + This.DisableLiveThumbnail := obj.value + This.NeedRestart := 1 + } + else if (obj.name = "CharScreenHotkey") { + This.CharScreenHotkey := obj.value + This.NeedRestart := 1 + } SetTimer(This.Save_Settings_Delay_Timer, -200) } }