var MAX_USER=6;
var SETUPUSR_LAUNCH_FOCUS_ICON=1;
var SETUPUSR_LAUNCH_FOCUS_NAME=2;
var SETUPUSR_LAUNCH_FOCUS_VOICE=3;
var SETUPUSR_LAUNCH_FOCUS_FACE=4;
var SETUPUSR_LAUNCH_FOCUS_HS=5;
var SETUPUSR_LAUNCH_FOCUS_MHC=6;
var me=HOME.editscreen_op;
me.visible_p=false;
me.screen=[{},{},{}];
me._active_screen=[null,null,null];
me._z_axis=-720;
me._y_axis=80;
me._x_axis=380;
me._angle=46;
me._side_x_pos=1920*1.4;
me._side_z_pos=-1920*1.4;
me._edit_panel_x=-1920*0.5+538*0.5;
me._edit_panel_size=[538,1080];
me._edit_option_size=[441,236];
me._power_on_option_size=[626,270];
me._bgedit_option_size=[444,236];
me._sound_option_size=[626,270];
me.is_move=false;
me.userIcon=new container({});
me.userIcon.init=function(){
if(this.components.length!=0)return;
this.visible_p=false;
this.translate=[me._edit_panel_size[0]/2,486,0];
this.components=[
this.base=new gimage({width:92,height:92,color:COL_POINT_ONBASE}),
this.userIcon=new gimage({width:80,height:80}),
];
this._visibility=false;};
me.userIcon.setSkin=function(usrprof_id){
this.init();
if(HOME.isMultiProfile()){
var uprofile=getProfile(usrprof_id)
if(uprofile){
var icon=uprofile.mhc.icon;
if(!(isString(icon)||icon instanceof Binary))icon="";
this.userIcon.src=icon;
this.base.src=IMG_PATH+"circle.png";
this.visible_p=(this._visibility==true);}else{
this.base.src="";
this.visible_p=false;
this.userIcon.src="";}
}
this.base.visible_p=false;};
me.userIcon.highlight=function(bool){
this.init();
this.base.visible_p=bool;}
me.userIcon.setVisible=function(bool){
this.init();
this._visibility=bool;
this.visible_p=(bool&&this.base.src);}

me.guide_org_font_size=48;
me.guide=new gtextbox({
translate:[1920/2-(1920-me._edit_panel_size[0])/2,490,0],
color:COL_TEXT_SUB_ONBASE,font_size:me.guide_org_font_size,
align:CENTER,valign:MIDDLE,width:1000,height:100,
text:"",visible_p:false});
change_font_size_b(me.guide);
AnimationGraphics.apply(me.guide);
me.components.unshift(me.guide);
me.guide.setText=function(text){
me.guide.font_size=me.guide_org_font_size;
setf_text(me.guide,text);
change_font_size_b(me.guide);};
me.guide.setEnable=function(b,func){
var self=this;
self.visible_p=b;
if(!this.timer)this.timer={};
delete_timer(this.timer);
append_timer(this.timer,300,function(obj){
delete_timer(obj);
if(!b){
self.visible_p=false;
if(func instanceof Function)func();}});};
me.isEditableScreen=function (){
var key=me._active_screen[1].getScreenKey();
var screen_info=me.getScreenInfo(key);
try{
return screen_info.editable;}catch(e){
return true;}
}
me.isFullTVScreen=function (plist){
if((plist.length==1)&&(plist[0]==TV_GADGET)){
return true;}
return false;}
me._createConfirmpanel=function (type,size,text,label,action_func,focus_moveto){
me.confirm=new Confirmpanel(type,[action_func],focus_moveto);
me.confirm.setMessageText(text);
me.confirm.setButtonLabel(label);
me.confirm.setTranslate(1920/2-(1920-460)/2,0,0);
me.confirm.setSize(size[0],size[1]);
var index=this.components.indexOf(me.focus);
if(index!=-1)this.components.splice(index,1);
var index2=this.components.indexOf(me.loading_circle);
if(index2!=-1)this.components.splice(index2,1);
me.components.push(me.confirm);
me.components.push(me.loading_circle);
me.components.push(me.focus);
me.confirm.setShow(true);
me.cursor=me.confirm;
me.cursor.onFocus(true);}
me._deleteConfirmpanel=function (){
me.confirm.setShow(false);
me.confirm.free();
var index=me.components.indexOf(me.confirm);
if(index!=-1)me.components.splice(index,1);}
me.init=function (){
me._initFileSelect();
me._initEditPanel();
me._initEditOption();
me._initBgEditOption();
me._initAddBookMarkPanel();
me._initBgEditPanel();
me._initPowerOnOption();
me._initSoundOption();
me.components.unshift(me.userIcon)
}
me._initEditPanel=function (){

var menu_list=[
{
title:LANG("LT_HOME_MOVE_ADD_REMOVE"),
mode:"NOT_FULL_TV",
download:false,
action:function(){
me.guide.setText(LANG("LT_HOME_SELECT_YOUR_APPS"));
me.guide.setEnable(true);
me.userIcon.setVisible(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true);
return true;},
highlights:function(bool){
var color=bool?COL_POINT:COL_TRANSPARENT;
me._active_screen[1].setGadgetFrameColor(color);},
},
{
title:LANG("LT_HOME_SCREEN_NAME"),
mode:"ALL",
download:false,
action:function(){
if(me.kbd&&me.kbd.visible_p)return;
require("kbd");
require("textarea");
me.screen_name=textarea.create({
width:320,height:48,font_size:27,
singleline:true,unconf_pos:"over",
});
me.screen_name.set_unconf_bg_param({
width:350,height:40,
color:[255,255,255,255],round_enable:false,
force_visible:false
});
me.screen_name.translate=[-184,410,0];
me.screen_name.set_visible(false);
me.screen_name.set_text(me._active_screen[1].getScreenName());
if(me.kbd==null){
me.kbd=Keyboard;
me.kbd.create("MIDIUM",[300,0,-200],me.screen_name);
me.components.push(me.kbd,me.screen_name);}else{
me.kbd.create("MIDIUM",[300,0,-200],me.screen_name);
me.components.push(me.kbd,me.screen_name);}
me._active_screen[1].setScreenNameFrameColor(COL_POINT);
var end_func=function(){
me.kbd.onFocus(false);
me.kbd.setShow(false,function(){
me._active_screen[1].setScreenNameShow(true);
me.screen_name.set_visible(false);
var index=me.components.indexOf(me.kbd);
if(index!=-1)me.components.splice(index,1);
index=me.components.indexOf(me.screen_name);
if(index!=-1)me.components.splice(index,1);
me.screen_name=null;
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true);
discard_package("kbd");});}
me.kbd.setAction(
function(text){
me._active_screen[1].setScreenName(text);
var key=me._active_screen[1].getScreenKey();
var screen_info=me.getScreenInfo(key);
screen_info.screen_name=text;
me.storeScreenInfo(screen_info,key);
end_func();},
function(){end_func();}
);
me.kbd.setShow(true,function(){
try{
me.screen_name.set_visible(true);
me._active_screen[1].setScreenNameShow(false);}catch(e){
}
});
me.cursor=me.kbd;
me.edit_panel.onFocus(false);
me.kbd.onFocus(true);
return true;},
highlights:function(bool){
var color=bool?COL_POINT:COL_TRANSPARENT;
me._active_screen[1].setScreenNameFrameColor(color);},
},
{
title:LANG("LT_HOME_BACKGROUND"),
mode:"NOT_FULL_TV",
download:false,
action:function(){
me.bg_edit_panel.setTranslate(1920*1.5,0,0);
me.guide.setText(LANG("LT_HOME_SELECT_BACKGROUND"));
me.guide.setEnable(true);
me.userIcon.setVisible(false);
me.bg_edit_panel.setShow(true);
me.bg_edit_panel.moveTo([0,0,0],[1920,200],0,80,null);
me.cursor=me.bg_edit_panel;
me.cursor.onFocus(true,true);
return true;},
highlights:function(bool){},
},
{
title:LANG("LT_HOME_SETTING_OWNER")||"Owner",
mode:"ALL",
download:true,
action:function(){

me.guide.setText(LANG("LT_HOME_SELECT_OWNER")||"Please select a user to set as an owner.");
me.guide.setEnable(true);
me.userIcon.setVisible(false);
var target=me._active_screen[1];
var focus_moveto=function(){
me.focus.moveTo.apply(me.focus,arguments);};
var show_focus=function(bool){
me.focus.setShow(bool);};
var return_action=function (finished_func){
target.activate(false);
target.moveTo([me._x_axis,me._y_axis,me._z_axis],null,null,160,function(){
target.activate(true);
if(finished_func)finished_func();});
me.cursor.onFocus(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,me.edit_panel.menu_index);
me.cursor.onFocus(true,true);
SetOwnerPanel.destroy(function(){
var id=me.components.indexOf(SetOwnerPanel);
if(id!=-1)me.components.splice(id,1);});};
var enter_action=function (usrprof_id){
var key=target.getScreenKey();
var info=me.getScreenInfo(key);
info.usrprof_id=usrprof_id;
if(me.storeScreenInfo(info,key)){
me.userIcon.setSkin(usrprof_id);}
HOME.GC_VoiceControlScreen();
try{
append_timer({},500,function(obj){
delete_timer(obj);
target.onFocus(false);
target.destroyGadgets();
target.createGadgets(info.uniq_id_list,true);
target.setEditMode(true);});}catch(e){
console.log(e.message);}
};
target.activate(false);
target.moveTo([1100,1220-40,-5000],null,null,160,function(){
target.activate(true);
SetOwnerPanel.init(focus_moveto,show_focus,enter_action,return_action);
var id=-1;
id=me.components.indexOf(SetOwnerPanel);
if(id!=-1)me.components.splice(id,1);
id=me.components.indexOf(me.guide);
me.components.splice(id+1,0,SetOwnerPanel);
me.cursor=SetOwnerPanel;
me.cursor.onFocus(true);});
return true;},
highlights:function(bool){
me.userIcon.highlight(bool);},
isShow:function(){
return HOME.isMultiProfile();},
isEnabled:function(){
var canSetOwner=true;
try{
canSetOwner=me._active_screen[1].canSetOwner();}catch(e){console.log(e.message);};
return canSetOwner;},
},
{
title:LANG("LT_HOME_POWER_ON_OPTION"),
mode:"ALL",
download:true,
action:function(){
me.cursor=me.power_on_option;
me.power_on_option.setShow(true,function(){
me.power_on_option.onFocus(true,true);});
return true;},
highlights:function(bool){},
},
{
title:LANG("LT_HOME_SETTING_SOUND"),
mode:"ALL",
download:true,
action:function(){
me.cursor=me.sound_option;
me.sound_option.setShow(true,function(){
me.sound_option.onFocus(true,true);});
return true;},
highlights:function(bool){},
}
];
if(!me.edit_panel){
me.edit_panel=new EditPanel(menu_list,me._edit_panel_size,
function(translate,size,alpha,speed,func){
var my_translate=[translate[0]+me._edit_panel_x,translate[1],
translate[2]];
me.focus.moveTo(my_translate,size,alpha,speed,func);},
function(bool){
me.focus.setShow(bool);},
function(w,h){
me.focus.setSize(w,h);},
function(x,y,z){
me.focus.stopAnimation();
me.focus.setTranslate(x+me._edit_panel_x,y,z);},
function(){
try{
var poweron=me.getPowerOnScreen();
var screen_info=me.getScreenInfo(poweron);}catch(e){
console.log("Screen Info eval error ");}
return screen_info.screen_name;},
function(word){
me.guide.setText(word);},
function(bool,func){
me.guide.setEnable(bool,func);}
);
me.edit_panel.visible_p=false;
AnimationGraphics.apply(me.edit_panel);
me.components.unshift(me.edit_panel);}
}
me._initEditOption=function (){

var option_list=[
{
title:LANG("LT_HOME_MOVE_THIS"),
action:function(selected){
if(selected==true){
me.edit_option.setMoveStatus(true);
me.guide.setEnable(false,function(){
me.guide.setText(LANG("LT_APPS_MOVE_SELECT_PLACE"));
me.guide.setEnable(true);});
me._active_screen[1].selectFocusedGadget(true);}else {
me.edit_option.setMoveStatus(false);
me.guide.setEnable(false,function(){
me.guide.setText(LANG("LT_HOME_SELECT_YOUR_APPS"));
me.guide.setEnable(true);});
me._active_screen[1].swapGadget();}
return false;},
cancel:function(){
me.edit_option.setMoveStatus(false);
me._active_screen[1].selectFocusedGadget(false);
me.edit_option.freeResource(true);},
},
{
title:LANG("LT_HOME_ADD_APP"),
action:function(){
me.edit_option.setShow(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true);
me.cursor.selectFocusedGadget(true);
me.cursor.activate(false);
var target=me.cursor;
target.moveTo2([me._x_axis,me._y_axis,me._z_axis],null,null,12,function(){
me.cursor.onFocus(true);
AddAppPanel.start_animation();
target.moveTo([1100,1220,-5000],null,null,80,function(){
target.activate(true);});});
var focus_moveto=function(){
me.focus.moveTo.apply(me.focus,arguments);};
var return_action=function (finished_func){
var target=me._active_screen[1];
target.selectFocusedGadget(false);
target.activate(false);
target.moveTo([me._x_axis,me._y_axis,me._z_axis],null,null,160,function(){
target.activate(true);
target.onFocus(true);
if(finished_func)finished_func();});
me.cursor=target;
AddAppPanel.destroy(function(){
var id=me.components.indexOf(AddAppPanel.applications);
if(id!=-1)me.components.splice(id,1);});};
var enter_action=function (product_id){
var uniq_id=me.getUniqID(product_id);
me.cursor=me._active_screen[1];
return_action(function(){
me._active_screen[1].addGadget(uniq_id);
me._storeProductIDList();});};
var cancel_action=function(){
return_action();};
AddAppPanel.init(focus_moveto,enter_action,cancel_action);
var id=me.components.indexOf(me.edit_panel);
if(id!=-1)me.components.splice(id,0,AddAppPanel.applications);
me.cursor=AddAppPanel;
return true;},
cancel:function(){
},
},
{
title:LANG("LT_HOME_DELETE_THIS"),
action:function(){
var product_id=me._active_screen[1].getFocusedProductId();
var uniq_id=me._active_screen[1].getFocusedUniqId();
var screen_key=me._active_screen[1].getScreenKey();
var vanished_id_list=me.getVanishProductIDs([product_id.toString()],screen_key);
if(vanished_id_list&&vanished_id_list.length!=0){
me._active_screen[1].vanish(vanished_id_list);}
var ret=me._active_screen[1].removeGadget();
me._storeProductIDList();
switch(product_id){
case WEBLINK_GADGET:
case SIGNAGELINK_GADGET:
me.add_bookmark_panel.deleteWeblinkTable(uniq_id);
break;}
return false;},
cancel:function(){
},
},
{
title:LANG("LT_HOME_ADD_BOOKMARK"),
action:function(){
me.add_bookmark_panel.setTranslate(1920*1.5,0,0);
me.edit_option.setShow(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true);
me.cursor.selectFocusedGadget(true);
me.add_bookmark_panel.setShow(true,"bookmark",
me._bookmark_list,function(id){me.add_bookmark_panel.addWeblinkTable(id);
me._active_screen[1].addGadget(id);
me._storeProductIDList();
me.add_bookmark_panel.setShow(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true);
me.cursor.selectFocusedGadget(false);},function(id){me._active_screen[1].selectFocusedGadget(false);});
me.add_bookmark_panel.moveTo([0,0,0],[1920,200],0,40,null);
me.cursor=me.add_bookmark_panel;
me.cursor.onFocus(true);
return true;},
cancel:function(){
me._active_screen[1].selectFocusedGadget(false);},
},
{
title:"サイネージを追加する",
action:function(){
me.add_bookmark_panel.setTranslate(1920*1.5,0,0);
me.edit_option.setShow(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true);
me.cursor.selectFocusedGadget(true);
me.add_bookmark_panel.setShow(true,"signage",
me._bookmark_list,function(id){me.add_bookmark_panel.addWeblinkTable(id);
me._active_screen[1].addGadget(id);
me._storeProductIDList();
me.add_bookmark_panel.setShow(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true);
me.cursor.selectFocusedGadget(false);},function(id){me._active_screen[1].selectFocusedGadget(false);});
me.add_bookmark_panel.moveTo([0,0,0],[1920,200],0,40,null);
me.cursor=me.add_bookmark_panel;
me.cursor.onFocus(true);
return true;},
cancel:function(){
me._active_screen[1].selectFocusedGadget(false);},
},
];
if(!me.edit_option){
me.edit_option=new EditOption(option_list,me._edit_option_size,
function(translate,size,alpha,speed,func){
var my_translate=[translate[0]+me.edit_option.translate[0],
translate[1]+me.edit_option.translate[1],translate[2]];
me.focus.moveTo(my_translate,size,alpha,speed,func);},
function(bool){
me.focus.setShow(bool);},
function(w,h){
me.focus.setSize(w,h);},
function(x,y,z){
me.focus.stopAnimation();
me.focus.setTranslate(x+me.edit_option.translate[0],y+
me.edit_option.translate[1],z);},
function(word){
me.guide.setText(word);}
);
me.edit_option.visible_p=false;
AnimationGraphics.apply(me.edit_option);
me.components.unshift(me.edit_option);}
}
me._initAddBookMarkPanel=function (){
if(!me.add_bookmark_panel){
me.add_bookmark_panel=new AddBookMarkPanel([1920,200],[0,-540+100,0],
function(){
me.focus.moveTo.apply(me.focus,arguments);});
me.add_bookmark_panel.visible_p=false;
AnimationGraphics.apply(me.add_bookmark_panel);
me.components.unshift(me.add_bookmark_panel);}
}
me._initFileSelect=function (){
if(!me.file_select_panel){
me.file_select_panel=FileSelect;
me.file_select_panel.create(
function(translate,size,alpha,speed,func){
var my_translate=[translate[0],translate[1],translate[2]];
me.focus.moveTo(my_translate,size,alpha,speed,func);},
function(bool,path){
if(bool==true){
me.file_select_panel.setShow(false);
me.bg_edit_panel.setImage(path);
me.cursor=me.bg_edit_panel;
me.cursor.onFocus(true,true);
me.guide.setEnable(true);}else{
me.file_select_panel.setShow(false);
me.cursor=me.bg_edit_panel;
me.cursor.onFocus(true,true);
me.guide.setEnable(true);}
},
function(){
me.bg_edit_panel.setShow(false);}
);
me.file_select_panel.visible_p=false;
me.components.unshift(me.file_select_panel);}
}
me._initBgEditPanel=function (){
var pop_up_func=function(icon_path,path){
me.bgedit_option.setTranslate(0,-540+325,0);
me.bgedit_option.setShow(true,icon_path,path);
me.cursor=me.bgedit_option;
me.bgedit_option.popup_open(function(){
me.cursor.onFocus(true,true);});};
var file_path="file://";
var extension=".jpg"
var dir_path="/usr/local/apps_nv/data/home/";
var f_name_bg="bg_";
var f_name_bg_icon="bg_icon_";
var bg_list=[
{
title:(LANG("LT_HOME_BACKGROUND")+" 1"),
path:DEFAULT_SCREEN_WALLPAPER,
icon_path:DEFAULT_SCREEN_WALLPAPER,
},
{
title:(LANG("LT_HOME_BACKGROUND")+" 2"),
path:IMG_PATH+"screen_back1.jpg",
icon_path:IMG_PATH+"screen_back1_icon.jpg",
},
{
title:(LANG("LT_HOME_BACKGROUND")+" 3"),
path:IMG_PATH+"screen_back2.jpg",
icon_path:IMG_PATH+"screen_back2_icon.jpg",
},
{
title:(LANG("LT_HOME_BACKGROUND")+" 4"),
path:IMG_PATH+"screen_back3.jpg",
icon_path:IMG_PATH+"screen_back3_icon.jpg",
},
{
title:(LANG("LT_HOME_BACKGROUND")+" 5"),
path:IMG_PATH+"screen_back4.jpg",
icon_path:IMG_PATH+"screen_back4_icon.jpg",
},
{
title:(LANG("LT_HOME_NEW_IMAGE")+"1"),
path:file_path+dir_path+f_name_bg+"1"+extension,
icon_path:file_path+dir_path+f_name_bg_icon+"1"+extension,
pop_up_action:pop_up_func,
file_select:function(){
me.guide.setEnable(false);
me.file_select_panel.setShow(true,
dir_path+f_name_bg+"1"+extension,
dir_path+f_name_bg_icon+"1"+extension);
me.cursor=me.file_select_panel;},
},
{
title:(LANG("LT_HOME_NEW_IMAGE")+"2"),
path:file_path+dir_path+f_name_bg+"2"+extension,
icon_path:file_path+dir_path+f_name_bg_icon+"2"+extension,
pop_up_action:pop_up_func,
file_select:function(){
me.guide.setEnable(false);
me.file_select_panel.setShow(true,
dir_path+f_name_bg+"2"+extension,
dir_path+f_name_bg_icon+"2"+extension);
me.cursor=me.file_select_panel;},
},
{
title:(LANG("LT_HOME_NEW_IMAGE")+"3"),
path:file_path+dir_path+f_name_bg+"3"+extension,
icon_path:file_path+dir_path+f_name_bg_icon+"3"+extension,
pop_up_action:pop_up_func,
file_select:function(){
me.guide.setEnable(false);
me.file_select_panel.setShow(true,
dir_path+f_name_bg+"3"+extension,
dir_path+f_name_bg_icon+"3"+extension);
me.cursor=me.file_select_panel;},
},
{
title:(LANG("LT_HOME_NEW_IMAGE")+"4"),
path:file_path+dir_path+f_name_bg+"4"+extension,
icon_path:file_path+dir_path+f_name_bg_icon+"4"+extension,
pop_up_action:pop_up_func,
file_select:function(){
me.guide.setEnable(false);
me.file_select_panel.setShow(true,
dir_path+f_name_bg+"4"+extension,
dir_path+f_name_bg_icon+"4"+extension);
me.cursor=me.file_select_panel;},
},
];
if(!me.bg_edit_panel){
me.bg_edit_panel=new BgEditPanel(bg_list,[1920,200],[0,-540+100,0],
function(translate,size,alpha,speed,func){
var my_translate=[translate[0],translate[1],translate[2]];
me.focus.moveTo(my_translate,size,alpha,speed,func);},
function(bool){
me.focus.setShow(bool);},
function(w,h){
me.focus.setSize(w,h);},
function(x,y,z){
me.focus.stopAnimation();
me.focus.setTranslate(x,y,z);},
function(path){
var key=me._active_screen[1].getScreenKey();
var screen_info=me.getScreenInfo(key);
screen_info.wallpaper=path;
me.storeScreenInfo(screen_info,key);
me._active_screen[1].setWallPaper(path);},
function(src_path,dec_path){
var screen_order=me.getScreenOrder();
for(var i=0;i<screen_order.length;i++){
var screen_info=me.getScreenInfo(screen_order[i]);
if(screen_info.wallpaper==src_path){
var key=screen_order[i];
screen_info.wallpaper=dec_path;
me.storeScreenInfo(screen_info,key);
for(var j=0;j<3;j++){
if(me._active_screen[j] instanceof Screen){
var active_screen_key=me._active_screen[j].getScreenKey();
if(active_screen_key==key){
me._active_screen[j].setWallPaper(dec_path);}
}
}
}
}
},
function(){
me.bg_edit_panel.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);}
);
me.bg_edit_panel.visible_p=false;
AnimationGraphics.apply(me.bg_edit_panel);
me.components.unshift(me.bg_edit_panel);}
}
me._initBgEditOption=function (){

var option_list=[
{
title:LANG("LT_HOME_SETTING_BACKGROUND"),
action:function(icon_path,path){
var key=me._active_screen[1].getScreenKey();
var screen_info=me.getScreenInfo(key);
screen_info.wallpaper=path;
me.storeScreenInfo(screen_info,key);
me._active_screen[1].setWallPaper(path);
me.bgedit_option.setShow(false);
me.bg_edit_panel.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);},
cancel:function(){
},
},
{
title:LANG("LT_HOME_REMOVE_BACKGROUND"),
action:function(icon_path,path){
var file_name=icon_path.substring(icon_path.lastIndexOf('/')+1,
icon_path.length);
HOME.clearUserBackground(file_name);
me.bgedit_option.setShow(false);
me.cursor=me.bg_edit_panel;
me.cursor.setDefaultImage(path);
me.cursor.deleteImage();
me.cursor.onFocus(true,true);
return true;},
cancel:function(){
},
},
];
if(!me.bgedit_option){
me.bgedit_option=new BgEditOption(option_list,me._bgedit_option_size,
function(translate,size,alpha,speed,func){
var my_translate=[translate[0]+me.bgedit_option.translate[0],
translate[1]+me.bgedit_option.translate[1],translate[2]];
me.focus.moveTo(my_translate,size,alpha,speed,func);},
function(bool){
me.focus.setShow(bool);},
function(w,h){
me.focus.setSize(w,h);},
function(x,y,z){
me.focus.stopAnimation();
me.focus.setTranslate(x+me.bgedit_option.translate[0],y+
me.bgedit_option.translate[1],z);},
function(word){
me.guide.setText(word);},
function(){
me.bg_edit_panel.setShow(false);}
);
me.bgedit_option.visible_p=false;
AnimationGraphics.apply(me.bgedit_option);
me.components.unshift(me.bgedit_option);}
}
me._setPowerOnLastScreen=function (){
var pon_select=null;
pon_select=me.getPowerOnSelect();
if(pon_select!="last"){
me.storePowerOnSelect("last");}
}
me._setPowerOnThisScreen=function (){
var pon_select=null;
pon_select=me.getPowerOnSelect();
me.storePowerOnSelect("fixed");
var screen_id=me._active_screen[1].getScreenKey();
me.storePowerOnScreen(screen_id);
var poweron=me.getPowerOnScreen();
var screen_info=me.getScreenInfo(poweron);
return screen_info.screen_name;}
me._setPowerOnFullTVScreen=function (){
var order=me.getScreenOrder();
var screen_id=order[0];
for(var i=0;i<order.length;i++){
if(isDLScreenKey(order[i]))continue;
var info=me.getScreenInfo(order[i]);
if(info.template=="tv"){
screen_id=order[i];
break;}
}
me.storePowerOnSelect("always tv");
me.storePowerOnScreen(screen_id);}

