예제 #1
0
std::string EntityTooltip::composeEntityInfoText(EmberEntity& entity)
{
	std::stringstream ss;
	if (entity.getName() != "") {
		ss << entity.getName() << " (of type " << entity.getType()->getName() << ")";
	} else {
		ss << entity.getType()->getName();
	}
	if (entity.hasAttr("biomass")) {
		ss << std::endl << "Edible";
	}
	if (entity.hasAttr("right_hand_wield")) {
		ss << std::endl << "Wieldable";
	}
	if (entity.hasAttr("worn")) {
		const Atlas::Message::Element& element = entity.valueOfAttr("worn");
		if (element.isString()) {
			ss << std::endl << "Worn on the " << element.asString();
		}
	}
	std::vector<std::string> actions = entity.getActions();
	if (actions.size()) {
		for (std::vector<std::string>::const_iterator I = actions.begin(); I != actions.end(); ++I) {
			ss << std::endl << "Can be used to " << *I;
		}
	}
	std::vector<std::string> operations = entity.getDefaultUseOperators();
	if (operations.size()) {
		for (std::vector<std::string>::const_iterator I = operations.begin(); I != operations.end(); ++I) {
			ss << std::endl << "Can be used to " << *I;
		}
	}

	return ss.str();
}
예제 #2
0
AvatarLogger::AvatarLogger(EmberEntity& avatarEntity)
: mChatLogger(nullptr)
{
	assert(&avatarEntity);

	//Put log files in a "logs" subdirectory of the home directory.
	const std::string dir = EmberServices::getSingleton().getConfigService().getHomeDirectory() + "/logs/";
	try {
		//make sure the directory exists

		oslink::directory osdir(dir);

		if (!osdir.isExisting()) {
			oslink::directory::mkdir(dir.c_str());
		}
		//perform setup of the stream
		std::stringstream logFileSS;
		logFileSS << dir << "/" << avatarEntity.getName() << "_chatlog.log";
		mChatLogger = std::unique_ptr<std::ofstream>(new std::ofstream(logFileSS.str().c_str(), std::ios::app));
		S_LOG_VERBOSE("Chat Logging set to write in [ " << logFileSS.str() << " ]");

		*mChatLogger << "-------------------------------------------------------" << std::endl;
		*mChatLogger << "Chat Logging Initialized at " <<  Time::getLocalTimeStr() << std::endl;
		*mChatLogger << "-------------------------------------------------------" << std::endl;

		//wait with connecting until everything has been properly set up
		GUIManager::getSingleton().AppendIGChatLine.connect(sigc::mem_fun(*this, &AvatarLogger::GUIManager_AppendIGChatLine));

	} catch (const std::exception& ex) {
		S_LOG_FAILURE("Error when creating directory for logs." << ex);
	}
}