Configuration_MACXT = {}
MACXT_Programmes:NewAppli_MACXT()
MACXT_Repertoire:Anti_Bug()
Hauteur_Window = 125
Longueur_Window = 200
Window_Hauteur = Hauteur_Window
Window_Longueur = Longueur_Window
MACXT_Graphic:Init_New_Personnal_Window()
screen.waitVblankStart(20)
function Configuration_MACXT:Afficher_Fenetre()
   if Window_Hauteur > Hauteur_Window then
      MACXT_Repertoire:Reinitialiser_Window()
      MACXT_Graphic:Init_New_Personnal_Window()
      Window_Hauteur = Window_Hauteur - 5
   end
   if Window_Hauteur < Hauteur_Window then
      MACXT_Repertoire:Reinitialiser_Window()
      MACXT_Graphic:Init_New_Personnal_Window()
      Window_Hauteur = Window_Hauteur + 5
   end
   if Window_Longueur > Longueur_Window then
      MACXT_Repertoire:Reinitialiser_Window()
      MACXT_Graphic:Init_New_Personnal_Window()
      Window_Longueur = Window_Longueur - 5
   end
   if Window_Longueur < Longueur_Window then
      MACXT_Repertoire:Reinitialiser_Window()
      MACXT_Graphic:Init_New_Personnal_Window()
      Window_Longueur = Window_Longueur + 5
   end
   if Window_Hauteur ~= Hauteur_Window then
      Window_Hauteur = Hauteur_Window
   end
