﻿### LICENSE:
#
# Copyright (C) 2011 Ahmad Amarullah ( http://amarullz.com/ )
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###

ini_set("rom_name","Sense of Eclipse");
ini_set("rom_version","3.90");
ini_set("rom_author","Daekin");
ini_set("rom_device","HTC HD2");
ini_set("rom_date","January 22,2013");

splash(2000,"splash");

fontresload("0","ttf/Roboto-Regular.ttf","12");
fontresload("1","ttf/Roboto-Regular.ttf","14");

theme("ics");

viewbox(
	"Welcome!",
	"\nYou are about to install:\n\n"+
	"<b><#selectbg_g>"+ini_get("rom_name")+" "+ini_get("rom_version")+
	"</#></b>\nby <b>"+ini_get("rom_author")+"</b>\n\n"+
	"Device:\t<b><#selectbg_g>"+ini_get("rom_device")+"</#></b>\n"+
	"Update:\t<b><#selectbg_g>"+ini_get("rom_date")+"</#></b>\n\n"+
	"Press <b>Next</b> to continue installation.",
	"@welcome"
);

agreebox(
	"Important Notice",
	"Please carefully read the Terms of Use!",
	"@agreement",
	resread("readme.txt"),
	"I agree with these Terms of Use",
	"You must agree with the Terms of Use to continue."
);

menubox(
	"Installation Type",
	"Please choose installation type:",
	"@confirm",
	"install.prop",
	"Update/Refresh","Install without wiping user data.\nNot advised if you are coming from another ROM or an older base.","@update",
	"Clean Installation","All user data will be removed.\nThe internal SD card content will remain untouched.","@install"
);

selectbox(
	"Data Partition Position",
	"Please select position of your\ndata partition:",
	"@default",
	"data.prop",
	"Third","/dev/block/mtdblock2",0,
	"Fourth","/dev/block/mtdblock3",0,
	"Fifth","/dev/block/mtdblock4",0,
	"Sixth","/dev/block/mtdblock5",1,
	"Seventh","/dev/block/mtdblock6",0
);

selectbox(
	"Installation Options",
	"Please select optional system components:",
	"@customize",
	"options.prop",
	"ZRAM","",2,
	"Enable","Higher performance using in-memory swap",1,
	"Disable","Better stability but slightly lower performance",0,
	"EGL Libraries","",2,
	"Classic","Better stability but no 3D previews",1,
	"Experimental","Fixed 3D previews but highly unstable",0,
	"Storage Mode","",2,
	"AD2SDX","Hybrid storage mode by Amarullz",0,
	"DA2SDM","Hybrid storage mode by Daekin",0,
	"DataOnEXT+DalvikOnNAND", "Hybrid storage mode by ph03n!x",1,
	"NAND","Native storage mode for T-Mobile HD2",0
);

pleasewait("Gathering system information...");
resexec("exec/checksys.sh");

if file_getprop("/tmp/aroma/device.prop","partitions") == "1" && prop("options.prop","selected.3") == "1" then
	alert(
		"Unsupported Configuration",
		"AD2SDX requires EXT4 partition!",
		"@alert"
	);
	back("1");
endif;

if file_getprop("/tmp/aroma/device.prop","partitions") == "1" && prop("options.prop","selected.3") == "2"  then
	alert(
		"Unsupported Configuration",
		"DA2SDM requires EXT4 partition!",
		"@alert"
	);
	back("1");
endif;

if file_getprop("/tmp/aroma/device.prop","partitions") == "1" && prop("options.prop","selected.3") == "3"  then
	alert(
		"Unsupported Configuration",
		"DataOnEXT+DalvikOnNAND requires EXT4 partition!",
		"@alert"
	);
	back("1");
endif;

if file_getprop("/tmp/aroma/device.prop","model") != "US" && prop("options.prop","selected.3") == "4" then
	alert(
		"Unsupported Configuration",
		"NAND storage mode is supported on T-Mobile HD2 only!",
		"@alert"
	);
	back("1");
endif;

ini_set("text_next","Install now");

viewbox(
	"Ready to install",
	"\nYou are now ready to begin installation.\n\n"+
	"Press <b>Install now</b> to start.\n\n"+
	"If you want to review or change any\nof your installation settings, press <b>Back</b>.",
	"@install"
);

ini_set("text_next", "Next");

install(
	"Installation",
	"Installing <b>"+ini_get("rom_name")+"</b>.\n"+
	"Please wait...",
	"@update",
	"Done!\nPress <b>Next</b> button."
);

ini_set("text_next","Finish");

viewbox(
	"Installation Successful",
	"\nYou are now running <b><#selectbg_g>"+ini_get("rom_name")+" "+ini_get("rom_version")+"</#></b>.\n\n"+
	"<b>Do at least 1 full system boot before flashing any mods.</b>\n\n"+
	"<#selectbg_g><b>Every donation to support author\nof this ROM is greatly appreciated!</b></#>\n\n",
	"@welcome"
);

exec("/sbin/cp","/tmp/aroma/.install.log","/sdcard/install.log");