me._initPowerOnOption=function (){

var option_list=[
{
title:LANG("LT_HOME_LAST_VIEWD"),
isShow:function(screen_id){
return true;},
isCheck:function(pon_select,poweron,screen_id){
return (pon_select=="last");},
action:function(selected){
me._setPowerOnLastScreen();
return true;},
cancel:function(){
me.power_on_option.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);},
},
{
title:LANG("LT_HOME_ALWAYS_THIS"),
isShow:function(screen_id){
return true;},
isCheck:function(pon_select,poweron,screen_id){
if((pon_select=="fixed"&&poweron==screen_id)||
(pon_select=="always tv"&&poweron==screen_id))
return true;
return false;},
action:function(selected){
if(!(SHOW_TVINFO&&system.locale.language=="ja-JP")){
me._setPowerOnThisScreen();
return true;}
var screen_id=me._active_screen[1].getScreenKey();
var info=me.getScreenInfo(screen_id);
if(info.template=="tv"){
me._setPowerOnFullTVScreen();}else{
me._setPowerOnThisScreen();}
return true;},
cancel:function(){
me.power_on_option.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);},
},
{
title:"必ずテレビを全画面で表示",
isShow:function(screen_id){
if(!(SHOW_TVINFO&&system.locale.language=="ja-JP"))
return false;
var info=me.getScreenInfo(screen_id);
return (info.template!="tv");},
isCheck:function(pon_select,poweron,screen_id){
return (pon_select=="always tv");},
action:function(selected){
me._setPowerOnFullTVScreen();
return true;},
cancel:function(){
me.power_on_option.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);},
},
];
if(!me.power_on_option){
me.power_on_option=new PowerOnOption(option_list,
me._power_on_option_size,
function(translate,size,alpha,speed,func){
var my_translate=[translate[0]+me.power_on_option.translate[0],
translate[1]+me.power_on_option.translate[1],translate[2]];
me.focus.moveTo(my_translate,size,alpha,speed,func);},
function(bool){
me.focus.setShow(bool);},
function(w,h){
me.focus.setSize(w,h);},
function(x,y,z){
me.focus.stopAnimation();
me.focus.setTranslate(x+me.power_on_option.translate[0],y+
me.power_on_option.translate[1],z);},
function(){
return me.getScreenOrder();},
function(screen_id){
return me.getScreenInfo(screen_id);},
function(screen_id){
me.storePowerOnScreen(screen_id);},
function(){
return me.getPowerOnSelect();}
);
me.power_on_option.visible_p=false;
AnimationGraphics.apply(me.power_on_option);
me.components.unshift(me.power_on_option);}
}
me._initSoundOption=function (){

var option_list=[
{
title:LANG("LT_ON"),
action:function(selected){
HOME.HOME_SOUND_MUTE=false;
HOME.storeSoundMute(false);},
cancel:function(){
me.sound_option.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);},
},
{
title:LANG("LT_OFF"),
action:function(selected){
HOME.HOME_SOUND_MUTE=true;
HOME.storeSoundMute(true);},
cancel:function(){
me.sound_option.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);},
}
];
if(!me.sound_option){
me.sound_option=new SoundOption(option_list,me._sound_option_size,
function(translate,size,alpha,speed,func){
var my_translate=[translate[0]+me.sound_option.translate[0],
translate[1]+me.sound_option.translate[1],translate[2]];
me.focus.moveTo(my_translate,size,alpha,speed,func);},
function(bool){
me.focus.setShow(bool);},
function(w,h){
me.focus.setSize(w,h);},
function(x,y,z){
me.focus.stopAnimation();
me.focus.setTranslate(x+me.sound_option.translate[0],y+
me.sound_option.translate[1],z);}
);
me.sound_option.visible_p=false;
AnimationGraphics.apply(me.sound_option);
me.components.unshift(me.sound_option);}
}
me.in_hook=function (enable_screen){
if(!enable_screen)return;
me.is_move=true;
me.set_bg_img_flag=true;
me.userIcon.setVisible(false);
me.focus.setShow(false);
var id=me.components.indexOf(SetOwnerPanel);
if(id!=-1)me.components.splice(id,1);
for(var i=0;i<3;i++){
if(enable_screen[i]&&(me.components.indexOf(enable_screen[i])==-1)){
me._active_screen[i]=enable_screen[i];
me.screen[i]=enable_screen[i];
me.components.unshift(me.screen[i]);}
}
me.toolbar.setTranslate(0,TOOLBAR_Y,0);
me.visible_p=true;
if(me.screen[0] instanceof Screen){
me.screen[0].moveTo([-me._side_x_pos,0,me._side_z_pos],
[0,0],me._angle,40,null);
me.screen[0].setShow(false);}
if(me.screen[2] instanceof Screen){
me.screen[2].setShow(false);
me.screen[2].moveTo([me._side_x_pos,0,me._side_z_pos],
[0,0],-me._angle,40,null);}
me.screen[1].setShow(true);
me.screen[1].activate(false);
me.screen[1].setEditMode(true);
me.screen[1].setFullscreen(false);
me.screen[1].moveTo([me._x_axis,me._y_axis,me._z_axis],[1920,1080],0,20,
function(){
me.cursor=me.screen[1];
me.edit_panel.freeResource(false);
me.edit_panel.setTranslate(-1920,0,0);
me.edit_panel.setShow(true,me._active_screen[1].getTemplateName());
me.edit_panel.moveTo([me._edit_panel_x,0,0],me._edit_panel_size,0,40,
function(){
me.focus.setShow(true);
me.edit_panel.onFocus(true);
me.cursor=me.edit_panel;
me.screen[1].activate(true);
try{
system.set_enable_change_bg_img(true);}catch(e){};
me.is_move=false;
me.setHomeEventStatus(false);
me.set_bg_img_flag=false;
var screen_key=me._active_screen[1].getScreenKey();
var screen_order=me.getScreenOrder();
var current_index=screen_order.indexOf(screen_key);
var temp_name=me._active_screen[1].getTemplateName();
var info=me.getScreenInfo(screen_key);
if(isDLScreen(screen_key)){
if(info&&isString(info.org_id))
temp_name=info.org_id;}
LogReport.report(LogReport.OPERATE_HS,"hs.settings",
{action:"start",pos:current_index.toString(),template:temp_name,});
me.userIcon.init();
me.userIcon.setSkin(info.usrprof_id);});});}
me.out_hook=function (){
me.visible_p=false;
me.userIcon.setSkin(null);
var id=me.components.indexOf(SetOwnerPanel);
if(id!=-1)me.components.splice(id,1);
me.screen[1].setScreenNameFrameColor(COL_TRANSPARENT);
me.screen[1].setGadgetFrameColor(COL_TRANSPARENT);
try{
system.set_enable_change_bg_img(false);}catch(e){};
me.screen[1].onFocus(false);
me.focus.setShow(false);
me.edit_panel.moveTo([-1920,0,0],me._edit_panel_size,0,40,function(){
me.edit_panel.setShow(false);
me.edit_panel.freeResource(true);});
var my_length=me.components.length;
var index=0;
for(var i=0;i<my_length;i++){
if((me.components[index] instanceof Screen)){
me.components.splice(index,1);}else {
index++;}
}
return [me.screen[0],me.screen[1],me.screen[2]];}
me.key_hook=function (up_down,key){
if(me.is_move==true)return false;
if(up_down!=KEY_PRESS)return true;
if(me.cursor instanceof Screen){
if(me.cursor.getMoveStatus()==true)return true;
switch(key){
case TXK_HOME:
case TXK_EXIT:
if(me.edit_option.getMoveStatus()==true){
me.edit_option.r_option[me.edit_option.option_index].cancel();}
me.edit_option.freeResource(true);
me._storeProductIDList();
break;
case TXK_RETURN:
HOME.HomeSoundPlay("cancel");
if(me.edit_option.getMoveStatus()==true){
me.edit_option.r_option[me.edit_option.option_index].cancel();}
me.edit_option.freeResource(true);
me._storeProductIDList();
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);
return true;
break;
case TXK_ENTER:
if(me.edit_option.getMoveStatus()==false){
var gstatus=me.cursor.getFocusedGadgetStatus();
me.edit_option.setTranslate(260,0,0);
if(me.edit_option.setShow(true,gstatus)!=false){
me.cursor=me.edit_option;
var index=me.components.indexOf(me.focus);
if(index!=-1)me.components.splice(index,1);
index=me.components.indexOf(me.edit_option);
if(index!=-1)me.components.splice(index,1);
me.components.push(me.focus);
me.components.push(me.edit_option);
me.edit_option.popup_open(function(){
var index=me.components.indexOf(me.focus);
if(index!=-1)me.components.splice(index,1);
index=me.components.indexOf(me.edit_option);
if(index!=-1)me.components.splice(index,1);
me.components.push(me.edit_option);
me.components.push(me.focus);
me.cursor.onFocus(true);});}
}else {
me.edit_option.r_option[me.edit_option.option_index].action(false);}
HOME.HomeSoundPlay("enter");
return true;}
if(me.cursor&&me.cursor.key_hook
&&me.cursor.key_hook(up_down,key)){
return true;}
if(key==TXK_LEFT){
if(me.edit_option.getMoveStatus()==true){
me.edit_option.r_option[me.edit_option.option_index].cancel();}
me.edit_option.freeResource(true);
me._storeProductIDList();
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,this.menu_index);
me.cursor.onFocus(true,true);
HOME.HomeSoundPlay(0);
return true;}
}else {
if(me.cursor&&me.cursor.key_hook
&&me.cursor.key_hook(up_down,key)){
switch(key){
case TXK_UP:case TXK_DOWN:
case TXK_LEFT:case TXK_RIGHT:
HOME.HomeSoundPlay(0);
break;}
return true;}
}
switch(key){
case TXK_HOME:
case TXK_EXIT:
if(me.cursor instanceof Confirmpanel){
me.confirm.free();}
me.exitTask();
setf_text(me.guide,"");
me.cursor=me.screen[1];
me.cursor.onFocus(true);
me.switchUI(me,HOME.MY_SCREEN);
append_timer({},200,function(obj){
delete_timer(obj);
HOME.HomeSoundPlay("cancel");});
return true;}
return false;}
me._getBookMarkList=function (){
try{
var tmp=apps_nvram_file.read({"filename":"Bookmark",
async:false,finished:function(){},product_id:"home"});
if(tmp){
tmp=sysutil.tconv.binary_to_string(tmp);
me._bookmark_list=eval(tmp).bookmarkpanel;}else{
me._bookmark_list=[];}
}catch(e){
console.log(" nvram_file Bookmark error :Error = "+e.message);
me._bookmark_list=[];}
}
me._storeProductIDList=function (){
var key=me._active_screen[1].getScreenKey();
var screen_info=me.getScreenInfo(key);
screen_info.product_id_list=me._active_screen[1].getProductId();
screen_info.uniq_id_list=me._active_screen[1].getUniqId();
me.storeScreenInfo(screen_info,key);}

