Advertisement
melapela

BF2 HITFIXER 2.0 AHK Script

May 24th, 2015
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 54.27 KB | None | 0 0
  1. /*
  2. ================================================================================================
  3. Battlefield 2 HitFixer
  4. by WaltBerkman
  5. Info: http://forums.bf2s.com/viewtopic.php?id=104544&p=1
  6. http://www.autohotkey.com/board/topic/32887-battlefield-hitfixer-fixes-hitreg-for-bf22142/
  7. =================================================================================================
  8. */
  9.  
  10. SendMode Input
  11. #Persistent
  12. #NoEnv
  13. #SingleInstance force
  14. #InstallKeybdHook
  15.  
  16. programName=Battlefield HitFixer
  17. CurrentVersion := 2.0
  18. LowestCompatibleIniVersion := 2.0
  19. v_WindowWidth := 340 ;Width of Main Window, used for scalable GUI
  20. v_WindowHeight := 470 ;Height of Main Window, used for scalable GUI
  21.  
  22. GoSub CreateIni
  23. GoSub ReadIni
  24. GoSub DownloadIcon
  25.  
  26. FileGetSize, Temp02, %A_ProgramFiles%\HitFixer\HitFixerIcon.ico
  27. if (Temp02 != 0) and (Temp02 != "")
  28. Menu Tray, Icon, %A_ProgramFiles%\HitFixer\HitFixerIcon.ico
  29.  
  30. GoSub BuildMainGui
  31. if v_AutoRunOnStart
  32. GoSub RunBFSoap
  33.  
  34. HotKey ~%v_HitFixKey%, Hitregfix, On UseErrorLevel
  35.  
  36. /*
  37. ======================================================
  38. Tray Menu
  39. ======================================================
  40. */
  41.  
  42. Menu, Tray, Tip, %programName% %CurrentVersion%
  43. Menu, Tray, NoStandard
  44. Menu Tray, Add, About, About
  45. Menu, Tray, Add
  46. Menu, Tray, Add, Hide, GeneralHideButton
  47. Menu, Tray, Add, Show, GeneralShowButton
  48. Menu, Tray, Disable, Show
  49. Menu, Tray, Default, Show
  50. Menu, Tray, Add
  51. Menu, Tray, Add
  52. Menu, Tray, Add, Exit, Exit
  53.  
  54. if v_AutoUpdateOnStart
  55. {
  56. StartupUpdateCheck := 1
  57. GoSub CheckforUpdates
  58. }
  59. return
  60.  
  61.  
  62. /*
  63. ======================================================
  64. Tray Menu Actions
  65. ======================================================
  66. */
  67.  
  68. GeneralHideButton:
  69. Gui, 6:Submit
  70. Gui, 6:Hide
  71. Menu, Tray, Disable, Hide
  72. Menu, Tray, Enable, Show
  73. return
  74.  
  75. GeneralShowButton:
  76. Gui, 6:Show
  77. Menu, Tray, Disable, Show
  78. Menu, Tray, Enable, Hide
  79. return
  80.  
  81.  
  82. /*
  83. ======================================================
  84. About Page
  85. ======================================================
  86. */
  87.  
  88. About:
  89.  
  90. v_AboutPageWidth := 320
  91. v_AboutPageHeight := 350
  92. Gui 91:Destroy
  93. Gui 91: -MaximizeBox +Theme +ToolWindow +AlwaysonTop
  94. Gui 91:Font, ;bold
  95. YPosition := 15
  96. FileGetSize, Temp02, %A_ProgramFiles%\HitFixer\HitFixerIcon.ico
  97. if (Temp02 != 0) and (Temp02 != "")
  98. {
  99. v_AboutPageHeight := 400
  100. TempX := (v_AboutPageWidth/2) - 64
  101. Gui, 91: Add, Picture, w128 h128 x%TempX% y%YPosition% vv_AboutPageIcon, %A_ProgramFiles%\HitFixer\HitFixerIcon.ico
  102. YPosition += 135
  103. }
  104.  
  105. XPosition := 8
  106. TempH := v_AboutPageHeight - 195
  107. TempW := v_AboutPageWidth - 16
  108. Gui, 91:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h%TempH%,
  109. YPosition += 25
  110. XPosition := 22
  111. TempX := v_AboutPageWidth - 120 -22
  112. Gui, 91:Add, Text, x%XPosition% y%YPosition%, %programName% %CurrentVersion% by WaltBerkman
  113. YPosition += 18
  114. Gui, 91:Add, Text, x%XPosition% y%YPosition%, DupaSoftware@gmail.com
  115. YPosition += 45
  116. TempX := (v_AboutPageWidth/2) - 60
  117. Gui, 91:Add, Button, x%TempX% y%YPosition% w120 h23 gLaunchContactEmail, Contact Email
  118. YPosition += 28
  119. Gui, 91:Add, Button, x%TempX% y%YPosition% w120 h23 gLaunchHitFixThread, View Website
  120.  
  121. TempX := v_AboutPageWidth - 80 - 8
  122. TempY := v_AboutPageHeight - 32
  123. Gui 91:Add, Button,x%TempX% y%TempY% w80 h23 gCloseAboutWindow, OK
  124. Gui 91:Show, w%v_AboutPageWidth% h%v_AboutPageHeight%, About %programName% %CurrentVersion%
  125. return
  126.  
  127. LaunchContactEmail:
  128. Run mailto:dupasoftware@gmail.com
  129. return
  130.  
  131. LaunchHitFixThread:
  132. Run http://forums.bf2s.com/viewtopic.php?id=104544
  133. return
  134.  
  135. CloseAboutWindow:
  136. Gui 91:Destroy
  137. return
  138.  
  139.  
  140. /*
  141. ======================================================
  142. Download Graphics
  143. ======================================================
  144. */
  145.  
  146. DownloadIcon:
  147.  
  148. FileGetSize, Temp02, %A_ProgramFiles%\HitFixer\HitFixerIcon.ico
  149. if (Temp02 = 0) or (Temp02 = "")
  150. {
  151. Gui, 90:Destroy
  152. Gui, 90:Font
  153. Gui, 90: -MaximizeBox +Theme +AlwaysOnTop +ToolWindow ;-SysMenu
  154. Gui, 90:Add, GroupBox, x12 y8 w276 h60,
  155. Gui, 90:Add, Text, x55 y28 ,Please wait while initial files download...
  156. Gui, 90:Add, Progress, x55 y45 w180 h5 -Smooth vv_IconProgressBar, 0
  157. SetTimer, UpdateIconProgress, 400
  158. Gui, 90:Show, w300 h80 , Battlefield HitFixer
  159. URLDownloadToFile http://www.autohotkey.net/~DupaUnit/HitFixerIcon.ico, %A_ProgramFiles%\HitFixer\HitFixerIcon.ico
  160. Gui, 90:Destroy
  161. }
  162. return
  163.  
  164.  
  165. UpdateIconProgress:
  166. GuiControl, 90: , v_IconProgressBar, +14
  167. GuiControlGet, Temp05, 90: , v_IconProgressBar
  168. if (Temp05 >= 100)
  169. SetTimer, UpdateIconProgress, Off
  170. return
  171.  
  172.  
  173. /*
  174. ======================================================
  175. Gui - Build and Tab calls
  176. ======================================================
  177. */
  178.  
  179. BuildMainGui:
  180. Gui, 6:Destroy
  181. Gui, 6:Font
  182. Gui, 6: -MaximizeBox +Theme +ToolWindow ;-SysMenu
  183. TempX := v_WindowWidth - 85
  184. TempY := v_WindowHeight - 33
  185. ;TempX -= 73
  186. Gui, 6:Add, Button, x%TempX% y%TempY% w65 h23 gMainHelpButton, Help
  187. TempX -= 73
  188. Gui, 6:Add, Button, x%TempX% y%TempY% w65 h23 gGeneralHideButton, Hide
  189. TempW := v_WindowWidth - 14
  190. TempH := v_WindowHeight - 50
  191. Gui, 6:Add, Tab2, x7 w%TempW% h%TempH% y5 Choose%v_SelectedTab% AltSubmit -Background vv_SelectedTab,General|BFSoap|Update|Advanced
  192.  
  193. GoSub GeneralPrefTab
  194. GoSub AdvancedPrefTab
  195. GoSub CleanServerHistoryTab
  196. GoSub UpdatePrefTab
  197.  
  198. if (v_EnableAdvancedCommands = 0)
  199. GoSub EnableAdvancedCommandsTab
  200.  
  201. Gui, 6:Show, w%v_WindowWidth% h%v_WindowHeight% x%v_PositionX% y%v_PositionY%, %programName% %CurrentVersion%
  202. return
  203.  
  204.  
  205. EnableAdvancedCommandsTab:
  206. Gui 6: Submit, NoHide
  207. if v_EnableAdvancedCommands
  208. {
  209. GuiControl, 6: , v_SelectedTab, |General|BFSoap|Update|Advanced
  210. GuiControl, 6: Show, v_VideoGroupbox
  211. GuiControl, 6: Show, v_FrameRate
  212. GuiControl, 6: Show, v_MaxFramesText
  213. GuiControl, 6: Show, v_ShowFPS
  214. }
  215. else
  216. {
  217. GuiControl, 6: , v_SelectedTab, |General|BFSoap|Update
  218. GuiControl, 6: Hide, v_VideoGroupbox
  219. GuiControl, 6: Hide, v_FrameRate
  220. GuiControl, 6: Hide, v_MaxFramesText
  221. GuiControl, 6: Hide, v_ShowFPS
  222. }
  223. return
  224.  
  225. Exit:
  226. 6GuiClose:
  227. GoSub UpdateIni
  228. ExitApp
  229. return
  230.  
  231.  
  232. /*
  233. ======================================================
  234. Gui General Tab - 1
  235. ======================================================
  236. */
  237.  
  238. GeneralPrefTab:
  239. Gui, 6: Tab, 1
  240. YPosition := 35
  241. XPosition := 16
  242.  
  243. FileGetSize, Temp02, %A_ProgramFiles%\HitFixer\HitFixerIcon.ico
  244. if (Temp02 != 0) and (Temp02 != "")
  245. {
  246. TempX := (v_WindowWidth / 2)- 36
  247. YPosition += 2
  248. Gui, 6: Add, Picture, w64 h64 x%TempX% y%YPosition% vv_MainPageIcon, %A_ProgramFiles%\HitFixer\HitFixerIcon.ico
  249. YPosition += 68
  250. }
  251.  
  252. TempW := v_WindowWidth - 32
  253. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h88,
  254. YPosition += 18
  255. XPosition := 28
  256. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% vv_AutoOpenConsole gSaveHotkeyFunction Checked%v_AutoOpenConsole%,Auto open console when running HitFixer
  257. YPosition += 22
  258. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% vv_AutoRunOnStart gSaveHotkeyFunction Checked%v_AutoRunOnStart%,Run BFSoap on startup
  259. YPosition += 22
  260. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% vv_EnableAdvancedCommands gEnableAdvancedCommandsTab Checked%v_EnableAdvancedCommands%,Enable advanced options
  261.  
  262. YPosition += 34
  263. XPosition := 16
  264. TempW := v_WindowWidth - 32
  265. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h54,HitFixer Key
  266. YPosition += 24
  267. XPosition := 28
  268. Gui, 6:Add, Hotkey, x%XPosition% y%YPosition% w95 h20 Limit8 Limit128 vv_HitfixKeyDisplayOnly, %v_HitfixKey%
  269. GuiControl 6: Disable, v_HitfixKeyDisplayOnly
  270. TempX := v_WindowWidth - 86
  271. YPosition -= 3
  272. Gui, 6:Add, Button, x%TempX% y%YPosition% w60 h23 gModifyHotkey, Edit...
  273. YPosition += 42
  274. XPosition := 16
  275.  
  276. TempW := v_WindowWidth - 32
  277. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h57 vv_ProtectGroupbox,Protection
  278. YPosition += 25
  279. XPosition := 28
  280. Gui, 6:Add, Text, x%XPosition% y%YPosition% w160 gProtectUserSettingsFunction vv_UserSettingsStatus,Usersettings Status Unknown
  281. TempX := v_WindowWidth - 96
  282. YPosition -= 2
  283. Gui, 6:Add, Button, x%TempX% y%YPosition% w70 h23 gProtectUserSettingsFunction vv_ProtectButton, Protect...
  284. GoSub CheckUserSettingsFunction
  285.  
  286. YPosition += 42
  287. XPosition := 16
  288. TempW := v_WindowWidth - 32
  289. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h54 vv_VideoGroupbox,Video
  290. YPosition += 24
  291. XPosition := 28
  292. Gui, 6:Add, Edit, x%XPosition% y%YPosition% w30 Limit3 Number gSaveHotkeyFunction vv_FrameRate, %v_FrameRate%
  293. YPosition += 4
  294. XPosition += 33
  295. Gui, 6:Add, Text, x%XPosition% y%YPosition% vv_MaxFramesText,Max Framerate
  296. XPosition += 97
  297. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% vv_ShowFPS gSaveHotkeyFunction Checked%v_ShowFPS%,Show FPS
  298. return
  299.  
  300.  
  301. SaveHotkeyFunction:
  302. Gui 6: Submit, NoHide
  303. return
  304.  
  305.  
  306. /*
  307. ======================================================
  308. Gui Advanced Tab - 2
  309. ======================================================
  310. */
  311.  
  312. AdvancedPrefTab:
  313. Gui, 6: Tab, 4
  314. YPosition := 35
  315. XPosition := 16
  316. TempW := v_WindowWidth - 32
  317. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h48,
  318. YPosition += 18
  319. XPosition += 9
  320. Gui, 6:Add, Slider, Range-20-20 Center Thick15 NoTicks x%XPosition% y%YPosition% w128 AltSubmit gUpdateBasePingDevSlider vv_BasePingDevSlider,%v_BasePingDevSlider% Ping Offset
  321. XPosition += 128
  322. YPosition += 2
  323. Gui, 6:Add, Text, x%XPosition% y%YPosition% w120 vBasePingDevSliderPercent,
  324. GoSub UpdateBasePingDevSlider
  325. YPosition += 37
  326. XPosition := 16
  327. TempW := v_WindowWidth - 32
  328. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h108, Ratios
  329. YPosition += 20
  330. XPosition += 9
  331. Gui, 6:Add, Slider, Range1-300 Center Thick15 NoTicks x%XPosition% y%YPosition% w128 AltSubmit gUpdateLatCompSlider vv_LatCompSlider, %v_LatCompSlider%
  332. YPosition += 1
  333. XPosition += 128
  334. Gui, 6:Add, Text, x%XPosition% w120 y%YPosition% vLatCompSliderPercent,%v_LatCompSlider%`% Latency Comp
  335. YPosition += 27
  336. XPosition -= 128
  337. Gui, 6:Add, Slider, Range1-300 Center Thick15 NoTicks x%XPosition% y%YPosition% w128 AltSubmit gUpdateExtrapSlider vv_ExtrapSlider, %v_ExtrapSlider%
  338. YPosition += 1
  339. XPosition += 128
  340. Gui, 6:Add, Text, x%XPosition% w120 y%YPosition% vExtrapSliderPercent,%v_ExtrapSlider%`% Extrapolation
  341. YPosition += 27
  342. XPosition -= 128
  343. Gui, 6:Add, Slider, Range1-300 Center Thick15 NoTicks x%XPosition% y%YPosition% w128 AltSubmit gUpdateInterpSlider vv_InterpSlider, %v_InterpSlider%
  344. YPosition += 1
  345. XPosition += 128
  346. Gui, 6:Add, Text, x%XPosition% w120 y%YPosition% vInterpSliderPercent,%v_InterpSlider%`% Interpolation
  347. YPosition += 37
  348. XPosition := 16
  349. TempW := v_WindowWidth - 32
  350. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h78,
  351. YPosition += 18
  352. XPosition := 28
  353. Gui, 6:Add, Edit, x%XPosition% y%YPosition% w30 Limit2 Number gSaveHotkeyFunction vv_PerfLog, %v_PerfLog%
  354. YPosition += 4
  355. XPosition += 33
  356. Gui, 6:Add, Text, x%XPosition% y%YPosition%,Log Player Count
  357. XPosition += 97
  358. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% vv_ShowNetGraph gSaveHotkeyFunction Checked%v_ShowNetGraph%, Show NetGraph
  359. YPosition += 25
  360. XPosition -= 130
  361. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% vv_ExtrapFrame gSaveHotkeyFunction Checked%v_ExtrapFrame%, Extrapolate Frame
  362. XPosition += 130
  363. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% vv_UseObjectCache gSaveHotkeyFunction Checked%v_UseObjectCache%, Use Object Cache
  364. YPosition += 39
  365. XPosition := 16
  366. TempW := v_WindowWidth - 32
  367. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h54,Hitreg Formula
  368. if (v_NewEquation = 1)
  369. {
  370. Temp01 := 1
  371. Temp02 := 0
  372. }
  373. else
  374. {
  375. Temp01 := 0
  376. Temp02 := 1
  377. }
  378. YPosition += 25
  379. XPosition := 28
  380. Gui, 6:Add, Radio, x%XPosition% y%YPosition%v Checked%Temp01% gSaveHotkeyFunction vv_NewEquation, Default
  381. xPosition += 65
  382. Gui, 6:Add, Radio, x%XPosition% y%YPosition% Checked%Temp02% gSaveHotkeyFunction,Restricted Range
  383. TempX := v_WindowWidth - 105
  384. TempY := v_WindowHeight - 78
  385. Gui, 6:Add, Button, x%TempX% y%TempY% w85 h23 gSetAdvancedtoDefaults, Defaults
  386. return
  387.  
  388.  
  389. UpdateBasePingDevSlider:
  390. if (v_BasePingDevSlider >= 0)
  391. {
  392. GuiControl, 6:Text, BasePingDevSliderPercent,+%v_BasePingDevSlider% Ping Offset
  393. }
  394. else
  395. {
  396. GuiControl, 6:Text, BasePingDevSliderPercent,%v_BasePingDevSlider% Ping Offset
  397. }
  398. return
  399.  
  400.  
  401. UpdateLatCompSlider:
  402. GuiControl, 6:Text, LatCompSliderPercent,%v_LatCompSlider%`% Latency Comp
  403. return
  404. UpdateExtrapSlider:
  405. GuiControl, 6:Text, ExtrapSliderPercent, %v_ExtrapSlider%`% Extrapolation
  406. return
  407. UpdateInterpSlider:
  408. GuiControl, 6:Text, InterpSliderPercent, %v_InterpSlider%`% Interpolation
  409. return
  410.  
  411.  
  412. SetAdvancedtoDefaults:
  413. GuiControl, 6:, v_PerfLog, 99
  414. GuiControl, 6:, v_ShowNetGraph, 0
  415. GuiControl, 6:, v_UseObjectCache, 1
  416. GuiControl, 6:, v_ExtrapFrame, 1
  417. GuiControl, 6:, Default, 1 ;Hitreg formula
  418. GuiControl, 6:, v_BasePingDevSlider, 10
  419. GuiControl, 6:, v_LatCompSlider, 100
  420. GuiControl, 6:, v_ExtrapSlider, 100
  421. GuiControl, 6:, v_InterpSlider, 100
  422. Gui 6: Submit, NoHide
  423. GoSub UpdateBasePingDevSlider
  424. GoSub UpdateLatCompSlider
  425. GoSub UpdateExtrapSlider
  426. GoSub UpdateInterpSlider
  427. return
  428.  
  429.  
  430. /*
  431. ======================================================
  432. Gui Update Tab - 3
  433. ======================================================
  434. */
  435.  
  436. UpdatePrefTab:
  437. Gui, 6: Tab, 3
  438. YPosition := 34
  439. XPosition := 16
  440. TempW := v_WindowWidth - 32
  441. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h48,
  442. YPosition += 20
  443. XPosition := 28
  444. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% vv_AutoUpdateOnStart gSaveHotkeyFunction Checked%v_AutoUpdateOnStart%,Check for updates on startup
  445. YPosition += 35
  446. XPosition := 16
  447. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h93 vv_UpdateButtonGroupBox,
  448. YPosition += 20
  449. TempX := (v_WindowWidth/2) - 64
  450. Gui, 6:Add, Button, x%TempX% y%YPosition% w128 h23 gCheckforUpdates vv_CheckUpdatesButton, Check for Updates...
  451. YPosition += 40
  452. XPosition := 28
  453. Gui, 6:Add, Text, x%XPosition% y%YPosition% w290 vv_UpdateAvailStatusText,
  454. YPosition += 20
  455. TempW := v_WindowWidth - 56
  456. UpdateProgressYPos := YPosition
  457. Gui, 6:Add, Progress, x%XPosition% y-100 w%TempW% h5 -Smooth vv_MainUpdateProgress, 0
  458. UpdateTabEndingYPos := YPosition
  459. return
  460.  
  461.  
  462. ChooseUpdateMethod:
  463. if A_IsCompiled
  464. GoSub ExecuteExeUpdate
  465. else
  466. GoSub ExecuteAhkUpdate
  467. return
  468.  
  469.  
  470. /*
  471. ======================================================
  472. Check for Updates
  473. ======================================================
  474. */
  475.  
  476. CheckforUpdates:
  477.  
  478. GuiControl, 6: Disable, v_CheckUpdatesButton
  479. GuiControl, 6:Text, v_UpdateAvailStatusText,Checking...
  480. GuiControl, 6: , v_MainUpdateProgress, 0
  481. SetTimer, UpdateUpdateProgress, 100
  482. GuiControl, 6: Move, v_MainUpdateProgress, y%UpdateTabEndingYPos%
  483.  
  484. URLDownloadToFile http://www.autohotkey.net/~DupaUnit/HitFixer_VersionRelease.ini, %A_ProgramFiles%\HitFixer\HitFixer_VersionRelease.ini
  485.  
  486. IniRead, v_LatestExeVersion, %A_ProgramFiles%\HitFixer\HitFixer_VersionRelease.ini, LATEST VERSION, ExeVersion
  487. IniRead, v_LatestAhkVersion, %A_ProgramFiles%\HitFixer\HitFixer_VersionRelease.ini, LATEST VERSION, AhkVersion
  488. IniRead, v_LatestExeName, %A_ProgramFiles%\HitFixer\HitFixer_VersionRelease.ini, LATEST VERSION, ExeName
  489. IniRead, v_LatestAhkName, %A_ProgramFiles%\HitFixer\HitFixer_VersionRelease.ini, LATEST VERSION, AhkName
  490.  
  491. if (v_LatestExeVersion = "ERROR") or (v_LatestAhkVersion = "ERROR") or (v_LatestExeVersion = "") or (v_LatestAhkVersion = "")
  492. {
  493. GuiControl, 6:Text, v_UpdateAvailStatusText,There was a problem checking for updates
  494. GoSub RemoveProgressState
  495. return
  496. }
  497.  
  498. if (CurrentVersion < v_LatestExeVersion) or (CurrentVersion < v_LatestAhkVersion)
  499. {
  500. GuiControl, 6:Text, v_UpdateAvailStatusText ,There is a new version available!
  501. GuiControl, 6: Disable, v_CheckUpdatesButton
  502. GuiControl, 6:MoveDraw, v_UpdateButtonGroupBox, h158
  503.  
  504.  
  505. if StartupUpdateCheck
  506. {
  507. StartupUpdateCheck := 0
  508. TrayTip, HitFixer Update, There is a new HitFixer version available
  509. SetTimer, RemoveUpdateTrayTip, 5000
  510. }
  511.  
  512. Temp01 := 0
  513. GuiControlGet, Temp02, 6: , v_UpdateEXEButton
  514. Temp01 += ErrorLevel
  515. GuiControlGet, Temp02, 6: , v_UpdateAhkButton
  516. Temp01 += ErrorLevel
  517. if (Temp01 < 2)
  518. {
  519. GoSub RemoveProgressState
  520. return
  521. }
  522.  
  523. YPosition := UpdateTabEndingYPos + 20
  524. XPosition := 28
  525. Gui, 6:Add, Text, x%XPosition% y%YPosition% w290 vv_NewExeVersionText,A new .EXE version is available
  526. TempX := v_WindowWidth - 132
  527. YPosition -= 3
  528. Gui, 6:Add, Button, x%TempX% y%YPosition% w100 h23 gChooseUpdateMethod vv_UpdateEXEButton, Download Now
  529. YPosition += 31
  530. Gui, 6:Add, Text, x%XPosition% y%YPosition% w290 vv_NewAhkVersionText,A new .AHK version is available
  531. YPosition -= 3
  532. Gui, 6:Add, Button, x%TempX% y%YPosition% w100 h23 gChooseUpdateMethod vv_UpdateAhkButton, Download Now
  533.  
  534. if !(CurrentVersion < v_LatestExeVersion)
  535. {
  536. GuiControl, 6:Text, v_NewExeVersionText,No new .EXE version available
  537. GuiControl, 6: Disable, v_UpdateEXEButton
  538. }
  539. if !(CurrentVersion < v_LatestAhkVersion)
  540. {
  541. GuiControl, 6:Text, v_NewAhkVersionText,No new .AHK version available
  542. GuiControl, 6: Disable, v_UpdateAhkButton
  543. }
  544. }
  545. else
  546. {
  547. GuiControl, 6:Text, v_UpdateAvailStatusText,Your version is up to date
  548. }
  549. GoSub RemoveProgressState
  550. return
  551.  
  552.  
  553. RemoveProgressState:
  554. SetTimer, UpdateUpdateProgress, Off
  555. GuiControl, 6: Enable, v_CheckUpdatesButton
  556. GuiControl, 6: Move, v_MainUpdateProgress, y-100
  557. return
  558.  
  559.  
  560. UpdateUpdateProgress:
  561. GuiControl, 6: , v_MainUpdateProgress, +6
  562. GuiControlGet, Temp05, 6: , v_MainUpdateProgress
  563. ;if (Temp05 >= 100)
  564. ;SetTimer, UpdateUpdateProgress, Off
  565. return
  566.  
  567.  
  568. RemoveUpdateTrayTip:
  569. SetTimer, RemoveUpdateTrayTip, Off
  570. TrayTip
  571. return
  572.  
  573.  
  574. /*
  575. ======================================================
  576. Execute Exe Update
  577. ======================================================
  578. */
  579.  
  580. ExecuteExeUpdate:
  581.  
  582. GuiControl, 6: Disable, v_CheckUpdatesButton
  583. GuiControl, 6:Text, v_UpdateAvailStatusText,Please wait while updates download...
  584. GuiControl, 6: , v_MainUpdateProgress, 0
  585. SetTimer, UpdateUpdateProgress, 600
  586. GuiControl, 6: Move, v_MainUpdateProgress, y%UpdateTabEndingYPos%
  587.  
  588. IfExist, %A_ProgramFiles%\HitFixer\HitFixer_Installer.exe
  589. FileRecycle, %A_ProgramFiles%\HitFixer\HitFixer_Installer.exe
  590.  
  591. if (A_GuiControl = "v_UpdateEXEButton")
  592. Temp01 := v_LatestExeName
  593. else
  594. Temp01 := v_LatestAhkName
  595.  
  596. IniWrite, %Temp01%, %A_ProgramFiles%\HitFixer\HitFixer_Installer.ini, UNINSTALL INFO, Requested Version
  597. IniWrite, %A_ScriptFullPath%, %A_ProgramFiles%\HitFixer\HitFixer_Installer.ini, UNINSTALL INFO, Delete File Path
  598. IniWrite, %A_ScriptDir%, %A_ProgramFiles%\HitFixer\HitFixer_Installer.ini, UNINSTALL INFO, Download Directory
  599. IniWrite, %A_ScriptName%, %A_ProgramFiles%\HitFixer\HitFixer_Installer.ini, UNINSTALL INFO, Delete File Name
  600.  
  601. URLDownloadToFile http://www.autohotkey.net/~DupaUnit/%Temp01%, %A_ScriptDir%\NEW%Temp01%
  602. FileGetSize, Temp02, %A_ScriptDir%\NEW%Temp01%
  603. if (Temp02 = 0)
  604. {
  605. GuiControl, 6:Text, v_UpdateAvailStatusText,There was a problem downloading update
  606. FileRecycle, %A_ScriptDir%\NEW%Temp01%
  607. FileRecycle, %A_ScriptFullPath%, %A_ProgramFiles%\HitFixer\HitFixer_Installer.ini
  608. GoSub RemoveProgressState
  609. return
  610. }
  611.  
  612. GuiControl, 6: , v_MainUpdateProgress, 0
  613. URLDownloadToFile http://www.autohotkey.net/~DupaUnit/HitFixer_Installer.exe, %A_ProgramFiles%\HitFixer\HitFixer_Installer.exe
  614. FileGetSize, Temp02, %A_ProgramFiles%\HitFixer\HitFixer_Installer.exe
  615. if (Temp02 = 0)
  616. {
  617. GuiControl, 6:Text, v_UpdateAvailStatusText,There was a problem downloading update
  618. FileRecycle, %A_ProgramFiles%\HitFixer\HitFixer_Installer.exe
  619. FileRecycle, %A_ScriptDir%\NEW%Temp01%
  620. FileRecycle, %A_ScriptFullPath%, %A_ProgramFiles%\HitFixer\HitFixer_Installer.ini
  621. GoSub RemoveProgressState
  622. return
  623. }
  624.  
  625. IfExist, %A_ProgramFiles%\HitFixer\HitFixer_Installer.exe
  626. Run, %A_ProgramFiles%\HitFixer\HitFixer_Installer.exe
  627. else
  628. {
  629. GoSub RemoveProgressState
  630. return
  631. }
  632. ExitApp
  633. return
  634.  
  635.  
  636. /*
  637. ======================================================
  638. Execute Ahk Update
  639. ======================================================
  640. */
  641.  
  642. ExecuteAhkUpdate:
  643.  
  644. GuiControl, 6: Disable, v_CheckUpdatesButton
  645. GuiControl, 6:Text, v_UpdateAvailStatusText,Please wait while updates download...
  646. GuiControl, 6: , v_MainUpdateProgress, 0
  647. SetTimer, UpdateUpdateProgress, 600
  648. GuiControl, 6: Move, v_MainUpdateProgress, y%UpdateTabEndingYPos%
  649.  
  650.  
  651. if (A_GuiControl = "v_UpdateEXEButton")
  652. Temp01 := v_LatestExeName
  653. else
  654. Temp01 := v_LatestAhkName
  655.  
  656. if (Temp01 = "")
  657. {
  658. GoSub RemoveProgressState
  659. return
  660. }
  661.  
  662. URLDownloadToFile http://www.autohotkey.net/~DupaUnit/%Temp01%, %A_ScriptDir%\NEW%Temp01%
  663.  
  664.  
  665. FileGetSize, Temp02, %A_ScriptDir%\NEW%Temp01%
  666. if (Temp02 = 0)
  667. {
  668. GuiControl, 6:Text, v_UpdateAvailStatusText,There was a problem downloading update
  669. FileRecycle, %A_ScriptDir%\NEW%Temp01%
  670. GoSub RemoveProgressState
  671. return
  672. }
  673.  
  674. FileRecycle, %A_ScriptFullPath%
  675. FileMove, %A_ScriptDir%\NEW%Temp01%, %A_ScriptDir%\%Temp01%
  676.  
  677. IfExist, %A_ScriptDir%\%Temp01%
  678. Run, %A_ScriptDir%\%Temp01%
  679. ExitApp
  680. return
  681.  
  682.  
  683. /*
  684. ======================================================
  685. Check Usersettings File Protection
  686. ======================================================
  687. */
  688.  
  689. CheckUserSettingsFunction:
  690.  
  691. v_UserSettingsStatus := "Usersettings Status Unknown"
  692. Gui, 6:Font, underline
  693. GuiControl, 6:Text, v_UserSettingsStatus,%v_UserSettingsStatus%
  694. GuiControl, 6:Font, v_UserSettingsStatus
  695. Gui, 6:Font
  696. if (v_BFInstallDirectory = "ERROR")
  697. return
  698. IfNotExist, %v_BFInstallDirectory%\BF2.exe
  699. return
  700.  
  701. v_UserSettingsStatus := "Usersettings are Not Protected"
  702. GuiControl, 6:Text, v_UserSettingsStatus,%v_UserSettingsStatus%
  703.  
  704. ;Inspect each Usersettings for stock lines and read-only status
  705. Loop, %v_BFInstallDirectory%\mods\*, 2, 0
  706. {
  707.  
  708. FileReadLine, Temp01, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con, 4
  709. if !(Temp01 = "SettingsManager.boolSet GSClPunkBuster 1")
  710. return
  711. FileReadLine, Temp01, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con, 5
  712. if !(Temp01 = "SettingsManager.floatSet GSDefaultLatencyCompensation 0.100000")
  713. return
  714. FileReadLine, Temp01, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con, 6
  715. if !(Temp01 = "SettingsManager.boolSet GSExtrapolateFrame 0")
  716. return
  717. FileReadLine, Temp01, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con, 7
  718. if !(Temp01 = "SettingsManager.U32Set GSExtrapolationTime 1200")
  719. return
  720. FileReadLine, Temp01, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con, 8
  721. if !(Temp01 = "SettingsManager.U32Set GSInterpolationTime 100")
  722. return
  723.  
  724. FileGetAttrib, Temp01, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con
  725. IfNotInString, Temp01, R
  726. return
  727. }
  728.  
  729. v_UserSettingsStatus := "Usersettings are Protected"
  730.  
  731. Gui, 6:Font, italic
  732. GuiControl, 6:Text, v_UserSettingsStatus,%v_UserSettingsStatus%
  733. GuiControl, 6:Font, v_UserSettingsStatus
  734. Gui, 6:Font
  735. GuiControl, 6:Disable, v_ProtectButton
  736. GuiControl, 6:Disable, v_UserSettingsStatus
  737. return
  738.  
  739.  
  740. /*
  741. ======================================================
  742. Protect Usersettings File
  743. ======================================================
  744. */
  745.  
  746. ProtectUserSettingsFunction:
  747.  
  748. IfNotExist, %v_BFInstallDirectory%\BF2.exe
  749. v_BFInstallDirectory := "ERROR"
  750.  
  751. if (v_BFInstallDirectory = "ERROR")
  752. {
  753. FileSelectFile, Temp01, 3, C:\Program Files\EA GAMES\Battlefield 2\BF2.exe, Select BF2.exe in Install Directory, Battlefield (BF2.exe)
  754.  
  755. if (Temp01 = "")
  756. return
  757. v_BFInstallDirectory := Temp01
  758.  
  759. Loop, 15
  760. {
  761. StringRight, Temp01, v_BFInstallDirectory, 1
  762. if !(Temp01 = "\")
  763. StringTrimRight, v_BFInstallDirectory, v_BFInstallDirectory, 1
  764. else
  765. {
  766. StringTrimRight, v_BFInstallDirectory, v_BFInstallDirectory, 1
  767. break
  768. }
  769. }
  770. IniWrite, %v_BFInstallDirectory%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, BFInstallDirectory
  771. }
  772.  
  773.  
  774. ;Find mod names and reset Usersettings
  775. Loop, %v_BFInstallDirectory%\mods\*, 2, 0
  776. {
  777.  
  778. FileReadLine, Temp01, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con, 10
  779. StringTrimRight, Temp01, Temp01, 1
  780. StringTrimLeft, Temp01, Temp01, 40
  781.  
  782. FileRecycle, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con
  783. FileAppend,
  784. (
  785. rem
  786. rem Settingsfile automatically saved by bf2
  787. rem
  788. SettingsManager.boolSet GSClPunkBuster 1
  789. SettingsManager.floatSet GSDefaultLatencyCompensation 0.100000
  790. SettingsManager.boolSet GSExtrapolateFrame 0
  791. SettingsManager.U32Set GSExtrapolationTime 1200
  792. SettingsManager.U32Set GSInterpolationTime 100
  793. SettingsManager.U32Set GSPerfLogAtPlayerCount 30
  794. SettingsManager.stringSet GSPlayerName "%Temp01%"
  795. SettingsManager.boolSet GSShowNetGraph 0
  796. SettingsManager.boolSet GSUseObjectCache 1
  797. ),%v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con
  798.  
  799. FileSetAttrib, +R, %v_BFInstallDirectory%\mods\%A_LoopFileName%\settings\Usersettings.con
  800. }
  801. GoSub CheckUserSettingsFunction
  802. return
  803.  
  804.  
  805. /*
  806. ======================================================
  807. Gui - Modify HotKey Window
  808. ======================================================
  809. */
  810.  
  811. ModifyHotkey:
  812. Gui, 4:Destroy
  813. Gui, 4: -SysMenu +ToolWindow +Theme +AlwaysonTop
  814. Gui, 4:Add, GroupBox, x4 y-2 w195 h38,
  815. Gui, 4:Add, Text,x11 y12 gModifyHotkey,HitFixer Key:
  816. Gui, 4:Add, Hotkey,x90 y9 w105 h20 Limit8 Limit128 vv_HitfixKey, %v_HitfixKey%
  817. Gui, 4:Add, Button, x3 y40 w97 Default gAcceptHotkeyAssignWin vHotKeyModifySaveButton, Save
  818. Gui, 4:Add, Button, x104 y40 w97 gCancelHotkeyAssignWin, Cancel
  819. ;GuiControl, 4:Focus, HotKeyModifySaveButton
  820. Gui, 4:Show, w204 h70, Set Hotkey
  821. return
  822.  
  823. CancelHotkeyAssignWin:
  824. Gui, 4:Destroy
  825. return
  826.  
  827. AcceptHotkeyAssignWin:
  828. Gui, 4:Submit
  829. IniWrite, %v_HitfixKey%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, HOTKEYS, HitfixerKey
  830. Gui, 4:Destroy
  831. GoSub UpdateIni
  832. Reload
  833. return
  834.  
  835.  
  836. /*
  837. ======================================================
  838. HitReg Fix
  839. ======================================================
  840. */
  841.  
  842. Hitregfix:
  843. ;Process, Priority, , High
  844.  
  845. SetTitleMatchMode, 2
  846. If ! (WinActive("BF2142 (v") or WinActive("BF2 (v"))
  847. return
  848.  
  849.  
  850. ;-----Open Console-------------------
  851. if (v_AutoOpenConsole = 1)
  852. {
  853. Sleep 110
  854. Send {~ Down}
  855. Sleep 110
  856. Send {~ Up}
  857. Sleep 10
  858. }
  859. ;------------------------------------
  860.  
  861. ;SetKeyDelay 5, 5
  862. Sleep 1
  863. Send,TYPE PING THEN PRESS ENTER{Space}{Space}
  864. Sleep 1
  865. Input, PingVar, T8 V,{Enter}{Esc}
  866. KeyWait, Enter, T5
  867.  
  868. if (ErrorLevel = "EndKey:Escape")
  869. {
  870. Send,{Space}(HITFIXER CANCELLED){ENTER}
  871. return
  872. }
  873. if !(PingVar < 1000 and PingVar > 1)
  874. {
  875. Send,PLEASE TRY AGAIN AND ENTER A NUMBER BETWEEN 1 AND 999.{ENTER}
  876. return
  877. }
  878. if PingVar is not digit
  879. {
  880. Send,PLEASE TRY AGAIN AND ENTER A NUMBER BETWEEN 1 AND 999.{ENTER}
  881. return
  882. }
  883.  
  884. ;*****Advanced Commands Only*******
  885. if v_EnableAdvancedCommands
  886. {
  887. ;-----Send FrameRate Commands---------
  888. if !(v_FrameRate = 100)
  889. {
  890. Send,game.lockFps %v_FrameRate%{Enter}
  891. Sleep 1
  892. }
  893. Send,renderer.drawFps %v_ShowFPS%{Enter}
  894. Sleep 1
  895. ;-----Send Misc HitReg Commands-------
  896.  
  897. Send,SettingsManager.U32Set GSPerfLogAtPlayerCount %v_PerfLog%{Enter}
  898. Sleep 1
  899. Send,SettingsManager.boolSet GSShowNetGraph %v_ShowNetGraph%{Enter}
  900. Sleep 1
  901. Send,SettingsManager.boolSet GSUseObjectCache %v_UseObjectCache%{Enter}
  902. }
  903. ;**********************************
  904.  
  905. ;-----Send Main HitReg Commands-------
  906.  
  907. PingVar += v_BasePingDevSlider
  908.  
  909. LatencyComp := (PingVar / 1000) * (v_LatCompSlider / 100)
  910. Interpol := Floor( PingVar * (v_InterpSlider / 100))
  911. if (v_NewEquation = 1)
  912. Extrapol := Floor( (12 * PingVar) * (v_ExtrapSlider / 100) )
  913. else
  914. Extrapol := Floor( ((5.5 * PingVar) + 489) * (v_ExtrapSlider / 100) )
  915. /*
  916. y is unknown (extrap)
  917. delta y/delta x
  918. y = mx + b
  919. y - mx = b
  920. y = 5.5x + 489 (X is ping)
  921. */
  922. Send,SettingsManager.boolSet GSExtrapolateFrame %v_ExtrapFrame%{Enter}
  923. Sleep 2
  924. Send,SettingsManager.floatSet GSDefaultLatencyCompensation %LatencyComp%{Enter}
  925. Sleep 2
  926. Send,SettingsManager.U32Set GSExtrapolationTime %Extrapol%{Enter}
  927. Sleep 2
  928. Send,SettingsManager.U32Set GSInterpolationTime %Interpol%{Enter}
  929. Sleep 2
  930.  
  931. ;Process, Priority, , Normal
  932.  
  933. ;-----Close Console------------------
  934. if (v_AutoOpenConsole = 1)
  935. {
  936. Sleep 110
  937. Send {~ Down}
  938. Sleep 110
  939. Send {~ Up}
  940. }
  941. ;------------------------------------
  942.  
  943. Send {Control Up}
  944. Send {Shift Up}
  945. Send {Alt Up}
  946.  
  947. return
  948.  
  949.  
  950. /*
  951. ======================================================
  952. Create ini
  953. ======================================================
  954. */
  955.  
  956. CreateIni:
  957. IfNotExist, %A_ProgramFiles%\HitFixer
  958. FileCreateDir, %A_ProgramFiles%\HitFixer
  959.  
  960. IniRead, Temp01, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, CURRENT VERSION, CurrentVersion
  961. if (Temp01 < LowestCompatibleIniVersion) or (Temp01 = "ERROR")
  962. FileDelete, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini
  963.  
  964. IfNotExist %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini
  965. {
  966. IniWrite, %CurrentVersion%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, CURRENT VERSION, CurrentVersion
  967. IniWrite, ^0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, HOTKEYS, HitfixerKey
  968. IniWrite, ., %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, HOTKEYS,. ;Legability space
  969. IniWrite, 1, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, NewEquation
  970. IniWrite, 1, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, SelectedTab
  971. IniWrite, 0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowAdvanced
  972. IniWrite, 0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, HideAdvWarning
  973. IniWrite, 100, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, LatCompSlider
  974. IniWrite, 100, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ExtrapSlider
  975. IniWrite, 100, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, InterpSlider
  976. IniWrite, 10, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, BasePingDevSlider
  977. IniWrite, 100, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, FrameRate
  978. IniWrite, 0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowFPS
  979. IniWrite, 99, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, PerfLog
  980. IniWrite, 1, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ExtrapFrame
  981. IniWrite, 0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowNetGraph
  982. IniWrite, 1, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, UseObjectCache
  983. IniWrite, ., %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS,. ;Legability space
  984.  
  985. IniWrite, 1, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanServerHistory
  986. IniWrite, 1, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanBRHistory
  987. IniWrite, 1, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanLogoCache
  988. IniWrite, 0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, AutoRunOnStart
  989.  
  990. IniWrite, ., %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS,. ;Legability space
  991.  
  992. IniWrite, 0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoOpenConsole
  993. IniWrite, 0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoUpdateOnStart
  994. IniWrite, 0, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, EnableAdvancedCommands
  995. IniWrite, 1, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoProtectUserSettings ;Unused ATM
  996. IniWrite, ERROR, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, BFInstallDirectory
  997.  
  998. IniWrite, ., %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS,. ;Legability space
  999. IniWrite, 100, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, WIN COORDS, PositionX
  1000. IniWrite, 100, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, WIN COORDS, PositionY
  1001. }
  1002. return
  1003.  
  1004.  
  1005. /*
  1006. ======================================================
  1007. Read ini
  1008. ======================================================
  1009. */
  1010.  
  1011. ReadIni:
  1012. IniRead, v_HitFixKey, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, HOTKEYS, HitfixerKey
  1013. IniRead, v_NewEquation, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, NewEquation
  1014. IniRead, v_SelectedTab, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, SelectedTab
  1015. IniRead, v_ShowAdvanced, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowAdvanced
  1016. IniRead, v_HideAdvWarning, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, HideAdvWarning
  1017. IniRead, v_LatCompSlider, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, LatCompSlider
  1018. IniRead, v_ExtrapSlider, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ExtrapSlider
  1019. IniRead, v_InterpSlider, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, InterpSlider
  1020. IniRead, v_BasePingDevSlider, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, BasePingDevSlider
  1021. IniRead, v_FrameRate, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, FrameRate
  1022. IniRead, v_ShowFPS, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowFPS
  1023. IniRead, v_PerfLog, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, PerfLog
  1024. IniRead, v_ExtrapFrame, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ExtrapFrame
  1025. IniRead, v_ShowNetGraph, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowNetGraph
  1026. IniRead, v_UseObjectCache, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, UseObjectCache
  1027.  
  1028. IniRead, v_CleanServerHistory, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanServerHistory
  1029. IniRead, v_CleanBRHistory, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanBRHistory
  1030. IniRead, v_CleanLogoCache, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanLogoCache
  1031. IniRead, v_AutoRunOnStart, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, AutoRunOnStart
  1032.  
  1033. IniRead, v_AutoOpenConsole, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoOpenConsole
  1034. IniRead, v_AutoUpdateOnStart, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoUpdateOnStart
  1035. IniRead, v_EnableAdvancedCommands, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, EnableAdvancedCommands
  1036. IniRead, v_AutoProtectUserSettings, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoProtectUserSettings
  1037. IniRead, v_BFInstallDirectory, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, BFInstallDirectory
  1038.  
  1039. IniRead, v_PositionX, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, WIN COORDS, PositionX
  1040. IniRead, v_PositionY, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, WIN COORDS, PositionY
  1041.  
  1042. if (v_PositionX < 0) or (v_PositionX = "ERROR")
  1043. v_PositionX := 100
  1044. if (v_PositionY < 0) or (v_PositionY = "ERROR")
  1045. v_PositionY := 100
  1046. return
  1047.  
  1048.  
  1049. /*
  1050. ======================================================
  1051. Update ini
  1052. ======================================================
  1053. */
  1054.  
  1055. UpdateIni:
  1056. Gui 6:Submit, NoHide
  1057. IniWrite, %CurrentVersion%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, CURRENT VERSION, CurrentVersion
  1058. IniWrite, %v_NewEquation%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, NewEquation
  1059. IniWrite, %v_SelectedTab%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, SelectedTab
  1060. IniWrite, %v_ShowAdvanced%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowAdvanced
  1061. IniWrite, %v_HideAdvWarning%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, HideAdvWarning
  1062. IniWrite, %v_LatCompSlider%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, LatCompSlider
  1063. IniWrite, %v_ExtrapSlider%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ExtrapSlider
  1064. IniWrite, %v_InterpSlider%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, InterpSlider
  1065. IniWrite, %v_BasePingDevSlider%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, BasePingDevSlider
  1066. IniWrite, %v_FrameRate%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, FrameRate
  1067. IniWrite, %v_ShowFPS%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowFPS
  1068. IniWrite, %v_PerfLog%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, PerfLog
  1069. IniWrite, %v_ExtrapFrame%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ExtrapFrame
  1070. IniWrite, %v_ShowNetGraph%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, ShowNetGraph
  1071. IniWrite, %v_UseObjectCache%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SETTINGS, UseObjectCache
  1072.  
  1073. IniWrite, %v_CleanServerHistory%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanServerHistory
  1074. IniWrite, %v_CleanBRHistory%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanBRHistory
  1075. IniWrite, %v_CleanLogoCache%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, CleanLogoCache
  1076. IniWrite, %v_AutoRunOnStart%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, SOAP SETTINGS, AutoRunOnStart
  1077.  
  1078. IniWrite, %v_AutoOpenConsole%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoOpenConsole
  1079. IniWrite, %v_AutoUpdateOnStart%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoUpdateOnStart
  1080. IniWrite, %v_EnableAdvancedCommands%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, EnableAdvancedCommands
  1081. IniWrite, %v_AutoProtectUserSettings%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, APP SETTINGS, AutoProtectUserSettings
  1082.  
  1083. IfWinExist, %programName% %CurrentVersion%
  1084. WinGetPos, v_PositionX, v_PositionY,,, %programName% %CurrentVersion%
  1085. IniWrite, %v_PositionX%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, WIN COORDS, PositionX
  1086. IniWrite, %v_PositionY%, %A_ProgramFiles%\HitFixer\BattlefieldHitFixer.ini, WIN COORDS, PositionY
  1087. return
  1088.  
  1089.  
  1090. /*
  1091. =========================================================================================
  1092. Main Help Tooltips
  1093. =========================================================================================
  1094. */
  1095.  
  1096. MainHelpButton:
  1097.  
  1098. GuiControlGet, Temp01, 6: , v_MainPageIcon
  1099. if (Temp01 = "")
  1100. YPosition := -52
  1101. else
  1102. YPosition := 18
  1103.  
  1104. Gui 6:Submit, NoHide
  1105. ;Tips for Tab 1--------------------------------------------
  1106. if (v_SelectedTab = 1) ;General
  1107. {
  1108. if !v_AutoOpenConsole
  1109. Tooltip,
  1110. (
  1111. HITFIXER INSTRUCTIONS
  1112.  
  1113. 1. Join a Battlefield server and press tilde (~) to show the console
  1114.  
  1115. 2. Press the assigned HitFixer key, type your ping, then hit Enter
  1116.  
  1117. 3. Press tilde (~) again to hide the console
  1118.  
  1119. ), -190, %YPosition%, 1
  1120. else
  1121. Tooltip,
  1122. (
  1123. HITFIXER INSTRUCTIONS
  1124.  
  1125. 1. Join a Battlefield server and press the assigned HitFixer key
  1126.  
  1127. 2. Type your ping, then hit Enter
  1128.  
  1129. ), -190, %YPosition%, 1
  1130.  
  1131.  
  1132. YPosition += 120
  1133. Tooltip,
  1134. (
  1135. When checked, you will no longer need to press tilde (~) before running HitFixer.
  1136. ), -190, %YPosition%, 2
  1137. YPosition += 25
  1138. Tooltip,
  1139. (
  1140. Automatically runs BFSoap functions when opening HitFixer.
  1141. ), -190, %YPosition%, 3
  1142. YPosition += 74
  1143. Tooltip,
  1144. (
  1145. This is the assigned Hotkey which will run HitFixer while
  1146. in a Battlefield game.
  1147. ), -190, %YPosition%, 4
  1148. YPosition += 62
  1149. Tooltip,
  1150. (
  1151. Protecting your Usersettings will prevent MD5 kicks for having
  1152. a modified Usersettings.con file. This is done by resetting your
  1153. Usersetting files to default, then setting them to Read-Only.
  1154. ), -190, %YPosition%, 5
  1155. YPosition += 66
  1156. if v_EnableAdvancedCommands
  1157. Tooltip,
  1158. (
  1159. This allows you to change the video framerate cap of Battlefield from
  1160. the default value of 100 FPS and to show the FPS counter in-game.
  1161. ), -190, %YPosition%, 6
  1162. }
  1163.  
  1164.  
  1165.  
  1166. ;Tips for Tab 2--------------------------------------------
  1167. if (v_SelectedTab = 2) ;BFSoap
  1168. {
  1169. Tooltip,
  1170. (
  1171. Battlefield keeps a list of recently played servers, which can
  1172. drastically lengthen your "connecting to account server" time.
  1173. Clearing this should cut your login time down to a few seconds.
  1174. ), -190, 68, 1
  1175. Tooltip,
  1176. (
  1177. This clears all BattleRecorder History Bookmarks (left side
  1178. under community tab), NOT your saved BattleRecorder files.
  1179. ), -190, 123, 2
  1180. Tooltip,
  1181. (
  1182. This clears all the saved banners from servers you've joined.
  1183. ), -190, 163, 3
  1184. Tooltip,
  1185. (
  1186. Clearing the video cache is useful when Battlefield randomly changes
  1187. your videos settings, such as having your shadows randomly turn on
  1188. or off. Note: After this is cleared, Battlefield will "Optimize
  1189. Shaders" the next time a server is joined.
  1190. ), -190, 243, 4
  1191.  
  1192.  
  1193. }
  1194. ;Tips for Tab 3--------------------------------------------
  1195. if (v_SelectedTab = 3) ;Update
  1196. {
  1197.  
  1198.  
  1199.  
  1200.  
  1201. }
  1202. ;Tips for Tab 4--------------------------------------------
  1203. if (v_SelectedTab = 4) ;Advanced
  1204. {
  1205. Tooltip,
  1206. (
  1207. This is the initial amount to add to your ping.
  1208. A value of +5 to +10 is recommended.
  1209. ), -150, 70, 1
  1210.  
  1211. Tooltip,
  1212. (
  1213. These sliders control the ratio of each of the
  1214. 3 Hitreg settings based off the "base" formula.
  1215. These should generally be left alone, although
  1216. lowering interpolation and raising extrapolation
  1217. can yield positive results on certain servers.
  1218. ), -150, 128, 2
  1219.  
  1220. Tooltip,
  1221. (
  1222. These are the remaining 4 settings included in
  1223. the Usersettings file. Their exact nature is
  1224. unknown, modify at your own risk.
  1225. ), -150, 240, 3
  1226.  
  1227. Tooltip,
  1228. (
  1229. The Default option sets the extrapolation based
  1230. off the EA formula. Restricted Range sets the
  1231. extrapolation value higher on low ping servers
  1232. and lower on high ping servers. Use this setting
  1233. if Default does not give desired results.
  1234. ), -150, 330, 4
  1235. }
  1236. MouseGetPos, OldMousePosX, OldMousePosY
  1237. SetTimer, RemoveToolTips, 300
  1238. return
  1239.  
  1240.  
  1241. RemoveToolTips:
  1242. MouseGetPos, MousePosX, MousePosY
  1243. if !(OldMousePosX = MousePosX) and !(OldMousePosY = MousePosY)
  1244. {
  1245. SetTimer, RemoveToolTips, Off
  1246. Loop, 20
  1247. Tooltip,,,,%A_Index%
  1248. return
  1249. }
  1250. OldMousePosX := MousePosX
  1251. OldMousePosY := MousePosY
  1252. return
  1253.  
  1254.  
  1255. /*
  1256. =========================================================================================
  1257. Battlefield Soap Utility
  1258. =========================================================================================
  1259. */
  1260. /*
  1261. ======================================================
  1262. Read Existing Profiles
  1263. ======================================================
  1264. */
  1265.  
  1266. CleanServerHistoryTab:
  1267. Loop, %A_MyDocuments%\Battlefield 2\Profiles\????, 2, 0
  1268. {
  1269. FileReadLine, Temp02, %A_LoopFileFullPath%\Profile.con, 1
  1270. StringTrimLeft, Temp02, Temp02, 22
  1271. StringTrimRight, Temp02, Temp02, 1
  1272. StringRight, Temp01, A_LoopFileFullPath, 2
  1273. Profile%Temp01% := Temp02
  1274. NumberOfProfiles := Temp01
  1275. }
  1276.  
  1277. /*
  1278. ======================================================
  1279. Gui BFCleaner Tab - 3
  1280. ======================================================
  1281. */
  1282.  
  1283. Gui, 6: Tab, 2
  1284. YPosition := 35
  1285. XPosition := 16
  1286. TempW := v_WindowWidth - 32
  1287. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h159,
  1288. YPosition += 15
  1289. XPosition += 67
  1290. TempX := (v_WindowWidth / 2) - 92 + 45
  1291. Gui, 6:Add, DropDownList, x%TempX% y%YPosition% w140 AltSubmit gUpdateCleanerDisplayCounts vProfileSelect, All||
  1292. YPosition += 3
  1293. TempX := (v_WindowWidth / 2) - 92
  1294. Gui, 6:Font, bold
  1295. Gui, 6:Add, Text, x%TempX% y%YPosition%,Profile: ;Profile and DDL are 184 wide
  1296. Gui, 6:Font,
  1297.  
  1298. ItemPosition := 1
  1299. Loop, %NumberOfProfiles%
  1300. {
  1301. Temp02 := A_Index
  1302. if (Temp02 < 10)
  1303. Temp02 := "0" . Temp02
  1304. Temp01 := Profile%Temp02%
  1305.  
  1306. IfInString, Temp01, |
  1307. StringReplace, Temp01, Temp01, |, l, All
  1308.  
  1309. if !(Temp01 = "")
  1310. {
  1311. ++ItemPosition
  1312. ItemPosition%ItemPosition% := Temp02
  1313. GuiControl, 6: , ProfileSelect, %Temp01%
  1314. }
  1315. }
  1316.  
  1317. XPosition := 28
  1318. YPosition += 36
  1319. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% w240 gCheckforDisableClean vv_CleanServerHistory Checked%v_CleanServerHistory%,
  1320. GoSub CountServerHistory
  1321. YPosition += 23
  1322. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% w240 gCheckforDisableClean vv_CleanBRHistory Checked%v_CleanBRHistory%,
  1323. GoSub AmountofBRbookmarks
  1324. YPosition += 23
  1325. Gui, 6:Add, Checkbox, x%XPosition% y%YPosition% w240 gCheckforDisableClean vv_CleanLogoCache Checked%v_CleanLogoCache%,
  1326. GoSub SizeLogoCache
  1327. YPosition += 27
  1328. TempX := v_WindowWidth - 106
  1329. Gui, 6:Add, Button, x%TempX% y%YPosition% w80 h23 gRunBFSoap vCleanNowButton, Clean Now
  1330. GoSub CheckforDisableClean
  1331.  
  1332.  
  1333. YPosition += 43
  1334. XPosition := 16
  1335. TempW := v_WindowWidth - 32
  1336. TempH := v_WindowHeight - 50
  1337. Gui, 6:Add, GroupBox, x%XPosition% y%YPosition% w%TempW% h93, Video Cache
  1338. YPosition += 22
  1339. XPosition += 12
  1340. TempW := v_WindowWidth - 52
  1341. Gui, 6:Add, Text, x%XPosition% y%YPosition% w%TempW%, Clearing the video cache will cause your game to optimize shaders next time you join a server
  1342.  
  1343. YPosition += 38
  1344. TempX := v_WindowWidth - 146
  1345. Gui, 6:Add, Button, x%TempX% y%YPosition% w120 h23 gRemoveVideoCache, Clear Video Cache
  1346. return
  1347.  
  1348.  
  1349. RunBFSoap:
  1350. Gui, 6: Submit, NoHide
  1351. if v_CleanServerHistory
  1352. GoSub RemoveHistory
  1353. if v_CleanBRHistory
  1354. GoSub RemoveBRboomarks
  1355. if v_CleanLogoCache
  1356. GoSub RemoveLogoCache
  1357. return
  1358.  
  1359.  
  1360. CheckforDisableClean:
  1361. Gui, 6: Submit, NoHide
  1362. if (v_CleanServerHistory or v_CleanBRHistory or v_CleanLogoCache)
  1363. GuiControl, 6:Enable, CleanNowButton
  1364. else
  1365. GuiControl, 6:Disable, CleanNowButton
  1366. return
  1367.  
  1368.  
  1369. UpdateCleanerDisplayCounts:
  1370. GoSub AmountofBRbookmarks
  1371. GoSub CountServerHistory
  1372. return
  1373.  
  1374.  
  1375. /*
  1376. ======================================================
  1377. Remove Video Cache
  1378. ======================================================
  1379. */
  1380.  
  1381. RemoveVideoCache:
  1382. Loop, %A_MyDocuments%\Battlefield 2\mods\*, 2, 0
  1383. FileRecycle, %A_LoopFileLongPath%
  1384. MsgBox Video Cache Cleared!
  1385. return
  1386.  
  1387.  
  1388. /*
  1389. ======================================================
  1390. Find Size of Logo Cache
  1391. ======================================================
  1392. */
  1393.  
  1394. SizeLogoCache:
  1395. LogoFolderSize := 0
  1396. Loop, %A_MyDocuments%\Battlefield 2\LogoCache\*.*, , 1
  1397. LogoFolderSize += %A_LoopFileSize%
  1398.  
  1399. StringTrimRight, LogoFolderSize, LogoFolderSize, 5
  1400. LogoFolderSize += 0.0
  1401. LogoFolderSize /= 10
  1402.  
  1403. Loop, 15
  1404. {
  1405. StringRight, Temp01, LogoFolderSize, 1
  1406. if (Temp01 = "0")
  1407. StringTrimRight, LogoFolderSize, LogoFolderSize, 1
  1408. else
  1409. break
  1410. }
  1411.  
  1412. if (LogoFolderSize > 0)
  1413. GuiControl, 6:Text, v_CleanLogoCache, Saved Server Logos (%LogoFolderSize% MB)
  1414. else
  1415. GuiControl, 6:Text, v_CleanLogoCache, Saved Server Logos (Clean)
  1416. return
  1417.  
  1418.  
  1419. /*
  1420. ======================================================
  1421. Remove Logo Cache
  1422. ======================================================
  1423. */
  1424.  
  1425. RemoveLogoCache:
  1426. FileRecycle, %A_MyDocuments%\Battlefield 2\LogoCache
  1427. GoSub SizeLogoCache
  1428. return
  1429.  
  1430.  
  1431. /*
  1432. ======================================================
  1433. Find Amount of BattleRecorder Bookmarks
  1434. ======================================================
  1435. */
  1436.  
  1437. AmountofBRbookmarks:
  1438. v_BattleRecorderLines := 0
  1439. Gui, 6: Submit, NoHide
  1440. if (ProfileSelect = 1)
  1441. {
  1442. Loop, %NumberOfProfiles%
  1443. {
  1444. Temp01 := A_Index
  1445. if (Temp01 < 10)
  1446. Temp01 := "0" . Temp01
  1447.  
  1448. ;===COUNT BR LINES
  1449.  
  1450. Loop, Read, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\DemoBookmarks.con
  1451. {
  1452. ++v_BattleRecorderLines
  1453. }
  1454. }
  1455. }
  1456. else
  1457. {
  1458. Temp01 := ItemPosition%ProfileSelect%
  1459. ;===COUNT BR LINES
  1460. Loop, Read, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\DemoBookmarks.con
  1461. {
  1462. ++v_BattleRecorderLines
  1463. }
  1464. }
  1465.  
  1466. if (v_BattleRecorderLines = 1)
  1467. GuiControl, 6:Text, v_CleanBRHistory, BattleRecorder History (%v_BattleRecorderLines% Bookmark)
  1468. else if (v_BattleRecorderLines = 0)
  1469. GuiControl, 6:Text, v_CleanBRHistory, BattleRecorder History (Clean)
  1470. else
  1471. GuiControl, 6:Text, v_CleanBRHistory, BattleRecorder History (%v_BattleRecorderLines% Bookmarks)
  1472. return
  1473.  
  1474.  
  1475. /*
  1476. ======================================================
  1477. Remove BattleRecorder Bookmarks
  1478. ======================================================
  1479. */
  1480.  
  1481. RemoveBRboomarks:
  1482. Gui, 6: Submit, NoHide
  1483. if (ProfileSelect = 1)
  1484. {
  1485. Loop, %NumberOfProfiles%
  1486. {
  1487. Temp01 := A_Index
  1488. if (Temp01 < 10)
  1489. Temp01 := "0" . Temp01
  1490.  
  1491. ;===DELETE BOOKMARKS FILE
  1492. FileRecycle, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\DemoBookmarks.con
  1493. }
  1494. }
  1495. else
  1496. {
  1497. Temp01 := ItemPosition%ProfileSelect%
  1498.  
  1499. ;===DELETE BOOKMARKS FILE
  1500. FileRecycle, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\DemoBookmarks.con
  1501. }
  1502. GoSub AmountofBRbookmarks
  1503. return
  1504.  
  1505.  
  1506. /*
  1507. ======================================================
  1508. Count Server History
  1509. ======================================================
  1510. */
  1511.  
  1512. CountServerHistory:
  1513. v_ServerHistoryLines := 0
  1514. Gui, 6: Submit, NoHide
  1515. if (ProfileSelect = 1)
  1516. {
  1517. Loop, %NumberOfProfiles%
  1518. {
  1519. Temp01 := A_Index
  1520. if (Temp01 < 10)
  1521. Temp01 := "0" . Temp01
  1522.  
  1523. ;===COUNT HISTORY LINES
  1524. Loop, Read, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con
  1525. {
  1526. If InStr(A_LoopReadLine, "GeneralSettings.addServerHistory")
  1527. ++v_ServerHistoryLines
  1528. }
  1529. }
  1530. }
  1531. else
  1532. {
  1533. Temp01 := ItemPosition%ProfileSelect%
  1534. ;===COUNT HISTORY LINES
  1535. Loop, Read, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con
  1536. {
  1537. If InStr(A_LoopReadLine, "GeneralSettings.addServerHistory")
  1538. ++v_ServerHistoryLines
  1539. }
  1540. }
  1541.  
  1542. if (v_ServerHistoryLines = 1)
  1543. GuiControl, 6:Text, v_CleanServerHistory, Recently Played Server History (%v_ServerHistoryLines% Server)
  1544. else if (v_ServerHistoryLines = 0)
  1545. GuiControl, 6:Text, v_CleanServerHistory, Recently Played Server History (Clean)
  1546. else
  1547. GuiControl, 6:Text, v_CleanServerHistory, Recently Played Server History (%v_ServerHistoryLines% Servers)
  1548. return
  1549.  
  1550.  
  1551. /*
  1552. ======================================================
  1553. Remove Played Server History
  1554. ======================================================
  1555. */
  1556.  
  1557. RemoveHistory:
  1558.  
  1559. Gui, 6: Submit, NoHide
  1560. if (ProfileSelect = 1)
  1561. {
  1562. Loop, %NumberOfProfiles%
  1563. {
  1564. Temp01 := A_Index
  1565. if (Temp01 < 10)
  1566. Temp01 := "0" . Temp01
  1567.  
  1568. ;===BACKUP GENERAL.CON
  1569. FileCopy, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General BACKUP.con
  1570.  
  1571. ;===REMOVE LINES AND COPY TO NEW DOC
  1572. Loop, Read, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General2.con
  1573. {
  1574. If !InStr(A_LoopReadLine, "GeneralSettings.addServerHistory")
  1575. FileAppend, %A_LoopReadLine%`n
  1576. }
  1577.  
  1578. ;===DELETE ORIGNAL GENERAL.CON AND RENAME NEW ONE
  1579. FileRecycle, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con
  1580. FileMove, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General2.con, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con
  1581. }
  1582. }
  1583. else
  1584. {
  1585. Temp01 := ItemPosition%ProfileSelect%
  1586.  
  1587. ;===BACKUP GENERAL.CON
  1588. FileCopy, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General BACKUP.con
  1589.  
  1590. ;===REMOVE LINES AND COPY TO NEW DOC
  1591. Loop, Read, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General2.con
  1592. {
  1593. If !InStr(A_LoopReadLine, "GeneralSettings.addServerHistory")
  1594. FileAppend, %A_LoopReadLine%`n
  1595. }
  1596.  
  1597. ;===DELETE ORIGNAL GENERAL.CON AND RENAME NEW ONE
  1598. FileRecycle, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con
  1599. FileMove, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General2.con, %A_MyDocuments%\Battlefield 2\Profiles\00%Temp01%\General.con
  1600. }
  1601. GoSub CountServerHistory
  1602. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement