#!/bin/bash
#
#Copyright 2012 CurlyMo <development@xbian.org>
#
#This file is part of XBian - XBMC on the Raspberry Pi.
#
#XBian is free software: you can redistribute it and/or modify it under the
#terms of the GNU General Public License as published by the Free Software
#Foundation, either version 3 of the License,or (at your option) any later
#version.
#
#XBian is distributed in the hope that it will be useful,but WITHOUT ANY
#WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
#details.
#
#You should have received a copy of the GNU General Public License along
#with XBian. If not,see <http://www.gnu.org/licenses/>

# Shows the overclocking warning
function showOCWarningDlg() {
	wrapTxtFn "$(_ overclocking.warning)" $(($DEFAULTWIDTH-4));
	centerTxtFn "$WRAPPEDTXT"
	showMsgDlg "$WRAPPEDTXT" $HEIGHT
}

# Shows the overclocking settings radio dialog
#  $1 [Array] The rows of the radio dialog
function showOCSettingsDlg() {
	OCMENU=$1;
	createTableFn "radio"\
	"#;\Zb$(_ overclocking.label.preset);\ZbARM;\ZbCORE;\ZbSDRAM;\ZbOvervolt"\
	"${OCMENU[@]}";

	centerTxtFn "$HEADER" $(($DEFAULTWIDTH+7))
	showRadioDlg "$CENTEREDTXT" "$ROWS" ${#OCMENU[@]} $((${#OCMENU[@]}+10))
}

# Shows the overclocking settings not changed dialog
function showNoOCChangeDlg() {
	wrapTxtFn "$(_ overclocking.alreadyset)" $(($DEFAULTWIDTH-4));
	centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4));
	valignTxtFn "$CENTEREDTXT"
	showMsgDlg "$ALIGNEDTXT" $HEIGHT
}

# Shows the overclocking settings updated dialog
function showUpdatedOCDlg() {
	wrapTxtFn "$(_ overclocking.changed)" $(($DEFAULTWIDTH-4));
	centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4));
	valignTxtFn "$CENTEREDTXT"
	showMsgDlg "$ALIGNEDTXT" $HEIGHT
}

# Shows the custom overclocking settings dialog
#  $1 [Array] Space seperated values (ARM CORE SDRAM VOLTAGE) 
function showCustomOCDlg() {
	IFS=" ";
	SETTINGS=($1)
	IFS=$ORIGINALIFS;
	
	ELEMENTS=();
	ELEMENTS+=("1,3,ARM Freq,${SETTINGS[0]},16,5,4,0");
	ELEMENTS+=("1,3,ARM Freq,Mhz (700),22,11,10,2");
	ELEMENTS+=("2,3,Core Freq,${SETTINGS[1]},16,4,3,0");
	ELEMENTS+=("2,3,Core Freq,Mhz (250),21,22,11,2");
	ELEMENTS+=("3,3,SDRAM Freq,${SETTINGS[2]},16,4,3,0");
	ELEMENTS+=("3,3,ARM Freq,Mhz (400),21,11,10,2");
	ELEMENTS+=("4,3,Overvolt,${SETTINGS[3]},16,2,1,0");
	ELEMENTS+=("4,3,Overvolt,* .025V + 1.2V (0),19,22,21,2");
	
	showInputFormDlg "";
}

#Shows the empty fields dialog
function showOCEmptyFieldsDlg() {
	wrapTxtFn $(_ overclocking.empty_fields) $(($DEFAULTWIDTH-4));
	centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4));
	valignTxtFn "$CENTEREDTXT"
	showMsgDlg "$ALIGNEDTXT" $HEIGHT $DEFAULTWIDTH $_RETRY
	return $?;
} 
