This commit is contained in:
2026-01-18 08:55:22 -06:00
parent 92b1252c82
commit 23dc5820ee
5 changed files with 16 additions and 12 deletions

View File

@@ -31,8 +31,8 @@ grid.prototype = {
// remove an entity from a cell
remove(entity, pos) {
def c = this.cell(pos.x, pos.y);
def i = c.indexOf(entity);
if (i != -1) c.splice(i, 1);
def i = search(c, entity);
if (i !== null) c.splice(i, 1);
},
// bounds check

View File

@@ -158,14 +158,14 @@ film2d.unregister = function(id) {
film2d.index_group = function(id, group) {
if (!group_index[group]) group_index[group] = []
if (group_index[group].indexOf(text(id)) < 0)
if (search(group_index[group], text(id)) == null)
group_index[group].push(text(id))
}
film2d.unindex_group = function(id, group) {
if (!group_index[group]) return
var idx = group_index[group].indexOf(text(id))
if (idx >= 0) group_index[group].splice(idx, 1)
var idx = search(group_index[group], text(id))
if (idx != null) group_index[group].splice(idx, 1)
}
film2d.reindex = function(id, old_groups, new_groups) {
@@ -192,7 +192,7 @@ film2d.query = function(selector) {
// If also filtering by group, check membership
if (selector.group) {
var groups = d.groups || []
if (groups.indexOf(selector.group) >= 0) result.push(d)
if (search(groups, selector.group) != null) result.push(d)
} else {
result.push(d)
}

View File

@@ -80,7 +80,7 @@ function make(defaults, display_names) {
if (device_kind == 'keyboard') {
if (starts_with(binding, 'mouse_button_')) {
var button = binding.replace('mouse_button_', '')
var button = replace(binding, 'mouse_button_', '')
return 'ui/mouse/mouse_' + button + '.png'
} else {
var key_map = {
@@ -140,7 +140,7 @@ function make(defaults, display_names) {
// Remove from other actions
for (var act in this.action_map) {
var idx = this.action_map[act].indexOf(new_control)
var idx = search(this.action_map[act], new_control)
if (idx >= 0) this.action_map[act].splice(idx, 1)
}

View File

@@ -21,9 +21,13 @@ Resources.lib = [".so", ".dll", ".dylib"]
// Helper function: get extension from path in lowercase (e.g., "image.png" -> "png")
function getExtension(path) {
var idx = path.lastIndexOf('.')
if (idx < 0) return ''
return lower(text(path, idx + 1))
var last = null
replace(path, ".", function(m,pos) {
last = pos
return m
})
if (last == null) return null
return lower(text(path, last + 1))
}
// Return true if ext is in at least one of the recognized lists

View File

@@ -89,7 +89,7 @@ function capture_test() {
}
// If YUV format, try BT.709 (HD video standard)
if (surf.format.indexOf("yuv") != -1 || surf.format.indexOf("yuy") != -1) {
if (search(surf.format, "yuv") != null || search(surf.format, "yuy") != null) {
try {
var hd_surf = surf.convert(surf.format, "bt709_limited");
log.console(" Converted to BT.709 limited (HD video standard)");