ini_set("rom_name",             "Energy");
ini_set("rom_author",           "NRGZ28");
ini_set("rom_device",           "HTC HD2");

splash(2000, "energize");

calibrate_matrix(
 "53685.00","315.00","-471240.00","-1700.00",
 "55760.00","-141270.00","65229.00","24"
);

  theme("sense");

textbox(
  "Changelog",
  "<b>Energy ROM Changelog</b>",
  "icons/info",
  readfile_aroma("changelog.txt")
);

textbox(
  "Requirements",
  "<b>Energy ROM Requirements</b>",
  "icons/info",
  readfile_aroma("require.txt")
);

menubox(
    "Energy ROM Installer",
    "Please select from menu below",
    "@personalize",
    "first.prop",    
    "<b>TMobile HD2 Installation to NAND</b>","Install ROM to internal storage","@default",
    "<b>EU/Asian HD2 Installation to EXT</b>","Install ROM to EXT partition","@customize",
    "System Info","Show device/partition information","@info",
    "Filemanager","Start the AROMA filemanager","@apps"
    );

if prop("first.prop","selected")=="3" then
  pleasewait("Getting System Information...");
  setvar(
      "sysinfo",
      "<@center><b>Your Device System Information</b></@>\n\n"+
      
      "Model\t\t\t: <b><#selectbg_g>"+sysprop("ro.product.model")+"</#></b>\n"+
      
      "CPU\t\t\t: <b><#selectbg_g>"+sysprop("ro.product.cpu.abi")+"</#></b>\n"+
      "LCD Density\t\t: <b><#selectbg_g>"+sysprop("ro.sf.lcd_density")+"</#></b>\n\n"+
      
      "System partition size\t: <b><#selectbg_g>"+getdisksize("/system","m")+" MB</#></b>\n"+
        "\tFree\t\t: <b><#selectbg_g>"+getdiskfree("/system","m")+" MB</#></b>\n\n"+
      "Data partition size\t: <b><#selectbg_g>"+getdisksize("/data","m")+" MB</#></b>\n"+
        "\tFree\t\t: <b><#selectbg_g>"+getdiskfree("/data","m")+" MB</#></b>\n\n"+
      "SDCard size\t\t: <b><#selectbg_g>"+getdisksize("/sdcard","m")+" MB</#></b>\n"+
        "\tFree\t\t: <b><#selectbg_g>"+getdiskfree("/sdcard","m")+" MB</#></b>\n\n"+
      "EXT partition size\t: <b><#selectbg_g>"+getdisksize("/sd-ext","m")+" MB</#></b>\n"+
        "\tFree\t\t: <b><#selectbg_g>"+getdiskfree("/sd-ext","m")+" MB</#></b>\n\n"+

      ""
  );
  
  textbox(
      "System Information",
      "Current system information may not be supported on all devices.",
      "@info",
      getvar("sysinfo")
  );
  
  back("2");
  
endif;

if prop("first.prop","selected")=="4" then
  restotmp("aromafm.cfg","aromafm.cfg");
  resexec("aromafm.sh");
  resexec("aromafm","1","0",prop("aromafm.prop","ziplocation"));
  #-- Back to Demo Menu ( 1 Wizard UI to Back )
  back("1");
endif;


selectbox(
  "Pre-Flash Options",
  "Please select whether to wipe /data or not",
  "icons/apps",
  "wipe.prop",
  
  "Install without wiping /data","",1,
  "Perform a full wipe","",0
);	
  
if prop("first.prop","selected")=="1" then

  writetmpfile(
	  "install.prop",
		  "mode=nand"
  );

endif;

if prop("first.prop","selected")=="2" then
 
  writetmpfile(
	  "install.prop",
		  "mode=ext"
  );

endif;


install(
  "Installing",
  "Installing Energy ROM...\nPlease Wait...",
  "icons/install"
);

# Set Next Text fo Finish
ini_set("text_next", "Finish");

viewbox(
  "Installation Completed",
  "Congratulations...</#>\n\n"+
  "Energy ROM has been installed\n\n"+
  "Press Finish and Reboot your phone.",
  "icons/info"
);
if
  confirm(
      "Reboot",
      "Reboot Now",
      "icons/info",
      "Reboot",
      "No"
  )=="yes"
then
  reboot("onfinish");
endif;