Author Topic: Help this code works? i try but not sucess!!  (Read 920 times)

gamesmame

  • Full Member
  • ***
  • Posts: 97
    • View Profile
Help this code works? i try but not sucess!!
« on: March 27, 2023, 01:20:44 PM »
I tried to create a simple and elegant layout to experiment with. This layout displays a background image and a list of available games on the main screen. When selecting a game, a menu should appear with the options "Play", "Manual" and "Video".

But do I think something is missing, or is the code completely wrong?

Code: [Select]
// Configurações
local bg = fe.add_artwork("backdrop", fe.add_image(bg_image)) // nome da imagem de fundo
local font_name = "Roboto Regular" // nome da fonte
local font_size = 20 // tamanho da fonte
local title_offset_y = 80 // distância do título em relação ao topo
local item_height = 40 // altura de cada item da lista
local item_spacing = 10 // espaçamento entre os itens da lista
local menu_options = [    ["Jogar", "emulator", "[name]"],
    ["Manual", "exec", "[rompath]/manual.pdf"],
    ["Vídeo", "exec", "[rompath]/video.mp4"]
]

// Imagem de fundo
local bg = fe.add_artwork("backdrop", bg_image)
bg.preserve_aspect_ratio = true
bg.trigger = Transition.EndNavigation
bg.post_trigger = Transition.ToNewVideo

// Título
local title = fe.add_text("[Title]", 0, title_offset_y, fe.layout.width, font_size*2, font_name, font_size*2, 0xffffffff, Effect.Fade)
title.word_wrap = true
title.align = Align.Center
title.trigger = Transition.EndNavigation
title.post_trigger = Transition.ToNewVideo

// Lista de jogos
local list = fe.add_list("romlist", 0, title_offset_y + title.height + item_spacing, fe.layout.width, fe.layout.height - (title_offset_y + title.height + item_spacing), font_name, font_size, 0xffffffff, Effect.Fade)
list.spacing = item_spacing
list.trigger = Transition.EndNavigation
list.post_trigger = Transition.ToNewVideo

// Ações
list.on_change = function( selected_item ) {
    title.set_text( selected_item.parent.get_name( selected_item ) )
}

list.on_select = function( selected_item ) {
    local sel = fe.do_menu(menu_options, "Menu")
    if (sel == -1) fe.exit()
    fe.do_action(sel)
}

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: Help this code works? i try but not sucess!!
« Reply #1 on: March 28, 2023, 06:29:52 AM »
not quite shure,  been talked abought many time as i recall to no avail ,   intercepting the select sig,   interesting code though...i hope you are able to do it. good luck
help a friend....