function EditOption(option_list,size,focus_moveto,focus_show,focus_size,focus_set,set_guide){
this.superClass=container;
this.superClass({});
this.width=size[0];
this.height=size[1];
this.back_mask_alpha=127;
this.back_mask=new gbox({width:1920*2,height:1080*2,
color:[0,0,0,0]});
this.popup=new this.PopUp({translate:[0,0,0],
width:this.width,height:this.height});
this.components.push(this.back_mask,this.popup);
AnimationGraphics.apply(this.back_mask);
this.option=[];
this.option_index=0;
this.move_status=false;this.is_move=false;
var option_len=option_list.length;
for(var i=0;i<option_len;i++){
this.option[i]=new this.Button({translate:[0,0,0],
width:this.width-60,height:55,title:option_list[i].title,});
this.option[i].action=option_list[i].action;
this.option[i].cancel=option_list[i].cancel;
this.components.push(this.option[i]);}
if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
if(focus_show instanceof Function){
this.showFocus=focus_show;}
if(focus_size instanceof Function){
this.sizeFocus=focus_size;}
if(focus_set instanceof Function){
this.setFocus=focus_set;}
if(set_guide instanceof Function){
this.setGuide=set_guide;}
}
EditOption.prototype.freeResource=function (bool){
if(bool){
this.popup.freeResource(true);
var option_len=this.option.length;
for(var i=0;i<option_len;i++){
this.option[i].freeResource(true);}
}else{
this.popup.freeResource(false);
var option_len=this.option.length;
for(var i=0;i<option_len;i++){
this.option[i].freeResource(false);}
}
}
EditOption.prototype.onFocus=function (bool,type){
var self=this;
if(bool==true){
this.option_index=0;
var focus_obj=this.r_option[0];
var my_width=this.width;
if(type){
self.is_move=true;
this.requestFocus(
[0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height+1],0,30,function(){self.is_move=false;});}else {
this.sizeFocus(focus_obj.width,focus_obj.height+1);
this.setFocus(0,focus_obj.translate[1],0);
this.showFocus(true);}
}else {
this.showFocus(false);}
}
EditOption.prototype.setShow=function (bool,gstatus){
var len=this.option.length;
for(var i=0;i<len;i++){
this.option[i].visible_p=false;}
if(bool==true){
if(gstatus){
var roption_num=0;
this.r_option=[];
this.option_index=0;
if(gstatus.addable==true){
me._getBookMarkList();
if(me._bookmark_list.length>0){
this.r_option[roption_num]=this.option[1];
roption_num++;
this.r_option[roption_num]=this.option[3];
roption_num++;}else{
this.option[1].action(true);
return false;}
if(me._active_screen[1].getTemplateName()=="signage"){
this.r_option[roption_num]=this.option[4];
roption_num++;}
}else{
if(gstatus.movable==true){
this.r_option[roption_num]=this.option[0];
roption_num++;}
if(gstatus.removable==true){
this.r_option[roption_num]=this.option[2];
roption_num++;}
}
if(roption_num==0){
return false;}else {
var btn_interval=20;
var btn_str_tr_x=-15;
if(roption_num==3){
btn_interval=6;
btn_str_tr_x=-10;}
if(roption_num!=1){
btn_str_tr_x=btn_str_tr_x+Math.floor(((roption_num-1)*
btn_interval+this.r_option[0].height*roption_num)/2)-
Math.floor(this.r_option[0].height/2);}
for(var i=0;i<roption_num;i++){
this.r_option[i].translate[1]=btn_str_tr_x-
(btn_interval+this.r_option[0].height)*i;
this.r_option[i].visible_p=true;}
this.freeResource(false);
this.visible_p=true;
this.translate=[
Math.floor((gstatus.translate[0]+380)*(-CAMERA_POS)/
(-CAMERA_POS+800)),
Math.floor((gstatus.translate[1])*(-CAMERA_POS)/
(-CAMERA_POS+800))-100,
0];}
this.back_mask.transparentTo(this.back_mask_alpha,500);}
}else {
this.visible_p=false;
this.popup_close();
this.back_mask.color[3]=0;}
force_redraw();}
EditOption.prototype.popup_open=function (end_func){
var self=this;
delete_timer(self);
self.is_move=true;
self.popup.open(this.height,function(){
self.is_move=false;
if(end_func){
end_func();}
});}
EditOption.prototype.popup_close=function (){
this.popup.close(56);}
EditOption.prototype.getMoveStatus=function (){
return this.move_status;}
EditOption.prototype.setMoveStatus=function (bool){
this.move_status=bool;}
EditOption.prototype.key_hook=function (up_down,key){
var self=this;
if((key==TXK_HOME)||(key==TXK_EXIT)){
delete_timer(self);
this.setShow(false);
return false;}
if(self.is_move==true)return;
switch(key){
case TXK_UP:
if(this.option_index==0)return false;
this.option_index--;
var focus_obj=this.r_option[this.option_index];
self.is_move=true;
this.requestFocus(
[0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height+1],0,30,function(){self.is_move=false;});
return true;
case TXK_DOWN:
if(this.option_index==this.r_option.length-1)return false;
this.option_index++;
var focus_obj=this.r_option[this.option_index];
self.is_move=true;
this.requestFocus(
[0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height+1],0,30,function(){self.is_move=false;});
return true;
case TXK_ENTER:
HOME.HomeSoundPlay("enter");
self.is_move=true;
append_timer(self,200,function(self){
delete_timer(self);
self.is_move=false;
var ret=false;
if(me.edit_option.r_option[me.edit_option.option_index]){
ret=me.edit_option.r_option[me.edit_option.option_index].action(true);}
if(ret==false){
me.edit_option.setShow(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true,key);}
});
return true;
case TXK_RETURN:
HOME.HomeSoundPlay("cancel");
me.edit_option.setShow(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true,key);
return true;}
return false;}

EditOption.prototype.PopUp=function(param){
this.popup_t1_src=IMG_PATH+"edit_option_t1.png";
this.popup_t2_src=IMG_PATH+"edit_option_t2.png";
this.popup_m1_src=IMG_PATH+"edit_option_m1.png";
this.popup_m2_src=IMG_PATH+"edit_option_m2.png";
this.popup_b1_src=IMG_PATH+"edit_option_b1.png";
this.popup_b2_src=IMG_PATH+"edit_option_b2.png";
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.popup_t_border=new gimage({width:this.width,height:36,
color:COL_POP_BORDER,
draw_type:DIRECT,src:this.popup_t1_src,}),
this.popup_m_border=new gimage({height:this.height-36-18,
width:this.width,
color:COL_POP_BORDER,
draw_type:DIRECT,src:this.popup_m1_src,}),
this.popup_b_border=new gimage({width:this.width,height:18,
color:COL_POP_BORDER,
draw_type:DIRECT,src:this.popup_b1_src,}),
this.popup_t=new gimage({width:this.width,height:36,
translate:[0,this.height/2-18,0],
color:COL_POP_A,
draw_type:DIRECT,src:this.popup_t2_src,}),
this.popup_m=new gimage({translate:[0,-9,0],width:this.width,
height:this.height-36-18,
color:COL_POP_A,
draw_type:DIRECT,src:this.popup_m2_src,}),
this.popup_b=new gimage({width:this.width,height:18,
translate:[0,-this.height/2+9,0],
color:COL_POP_A,
draw_type:DIRECT,src:this.popup_b2_src,}),
]
});
this.popup_t_border.translate=this.popup_t.translate;
this.popup_m_border.translate=this.popup_m.translate;
this.popup_b_border.translate=this.popup_b.translate;};
EditOption.prototype.PopUp.prototype.open=function(height,end_func){
delete_timer(this);
append_timer(this,10,function(self,count){
delete_timer(self);
if(end_func){
end_func();}
force_redraw();});};
EditOption.prototype.PopUp.prototype.close=function(height){};
EditOption.prototype.PopUp.prototype.freeResource=function(bool){
if(this.isResource==bool)return;
this.isResource=bool;
gimageResource(this.popup_t_border,bool);
gimageResource(this.popup_m_border,bool);
gimageResource(this.popup_b_border,bool);
gimageResource(this.popup_t,bool);
gimageResource(this.popup_m,bool);
gimageResource(this.popup_b,bool);}

EditOption.prototype.Button=function(param){
this.title=param.title;
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.text=new gtext({width:this.width-36,align:LC_TEXT_ALIGN,
color:COL_TEXT_ONBASE,
translate:[0,0,0],font_size:36,text:this.title,}),
]
});
change_font_size(this.text);};
EditOption.prototype.Button.prototype.freeResource=function(bool){
if(this.isResource==bool)return;
this.isResource=bool;
gtextResource(this.text,bool);}


