void HelloWorld::addEndLine(){
    
    auto b = EndLine::createWithContext(this);
    b->setLineIndex(4);
    b->setPositionY(b->getLineIndex()*visibleSize.height/4);
    gameLayer->addChild(b);
    
    currentEndLine = b;
}
Пример #2
0
string HumdrumLine::getXmlId(const string& prefix) const {
	string output;
	if (prefix.size() > 0) {
		output = prefix;
	} else {
		output = getXmlIdPrefix();
	}
	output += "loc" + to_string(getLineIndex());
	return output;
}
Пример #3
0
/*
 ******************************************************
 * Find the path and write to the file.
 ******************************************************
 */
void findPathAndWriteToFile(STATION *source, STATION* dest) {
  
  int sourceLineIndex = getLineIndex(source->lineName); 
  int destLineIndex = getLineIndex(dest->lineName); 
  int numberOfStationsCurrentLine = 0, numberOfStationsTransferLine = 0; //Number of stations to be considered in the path from source line and dest line.
  STATION *transferStation = NULL; //Transfer station on destination line
  STATION *currentTransferStation = NULL; //Transfer station on source line. Station name will be same as the above, but lineName will be diffrent

  //If source and destination is on same line
  if(strcmp(source->lineName, dest->lineName) == 0) {
    numberOfStationsCurrentLine = abs(dest->stationNumber - source->stationNumber);
    displayPathAndWriteToFile(sourceLineIndex, destLineIndex, source, dest, transferStation, numberOfStationsCurrentLine, numberOfStationsTransferLine, currentTransferStation);
  }

  // source and destination on different line
  else {
     currentTransferStation = getCurrentTransferStation(source, dest);
     transferStation = getTransferStation(source, dest);
     numberOfStationsCurrentLine = abs(currentTransferStation->stationNumber - source->stationNumber);
     numberOfStationsTransferLine = abs(transferStation->stationNumber - dest->stationNumber);
     displayPathAndWriteToFile(sourceLineIndex, destLineIndex, source, dest, transferStation, numberOfStationsCurrentLine, numberOfStationsTransferLine, currentTransferStation);
  }
}
Пример #4
0
/*
 *************************************************************
 * Get the correct station as the source station.
 * Ex: to go from Fort Tottent to Pentagon, choose Fort Totten
 * of yellow line as source, not the green line.
 *************************************************************
 */
STATION* getCorrectStation(STATION* source, STATION* dest) {

  STATION *temp = NULL;
  bool found = false;
  int lineIndex, j;

  for(int i=0; i<source->numOfTransferLines; i++) {
    if(strcmp(source->transferLines[i], dest->lineName) == 0) {
      found = true;
      goto found;
    }
  }
  found:
  if(found == true) {
    lineIndex = getLineIndex(dest->lineName);
    temp = line[lineIndex]->start;
    while(strcmp(source->stationName, temp->stationName) !=0)
      temp = temp->next;
    return temp;
  }
  else return source;
}
Пример #5
0
ostream& HumdrumLine::printXml(ostream& out, int level, const string& indent) {

	if (hasSpines()) {
		out << Convert::repeatString(indent, level) << "<frame";
		out << " n=\"" << getLineIndex() << "\"";
		out << " xml:id=\"" << getXmlId() << "\"";
		out << ">\n";
		level++;

		out << Convert::repeatString(indent, level) << "<frameInfo>\n";
		level++;

		out << Convert::repeatString(indent, level) << "<fieldCount>";
		out << getTokenCount() << "</fieldCount>\n";

		out << Convert::repeatString(indent, level);
		out << "<frameStart";
		out << Convert::getHumNumAttributes(getDurationFromStart());
		out << "/>\n";

		out << Convert::repeatString(indent, level);
		out << "<frameDuration";
		out << Convert::getHumNumAttributes(getDuration());
		out << "/>\n";

		out << Convert::repeatString(indent, level) << "<frameType>";
		if (isData()) {
			out << "data";
		} else if (isBarline()) {
			out << "barline";
		} else if (isInterpretation()) {
			out << "interpretation";
		} else if (isLocalComment()) {
			out << "local-comment";
		}
		out << "</frameType>\n";

		if (isBarline()) {
			// print the duration to the next barline or to the end of the score
			// if there is no barline at the end of the score.
			out << Convert::repeatString(indent, level);
			out << "<barlineDuration";
			out << Convert::getHumNumAttributes(getBarlineDuration());
			out << "/>\n";
		}

		bool bstart = isKernBoundaryStart();
		bool bend   = isKernBoundaryEnd();
		if (bstart || bend) {
			out << Convert::repeatString(indent, level);
			cout << "<kernBoundary";
			cout << " start=\"";
			if (bstart) {
				cout << "true";
			} else {
				cout << "false";
			}
			cout << "\"";
			cout << " end=\"";
			if (bend) {
				cout << "true";
			} else {
				cout << "false";
			}
			cout << "\"";
			cout << "/>\n";
		}

		level--;
		out << Convert::repeatString(indent, level) << "</frameInfo>\n";

		out << Convert::repeatString(indent, level) << "<fields>\n";
		level++;
		for (int i=0; i<getFieldCount(); i++) {
			token(i)->printXml(out, level, indent);
		}
		level--;
		out << Convert::repeatString(indent, level) << "</fields>\n";
		
		level--;
		out << Convert::repeatString(indent, level) << "</frame>\n";

	} else {
		// global comments, reference records, or blank lines print here.
		out << Convert::repeatString(indent, level) << "<metaFrame";
		out << " n=\"" << getLineIndex() << "\"";
		out << " token=\"" << Convert::encodeXml(((string)(*this))) << "\"";
		out << " xml:id=\"" << getXmlId() << "\"";
		out << "/>\n";
		level++;

		out << Convert::repeatString(indent, level) << "<frameInfo>\n";
		level++;

		out << Convert::repeatString(indent, level);
		out << "<startTime";
		out << Convert::getHumNumAttributes(getDurationFromStart());
		out << "/>\n";

		out << Convert::repeatString(indent, level) << "<frameType>";
		if (isReference()) {
			out << "reference";
		} else if (isBlank()) {
			out << "empty";
		} else {
			out << "global-comment";
		}
		out << "</frameType>\n";

		if (isReference()) {
			out << Convert::repeatString(indent, level);
			out << "<referenceKey>" << Convert::encodeXml(getReferenceKey());
			out << "</referenceKey>\n";

			out << Convert::repeatString(indent, level);
			out << "<referenceValue>" << Convert::encodeXml(getReferenceValue());
			out << "</referenceValue>\n";
		}

		level--;
		out << Convert::repeatString(indent, level) << "<frameInfo>\n";


		level--;
		out << Convert::repeatString(indent, level) << "</metaFrame>\n";
	}

	return out;
}