Skip to content

Commit

Permalink
Templates: print() now prints to the log.
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFreezed committed Jul 19, 2021
1 parent aedee64 commit d32452e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions misc/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ v1.9 (2021-07-19)
- Particle color gradients can be saved and loaded. (Right-click on the preview.)
- Fixed slider handle position being slightly off while dragging.
- Exporter: Updated dialog to show all files that will be exported, and if they overwrite anything, at the bottom.
- Templates: print() now prints to the log.
- File browser: Click in the file list and type to search.
- File browser: Enable name filter for the file list by entering a filename with an asterisk (e.g. "*.lua").

Expand Down
6 changes: 3 additions & 3 deletions src/build.gloa
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ local doRelease :: () {
-- Add remaining files.
do {
copyFilesInDirectory("exportTemplates", outputDir.."/exportTemplates", "%.lua$")
copyFile("misc/CHANGELOG.txt", outputDir.."/_Changelog.txt")
copyFile("misc/Changelog.txt", outputDir.."/_CHANGELOG.txt")
copyFile("misc/README.txt", outputDir.."/_README.txt")
}
}
Expand Down Expand Up @@ -277,7 +277,7 @@ local doRelease :: () {
copyFilesInDirectory("exportTemplates", contentsDir.."/Resources/exportTemplates", "%.lua$")
copyFile(values.lovePath, contentsDir.."/Resources/Game.love")
copyFile("temp/appIcon.icns", contentsDir.."/Resources/AppIcon.icns")
copyFile("misc/CHANGELOG.txt", outputDir.."/_Changelog.txt")
copyFile("misc/Changelog.txt", outputDir.."/_CHANGELOG.txt")
copyFile("misc/README.txt", outputDir.."/_README.txt")
}
}
Expand All @@ -291,7 +291,7 @@ local doRelease :: () {

copyFilesInDirectory("exportTemplates", outputDir.."/exportTemplates", "%.lua$")
copyFile(values.lovePath, format("%s/%s.love", outputDir, values.exeName))
copyFile("misc/CHANGELOG.txt", format("%s/_Changelog.txt", outputDir))
copyFile("misc/Changelog.txt", format("%s/_CHANGELOG.txt", outputDir))
copyFile("misc/README.txt", format("%s/_README.txt", outputDir))
copyFile("misc/README (universal).txt", format("%s/_README (universal).txt", outputDir))
}
Expand Down
4 changes: 2 additions & 2 deletions src/guiSetup.gloa
Original file line number Diff line number Diff line change
Expand Up @@ -3657,12 +3657,12 @@ export setupGuiCallbacks :: () {
local pathSet: struct { !key:string, !value:bool }

for project.systems {
local ok, path = resolveTextureOutputPath(project, it)
local ok, path, sameAsInput = resolveTextureOutputPath(project, it)
if not ok {
insert(textEl.textLines, "Missing/invalid texture path!")
} elseif not pathSet[path] {
pathSet[path] = true
insert(textEl.textLines, (doesFileExist(path) ? "[OVERWRITE] " : "")..path)
insert(textEl.textLines, (sameAsInput ? "[IN BASE] " : doesFileExist(path) ? "[OVERWRITE] " : "")..path)
}
}
}
Expand Down
22 changes: 18 additions & 4 deletions src/misc.gloa
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
getModifierKey
isInside
limitArray, areArraysEqual
log
log, logNoTimestamp
newMonochromeImage, newImageUsingPalette
pcall_newImage, pcall_newShader
prepareSandbox
Expand Down Expand Up @@ -313,14 +313,20 @@ export trim :: (s:string) -> string {
export prepareSandbox :: (globals:table) -> (env:table) {
local setMetatable :: (t:table, metatable:table) -> table !foreign lua "setmetatable"

local indexTable: table = {
local sandboxPrint :: (...:any) {
local values :: []string.{}
for ... values[itIndex] = toString(it)
logNoTimestamp(concatenate(values, "\t", 1, #...))
}

local indexTable = table.{
_VERSION = cast(any) !foreign lua "_VERSION",
assert = cast(any) !foreign lua "assert",
error = cast(any) !foreign lua "error",
ipairs = cast(any) !foreign lua "ipairs",
next = cast(any) !foreign lua "next",
pairs = cast(any) !foreign lua "pairs",
print = cast(any) !foreign lua "print",
print = sandboxPrint,
select = cast(any) !foreign lua "select",
tonumber = cast(any) !foreign lua "tonumber",
tostring = cast(any) !foreign lua "tostring",
Expand Down Expand Up @@ -401,7 +407,7 @@ export prepareSandbox :: (globals:table) -> (env:table) {
for globals indexTable[itIndex] = it

setMetatable(env, {
__newindex = (templateEnv:table, k:any, v:any) {
__newindex = (templateEnv:table, k,v:any) {
errorf(2, "cannot add global '%s' (globals are disabled)", toString(k))
},
__index = indexTable,
Expand Down Expand Up @@ -455,10 +461,18 @@ export log :: (s:string) {
insert(logStrings, os.getDate"[%H:%M:%S] "..s)
print(s)
}
export logNoTimestamp :: (s:string) {
if logStrings[LOG_MAX_ENTRIES] ~= NULL remove(logStrings, 1)
insert(logStrings, s)
print(s)
}

export log :: (s:string, v,...:int|float|string|Type) {
log(format(s, v, ...))
}
export logNoTimestamp :: (s:string, v,...:int|float|string|Type) {
logNoTimestamp(format(s, v, ...))
}



Expand Down

0 comments on commit d32452e

Please sign in to comment.