mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 03:45:32 +01:00
add LuaEngine Compiler UI
This commit is contained in:
parent
3598028ded
commit
df642d7411
3 changed files with 141 additions and 3 deletions
|
@ -128,8 +128,10 @@ File "/opt/windev/qt64d-latest/plugins/imageformats/qwebp.dll"
|
|||
SetOutPath "$INSTDIR\platforms"
|
||||
File "/opt/windev/qt64d-latest/plugins/platforms/qwindows.dll"
|
||||
SetOutPath "$INSTDIR\scripts"
|
||||
File "scripts/luaenginec.lea"
|
||||
File "scripts/luaenginert.lea"
|
||||
SetOutPath "$INSTDIR\sstubs"
|
||||
File "sstubs/windows.json"
|
||||
File "windows.le"
|
||||
SetOutPath "$INSTDIR\styles"
|
||||
File "/opt/windev/qt64d-latest/plugins/styles/qcleanlooksstyle.dll"
|
||||
|
@ -146,8 +148,8 @@ WriteUninstaller "$INSTDIR\uninstall.exe"
|
|||
!ifdef REG_START_MENU
|
||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||
CreateDirectory "$SMPROGRAMS\$SM_Folder"
|
||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_RUNTIME}" "$INSTDIR\scripts\luaenginert.lea"
|
||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Compiler.lnk" "$INSTDIR\${MAIN_APP_COMPILER}"
|
||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_RUNTIME}" "$\"$INSTDIR\scripts\luaenginert.lea$\""
|
||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Compiler.lnk" "$INSTDIR\${MAIN_APP_RUNTIME}" "$\"$INSTDIR\scripts\luaenginec.lea$\""
|
||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
|
||||
|
||||
!ifdef WEB_SITE
|
||||
|
@ -160,7 +162,7 @@ CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk" "$INSTDIR\${APP_
|
|||
!ifndef REG_START_MENU
|
||||
CreateDirectory "$SMPROGRAMS\LuaEngine"
|
||||
CreateShortCut "$SMPROGRAMS\LuaEngine\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_RUNTIME}" "$\"$INSTDIR\scripts\luaenginert.lea$\""
|
||||
CreateShortCut "$SMPROGRAMS\LuaEngine\${APP_NAME} Compiler.lnk" "$INSTDIR\${MAIN_APP_COMPILER}"
|
||||
CreateShortCut "$SMPROGRAMS\LuaEngine\${APP_NAME} Compiler.lnk" "$INSTDIR\${MAIN_APP_RUNTIME}" "$\"$INSTDIR\scripts\luaenginec.lea$\""
|
||||
CreateShortCut "$SMPROGRAMS\LuaEngine\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
|
||||
|
||||
!ifdef WEB_SITE
|
||||
|
@ -210,7 +212,9 @@ Delete "$INSTDIR\imageformats\qtiff.dll"
|
|||
Delete "$INSTDIR\imageformats\qwbmp.dll"
|
||||
Delete "$INSTDIR\imageformats\qwebp.dll"
|
||||
Delete "$INSTDIR\platforms\qwindows.dll"
|
||||
Delete "$INSTDIR\scripts\luaenginec.lea"
|
||||
Delete "$INSTDIR\scripts\luaenginert.lea"
|
||||
Delete "$INSTDIR\sstubs\windows.json"
|
||||
Delete "$INSTDIR\sstubs\windows.le"
|
||||
Delete "$INSTDIR\styles\qcleanlooksstyle.dll"
|
||||
Delete "$INSTDIR\styles\qplastiquestyle.dll"
|
||||
|
|
129
scripts/luaenginec.lea
Normal file
129
scripts/luaenginec.lea
Normal file
|
@ -0,0 +1,129 @@
|
|||
#!/usr/bin/env luaengine
|
||||
--[[
|
||||
******************************************************************************
|
||||
* luaenginec LuaEngine Compiler
|
||||
* Copyright (C) 2019 Syping
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************
|
||||
--]]
|
||||
|
||||
local sstubDir
|
||||
local mainWindow
|
||||
local currentSstub
|
||||
local compilerPath
|
||||
local compileButton
|
||||
local currentFilter
|
||||
local scriptLineEdit
|
||||
local outputLineEdit
|
||||
local sstubsTable = {}
|
||||
local radioButtonFile = {}
|
||||
local radioButtonFilter = {}
|
||||
|
||||
function main()
|
||||
local initOk = init()
|
||||
if (initOk == false) then
|
||||
return 1
|
||||
end
|
||||
|
||||
mainWindow = createMainWindow("LuaEngine Compiler")
|
||||
local mainLayout = createLayout(VerticalLayout, mainWindow)
|
||||
|
||||
createLabel("<strong>LuaEngine Compiler</strong>", mainLayout)
|
||||
|
||||
local scriptLayout = createLayout(HorizontalLayout, mainLayout)
|
||||
createLabel("Script:", scriptLayout)
|
||||
scriptLineEdit = createLineEdit("", scriptLayout)
|
||||
setWidgetReadOnly(scriptLineEdit)
|
||||
local scriptToolButton = createToolButton("...", scriptLayout)
|
||||
connect(scriptToolButton, "clicked()", "scriptButtonPressed")
|
||||
|
||||
local radioButton = createRadioButton("LuaEngine Bytecode", mainLayout)
|
||||
currentFilter = "LuaEngine Bytecode (*.luac *.leac)"
|
||||
radioButtonFile[radioButton] = nil
|
||||
radioButtonFilter[radioButton] = currentFilter
|
||||
connect(radioButton, "clicked()", "radioButtonClicked")
|
||||
setWidgetChecked(radioButton, true)
|
||||
|
||||
for index, subtable in ipairs(sstubsTable) do
|
||||
radioButton = createRadioButton(subtable["name"], mainLayout)
|
||||
radioButtonFile[radioButton] = subtable["file"]
|
||||
radioButtonFilter[radioButton] = subtable["filter"]
|
||||
connect(radioButton, "clicked()", "radioButtonClicked")
|
||||
end
|
||||
|
||||
local buttonLayout = createLayout(HorizontalLayout, mainLayout)
|
||||
createSpacerItem(SizePolicyExpanding, SizePolicyMinimum, buttonLayout)
|
||||
compileButton = createPushButton("&Compile", buttonLayout)
|
||||
setWidgetEnabled(compileButton, false)
|
||||
connect(compileButton, "clicked()", "compileScript")
|
||||
|
||||
setWidgetSize(mainWindow, 300, 0)
|
||||
setWidgetFixed(mainWindow, true)
|
||||
showWidget(mainWindow, ShowDefault)
|
||||
|
||||
return GuiExecuted
|
||||
end
|
||||
|
||||
function init()
|
||||
local binDir = getDirectoryPath(_LuaEngineRT)
|
||||
if (luaEnginePlatform() == "Windows") then
|
||||
compilerPath = binDir.."/luaenginec.exe"
|
||||
if (checkFileExists(compilerPath)) then
|
||||
sstubDir = binDir.."/sstubs"
|
||||
for index, file in ipairs(getDirectoryContent(sstubDir, "*.json", Files)) do
|
||||
local handle = io.open(file, "r")
|
||||
if (handle ~= nil) then
|
||||
local content = handle:read("*a")
|
||||
table.insert(sstubsTable, jsonToTable(content))
|
||||
handle:close()
|
||||
end
|
||||
end
|
||||
else
|
||||
showMessageBox(WarningMessageBox, "LuaEngine Compiler not found!", "LuaEngine Compiler")
|
||||
return false
|
||||
end
|
||||
else
|
||||
showMessageBox(InfoMessageBox, "LuaEngine Compiler only supported on Windows now.", "LuaEngine Compiler")
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function scriptButtonPressed()
|
||||
local filePath = showFileDialog(OpenFileDialog, "Select LuaEngine script...", "LuaEngine scripts (*.lua *.lea)", mainWindow)
|
||||
if (filePath ~= nil) then
|
||||
setWidgetText(scriptLineEdit, filePath)
|
||||
setWidgetEnabled(compileButton, true)
|
||||
end
|
||||
end
|
||||
|
||||
function radioButtonClicked(radioButton)
|
||||
currentSstub = radioButtonFile[radioButton]
|
||||
currentFilter = radioButtonFilter[radioButton]
|
||||
end
|
||||
|
||||
function compileScript()
|
||||
local filePath = showFileDialog(SaveFileDialog, "Select output file...", currentFilter, mainWindow)
|
||||
if (filePath ~= nil) then
|
||||
local extraArg1
|
||||
local extraArg2
|
||||
if (currentSstub ~= nil) then
|
||||
extraArg1 = "--luaengine"
|
||||
extraArg2 = sstubDir.."/"..currentSstub
|
||||
end
|
||||
if (executeProcess(compilerPath, getWidgetText(scriptLineEdit), filePath, extraArg1, extraArg2, false) == false) then
|
||||
showMessageBox(WarningMessageBox, "Error occurred while compile!", "LuaEngine Compiler")
|
||||
end
|
||||
end
|
||||
end
|
5
sstubs/windows.json
Normal file
5
sstubs/windows.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"file": "windows.le",
|
||||
"name": "Windows 64-Bit",
|
||||
"filter": "Windows executables (*.exe)"
|
||||
}
|
Loading…
Reference in a new issue