replace
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
10
resources.cm
10
resources.cm
@@ -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
|
||||
|
||||
@@ -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)");
|
||||
|
||||
Reference in New Issue
Block a user