function EditPanel(menu_list,size,focus_moveto,focus_show,focus_size,
focus_set,get_power_on_scname,set_guide,set_guide_enable){
this.superClass=container;
this.superClass({});
this.width=size[0];
this.height=size[1];
this.back_panel_src=IMG_PATH+"edit_panel.png";
this.title_src=LANG("LT_HOME_SETTINGS");
this.is_move=false;
this.back_panel=new gbox({width:this.width,height:this.height,
color:COL_BASE});
this.title=new gtextbox({translate:[0,1080*0.5-50,0],
color:COL_TEXT_SUB_ONBASE,font_size:52,align:CENTER,valign:MIDDLE,
width:this.width-100,height:107,text:this.title_src,});
change_font_size_b(this.title);
this.line_w=new gbox({translate:[0,-224,0],
width:this.width-10,height:2,color:COL_BORDER_ONBASE});
this.line_h=new gbox({translate:[538*0.5,0,0],
width:2,height:1080,color:COL_BORDER_ONBASE});
this.components.push(this.back_panel,this.title,this.line_w,this.line_h);
this.menu=[];
var list_len=menu_list.length;
for(var i=0,j=0;j<list_len;j++){
if(menu_list[j].isShow&&menu_list[j].isShow()==false)
continue;
this.menu[i]=new this.Button({translate:[0,1080*0.5-170-(126+4)*i,0],
title:menu_list[j].title,width:this.width-20-16,height:112,});
if(j==list_len-2)this.menu[i].translate=[0,-310,0];
if(j==list_len-1)this.menu[i].translate=[0,-440,0];
this.menu[i].action=menu_list[j].action;
this.menu[i].mode=menu_list[j].mode;
this.menu[i].download=menu_list[j].download;
this.menu[i].highlights=menu_list[j].highlights;
this.menu[i].isEnabled=menu_list[j].isEnabled;
this.components.push(this.menu[i]);
i++;}
this.powe_option_guide=new gtext({
translate:[0,-410,0],
color:COL_TEXT_ONBASE,font_size:34,align:LC_TEXT_ALIGN,width:this.width-100,
text:"",omitter:"...",visible_p:false});
this.components.push(this.powe_option_guide);
if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
if(focus_show instanceof Function){
this.showFocus=focus_show;}
if(focus_size instanceof Function){
this.sizeFocus=focus_size;}
if(focus_set instanceof Function){
this.setFocus=focus_set;}
if(get_power_on_scname instanceof Function){
this.getPower_On_Scname=get_power_on_scname;}
if(set_guide instanceof Function){
this.setGuide=set_guide;}
if(set_guide_enable instanceof Function){
this.setGuideEnable=set_guide_enable;}
}
EditPanel.prototype=new container({});
EditPanel.prototype.menu_index=0;
EditPanel.prototype.width=538;
EditPanel.prototype.height=1080;
EditPanel.prototype.freeResource=function (bool){
if(bool){
if(this.back_panel.src=="")return;
this.back_panel_src=this.back_panel.src;
this.back_panel.src="";
this.title_src=this.title.text;
setf_text(this.title,"");
var menu_len=this.menu.length;
for(var i=0;i<menu_len;i++){
this.menu[i].freeResource(true);}
}else{
this.back_panel.src=this.back_panel_src;
setf_text(this.title,this.title_src);
var menu_len=this.menu.length;
for(var i=0;i<menu_len;i++){
this.menu[i].freeResource(false);}
}
}
EditPanel.prototype.onFocus=function (bool,type){
if(bool==true){
me.userIcon.setVisible(bool);
var focus_obj=this.menu[this.menu_index];
if(me.isEditableScreen()){
focus_obj.highlights(bool);}
var my_width=this.width;
if(type){
this.requestFocus([0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height],0,30,null);}else {
this.sizeFocus(focus_obj.width,focus_obj.height);
this.setFocus(0,focus_obj.translate[1],0);
this.showFocus(true);}
var self=this;
this.setGuideEnable(false,function(){self.setGuide(LANG(""));});
setf_text(this.powe_option_guide,this.getPower_On_Scname());}else {
this.showFocus(false);
var focus_obj=this.menu[this.menu_index];
focus_obj.highlights(bool);}
}
EditPanel.prototype.setShow=function (bool,tmp_name){
var plist=me._active_screen[1].getProductId();
var is_fullTV=me.isFullTVScreen(plist);
if(bool==true){
for(var i=0,j=-1,max=this.menu.length;i<max;i++){
if(i==max-2)j=i-1;
var isEnabled=true;
if(this.menu[i]&&this.menu[i].isEnabled)
isEnabled=this.menu[i].isEnabled();
if((this.menu[i].mode=="ALL")||
((this.menu[i].mode=="NOT_FULL_TV")&&
(tmp_name!="tv")&&(is_fullTV!=true))){
this.menu[i].visible_p=true;
j++;}else{
this.menu[i].visible_p=false;}
if((this.menu[i].download==false)&&(!me.isEditableScreen())||!isEnabled){
this.menu[i].setTextColor(COL_WIDGET_SUB);}else {
this.menu[i].setTextColor(COL_TEXT_ONBASE);}
this.menu[i].translate[1]=1080*0.5-170-(126+4)*j;
if(j==max-2)this.menu[i].translate=[0,-310,0];
if(j==max-1)this.menu[i].translate=[0,-440,0];}
this.visible_p=true;}else {
this.selectMenu(false,this.menu_index);
this.visible_p=false;
this.menu_index=0;}
for(var i=0;i<this.menu.length;i++){
if(!this.menu[i].visible_p)continue;
this.menu_index=i;
break;}
}
EditPanel.prototype.selectMenu=function (bool,menu_index){
var len=this.menu.length;
var da=15;
for(var i=0;i<len;i++){
var isEnabled=true;
if(this.menu[i]&&this.menu[i].isEnabled)
isEnabled=this.menu[i].isEnabled();
if(bool&&(i==menu_index)){
this.menu[i].setTextColor(COL_POINT_ONBASE);}else if(this.menu[i].download==false&&!me.isEditableScreen()||!isEnabled){
this.menu[i].setTextColor(COL_WIDGET_SUB);}else{
this.menu[i].setTextColor(COL_TEXT_ONBASE);}
}
}
EditPanel.prototype.key_hook=function (up_down,key){
var self=this;
if(self.is_move==true)return false;
var last_menu_index=this.menu_index;
switch(key){
case TXK_UP:
for(var i=1;i<=this.menu_index;i++){
var next=this.menu[this.menu_index-i];
if(next&&next.visible_p){
this.menu_index=this.menu_index-i;
break;}
}
if(this.menu[last_menu_index])
this.menu[last_menu_index].highlights(false);
var focus_obj=this.menu[this.menu_index];
if(me.isEditableScreen()){
focus_obj.highlights(true);}
this.is_move=true;
this.requestFocus(
[0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height],0,30,
function(){
self.is_move=false;});
return true;
case TXK_DOWN:
for(var i=this.menu_index+1;i<this.menu.length;i++){
var next=this.menu[i];
if(next&&next.visible_p){
this.menu_index=i;
break;}
}
if(this.menu[last_menu_index])
this.menu[last_menu_index].highlights(false);
var focus_obj=this.menu[this.menu_index];
if(me.isEditableScreen()){
focus_obj.highlights(true);}
this.is_move=true;
this.requestFocus(
[0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height],0,30,
function(){
self.is_move=false;});
return true;
case TXK_ENTER:
var focus_obj=self.menu[self.menu_index];
var isEnabled=true;
if(focus_obj&&focus_obj.isEnabled)isEnabled=focus_obj.isEnabled();
if(isEnabled){
if(focus_obj.download==true
||(focus_obj.download==false&&me.isEditableScreen())){
HOME.HomeSoundPlay("enter");}
}
case TXK_RIGHT:
var focus_obj=self.menu[self.menu_index];
var isEnabled=true;
if(focus_obj&&focus_obj.isEnabled)isEnabled=focus_obj.isEnabled();
if(!isEnabled)return false;
if((((focus_obj.download==false)&&(!me.isEditableScreen())))){
return false;}
if(self.menu[self.menu_index]&&
self.menu[self.menu_index].action()){
self.selectMenu(true,self.menu_index);
return true;}else {
self.selectMenu(false,self.menu_index);
return false;}
case TXK_RETURN:
me.switchUI(me,HOME.MY_SCREEN);
append_timer({},200,function(obj){
delete_timer(obj);
HOME.HomeSoundPlay("cancel");});
return true;}
return false;}

EditPanel.prototype.Button=function(param){
this.title=param.title;
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.text=new gtextbox({width:this.width-90+16,height:87,
color:COL_TEXT_ONBASE,
align:LC_TEXT_ALIGN,valign:MIDDLE,font_size:36,text:this.title,}),
]
});};
EditPanel.prototype.Button.prototype.freeResource=function(bool){
if(this.isResource==bool)return;
this.isResource=bool;
gtextResource(this.text,bool);}
EditPanel.prototype.Button.prototype.setTextColor=function(col){
this.text.color=col;}


function AddBookMarkPanel(size,translate,focus_moveto){
this.superClass=container;
this.superClass({});
this.width=size[0];
this.height=size[1];
this._pos_y=translate[1];
this.app_width=160;
this.app_height=112;
this.bookmark_width=192;
this.bookmark_height=112;
this.app_max=11;
this.app_start_position=5;
this.app_position=[-1200,-960,-720,-480,-240,0,240,480,720,960,1200];
this.index=0;
this.selected_area=new gbox({translate:[0,this._pos_y,0],width:240,height:this.height,color:COL_FCS,visible_p:false,});
this.list_base=new container({translate:[0,this._pos_y,0],});
this.list_base.width=0;
this.list_base.height=0;
AnimationGraphics.apply(this.list_base);
if(this.list_base.moveToDirect){
this.list_base.moveTo=this.list_base.moveToDirect;}
this.components.push(this.selected_area,this.list_base);

if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
}
AddBookMarkPanel.prototype.onFocus=function (bool){
if(!bool)return;
this.requestFocus([0,this._pos_y,0],[240,this.height-16],0,30,null);}
AddBookMarkPanel.prototype.freeResource=function (bool){
if(bool){
if(this.app){
for(var i=0,max=this.app.length;i<max;i++){
this.app[i].freeResource(true);}
}
}else{
if(this.app){
for(var i=0,max=this.app.length;i<max;i++){
this.app[i].freeResource(false);}
}
}
}
AddBookMarkPanel.prototype.setShow=function (bool,mode,app_list,
enter_action,cancel_action){
this.index=0;
this.mode=mode;
if((bool==true)&&(this.visible_p==false)){
this.enter_action=enter_action;
this.cancel_action=cancel_action;
this.app_list=app_list;
this.app_num=this.app_list.length;
this.visible_p=true;
this.app=[];
for(var i=0;i<this.app_max;i++){if(this.mode=="apps"){
this.app[i]=new this.Icon({translate:[this.app_position[i],0,0],
height:this.height,
app_width:this.app_width,app_height:this.app_height,});}else {
this.app[i]=new this.Icon({translate:[this.app_position[i],0,0],
height:this.height,
app_width:this.bookmark_width,app_height:this.bookmark_height,});}
this.list_base.components.push(this.app[i]);
if(i>=this.app_start_position){
if((i-this.app_start_position)<this.app_num){
this.setIcon(this.app[i],this.app_list[i-this.app_start_position]);}
}
}
}else if(bool==false){
this.visible_p=false;
this.freeResource(true);}
force_redraw();
this.list_base.setTranslate(0,this._pos_y,0);}
AddBookMarkPanel.prototype.getTitle=function (id){
var me=this;
var title="";
var _product_id=id;
http_request({url:APPLI_PATH+id+"/Info.plist",
sync:true,method:"GET",
onload:function(status,header,body){
try{
if(status==200){
try{
title=body.match(new RegExp("^title."+system.locale.language.substr(0,5)+"=(.*)$","m"))[1];}catch(ex_no_key){
try{
title=body.match(new RegExp("^title."+system.locale.language.substr(0,2)+"=(.*)$","m"))[1];}catch(ex_never_key){
try{
title=body.match(new RegExp("^title=(.*)$","m"))[1];}catch(ex_no_title){
console.log("[ERROR] No title in \"Info.plist\". Please check ID="+_product_id);}
}
}
}else{
console.log("Cannot find \"Info.plist\" of ID="+_product_id);}
}catch(e){
console.log(e.message);}
}
});
return title;}
AddBookMarkPanel.prototype.setIcon=function (set_obj,data){
if(this.mode=="apps"){
set_obj.setData({
img_path:APPLI_PATH+data+"/icon.png",
title:this.getTitle(data),product_id:data});}else if(this.mode=="signage"){
try{
var img_data=apps_nvram_file.read({"filename":data.times+"",
async:false,finished:function(){},product_id:"home"});
set_obj.setData({img_path:img_data,
title:data.title,product_id:SIGNAGELINK_GADGET+data.id})
}catch(e){
console.log(" nvram_file error :Error = "+e.message);
set_obj.setData({img_path:IMG_PATH+"default_bookmark_img.png",
title:data.title,product_id:SIGNAGELINK_GADGET+data.id})
}
}else{
try{
var img_data=apps_nvram_file.read({"filename":data.times+"",
async:false,finished:function(){},product_id:"home"});
set_obj.setData({img_path:img_data,
title:data.title,product_id:WEBLINK_GADGET+data.id})
}catch(e){
console.log(" nvram_file error :Error = "+e.message);
set_obj.setData({img_path:IMG_PATH+"default_bookmark_img.png",
title:data.title,product_id:WEBLINK_GADGET+data.id})
}
}
}
AddBookMarkPanel.prototype.key_hook=function (up_down,key){
var tmp_obj;
var tmp_tr_x;
var tmp_index;
var data_obj;
switch(key){
case TXK_HOME:
case TXK_EXIT:
this.setShow(false);
this.cancel_action();
return false;
case TXK_RIGHT:
if(this.index==this.app_num-1)return false;
this.index++;
this.list_base.moveTo([-this.index*240,this._pos_y,0],[0,0],0,40,null);
tmp_tr_x=this.app[this.app_max-1].translate[0];
tmp_obj=this.app.shift();
tmp_index=this.index+this.app_start_position;
if(tmp_index<this.app_num){
data_obj=this.app_list[tmp_index];
this.setIcon(tmp_obj,data_obj)
}else{
tmp_obj.freeResource(true);}
tmp_obj.translate[0]=tmp_tr_x+240;
this.app.push(tmp_obj);
return true;
case TXK_LEFT:
if(this.index==0)return false;
this.index--;
this.list_base.moveTo([-this.index*240,this._pos_y,0],[0,0],0,40,null);
tmp_tr_x=this.app[0].translate[0];
tmp_obj=this.app.pop();
tmp_index=this.index-this.app_start_position;
if(0<=tmp_index){
data_obj=this.app_list[tmp_index];
this.setIcon(tmp_obj,data_obj)
}else{
tmp_obj.freeResource(true);}
tmp_obj.translate[0]=tmp_tr_x-240;
this.app.unshift(tmp_obj);
return true;
case TXK_ENTER:
HOME.HomeSoundPlay("enter");
switch(this.app[this.app_start_position].getId().substr(0,16)){
case WEBLINK_GADGET:
case SIGNAGELINK_GADGET:
this.enter_action(this.app[this.app_start_position].getId());
break;
default:var uniq_id=me.getUniqID(this.app[this.app_start_position].getId());
this.enter_action(uniq_id);}
return true;
case TXK_RETURN:
HOME.HomeSoundPlay("cancel");
this.cancel_action();
this.setShow(false);
me.cursor=me._active_screen[1];
me.cursor.onFocus(true,key);
return true;}
return false;}
AddBookMarkPanel.prototype.addWeblinkTable=function(uniq_id){
if((uniq_id==null)||(!isString(uniq_id))){
return;}
if(this.checkWeblinkCount(uniq_id)){
return;}
var bookmark_data=null;
var bookmark_id=uniq_id.substr(16,4);var url="";
try{
var tmp=null;
var nvram_file_list=apps_nvram_file.list({product_id:"home"});
if((nvram_file_list)&&(nvram_file_list.indexOf("Bookmark")!=-1)){
tmp=apps_nvram_file.read({"filename":"Bookmark",async:false,
finished:function(){},product_id:"home"});}
if(tmp){
tmp=sysutil.tconv.binary_to_string(tmp);
bookmark_data=eval(tmp);}else{
bookmark_data={};
bookmark_data.bookmarkpanel=[];}
}catch(e){
console.log(" nvram_file Bookmark error :Error = "+e.message);
bookmark_data={};
bookmark_data.bookmarkpanel=[];}
for(var i=0,max=bookmark_data.bookmarkpanel.length;i<max;i++){
if(bookmark_id==bookmark_data.bookmarkpanel[i].id){
url=bookmark_data.bookmarkpanel[i].url;
break;}
}
var weblink_data=null;
try{
var tmp=null;
var nvram_file_list=apps_nvram_file.list({product_id:"home"});
if((nvram_file_list)&&(nvram_file_list.indexOf("Weblink_table")!=-1)){
tmp=apps_nvram_file.read({"filename":"Weblink_table",async:false,
finished:function(){},product_id:"home"});}
if(tmp){
tmp=sysutil.tconv.binary_to_string(tmp);
weblink_data=eval(tmp);}else{
weblink_data={};
weblink_data.weblink_table=[];}
}catch(e){
console.log(" nvram_file Weblink_table error :Error = "+e.message);
weblink_data={};
weblink_data.weblink_table=[];}
var add_data={"id":bookmark_id,"url":url,};weblink_data.weblink_table.push(add_data);
try{
apps_nvram_file.write({"filename":"Weblink_table_bk","data":weblink_data.toSource(),
async:false,finished:function(){},product_id:"home"});
apps_nvram_file.rename({"from":"Weblink_table_bk","to":"Weblink_table",product_id:"home"});}catch(e){
console.log(" nvram_file write Weblink_table error :Error = "+e.message);}
}
AddBookMarkPanel.prototype.deleteWeblinkTable=function (uniq_id){
if((uniq_id==null)||(!isString(uniq_id))){
return;}
if(this.checkWeblinkCount(uniq_id)){
return;}
var weblink_data=null;
var weblink_id=uniq_id.substr(16,4);var index=0;try{
var tmp=null;
var nvram_file_list=apps_nvram_file.list({product_id:"home"});
if((nvram_file_list)&&(nvram_file_list.indexOf("Weblink_table")!=-1)){
tmp=apps_nvram_file.read({"filename":"Weblink_table",async:false,
finished:function(){},product_id:"home"});}
if(tmp){
tmp=sysutil.tconv.binary_to_string(tmp);
weblink_data=eval(tmp);}else{
weblink_data={};
weblink_data.weblink_table=[];}
}catch(e){
console.log(" nvram_file Weblink_table error :Error = "+e.message);
weblink_data={};
weblink_data.weblink_table=[];}
for(var i=0,max=weblink_data.weblink_table.length;i<max;i++){
if(weblink_id==weblink_data.weblink_table[i].id){
index=i;
break;}
}
weblink_data.weblink_table.splice(index,1);
try{
apps_nvram_file.write({"filename":"Weblink_table_bk","data":weblink_data.toSource(),
async:false,finished:function(){},product_id:"home"});
apps_nvram_file.rename({"from":"Weblink_table_bk","to":"Weblink_table",product_id:"home"});}catch(e){
console.log(" nvram_file write Weblink_table error :Error = "+e.message);}
}
AddBookMarkPanel.prototype.checkWeblinkCount=function (uniq_id){
var screen_order=me.getScreenOrder();var screen_info=[];
var order_num=screen_order.length;
for(var i=0;i<order_num;i++){
screen_info[i]=me.getScreenInfo(screen_order[i]);
var index=screen_info[i].uniq_id_list.indexOf(uniq_id);
if(index!=-1){
return true;}
}
return false;}

