loadmodule "luaiup" loadmodule "luahandle" local equivalent_locales = { ["French"] = "frFR", ["FranÃais"] = "frFR", ["fr"] = "frFR", } local invite_locale = { ["default"] = "Please input .paq file to run", ["frFR"] = "Saisissez le fichier .paq pour continuer", } local ok_locale = { ["default"] = "Ok", ["frFR"] = "Ok", } local quit_locale = { ["default"] = "Quit", ["frFR"] = "Quitter", } local error_not_archive_locale = { ["default"] = "Wrong archive file type", ["frFR"] = "Mauvais type d'archive .paq", } local error_wrong_archive_locale = { ["default"] = "Archive doesn't contain archive_main.lua", ["frFR"] = "L'archive ne contient pas archive_main.lua", } local error_bad_lua_locale = { ["default"] = "archive_main.lua doesn't contain a archive_main function", ["frFR"] = "archive_main.lua ne contient pas de fonction archive_main", } local commandline_locale = { ["default"] = "Command line", ["frFR"] = "Ligne de commande", } local okay = false local commandline = false local system_locale local input_file_text local function generate_dlg() input_file_text = iup.text { expand = "Horizontal", } local input_file_btn = iup.button { title = "..." } local invite = invite_locale.default system_locale = iup.GetGlobal "SYSTEMLANGUAGE" if type(system_locale) == "string" then system_locale = split(split(system_locale, "_")[1], " ")[1] local direct = invite_locale[system_locale] if direct then invite = direct else system_locale = equivalent_locales[system_locale] if system_locale then invite = invite_locale[system_locale] else system_locale = "default" end end else system_locale = "default" end function input_file_btn:action() local filedlg = iup.filedlg { filter = "*.paq", title = invite, } filedlg:popup() if filedlg.status + 0 == 0 then input_file_text.value = filedlg.value end return iup.DEFAULT end local ok_btn = iup.button { title = ok_locale[system_locale] } function ok_btn:action() okay = true return iup.CLOSE end local quit_btn = iup.button { title = quit_locale[system_locale] } function quit_btn:action() return iup.CLOSE end local commandline_btn = iup.button { title = commandline_locale[system_locale] } function commandline_btn:action() commandline = true return iup.CLOSE end return iup.dialog { iup.vbox { iup.hbox { iup.fill{}, iup.label { title = "Lua Interface Light", font = "Arial Bold 18" }, iup.fill{}, }, iup.fill { size = "x8" }, iup.label { title = invite }, iup.hbox { input_file_text, input_file_btn, }, iup.fill { size = "x16" }, iup.hbox { ok_btn, iup.fill{}, quit_btn, normalizesize = "Horizontal", }, iup.fill { size = "x2" }, iup.hbox { iup.fill{}, commandline_btn, }, }, resize = "No", maxbox = "No", minbox = "No", title = "Lua Interface Light", gap = "2", defaultesc = quit_btn, toolbox = "Yes", margin = "10x10", size = "200x", } end function lua_interface_light_main() local dlg = generate_dlg() dlg:show() iup.MainLoop() dlg:hide() if commandline then return true end if not okay then return false end if not pcall(Archive(input_file_text.value)) then error(error_not_archive_locale[system_locale]) end if not pcall(load "archive_main.lua") then error(error_wrong_archive_locale[system_locale]) end if not type(archive_main) == "function" then error(error_bad_lua_locale[system_locale]) end return archive_main() end