private void DecodeLoad(ushort channelId) { var position = ReceiveUint(); var index = new TrackIndex { ChannelId = channelId, Position = position }; var type = DecodeTrackType(); var description = ReceiveString(); var duration = 0U; if (type.HasAudio()) { duration = ReceiveUint(); } var text = ""; if (type.HasText()) { text = ReceiveString(); } var track = TrackFactory.Create(type, description, duration, text); Dispatch(new MarkerChangeArgs(channelId, MarkerType.Position, 0U)); Dispatch(new TrackLoadArgs(index, track)); }
protected override void DecodeItem(byte channelId) { // The client version of this command gets the item information. var position = ReceiveUint(); var index = new TrackIndex { ChannelId = channelId, Position = position }; var type = DecodeTrackType(); var description = ReceiveString(); var entry = TrackFactory.Create(type, description); Dispatch(new TrackAddArgs(index, entry)); }
//speed must be in [-1, 1] range public bool SetTrackForwardSpeed(TrackIndex trackId, double speed) { if (speed < MinInputSpeed || speed > MaxInputSpeed) { return(false); } byte[] buff = { (byte)MoveEnum.TrackSetSpeed, (byte)(trackId + '0'), Delimiter, }; buff = buff.Concat(CalcSpeed(speed).NumToArray()); SendCommand(ControllerEnum.MovementController, buff); return(true); }
void TrackGetGroupElementIndexRecursive(Group grp, int id, ref TrackIndex trackIndexOutput) { int grpElemInd = grp.getItemIndex(id); if (grpElemInd != -1) { trackIndexOutput.index = grpElemInd; return; } //grab through sub groups for (int grpInd = 0; grpInd < grp.elements.Count; grpInd++) { int grpElemId = grp.elements[grpInd]; if (grpElemId < 0) //is group? { Group subGrp = null; for (int i = 0; i < groupValues.Count; i++) { if (groupValues[i].group_id == grpElemId) { subGrp = groupValues[i]; break; } } if (subGrp != null) { TrackGetGroupElementIndexRecursive(subGrp, id, ref trackIndexOutput); if (trackIndexOutput.index != -1) { trackIndexOutput.groupIndices.Add(grpInd); break; } } } } }
int TrackIdGroupOrderCompare(int t1, int t2) { TrackIndex t1Ind = TrackIndex.Create(), t2Ind = TrackIndex.Create(); TrackGetGroupElementIndexRecursive(rootGroup, t1, ref t1Ind); TrackGetGroupElementIndexRecursive(rootGroup, t2, ref t2Ind); if (t1Ind.groupIndices.Count == t2Ind.groupIndices.Count) { return(t1Ind.index - t2Ind.index); } else if (t1Ind.groupIndices.Count < t2Ind.groupIndices.Count) { int t2GroupIndex = t1Ind.groupIndices.Count; return(t1Ind.index - t2Ind.groupIndices[t2GroupIndex]); } else if (t1Ind.groupIndices.Count > t2Ind.groupIndices.Count) { int t1GroupIndex = t2Ind.groupIndices.Count; return(t1Ind.groupIndices[t1GroupIndex] - t2Ind.index); } return(0); }
public bool Equals(TrackIndex obj) { return(DiscNumber == obj.DiscNumber && TrackNumber == obj.TrackNumber); }
public bool Equals(TrackIndex obj) { return DiscNumber == obj.DiscNumber && TrackNumber == obj.TrackNumber; }