AddBookMarkPanel.prototype.Icon=function(param){
this.product_id=null;
this.image_src="";
this.title="";
this.height=param.height;
this.app_width=param.app_width;
this.app_height=param.app_height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.text=new gtext({width:this.app_width+40,
color:[0,0,0,255],translate:[0,-this.height*0.5+40,0],
font_size:32,align:CENTER,omitter:"...",}),
this.image=new gimage({translate:[0,20,0],
color:[255,255,255,255],width:this.app_width,
height:this.app_height,draw_type:DIRECT,}),
]
});};
AddBookMarkPanel.prototype.Icon.prototype.setData=function(param){
this.product_id=param.product_id;
this.image_src=param.img_path;
this.title=param.title;
this.image.src=this.image_src;
setf_text(this.text,this.title);}
AddBookMarkPanel.prototype.Icon.prototype.getId=function(){
return this.product_id;}
AddBookMarkPanel.prototype.Icon.prototype.freeResource=function(bool){
if(bool){
if(this.image.src=="")return;
this.image_src=this.image.src;
this.image.src="";
setf_text(this.text,"");}else{
this.image.src=this.image_src;
setf_text(this.text,this.title);}
}

var AddAppPanel={};
AddAppPanel.init=function (focus_moveto,enter_action,cancel_action){
var APPS_POS_NORMAL=[240-12+32,40-140,0];
this.APPS_POS_NORMAL=APPS_POS_NORMAL;
if(!this.applications)
{
require("apps_plate");
provide("apps_plate");

var floor=function(val){return Math.floor(val);};
var floor_plus_one=function(val){return Math.floor(val)+1;};
var floor_plus_two=function(val){return Math.floor(val)+2;};
function focus_moveto2(pos,size,angle,speed,func){if(!speed)speed=32;
var pos2=[APPS_POS_NORMAL[0]+pos[0]*0.75,
APPS_POS_NORMAL[1]+pos[1]*0.75,
APPS_POS_NORMAL[2]+pos[2]*0.75+0.01];
var size2=[size[0]*0.75,size[1]*0.75];
focus_moveto(pos2.map(floor),size2.map(floor_plus_two),
angle,Math.max(32*(CONTEXT_SURFER?1:2),speed),func);};
function focus_moveto3(pos,size,angle,speed,func){if(!speed)speed=32;
var pos2=[APPS_POS_NORMAL[0]+pos[0]*0.75,
APPS_POS_NORMAL[1]+pos[1]*0.75,
APPS_POS_NORMAL[2]+pos[2]*0.75+0.01];
var size2=[size[0]*0.75,size[1]*0.75];
focus_moveto(pos2,size2.map(floor_plus_one),
angle,Math.max(32*(CONTEXT_SURFER?1:2),speed),func);};
this.recent=new apps_plate.FavoriteList(focus_moveto2);
this.recent.translate[1]=210-26;
this.apps_list=new apps_plate.AppsPlateOperator(focus_moveto3);
this.apps_list.translate[1]=-196-36;
this.applications=new apps_plate.ApplicationList(this.recent,this.apps_list);
this.timer={};}
var self=this;
if(focus_moveto instanceof Function)
this.focus_moveto=focus_moveto;
if(enter_action instanceof Function)
this.enter_action=enter_action;
if(cancel_action instanceof Function)
this.cancel_action=cancel_action;
var app_list=null;
try{
var ret=apps_nvram_file.read({filename:"apps_list",product_id:"home"});
ret=sysutil.tconv.binary_to_string(ret);
app_list=eval(ret);}catch(e){
app_list=null;}
this.applications.init();
this.applications.cursor=0;
this.recent.cursor=0;
this.apps_list.cursor=0;
this.applications.showRestrictedState(getAdultSetting());
this.applications.setDisableFunc(
function(id,application_icon){
if(id==TV_GADGET)return true;
return application_icon.restricted;});
this.applications.addApps(app_list,0);
this.applications.setSize(1440,810);
this.applications.setTranslate(APPS_POS_NORMAL[0],-1080,APPS_POS_NORMAL[2]);
append_timer(this.timer,500,function(obj){
self.applications.updateIcons();
force_redraw();});};
AddAppPanel.start_animation=function(){
var self=this;
var APPS_POS_NORMAL=this.APPS_POS_NORMAL;
this.applications.moveTo(APPS_POS_NORMAL,null,null,20,function(){
self.applications.onFocus(true);});};
AddAppPanel.focus_moveto=NULL_FUNCTION;
AddAppPanel.enter_action=NULL_FUNCTION;
AddAppPanel.cancel_action=NULL_FUNCTION;
AddAppPanel.destroy=function (finished_func){
delete_timer(this.timer);
var self=this;
this.applications.moveTo([this.APPS_POS_NORMAL[0],-1080,this.APPS_POS_NORMAL[1]],
null,null,40,function(){
self.applications.onFocus(false);
if(finished_func)finished_func();
delete self.recent;
delete self.apps_list;
delete self.applications;});};
AddAppPanel.onFocus=function (bool){
return this.applications.onFocus(bool);};
AddAppPanel.key_hook=function (up_down,key){
if(key!=TXK_ENTER){
if(this.applications.key_hook(up_down,key))
return true;}
switch(key){
case TXK_ENTER:
var info=this.applications.getCurrentProduct();
if(info&&isString(info[1])&&
info[1]!=TV_GADGET&&info[4]!=true)
{
this.focus_moveto([0,-730,0],null,null,9999);
this.enter_action(info[1]);}
return true;
case TXK_UP:
case TXK_RETURN:
this.cancel_action();
return true;
case TXK_HOME:
case TXK_EXIT:
this.cancel_action();
return false;
default:
break;}
return false;};

var Keyboard=new container({});
Keyboard.create=function(size,translate,textarea){
if(this.components.length>0)return;
this.width=0;
this.height=0;
this.translate=[translate[0],-550,translate[2]];
this.textarea=textarea;
kbd.set_skin_info({color:"WHITE",size:size});
this.kbd=kbd.create();
this.kbd.set_bg_alpha(230);
if(textarea)this.kbd.set_trg_textarea(this.textarea);
this.textarea.set_text_color(COL_TEXT_ONBASE);
this.textarea.set_reverse_text_color(COL_POINT_ONBASE);
this.components.push(this.kbd);
this.kbd.set_height_change_callback(this.change_kb_height);
this.change_kb_height(this.kbd.get_height());
if(!AnimationGraphics.instanceof(this))
AnimationGraphics.apply(this);}
Keyboard.setTextarea=function (textarea){
this.textarea=textarea;
this.kbd.set_trg_textarea(this.textarea);}
Keyboard.setShow=function (bool,end_func){
var self=this;
if(bool==true){
this.visible_p=true;
this.translate[1]=-540-this.height/2;
this.moveTo([this.translate[0],-540+this.height/2,this.translate[2]],
[0,this.height],0,40,end_func);
if(ebus&&ebus.kbd&&ebus.kbd.supported){
HOME.add_event_hook(ebus.kbd,this.kbd.usb_key_hook);}
if(ebus.asr)
HOME.add_event_hook(ebus.asr,this.kbd.asr_hook);}else {
this.moveTo([this.translate[0],-540-this.height/2,this.translate[2]],
[0,this.height],0,40,
function(){
HOME.del_event_hook(ebus.kbd);
HOME.del_event_hook(ebus.asr);
self.visible_p=false;
self.kbd.free();
self.components.splice(0,self.components.length);
end_func();}
);}
force_redraw();}
Keyboard.onFocus=function (bool){
if(bool==true){
this.cursor=this.kbd;
this.kbd.enter_focus();}else {
this.kbd.leave_focus();
this.cursor=null;}
}
Keyboard.change_kb_height=function(height){
var self=Keyboard;
self.height=height;
self.translate[1]=-540+self.height/2;
self.kbd.set_translate([0,height/2,0]);}
Keyboard.setAction=function (done_action,cancel_action){
var self=this;
var done_cb=(typeof done_action=="function")?done_action:null;
var cancel_cb=(typeof cancel_action=="function")?cancel_action:null;
this.doneAction=function(){
if(done_cb)done_cb(self.textarea.get_text());
append_timer({},200,function(obj){
delete_timer(obj);
HOME.HomeSoundPlay("enter");});}
this.cancelAction=function(){
if(cancel_cb)cancel_cb();
append_timer({},200,function(obj){
delete_timer(obj);
HOME.HomeSoundPlay("cancel");});}
this.kbd.set_done_callback(self.doneAction);
this.kbd.set_cancel_callback(self.cancelAction);}
Keyboard.setText=function (text){
if(text)this.kbd.setText(text);}
Keyboard.key_hook=function (up_down,key){
var ret=false;
if(this.cursor==this.kbd){
ret=this.kbd.keyhook(up_down,key);}
if(ret==false&&((key==TXK_HOME)||(key==TXK_EXIT))){
HOME.del_event_hook(ebus.kbd);
this.visible_p=false;
this.kbd.free();
this.components.splice(0,this.components.length);
me._active_screen[1].setScreenNameShow(true);
me.screen_name.set_visible(false);
var index=me.components.indexOf(this);
if(index!=-1)me.components.splice(index,1);
index=me.components.indexOf(me.screen_name);
if(index!=-1)me.components.splice(index,1);
me.screen_name=null;
discard_package("kbd");
return false;}
return ret;}


