public OptionList(GCSVTable csv, IGCSVCollection csvs, Utilities.VariableBin var, Func<IData,bool> selector) { Var = var; Options = new List<Option>(); foreach (var line in csv) { if (!selector(line)) continue; var o = new Option(); o.Parent = this; o.Caption = line["caption"]; o.ID = line["id"]; o.Active = line["active"].ToBool(); o.Default = line["default"]; var l = csvs[line["list"]]; o.Values = l.Where(m => !m.ContainsKey("active") || m["active"].ToBool()).Select(m => new KeyValuePair<string, string>(m[line["value"]], m[line["text"]])).ToList(); o.Initialize(); if (!var.Str.ContainsKey(o.ID) || !o.Active) // set defaults if variable is not set or option is not active var.Str[o.ID] = o.Default; if (var.Str.ContainsKey(o.ID)) o.ComboBox.SelectedIndex = o.Values.FindIndex(p => p.Key == var.Str[o.ID]); Options.Add(o); } }
public OptionList(GCSVTable csv, Func<IData, Options, string> getDefault, Func<string, Options> getList, Utilities.VariableBin var, Func<IData, bool> selector) { Var = var; Options = new List<Option>(); foreach (var line in csv) { if (!selector(line)) continue; var o = new Option(); o.Parent = this; o.Caption = line["caption"]; o.ID = line["id"]; o.Active = line["active"].ToBool(); var l = getList(line["list"]); o.Values = l.ToList(); o.Default = getDefault(line, o.Values); o.Initialize(); if (!var.Str.ContainsKey(o.ID)) var.Str[o.ID] = o.Default; if (var.Str.ContainsKey(o.ID)) o.ComboBox.SelectedIndex = o.Values.FindIndex(p => p.Key == var.Str[o.ID]); Options.Add(o); } }
// Use this for initialization public virtual void Start() { // Set verbose mode NatCam.Verbose = verbose; // Set the active camera NatCam.Camera = facing == Facing.Front ? DeviceCamera.FrontCamera : DeviceCamera.RearCamera; // Null checking if (!NatCam.Camera) { // Log Util.LogError("Active camera is null. Consider changing the facing of the camera"); return; } // Set the camera's preview resolution NatCam.Camera.SetPreviewResolution(previewResolution); // Set the camera's photo resolution NatCam.Camera.SetPhotoResolution(photoResolution); // Set the camera's framerate NatCam.Camera.SetFramerate(framerate); // Play NatCam.Play(); // Register callback for when the preview starts //Note that this is a MUST when assigning the preview texture to anything NatCam.OnStart += OnStart; // Register for preview updates NatCam.OnFrame += OnFrame; }
public static void DetectBarcode(MetadataCallback <Barcode> callback, BarcodeFormat format = BarcodeFormat.ALL, bool detectOnce = true) { if (!Implementation.SupportsMetadata) { Util.LogError("Current platform does not support metadata detection"); return; } if (callback == null) { Util.LogError("Cannot detect barcode with no callback"); return; } MetadataCallback <IMetadata> callbackWrapper = null; callbackWrapper = barcode => { if (!(barcode is Barcode)) { return; } if ((((Barcode)barcode).format & format) == 0) { return; } if (detectOnce) { Implementation.OnMetadata -= callbackWrapper; } callback((Barcode)barcode); }; Implementation.OnMetadata += callbackWrapper; }
public void remove(Utilities.Vec2Int key) { if (key == null) return; mStaticWalls.Remove(key); }
/// <summary> /// Detect a text /// </summary> /// <param name="callback">Callback to be invoked with the detected text</param> /// <param name="detectOnce">If true, at most one text will be detected</param> public static void DetectText(MetadataCallback <Text> callback, bool detectOnce = true) // NCDOC { if (!Implementation.SupportsMetadata) { Util.LogError("Current platform does not support metadata detection"); return; } if (callback == null) { Util.LogError("Cannot detect text with no callback"); return; } MetadataCallback <IMetadata> callbackWrapper = null; callbackWrapper = text => { if (!(text is Text)) { return; } if (detectOnce) { Implementation.OnMetadata -= callbackWrapper; } callback((Text)text); }; Implementation.OnMetadata += callbackWrapper; }
public static void StopRecording() { if (!Implementation.SupportsRecording) { Util.LogError("Cannot stop recording video because implementation does not support recording"); return; } Implementation.StopRecording(); }
public PlaceableStaticWall getSide(Utilities.SIDE_4 side) { PlaceableStaticWall retVal = null; Tile adjTile = null; switch (side) { case Utilities.SIDE_4.RIGHT: if (bottomRight != null) { adjTile = bottomRight.getSide(side); if (adjTile != null) retVal = adjTile.getObject() as PlaceableStaticWall; } break; case Utilities.SIDE_4.TOP: if (topRight != null) { adjTile = topRight.getSide(side); if (adjTile != null) retVal = adjTile.getObject() as PlaceableStaticWall; } break; case Utilities.SIDE_4.LEFT: if (bottomLeft != null) { adjTile = bottomLeft.getSide(side); if (adjTile != null) retVal = adjTile.getObject() as PlaceableStaticWall; } break; case Utilities.SIDE_4.BOTTOM: if (bottomRight != null) { adjTile = bottomRight.getSide(side); if (adjTile != null) retVal = adjTile.getObject() as PlaceableStaticWall; } break; default: return null; } return retVal; }
public virtual void OnStart() { // Set the preview RawImage texture once the preview starts if (preview != null) { preview.texture = NatCam.Preview; } // Log else { Util.LogError("Preview RawImage has not been set"); } Util.LogVerbose("Preview started with dimensions: " + new Vector2(NatCam.Preview.width, NatCam.Preview.height)); }
public static void CapturePhoto(PhotoCallback callback) { if (callback == null) { Util.LogError("Cannot capture photo when callback is null"); return; } if (!Implementation.IsPlaying) { Util.LogError("Cannot capture photo when session is not running"); return; } Implementation.CapturePhoto(callback); }
public static void StartRecording(Configuration configuration, SaveCallback callback) { if (!Implementation.SupportsRecording) { Util.LogError("Cannot record video because implementation does not support recording"); return; } if (!IsPlaying) { Util.LogError("Cannot record video when session is not running"); return; } if (callback == null) { Util.LogError("Cannot record video without callback"); return; } Implementation.StartRecording(configuration, callback); }
public static void StartRecording(SaveCallback callback = null) { if (!Implementation.SupportsRecording) { Util.LogError("Cannot record video because implementation does not support recording"); return; } if (!IsPlaying) { Util.LogError("Cannot record video when session is not running"); return; } if (IsRecording) { Util.LogError("Cannot record video because video is already being recorded"); return; } Implementation.StartRecording(callback); }
public static void SavePhoto(Texture2D photo, SaveMode mode = SaveMode.SaveToAppDocuments, Orientation orientation = 0, SaveCallback callback = null) { if (photo == null) { return; } if (orientation != 0) { IDispatch main = new MainDispatch(), worker = new ConcurrentDispatch(); Util.RotateImage(Texture2D.Instantiate(photo), orientation, worker, main, (rotated, unused) => { Implementation.SavePhoto(rotated.EncodeToPNG(), mode, callback); Texture2D.Destroy(rotated); main.Release(); worker.Release(); }); } else { Implementation.SavePhoto(photo.EncodeToPNG(), mode, callback); } }
/// <summary> /// Detect a face /// </summary> /// <param name="callback">Callback to be invoked with the detected face</param> public static void DetectFace(MetadataCallback <Face> callback) // NCDOC { if (!Implementation.SupportsMetadata) { Util.LogError("Current platform does not support metadata detection"); return; } if (callback == null) { Util.LogError("Cannot detect face with no callback"); return; } MetadataCallback <IMetadata> callbackWrapper = null; callbackWrapper = face => { if (face is Face) { callback((Face)face); } }; Implementation.OnMetadata += callbackWrapper; }
protected Tile getTile(Utilities.Vec2Int v) { Utilities.Vec2Int basePos; if (_area.GetLength(0) % 2 == 0) //Is it even basePos = _map.toLogicalTilePos(transform.position + Utilities.Math.toVector3(Map.tileSize / 2)); else basePos = _map.toLogicalTilePos(transform.position); return _map.getExistingTile(basePos + v); }
protected override bool isValidTile(int areaX, int areaY, Utilities.Vec2Int tilePos) { if (areaX < 0 || areaX >= _area.GetLength(0)) return false; else if (areaY < 0 || areaY >= _area.GetLength(1)) return false; if (_area[areaX, areaY]) { Tile tile = getTile(tilePos); if (tile == null || !tile.hasObject() || !(tile.getObject() is PlaceableStaticWall)) return false; } return true; }
public void SetFlipy(bool ifenable) { Util.LogError("Flipy is not supported on legacy"); }
protected override bool isValidTile(int areaX, int areaY, Utilities.Vec2Int tilePos) { if (areaX < 0 || areaX >= _area.GetLength(0)) return false; else if (areaY < 0 || areaY >= _area.GetLength(1)) return false; if (_area[areaX, areaY]) { Tile tile = getTile(tilePos); if (tile == null || (tile.hasObject() && tile.getObject().getID() != getID())) return false; } return true; }
protected abstract bool isValidTile(int areaX, int areaY, Utilities.Vec2Int tilePos);