@@ -8,52 +8,144 @@ package overlay
88
99#import <Cocoa/Cocoa.h>
1010
11- static NSWindow *overlayWindow = nil;
11+ static NSWindow *ocrWindow = nil;
12+ static NSWindow *inputWindow = nil;
13+ static NSWindow *statusWindow = nil;
14+ static NSTextField *statusLabel = nil;
1215
13- void ShowOverlay(int x, int y, int width, int height) {
16+ // OCR 영역 오버레이 (빨간색)
17+ void ShowOCRRegion(int x, int y, int width, int height) {
1418 dispatch_async(dispatch_get_main_queue(), ^{
15- if (overlayWindow != nil) {
16- [overlayWindow close];
17- overlayWindow = nil;
19+ if (ocrWindow != nil) {
20+ [ocrWindow close];
21+ ocrWindow = nil;
1822 }
1923
2024 NSRect frame = NSMakeRect(x, [[NSScreen mainScreen] frame].size.height - y - height, width, height);
2125
22- overlayWindow = [[NSWindow alloc]
26+ ocrWindow = [[NSWindow alloc]
2327 initWithContentRect:frame
2428 styleMask:NSWindowStyleMaskBorderless
2529 backing:NSBackingStoreBuffered
2630 defer:NO];
2731
28- [overlayWindow setLevel:NSFloatingWindowLevel];
29- [overlayWindow setBackgroundColor:[NSColor clearColor]];
30- [overlayWindow setOpaque:NO];
31- [overlayWindow setIgnoresMouseEvents:YES];
32- [overlayWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
32+ [ocrWindow setLevel:NSFloatingWindowLevel];
33+ [ocrWindow setBackgroundColor:[NSColor clearColor]];
34+ [ocrWindow setOpaque:NO];
35+ [ocrWindow setIgnoresMouseEvents:YES];
36+ [ocrWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
3337
34- // 빨간색 테두리 뷰 생성
3538 NSView *contentView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
3639 contentView.wantsLayer = YES;
3740 contentView.layer.borderColor = [[NSColor redColor] CGColor];
38- contentView.layer.borderWidth = 3 .0;
39- contentView.layer.backgroundColor = [[NSColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.1 ] CGColor];
41+ contentView.layer.borderWidth = 2 .0;
42+ contentView.layer.backgroundColor = [[NSColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.05 ] CGColor];
4043
41- [overlayWindow setContentView:contentView];
42- [overlayWindow makeKeyAndOrderFront:nil];
44+ [ocrWindow setContentView:contentView];
45+ [ocrWindow makeKeyAndOrderFront:nil];
4346 });
4447}
4548
46- void HideOverlay() {
49+ // 입력창 영역 오버레이 (초록색)
50+ void ShowInputRegion(int x, int y, int width, int height) {
4751 dispatch_async(dispatch_get_main_queue(), ^{
48- if (overlayWindow != nil) {
49- [overlayWindow close];
50- overlayWindow = nil;
52+ if (inputWindow != nil) {
53+ [inputWindow close];
54+ inputWindow = nil;
55+ }
56+
57+ NSRect frame = NSMakeRect(x, [[NSScreen mainScreen] frame].size.height - y - height, width, height);
58+
59+ inputWindow = [[NSWindow alloc]
60+ initWithContentRect:frame
61+ styleMask:NSWindowStyleMaskBorderless
62+ backing:NSBackingStoreBuffered
63+ defer:NO];
64+
65+ [inputWindow setLevel:NSFloatingWindowLevel];
66+ [inputWindow setBackgroundColor:[NSColor clearColor]];
67+ [inputWindow setOpaque:NO];
68+ [inputWindow setIgnoresMouseEvents:YES];
69+ [inputWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
70+
71+ NSView *contentView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
72+ contentView.wantsLayer = YES;
73+ contentView.layer.borderColor = [[NSColor greenColor] CGColor];
74+ contentView.layer.borderWidth = 2.0;
75+ contentView.layer.backgroundColor = [[NSColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:0.05] CGColor];
76+
77+ [inputWindow setContentView:contentView];
78+ [inputWindow makeKeyAndOrderFront:nil];
79+ });
80+ }
81+
82+ // 상태 패널 (우측 하단)
83+ void ShowStatusPanel(int x, int y, int width, int height) {
84+ dispatch_async(dispatch_get_main_queue(), ^{
85+ if (statusWindow != nil) {
86+ [statusWindow close];
87+ statusWindow = nil;
88+ statusLabel = nil;
89+ }
90+
91+ NSRect frame = NSMakeRect(x, [[NSScreen mainScreen] frame].size.height - y - height, width, height);
92+
93+ statusWindow = [[NSWindow alloc]
94+ initWithContentRect:frame
95+ styleMask:NSWindowStyleMaskBorderless
96+ backing:NSBackingStoreBuffered
97+ defer:NO];
98+
99+ [statusWindow setLevel:NSFloatingWindowLevel];
100+ [statusWindow setBackgroundColor:[NSColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8]];
101+ [statusWindow setOpaque:NO];
102+ [statusWindow setIgnoresMouseEvents:YES];
103+ [statusWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
104+
105+ statusLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 10, width - 20, height - 20)];
106+ [statusLabel setBezeled:NO];
107+ [statusLabel setDrawsBackground:NO];
108+ [statusLabel setEditable:NO];
109+ [statusLabel setSelectable:NO];
110+ [statusLabel setTextColor:[NSColor whiteColor]];
111+ [statusLabel setFont:[NSFont monospacedSystemFontOfSize:11 weight:NSFontWeightRegular]];
112+ [statusLabel setStringValue:@"🎮 대기 중..."];
113+
114+ [[statusWindow contentView] addSubview:statusLabel];
115+ [statusWindow makeKeyAndOrderFront:nil];
116+ });
117+ }
118+
119+ // 상태 텍스트 업데이트
120+ void UpdateStatus(const char *text) {
121+ NSString *nsText = [NSString stringWithUTF8String:text];
122+ dispatch_async(dispatch_get_main_queue(), ^{
123+ if (statusLabel != nil) {
124+ [statusLabel setStringValue:nsText];
125+ }
126+ });
127+ }
128+
129+ // 모든 오버레이 숨기기
130+ void HideAllOverlays() {
131+ dispatch_async(dispatch_get_main_queue(), ^{
132+ if (ocrWindow != nil) {
133+ [ocrWindow close];
134+ ocrWindow = nil;
135+ }
136+ if (inputWindow != nil) {
137+ [inputWindow close];
138+ inputWindow = nil;
139+ }
140+ if (statusWindow != nil) {
141+ [statusWindow close];
142+ statusWindow = nil;
143+ statusLabel = nil;
51144 }
52145 });
53146}
54147
55148void InitApp() {
56- // NSApplication 초기화 (메인 스레드에서)
57149 dispatch_async(dispatch_get_main_queue(), ^{
58150 [NSApplication sharedApplication];
59151 [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
@@ -62,6 +154,7 @@ void InitApp() {
62154*/
63155import "C"
64156import (
157+ "fmt"
65158 "time"
66159)
67160
@@ -76,17 +169,69 @@ func Init() {
76169 }
77170}
78171
79- // Show OCR 캡처 영역 오버레이 표시
172+ // Show OCR 캡처 영역 오버레이 표시 (하위 호환)
80173func Show (x , y , width , height int ) {
174+ ShowOCRRegion (x , y , width , height )
175+ }
176+
177+ // Hide 오버레이 숨기기 (하위 호환)
178+ func Hide () {
179+ HideAll ()
180+ }
181+
182+ // ShowOCRRegion OCR 영역 표시 (빨간색)
183+ func ShowOCRRegion (x , y , width , height int ) {
81184 if ! initialized {
82185 Init ()
83186 }
84- C .ShowOverlay (C .int (x ), C .int (y ), C .int (width ), C .int (height ))
187+ C .ShowOCRRegion (C .int (x ), C .int (y ), C .int (width ), C .int (height ))
85188}
86189
87- // Hide 오버레이 숨기기
88- func Hide () {
89- C .HideOverlay ()
190+ // ShowInputRegion 입력창 영역 표시 (초록색)
191+ func ShowInputRegion (x , y , width , height int ) {
192+ if ! initialized {
193+ Init ()
194+ }
195+ C .ShowInputRegion (C .int (x ), C .int (y ), C .int (width ), C .int (height ))
196+ }
197+
198+ // ShowStatusPanel 상태 패널 표시
199+ func ShowStatusPanel (x , y , width , height int ) {
200+ if ! initialized {
201+ Init ()
202+ }
203+ C .ShowStatusPanel (C .int (x ), C .int (y ), C .int (width ), C .int (height ))
204+ }
205+
206+ // ShowAll 모든 오버레이 표시 (OCR 영역, 입력창 영역, 상태 패널)
207+ func ShowAll (ocrX , ocrY , ocrW , ocrH , inputX , inputY , inputW , inputH int ) {
208+ if ! initialized {
209+ Init ()
210+ }
211+
212+ // OCR 영역 (빨간색)
213+ ShowOCRRegion (ocrX , ocrY , ocrW , ocrH )
214+
215+ // 입력창 영역 (초록색)
216+ ShowInputRegion (inputX , inputY , inputW , inputH )
217+
218+ // 상태 패널 (OCR 영역 오른쪽)
219+ statusX := ocrX + ocrW + 10
220+ statusY := ocrY
221+ statusW := 280
222+ statusH := 150
223+ ShowStatusPanel (statusX , statusY , statusW , statusH )
224+ }
225+
226+ // UpdateStatus 상태 텍스트 업데이트
227+ func UpdateStatus (format string , args ... interface {}) {
228+ text := fmt .Sprintf (format , args ... )
229+ C .UpdateStatus (C .CString (text ))
230+ }
231+
232+ // HideAll 모든 오버레이 숨기기
233+ func HideAll () {
234+ C .HideAllOverlays ()
90235}
91236
92237// ShowForDuration 지정 시간 동안 오버레이 표시
0 commit comments