function BgEditPanel(bg_list,size,translate,focus_moveto,
focus_show,focus_size,focus_set,set_wallpaper,change_Image,return_func){
this.superClass=container;
this.superClass({});
this.width=size[0];
this.height=size[1];
this._pos_y=translate[1];
this.bg_list=bg_list;
this.bg_num=this.bg_list.length;
this.bg_width=160;
this.bg_height=90;
this.bg_max=11;
this.bg_start_position=5;
this.bg_position=[-1200,-960,-720,-480,-240,0,240,480,720,960,1200];
this.index=0;
this.bg=[];
this.selected_area=new gbox({translate:[0,this._pos_y,0],width:240,
height:this.height-20,color:COL_TRANSPARENT,visible_p:false,});
this.list_base=new container({translate:[0,this._pos_y,0],});
this.list_base.width=0;
this.list_base.height=0;
AnimationGraphics.apply(this.list_base);
this.components.push(this.selected_area,this.list_base);
if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
if(focus_show instanceof Function){
this.showFocus=focus_show;}
if(focus_size instanceof Function){
this.sizeFocus=focus_size;}
if(focus_set instanceof Function){
this.setFocus=focus_set;}
if(focus_set instanceof Function){
this.setWallPaper=set_wallpaper;}
if(change_Image instanceof Function){
this.changeImage=change_Image;}
if(return_func instanceof Function){
this.returnFunc=return_func;}
}
BgEditPanel.prototype.freeResource=function (bool){
if(bool){
if(this.bg){
for(var i=0,max=this.bg.length;i<max;i++){
this.bg[i].freeResource(true);}
this.bg=[];
this.list_base.components.splice(0,this.list_base.components.length);}
}else{
if(this.bg){
for(var i=0,max=this.bg.length;i<max;i++){
this.bg[i].freeResource(false);}
}
}
}
BgEditPanel.prototype.setShow=function (bool){
this.index=0;
if(bool==true){
this.visible_p=true;
if(this.bg.length!=0)return;
this.bg=[];
for(var i=0;i<this.bg_max;i++){this.bg[i]=new this.Icon({translate:[this.bg_position[i],0,0],
height:this.height,
bg_width:this.bg_width,bg_height:this.bg_height,});
this.list_base.components.push(this.bg[i]);
if(i>=this.bg_start_position){
if((i-this.bg_start_position)<this.bg_num){
var data_obj=this.bg_list[i-this.bg_start_position];
this.bg[i].setData({
img_path:data_obj.icon_path,
title:data_obj.title,bg_id:data_obj.bg_id});}
}
}
}else {
this.visible_p=false;
this.freeResource(true);}
force_redraw();
this.list_base.setTranslate(0,this._pos_y,0);}
BgEditPanel.prototype.onFocus=function (bool,type){
var self=this;
if(bool==true){
var focus_obj=this.selected_area;
var my_width=this.width;
if(type){
this.requestFocus([0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height],0,30,
function(obj){
self.selected_area.visible_p=true;});}else {
this.sizeFocus(focus_obj.width,focus_obj.height);
this.setFocus(0,focus_obj.translate[1],0);
this.showFocus(true);}
}else {
this.showFocus(false);}
}
BgEditPanel.prototype.reload=function (){
this.freeResource(true);
this.freeResource(false);}
BgEditPanel.prototype.setImage=function (img){
this.bg[this.bg_start_position].setImage(img);
force_redraw();}
BgEditPanel.prototype.deleteImage=function (){
this.bg[this.bg_start_position].deleteImage("");
force_redraw();}
BgEditPanel.prototype.setDefaultImage=function (path){
this.changeImage(path,this.bg_list[0].icon_path);}
BgEditPanel.prototype.key_hook=function (up_down,key){
var tmp_obj;
var tmp_tr_x;
var tmp_index;
var data_obj;
switch(key){
case TXK_HOME:
case TXK_EXIT:
this.setShow(false);
return false;
case TXK_RIGHT:
if(this.index==this.bg_num-1)return false;
this.index++;
this.list_base.moveTo([-this.index*240,this._pos_y,0],
[0,0],0,40,null);
tmp_tr_x=this.bg[this.bg_max-1].translate[0];
tmp_obj=this.bg.shift();
tmp_index=this.index+this.bg_start_position;
if(tmp_index<this.bg_num){
data_obj=this.bg_list[tmp_index];
tmp_obj.setData({img_path:data_obj.icon_path,
title:data_obj.title,bg_id:data_obj.bg_id});}else{
tmp_obj.freeResource(true);}
tmp_obj.translate[0]=tmp_tr_x+240;
this.bg.push(tmp_obj);
return true;
case TXK_LEFT:
if(this.index==0){
this.returnFunc();
return true;}
this.index--;
this.list_base.moveTo([-this.index*240,this._pos_y,0],
[0,0],0,40,null);
tmp_tr_x=this.bg[0].translate[0];
tmp_obj=this.bg.pop();
tmp_index=this.index-this.bg_start_position;
if(0<=tmp_index){
data_obj=this.bg_list[tmp_index];
tmp_obj.setData({img_path:data_obj.icon_path,
title:data_obj.title,bg_id:data_obj.bg_id});}else{
tmp_obj.freeResource(true);}
tmp_obj.translate[0]=tmp_tr_x-240;
this.bg.unshift(tmp_obj);
return true;
case TXK_ENTER:
var ret=false;
data_obj=this.bg_list[this.index];
if(this.bg[this.bg_start_position].getAddIconStatus()
==true){
data_obj.file_select();
ret=true;}else{
if(data_obj.pop_up_action){
data_obj.pop_up_action(data_obj.icon_path,data_obj.path);
ret=true;}else{
this.setWallPaper(data_obj.path);
ret=false;}
}
if(ret==false){
me.bg_edit_panel.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,me.edit_panel.menu_index);
me.cursor.onFocus(true,true);}
HOME.HomeSoundPlay("enter");
return true;
case TXK_RETURN:
HOME.HomeSoundPlay("cancel");
me.bg_edit_panel.setShow(false);
me.cursor=me.edit_panel;
me.edit_panel.selectMenu(false,me.edit_panel.menu_index);
me.cursor.onFocus(true,true);
return true;}
return false;}

BgEditPanel.prototype.Icon=function(param){
var self=this;
this.bg_id=null;
this.image_src="";
this.add_icon_src=IMG_PATH+"add_mark.png";
this.title="";
this.height=param.height;
this.bg_width=param.bg_width;
this.bg_height=param.bg_height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.text=new gtext({width:this.bg_width+40,
color:COL_TEXT_ONBASE,translate:[0,-this.height*0.5+40,0],
font_size:32,align:CENTER,}),
this.bg=new gbox({translate:[0,20,0],color:COL_BASE,visible_p:false,
width:this.bg_width,height:this.bg_height,}),
this.image=new gimage({translate:[0,20,0],
draw_type:DIRECT,
width:this.bg_width,height:this.bg_height,
onload:function(){
self.add_icon.visible_p=false;
self.bg.visible_p=true;
if(self.image.src==DEFAULT_SCREEN_WALLPAPER)
self.image.color=COL_TEXT_ONBASE;
force_redraw();},
onerror:function(){
self.add_icon.visible_p=true;
self.bg.visible_p=true;
force_redraw();},}),
this.add_icon=new gimage({translate:[0,16,0],
width:32*2,height:32*2,visible_p:false,
src:this.add_icon_src,}),
]
});};
BgEditPanel.prototype.Icon.prototype.getAddIconStatus=function(){
return this.add_icon.visible_p;}
BgEditPanel.prototype.Icon.prototype.setData=function(param){
this.bg_id=param.bg_id;
this.title=param.title;
this.image.src=param.img_path;
this.add_icon.src=this.add_icon_src;
setf_text(this.text,this.title);
change_font_size(this.text);}
BgEditPanel.prototype.Icon.prototype.freeResource=function(bool){
if(bool){
this.image.src="";
this.add_icon.src="";
this.bg.visible_p=false;
setf_text(this.text,"");}else{
}
}
BgEditPanel.prototype.Icon.prototype.setImage=function(img){
this.image.src=img;
this.add_icon.visible_p=false;}
BgEditPanel.prototype.Icon.prototype.deleteImage=function(){
this.image.src="";
this.add_icon.visible_p=true;
this.bg.visible_p=true;}


function BgEditOption(option_list,size,focus_moveto,focus_show,
focus_size,focus_set,set_guide,bg_edit_panel_close){
this.superClass=container;
this.superClass({});
this.width=size[0];
this.height=size[1];
this.back_mask_alpha=127;
this.back_mask=new gbox({width:1920*2,height:1080*2,
color:[0,0,0,0],});
this.popup=new this.PopUp({translate:[0,0,0],
width:this.width,height:this.height});
this.components.push(this.back_mask,this.popup);
AnimationGraphics.apply(this.back_mask);
this.option=[];
this.option_index=0;
this.move_status=false;this.is_move=false;
var option_len=option_list.length;
for(var i=0;i<option_len;i++){
this.option[i]=new this.Button({translate:[0,0,0],
width:this.width-60,height:54,title:option_list[i].title,});
this.option[i].action=option_list[i].action;
this.option[i].cancel=option_list[i].cancel;
this.components.push(this.option[i]);}
if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
if(focus_show instanceof Function){
this.showFocus=focus_show;}
if(focus_size instanceof Function){
this.sizeFocus=focus_size;}
if(focus_set instanceof Function){
this.setFocus=focus_set;}
if(set_guide instanceof Function){
this.setGuide=set_guide;}
if(bg_edit_panel_close instanceof Function){
this.closeBgEditPanel=bg_edit_panel_close;}
}
BgEditOption.prototype.freeResource=function (bool){
if(bool){
this.popup.freeResource(true);
var option_len=this.option.length;
for(var i=0;i<option_len;i++){
this.option[i].freeResource(true);}
}else{
this.popup.freeResource(false);
var option_len=this.option.length;
for(var i=0;i<option_len;i++){
this.option[i].freeResource(false);}
}
}
BgEditOption.prototype.onFocus=function (bool,type){
if(bool==true){
var self=this;
this.option_index=0;
var focus_obj=this.option[0];
var my_width=this.width;
if(type){
self.is_move=true;
this.requestFocus(
[0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height],0,30,function(){self.is_move=false;});}else {
this.sizeFocus(focus_obj.width,focus_obj.height);
this.setFocus(0,focus_obj.translate[1],0);
this.showFocus(true);}
}else {
this.showFocus(false);}
}
BgEditOption.prototype.setShow=function (bool,icon_path,path){
this.target_icon_path=icon_path;
this.target_path=path;
var len=this.option.length;
for(var i=0;i<len;i++){
this.option[i].visible_p=false;}
if(bool==true){
this.option_index=0;
var option_len=this.option.length;
var btn_interval=20;
var btn_str_tr_x=0;
if(option_len!=1){
btn_str_tr_x=btn_str_tr_x+Math.floor(((option_len-1)*
btn_interval+this.option[0].height*option_len)/2)-
Math.floor(this.option[0].height/2);}
for(var i=0;i<option_len;i++){
this.option[i].translate[1]=btn_str_tr_x-
(btn_interval+this.option[0].height)*i;
this.option[i].visible_p=true;}
this.freeResource(false);
this.visible_p=true;
this.back_mask.transparentTo(this.back_mask_alpha,500);this.setGuide("");
}else {
this.visible_p=false;
this.back_mask.color[3]=0;this.popup_close();}
force_redraw();}
BgEditOption.prototype.popup_open=function (end_func){
var self=this;
delete_timer(self);
self.is_move=true;
self.popup.open(this.height,function(){
self.is_move=false;
if(end_func){
end_func();}
});}
BgEditOption.prototype.popup_close=function (){
this.popup.close(56);}
BgEditOption.prototype.getMoveStatus=function (){
return this.move_status;}
BgEditOption.prototype.setMoveStatus=function (bool){
if(bool==true){
this.move_status=bool;}else {
this.move_status=bool;}
}
BgEditOption.prototype.key_hook=function (up_down,key){
console.log(" KEY BG EDIT OPTON ");
var self=this;
if((key==TXK_HOME)||(key==TXK_EXIT)){
this.closeBgEditPanel();
this.setShow(false);
return false;}
if(self.is_move==true)return;
switch(key){
case TXK_UP:
if(this.option_index==0)return false;
this.option_index--;
var focus_obj=this.option[this.option_index];
self.is_move=true;
this.requestFocus(
[0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height],0,30,function(){self.is_move=false;});
return true;
case TXK_DOWN:
if(this.option_index==this.option.length-1)return false;
this.option_index++;
var focus_obj=this.option[this.option_index];
self.is_move=true;
this.requestFocus(
[0,focus_obj.translate[1],0],
[focus_obj.width,focus_obj.height],0,30,function(){self.is_move=false;});
return true;
case TXK_ENTER:
var ret=false;
if(this.option[this.option_index].action){
ret=this.option[this.option_index].action(
this.target_icon_path,this.target_path);}
append_timer({},300,function(obj){
delete_timer(obj);
HOME.HomeSoundPlay("enter");});
return ret;
case TXK_RETURN:
HOME.HomeSoundPlay("cancel");
me.bgedit_option.setShow(false);
me.cursor=me.bg_edit_panel;
me.cursor.onFocus(true,true);
return true;}
return false;}

BgEditOption.prototype.PopUp=function(param){
this.popup_t1_src=IMG_PATH+"edit_option_b1.png";
this.popup_t2_src=IMG_PATH+"edit_option_b2.png";
this.popup_m1_src=IMG_PATH+"edit_option_m1.png";
this.popup_m2_src=IMG_PATH+"edit_option_m2.png";
this.popup_b1_src=IMG_PATH+"edit_option_t1.png";
this.popup_b2_src=IMG_PATH+"edit_option_t2.png";
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.popup_t_border=new gimage({width:this.width,height:18,
color:COL_POP_BORDER,
draw_type:DIRECT,src:this.popup_t1_src,
flip:FLIP_VERTICAL,}),
this.popup_m_border=new gimage({width:this.width,height:this.height-36-18,
color:COL_POP_BORDER,
draw_type:DIRECT,src:this.popup_m1_src,}),
this.popup_b_border=new gimage({width:this.width,height:36,
color:COL_POP_BORDER,
draw_type:DIRECT,src:this.popup_b1_src,
flip:FLIP_VERTICAL,}),
this.popup_t=new gimage({width:this.width,height:18,
translate:[0,this.height/2-27,0],
color:COL_POP_A,
draw_type:DIRECT,src:this.popup_t2_src,
flip:FLIP_VERTICAL,}),
this.popup_m=new gimage({translate:[0,-9,0],width:this.width,
height:this.height-36-18,
color:COL_POP_A,
draw_type:DIRECT,src:this.popup_m2_src,}),
this.popup_b=new gimage({width:this.width,height:36,
translate:[0,-this.height/2,0],
color:COL_POP_A,
draw_type:DIRECT,src:this.popup_b2_src,
flip:FLIP_VERTICAL,}),
]
});
this.popup_t_border.translate=this.popup_t.translate;
this.popup_m_border.translate=this.popup_m.translate;
this.popup_b_border.translate=this.popup_b.translate;};
BgEditOption.prototype.PopUp.prototype.open=function(height,end_func){
delete_timer(this);
append_timer(this,10,function(self,count){
delete_timer(self);
if(end_func){
end_func();}
force_redraw();});};
BgEditOption.prototype.PopUp.prototype.close=function(height){};
BgEditOption.prototype.PopUp.prototype.freeResource=function(bool){
if(this.isResource==bool)return;
this.isResource=bool;
gimageResource(this.popup_t_border,bool);
gimageResource(this.popup_m_border,bool);
gimageResource(this.popup_b_border,bool);
gimageResource(this.popup_t,bool);
gimageResource(this.popup_m,bool);
gimageResource(this.popup_b,bool);}

BgEditOption.prototype.Button=function(param){
this.title=param.title;
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.button_border=new gbox({width:this.width,height:this.height,
color:COL_BTN_BORDER}),
this.button=new gbox({width:this.width-4,height:this.height-4,
color:COL_BTN}),
this.text=new gtext({width:this.width-40,align:LC_TEXT_ALIGN,
color:COL_TEXT_ONBASE,
translate:[0,0,0],font_size:36,text:this.title,}),
]
});
change_font_size(this.text);};
BgEditOption.prototype.Button.prototype.freeResource=function(bool){
if(this.isResource==bool)return;
this.isResource=bool;
gtextResource(this.text,bool);}


var FileSelect=new container({});
FileSelect.create=function(focus_moveto,file_select_action,
bg_edit_panel_close){

this.back_mask=new gbox({width:1920*2,height:1080*2,color:[0,0,0,127],});
this.components.push(this.back_mask);
AnimationGraphics.apply(this.back_mask);
if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
if(file_select_action instanceof Function){
this.actionSelectFile=file_select_action;}
if(bg_edit_panel_close instanceof Function){
this.closeBgEditPanel=bg_edit_panel_close;}
}
FileSelect.filer_create=function (){
require("filer");
this.file_selector=new filer.gui();
discard_package("filer");
this.file_selector.setTitle(LANG("LT_HOME_NEW_IMAGE"));
this.file_selector.setImage(IMG_PATH+"filer_photo.png");
this.file_selector.setFilenameExtension(["jpeg","jpg","jpe"]);
var self=this;
var action_func=function(file_obj,bool){
if(bool==true)
{
if(file_obj==null){
self.actionSelectFile(false);
return true;}
else
{
var fileObj=self.file_selector.getFileObj();
if(fileObj.exists){
resize_jpeg(fileObj,self.path,960,540);
resize_jpeg(fileObj,self.icon_path,214,120);
self.setShow(false);}
self.actionSelectFile(true,"file://"+self.icon_path);
return true;}
}
else
{
self.actionSelectFile(false);
return true;}
return true;}
this.file_selector.init(this.requestFocus,action_func);
this.components.push(this.file_selector);
}
FileSelect.setShow=function (bool,path,icon_path){
if(bool==true){
this.path=path;
this.icon_path=icon_path;
this.filer_create();
this.visible_p=true;}else {
this.visible_p=false;
this.file_selector.freeResource();
var index=this.components.indexOf(this.file_selector);
if(index!=-1)this.components.splice(index,1);}
force_redraw();
}
FileSelect.onFocus=function (bool){
if(bool==true){
}else {
}
}
FileSelect.key_hook=function (up_down,key){
if(this.file_selector.key_hook(up_down,key)){
return true;}
if((key==TXK_HOME)||(key==TXK_EXIT)){
this.closeBgEditPanel();
this.setShow(false);}
return false;}


