Advertisement
Wyvern67

Launcher Minecraft.fr

Mar 31st, 2015
927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 18.69 KB | None | 0 0
  1. #region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=Data\icon.ico
  3. #AutoIt3Wrapper_UseX64=n
  4. #AutoIt3Wrapper_Res_Comment=Achievement get ! Fouiner dans les ressources du wrapper. Je n y ai rien mis de spécial, te tracasse pas.
  5. #AutoIt3Wrapper_Res_Description=Launcher Minecraft.fr
  6. #AutoIt3Wrapper_Res_Fileversion=0.1.0.15
  7. #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
  8. #AutoIt3Wrapper_Res_Language=1036
  9. #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
  10. #AutoIt3Wrapper_Run_Tidy=y
  11. #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
  12. ;~ #include <ButtonConstants.au3>
  13. #include <EditConstants.au3>
  14. #include <GUIConstantsEx.au3>
  15. #include <StaticConstants.au3>
  16. #include <WindowsConstants.au3>
  17. #include <IE.au3>
  18. #include <gdiplus.au3>
  19. #include <Misc.au3>
  20. #include <String.au3>
  21. #include <aaa.au3>
  22. #include <7zip.au3>
  23. #include <_InetGetX.au3>
  24.  
  25. #cs
  26.     A faire :
  27.     Le launcher officiel ne clique pas sur login automatiquement (Résolu ?)
  28.     Le launcher officiel ne disparait pas
  29.     Ca fait "ting ting ting" quand on clique sur minecraft.fr
  30.    
  31.     Adresses de téléchargement :
  32.     /newsFeed.php
  33.     /Minecraft_font.ttf
  34.     /Minecraft_Mods.zip
  35.     /version.htm
  36.     /Minecraft.fr.zip
  37.     /log.php <action>
  38. #ce
  39.  
  40. Local $sString
  41. $counter = 1
  42. $exitcode = False
  43. $existed = False
  44. $F1Width = 800
  45. $F1Height = 311
  46. $df = @ScriptDir & "\Data\"
  47. $minecraftdir = @AppDataDir & "\.minecraft"
  48. $registry = "HKCU\SOFTWARE\Minecraft"
  49. $checkerdir = "Checker.exe"
  50. $ftp = "http://serveurmcfr.mtxserv.fr"
  51. $justFtpDir = "/Launcher/Dependances%20launcher"
  52. $ftpDir = $ftp & $justFtpDir
  53. $DebugCons = 0
  54.  
  55. If _Singleton(@ScriptName) = 0 Then
  56.     Exit
  57. EndIf
  58.  
  59. While 1
  60.     If WinExists("Minecraft Launcher") Then
  61.         ProcessClose(WinGetProcess("Minecraft Launcher"))
  62.     Else
  63.         ExitLoop
  64.     EndIf
  65. WEnd
  66.  
  67. ;GUI de débug
  68. $FDebug = GUICreate("Console testeur", 500, 300, (@DesktopWidth / 2) + ($F1Width / 2) + 5, (@DesktopHeight / 2) - ($F1Height / 2), $WS_BORDER)
  69. $DebugCons = GUICtrlCreateEdit("", 0, 0, 500, 300, $ES_READONLY)
  70.  
  71. While ProcessExists("Checker.exe")
  72.     ProcessClose("Checker.exe")
  73.     Debug("Fermeture du/des Checker.exe.")
  74. WEnd
  75.  
  76. $ping = Ping("www.google.fr")
  77.  
  78. If @ScriptName = "Src.au3" Or @ScriptName = "Src.exe" Then
  79.     $debugMode = True
  80.     GUISetState(@SW_SHOW, $FDebug)
  81. Else
  82.     $debugMode = False
  83.     GUISetState(@SW_HIDE, $FDebug)
  84. EndIf
  85.  
  86. If FileExists("C:\Windows\Fonts\Minecraft normal.ttf") = 0 Or FileExists("C:\Windows\Fonts\BRLNSR.TTF") = 0 Then
  87.     Debug("Polices d'écriture non installées.")
  88.     If RegRead($registry, "FontEnabled") = 1 Or RegRead($registry, "FontEnabled") = "" Then
  89.         $temp = MsgBox(4, "Launcher Minecraft.fr", "Il semble que vous ne possédez pas les polices d'écritures requises. Voulez-vous les installer ?")
  90.         If $temp = 6 Then
  91.             InetGet($ftpDir & "/Minecraft_font.ttf", "Minecraft normal.ttf", 1)
  92.             ShellExecute("Minecraft normal.ttf")
  93.             $hNews = InetGet($ftpDir & "/BRLNSR.TTF", "BRLNSR.TTF", 1)
  94.             ShellExecute("BRLNSR.TTF")
  95.             While ProcessExists("fontview.exe")
  96.             WEnd
  97.             FileDelete("Minecraft normal.ttf")
  98.             FileDelete("BRLNSR.TTF")
  99.             RegWrite($registry, "FontEnabled", "REG_DWORD", Hex(1))
  100.         Else
  101.             RegWrite($registry, "FontEnabled", "REG_DWORD", Hex(0))
  102.         EndIf
  103.     EndIf
  104. ElseIf FileExists("C:\Windows\Fonts\Minecraft normal.ttf") = 1 And FileExists("C:\Windows\Fonts\BRLNSR.TTF") = 1 Then
  105.     RegWrite($registry, "FontEnabled", "REG_DWORD", Hex(1))
  106. EndIf
  107.  
  108.  
  109. ;Mise au clair : Est-ce qu'on utilise une police custom ou pas ?
  110. If RegRead($registry, "FontEnabled") = 1 Then $policesOk = True
  111. If RegRead($registry, "FontEnabled") = 0 Then $policesOk = False
  112.  
  113. ;GUI de mise à jour
  114. $g2_height = 138
  115. $g2_width = 286
  116. $F2 = GUICreate("Mise à jour", $g2_width, $g2_height, (@DesktopWidth / 2) - ($g2_width / 2), (@DesktopHeight / 2) - ($g2_height / 2))
  117. GUICtrlCreateLabel("Votre version du jeu n'est pas à jour.", ($g2_width / 2) - ((StringLen("Votre version du jeu n'est pas à jour.") * 4.6) / 2), 16)
  118. GUICtrlCreateLabel("Veuillez patienter le temps de sa mise à niveau.", ($g2_width / 2) - ((StringLen("Veuillez patienter le temps de sa mise à niveau.") * 4.6) / 2), 32)
  119. $g2_Progress1 = GUICtrlCreateProgress(($g2_width / 2) - (($g2_width - 40) / 2), 88, $g2_width - 40, 25)
  120. $g2_Label2 = GUICtrlCreateLabel("Attente d'informations...", 25, 114, 300, 40)
  121. GUISetState(@SW_HIDE)
  122.  
  123.  
  124. ;GUI principale
  125. $F1 = GUICreate("Minecraft.fr", $F1Width, $F1Height, (@DesktopWidth / 2) - ($F1Width / 2), (@DesktopHeight / 2) - ($F1Height / 2), $WS_POPUP)
  126.  
  127. $PicFond = GUICtrlCreatePic($df & "fond.jpg", 0, 0, $F1Width, $F1Height)
  128. GUICtrlSetState($PicFond, $GUI_DISABLE)
  129. $picClose = PngGuiCreatePic($df & "btnClose.png", $F1Width - 20, $F1Height - $F1Height)
  130. $btnMc = GUICtrlCreatePic($df & "btnMc.bmp", $F1Width / 1.2841 - 130, ($F1Height / 1.19) - 28, 130, 28)
  131. If $ping <> 0 Then
  132.     $btnMcFr = GUICtrlCreatePic($df & "btnMcFr.bmp", $F1Width / 1.0362 - 130, ($F1Height / 1.19) - 28, 130, 28)
  133. Else
  134.     $btnMcFr = ""
  135. EndIf
  136. ;$btnOptions = PngGuiCreatePic($df&"btnOptions.bmp", ($F1Width/1.67)-28, ($F1Height/1.19)-28)
  137. $btnOptions = ""
  138. $btnSaveState = IniRead($df & "launcher.ini", "GUI", "Save", "off")
  139. $btnSave = PngGuiCreatePic($df & "save_" & $btnSaveState & ".png", ($F1Width / 1.2195), ($F1Height / 1.6368) - 28)
  140. GUICtrlSetImage($btnSave, $df & "save_" & $btnSaveState & ".bmp")
  141. $btnNewsFeed = GUICtrlCreatePic("", 24, 40, 388, 250)
  142.  
  143.  
  144. ;Inputs
  145. $username = IniRead($df & "launcher.ini", "GUI", "Username", "Nom d'utilisateur")
  146. If $username = "" Then $username = "Nom d'utilisateur"
  147. If $btnSaveState = "on" Then
  148.     $password = _StringEncrypt(0, IniRead($df & "launcher.ini", "GUI", "Password", "Password"), "Stallman", 1)
  149. Else
  150.     $password = "Password"
  151. EndIf
  152.  
  153. If $password = "" Then $password = "Password"
  154. $inputUsername = GUICtrlCreateInput($username, ($F1Width / 1.7777), $F1Height / 2.658, 200, 30)
  155. GUICtrlSetTip($inputUsername, "Votre nom de compte")
  156. $inputPassword = GUICtrlCreateInput($password, ($F1Width / 1.7777), $F1Height / 1.9316, 200, 30, $ES_PASSWORD)
  157. GUICtrlSetTip($inputPassword, "Le mot de passe de votre compte")
  158. GUICtrlSetFont($inputUsername, 13, 400, 0, "Minecraft")
  159. GUICtrlSetFont($inputPassword, 13, 400, 0, "Minecraft")
  160. $picMove = GUICtrlCreatePic("", 0, 0, $F1Width - 20, 20)
  161. GUISetState()
  162.  
  163. ;Module "Si il n'a pas (le bon?) minecraft_modded.jar, alors le retélécharger depuis Minecraft.fr
  164. If $ping <> 0 Then
  165.     $modVersion = IniRead($df & "launcher.ini", "GUI", "Version", "")
  166.     $modWeight = IniRead($df & "launcher.ini", "GUI", "Weight", "")
  167.     $modVersion = _StringEncrypt(0, $modVersion, "Stallman")
  168.     If FileExists(@TempDir & "\Launcher_MinecraftFr_version.txt") Then FileDelete(@TempDir & "\Launcher_MinecraftFr_version.txt")
  169.     $ret = _InetgetX($ftp, $justFtpDir & "/version.htm", @TempDir & "\Launcher_MinecraftFr_version.txt")
  170. ;~  InputBox("", "", FileRead(@TempDir & "\Launcher_MinecraftFr_version.txt"))
  171.     $modGoodVersion = FileReadLine(@TempDir & "\Launcher_MinecraftFr_version.txt", 1)
  172.     FileDelete(@TempDir & "\Launcher_MinecraftFr_version.txt")
  173.     If DirGetSize(@AppDataDir & "\.minecraft\Minecraft.fr") = -1 Then $modVersion = "0.0.0"
  174.  
  175.     Debug("Version : " & $modVersion & "/" & $modGoodVersion)
  176.     If StringCompare($modGoodVersion, $modVersion) <> 0 Then
  177.         Debug(@CRLF & "Jeu pas à jour. Mise à jour...")
  178.         GUISetState(@SW_SHOW, $F2)
  179.         GUISetState(@SW_HIDE, $F1)
  180.         GUICtrlSetData($g2_Progress1, 25)
  181.         GUICtrlSetData($g2_Label2, "Téléchargement...")
  182.         $hUpdate = InetGet($ftpDir & "/Minecraft.fr.zip", @TempDir & "\.minecraft.zip", 1, 1)
  183.         $updateSize = InetGetSize($ftpDir & "/Minecraft.fr.zip")
  184.         Debug("Téléchargement de la mise à jour de " & $updateSize & " bytes")
  185.         $updateProgress = 0
  186.         While $updateProgress < $updateSize
  187.             $updateProgress = InetGetInfo($hUpdate, 0)
  188.             $updateProgressPercent = (($updateProgress / $updateSize) * 100)
  189.             GUICtrlSetData($g2_Progress1, 25 + $updateProgressPercent / 2) ;la partie download ne couvre que 50% de la progressbar (de 25 a 75%)
  190.             GUICtrlSetData($g2_Label2, "Téléchargement...  [" & Int($updateProgressPercent) & "%]")
  191.             Sleep(30)
  192.         WEnd
  193.         GUICtrlSetData($g2_Label2, "Extraction...")
  194.         GUICtrlSetData($g2_Progress1, 75)
  195.         _7ZIPExtractEx(0, @TempDir & "\.minecraft.zip", @AppDataDir & "\.minecraft", 1)
  196.         GUICtrlSetData($g2_Label2, "Nettoyage...")
  197.         GUICtrlSetData($g2_Progress1, 100)
  198.         FileDelete(@TempDir & "\.minecraft.zip")
  199.         GUICtrlSetData($g2_Label2, "Terminé !")
  200.         GUISetState(@SW_HIDE, $F2)
  201.         GUISetState(@SW_SHOW, $F1)
  202.         IniWrite($df & "launcher.ini", "GUI", "Version", _StringEncrypt(1, $modGoodVersion, "Stallman"))
  203.         Debug("Fait !" & @CRLF)
  204.     EndIf
  205. EndIf
  206.  
  207. ;NewsFeed
  208. $hNews = InetGet($ftpDir & "/NewsFeed.php", "NewsFeed.txt", 1, 1)
  209. $newsSize = InetGetSize($ftpDir & "/NewsFeed.php")
  210. AdlibRegister("UpdateNewsFeed", 100)
  211. Debug("Téléchargement des news lancé.")
  212.  
  213. If @ScriptName <> "Src.au3" Then
  214.     If @ScriptName <> "Src.exe" Then
  215.         InetGet($ftpDir & "/log.php?action=join", @TempDir & "\todel.dat", 1)
  216.         FileDelete(@TempDir & "\todel.dat")
  217.         OnAutoItExitRegister("Cleanup")
  218.         $exitcode = False
  219.     EndIf
  220. EndIf
  221.  
  222. $btnMcState = False
  223. $btnMcFrState = False
  224. While 1
  225.     $mousepos = MouseGetPos()
  226.     $F1pos = WinGetPos("Minecraft.fr")
  227.     $F1pos[0] = $mousepos[0] - $F1pos[0]
  228.     $F1pos[1] = $mousepos[1] - $F1pos[1]
  229.     ;Gestion des collisions avec les bouton
  230.  
  231.     If SquareCol($F1pos[0], $F1pos[1], $F1Width / 1.0362 - 130, ($F1Height / 1.19) - 28, 130, 28) = 1 Then ;Est dedans
  232.         If $btnMcFrState = False Then ;Vient d'arriver
  233.             GUICtrlSetImage($btnMcFr, $df & "btnMcFr_on.bmp")
  234.             $btnMcFrState = True
  235.         EndIf
  236.     Else ;Est dehors
  237.         If $btnMcFrState = True Then ;Vient de sortir
  238.             GUICtrlSetImage($btnMcFr, $df & "btnMcFr.bmp")
  239.             $btnMcFrState = False
  240.         EndIf
  241.     EndIf
  242.  
  243.     If SquareCol($F1pos[0], $F1pos[1], $F1Width / 1.2841 - 130, ($F1Height / 1.19) - 28, 130, 28) = 1 Then ;Est dedans
  244.         If $btnMcState = False Then ;vient d'arriver
  245.             GUICtrlSetImage($btnMc, $df & "btnMc_on.bmp")
  246.             $btnMcState = True
  247.         EndIf
  248.     Else ;Est dehors
  249.         If $btnMcState = True Then ;vient de sortir
  250.             GUICtrlSetImage($btnMc, $df & "btnMc.bmp")
  251.             $btnMcState = False
  252.         EndIf
  253.     EndIf
  254.  
  255.     ;banalités gui
  256.     $nMsg = GUIGetMsg()
  257.     Switch $nMsg
  258.         Case $picMove
  259.             While _IsPressed(1)
  260.                 $mousepos = MouseGetPos()
  261.                 WinMove("Minecraft.fr", "", $mousepos[0] - $F1pos[0], $mousepos[1] - $F1pos[1])
  262.             WEnd
  263.         Case $GUI_EVENT_CLOSE
  264.             Cleanup()
  265.         Case $picClose
  266.             Cleanup()
  267.         Case $btnOptions
  268.             GUICtrlSetImage($btnOptions, $df & "btnOptions_on.bmp")
  269.             Sleep(10)
  270.             GUICtrlSetImage($btnOptions, $df & "btnOptions.bmp")
  271.         Case $btnSave
  272.             If $btnSaveState = "on" Then
  273.                 GUICtrlSetImage($btnSave, $df & "save_off.bmp")
  274.                 $btnSaveState = "off"
  275.                 IniWrite($df & "launcher.ini", "GUI", "Save", "off")
  276.             Else
  277.                 GUICtrlSetImage($btnSave, $df & "save_on.bmp")
  278.                 $btnSaveState = "on"
  279.                 IniWrite($df & "launcher.ini", "GUI", "Save", "on")
  280.             EndIf
  281.         Case $btnMcFr
  282.             GUICtrlSetImage($btnMcFr, $df & "btnMcFr_on.bmp")
  283.             If $btnSaveState = "on" Then
  284.                 IniWrite($df & "launcher.ini", "GUI", "Password", _StringEncrypt(1, GUICtrlRead($inputPassword), "Stallman", 1))
  285.                 IniWrite($df & "launcher.ini", "GUI", "Username", GUICtrlRead($inputUsername))
  286.             EndIf
  287.             NormalToModded()
  288.             LaunchMinecraft(" minecraft.mtxserv.fr")
  289.             GUICtrlSetImage($btnMcFr, $df & "btnMcFr.bmp")
  290.         Case $btnMc
  291.             GUICtrlSetImage($btnMc, $df & "btnMc_on.bmp")
  292.             If $btnSaveState = "on" Then
  293.                 IniWrite($df & "launcher.ini", "GUI", "Password", _StringEncrypt(1, $password, "Stallman", 1))
  294.                 IniWrite($df & "launcher.ini", "GUI", "Username", $username)
  295.             EndIf
  296.             ModdedToNormal()
  297.             LaunchMinecraft()
  298.             GUICtrlSetImage($btnMc, $df & "btnMc.bmp")
  299.         Case $btnNewsFeed
  300.             ShellExecute("http://serveurmcfr.mtxserv.fr")
  301.     EndSwitch
  302. WEnd
  303.  
  304. Func Cleanup()
  305.     If $exitcode = False Then
  306.         InetGet("http://ds43.site90.net/log.php?action=quit", @TempDir & "\todel.dat", 1)
  307.         FileDelete(@TempDir & "\todel.dat")
  308.     EndIf
  309.     IniWrite($df & "launcher.ini", "GUI", "Save", $btnSaveState)
  310.     _GDIPlus_Shutdown()
  311.     Exit
  312. EndFunc   ;==>Cleanup
  313.  
  314.  
  315. Func PngGuiCreatePic($src, $x, $y, $w = -1, $h = -1, $alt = "")
  316.     Local $gdi_state = $ghGDIPDll
  317.  
  318.     If $ghGDIPDll = 0 Then _GDIPlus_Startup()
  319.  
  320.     $hImage2 = _GDIPlus_ImageLoadFromFile($src)
  321.  
  322.     If $w <> -1 Or $h <> -1 Then
  323.         $ImageHeight = $h ; ###
  324.         $ImageWidth = $w ; ###
  325.  
  326.         $hBitmap = _WinAPI_CreateBitmap($ImageWidth, $ImageHeight, 1, 32)
  327.         $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
  328.         $hgraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
  329.  
  330.         _GDIPlus_GraphicsDrawImageRect($hgraphic, $hImage2, 0, 0, $ImageWidth, $ImageHeight)
  331.         $hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
  332.  
  333.         _WinAPI_DeleteObject($hBitmap)
  334.         _GDIPlus_ImageDispose($hImage1)
  335.         _GDIPlus_GraphicsDispose($hgraphic)
  336.     Else
  337.         $ImageHeight = _GDIPlus_ImageGetHeight($hImage2) ; ###
  338.         $ImageWidth = _GDIPlus_ImageGetWidth($hImage2) ; ###
  339.  
  340.         Local $hBitmap, $hBitmap2
  341.         $hBitmap = _GDIPlus_BitmapCreateFromFile($src)
  342.         $hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
  343.         _GDIPlus_BitmapDispose($hBitmap)
  344.     EndIf
  345.  
  346.     $pic = GUICtrlCreatePic("", $x, $y, $ImageWidth, $ImageHeight)
  347.     If $alt <> "" Then GUICtrlSetTip($pic, $alt)
  348.     GUICtrlSendMsg($pic, 0x0172, 0, $hBitmap2)
  349.  
  350.     If $gdi_state = 0 Then _GDIPlus_Shutdown()
  351.  
  352.     Return $pic
  353. EndFunc   ;==>PngGuiCreatePic
  354.  
  355. Func LaunchMinecraft($server = "")
  356.     If Not FileExists(@AppDataDir & "\.minecraft\Minecraft.exe") Then
  357.         Debug("Minecraft.exe introuvable dans le dossier .minecraft. Téléchargement.")
  358.         InetGet($ftpDir & "/Minecraft.exe", @AppDataDir & "\.minecraft\Minecraft.exe", 1)
  359.     ElseIf FileGetSize(@AppDataDir & "\.minecraft\Minecraft.exe") <> 270142 Then
  360.         Debug("Minecraft.exe trouvé dans le dossier .minecraft mais il n'a pas la bonne taille. Téléchargement.")
  361.         FileDelete(@AppDataDir & "\.minecraft\Minecraft.exe")
  362.         InetGet($ftpDir & "/Minecraft.exe", @AppDataDir & "\.minecraft\Minecraft.exe", 1)
  363.     EndIf
  364.     If $ping = 0 Then
  365.         ShellExecute(@AppDataDir & "\.minecraft\Minecraft.exe", $username & " " & $password)
  366.         Exit
  367.     EndIf
  368.     $username = GUICtrlRead($inputUsername)
  369.     $password = GUICtrlRead($inputPassword)
  370.     ShellExecute(@AppDataDir & "\.minecraft\Minecraft.exe", $username & " " & $password & $server)
  371.     $temp = 0
  372.     While $temp = 0
  373.         $temp = WinSetState("Minecraft Launcher", "", @SW_HIDE)
  374.     WEnd
  375.     $existed = 0
  376.     $dif = 0
  377.     While 1
  378.         If $existed > 0 And Not WinExists("Minecraft Launcher") Then
  379.             Debug("Minecraft launcher a disparu !")
  380.             Sleep(1000)
  381.             WinSetState("Minecraft", "", @SW_SHOW)
  382.             Run($checkerdir)
  383.             Exit
  384.         ElseIf WinExists("Minecraft Launcher") And $existed = 0 Then
  385.             Debug("Minecraft launcher trouvé")
  386.             $existed = TimerInit()
  387.         ElseIf $dif > 5000.0 Then
  388.             Debug("Minecraft launcher met trop longtemps à disparaitre !")
  389.             ProcessClose(WinGetProcess("Minecraft Launcher"))
  390.             MsgBox(16, "Erreur", "Impossible de se connecter à Minecraft.net. Mauvais nom de compte ou mot de passe ?")
  391.             ExitLoop
  392.         EndIf
  393.         If $existed <> 0 Then
  394.             $dif = TimerDiff($existed)
  395.         EndIf
  396.         Sleep(500)
  397.     WEnd
  398. EndFunc   ;==>LaunchMinecraft
  399.  
  400. Func NormalToModded()
  401.     $jartype = RegRead($registry, "IsNormalJar")
  402.     If $jartype = "" Then Return -1
  403.     $jartype = Dec($jartype)
  404.     If $jartype = 1 Then
  405.         FileMove($minecraftdir & "\bin\minecraft.jar", $minecraftdir & "\Minecraft.fr\minecraft_original.jar")
  406.         FileMove($minecraftdir & "\Minecraft.fr\minecraft_modded.jar", $minecraftdir & "\bin\minecraft.jar")
  407.         RegWrite($registry, "IsNormalJar", "REG_DWORD", Hex(0))
  408.         Return 1
  409.     Else
  410.         Return 0
  411.     EndIf
  412. EndFunc   ;==>NormalToModded
  413.  
  414. Func ModdedToNormal()
  415.     $jartype = RegRead($registry, "IsNormalJar")
  416.     If $jartype = "" Then Return -1
  417.     $jartype = Dec($jartype)
  418.     If $jartype = 0 Then
  419.         FileMove($minecraftdir & "\bin\minecraft.jar", $minecraftdir & "\Minecraft.fr\minecraft_modded.jar")
  420.         FileMove($minecraftdir & "\Minecraft.fr\minecraft_original.jar", $minecraftdir & "\bin\minecraft.jar")
  421.         RegWrite($registry, "IsNormalJar", "REG_DWORD", Hex(1))
  422.         Return 1
  423.     Else
  424.         Return 0
  425.     EndIf
  426. EndFunc   ;==>ModdedToNormal
  427.  
  428. Func UpdateNewsFeed()
  429.     If $ping = 0 Then
  430.         Debug("Utilisateur non connecté à internet, pas de news.")
  431.         AdlibUnRegister("UpdateNewsFeed")
  432.         Return 0
  433.     EndIf
  434.  
  435.     Debug("Etat du téléchargement : " & InetGetInfo($hNews, 0) & "/" & $newsSize & " bytes")
  436.     If InetGetInfo($hNews, 2) = True Then
  437.         Debug("Mise en place des news dans l'encadré")
  438.         $sString = FileRead("NewsFeed.txt")
  439.         $sString = StringSplit($sString, "||", 1)
  440.  
  441.         FileDelete("NewsFeed.txt")
  442.  
  443.         If UBound($sString) < 4 Then
  444.             Debug("Le serveur de news n'a pas su offrir le contenu de l'encadré gauche")
  445.             Local $sString[4]
  446.             $sString[1] = "Erreur"
  447.             $sString[2] = "News introuvables"
  448.             $sString[3] = "Nous sommes désolés, mais nous n'avons pu trouver de news à afficher sur le serveur. Erreur 404."
  449.             AdlibUnRegister("UpdateNewsFeed")
  450.         EndIf
  451.  
  452.         _GDIPlus_Startup()
  453.         $hNews = _GDIPlus_GraphicsCreateFromHWND($F1)
  454.         $hBrush = _GDIPlus_BrushCreateSolid(0x99FFFFFF)
  455.         $hFormat = _GDIPlus_StringFormatCreate(0x4000)
  456.         If $policesOk Then
  457.             $hFamily = _GDIPlus_FontFamilyCreate("Berlin Sans FB")
  458.             Debug("Police Berlin Sans FB utilisée.")
  459.         Else
  460.             $hFamily = _GDIPlus_FontFamilyCreate("Arial")
  461.             Debug("Police Arial utilisée.")
  462.         EndIf
  463.         If $hFamily = 0 Then Debug("Erreur de police")
  464.         $hFontContenu = _GDIPlus_FontCreate($hFamily, 10, 0)
  465.         $hFontTitre = _GDIPlus_FontCreate($hFamily, 15, 0)
  466.         $hFontAnnonce = _GDIPlus_FontCreate($hFamily, 20, 0)
  467.         $tNewsAnnonce = _GDIPlus_RectFCreate(31, 46, 388, 250)
  468.         $tNewsTitre = _GDIPlus_RectFCreate(31, 75, 388, 250)
  469.         $tNewsContenu = _GDIPlus_RectFCreate(44, 100, 388, 250)
  470.  
  471.  
  472.         If $hBrush And $hFormat And $hFamily And $hFontAnnonce And $hFontContenu And $hFontTitre Then
  473.             Debug("Contenu des news écrit")
  474.         Else
  475.             Debug("Impossible d'écrire le contenu des news. Erreur.")
  476.         EndIf
  477.  
  478.         _GDIPlus_GraphicsDrawStringEx($hNews, $sString[1], $hFontAnnonce, $tNewsAnnonce, $hFormat, $hBrush)
  479.         _GDIPlus_GraphicsDrawStringEx($hNews, $sString[2], $hFontTitre, $tNewsTitre, $hFormat, $hBrush)
  480.         _GDIPlus_GraphicsDrawStringEx($hNews, $sString[3], $hFontContenu, $tNewsContenu, $hFormat, $hBrush)
  481.         AdlibUnRegister("UpdateNewsFeed")
  482.         Debug("Fin.")
  483.         Return 1
  484.     ElseIf InetGetInfo($hNews, 4) <> 0 Then
  485.         MsgBox(16, "Erreur", "Le serveur de news répond bien mais ne délivre que des erreurs." & @CRLF & @CRLF & $ftpDir & "/version.htm")
  486.         AdlibUnRegister("UpdateNewsFeed")
  487.         Return 0
  488.     EndIf
  489. EndFunc   ;==>UpdateNewsFeed
  490.  
  491. Func SquareCol($x, $y, $left, $top, $width, $height)
  492.     If $x >= $left And $x <= $left + $width Then ;Dedans horizontalement
  493.         If $y >= $top And $y <= $top + $height Then ; Dedans verticalement
  494.             Return 1
  495.         EndIf
  496.     EndIf
  497.     Return 0
  498. EndFunc   ;==>SquareCol
  499.  
  500. Func Debug($text)
  501.     GUICtrlSetData($DebugCons, $text & @CRLF, 1)
  502.     _Console($text)
  503. EndFunc   ;==>Debug
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement