//
// Attract-Mode Front-End : "Vertical Arcade" layout
// Made by 배고픈마리오 (CSOne)
// Ver.2.0 (2021.02.17) Vewlix Cabinet added 
// Ver.1.1 (2019.12.22)
// Ver.1.0 (2019.12.19)

local orderx = 0;
class UserConfig { 
</ label="글꼴(게임목록)", help="화면에 표시되는 글자 폰트를 변경할 수 있습니다.", options="Jalnan,TmonMonsori,TT,Font,NanumGothicBold,User1,User2,User3", order=orderx++ /> select_font1="TmonMonsori";
</ label="글꼴(시계)", help="화면에 표시되는 글자 폰트를 변경할 수 있습니다.", options="TmonMonsori,TT,Font,NanumGothicBold,User1,User2,User3", order=orderx++ /> select_font2="TmonMonsori";
</ label="화면 늘리기", help="게임기통의 화면을 강제를 늘리려면 Yes를 원본비율로 표시하려면 No를 선택하세요. 'No' is original rate.", options="Yes,No", order=orderx++ /> enable_stretch="Yes";
</ label="모니터 스캔라인", help="게임기통 화면에 스캔라인 효과를 주거나 끌수 있습니다.", options="On,Off", order=orderx++ /> enable_scanline="On";
</ label="조작키 안내", help="조작키 설명 이미지를 선택할 수 있습니다.", options="XBOX360,PS Pad,Keyboard,off", order=orderx++ /> select_Keyinfo="XBOX360";
</ label="즐겨찾기 아이콘", help="즐겨찾기 아이콘을 목록전체에 표시할지 말지 선택할 수 있습니다.", options="On,Off", order=orderx++ /> enable_Fav_icon="On";
} 

local my_config = fe.get_config();
fe.layout.font=my_config["select_font1"];
fe.layout.width=1920;
fe.layout.height=1080;
local blip = fe.layout.height;
local flx = fe.layout.width;
local fly = fe.layout.height;
local flw = fe.layout.width;
local flh = fe.layout.height;


// 레이아웃 비율조절 

//fe.layout.preserve_aspect_ratio = true;

//fe.load_module("animate");
fe.load_module( "animate_old" );
fe.add_image( "bg_black.png", 0, 0, 1920, 1080);
fe.add_image( "bg_white.png", 150, 45, 714, 165);


// 캐비넷 상단 로고 페이드인 전환효과
local marqueeBkg0=fe.add_image( "cab_body_Vewlix_Top_RED.png", 150, 45, 714, 165 );
marqueeBkg0.alpha = 240;

::OBJECTS <- {
marquee = fe.add_artwork( "marquee", 150, 45, 714, 165 ),
}
    local move_marquee1 = {
 	when = Transition.ToNewSelection, property = "alpha", start = 0, end = 255, time = 800
    }
    animation.add( PropertyAnimation( OBJECTS.marquee, move_marquee1 ) );
OBJECTS.marquee.trigger = Transition.EndNavigation;


// 미리보기 동영상 화면늘리기 or 화면비율유지

local snap = fe.add_artwork( "snap", 305, 252, 402, 715 );

if ( my_config["enable_scanline"] == "On" )
{
fe.add_image( "scanline2.png", 304, 252, 453, 810);
}

if ( my_config["enable_stretch"] == "No" )
{
snap.preserve_aspect_ratio = true;
}
snap.trigger = Transition.EndNavigation;

	
// 캐비넷 이미지, 디스플레이 타이틀

fe.add_image( "bg3.png", 0, 0, 1920, 1080);
local displayName_bg = fe.add_image ("display/[DisplayName]_bg",1220, -300, 450, 200);
local displayName = fe.add_image ("display/[DisplayName]",1220, -300, 450, 200);
local move_transition7 = { when = Transition.ToNewList, property = "y", start = -300, end = 24, tween = Tween.Back, time = 800, delay = 100 }
animation.add( PropertyAnimation( displayName_bg, move_transition7 ) );
animation.add( PropertyAnimation( displayName, move_transition7 ) );


//선택박스
//local box_select= fe.add_image( "box_effect_15.png", flw*0.540625, flh*0.5148148, flw*0.4395833, flh*0.064814 );
local box_select= fe.add_image( "select_box.png", flw*0.540625, flh*0.52222, flw*0.4395833, flh*0.05 );
local box_select_effect = {
	//when = Transition.EndNavigation,
	property = "alpha",
	start = 0,
	end = 255,
	time = 250,
	delay = 0
	tween = Tween.Linear,
	pulse = true,
	}
animation.add( PropertyAnimation( box_select, box_select_effect ) );