end
while true do
   MACXT_Graphic:Afficher_Wallpaper()
   Configuration_MACXT:Afficher_Fenetre()
   MACXT_Title = "Configurations Systeme"
   if Affichage_Principale == 1 then
      Hauteur_Window = 125
      Longueur_Window = 250
      MACXT_Texte_Window[1] = {Caption = "Options d'alimentation",Action = "Alimentation"}
      MACXT_Texte_Window[2] = {Caption = "Options de la dock",Action = "Dock_Systeme"}
      MACXT_Texte_Window[3] = {Caption = "Options de MACXT",Action = "Config_MACXT"}
      MACXT_Texte_Window[4] = {Caption = "Options de Police",Action = "Police_Systeme"}
      MACXT_Texte_Window[5] = {Caption = "Options sur l'apparence",Action = "Skin_Systeme"}
      if usb == 0 then
         MACXT_Texte_Window[6] = {Caption = "Activer Usb",Action = "Usb_Statut"}
       elseif usb == 1 then
         MACXT_Texte_Window[6] = {Caption = "Desactiver Usb",Action = "Usb_Statut"}
      end
      MACXT_Repertoire:Actualise_Texte_Window()
      NombreChoixMACXT = 6
      if Action_Window == "Usb_Statut" then
         if usb == 0 then
            System.usbDiskModeActivate()
            usb = 1
          elseif usb == 1 then
            System.usbDiskModeDeactivate()
            usb = 0
         end
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "Skin_Systeme" then
         Affichage_Principale = 0
         Afficher_Options_Skin_MACXT = 1
         MACXT_Graphic:New_Textes()
         MACXT_Repertoire:Reinitialiser_Window()
         Hauteur_Window = 65
         Longueur_Window = 150
         MACXT_Graphic:Init_New_Personnal_Window()
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "Config_MACXT" then
         Affichage_Principale = 0
         Afficher_Options_MACXT = 1
         MACXT_Graphic:New_Textes()
         MACXT_Repertoire:Reinitialiser_Window()
         Hauteur_Window = 120
         Longueur_Window = 150
         MACXT_Graphic:Init_New_Personnal_Window()
         REGISTRY:Read("MACXT","Vitesse_Souris")
      end
      if Action_Window == "Alimentation" then
         Affichage_Principale = 0
         Afficher_Options_Alim = 1
         MACXT_Graphic:New_Textes()
         MACXT_Repertoire:Reinitialiser_Window()
         Hauteur_Window = 65
         REGISTRY:Read("MACXT","Alimentation")
         REGISTRY:Read("MACXT","PSP_Alimentation")
      end
      if Action_Window == "Dock_Systeme" then
         Affichage_Principale = 0
         Afficher_Options_Dock = 1
         MACXT_Graphic:New_Textes()
         MACXT_Repertoire:Reinitialiser_Window()
         Hauteur_Window = 65
         MACXT_Graphic:Init_New_Personnal_Window()
         REGISTRY:Read("Dock","Afficher")
      end
   end
   MACXT_Objets_Barre[1] = {Caption = "PreferencesSysteme",Fonction = "Preferencessysteme"}
   MACXT_Objets_Barre[2] = {Caption = "Presentation",Fonction = "Presentation_PS"}
   if Fonction_Barre == "Preferencessysteme" then
      MACXT_Objets_Barre_Fonction[1] = {Caption = "A propos de PS",Action = "Propos_PS"}
      MACXT_Objets_Barre_Fonction[2] = {Caption = "Quitter PS",Action = "Quit_PS"}
      MACXT_Repertoire:Actualise_Fonction()
   end
   if Fonction_Barre == "Presentation_PS" then
      MACXT_Objets_Barre_Fonction[1] = {Caption = "Par icones",Action = "Presentation_icones"}
      MACXT_Objets_Barre_Fonction[2] = {Caption = "Par texte",Action = "Presentation_texte"}
      MACXT_Objets_Barre_Fonction[3] = {Caption = "Par boutons",Action = "Presentation_boutons"}
      MACXT_Repertoire:Actualise_Fonction()
   end
   MACXT_Repertoire:Actualise_Systeme_Barre()
   if Action_Barre == "Quit_PS" then
      Afficher_Personnal_Window = 0
      break
   end
   if Afficher_Options_Skin_MACXT == 1 then
      Hauteur_Window = 65
      Longueur_Window = 150
      NombreChoixMACXT = 3
      Longueur_Window = 220
      MACXT_Title = "Options sur l'apparence"
      MACXT_Texte_Window[1] = {Caption = "Charger un skin...",Action = "LoadSkinMACXT"}
      MACXT_Texte_Window[2] = {Caption = "Fond d'ecran par defaut",Action = "Default_FDE_MACXT"}
      MACXT_Texte_Window[3] = {Caption = "Retour",Action = "Retour_Avant"}
      MACXT_Repertoire:Actualise_Texte_Window()
      if Action_Window == "Default_FDE_MACXT" then
         filewallpaper = io.open("MACXT/Systeme/Registre/MACXT/Image_Wallpaper.MACXT","w")
         filewallpaperread = io.open("MACXT/Systeme/Registre/MACXT/Path_Wallpaper_Image.MACXT","r")
         filewallpaper:write(filewallpaperread:read("*a"))
         filewallpaper:close()
         filewallpaperread:close()
         REGISTRY:Write_On_File("MACXT","Wallpaper","Default_Directory = 1")
         filewallpaper = nil
         filewallpaperread = nil
         MACXT_Wallpaper = nil
         MACXT_Wallpaper = Image.load(MACXT_Path.."/MACXT/Systeme/Images/Wallpaper.png")
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "Retour_Avant" then
         Afficher_Options_Skin_MACXT = 0
         Affichage_Principale = 1
         Hauteur_Window = 125
         Longueur_Window = 250
         MACXT_Repertoire:Anti_Bug()
      end
   end
   if Afficher_Options_MACXT == 1 then
      NombreChoixMACXT = 4
      Longueur_Window = 230
      MACXT_Title = "Options MACXT"
      MACXT_Texte_Window[1] = {Caption = "Augmenter vitesse souris",Action = "+Souris"}
      MACXT_Texte_Window[2] = {Caption = "Diminuer vitesse souris",Action = "-Souris"}
      MACXT_Texte_Window[3] = {Caption = "Parametre par defaut",Action = "Reinitialiser_Vitesse"}
      MACXT_Texte_Window[4] = {Caption = "Retour",Action = "Retour_Avant"}
      MACXT_Texte_Window[5] = {Caption = "Vitesse actuelle : "..Vitesse_Souris}
      MACXT_Repertoire:Actualise_Texte_Window()
      if Action_Window == "-Souris" then
         Vitesse_Souris = Vitesse_Souris + 1
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "+Souris" then
         Vitesse_Souris = Vitesse_Souris - 1
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "Retour_Avant" then
         Afficher_Options_MACXT = 0
         Affichage_Principale = 1
         Hauteur_Window = 125
         Longueur_Window = 250
         MACXT_Repertoire:Anti_Bug()
      end
   end
   if Afficher_Options_Dock == 1 then
      NombreChoixMACXT = 3
      Longueur_Window = 240
      MACXT_Title = "Options de la dock"
      if Afficher_Dock_Programmes_Now == 0 then
         MACXT_Texte_Window[1] = {Caption = "Desactiver le masquage",Action = "Options_Masquage"}
       else
         MACXT_Texte_Window[1] = {Caption = "Activer le masquage",Action = "Options_Masquage"}
      end
      if Afficher_Aide_MACXT == 0 then
         MACXT_Texte_Window[2] = {Caption = "Afficher les noms",Action = "AfficherNoms"}
       else
         MACXT_Texte_Window[2] = {Caption = "Ne pas afficher les noms",Action = "AfficherNoms"}
      end
      MACXT_Texte_Window[3] = {Caption = "Retour",Action = "Retour_Avant"}
      MACXT_Repertoire:Actualise_Texte_Window()
      NombreChoixMACXT = 3
      if Action_Window == "AfficherNoms" then
         if Afficher_Aide_MACXT == 0 then
            REGISTRY:Write_On_File("Dock","Infos","Afficher_Aide_MACXT = 1")
            REGISTRY:Read("Dock","Infos")
          else
            REGISTRY:Write_On_File("Dock","Infos","Afficher_Aide_MACXT = 0")
            REGISTRY:Read("Dock","Infos")
         end
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "Options_Masquage" then
         if Afficher_Dock_Programmes_Now == 0 then
            VALUE_WRITE = "Afficher_Dock_Programmes_Now = 1"
          else
            VALUE_WRITE = "Afficher_Dock_Programmes_Now = 0"
         end
         REGISTRY:Write_On_File("Dock","Afficher",VALUE_WRITE)
         REGISTRY:Read("Dock","Afficher")
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "Retour_Avant" then
         Hauteur_Window = 125
         Longueur_Window = 250
         Afficher_Options_Dock = 0
         Affichage_Principale = 1
         MACXT_Repertoire:Anti_Bug()
      end
   end
   if Afficher_Options_Alim == 1 then
      Longueur_Window = 300
      MACXT_Title = "Options d'alimentation"
      if Quit_MACXT_Batt == 1 then
         MACXT_Texte_Window[1] = {Caption = "Arreter MACXT si batt < 10%:OUI",Action = "Alim_Op"}
       else
         MACXT_Texte_Window[1] = {Caption = "Arreter MACXT si batt < 10%:NON",Action = "Alim_Op"}
      end
      if Stop_PSP_Batt == 1 then
         MACXT_Texte_Window[2] = {Caption = "Arreter la psp si batt < 10% : OUI",Action = "Batt_Op"}
       else
         MACXT_Texte_Window[2] = {Caption = "Arreter la psp si batt < 10% : NON",Action = "Batt_Op"}
      end
      MACXT_Texte_Window[3] = {Caption = "Retour",Action = "Retour_Avant"}
      MACXT_Repertoire:Actualise_Texte_Window()
      NombreChoixMACXT = 3
      if Action_Window == "Batt_Op" then
         if Stop_PSP_Batt == 1 then
            VALUE_WRITE = "Stop_PSP_Batt = 0"
          else
            VALUE_WRITE = "Stop_PSP_Batt = 1"
         end
         REGISTRY:Write_On_File("MACXT","PSP_Alimentation",VALUE_WRITE)
         REGISTRY:Read("MACXT","PSP_Alimentation")
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "Alim_Op" then
         if Quit_MACXT_Batt == 1 then
            VALUE_WRITE = "Quit_MACXT_Batt = 0"
             else
            VALUE_WRITE = "Quit_MACXT_Batt = 1"
         end
         REGISTRY:Write_On_File("MACXT","Alimentation",VALUE_WRITE)
         REGISTRY:Read("MACXT","Alimentation")
         MACXT_Repertoire:Anti_Bug()
      end
      if Action_Window == "Retour_Avant" then
         Hauteur_Window = 125
         Longueur_Window = 250
         Afficher_Options_Alim = 0
         Affichage_Principale = 1
         MACXT_Repertoire:Anti_Bug()
      end
   end
   if Afficher_Personnal_Window ~= 1 then
      break
   end
   MACXT_Kernel:Kernel()
screen.waitVblankStart()
screen:flip()
end
