Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.77 KB | None | 0 0
  1. #NoTrayIcon
  2.  
  3. global $space, $end, $endx, $redraw, $boardw[32], $fields[64], $log, $user32 = DllOpen("user32")
  4.  
  5. ;---config---
  6. $circle=50 ;board size
  7. ;------------
  8.  
  9. ;---fill-board---
  10. $beginswb=$circle/0.134408602150538
  11. $i=0
  12. while $i<64
  13. $beginswa=$circle/2.27272727272727
  14. $ii=0
  15. while $ii<8
  16. $fields[$i]=$beginswa & "_" & $beginswb
  17. $beginswa=$beginswa+$circle
  18. $ii=$ii+1
  19. $i=$i+1
  20. WEnd
  21. $beginswb=$beginswb-$circle
  22. WEnd
  23.  
  24. ;---white---
  25. $beginswa=$circle/2.27272727272727
  26. $beginswb=$circle/0.134408602150538
  27. $boardw[0]="w_" & $beginswa & "_" & $beginswb & "_t_y"
  28. $beginswa=$beginswa+$circle
  29. $boardw[1]="w_" & $beginswa & "_" & $beginswb & "_s_y"
  30. $beginswa=$beginswa+$circle
  31. $boardw[2]="w_" & $beginswa & "_" & $beginswb & "_l_y"
  32. $beginswa=$beginswa+$circle
  33. $boardw[3]="w_" & $beginswa & "_" & $beginswb & "_d_y"
  34. $beginswa=$beginswa+$circle
  35. $boardw[4]="w_" & $beginswa & "_" & $beginswb & "_k_y"
  36. $beginswa=$beginswa+$circle
  37. $boardw[5]="w_" & $beginswa & "_" & $beginswb & "_l_y"
  38. $beginswa=$beginswa+$circle
  39. $boardw[6]="w_" & $beginswa & "_" & $beginswb & "_s_y"
  40. $beginswa=$beginswa+$circle
  41. $boardw[7]="w_" & $beginswa & "_" & $beginswb & "_t_y"
  42. $beginswa=$circle/2.27272727272727
  43. $beginswb=$beginswb-$circle
  44. $i=8
  45. while $i<16
  46. $boardw[$i]="w_" & $beginswa & "_" & $beginswb & "_b_y"
  47. $beginswa=$beginswa+$circle
  48. $i=$i+1
  49. WEnd
  50. ;-----------
  51.  
  52. ;---black---
  53. $beginswa=$circle/2.27272727272727
  54. $beginswb=$beginswb-$circle*6
  55. $boardw[16]="b_" & $beginswa & "_" & $beginswb & "_t_y"
  56. $beginswa=$beginswa+$circle
  57. $boardw[17]="b_" & $beginswa & "_" & $beginswb & "_s_y"
  58. $beginswa=$beginswa+$circle
  59. $boardw[18]="b_" & $beginswa & "_" & $beginswb & "_l_y"
  60. $beginswa=$beginswa+$circle
  61. $boardw[19]="b_" & $beginswa & "_" & $beginswb & "_d_y"
  62. $beginswa=$beginswa+$circle
  63. $boardw[20]="b_" & $beginswa & "_" & $beginswb & "_k_y"
  64. $beginswa=$beginswa+$circle
  65. $boardw[21]="b_" & $beginswa & "_" & $beginswb & "_l_y"
  66. $beginswa=$beginswa+$circle
  67. $boardw[22]="b_" & $beginswa & "_" & $beginswb & "_s_y"
  68. $beginswa=$beginswa+$circle
  69. $boardw[23]="b_" & $beginswa & "_" & $beginswb & "_t_y"
  70. $beginswa=$circle/2.27272727272727
  71. $beginswb=$beginswb+$circle
  72. $i=24
  73. while $i<32
  74. $boardw[$i]="b_" & $beginswa & "_" & $beginswb & "_b_y"
  75. $beginswa=$beginswa+$circle
  76. $i=$i+1
  77. WEnd
  78. ;-----------
  79. ;----------------
  80.  
  81. #include <GDIPlus.au3>
  82. #include <WindowsConstants.au3>
  83.  
  84. #include <GuiConstantsEx.au3>
  85.  
  86. Opt("GUIOnEventMode", 1)
  87.  
  88. $space=$circle/2.5
  89. $full=$circle*8
  90. $end=$space+$full
  91. $endx=$space*2+$full
  92.  
  93. OnAutoItExitRegister("end")
  94.  
  95. $redraw="a"
  96. $marked="a"
  97.  
  98. $bg=GUICreate("chess", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
  99. GUISetBkColor(0xF0F0F0)
  100. GUISetState(@SW_SHOW, $bg)
  101.  
  102. While 1
  103. ;---redraw---
  104. if $redraw=="a" Then
  105. $hGUI=GUICreate("chess", $endx, $endx, -1, -1, $WS_POPUP)
  106. GUISetBkColor(0xD3D3D3)
  107. GUISetOnEvent(-3, "end")
  108. GUISetState()
  109. _GDIPlus_Startup()
  110. $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
  111. $hBrushb = _GDIPlus_BrushCreateSolid(0xAACE9E00)
  112. $hBrushw = _GDIPlus_BrushCreateSolid(0xD18B4700)
  113.  
  114. local $j[8]
  115. $j[0]="A"
  116. $j[1]="B"
  117. $j[2]="C"
  118. $j[3]="D"
  119. $j[4]="E"
  120. $j[5]="F"
  121. $j[6]="G"
  122. $j[7]="H"
  123.  
  124. $endj=$end+$space/10
  125. $font=$circle/5
  126. $ia=0
  127. $i=$circle-($space/2)
  128. While $ia<8
  129. _GDIPlus_GraphicsDrawString($hGraphic, $j[$ia], $i, $endj, "Arial", $font)
  130. $ia=$ia+1
  131. $i=$i+$circle
  132. WEnd
  133.  
  134. $endjx=$space/4
  135. $ia=8
  136. $i=$circle-($space/2)
  137. While $ia>0
  138. _GDIPlus_GraphicsDrawString($hGraphic, $ia, $endjx, $i, "Arial", $font)
  139. $ia=$ia-1
  140. $i=$i+$circle
  141. WEnd
  142.  
  143. $iii="a"
  144. $ii=$space
  145. while $ii<$end
  146. $i=$space
  147. while $i<$end
  148.  
  149. if $iii=="a" Then
  150. _GDIPlus_GraphicsFillRect($hGraphic, $i, $ii, $circle, $circle, $hBrushb)
  151. $i=$i+$circle
  152. _GDIPlus_GraphicsFillRect($hGraphic, $i, $ii, $circle, $circle, $hBrushw)
  153. $i=$i+$circle
  154. Else
  155. _GDIPlus_GraphicsFillRect($hGraphic, $i, $ii, $circle, $circle, $hBrushw)
  156. $i=$i+$circle
  157. _GDIPlus_GraphicsFillRect($hGraphic, $i, $ii, $circle, $circle, $hBrushb)
  158. $i=$i+$circle
  159. EndIf
  160. WEnd
  161.  
  162. if $iii=="a" Then
  163. $iii="b"
  164. Else
  165. $iii="a"
  166. EndIf
  167.  
  168. $ii=$ii+$circle
  169. WEnd
  170. ;----------------
  171.  
  172. local $hImage, $drawi
  173. $figures=$circle/1.08695652173913
  174.  
  175. ;---white---
  176. $drawi=StringSplit($boardw[0], "_", 1)
  177. if $drawi[1]=="w" and $drawi[4]=="t" and $drawi[5]=="y" Then
  178. $hImage = _GDIPlus_ImageLoadFromFile("w_tower.png")
  179. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  180. EndIf
  181.  
  182. $drawi=StringSplit($boardw[1], "_", 1)
  183. if $drawi[1]=="w" and $drawi[4]=="s" and $drawi[5]=="y" Then
  184. $hImage = _GDIPlus_ImageLoadFromFile("w_horse.png")
  185. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  186. endif
  187.  
  188. $drawi=StringSplit($boardw[2], "_", 1)
  189. if $drawi[1]=="w" and $drawi[4]=="l" and $drawi[5]=="y" Then
  190. $hImage = _GDIPlus_ImageLoadFromFile("w_runner.png")
  191. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  192. EndIf
  193.  
  194. $drawi=StringSplit($boardw[3], "_", 1)
  195. if $drawi[1]=="w" and $drawi[4]=="d" and $drawi[5]=="y" Then
  196. $hImage = _GDIPlus_ImageLoadFromFile("w_queen.png")
  197. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  198. EndIf
  199.  
  200. $drawi=StringSplit($boardw[4], "_", 1)
  201. if $drawi[1]=="w" and $drawi[4]=="k" and $drawi[5]=="y" Then
  202. $hImage = _GDIPlus_ImageLoadFromFile("w_king.png")
  203. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  204. EndIf
  205.  
  206. $drawi=StringSplit($boardw[5], "_", 1)
  207. if $drawi[1]=="w" and $drawi[4]=="l" and $drawi[5]=="y" Then
  208. $hImage = _GDIPlus_ImageLoadFromFile("w_runner.png")
  209. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  210. EndIf
  211.  
  212. $drawi=StringSplit($boardw[6], "_", 1)
  213. if $drawi[1]=="w" and $drawi[4]=="s" and $drawi[5]=="y" Then
  214. $hImage = _GDIPlus_ImageLoadFromFile("w_horse.png")
  215. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  216. EndIf
  217.  
  218. $drawi=StringSplit($boardw[7], "_", 1)
  219. if $drawi[1]=="w" and $drawi[4]=="t" and $drawi[5]=="y" Then
  220. $hImage = _GDIPlus_ImageLoadFromFile("w_tower.png")
  221. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  222. EndIf
  223.  
  224. $i=8
  225. while $i<16
  226. $drawi=StringSplit($boardw[$i], "_", 1)
  227. if $drawi[1]=="w" and $drawi[4]=="b" and $drawi[5]=="y" Then
  228. $hImage = _GDIPlus_ImageLoadFromFile("w_pawn.png")
  229. _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  230. EndIf
  231. $i=$i+1
  232. WEnd
  233. ;-----------
  234.  
  235. ;---black---
  236. $drawi=StringSplit($boardw[16], "_", 1)
  237. if $drawi[1]=="b" and $drawi[4]=="t" and $drawi[5]=="y" Then
  238. $hImage = _GDIPlus_ImageLoadFromFile("b_tower.png")
  239. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  240. EndIf
  241.  
  242. $drawi=StringSplit($boardw[17], "_", 1)
  243. if $drawi[1]=="b" and $drawi[4]=="s" and $drawi[5]=="y" Then
  244. $hImage = _GDIPlus_ImageLoadFromFile("b_horse.png")
  245. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  246. endif
  247.  
  248. $drawi=StringSplit($boardw[18], "_", 1)
  249. if $drawi[1]=="b" and $drawi[4]=="l" and $drawi[5]=="y" Then
  250. $hImage = _GDIPlus_ImageLoadFromFile("b_runner.png")
  251. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  252. EndIf
  253.  
  254. $drawi=StringSplit($boardw[19], "_", 1)
  255. if $drawi[1]=="b" and $drawi[4]=="d" and $drawi[5]=="y" Then
  256. $hImage = _GDIPlus_ImageLoadFromFile("b_queen.png")
  257. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  258. EndIf
  259.  
  260. $drawi=StringSplit($boardw[20], "_", 1)
  261. if $drawi[1]=="b" and $drawi[4]=="k" and $drawi[5]=="y" Then
  262. $hImage = _GDIPlus_ImageLoadFromFile("b_king.png")
  263. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  264. EndIf
  265.  
  266. $drawi=StringSplit($boardw[21], "_", 1)
  267. if $drawi[1]=="b" and $drawi[4]=="l" and $drawi[5]=="y" Then
  268. $hImage = _GDIPlus_ImageLoadFromFile("b_runner.png")
  269. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  270. EndIf
  271.  
  272. $drawi=StringSplit($boardw[22], "_", 1)
  273. if $drawi[1]=="b" and $drawi[4]=="s" and $drawi[5]=="y" Then
  274. $hImage = _GDIPlus_ImageLoadFromFile("b_horse.png")
  275. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  276. EndIf
  277.  
  278. $drawi=StringSplit($boardw[23], "_", 1)
  279. if $drawi[1]=="b" and $drawi[4]=="t" and $drawi[5]=="y" Then
  280. $hImage = _GDIPlus_ImageLoadFromFile("b_tower.png")
  281. _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  282. EndIf
  283.  
  284. $i=24
  285. while $i<32
  286. $drawi=StringSplit($boardw[$i], "_", 1)
  287. if $drawi[1]=="b" and $drawi[4]=="b" and $drawi[5]=="y" Then
  288. $hImage = _GDIPlus_ImageLoadFromFile("b_pawn.png")
  289. _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
  290. EndIf
  291. $i=$i+1
  292. WEnd
  293. ;-----------
  294. $redraw="b"
  295. EndIf
  296. ;------------
  297. $winpos = WinGetPos($hGUI)
  298. $pos=MouseGetPos()
  299. $posa=$pos[0]
  300. $posb=$pos[1]
  301. $pos[0]=$pos[0]-$winpos[0]
  302. $pos[1]=$pos[1]-$winpos[1]
  303. if $pos[0]<1 Then
  304. MouseMove($posa+3, $posb, 0)
  305. EndIf
  306. if $pos[0]>$endx Then
  307. MouseMove($posa-3, $posb, 0)
  308. EndIf
  309. if $pos[1]<1 Then
  310. MouseMove($posa, $posb+3, 0)
  311. EndIf
  312. if $pos[1]>$endx Then
  313. MouseMove($posa, $posb-3, 0)
  314. EndIf
  315. if _IsPressed('01') = 1 Then
  316.  
  317. ;---check-field---
  318. $i=0
  319. while $i<64
  320. $drawi=StringSplit($fields[$i], "_", 1)
  321. if $pos[0]>$drawi[1] and $pos[0]<$drawi[1]+$figures and $pos[1]>$drawi[2] and $pos[1]<$drawi[2]+$figures Then
  322. if $marked=="b" Then
  323.  
  324. $ia=0
  325. while $ia<32
  326. if $boardwx==$boardw[$ia] Then
  327. $drawix=StringSplit($boardw[$ia], "_", 1)
  328.  
  329. $search=$drawix[1] & "_" & $drawi[1] & "_" & $drawi[2] & "_"
  330. $ix=0
  331. while $ix<32
  332. if StringInStr($boardw[$ix], $search, 1) Then
  333. ExitLoop
  334. EndIf
  335. $ix=$ix+1
  336. WEnd
  337.  
  338. ;---rules---
  339. $next="a"
  340. $beginswbx=$circle/0.134408602150538
  341. $beginswbx=$beginswbx-$circle
  342. ;---pawn-white---
  343. if $drawix[1]=="w" and $drawix[4]=="b" Then
  344. if $ix>31 Then
  345.  
  346. if $drawix[2]<>$drawi[1] Then
  347. msgbox(4096, "error", "incorrect usage0")
  348. Else
  349.  
  350. if $beginswbx==$drawix[3] Then
  351. $ker=$circle*2
  352. Else
  353. $ker=$circle
  354. EndIf
  355.  
  356. if $drawix[3]<$drawi[2] or $drawix[3]>$drawi[2]+$ker Then
  357. msgbox(4096, "error", "incorrect usage1")
  358. Else
  359. $next="b"
  360. EndIf
  361. EndIf
  362. Else
  363. msgbox(4096, "error", "incorrect usage2")
  364. endif
  365. EndIf
  366. ;----------------
  367.  
  368. ;---pawn-black---
  369. $beginswbx=$beginswbx-$circle*6
  370. $beginswbx=$beginswbx+$circle
  371. if $drawix[1]=="b" and $drawix[4]=="b" Then
  372. if $ix>31 Then
  373.  
  374. if $drawix[2]<>$drawi[1] Then
  375. msgbox(4096, "error", "incorrect usage3")
  376. Else
  377.  
  378. if $beginswbx==$drawix[3] Then
  379. $ker=$circle*2
  380. Else
  381. $ker=$circle
  382. EndIf
  383.  
  384. ;-------------------------------------------------------------------------------------------here
  385. if $drawix[3]>$drawi[2] Then
  386. msgbox(4096, "...", "if (" & $drawix[3] & ">" & $drawi[2] & ") { thats true o.0 }")
  387. EndIf
  388. ConsoleWrite("if (" & $drawix[3] & ">" & $drawi[2] & ") { thats true o.0 }")
  389. ;-----------------------------------------------------------------------------------------------
  390.  
  391. if $drawix[3]+$ker<$drawi[2] Then
  392. msgbox(4096, "error", "incorrect usage4")
  393. Else
  394. $next="b"
  395. EndIf
  396. EndIf
  397. Else
  398. msgbox(4096, "error", "incorrect usage5")
  399. endif
  400. EndIf
  401. ;----------------
  402. ;-----------
  403.  
  404. if $next="b" then
  405. $boardw[$ia]=$drawix[1] & "_" & $drawi[1] & "_" & $drawi[2] & "_" & $drawix[4] & "_" & $drawix[5]
  406. EndIf
  407.  
  408. ExitLoop
  409. EndIf
  410. $ia=$ia+1
  411. WEnd
  412.  
  413. _GDIPlus_BrushDispose($hBrushw)
  414. _GDIPlus_BrushDispose($hBrushb)
  415. _GDIPlus_GraphicsDispose($hGraphic)
  416. _GDIPlus_PenDispose($hPenmark)
  417. _GDIPlus_GraphicsDispose($hGraphicmark)
  418. _GDIPlus_Shutdown()
  419. guidelete($hGUI)
  420. $redraw="a"
  421. $marked="a"
  422. EndIf
  423. EndIf
  424. $i=$i+1
  425. WEnd
  426. ;-----------------
  427.  
  428. ;---find-figure---
  429. $i=0
  430. while $i<32
  431. $drawi=StringSplit($boardw[$i], "_", 1)
  432.  
  433. if $pos[0]>$drawi[2] and $pos[0]<$drawi[2]+$figures and $pos[1]>$drawi[3] and $pos[1]<$drawi[3]+$figures Then
  434. if $marked=="a" and $redraw=="b" Then
  435. $hGraphicmark = _GDIPlus_GraphicsCreateFromHWND($hGUI)
  436. $hPenmark = _GDIPlus_PenCreate(0xAF50FF00, $circle/25)
  437. _GDIPlus_GraphicsDrawArc($hGraphicmark, $drawi[2]-($figures/($circle/2)), $drawi[3]-($figures/($circle/2)), $circle, $circle, 180, 360, $hPenmark)
  438. $boardwx=$boardw[$i]
  439. $marked="b"
  440. EndIf
  441. EndIf
  442.  
  443. $i=$i+1
  444. WEnd
  445.  
  446. sleep(100)
  447. EndIf
  448. WEnd
  449. ;-----------------
  450.  
  451. Func _IsPressed($hexKey)
  452. Local $aR, $bRv
  453. $hexKey = '0x' & $hexKey
  454. $aR = DllCall($user32, "int", "GetAsyncKeyState", "int", $hexKey)
  455. if $aR[0] <> 0 Then
  456. $bRv = 1
  457. Else
  458. $bRv = 0
  459. EndIf
  460. Return $bRv
  461. EndFunc
  462.  
  463. func end()
  464. _GDIPlus_BrushDispose($hBrushw)
  465. _GDIPlus_GraphicsDispose($hGraphic)
  466. _GDIPlus_Shutdown()
  467. Exit
  468. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement