public DataMap RegisterDefaultData(DataMap _DataMap) { Debug.Log("Resetting Data"); _DataMap.Clear(); _DataMap.RegisterData("SensitivityX", 4f); _DataMap.RegisterData("SensitivityY", 4f); _DataMap.RegisterData("InvertPitch", true); return _DataMap; }
async void HandleMessage(IMessageEvent message) { try { Android.Util.Log.Info("WearIntegration", "Received Message"); var client = new GoogleApiClientBuilder(this) .AddApi(WearableClass.API) .Build(); var result = client.BlockingConnect(30, Java.Util.Concurrent.TimeUnit.Seconds); if (!result.IsSuccess) return; var path = message.Path; try { if (path.StartsWith(TweetsPath)) { var viewModel = new TwitterViewModel(); await viewModel.ExecuteLoadTweetsCommand(); var request = PutDataMapRequest.Create(TweetsPath + "/Answer"); var map = request.DataMap; var tweetMap = new List<DataMap>(); foreach (var tweet in viewModel.Tweets) { var itemMap = new DataMap(); itemMap.PutLong("CreatedAt", tweet.CreatedAt.Ticks); itemMap.PutString("ScreenName", tweet.ScreenName); itemMap.PutString("Text", tweet.Text); tweetMap.Add(itemMap); } map.PutDataMapArrayList("Tweets", tweetMap); map.PutLong("UpdatedAt", DateTime.UtcNow.Ticks); await WearableClass.DataApi.PutDataItem(client, request.AsPutDataRequest()); } } finally { client.Disconnect(); } } catch (Exception e) { Android.Util.Log.Error("WearIntegration", e.ToString()); } }
public PutDataRequest ToPutDataRequest() { PutDataMapRequest request = PutDataMapRequest.Create("/question/" + questionIndex); DataMap dataMap = request.DataMap; dataMap.PutString(Constants.QUESTION, question); dataMap.PutInt(Constants.QUESTION_INDEX, questionIndex); dataMap.PutStringArray(Constants.ANSWERS, answers); dataMap.PutInt(Constants.CORRECT_ANSWER_INDEX, correctAnswerIndex); return(request.AsPutDataRequest()); }
/// <summary> /// Invoked when a data map is selected on the screen. /// </summary> /// <param name="dataMap">The data map just selected.</param> private void OnDataMapSelected(DataMap dataMap) { var searchBar = _searchBar; if (null != searchBar) { searchBar.ResignFirstResponder(); } SimpleEventBus.Publish(new DataMapSelected(dataMap, false)); }
public DataMap GetDataMap(uint i) { DataMap entry = null; if (i < numDataMaps) { uint offset = 16 /*sizeof(header) */ + 12 /*sizeof(DataMap) */ * i; entry = new DataMap(offset, m_bufTable); } return(entry); }
private void OnDataVerified(DataVerified data) { Notifications.Enqueue(new DataVerifiedNotification(data.Hash, data.Bitfield)); DataMap?.Handle(data); DataGet?.Handle(data); DataShare?.Handle(data); Coordinator?.Handle(data); TrackerGet.Announce(Hash); }
private void HandleAffectDateAndTime(DataMap resultObject, ApplicationMetadata application) { var originalDateTime = resultObject.GetAttribute("affecteddate", true); resultObject.Attributes["#affecteddateonly"] = originalDateTime; resultObject.Attributes["#affectedtime"] = originalDateTime; var user = SecurityFacade.CurrentUser(); resultObject.Attributes["isitcortom"] = ShouldShowITC(user); }
public static T GetData <T>(string serviceId, DataMap parameter) { try { return(GetData <T>(serviceId, null, null, parameter)); } catch { throw; } }
public static bool HasAutoGeneratedPrimaryKey(DataMap map, SyncSide syncSide) { if (GetEntityDefinition(map, syncSide).PrimaryKeyGenerationType == PrimaryKeyGenerationType.AutoGenerate) { return(true); } else { return(false); } }
/// <summary> /// /// </summary> /// <param name="ID"></param> /// <returns></returns> public static Packet Profile(string ID) { Packet packet = new Packet(); packet.Command = "SUB PROFILE QUERY"; var datamap = new DataMap(); datamap.SetValue("Sub-Id", ID); packet.Payload = Static.PalringoEncoding.GetString(datamap.Serialize()); return(packet); }
public string apply(DataMap map) { var parameters = new object[_fieldNames.Count]; for (int i = 0; i < _fieldNames.Count(); i++) { dynamic obj = map.Attributes[_fieldNames[i]]; parameters[i] = obj; } return(String.Format(_constExpression, parameters)); }
private static string NormalizeStatus(DataMap dataMap) { var maxstatus = dataMap.Value("synstatus_.maxvalue"); // We'll perform a case-insensitive // comparison in the Maximo status // (as the synonym is customizable). return(null != maxstatus ? maxstatus.ToUpperInvariant() : null); }
public HeapData GetData(uint addr) { if (DataMap.TryGetValue(addr, out HeapData data)) { return(data); } else { throw new XiVMError($"Invalid Heap address {addr}"); } }
/// <summary> /// Adds or overrides value in the cache. /// </summary> /// <param name="Field">The field info of the class.</param> /// <param name="Value">The value to store.</param> public void SetValue(FieldInfo Field, object Value) { if (DataMap.ContainsKey(Field)) { DataMap[Field] = Value; } else { DataMap.Add(Field, Value); } }
public SimpleTimeEntryData(DataMap map) { dataMap = map; id = map.Get(nameof(id), Guid.Empty); isRunning = map.Get(nameof(isRunning), false); description = map.Get(nameof(description), string.Empty); project = map.Get(nameof(project), string.Empty); projectColor = map.Get(nameof(projectColor), string.Empty); startTime = map.Get(nameof(startTime), DateTime.UtcNow); stopTime = map.Get(nameof(stopTime), DateTime.UtcNow); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="resultcount"></param> /// <returns></returns> public static Packet GroupQuery(string name, int resultcount) { var map = new DataMap(); var pack = new Packet { Command = "PROVIF QUERY" }; map.SetValue("action", "palringo_groups"); map.SetValue("parameters", "offset=0&max_results=" + resultcount + "&name=" + System.Uri.EscapeDataString(name)); pack.Payload = Static.PalringoEncoding.GetString(map.Serialize()); return(pack); }
public override void OnBeforeUpload(OnBeforeUploadContext context, DataMap dataMap) { base.OnBeforeUpload(context, dataMap); // TODO: solve the conundrum of not // being able to send the wo status // when uploading existing orders. if (false == dataMap.LocalState.IsLocal) { context.Content.Remove("status"); } }
/// <summary> /// /// </summary> /// <param name="userid"></param> /// <returns></returns> public static Packet UserQuery(int userid) { var newmap = new DataMap(); var pcck = new Packet { Command = "PROVIF QUERY" }; newmap.SetValue("action", "palringo_profile_info"); newmap.SetValue("parameters", "id=" + userid); pcck.Payload = Static.PalringoEncoding.GetString(newmap.Serialize()); return(pcck); }
public Object GetMap(DataMap asMap) { var theEvent = asMap.Get(_propertyName) as EventBean; if (theEvent == null) { return(null); } // If the map does not contain the key, this is allowed and represented as null return(theEvent.Underlying); }
public IPacket UserInfo(string id) { var map = new DataMap(); map.SetValue("Sub-Id", id); return(new Packet { Command = "SUB PROFILE QUERY", Payload = map.Serialize() }); }
public void BindData(string groupCode, DataMap parameters = null, string nullText = null, bool init = false) { if (init == true || _IsSetInit == false) { if (nullText.IsNullOrEmpty()) { SetDefault(); } else { SetNullText(nullText); } } if (groupCode.IsNullOrEmpty() == false) { GroupCode = groupCode; } object value = null; if (DataSource != null && EditValue != null) { value = EditValue; } DataSource = CodeHelper.Lookup(GroupCode, parameters); if (RowCount > 0) { if (value != null) { EditValue = value; } else { if (Properties.AllowNullInput == DefaultBoolean.False) { SelectedIndex = 0; } else { EditValue = null; } } if (RowCount <= 20) { Properties.DropDownRows = RowCount; } else { Properties.DropDownRows = 20; } } }
public ICollection <EventBean> Get(EventBean theEvent, DataMap parent, ExprEvaluatorContext context) { _events[_lookupStream] = theEvent; var mk = EventBeanUtility.GetMultiKey(_events, _evaluators, context, _keyCoercionTypes); var innerIndex = (DataMap)parent.Get(mk); if (innerIndex == null) { return(null); } return(_next.Get(theEvent, innerIndex, context)); }
void SetupAllPickers(DataMap config) { SetupColorPickerSelection(Resource.Id.Background, KeyBackgroundColor, config, Resource.String.ColorBlack); SetupColorPickerSelection(Resource.Id.Hours, KeyHoursColor, config, Resource.String.ColorWhite); SetupColorPickerSelection(Resource.Id.Minutes, KeyMinutesColor, config, Resource.String.ColorWhite); SetupColorPickerSelection(Resource.Id.Seconds, KeySecondsColor, config, Resource.String.ColorGray); SetUpColorPickerListener(Resource.Id.Background, KeyBackgroundColor); SetUpColorPickerListener(Resource.Id.Hours, KeyHoursColor); SetUpColorPickerListener(Resource.Id.Minutes, KeyMinutesColor); SetUpColorPickerListener(Resource.Id.Seconds, KeySecondsColor); }
// Use this for initialization void Start() { _curPower = 0; _bGunner = GetComponent <BeamGunner>(); CreateBulletPool(); _controls = GameObject.Find("_GameRegistry").GetComponent <ControlMap>(); _data = GameObject.Find("_GameRegistry").GetComponent <DataMap>(); _nextFireTime = Time.time + fireRate; _health = maxHealth; _cam = Camera.main.transform; _mouseMode = _data.GetBool("MouseMode"); }
public void TestConvert() { var t1 = new List <float>(new float[] { 1, 0, 0 }); var d = new DataMap(); d.Add("foo", t1); var t2 = d["foo"].ToArray <bool>(); Assert.Equal(new bool[] { true, false, false }, t2); }
/// <summary> /// Intializes a new instance. /// </summary> internal MapColumnCollection(DataMap <T> map) { if (map == null) { throw new ArgumentNullException("map", "Meta Map cannot be null."); } if (map.IsDisposed) { throw new ObjectDisposedException(map.ToString()); } _Map = map; }
public void TestAsArrayKeepsArrayInstance() { var t1 = new float[] { 1, 2, 3 }; var d = new DataMap(); d.Add("foo", t1); var t2 = d["foo"].AsArray <float>(); Assert.True(ReferenceEquals(t1, t2)); }
public DataMap GetFeatureImportance(Booster.ImportanceType importanceType, int numIteration = 0) { var featureNames = _predicator.Booster.FeatureNames; var imp = _predicator.Booster.GetFeatureImportance(numIteration, importanceType); var result = new DataMap(); result.Add("Name", featureNames); result.Add("Importance", imp); return(result); }
public static EventsSave Restore(TypeDesc typeDesc, SaveInfo info, ref ByteStreamReader bsr) { int count = bsr.ReadSInt(); // inline version of reading embedded field of type CBaseEntityOutput (it only contains 1 field) if (bsr.ReadSShort() != 4) { throw new ConstraintException("first entry in data map should be 4"); } string?mapSym = bsr.ReadSymbol(info); if (mapSym != "Value") { throw new ConstraintException($"bad symbol, expected \"Value\" but read \"{mapSym}\""); } int fieldsSaved = bsr.ReadSInt(); ParsedSaveField?psf = null; if (fieldsSaved == 1) { bsr.StartBlock(info, out string?sym); if (sym != "m_Value") { throw new ConstraintException($"bad symbol, expected \"m_Value\" but read \"{sym}\""); } FieldType type = (FieldType)bsr.ReadSInt(); string? s = FieldNameFromType(type); if (s != null) { TypeDesc t = new TypeDesc(s, type); DataMap m = new DataMap("m_Value", new [] { t }); var pm = bsr.ReadDataMap(m, info); if (pm.ParsedFields.Any()) { psf = pm.ParsedFields.Single().Value; } } bsr.EndBlock(info); } else if (fieldsSaved != 0) { throw new ConstraintException($"expected 0 fields, got {fieldsSaved}"); } ParsedDataMap[] events = new ParsedDataMap[count]; for (int i = 0; i < count; i++) { events[i] = bsr.ReadDataMap("EntityOutput", info); } return(new EventsSave(typeDesc, psf, events)); }
public void TestToArrayCopyData() { var t1 = new float[] { 1, 2, 3 }; var d = new DataMap(); d.Add("foo", t1); var t2 = d["foo"].ToArray <float>(); Assert.False(ReferenceEquals(t1, t2)); }
private void LoadData() { Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Player"), LayerMask.NameToLayer("Enemy")); SceneManager.sceneLoaded += (Scene, Load) => Languages.UpdateLanguageInScene(); Languages.LanguageCurrent = Languages.Nation.VietNam; Languages.LoadData(); VFXManager.LoadData(); ChestManager.LoadData(); RewardManager.LoadData(); WeaponManager.LoadData(); DataMap.LoadData(); }
public void TestToListCopyData() { var t1 = new List <int>(new[] { 1, 2, 3 }); var d = new DataMap(); d.Add("foo", t1); var t2 = d["foo"].ToList <int>(); Assert.False(ReferenceEquals(t1, t2)); }
protected void Page_Load(object sender, EventArgs e) { if (!ReadNodeId()) Response.Redirect("Error.aspx"); string vxkConnection = ConfigurationHelper.ReadString("VXK.Connection"); TimeSpan vxkTimeout = ConfigurationHelper.ReadTimeSpan("VXK.Timeout"); VXStorageConnection conn = new VXSqlStorageConnection(); conn.Parse(vxkConnection); VXKManager vxk = new VXKSqlManager(conn); vxk.CommandTimeout = vxkTimeout; DataMap map = new DataMap(); map.Load(vxk, m_nodeId); m_renderedItems = map.BuildRenderedItems(); }
void CreateMaps() { maps = new List<DataMap>(); DataMap map; // * // MAP 404 map = new DataMap(); map.ID = 0; map.Name = "???"; map.Width = 0; map.Height = 0; map.Tilemap = new int[0,0]{}; maps.Add(map); // * // MAP 001 map = new DataMap(); map.ID = 1; map.Name = "Test Map"; map.Width = 19; map.Height = 15; map.Tilemap = new int[15, 19] { {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} }; maps.Add(map); }
void Start() { dataMap = new DataMap(Constants.mapWidth, Constants.mapHeight); float horizontalOffset = (Constants.mapWidth / 2) * Constants.tileSize; float verticatOffset = (Constants.mapHeight / 2) * Constants.tileSize; for (int i = 0; i < Constants.mapWidth; i++) { for (int j = 0; j < Constants.mapHeight; j++) { Vector3 position = new Vector3( i * Constants.tileSize - horizontalOffset, j * Constants.tileSize - verticatOffset, 0); GameObject newTile = Instantiate(Resources.Load("Prefabs/tile_prefab"), position, Quaternion.identity) as GameObject; newTile.transform.parent = this.transform; newTile.name = "tile (" + i.ToString() + ", " + j.ToString() + ")"; DrawTile drawComponent = newTile.GetComponent<DrawTile>(); drawComponent.Initilalize(dataMap.GetTileAt(i, j)); } } }
void LoadInputSettings() { Debug.Log("Loading Configs"); string configPath = Application.dataPath+"/KeyConfigs.txt"; string dataPath = Application.dataPath+"/DataConfigs.txt"; if(File.Exists(configPath)) { _Controls.LoadMap(File.ReadAllLines(configPath)); } else { Debug.Log("Creating Config File"); StreamWriter configFile = File.CreateText(configPath); _Controls = _Controls.RegisterDefaultControls(_Controls); string[] controlMapping = _Controls.GetMap(); foreach(string s in controlMapping) { configFile.WriteLine(s); } configFile.Flush(); } if(File.Exists(dataPath)) { _Data.LoadMap(File.ReadAllLines(dataPath)); }else { Debug.Log("Creating Data File"); StreamWriter dataFile = File.CreateText(dataPath); _Data = _Data.RegisterDefaultData(_Data); string[] dataMapping = _Data.GetMap(); foreach(string s in dataMapping) { dataFile.WriteLine(s); } dataFile.Flush(); } }
void addIntKeyIfMissing(DataMap config, string key, int color) { if (!config.ContainsKey (key)) { config.PutInt (key, color); } }
public static void PutConfigDataItem(IGoogleApiClient googleApiClient, DataMap newConfig) { var putDataMapRequest = PutDataMapRequest.Create (PathWithFeature); var configToPut = putDataMapRequest.DataMap; configToPut.PutAll (newConfig); WearableClass.DataApi.PutDataItem (googleApiClient, putDataMapRequest.AsPutDataRequest ()) .SetResultCallback (new DataItemResultCallback(dataItemResult => { if (Log.IsLoggable (Tag, LogPriority.Debug)) { Log.Debug (Tag, "PutDataItem result status: " + dataItemResult.Status); } }) ); }
public static void OverwriteKeysInConfigDataMap(IGoogleApiClient googleApiClient, DataMap configKeysToOverwrite) { FetchConfigDataMap (googleApiClient, new DataItemResultCallback(dataItemResult => { var overwrittenConfig = new DataMap (); if (dataItemResult.DataItem != null) { var dataItem = dataItemResult.DataItem; var dataMapItem = DataMapItem.FromDataItem (dataItem); var currentConfig = dataMapItem.DataMap; overwrittenConfig.PutAll (currentConfig); } overwrittenConfig.PutAll (configKeysToOverwrite); DigitalWatchFaceUtil.PutConfigDataItem (googleApiClient, overwrittenConfig); }) ); }
void SetDefaultValuesForMissingKeys(DataMap config) { addIntKeyIfMissing (config, DigitalWatchFaceUtil.KeyBackgroundColor, DigitalWatchFaceUtil.ColorValueDefaultAndAmbientBackground); addIntKeyIfMissing (config, DigitalWatchFaceUtil.KeyHoursColor, DigitalWatchFaceUtil.ColorValueDefaultAndAmbientHourDigits); addIntKeyIfMissing (config, DigitalWatchFaceUtil.KeyMinutesColor, DigitalWatchFaceUtil.ColorValueDefaultAndAmbientMinuteDigits); addIntKeyIfMissing (config, DigitalWatchFaceUtil.KeySecondsColor, DigitalWatchFaceUtil.ColorValueDefaultAndAmbientSecondDigits); }
async void HandleMessage (IMessageEvent message) { try { Android.Util.Log.Info ("WearIntegration", "Received Message"); var client = new GoogleApiClientBuilder (this) .AddApi (LocationServices.API) .AddApi (WearableClass.API) .Build (); var result = client.BlockingConnect (30, Java.Util.Concurrent.TimeUnit.Seconds); if (!result.IsSuccess) return; var path = message.Path; try { var stations = Hubway.Instance.LastStations; if (stations == null) stations = await Hubway.Instance.GetStations (); if (path.StartsWith (SearchStationPath)) { var lastLocation = LocationServices.FusedLocationApi.GetLastLocation (client); if (lastLocation == null) return; var currentPoint = new GeoPoint { Lat = lastLocation.Latitude, Lon = lastLocation.Longitude }; var nearestStations = Hubway.GetStationsAround (stations, currentPoint, maxItems: 6, minDistance: double.MaxValue); var favManager = FavoriteManager.Obtain (this); var favorites = await favManager.GetFavoriteStationIdsAsync (); var request = PutDataMapRequest.Create (SearchStationPath + "/Answer"); var map = request.DataMap; var stationMap = new List<DataMap> (); foreach (var station in nearestStations) { var itemMap = new DataMap (); itemMap.PutInt ("Id", station.Id); var asset = await CreateWearAssetFrom (station); itemMap.PutAsset ("Background", asset); string secondary; string primary = StationUtils.CutStationName (station.Name, out secondary); itemMap.PutString ("Primary", primary); itemMap.PutString ("Secondary", secondary); var distance = GeoUtils.Distance (currentPoint, station.Location); itemMap.PutDouble ("Distance", distance); itemMap.PutDouble ("Lat", station.Location.Lat); itemMap.PutDouble ("Lon", station.Location.Lon); itemMap.PutInt ("Bikes", station.BikeCount); itemMap.PutInt ("Racks", station.EmptySlotCount); itemMap.PutBoolean ("IsFavorite", favorites.Contains (station.Id)); stationMap.Add (itemMap); } map.PutDataMapArrayList ("Stations", stationMap); map.PutLong ("UpdatedAt", DateTime.UtcNow.Ticks); await WearableClass.DataApi.PutDataItem (client, request.AsPutDataRequest ()); } else { var uri = new Uri ("wear://watch" + path); var query = uri.GetComponents (UriComponents.Query, UriFormat.Unescaped); var parts = uri.GetComponents (UriComponents.Path, UriFormat.Unescaped).Split ('/'); var action = parts[parts.Length - 2]; var id = int.Parse (parts.Last ()); if (action == FavoriteAction) { var favorites = FavoriteManager.Obtain (this); handler.Post (() => { if (query == "add") favorites.AddToFavorite (id); else favorites.RemoveFromFavorite (id); }); } } } finally { client.Disconnect (); } } catch (Exception e) { Android.Util.Log.Error ("WearIntegration", e.ToString ()); AnalyticsHelper.LogException ("WearIntegration", e); } }
void SendConfigurationUpdateMessage(string configKey, int color) { if (peerId != null) { var config = new DataMap (); config.PutInt (configKey, color); WearableClass.MessageApi.SendMessage (googleApiClient, peerId, PathWithFeature, config.ToByteArray ()); if (Log.IsLoggable (Tag, LogPriority.Debug)) { Log.Debug (Tag, string.Format ("Sent watch face configuration messahe: {0} -> {1}", configKey, Integer.ToHexString (color))); } } }
private bool DecodePayload(AlternativeCompositeByteBuf buffer) { Logger.Debug("About to pass message {0} to {1}. Buffer to read: {2}.", Message, Message.SenderSocket, buffer.ReadableBytes); if (!Message.HasContent()) { return true; } int size; IPublicKey receivedPublicKey; while (_contentTypes.Count > 0) { Message.Content content = _contentTypes.Peek(); Logger.Debug("Go for content: {0}.", content); switch (content) { case Message.Content.Integer: if (buffer.ReadableBytes < Utils.Utils.IntegerByteSize) { return false; } Message.SetIntValue(buffer.ReadInt()); LastContent = _contentTypes.Dequeue(); break; case Message.Content.Long: if (buffer.ReadableBytes < Utils.Utils.LongByteSize) { return false; } Message.SetLongValue(buffer.ReadLong()); LastContent = _contentTypes.Dequeue(); break; case Message.Content.Key: if (buffer.ReadableBytes < Number160.ByteArraySize) { return false; } var keyBytes = new sbyte[Number160.ByteArraySize]; buffer.ReadBytes(keyBytes); Message.SetKey(new Number160(keyBytes)); LastContent = _contentTypes.Dequeue(); break; case Message.Content.BloomFilter: if (buffer.ReadableBytes < Utils.Utils.ShortByteSize) { return false; } size = buffer.GetUShort(buffer.ReaderIndex); if (buffer.ReadableBytes < size) { return false; } Message.SetBloomFilter(new SimpleBloomFilter<Number160>(buffer)); LastContent = _contentTypes.Dequeue(); break; case Message.Content.SetNeighbors: if (_neighborSize == -1 && buffer.ReadableBytes < Utils.Utils.ByteByteSize) { return false; } if (_neighborSize == -1) { _neighborSize = buffer.ReadByte(); } if (_neighborSet == null) { _neighborSet = new NeighborSet(-1, new List<PeerAddress>(_neighborSize)); } for (int i = _neighborSet.Size; i < _neighborSize; i++) { if (buffer.ReadableBytes < Utils.Utils.ShortByteSize) { return false; } int header = buffer.GetUShort(buffer.ReaderIndex); size = PeerAddress.CalculateSize(header); if (buffer.ReadableBytes < size) { return false; } var pa = new PeerAddress(buffer); _neighborSet.Add(pa); } Message.SetNeighborSet(_neighborSet); LastContent = _contentTypes.Dequeue(); _neighborSize = -1; // TODO why here? not in prepareFinish()? _neighborSet = null; break; case Message.Content.SetPeerSocket: if (_peerSocketAddressSize == -1 && buffer.ReadableBytes < Utils.Utils.ByteByteSize) { return false; } if (_peerSocketAddressSize == -1) { _peerSocketAddressSize = buffer.ReadUByte(); } if (_peerSocketAddresses == null) { _peerSocketAddresses = new List<PeerSocketAddress>(_peerSocketAddressSize); } for (int i = _peerSocketAddresses.Count; i < _peerSocketAddressSize; i++) { if (buffer.ReadableBytes < Utils.Utils.ByteByteSize) { return false; } int header = buffer.GetUByte(buffer.ReaderIndex); bool isIPv4 = header == 0; // TODO check if works size = PeerSocketAddress.Size(isIPv4); if (buffer.ReadableBytes < size + Utils.Utils.ByteByteSize) { return false; } // skip the ipv4/ipv6 header buffer.SkipBytes(1); _peerSocketAddresses.Add(PeerSocketAddress.Create(buffer, isIPv4)); } Message.SetPeerSocketAddresses(_peerSocketAddresses); LastContent = _contentTypes.Dequeue(); _peerSocketAddressSize = -1; // TODO why here? not in prepareFinish()? _peerSocketAddresses = null; break; case Message.Content.SetKey640: if (_keyCollectionSize == -1 && buffer.ReadableBytes < Utils.Utils.IntegerByteSize) { return false; } if (_keyCollectionSize == -1) { _keyCollectionSize = buffer.ReadInt(); } if (_keyCollection == null) { _keyCollection = new KeyCollection(new List<Number640>(_keyCollectionSize)); } for (int i = _keyCollection.Size; i < _keyCollectionSize; i++) { if (buffer.ReadableBytes < 4 * Number160.ByteArraySize) { return false; } var me = new sbyte[Number160.ByteArraySize]; buffer.ReadBytes(me); var locationKey = new Number160(me); buffer.ReadBytes(me); var domainKey = new Number160(me); buffer.ReadBytes(me); var contentKey = new Number160(me); buffer.ReadBytes(me); var versionKey = new Number160(me); _keyCollection.Add(new Number640(locationKey, domainKey, contentKey, versionKey)); } Message.SetKeyCollection(_keyCollection); LastContent = _contentTypes.Dequeue(); _keyCollectionSize = -1; // TODO why here? not in prepareFinish()? _keyCollection = null; break; case Message.Content.MapKey640Data: if (_mapSize == -1 && buffer.ReadableBytes < Utils.Utils.IntegerByteSize) { return false; } if (_mapSize == -1) { _mapSize = buffer.ReadInt(); } if (_dataMap == null) { _dataMap = new DataMap(new Dictionary<Number640, Data>(2 * _mapSize)); } if (_data != null) { if (!_data.DecodeBuffer(buffer)) { return false; } if (!_data.DecodeDone(buffer, Message.PublicKey(0), _signatureFactory)) { return false; } _data = null; // TODO why here? not in prepareFinish()? _key = null; } for (int i = _dataMap.Size; i < _mapSize; i++) { if (_key == null) { if (buffer.ReadableBytes < 4 * Number160.ByteArraySize) { return false; } var me = new sbyte[Number160.ByteArraySize]; buffer.ReadBytes(me); var locationKey = new Number160(me); buffer.ReadBytes(me); var domainKey = new Number160(me); buffer.ReadBytes(me); var contentKey = new Number160(me); buffer.ReadBytes(me); var versionKey = new Number160(me); _key = new Number640(locationKey, domainKey, contentKey, versionKey); } _data = Data.DeocdeHeader(buffer, _signatureFactory); if (_data == null) { return false; } _dataMap.BackingDataMap.Add(_key, _data); if (!_data.DecodeBuffer(buffer)) { return false; } if (!_data.DecodeDone(buffer, Message.PublicKey(0), _signatureFactory)) { return false; } // if we have signed the message, set the public key anyway, but only if we indicated so if (Message.IsSign && Message.PublicKey(0) != null && _data.HasPublicKey && (_data.PublicKey == null || _data.PublicKey == PeerBuilder.EmptyPublicKey)) // TODO check empty key condition { _data.SetPublicKey(Message.PublicKey(0)); } _data = null; // TODO why here? not in prepareFinish()? _key = null; } Message.SetDataMap(_dataMap); LastContent = _contentTypes.Dequeue(); _mapSize = -1; // TODO why here? not in prepareFinish()? _dataMap = null; break; case Message.Content.MapKey640Keys: if (_keyMap640KeysSize == -1 && buffer.ReadableBytes < Utils.Utils.IntegerByteSize) { return false; } if (_keyMap640KeysSize == -1) { _keyMap640KeysSize = buffer.ReadInt(); } if (_keyMap640Keys == null) { _keyMap640Keys = new KeyMap640Keys(new SortedDictionary<Number640, ICollection<Number160>>()); // TODO check TreeMap equivalent } const int meta = 4 * Number160.ByteArraySize; for (int i = _keyMap640Keys.Size; i < _keyMap640KeysSize; i++) { if (buffer.ReadableBytes < meta + Utils.Utils.ByteByteSize) { return false; } size = buffer.GetUByte(buffer.ReaderIndex + meta); if (buffer.ReadableBytes < meta + Utils.Utils.ByteByteSize + (size * Number160.ByteArraySize)) { return false; } var me = new sbyte[Number160.ByteArraySize]; buffer.ReadBytes(me); var locationKey = new Number160(me); buffer.ReadBytes(me); var domainKey = new Number160(me); buffer.ReadBytes(me); var contentKey = new Number160(me); buffer.ReadBytes(me); var versionKey = new Number160(me); int numBasedOn = buffer.ReadByte(); var value = new HashSet<Number160>(); for (int j = 0; j < numBasedOn; j++) { buffer.ReadBytes(me); var basedOnKey = new Number160(me); value.Add(basedOnKey); } _keyMap640Keys.Put(new Number640(locationKey, domainKey, contentKey, versionKey), value); } Message.SetKeyMap640Keys(_keyMap640Keys); LastContent = _contentTypes.Dequeue(); _keyMap640KeysSize = -1; // TODO why here? not in prepareFinish()? _keyMap640Keys = null; break; case Message.Content.MapKey640Byte: if (_keyMapByteSize == -1 && buffer.ReadableBytes < Utils.Utils.IntegerByteSize) { return false; } if (_keyMapByteSize == -1) { _keyMapByteSize = buffer.ReadInt(); } if (_keyMapByte == null) { _keyMapByte = new KeyMapByte(new Dictionary<Number640, sbyte>(2 * _keyMapByteSize)); } for (int i = _keyMapByte.Size; i < _keyMapByteSize; i++) { if (buffer.ReadableBytes < 4 * Number160.ByteArraySize + 1) { return false; } var me = new sbyte[Number160.ByteArraySize]; buffer.ReadBytes(me); var locationKey = new Number160(me); buffer.ReadBytes(me); var domainKey = new Number160(me); buffer.ReadBytes(me); var contentKey = new Number160(me); buffer.ReadBytes(me); var versionKey = new Number160(me); sbyte value = buffer.ReadByte(); _keyMapByte.Put(new Number640(locationKey, domainKey, contentKey, versionKey), value); } Message.SetKeyMapByte(_keyMapByte); LastContent = _contentTypes.Dequeue(); _keyMapByteSize = -1; // TODO why here? not in prepareFinish()? _keyMapByte = null; break; case Message.Content.ByteBuffer: if (_bufferSize == -1 && buffer.ReadableBytes < Utils.Utils.IntegerByteSize) { return false; } if (_bufferSize == -1) { _bufferSize = buffer.ReadInt(); } if (_buffer == null) { _buffer = new DataBuffer(); } int already = _buffer.AlreadyTransferred; int remaining = _bufferSize - already; // already finished if (remaining != 0) { int read = _buffer.TransferFrom(buffer, remaining); if (read != remaining) { Logger.Debug( "Still looking for data. Indicating that its not finished yet. Already Transferred = {0}, Size = {1}.", _buffer.AlreadyTransferred, _bufferSize); return false; } } ByteBuf buf2 = AlternativeCompositeByteBuf.CompBuffer(_buffer.ToByteBufs()); Message.SetBuffer(new Buffer(buf2, _bufferSize)); LastContent = _contentTypes.Dequeue(); _bufferSize = -1; _buffer = null; break; case Message.Content.SetTrackerData: if (_trackerDataSize == -1 && buffer.ReadableBytes < Utils.Utils.ByteByteSize) { return false; } if (_trackerDataSize == -1) { _trackerDataSize = buffer.ReadUByte(); } if (_trackerData == null) { _trackerData = new TrackerData(new Dictionary<PeerAddress, Data>(2 * _trackerDataSize)); } if (_currentTrackerData != null) { if (!_currentTrackerData.DecodeBuffer(buffer)) { return false; } if (!_currentTrackerData.DecodeDone(buffer, Message.PublicKey(0), _signatureFactory)) { return false; } _currentTrackerData = null; } for (int i = _trackerData.Size; i < _trackerDataSize; i++) { if (buffer.ReadableBytes < Utils.Utils.ShortByteSize) { return false; } int header = buffer.GetUShort(buffer.ReaderIndex); size = PeerAddress.CalculateSize(header); if (buffer.ReadableBytes < Utils.Utils.ShortByteSize) { return false; } var pa = new PeerAddress(buffer); _currentTrackerData = Data.DeocdeHeader(buffer, _signatureFactory); if (_currentTrackerData == null) { return false; } _trackerData.PeerAddresses.Add(pa, _currentTrackerData); if (Message.IsSign) { _currentTrackerData.SetPublicKey(Message.PublicKey(0)); } if (!_currentTrackerData.DecodeBuffer(buffer)) { return false; } if (!_currentTrackerData.DecodeDone(buffer, Message.PublicKey(0), _signatureFactory)) { return false; } _currentTrackerData = null; // TODO why here? } Message.SetTrackerData(_trackerData); LastContent = _contentTypes.Dequeue(); _trackerDataSize = -1; _trackerData = null; break; case Message.Content.PublicKey: // fall-through case Message.Content.PublicKeySignature: receivedPublicKey = _signatureFactory.DecodePublicKey(buffer); if (content == Message.Content.PublicKeySignature) { if (receivedPublicKey == PeerBuilder.EmptyPublicKey) // TODO check if works { // TODO throw InvalidKeyException throw new SystemException("The public key cannot be empty."); } } if (receivedPublicKey == null) { return false; } Message.SetPublicKey(receivedPublicKey); LastContent = _contentTypes.Dequeue(); break; default: break; } } if (Message.IsSign) { var signatureEncode = _signatureFactory.SignatureCodec; size = signatureEncode.SignatureSize; if (buffer.ReadableBytes < size) { return false; } signatureEncode.Read(buffer); Message.SetReceivedSignature(signatureEncode); } return true; }
protected override void OnStop () { WearableClass.DataApi.RemoveListener (google_api_client, this); WearableClass.MessageApi.RemoveListener (google_api_client, this); var dataMap = new DataMap (); dataMap.PutInt (Constants.NUM_CORRECT, num_correct); dataMap.PutInt (Constants.NUM_INCORRECT, num_incorrect); if (has_question_been_asked) num_skipped++; num_skipped += future_questions.Size (); dataMap.PutInt (Constants.NUM_SKIPPED, num_skipped); if (num_correct + num_incorrect + num_skipped > 0) SendMessageToWearable (Constants.QUIZ_EXITED_PATH, dataMap.ToByteArray ()); ClearQuizStatus (); base.OnStop (); }
public void AskNextQuestionIfExists () { if (future_questions.IsEmpty) { var dataMap = new DataMap (); dataMap.PutInt (Constants.NUM_CORRECT, num_correct); dataMap.PutInt (Constants.NUM_INCORRECT, num_incorrect); dataMap.PutInt (Constants.NUM_SKIPPED, num_skipped); SendMessageToWearable (Constants.QUIZ_ENDED_PATH, dataMap.ToByteArray ()); SetHasQuestionBeenAsked (false); } else { WearableClass.DataApi.PutDataItem (google_api_client, (future_questions.Remove () as Question).ToPutDataRequest ()); SetHasQuestionBeenAsked (true); } }
/// <summary> /// Basic implementation of a map src solid filling renderer. /// </summary> /// <param name="clip">The clipping rectangle.</param> /// <param name="scanner">The scans to render.</param> /// <param name="dest">The map to render to.</param> /// <param name="src">The source map.</param> /// <param name="offset">The offset of the source map.</param> /// <param name="mode">The color blending mode to use.</param> /// <param name="isAA">True if anti-aliasing is enabled.</param> public static void SolidCopyRender(Rectangle clip, Scanner scanner, DataMap<ARGB> dest, DataMap<ARGB> src, Point2D offset, ColorMode mode = ColorMode.NORMAL, bool isAA = true) { IUnsafeMap uDest = dest as IUnsafeMap; IUnsafeMap uSrc = src as IUnsafeMap; if(uDest == null) { throw new InvalidOperationException("Destination image does not support advanced color rendering!"); } if(uSrc == null) { throw new InvalidOperationException("Source image does not support advanced color rendering!"); } byte* addr = uDest.BeginUnsafeOperation(); int width = dest.Width; int stride = uDest.GetStride(); byte* srcAddr = uSrc.BeginUnsafeOperation(); int srcWidth = src.Width; int srcStride = uSrc.GetStride(); for(int y = scanner.yMin; y <= scanner.yMax; y++) { double x1 = Max(scanner[y].min, clip.Min.X); double x2 = Min(scanner[y].max, clip.Max.X); //Anti-Aliasing variables //x1 vars are x min side //x2 vars are x max side //xb vars are y min side //xa vars are y max side double x1b = 0, x1a = 0; double x2b = 0, x2a = 0; int left; int right; if(isAA) { bool hasMin = false, hasMax = false; //if not at ymin or ymin is a clipped min (aka we have another "ghost" scan) if(y > scanner.yMin || scanner.isYMinClipped) { x1b = Max(scanner[y - 1].min, clip.Min.X); x2b = Min(scanner[y - 1].max, clip.Max.X); x1b = (x1b + x1) / 2; x2b = (x2b + x2) / 2; hasMin = true; } //if not at ymax or ymax is a clipped max (aka we have another "ghost" scan) if(y < scanner.yMax || scanner.isYMaxClipped) { x1a = Max(scanner[y + 1].min, clip.Min.X); x2a = Min(scanner[y + 1].max, clip.Max.X); x1a = (x1a + x1) / 2; x2a = (x2a + x2) / 2; hasMax = true; } if(!hasMin) { //if single line shape, just make everything literal if(!hasMax) { x1b = x1a = x1; x2b = x2a = x2; }else//if at ymin, extrapolate max->current into current->min { x1b = x1 - (x1a - x1); x2b = x2 - (x2a - x2); } }else//if at ymax, extrapolate min->current into current->max if(!hasMax) { x1a = x1 + (x1 - x1b); x2a = x2 + (x2 - x2b); } //if aa, round toward center, otherwise round away to match default renderer left = (int)Math.Ceiling(Max(x1b, x1a)); right = (int)Math.Floor(Min(x2b, x2a)); }else { //if not aa, round away to match default renderer left = (int)Math.Floor(x1); right = (int)Math.Ceiling(x2); } //if valid center if(left <= right) { //solid fill with blend modes byte* ptr = addr + (left + (y * width)) * stride; byte* srcPtr = srcAddr + ((left + offset.X) + ((y + offset.Y) * srcWidth)) * srcStride; byte* endPtr = ptr + (right - left + 1) * stride; switch(mode) { case ColorMode.BLEND: { while(ptr != endPtr) { //*((ARGB*)ptr) &= *((ARGB*)srcPtr); //manually inline blending ARGB srcColor = *(ARGB*)srcPtr; ARGB color = *(ARGB*)ptr; int aComp = 255 - srcColor.A; color = new ARGB{A = (byte)(srcColor.A + color.A), R = (byte)(((srcColor.R * srcColor.A) + (color.R * aComp)) >> 8), G = (byte)(((srcColor.G * srcColor.A) + (color.G * aComp)) >> 8), B = (byte)(((srcColor.B * srcColor.A) + (color.B * aComp)) >> 8)}; *(ARGB*)ptr = color; ptr += stride; srcPtr += srcStride; } break; } case ColorMode.NORMAL: { while(ptr != endPtr) { *((ARGB*)ptr) = *((ARGB*)srcPtr); ptr += stride; srcPtr += srcStride; } break; } case ColorMode.MASK: { while(ptr != endPtr) { if((*((ARGB*)srcPtr)).A != 0) *((ARGB*)ptr) = *((ARGB*)srcPtr); ptr += stride; srcPtr += srcStride; } break; } } } //if aa, add smoothing to edges if(isAA) { int center = (left + right) / 2; if(Min(x1b, x1a) != left) AAEdgeCopy(addr, width, stride, x1b, x1a, y, srcAddr, srcWidth, srcStride, offset, true, clipMax: Min(center, clip.Max.X)); if(Max(x2b, x2a) != right) AAEdgeCopy(addr, width, stride, x2b + 1, x2a + 1, y, srcAddr, srcWidth, srcStride, offset, false, clipMin: Max(center + 1, clip.Min.X)); } } uDest.EndUnsafeOperation(); uSrc.EndUnsafeOperation(); }
/// <summary> /// Basic implementation of a constant src solid filling renderer. /// </summary> /// <param name="clip">The clipping rectangle.</param> /// <param name="scanner">The scans to render.</param> /// <param name="dest">The map to render to.</param> /// <param name="value">The constant value.</param> /// <param name="mode">The color blending mode to use.</param> /// <param name="isAA">True if anti-aliasing is enabled.</param> public static void SolidConstRender(Rectangle clip, Scanner scanner, DataMap<ARGB> dest, ARGB value, ColorMode mode = ColorMode.NORMAL, bool isAA = true) { //for constants, we can early return on blend and mask when alpha is 0 if((mode == ColorMode.BLEND || mode == ColorMode.MASK) && value.A == 0) return; //mask at non-zero is equivalent to normal if(mode == ColorMode.MASK) mode = ColorMode.NORMAL; //blend at opaque is equivalent to normal if(mode == ColorMode.BLEND && value.A == 255) mode = ColorMode.NORMAL; IUnsafeMap uDest = dest as IUnsafeMap; if(uDest == null) { throw new InvalidOperationException("Destination image does not support advanced color rendering!"); } byte* addr = uDest.BeginUnsafeOperation(); int width = dest.Width; int stride = uDest.GetStride(); for(int y = scanner.yMin; y <= scanner.yMax; y++) { double x1 = Max(scanner[y].min, clip.Min.X); double x2 = Min(scanner[y].max, clip.Max.X); //Anti-Aliasing variables //x1 vars are x min side //x2 vars are x max side //xb vars are y min side //xa vars are y max side double x1b = 0, x1a = 0; double x2b = 0, x2a = 0; int left; int right; if(isAA) { bool hasMin = false, hasMax = false; //if not at ymin or ymin is a clipped min (aka we have another "ghost" scan) if(y > scanner.yMin || scanner.isYMinClipped) { x1b = Max(scanner[y - 1].min, clip.Min.X); x2b = Min(scanner[y - 1].max, clip.Max.X); x1b = (x1b + x1) / 2; x2b = (x2b + x2) / 2; hasMin = true; } //if not at ymax or ymax is a clipped max (aka we have another "ghost" scan) if(y < scanner.yMax || scanner.isYMaxClipped) { x1a = Max(scanner[y + 1].min, clip.Min.X); x2a = Min(scanner[y + 1].max, clip.Max.X); x1a = (x1a + x1) / 2; x2a = (x2a + x2) / 2; hasMax = true; } if(!hasMin) { //if single line shape, just make everything literal if(!hasMax) { x1b = x1a = x1; x2b = x2a = x2; }else//if at ymin, extrapolate max->current into current->min { x1b = x1 - (x1a - x1); x2b = x2 - (x2a - x2); } }else//if at ymax, extrapolate min->current into current->max if(!hasMax) { x1a = x1 + (x1 - x1b); x2a = x2 + (x2 - x2b); } //if aa, round toward center left = (int)Math.Ceiling(Max(x1b, x1a)); right = (int)Math.Floor(Min(x2b, x2a)); }else { //if not aa, round away from center to match default renderer left = (int)Math.Floor(x1); right = (int)Math.Ceiling(x2); } //if valid center if(left <= right) { //solid fill with blend modes byte* ptr = addr + (left + (y * width)) * stride; byte* endPtr = ptr + (right - left + 1) * stride; switch(mode) { case ColorMode.BLEND: { //precalc value ARGB preValue = new ARGB{A = (byte)(255 - value.A), R = (byte)((value.R * value.A) >> 8), G = (byte)((value.G * value.A) >> 8), B = (byte)((value.B * value.A) >> 8)}; while(ptr != endPtr) { //*((ARGB*)ptr) &= value; //manually inline blending ARGB color = *(ARGB*)ptr; color = new ARGB{A = (byte)(value.A + color.A), R = (byte)(preValue.R + ((color.R * preValue.A) >> 8)), G = (byte)(preValue.G + ((color.G * preValue.A) >> 8)), B = (byte)(preValue.B + ((color.B * preValue.A) >> 8))}; *(ARGB*)ptr = color; ptr += stride; } break; } case ColorMode.NORMAL: { while(ptr != endPtr) { *((ARGB*)ptr) = value; ptr += stride; } break; } } } //if aa, add smoothing to edges if(isAA) { int center = (left + right) / 2; if(Min(x1b, x1a) != left) AAEdgeConst(addr, width, stride, x1b, x1a, y, value, true, clipMax: Min(center, clip.Max.X)); if(Max(x2b, x2a) != right) AAEdgeConst(addr, width, stride, x2b + 1, x2a + 1, y, value, false, clipMin: Max(center + 1, clip.Min.X)); } } uDest.EndUnsafeOperation(); }
void SetupColorPickerSelection(int spinnerId, string configKey, DataMap config, int defaultColorNameResId) { var defaultColorName = GetString (defaultColorNameResId); var defaultColor = Color.ParseColor (defaultColorName); int color = config != null ? config.GetInt (configKey, defaultColor) : defaultColor; var spinner = FindViewById<Spinner> (spinnerId); var colorNames = Resources.GetStringArray (Resource.Array.ColorArray); for (int i = 0; i < colorNames.Length; i++) { if (Color.ParseColor (colorNames [i]) == color) { spinner.SetSelection (i); break; } } }
void SetupAllPickers(DataMap config) { SetupColorPickerSelection (Resource.Id.Background, KeyBackgroundColor, config, Resource.String.ColorBlack); SetupColorPickerSelection (Resource.Id.Hours, KeyHoursColor, config, Resource.String.ColorWhite); SetupColorPickerSelection (Resource.Id.Minutes, KeyMinutesColor, config, Resource.String.ColorWhite); SetupColorPickerSelection (Resource.Id.Seconds, KeySecondsColor, config, Resource.String.ColorGray); SetUpColorPickerListener (Resource.Id.Background, KeyBackgroundColor); SetUpColorPickerListener (Resource.Id.Hours, KeyHoursColor); SetUpColorPickerListener (Resource.Id.Minutes, KeyMinutesColor); SetUpColorPickerListener (Resource.Id.Seconds, KeySecondsColor); }
public Message PrepareFinish() { Message ret = Message; Message.SetDone(); _contentTypes.Clear(); Message = null; _neighborSize = -1; _neighborSet = null; // TODO set peerSocketAddressSize/peerSocketAddresses -1/null? _keyCollectionSize = -1; _keyCollection = null; _mapSize = -1; _dataMap = null; _data = null; // TODO set _key to null? _keyMap640KeysSize = -1; _keyMap640Keys = null; // TODO set _keyMapBytesSize/list to -1/null? _bufferSize = -1; _buffer = null; // TODO set _trackerDataSize/list to -1/null? // TODO set _signatureFactory to null? return ret; }
public void DumpInitialPacket(Dictionary<uint, DataElement> data) { var dataMap = new DataMap(data); uint index; if (dataMap.TryGetIndex(DataCategory.Radio, out index)) { var radioStations = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(radioStations); } if (dataMap.TryGetIndex(DataCategory.Perks, out index)) { var perks = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(perks); } if (dataMap.TryGetIndex(DataCategory.Stats, out index)) { var stats = ReadListOfAttributes(data, index); PrintAttributeMap(stats); } if (dataMap.TryGetIndex(DataCategory.Special, out index)) { var special = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(special); } if (dataMap.TryGetIndex(DataCategory.Quests, out index)) { var quests = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(quests); } if (dataMap.TryGetIndex(DataCategory.Workshop, out index)) { var workshops = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(workshops); } if (dataMap.TryGetIndex(DataCategory.Log, out index)) { var log = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(log); } if (dataMap.TryGetIndex(DataCategory.Map, out index)) { var map = ReadListOfAttributes(data, index); PrintAttributeMap(map); } if (dataMap.TryGetIndex(DataCategory.PlayerInfo, out index)) { var playerInfo = ReadListOfAttributes(data, index); PrintAttributeMap(playerInfo); } if (dataMap.TryGetIndex(DataCategory.Status, out index)) { var status = ReadListOfAttributes(data, index); PrintAttributeMap(status); } if (dataMap.TryGetIndex(DataCategory.Inventory, out index)) { var inventoryMap = new InventoryMap(data, index); if (inventoryMap.TryGetIndex(InventoryCategory.Aid, out index)) { var aid = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(aid); } if (inventoryMap.TryGetIndex(InventoryCategory.Recordings, out index)) { var recordings = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(recordings); } if (inventoryMap.TryGetIndex(InventoryCategory.Weapons, out index)) { var weapons = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(weapons); } if (inventoryMap.TryGetIndex(InventoryCategory.Writings, out index)) { var books = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(books); } if (inventoryMap.TryGetIndex(InventoryCategory.Junk, out index)) { var junk = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(junk); } if (inventoryMap.TryGetIndex(InventoryCategory.Apparel, out index)) { var apparel = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(apparel); } if (inventoryMap.TryGetIndex(InventoryCategory.Keys, out index)) { var keys = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(keys); } if (inventoryMap.TryGetIndex(InventoryCategory.Ammo, out index)) { var ammo = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(ammo); } if (inventoryMap.TryGetIndex(InventoryCategory.Components, out index)) { var components = ReadListOfAttributeMaps(data, index); PrintAttributeMaps(components); } } }
void UpdateUiForConfigDataMap(DataMap config) { bool uiUpdated = false; foreach (var configKey in config.KeySet ()) { if (!config.ContainsKey (configKey)) { continue; } int color = config.GetInt (configKey); if (Log.IsLoggable (Tag, LogPriority.Debug)) { Log.Debug (Tag, "Found watch face config key: " + configKey + " -> " + Integer.ToHexString (color)); } if (UpdateUiForKey (configKey, color)) { uiUpdated = true; } } if (uiUpdated) { Invalidate (); } }
// Use this for initialization void Start() { Inst = GetComponent<Movement>(); _Controls = GameObject.Find("Controls").GetComponent<ControlMap>(); _Data = GameObject.Find("Controls").GetComponent<DataMap>(); LoadInputSettings(); //Screen.lockCursor = true; wayPoints = GameObject.Find("wp0").GetComponent<WaypointReg>().GetWayPoints(); if(ControlMode == _ControlMode.AI) { // Inst.thisCam.enabled = false; // Inst.thisCam.GetComponent<AudioListener>().enabled = false; if(GetComponent<HUD>() != null) GetComponent<HUD>().enabled = false; } if(Inst == null) Inst = GetComponent<Movement>(); }
public void Load(int id) { data = Data.Maps[id]; Initialize(); MakeGrid(); }
public Message SetDataMap(DataMap dataMap) { if (!_presetContentTypes) { SetContentType(Content.MapKey640Data); } if (_dataMapList == null) { _dataMapList = new List<DataMap>(1); } _dataMapList.Add(dataMap); return this; }
void UpdateConfigDataItem(int backgroundColor) { var configKeysToOverwrite = new DataMap (); configKeysToOverwrite.PutInt (DigitalWatchFaceUtil.KeyBackgroundColor, backgroundColor); DigitalWatchFaceUtil.OverwriteKeysInConfigDataMap (googleApiClient, configKeysToOverwrite); }