// 리스트 게임번호 그림자
local listbox1b = fe.add_listbox( flw*0.541666667,flh*0.212963, flw*0.1796875, flh*0.6759259 );
listbox1b.rows = 15;
listbox1b.charsize = 30;
listbox1b.set_sel_rgb( 208, 56, 0 );
listbox1b.set_rgb( 0, 0, 0 );
listbox1b.selbg_alpha = 0;
listbox1b.align = Align.Left;
listbox1b.charsize=32;
listbox1b.format_string = "[ListEntry]";

// 리스트 박스 게임번호
local listbox1 = fe.add_listbox( flw*0.540104167, flh*0.2101852, flw*0.1796875, flh*0.6759259 );
listbox1.rows = 15;
listbox1.charsize = 30;
listbox1.set_sel_rgb( 255 243, 20 );
listbox1.set_rgb( 73, 223, 222 );
listbox1.selbg_alpha = 0;
listbox1.align = Align.Left;
listbox1.charsize=32;
listbox1.format_string = "[ListEntry]";

// 리스트 박스 게임이름 그림자
local listbox2b = fe.add_listbox( flw*0.583333, flh*0.212963, flw*0.40625, flh*0.6759259 );
listbox2b.rows = 15;
listbox2b.charsize = 30;
listbox2b.set_sel_rgb( 208, 56, 0 );
listbox2b.set_rgb( 0, 0, 0 );
listbox2b.selbg_alpha = 0;
listbox2b.align = Align.Left;
listbox2b.format_string = "[!gamename]  【[Players]인용】  [Year]년  【[Manufacturer]】";

// 리스트 박스 게임이름
local listbox2 = fe.add_listbox( flw*0.5817708, flh*0.2101852, flw*0.40625, flh*0.6759259 );
listbox2.rows = 15;
listbox2.charsize = 30;
listbox2.set_sel_rgb( 255 243, 20 );
listbox2.set_rgb( 240, 240, 240 );
listbox2.selbg_alpha = 0;
listbox2.align = Align.Left;
listbox2.format_string = "[!gamename]  【[Players]인용】  [Year]년  【[Manufacturer]】";

// 문자 생략
// Game name text. We do this in the layout as the frontend doesn't chop up titles with a forward slash
function gamename( index_offset ) {
  local s = split( fe.game_info( Info.Title, index_offset ), "[" );
 	if ( s.len() > 0 ) return s[0];
  return "";
}


// 시계
local clockbtext = fe.add_text( "시계:", flw*0.515625, flh*0.92962963, flw*0.104166667, flh*0.042592593 );
clockbtext.set_rgb( 0, 0, 0 );
clockbtext.charsize = 34;

local clocktext = fe.add_text( "시계:", flw*0.5140625, flh*0.926851852, flw*0.104166667, flh*0.042592593 );
clocktext.set_rgb( 211, 250, 255 );
clocktext.charsize = 34;

local clockb = fe.add_text( "", flw*0.604166667, flh*0.92962963, flw*0.166666667, flh*0.042592593  );
clockb.align = Align.Left;
clockb.charsize = 34;
clockb.set_rgb( 0, 0, 0 );

local clock = fe.add_text( "", flw*0.602604167, flh*0.926851852, flw*0.166666667, flh*0.042592593  );
clock.align = Align.Left;
clock.charsize = 34;
clock.set_rgb( 73, 223, 222 );

function update_clock( ttime ){
  local now = date();
  clockb.msg = format("%02d", now.hour) + ":" + format("%02d", now.min );
  clock.msg = format("%02d", now.hour) + ":" + format("%02d", now.min );
}
fe.add_ticks_callback( this, "update_clock" );


// 즐겨찾기 필터
local listtextb = fe.add_text( "[!filter]:", flw*0.708333333, flh*0.92962963, flw*0.234375, flh*0.042592593 );
listtextb.set_rgb( 208, 56, 0 );
listtextb.charsize = 34;
listtextb.align = Align.Left;

local listtext = fe.add_text( "[!filter]:", flw*0.706770833, flh*0.926851852, flw*0.234375, flh*0.042592593 );
listtext.set_rgb( 255 243, 20 );
listtext.charsize = 34;
listtext.align = Align.Left;

local listb = fe.add_text("[ListEntry]/[ListSize]", flw*0.86615, flh*0.92962963, flw*0.118, flh*0.042592593 );
listb.set_rgb( 0, 0, 0 );
listb.charsize = 34;
listb.align = Align.Right;

local list = fe.add_text( "[ListEntry]/[ListSize]", flw*0.86458, flh*0.926851852, flw*0.118, flh*0.042592593 );
list.set_rgb( 73, 223, 222 );
list.charsize = 34;
list.align = Align.Right;


