-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogle Map Maker Building.ahk
536 lines (442 loc) · 9.92 KB
/
Google Map Maker Building.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
#include fileio.ahk
#include gdip_routines.ahk
degrees(deg)
{
return deg*0.0174532925
}
StrSplit(ByRef text, delimiter := "", omitChars := "")
{
ret := []
Loop, Parse, text, % delimiter, % omitChars
ret.Insert(A_LoopField)
return ret
}
Gdip_Startup()
CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
Gui, 99: +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 99: Show
Gui, 2: Add, Text,, Numele fisierului
Gui, 2: Add, Edit, w150 vFile
Gui, 2: Add, Text,, Lista coordonate (x1,y1 x2,y2 ... xn,yn)
Gui, 2: Add, Edit, w400 h200 vCoords
Gui, 2: Add, Button, w100 x310, Trimite
Gui, 3: Add, DropDownList, vFirstShapePoint w100
Gui, 3: Add, DropDownList, vSecondShapePoint w100 xp+110
Gui, 3: Add, Button, xp+110 w30, OK
Gui, 3: Add, Text, xm, Primul bloc
Gui, 3: Add, Text, xp+110 yp, Al doilea bloc
Width := A_ScreenWidth,
Height := A_ScreenHeight,
hwnd1 := WinExist(),
Canvas := 0,
pBitmapDraw_%Canvas% := Gdip_CreateBitmap(Width, Height),
GDrawplus_%Canvas% := Gdip_GraphicsFromImage(pBitmapDraw_%Canvas%),
Gdip_SetSmoothingMode(GDrawplus_%Canvas%, 4),
hbmDraw_%Canvas% := CreateDIBSection(Width, Height),
hdcDraw_%Canvas% := CreateCompatibleDC(),
obmDraw_%Canvas% := SelectObject(hdcDraw_%Canvas%, hbmDraw_%Canvas%),
GDraw_%Canvas% := Gdip_GraphicsFromHDC(hdcDraw_%Canvas%)
bPen := Gdip_CreatePen(0xffff0000, 2)
redesenare(puncte)
{
Global
Gdip_GraphicsClear(GDraw_%Canvas%)
numar := puncte.MaxIndex()
repetari := numar - 1
Loop, %repetari%
{
Gdip_DrawLine(GDraw_0, bPen, puncte[a_index][1], puncte[a_index][2], puncte[a_index+1][1], puncte[a_index+1][2])
}
Gdip_DrawLine(GDraw_0, bPen, puncte[1][1], puncte[1][2], puncte[numar][1], puncte[numar][2])
UpdateLayeredWindow(hwnd1, hdcDraw_0, 0, 0, Width, Height)
}
startX := (Width / 2) + 100
startY := (Height / 3)
mutareBloc := 5 ;in pixeli
rotireBloc := 0.5 ;in grade
SetWorkingDir %A_ScriptDir%
Load_All(shapes, files)
numar_blocuri := shapes.MaxIndex()
IfExist, session.ini
{
IniRead, currentX, session.ini, CurrentSession, currentX
IniRead, currentY, session.ini, CurrentSession, currentY
IniRead, isFlipH, session.ini, CurrentSession, isFlipH
IniRead, isFlipV, session.ini, CurrentSession, isFlipV
IniRead, unghi_total, session.ini, CurrentSession, unghiTotal
IniRead, numar_bloc_curent, session.ini, CurrentSession, shapeID
} Else {
IniWrite, 1, session.ini, CurrentSession, shapeID
IniWrite, 0, session.ini, CurrentSession, unghiTotal
IniWrite, 0, session.ini, CurrentSession, isFlipH
IniWrite, 0, session.ini, CurrentSession, isFlipV
IniWrite, %startX%, session.ini, CurrentSession, currentX
IniWrite, %startY%, session.ini, CurrentSession, currentY
currentX := startX
currentY := startY
numar_bloc_curent := 1
unghi_total := 0
}
selectareBloc(numar_bloc_curent)
If (isFlipH)
{
flipHorizontal()
}
If (isFlipV)
{
flipVertical()
}
calculareCentru()
redesenare(bloc)
calculareCentru()
{
Global
minX := maxX := bloc[1][1]
minY := maxY := bloc[1][2]
Loop, %numar_puncte%
{
if (bloc[a_index][1] < minX)
minX := bloc[a_index][1]
if (bloc[a_index][1] > maxX)
maxX := bloc[a_index][1]
if (bloc[a_index][2] < minY)
minY := bloc[a_index][2]
if (bloc[a_index][2] > maxY)
maxY := bloc[a_index][2]
}
cx := minX + ((maxX - minX) / 2)
cy := minY + ((maxY - minY) / 2)
}
rotireBloc(unghi)
{
Global
Loop, %numar_puncte%
{
s := sin(unghi)
c := cos(unghi)
bloc[a_index][1] := bloc[a_index][1] - cx
bloc[a_index][2] := bloc[a_index][2] - cy
xnew := bloc[a_index][1] * c - bloc[a_index][2] * s
ynew := bloc[a_index][1] * s + bloc[a_index][2] * c
bloc[a_index][1] := xnew + cx
bloc[a_index][2] := ynew + cy
IniWrite, %unghi_total%, session.ini, CurrentSession, unghiTotal
}
return
}
selectareBloc(numar_bloc)
{
Global
numar_puncte := shapes[numar_bloc].MaxIndex()
bloc := shapes[numar_bloc].clone()
IfWinExist, Lipire blocuri
{
List3 := "|"
Loop, %numar_puncte%
{
bloc[a_index] := shapes[numar_bloc][a_index].clone()
List3 .= a_index . "|"
}
GuiControl, 3:, SecondShapePoint, %List3%
GuiControl, 3: Choose, SecondShapePoint, 1
} Else {
Loop, %numar_puncte%
{
bloc[a_index] := shapes[numar_bloc][a_index].clone()
}
}
Loop, %numar_puncte%
{
bloc[a_index][1] := bloc[a_index][1] + currentX
bloc[a_index][2] := bloc[a_index][2] + currentY
}
calculareCentru()
rotireBloc(unghi_total)
IniWrite, %numar_bloc%, session.ini, CurrentSession, shapeID
ToolTip, % files[numar_bloc], currentX+50, currentY+50
SetTimer, RemoveToolTip, 500
return
}
repozitionare(x, y)
{
Global
Loop, %numar_puncte%
{
bloc[a_index][1] := bloc[a_index][1] + x
bloc[a_index][2] := bloc[a_index][2] + y
}
redesenare(bloc)
calculareCentru()
}
flipHorizontal()
{
Global
calculareCentru()
Loop, %numar_puncte%
{
bloc[a_index][1] := maxX - bloc[a_index][1] + currentX
}
calculareCentru()
}
flipVertical()
{
Global
calculareCentru()
Loop, %numar_puncte%
{
bloc[a_index][2] := maxY - bloc[a_index][2] + currentY
}
calculareCentru()
}
A::
{
Gui, 99:Hide
2ButtonTrimite:
KeyWait,a
IfWinExist, Adauga forma bloc
{
Gui, 2:Hide
Gui, 2:Submit
If !ErrorLevel AND File AND Coords
{
shapes[numar_blocuri+1] := Array()
Loop, parse, Coords, `|
{
shapes[numar_blocuri+1][a_index] := StrSplit(A_LoopField, ",").clone()
}
numar_blocuri += 1
files[numar_blocuri] := File
Save_Shape(shapes[numar_blocuri], "shapes\" . files[numar_blocuri] . ".txt")
selectareBloc(numar_blocuri)
GuiControl,,Coords,
GuiControl,,File,
Gui, 99:Show
} Else {
MsgBox, Toate campurile sunt obligatorii
Gui, 2:Show
}
}
Else
{
Gui, 2: Show, Center, Adauga forma bloc
}
Return
}
Q::
{
if (beforeShape != "")
{
List1 := "|"
List2 := "|"
numar_puncte_before := beforeShape.MaxIndex()
Loop, %numar_puncte_before%
List1 .= A_Index . "|"
Loop, %numar_puncte%
List2 .= A_Index . "|"
GuiControl, 3:, FirstShapePoint, %List1%
GuiControl, 3:, SecondShapePoint, %List2%
GuiControl, 3: Choose, FirstShapePoint, 1
GuiControl, 3: Choose, SecondShapePoint, 1
Gui, 3: Show, Center, Lipire blocuri
Return
} else {
MsgBox, Mai intai trebuie sa desenati un bloc
}
3ButtonOK:
{
Gui, 3:Submit
If !ErrorLevel AND FirstShapePoint AND SecondShapePoint
{
moveX := currentX + ((beforeShape[FirstShapePoint][1] - bloc[SecondShapePoint][1]) * -1)
moveY := currentY + ((beforeShape[FirstShapePoint][2] - bloc[SecondShapePoint][2]) * -1)
MouseMove, currentX, currentY
MouseClickDrag, L, currentX, currentY, moveX, moveY, 50
Sleep, 500
;msgbox, % moveX . " x " . moveY
}
Return
}
Return
}
NumpadAdd::
{
unghi := degrees(rotireBloc)
unghi_total := unghi_total + unghi
rotireBloc(unghi)
redesenare(bloc)
Return
}
NumpadSub::
{
unghi := degrees(rotireBloc)*-1
unghi_total := unghi_total + unghi
rotireBloc(unghi)
redesenare(bloc)
Return
}
Up::
Left::
Down::
Right::
{
If ((GetKeyState("Up", "P") AND GetKeyState("Left", "P")))
{
currentX += mutareBloc*-1
currentY -= mutareBloc
repozitionare(mutareBloc*-1, mutareBloc*-1)
}
Else If ((GetKeyState("Up", "P") AND GetKeyState("RIGHT", "P")))
{
currentX += mutareBloc
currentY -= mutareBloc
repozitionare(mutareBloc, mutareBloc*-1)
}
Else If ((GetKeyState("DOWN", "P") AND GetKeyState("LEFT", "P")))
{
currentX += mutareBloc*-1
currentY += mutareBloc
repozitionare(mutareBloc*-1, mutareBloc)
}
Else If ((GetKeyState("DOWN", "P") AND GetKeyState("RIGHT", "P")))
{
currentX += mutareBloc
currentY += mutareBloc
repozitionare(mutareBloc, mutareBloc)
}
Else If (GetKeyState("Up", "P"))
{
currentY -= mutareBloc
repozitionare(0, mutareBloc*-1)
}
Else If (GetKeyState("Left", "P"))
{
currentX += mutareBloc*-1
repozitionare(mutareBloc*-1, 0)
}
Else If (GetKeyState("Down", "P"))
{
currentY += mutareBloc
repozitionare(0, mutareBloc)
}
Else If (GetKeyState("Right", "P"))
{
currentX += mutareBloc
repozitionare(mutareBloc, 0)
}
IniWrite, %currentX%, session.ini, CurrentSession, currentX
IniWrite, %currentY%, session.ini, CurrentSession, currentY
return
}
NumpadMult::
{
flipHorizontal()
If (isFlipH = 1)
{
IniWrite, 0, session.ini, CurrentSession, isFlipH
} Else {
IniWrite, 1, session.ini, CurrentSession, isFlipH
}
redesenare(bloc)
return
}
NumpadDiv::
{
flipVertical()
If (isFlipV = 1)
{
IniWrite, 0, session.ini, CurrentSession, isFlipV
} Else {
IniWrite, 1, session.ini, CurrentSession, isFlipV
}
redesenare(bloc)
return
}
PgUp::
{
If (numar_bloc_curent = numar_blocuri)
{
numar_bloc_curent := 1
} Else {
numar_bloc_curent += 1
}
selectareBloc(numar_bloc_curent)
If (isFlipH)
{
flipHorizontal()
}
If (isFlipV)
{
flipVertical()
}
redesenare(bloc)
Return
}
PgDn::
{
If (numar_bloc_curent = 1)
{
numar_bloc_curent := numar_blocuri
} Else {
numar_bloc_curent -= 1
}
selectareBloc(numar_bloc_curent)
If (isFlipH)
{
flipHorizontal()
}
If (isFlipV)
{
flipVertical()
}
redesenare(bloc)
Return
}
r::
{
unghi_total := unghi_total * -1
rotireBloc(unghi_total)
repozitionare(startX-currentX, startY-currentY)
redesenare(bloc)
currentX := startX
currentY := startY
unghi_total := 0
IniWrite, %startX%, session.ini, CurrentSession, currentX
IniWrite, %startY%, session.ini, CurrentSession, currentY
IniWrite, 0, session.ini, CurrentSession, unghiTotal
IniWrite, 1, session.ini, CurrentSession, shapeID
return
}
Enter::
{
Gui,99: Hide
Loop, %numar_puncte%
{
MouseMove bloc[a_index][1], bloc[a_index][2]
Click
Sleep, 300
}
MouseMove bloc[1][1], bloc[1][2]
Click
Sleep, 100
Click
beforeShape := bloc.clone()
Loop, %numar_puncte%
{
beforeShape[a_index] := bloc[a_index].clone()
}
Gui,99: Show
return
}
v::
{
tooltip, Liviu Roman`nGoogle Map Maker Building`nVersiunea 1.00, currentX, currentY
SetTimer, RemoveToolTip, 5000
return
}
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return
~ESC::ExitApp