Skip to content

Commit d32452e

Browse files
committed
Templates: print() now prints to the log.
1 parent aedee64 commit d32452e

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

misc/Changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ v1.9 (2021-07-19)
55
- Particle color gradients can be saved and loaded. (Right-click on the preview.)
66
- Fixed slider handle position being slightly off while dragging.
77
- Exporter: Updated dialog to show all files that will be exported, and if they overwrite anything, at the bottom.
8+
- Templates: print() now prints to the log.
89
- File browser: Click in the file list and type to search.
910
- File browser: Enable name filter for the file list by entering a filename with an asterisk (e.g. "*.lua").
1011

src/build.gloa

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ local doRelease :: () {
219219
-- Add remaining files.
220220
do {
221221
copyFilesInDirectory("exportTemplates", outputDir.."/exportTemplates", "%.lua$")
222-
copyFile("misc/CHANGELOG.txt", outputDir.."/_Changelog.txt")
222+
copyFile("misc/Changelog.txt", outputDir.."/_CHANGELOG.txt")
223223
copyFile("misc/README.txt", outputDir.."/_README.txt")
224224
}
225225
}
@@ -277,7 +277,7 @@ local doRelease :: () {
277277
copyFilesInDirectory("exportTemplates", contentsDir.."/Resources/exportTemplates", "%.lua$")
278278
copyFile(values.lovePath, contentsDir.."/Resources/Game.love")
279279
copyFile("temp/appIcon.icns", contentsDir.."/Resources/AppIcon.icns")
280-
copyFile("misc/CHANGELOG.txt", outputDir.."/_Changelog.txt")
280+
copyFile("misc/Changelog.txt", outputDir.."/_CHANGELOG.txt")
281281
copyFile("misc/README.txt", outputDir.."/_README.txt")
282282
}
283283
}
@@ -291,7 +291,7 @@ local doRelease :: () {
291291

292292
copyFilesInDirectory("exportTemplates", outputDir.."/exportTemplates", "%.lua$")
293293
copyFile(values.lovePath, format("%s/%s.love", outputDir, values.exeName))
294-
copyFile("misc/CHANGELOG.txt", format("%s/_Changelog.txt", outputDir))
294+
copyFile("misc/Changelog.txt", format("%s/_CHANGELOG.txt", outputDir))
295295
copyFile("misc/README.txt", format("%s/_README.txt", outputDir))
296296
copyFile("misc/README (universal).txt", format("%s/_README (universal).txt", outputDir))
297297
}

src/guiSetup.gloa

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3657,12 +3657,12 @@ export setupGuiCallbacks :: () {
36573657
local pathSet: struct { !key:string, !value:bool }
36583658

36593659
for project.systems {
3660-
local ok, path = resolveTextureOutputPath(project, it)
3660+
local ok, path, sameAsInput = resolveTextureOutputPath(project, it)
36613661
if not ok {
36623662
insert(textEl.textLines, "Missing/invalid texture path!")
36633663
} elseif not pathSet[path] {
36643664
pathSet[path] = true
3665-
insert(textEl.textLines, (doesFileExist(path) ? "[OVERWRITE] " : "")..path)
3665+
insert(textEl.textLines, (sameAsInput ? "[IN BASE] " : doesFileExist(path) ? "[OVERWRITE] " : "")..path)
36663666
}
36673667
}
36683668
}

src/misc.gloa

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
getModifierKey
2020
isInside
2121
limitArray, areArraysEqual
22-
log
22+
log, logNoTimestamp
2323
newMonochromeImage, newImageUsingPalette
2424
pcall_newImage, pcall_newShader
2525
prepareSandbox
@@ -313,14 +313,20 @@ export trim :: (s:string) -> string {
313313
export prepareSandbox :: (globals:table) -> (env:table) {
314314
local setMetatable :: (t:table, metatable:table) -> table !foreign lua "setmetatable"
315315

316-
local indexTable: table = {
316+
local sandboxPrint :: (...:any) {
317+
local values :: []string.{}
318+
for ... values[itIndex] = toString(it)
319+
logNoTimestamp(concatenate(values, "\t", 1, #...))
320+
}
321+
322+
local indexTable = table.{
317323
_VERSION = cast(any) !foreign lua "_VERSION",
318324
assert = cast(any) !foreign lua "assert",
319325
error = cast(any) !foreign lua "error",
320326
ipairs = cast(any) !foreign lua "ipairs",
321327
next = cast(any) !foreign lua "next",
322328
pairs = cast(any) !foreign lua "pairs",
323-
print = cast(any) !foreign lua "print",
329+
print = sandboxPrint,
324330
select = cast(any) !foreign lua "select",
325331
tonumber = cast(any) !foreign lua "tonumber",
326332
tostring = cast(any) !foreign lua "tostring",
@@ -401,7 +407,7 @@ export prepareSandbox :: (globals:table) -> (env:table) {
401407
for globals indexTable[itIndex] = it
402408

403409
setMetatable(env, {
404-
__newindex = (templateEnv:table, k:any, v:any) {
410+
__newindex = (templateEnv:table, k,v:any) {
405411
errorf(2, "cannot add global '%s' (globals are disabled)", toString(k))
406412
},
407413
__index = indexTable,
@@ -455,10 +461,18 @@ export log :: (s:string) {
455461
insert(logStrings, os.getDate"[%H:%M:%S] "..s)
456462
print(s)
457463
}
464+
export logNoTimestamp :: (s:string) {
465+
if logStrings[LOG_MAX_ENTRIES] ~= NULL remove(logStrings, 1)
466+
insert(logStrings, s)
467+
print(s)
468+
}
458469

459470
export log :: (s:string, v,...:int|float|string|Type) {
460471
log(format(s, v, ...))
461472
}
473+
export logNoTimestamp :: (s:string, v,...:int|float|string|Type) {
474+
logNoTimestamp(format(s, v, ...))
475+
}
462476

463477

464478

0 commit comments

Comments
 (0)