function PowerOnOption(option_list,size,focus_moveto,focus_show,
focus_size,focus_set,get_screen_order,get_screen_info,
store_poweron_screen,get_power_on_select){
this.superClass=container;
this.superClass({});
this.width=size[0];
this.height=size[1];
this.popup_num=0;
this.popup_tree_m=[];
this.popup_arry=[];
this.option_list=option_list;
this.popup_base_tr=[-115,-310,0];
this.back_mask_alpha=127;
this.back_mask=new gbox({width:1920*2,height:1080*2,
color:[0,0,0,0],});
this.components.push(this.back_mask);
AnimationGraphics.apply(this.back_mask);
this.is_move=false;
if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
if(focus_show instanceof Function){
this.showFocus=focus_show;}
if(focus_size instanceof Function){
this.sizeFocus=focus_size;}
if(focus_set instanceof Function){
this.setFocus=focus_set;}
if(get_screen_order instanceof Function){
this.getScreenOrder=get_screen_order;}
if(get_screen_info instanceof Function){
this.getScreenInfo=get_screen_info;}
if(store_poweron_screen instanceof Function){
this.storePowerOnScreen=store_poweron_screen;}
if(get_power_on_select instanceof Function){
this.getPowerOnSelect=get_power_on_select;}
}
PowerOnOption.prototype.onFocus=function (bool,type){
try{
if(bool==true){
var self=this;
var focus_obj_pa=this.popup_arry[this.popup_num-1];
var focus_obj=
focus_obj_pa.option[this.popup_arry[this.popup_num-1].option_index];
var my_width=this.width;
if(type){
self.is_move=true;
this.requestFocus(
[focus_obj_pa.translate[0]+focus_obj.translate[0],
focus_obj_pa.translate[1]+focus_obj.translate[1],
focus_obj_pa.translate[2]+focus_obj.translate[2]],
[focus_obj.width+2,focus_obj.height+2],0,30,function(){self.is_move=false;});}else {
this.sizeFocus(focus_obj.width+2,focus_obj.height+2);
this.setFocus(focus_obj_pa.translate[0]+focus_obj.translate[0],
focus_obj_pa.translate[1]+focus_obj.translate[1],
focus_obj_pa.translate[2]+focus_obj.translate[2]);
this.showFocus(true);}
}else {
this.showFocus(false);}
}catch(e){
}
}
PowerOnOption.prototype.popup_creat=function (){
var pre_obj;
var pre_option_obj;
if(this.popup_num==0){
this.popup_tree_m.push(0);}else{
var pre_option_index;
pre_option_index=this.popup_arry[this.popup_num-1].option_index;
this.popup_tree_m.push(pre_option_index);
pre_obj=this.popup_arry[this.popup_num-1];
pre_option_obj=
this.popup_arry[this.popup_num-1].option[pre_option_index];}
var obj=new container({});
var option_list_w=this.option_list;
obj.option=[];
obj.option_index=0;
for(var i=0;i<this.popup_num;i++){
option_list_w=
option_list_w[this.popup_tree_m[this.popup_num]].option_list;}
var screen_id=me._active_screen[1].getScreenKey();
var tmp_list=[];
for(var i=0;i<option_list_w.length;i++){
if(option_list_w[i].isShow(screen_id))
tmp_list.push(option_list_w[i]);}
option_list_w=tmp_list;
var option_len=option_list_w.length;
var btn_interval=5;
var btn_height=64;
obj.popup=new this.PopUp({translate:[0,0,0],
width:this.width,
height:40+option_len*btn_height+(option_len-1)*btn_interval});
obj.components.push(obj.popup);
for(var i=0;i<option_len;i++){
obj.option[i]=new this.Button({translate:[0,0,0],
width:this.width-60,height:btn_height,title:option_list_w[i].title,});
obj.option[i].action=option_list_w[i].action;
obj.option[i].cancel=option_list_w[i].cancel;
obj.option[i].isShow=option_list_w[i].isShow;
obj.option[i].isCheck=option_list_w[i].isCheck;
obj.components.push(obj.option[i]);}
var btn_str_tr_x=0;
if(option_len!=1){
btn_str_tr_x=btn_str_tr_x+Math.floor(((option_len-1)*
btn_interval+btn_height*option_len)/2)-
Math.floor(btn_height/2);}
for(var i=0;i<option_len;i++){
obj.option[i].translate[1]=btn_str_tr_x-
(btn_interval+btn_height)*i;
obj.option[i].visible_p=true;}
if(this.popup_num==0){
obj.translate=this.popup_base_tr;}else{
obj.translate=[
pre_obj.translate[0]+pre_option_obj.translate[0]+this.width*3/4,
pre_obj.translate[1]+pre_option_obj.translate[1],
pre_obj.translate[2]+pre_option_obj.translate[2],
];}
this.popup_arry.push(obj);
this.components.push(obj);
this.popup_num++;}
PowerOnOption.prototype.popup_open=function (end_func){
var self=this;
var obj=this.popup_arry[this.popup_num-1];
delete_timer(obj);
self.is_move=true;
obj.popup.open(this.width,function(){
self.is_move=false;
if(end_func){
end_func();}
});}
PowerOnOption.prototype.popup_close=function (){
var obj=this.popup_arry[this.popup_num-1];
for(var i=0;i<obj.option.length;i++){
obj.option[i].visible_p=false;}
obj.popup.close(30);};
PowerOnOption.prototype.popup_destroy=function (mode){
if(mode=="one"){
var obj=this.popup_arry[this.popup_num-1];
obj.visible_p=false;
obj.popup.destroy();
for(var i=0,max=obj.option.length;i<max;i++){
obj.option[i].destroy();}
obj.components.splice(0,obj.components.length);
this.popup_num--;
this.popup_tree_m.pop();
this.popup_arry.pop();}else{
this.visible_p=false;
for(var i=1;i<this.popup_num;i++){
var obj=this.popup_arry[this.popup_num-1];
obj.popup.destroy();
for(var i=0,max=obj.option.length;i<max;i++){
obj.option[i].destroy();}
obj.components.splice(0,obj.components.length);}
this.popup_num=0;
this.popup_tree_m=[];
this.popup_arry=[];}
}
PowerOnOption.prototype.setShow=function (bool,focus_func){
if(bool==true){
this.popup_creat();
this.popup_arry[0].translate=[-115,-310,0];
var obj=this.popup_arry[this.popup_num-1];
var pon_select=me.getPowerOnSelect();
var poweron=me.getPowerOnScreen();
var screen_id=me._active_screen[1].getScreenKey();
for(var i=0;i<obj.option.length;i++){
var ret=obj.option[i].isCheck(pon_select,poweron,screen_id);
obj.option[i].set_check(ret);
if(ret)obj.option_index=i;}
this.visible_p=true;
this.back_mask.transparentTo(this.back_mask_alpha,500);this.popup_open(focus_func);}else {
this.visible_p=false;
this.popup_close();
this.back_mask.color[3]=0;this.popup_destroy("all");}
force_redraw();}
PowerOnOption.prototype.key_hook=function (up_down,key){
var obj=this.popup_arry[this.popup_num-1];
var self=this;
if((key==TXK_HOME)||(key==TXK_EXIT)){
this.setShow(false);
return false;}
if(self.is_move==true)return;
switch(key){
case TXK_UP:
if(obj.option_index==0)return false;
obj.option_index--;
var focus_obj=obj.option[obj.option_index];
self.is_move=true;
this.requestFocus(
[obj.translate[0]+focus_obj.translate[0],
obj.translate[1]+focus_obj.translate[1],
obj.translate[2]+focus_obj.translate[2]],
[focus_obj.width+2,focus_obj.height+2],0,30,function(){self.is_move=false;});
return true;
case TXK_DOWN:
if(obj.option_index==obj.option.length-1)return false;
obj.option_index++;
var focus_obj=obj.option[obj.option_index];
self.is_move=true;
this.requestFocus(
[obj.translate[0]+focus_obj.translate[0],
obj.translate[1]+focus_obj.translate[1],
obj.translate[2]+focus_obj.translate[2]],
[focus_obj.width+2,focus_obj.height+2],0,30,function(){self.is_move=false;});
return true;
case TXK_ENTER:
var ret=false;
if(obj.option[obj.option_index]){
for(var i=0,max=obj.option.length;i<max;i++){
obj.option[i].set_check(false);}
obj.option[obj.option_index].set_check(true);
ret=obj.option[obj.option_index].action(true);}
HOME.HomeSoundPlay("enter");
return ret;
case TXK_RETURN:
HOME.HomeSoundPlay("cancel");
case TXK_LEFT:
obj.option[obj.option_index].cancel();
return true;}
return false;}

PowerOnOption.prototype.PopUp=function(param){
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.pop_border=new gbox({width:this.width-30,height:this.height-10,
color:COL_POP_BORDER}),
this.pop=new gbox({width:this.width-34,height:this.height-14,
color:COL_POP_A}),
]
});};
PowerOnOption.prototype.PopUp.prototype.open=function(width,end_func){
delete_timer(this);
append_timer(this,10,function(self,count){
delete_timer(self);
if(end_func){
end_func();}
force_redraw();});};
PowerOnOption.prototype.PopUp.prototype.close=function(width){
this.visible_p=false;};
PowerOnOption.prototype.PopUp.prototype.freeResource=function(bool){}
PowerOnOption.prototype.PopUp.prototype.destroy=function(){
if(this.components.length==0)return 0;
this.components.splice(0,this.components.length);}

PowerOnOption.prototype.Button=function(param){
this.check_src=IMG_PATH+"check.png";
this.title=param.title;
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.check_border=new gbox({width:40,height:40,color:COL_TEXT_ONBASE,
translate:[-this.width/2+50/2+10,0,0]}),
this.check_inner=new gbox({width:40-4,height:40-4,color:COL_POINT,
translate:[-this.width/2+50/2+10,0,0]}),
this.check=new gimage({width:36,height:36,color:COL_TEXT_ONBASE,
translate:[-this.width/2+50/2+10,0,0],
draw_type:DIRECT,src:this.check_src,}),
this.text=new gtext({width:this.width-10-50-10-10,align:LC_TEXT_ALIGN,
color:COL_TEXT_ONBASE,
translate:[this.width/2-(this.width-10-50-10)/2,0,0],
font_size:36,text:this.title,}),
]
});
change_font_size(this.text);};
PowerOnOption.prototype.Button.prototype.freeResource=function(bool){
if(this.isResource==bool)return;
this.isResource=bool;
gtextResource(this.text,bool);
gimageResource(this.check,bool);}
PowerOnOption.prototype.Button.prototype.destroy=function(){
if(this.components.length==0)return;
this.check.src="";
setf_text(this.text,"");
this.components.splice(0,this.components.length);}
PowerOnOption.prototype.Button.prototype.set_check=function(bool){
this.check.visible_p=bool;
force_redraw();}


function SoundOption(option_list,size,focus_moveto,focus_show,
focus_size,focus_set){
this.superClass=container;
this.superClass({});
this.width=size[0];
this.height=size[1];
this.popup_num=0;
this.popup_tree_m=[];
this.popup_arry=[];
this.option_list=option_list;
this.popup_base_tr=[-115,-310,0];
this.back_mask_alpha=127;
this.back_mask=new gbox({width:1920*2,height:1080*2,
color:[0,0,0,0],});
this.components.push(this.back_mask);
AnimationGraphics.apply(this.back_mask);
this.is_move=false;
if(focus_moveto instanceof Function){
this.requestFocus=focus_moveto;}
if(focus_show instanceof Function){
this.showFocus=focus_show;}
if(focus_size instanceof Function){
this.sizeFocus=focus_size;}
if(focus_set instanceof Function){
this.setFocus=focus_set;}
}
SoundOption.prototype.onFocus=function (bool,type){
if(bool==true){
var self=this;
var focus_obj_pa=this.popup_arry[this.popup_num-1];
var focus_obj=
focus_obj_pa.option[this.popup_arry[this.popup_num-1].option_index];
var my_width=this.width;
if(type){
self.is_move=true;
this.requestFocus(
[focus_obj_pa.translate[0]+focus_obj.translate[0],
focus_obj_pa.translate[1]+focus_obj.translate[1],
focus_obj_pa.translate[2]+focus_obj.translate[2]],
[focus_obj.width+2,focus_obj.height+2],0,30,function(){self.is_move=false;});}else {
this.sizeFocus(focus_obj.width+2,focus_obj.height+2);
this.setFocus(focus_obj_pa.translate[0]+focus_obj.translate[0],
focus_obj_pa.translate[1]+focus_obj.translate[1],
focus_obj_pa.translate[2]+focus_obj.translate[2]);
this.showFocus(true);}
}else {
this.showFocus(false);}
}
SoundOption.prototype.popup_creat=function (){
var pre_obj;
var pre_option_obj;
if(this.popup_num==0){
this.popup_tree_m.push(0);}else{
var pre_option_index;
pre_option_index=this.popup_arry[this.popup_num-1].option_index;
this.popup_tree_m.push(pre_option_index);
pre_obj=this.popup_arry[this.popup_num-1];
pre_option_obj=
this.popup_arry[this.popup_num-1].option[pre_option_index];}
var obj=new container({});
var option_list_w=this.option_list;
obj.option=[];
obj.option_index=0;
for(var i=0;i<this.popup_num;i++){
option_list_w=
option_list_w[this.popup_tree_m[this.popup_num]].option_list;}
var option_len=option_list_w.length;
var btn_interval=5;
var btn_height=64;
obj.popup=new this.PopUp({translate:[0,0,0],
width:this.width,
height:40+option_len*btn_height+(option_len-1)*btn_interval});
obj.components.push(obj.popup);
for(var i=0;i<option_len;i++){
obj.option[i]=new this.Button({translate:[0,0,0],
width:this.width-60,height:btn_height,title:option_list_w[i].title,});
obj.option[i].action=option_list_w[i].action;
obj.option[i].cancel=option_list_w[i].cancel;
obj.components.push(obj.option[i]);}
var btn_str_tr_x=0;
if(option_len!=1){
btn_str_tr_x=btn_str_tr_x+Math.floor(((option_len-1)*
btn_interval+btn_height*option_len)/2)-
Math.floor(btn_height/2);}
for(var i=0;i<option_len;i++){
obj.option[i].translate[1]=btn_str_tr_x-
(btn_interval+btn_height)*i;
obj.option[i].visible_p=true;}
if(this.popup_num==0){
obj.translate=this.popup_base_tr;}else{
obj.translate=[
pre_obj.translate[0]+pre_option_obj.translate[0]+this.width*3/4,
pre_obj.translate[1]+pre_option_obj.translate[1],
pre_obj.translate[2]+pre_option_obj.translate[2],
];}
this.popup_arry.push(obj);
this.components.push(obj);
this.popup_num++;}
SoundOption.prototype.popup_open=function (end_func){
var self=this;
var obj=this.popup_arry[this.popup_num-1];
delete_timer(obj);
self.is_move=true;
obj.popup.open(this.width,function(){
self.is_move=false;
if(end_func){
end_func();}
});}
SoundOption.prototype.popup_close=function (){
var obj=this.popup_arry[this.popup_num-1];
for(var i=0;i<obj.option.length;i++){
obj.option[i].visible_p=false;}
obj.popup.close(30);};
SoundOption.prototype.popup_destroy=function (mode){
if(mode=="one"){
var obj=this.popup_arry[this.popup_num-1];
obj.visible_p=false;
obj.popup.destroy();
for(var i=0,max=obj.option.length;i<max;i++){
obj.option[i].destroy();}
obj.components.splice(0,obj.components.length);
this.popup_num--;
this.popup_tree_m.pop();
this.popup_arry.pop();}else{
this.visible_p=false;
for(var i=1;i<this.popup_num;i++){
var obj=this.popup_arry[this.popup_num-1];
obj.popup.destroy();
for(var i=0,max=obj.option.length;i<max;i++){
obj.option[i].destroy();}
obj.components.splice(0,obj.components.length);}
this.popup_num=0;
this.popup_tree_m=[];
this.popup_arry=[];}
}
SoundOption.prototype.setShow=function (bool,focus_func){
if(bool==true){
this.popup_creat();
this.popup_arry[0].translate=[-115,-440,0];
var pon_select=null;
var obj=this.popup_arry[this.popup_num-1];
if(HOME.getSoundMute()==false){
obj.option[0].set_check(true);
obj.option[1].set_check(false);
obj.option_index=0;}else{
obj.option[0].set_check(false);
obj.option[1].set_check(true);
obj.option_index=1;}
this.visible_p=true;
this.back_mask.transparentTo(this.back_mask_alpha,500);this.popup_open(focus_func);}else {
this.visible_p=false;
this.popup_close();
this.back_mask.color[3]=0;this.popup_destroy("all");}
force_redraw();}
SoundOption.prototype.key_hook=function (up_down,key){
var obj=this.popup_arry[this.popup_num-1];
var self=this;
if((key==TXK_HOME)||(key==TXK_EXIT)){
this.setShow(false);
return false;}
if(self.is_move==true)return;
switch(key){
case TXK_UP:
if(obj.option_index==0)return false;
obj.option_index--;
var focus_obj=obj.option[obj.option_index];
self.is_move=true;
this.requestFocus(
[obj.translate[0]+focus_obj.translate[0],
obj.translate[1]+focus_obj.translate[1],
obj.translate[2]+focus_obj.translate[2]],
[focus_obj.width+2,focus_obj.height+2],0,30,function(){self.is_move=false;});
return true;
case TXK_DOWN:
if(obj.option_index==obj.option.length-1)return false;
obj.option_index++;
var focus_obj=obj.option[obj.option_index];
self.is_move=true;
this.requestFocus(
[obj.translate[0]+focus_obj.translate[0],
obj.translate[1]+focus_obj.translate[1],
obj.translate[2]+focus_obj.translate[2]],
[focus_obj.width+2,focus_obj.height+2],0,30,function(){self.is_move=false;});
return true;
case TXK_ENTER:
var ret=false;
if(obj.option[obj.option_index]){
for(var i=0,max=obj.option.length;i<max;i++){
obj.option[i].set_check(false);}
obj.option[obj.option_index].set_check(true);
ret=obj.option[obj.option_index].action(true);}
HOME.HomeSoundPlay("enter");
return ret;
case TXK_RETURN:
HOME.HomeSoundPlay("cancel");
case TXK_LEFT:
obj.option[obj.option_index].cancel();
return true;}
return false;}

