summaryrefslogtreecommitdiff
path: root/lua-interface-light.lua
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-11-08 22:08:09 -0800
committerPixel <pixel@nobis-crew.org>2009-11-08 22:08:09 -0800
commit4c239ae7dbd4043935dba1c8adc2a2ac397b9d40 (patch)
tree4c18dcabbac1d541af933649c6b780969b9605f0 /lua-interface-light.lua
parenta02d152d1fdd6dcdc8fa977430d23a3822e4e4c2 (diff)
Removing useless flags debug and compile now, and adding lua-interface-light.lua for default lua-interface-light.exe behavior.
Diffstat (limited to 'lua-interface-light.lua')
-rw-r--r--lua-interface-light.lua148
1 files changed, 148 insertions, 0 deletions
diff --git a/lua-interface-light.lua b/lua-interface-light.lua
new file mode 100644
index 0000000..f4a019d
--- /dev/null
+++ b/lua-interface-light.lua
@@ -0,0 +1,148 @@
+loadmodule "luaiup"
+loadmodule "luahandle"
+
+local equivalent_locales = {
+ ["French"] = "frFR",
+ ["FranÃais"] = "frFR",
+ ["fr_FR"] = "frFR",
+ ["fr_BE"] = "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 okay = 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
+ 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
+
+ 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",
+ }
+ },
+
+ 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 not okay then return 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
+
+ archive_main()
+end