diff --git a/EVE-X-Preview.json b/EVE-X-Preview.json index a90f2ad..5032029 100644 --- a/EVE-X-Preview.json +++ b/EVE-X-Preview.json @@ -269,6 +269,10 @@ }, "global_Settings":{ "CharScreenHotkey":"", + "CharacterNameOverlayPosition":{ + "x":1075, + "y":7 + }, "DisableLiveThumbnail":1, "Exclude_Character_Hotkey":"", "Global_Hotkeys":1, diff --git a/Lib/DefaultJSON.ahk b/Lib/DefaultJSON.ahk index 9274d57..59abe69 100644 --- a/Lib/DefaultJSON.ahk +++ b/Lib/DefaultJSON.ahk @@ -21,6 +21,10 @@ "ThumbnailMinimumSize": { "width": 50, "height": 50 + }, + "CharacterNameOverlayPosition": { + "x": 0, + "y": 20 } }, "_Profiles": { diff --git a/src/Main_Class.ahk b/src/Main_Class.ahk index 8837e6e..d9ba5c1 100644 --- a/src/Main_Class.ahk +++ b/src/Main_Class.ahk @@ -47,6 +47,13 @@ AutoForwardTimer := 0 ; Timer reference for TriggerAutoForward AutoForwardRunning := false ; Flag to prevent re-entrancy AutoForwardTimerPending := false ; Flag to prevent multiple timers from being scheduled + CharacterNameOverlay := 0 ; GUI overlay for displaying current character name + CharacterNameOverlayLastText := "" ; Track last displayed text to prevent flashing + CharacterNameOverlayX := 0 ; Stored X position for dragging + CharacterNameOverlayY := 0 ; Stored Y position for dragging + CharacterNameOverlayDragging := false ; Flag for drag state + CharacterNameOverlayOffsetX := 0 ; Drag offset X + CharacterNameOverlayOffsetY := 0 ; Drag offset Y __New() { @@ -101,6 +108,7 @@ ;The Main Timer who checks for new EVE Windows or closes Windows SetTimer(ObjBindMethod(This, "HandleMainTimer"), 50) + SetTimer(ObjBindMethod(This, "UpdateCharacterNameOverlay"), 500) This.Save_Settings_Delay_Timer := ObjBindMethod(This, "SaveJsonToFile") ;Timer property to remove Thumbnails for closed EVE windows This.DestroyThumbnails := ObjBindMethod(This, "EvEWindowDestroy") @@ -110,9 +118,120 @@ This.Register_Hotkey_Groups() This.BorderActive := 0 This.ClientsInCharScreen := Map() + + ; Create character name overlay + This.CreateCharacterNameOverlay() return This } + + CreateCharacterNameOverlay() { + This.CharacterNameOverlay := Gui("+LastFound -Caption +ToolWindow AlwaysOnTop -SysMenu", "CharacterNameOverlay") + This.CharacterNameOverlay.BackColor := "040101" + This.CharacterNameOverlay.MarginX := 20 + This.CharacterNameOverlay.MarginY := 10 + This.CharacterNameOverlay.SetFont("s24 w700 cFFFFFF", "Arial") + nameCtrl := This.CharacterNameOverlay.Add("Text", "vCharacterNameText w300 Center", "") + nameCtrl.Opt("+Background040101") + nameCtrl.OnEvent("Click", ObjBindMethod(This, "CharacterNameOverlay_Drag")) + This.CharacterNameOverlay.SetFont("s14 w400 cAAAAAA", "Arial") + hotkeyCtrl := This.CharacterNameOverlay.Add("Text", "vCharacterHotkeyText w300 Center", "") + hotkeyCtrl.Opt("+Background040101") + hotkeyCtrl.OnEvent("Click", ObjBindMethod(This, "CharacterNameOverlay_Drag")) + WinSetTransColor("040101", This.CharacterNameOverlay.Hwnd) + This.CharacterNameOverlayX := This.CharacterNameOverlayPosition["x"] ? This.CharacterNameOverlayPosition["x"] : A_ScreenWidth - 340 + This.CharacterNameOverlayY := This.CharacterNameOverlayPosition["y"] ? This.CharacterNameOverlayPosition["y"] : 20 + SetTimer(ObjBindMethod(This, "CharacterNameOverlay_CheckDrag"), 10) + } + + UpdateCharacterNameOverlay() { + if (!This.CharacterNameOverlay) + return + + try { + if (WinActive(This.EVEExe)) { + activeTitle := This.CleanTitle(WinGetTitle("A")) + if (activeTitle != "" && activeTitle != This.CharacterNameOverlayLastText) { + This.CharacterNameOverlayLastText := activeTitle + This.CharacterNameOverlay["CharacterNameText"].Text := activeTitle + + hotkeyText := "" + hotkeyValue := This._Hotkeys[activeTitle] + if (hotkeyValue && hotkeyValue != "" && hotkeyValue != 0) { + hotkeyText := hotkeyValue + } + This.CharacterNameOverlay["CharacterHotkeyText"].Text := hotkeyText + + This.CharacterNameOverlay.Show("w340 NoActivate") + if (This.CharacterNameOverlayX = 0) + This.CharacterNameOverlayX := A_ScreenWidth - 340 + WinMove(This.CharacterNameOverlayX, This.CharacterNameOverlayY, , , This.CharacterNameOverlay.Hwnd) + if (!GetKeyState("LButton", "P")) + WinSetExStyle("+0x20", This.CharacterNameOverlay.Hwnd) + return + } + } else if (This.CharacterNameOverlayLastText != "") { + This.CharacterNameOverlayLastText := "" + This.CharacterNameOverlay.Show("Hide") + } + } catch { + } + } + + CharacterNameOverlay_CheckDrag() { + if (!This.CharacterNameOverlay) + return + + if (!WinExist("ahk_id " This.CharacterNameOverlay.Hwnd)) + return + + MouseGetPos(&mx, &my) + WinGetPos(&wx, &wy, &ww, &wh, This.CharacterNameOverlay.Hwnd) + + if (mx >= wx && mx <= wx + ww && my >= wy && my <= wy + wh) { + if (GetKeyState("LButton", "P")) { + WinSetExStyle("-0x20", This.CharacterNameOverlay.Hwnd) + if (!This.CharacterNameOverlayDragging) { + This.CharacterNameOverlayDragging := true + CoordMode("Mouse", "Screen") + MouseGetPos(&startX, &startY) + WinGetPos(&winX, &winY, , , This.CharacterNameOverlay.Hwnd) + This.CharacterNameOverlayOffsetX := startX - winX + This.CharacterNameOverlayOffsetY := startY - winY + } + + MouseGetPos(¤tX, ¤tY) + newX := currentX - This.CharacterNameOverlayOffsetX + newY := currentY - This.CharacterNameOverlayOffsetY + if (newX < 0) + newX := 0 + if (newY < 0) + newY := 0 + if (newX + 340 > A_ScreenWidth) + newX := A_ScreenWidth - 340 + WinMove(newX, newY, , , This.CharacterNameOverlay.Hwnd) + This.CharacterNameOverlayX := newX + This.CharacterNameOverlayY := newY + This.CharacterNameOverlayPosition["x"] := newX + This.CharacterNameOverlayPosition["y"] := newY + SetTimer(This.Save_Settings_Delay_Timer, -200) + } else { + if (This.CharacterNameOverlayDragging) { + This.CharacterNameOverlayDragging := false + WinSetExStyle("+0x20", This.CharacterNameOverlay.Hwnd) + } + } + } else { + if (This.CharacterNameOverlayDragging && !GetKeyState("LButton", "P")) { + This.CharacterNameOverlayDragging := false + WinSetExStyle("+0x20", This.CharacterNameOverlay.Hwnd) + } + } + } + + CharacterNameOverlay_Drag(*) { + ; Handler for click events - but we use timer-based dragging instead + } HandleMainTimer() { static HideShowToggle := 0, WinList := {} @@ -166,6 +285,7 @@ if ((DllCall("IsIconic","UInt", WinActive("ahk_exe exefile.exe")) || ActiveProcessName != "exefile.exe") && !HideShowToggle && This.HideThumbnailsOnLostFocus) { SetTimer(This.CheckforActiveWindow, -500) HideShowToggle := 1 + This.UpdateCharacterNameOverlay() } else if ( ActiveProcessName = "exefile.exe" && !DllCall("IsIconic","UInt", WinActive("ahk_exe exefile.exe"))) { Ahwnd := WinExist("A") @@ -185,7 +305,6 @@ This.ShowActiveBorder(Ahwnd) This.UpdateThumb_AfterActivation(, Ahwnd) This.BorderActive := Ahwnd - } } } diff --git a/src/Propertys.ahk b/src/Propertys.ahk index 6072a03..ba50b04 100644 --- a/src/Propertys.ahk +++ b/src/Propertys.ahk @@ -89,6 +89,11 @@ class Propertys extends TrayMenu { set => This._JSON["global_Settings"]["ThumbnailMinimumSize"][key] := value } + CharacterNameOverlayPosition[key] { + get => This._JSON["global_Settings"]["CharacterNameOverlayPosition"][key] + set => This._JSON["global_Settings"]["CharacterNameOverlayPosition"][key] := value + } + ;######################## ;## Profile ThumbnailSettings