// 즐겨찾기 아이콘 표시
function getFavs(index_offset){
  if(fe.game_info( Info.Favourite, index_offset ) == "1") return "★.png";
  else return "";
}
function getFavs2(index_offset){
  if(fe.game_info( Info.Favourite, index_offset ) == "1") return "★";
  else return "";
}


if ( my_config["enable_Fav_icon"] == "On" )
{
local listFav = fe.add_listbox( flw*0.5, flh*0.2101852, flw*0.03125, flh*0.6759259);
listFav.rows = 15;
listFav.charsize = 30;
listFav.set_sel_rgb( 255, 255, 0 );
listFav.set_rgb( 255, 255, 0 );
listFav.selbg_alpha = 0;
listFav.align = Align.Left;
listFav.format_string = "[!getFavs2]";
}

local romFav = fe.add_image(getFavs(0), flw*0.5, flh*0.5185, flw*0.03125, flh*0.0555);
fe.add_transition_callback( "update_my_list" );
function update_my_list( ttype, var, ttime )
{
    if(ttype == Transition.ToNewSelection){
        romFav.file_name = getFavs(var);
    }
    return false;
}

fe.add_signal_handler( "updateFavs" );
function updateFavs( signal_str )
{
    if(signal_str == "add_favourite"){
        if(romFav.file_name != "") romFav.file_name = "";
        else romFav.file_name = "★.png";
    }
}


// Change filter name to upper case
 function filter(){
	local text = fe.filters[fe.list.filter_index].name;

                if (text == "Favourites")
                text = "즐겨찾기"
		        if (text == "All")
                text = "전체게임"
				if (text == "Fighting")
                text = "대전격투게임"
                if (text == "Shooting")
                text = "슈팅게임"
		        if (text == "GunShooter")
                text = "건슈팅게임"
				if (text == "Action")
                text = "액션게임"
                if (text == "BeltAction")
                text = "벨트스크롤액션"
		        if (text == "Racing")
                text = "레이싱게임"
				if (text == "Puzzle")
                text = "퍼즐오락게임"
                if (text == "Board")
                text = "보드게임"
		        if (text == "Quiz")
                text = "퀴즈게임"
				if (text == "Rhythm")
                text = "리듬게임"
		        if (text == "RPG")
                text = "롤플레잉게임"
				if (text == "Adventure")
                text = "어드벤처게임"
                if (text == "1980s")
                text = "1980년대 게임"
		        if (text == "1990s")
                text = "1990년대 게임"
				if (text == "2000s")
                text = "2000년대 게임"
				if (text == "2010s")
                text = "2010년대 게임"
		return text.toupper();
 }


// 게임표지 페이드인 전환효과
::OBJECTS <- {
flyer = fe.add_artwork( "flyer", 685, 1370, 370, 450 ),
}
    local move_flyer1 = {
 	when = Transition.ToNewSelection, property = "alpha", start = 0, end = 255, time = 500
    }
    animation.add( PropertyAnimation( OBJECTS.flyer, move_flyer1 ) );
OBJECTS.flyer.trigger = Transition.EndNavigation;


//모니터 회전방향 안내 아이콘
local rotation_icon = fe.add_image("[Rotation].png",775, 775, 66, 66);
local rotation_ani = { when = Transition.ToNewSelection, property = "rotation", start = -90, end = 0, loop = false, time = 180, delay = 0 }
local rotation_ani2 = { when = Transition.ToNewList, property = "rotation", start = -90, end = 0, loop = false, time = 180, delay = 100 }
animation.add( PropertyAnimation( rotation_icon, rotation_ani ) );
animation.add( PropertyAnimation( rotation_icon, rotation_ani2 ) );

local rotation_icon2 = fe.add_image("[AltTitle].png",775, 775, 66, 66);
local rotation_ani3 = { when = Transition.ToNewSelection, property = "rotation", start = 90, end = 0, loop = false, time = 180, delay = 0 }
local rotation_ani4 = { when = Transition.ToNewList, property = "rotation", start = 90, end = 0, loop = false, time = 180, delay = 100 }
animation.add( PropertyAnimation( rotation_icon2, rotation_ani3 ) );
animation.add( PropertyAnimation( rotation_icon2, rotation_ani4 ) );


// 조작키 안내
local key_info = fe.add_image(FeConfigDirectory+"menu-art/common/" + "key_" + my_config["select_Keyinfo"] + "_[Status]" + ".png", flw*0.01823, flh*0.9167, flw*0.4948, flh*0.07037 );
local move_transition8 = { when = Transition.ToNewList, property = "y", start = fly+200, end = flh*0.9167, tween = "cubic", time = 600 }
animation.add( PropertyAnimation( key_info, move_transition8 ) );