SoundOption.prototype.PopUp=function(param){
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.pop_border=new gbox({width:this.width-30,height:this.height-10,
color:COL_POP_BORDER}),
this.pop=new gbox({width:this.width-34,height:this.height-14,
color:COL_POP_A}),
]
});};
SoundOption.prototype.PopUp.prototype.open=function(width,end_func){
delete_timer(this);
append_timer(this,10,function(self,count){
delete_timer(self);
if(end_func){
end_func();}
force_redraw();});};
SoundOption.prototype.PopUp.prototype.close=function(width){
this.visible_p=false;};
SoundOption.prototype.PopUp.prototype.freeResource=function(bool){}
SoundOption.prototype.PopUp.prototype.destroy=function(){
if(this.components.length==0)return;
this.components.splice(0,this.components.length);}

SoundOption.prototype.Button=function(param){
this.check_src=IMG_PATH+"check.png";
this.title=param.title;
this.width=param.width;
this.height=param.height;
this.superClass=container;
this.superClass({
translate:param.translate,
components:[
this.check_border=new gbox({width:40,height:40,color:COL_TEXT_ONBASE,
translate:[-this.width/2+50/2+10,0,0]}),
this.check_inner=new gbox({width:40-4,height:40-4,color:COL_POINT,
translate:[-this.width/2+50/2+10,0,0]}),
this.check=new gimage({width:36,height:36,color:COL_TEXT_ONBASE,
translate:[-this.width/2+50/2+10,0,0],
draw_type:DIRECT,src:this.check_src,}),
this.text=new gtext({width:this.width-10-50-10-10,align:LC_TEXT_ALIGN,
color:COL_TEXT_ONBASE,
translate:[this.width/2-(this.width-10-50-10)/2,0,0],
font_size:36,text:this.title,}),
]
});};
SoundOption.prototype.Button.prototype.freeResource=function(bool){
if(this.isResource==bool)return;
this.isResource=bool;
gtextResource(this.text,bool);
gimageResource(this.check,bool);}
SoundOption.prototype.Button.prototype.destroy=function(){
if(this.components.length==0)return;
this.check.src="";
setf_text(this.text,"");
this.components.splice(0,this.components.length);}
SoundOption.prototype.Button.prototype.set_check=function(bool){
this.check.visible_p=bool;
force_redraw();}
var SetOwnerPanel=new container({});
SetOwnerPanel.init=function (focus_moveto,show_focus,enter_action,return_action){
this.components=[
new gbox({translate:[260+18,120,0],width:1400,height:2,color:COL_BORDER_ONBASE}),
];
if(focus_moveto instanceof Function)
this.focus_moveto=focus_moveto;
if(show_focus instanceof Function)
this.show_focus=show_focus;
if(enter_action instanceof Function)
this.enter_action=enter_action;
if(return_action instanceof Function)
this.return_action=return_action;
this.confirm_panel=new container({});
var profile_list=[]
try{
var profile=system.user_profile.get({"mhc":{}});
for(var i=0;i<profile.mhc.all.length;i++){
if(isNumber(profile.mhc.all[i])&&profile.mhc.all[i]>=0)
profile_list.push(profile.mhc.all[i])
}
if(profile_list.length<MAX_USER)
profile_list.push("ADD");}catch(e){
this.return_action();};
var target=me._active_screen[1];
var key=target.getScreenKey();
var info=me.getScreenInfo(key);
this.usr_list=[];
this.oneline=~~(profile_list.length/2+0.5);
if(profile_list.length<=4)this.oneline=profile_list.length;
for(var i=0;i<profile_list.length;i++){
var usrbtn=new UserButton();
usrbtn.translate[0]=(i%this.oneline)*280+400-140*(this.oneline);
usrbtn.translate[1]=(~~(i/this.oneline))*-280-40-120*(profile_list.length==this.oneline);
usrbtn.setUsrProfId(profile_list[i]);
usrbtn.highlight(false)
this.usr_list.push(usrbtn);}
this.components.push.apply(this.components,this.usr_list);
this.mask=new gbox({visible_p:false,
translate:[0,0,0],width:1920,height:1080,color:COL_GRAYOUT});
this.components.push(this.mask,this.confirm_panel);
this.cursor=this.usr_list[0];
if(isNumber(info.usrprof_id)){
this.popup_delete_owner(true);}else{
this.show(true);}
};
SetOwnerPanel.show=function (bool){
if(bool){
append_timer(this,40,function(obj,cnt){
var is_comp=false;
if(cnt>=9){
delete_timer(obj);
is_comp=true;}
var size=80+50*cnt/3;
if(cnt>6)size=180-30*(cnt-6)/3;
for(var i=0;i<obj.usr_list.length;i++){
obj.usr_list[i].setSize(size,is_comp);}
force_redraw();});}else{
delete_timer(this);}
};
SetOwnerPanel.destroy=function (finished_func){
if(finished_func)finished_func();};
SetOwnerPanel.onFocus=function(bool){
if(this.cursor==this.confirm)
return this.cursor.onFocus(bool);
if(bool){
this.cursor=this.usr_list[0];
if(!this.cursor)return;}
this.show_focus(!bool);
this.cursor.onFocus(bool);};
SetOwnerPanel.setUserButton=function(target){
if(!(target instanceof UserButton))
return false;
this.cursor.onFocus(false);
this.cursor=target;
this.cursor.onFocus(true);
return true;};
SetOwnerPanel.popup_delete_owner=function(bool){
var msg=LANG("LT_HOME_DELETE_OWNER")||"Are you sure you wish to delete owner?";
var self=this;
var action_func=[
function(){self.enter_action(null);
self.popup_delete_owner(false);
self.show(true);
HOME.HomeSoundPlay("enter");},
function(){self.popup_delete_owner(false);
self.return_action();
HOME.HomeSoundPlay("cancel");},
];
return this.popup_common(bool,msg,action_func,1);};
SetOwnerPanel.popup_voice_control=function(bool){
var msg=LANG("LT_HOME_VOICE_CONTROL")||"Are you sure you wish to jump to this Home Screen by your voice?";
var self=this;
var action_func=[
function(){var screen_key=me._active_screen[1].getScreenKey();
var usrprof_id=self.last_cursor.getUsrProfId();
HOME.storeVoiceControlScreen(usrprof_id,screen_key);
var uprofile=getProfile(usrprof_id);
if(uprofile&&uprofile.mhc&&
((uprofile.mhc.face_id==-1||uprofile.mhc.face_id==(1<<16)-1||uprofile.mhc.face_id===undefined)&&
uprofile.mhc.voice_mhs_str===undefined)){
var arg="-U %s -f %s".replace("%s",usrprof_id).replace("%s",SETUPUSR_LAUNCH_FOCUS_VOICE);
apputil.launch_apl(SETUPUSER_APPS,arg);
return;}
self.popup_voice_control(false);
self.return_action();
HOME.HomeSoundPlay("enter");},
function(){self.popup_voice_control(false);
self.return_action();
HOME.HomeSoundPlay("cancel");},
];
return this.popup_common(bool,msg,action_func,0);};
SetOwnerPanel.popup_common=function(bool,msg,action_func,init_pos){
this._popup=bool;
this.show_focus(bool);
if(bool){
this.mask.visible_p=true;
var type=Confirmpanel.prototype.OPTION_TYPE_YES_NO;
this.confirm=new Confirmpanel(type,[],this.focus_moveto);
this.confirm_panel.components=[this.confirm];
this.confirm.setMessageText(msg);
this.confirm.setAction(action_func);
this.confirm.setButtonLabel(LANG("LT_YES"),LANG("LT_NO"));
this.confirm.setTranslate(1920/2-(1920-460)/2,-160,0);
this.confirm.setSize(1080,420);
this.confirm.setShow(true);
this.confirm.onFocus=function(b,key){
if(b==true){
this.cursor=init_pos;
this.correctFocus();}
}
this.last_cursor=this.cursor;
this.cursor.onFocus(false);
this.cursor=this.confirm;
this.cursor.onFocus(true);}else{
this.mask.visible_p=false;
this.confirm.free();
this.confirm_panel.components=[];
if(this.last_cursor){
this.cursor.onFocus(false);
this.cursor=this.last_cursor;
this.last_cursor=null;
this.cursor.onFocus(true);}
}
};
SetOwnerPanel.key_hook=function(up_down,key){
if(this.cursor&&
this.cursor.key_hook&&
this.cursor.key_hook(up_down,key))
return true;
if(up_down!=KEY_PRESS)return false;
var index=this.usr_list.indexOf(this.cursor);
switch(key){
case TXK_RETURN:
HOME.HomeSoundPlay("cancel");
this.return_action();
return true;
case TXK_UP:
return this.setUserButton(this.usr_list[index-this.oneline]);
case TXK_DOWN:
var tmp=this.setUserButton(this.usr_list[index+this.oneline]);
if(tmp==false&&~~(index/ this.oneline) != ~~((this.usr_list.length-1) /this.oneline))
tmp=this.setUserButton(this.usr_list[this.usr_list.length-1]);
return tmp;
case TXK_LEFT:
if(index%this.oneline==0){
this.return_action();
return true;}
return this.setUserButton(this.usr_list[index-1]);
case TXK_RIGHT:
if(((index+1)%this.oneline)==0)return false;
return this.setUserButton(this.usr_list[index+1]);
case TXK_ENTER:
if(!(this.cursor&&this.cursor.getUsrProfId))return true;
var usrprof_id=this.cursor.getUsrProfId();
if(usrprof_id=="ADD"){
var arg="-C";
apputil.launch_apl(SETUPUSER_APPS,arg);
return;}
this.enter_action(usrprof_id);
this.usr_list.map(function(obj){obj.highlight(false);});
HOME.HomeSoundPlay("enter");
if(!isNumber(usrprof_id)){
HOME.setCurProfId(null);
this.return_action();
return true;}
this.cursor.highlight(true);
HOME.setCurProfId(usrprof_id);
this.popup_voice_control(true);
return true;
default:
break;}
return false;};
function UserButton(){
this.translate=[0,0,0];
this.width=150;
this.height=150;
this.components=[
this.base=new gimage({visible_p:false,color:COL_POINT_ONBASE,
width:this.width+2,height:this.height+2}),
this.focus=new gimage({visible_p:false,translate:[0.5,-1,0],
width:this.width+42,height:this.height+42,
src:IMG_PATH+"circle_focus.png",color:COL_FCS}),
this.userIcon=new gimage({width:(this.width-10)-50,height:(this.height-10)-50}),
this.userName=new gtextbox({visible_p:false,
translate:[0,-(this.height/2)-45,0],
width:(this.width+70),height:80,
align:CENTER,color:COL_TEXT_ONBASE}),
];}
UserButton.prototype=new container({});
UserButton.prototype.onFocus=function(bool){
this.focus.visible_p=bool;
var base_size=(this.width+30);
var target_size=(this.width+44);
var delta=(target_size-base_size)/3;
this.focus.width=base_size;
this.focus.height=this.focus.width;
delete_timer(this);
if(!bool)return;
append_timer(this,30,function(obj,cnt){
force_redraw();
if(cnt>3){
delete_timer(obj);
obj.focus.width=target_size;
obj.focus.height=obj.focus.width;
return;}
obj.focus.width=Math.round(base_size+delta*cnt);
obj.focus.height=obj.focus.width;});
force_redraw();};
UserButton.prototype.highlight=function(bool){
if(this._highlight!==undefined)
this.base.visible_p=bool;
this._highlight=bool;
this.userName.color=(bool)?COL_POINT:COL_TEXT_ONBASE;};
UserButton.prototype.getUsrProfId=function(){
return this.usrprof_id;};
UserButton.prototype.setSize=function(size,is_complete){
this.base.visible_p=(is_complete&&this._highlight);
this.userName.visible_p=is_complete;
this.userIcon.width=~~(size-10);
this.userIcon.height=~~(size-10);
if(this.usrprof_id=="ADD"){
this.userIcon.width=~~(size+40);
this.userIcon.height=~~(size+40);}
};
UserButton.prototype.setUsrProfId=function(usrprof_id){
this.usrprof_id=usrprof_id;
if(usrprof_id=="ADD"){
this.userIcon.src=IMG_PATH+"setting_icon.png";
var name=LANG("LT_CG_ADD_USER")||"Add User";
setf_text(this.userName,name.toString());
change_font_size_b(this.userName);
this.focus.src=IMG_PATH+"mus_setting_focus.png";
this.focus.color=[255,255,255,255];
return;}
var uprofile=getProfile(usrprof_id);
if(uprofile&&uprofile.mhc){
this.userIcon.src=uprofile.mhc.icon;
var name=(uprofile.mhc.name)||"";
setf_text(this.userName,name.toString());
change_font_size_b(this.userName);
this.base.src=IMG_PATH+"circle.png";
this.visible_p=true;}else{
this.base.src="";
this.visible_p=false;
this.userIcon.src="";}
this.base.visible_p=false;};
