示例#1
0
void Lunem::SetSpecies(string s)
{
	m_sSpecies = s;
	if (mName.empty())
		mName = m_sSpecies;

	/*
		Try to load our avatar from cache/lunem/species (no extension, due to being any format)
		Assuming the dimensions are 128x128 (if png)
		If we don't have one local, load a temporary replacement and download the avatar
	*/
	
	if (m_sSpecies == "none") // Don't use a custom download if we have a custom species
		return;
	
	XmlFile xf;
	string url, file = DIR_CACHE;
	file += "lunem/" + m_sSpecies;
	
	LoadAvatar("assets/unknown_lunem.png", "", 48, 48, 100, true, true);
	SwapAvatars();
	
	if (fileExists(file)) // load from disk
	{	
		LoadAvatar(file, "", 128, 128, 100, true, true);
		
		// if the image file is invalid, delete it from cache and let it try to redownload later
		if (!SwapAvatars())
		{
			removeFile(file);
		}
	}
	else // Need to download
	{
		// Download from master
		if (!xf.LoadFromFile("assets/connections.cfg"))
		{
			FATAL(xf.GetError());	
		}
		
		TiXmlElement* e = xf.mDoc.FirstChildElement();
		if (e)
			e = e->FirstChildElement("lunem");
		
		if (e)
			url = xf.GetText(e);
		
		if (url.empty())
		{
			FATAL("Invalid Url");	
		}
		
		url += m_sSpecies; // Something like http://site.com/dir/SPECIES_NAME
		
		downloader->QueueDownload(url, file, this, callback_lunemAvatarDownloadSuccess, 
									callback_lunemAvatarDownloadFailure, false);
	}
}
示例#2
0
plKey plAvatarMgr::LoadPlayer(const plString &name, const plString &account, const plString &linkInName)
{
    // what we'd like to do is turn the linkInName into a spawn point key and
    // put that into the plLoadAvatarMsg, which is already set up to handle
    // initial spawn points.
    // however, that will require that we can handle waiting for our spawn point to load,
    // so we're goin to do this the "old way" for now.
    
    plArmatureMod::SetSpawnPointOverride(linkInName);
    return LoadAvatar(name, account, true, nullptr, nullptr);
}
示例#3
0
void AvatarEditor::InitEditorWindow()
{
    Foundation::UiServiceInterface *ui = rexlogicmodule_->GetFramework()->GetService<Foundation::UiServiceInterface>();
    if (ui == 0) // If this occurs, we're most probably operating in headless mode.
        return;

    QUiLoader loader;
    loader.setLanguageChangeEnabled(true);
    QFile file("./data/ui/avatareditor.ui");
    if (!file.exists())
    {
        RexLogicModule::LogError("Cannot find avatar editor .ui file.");
        return;
    }

    avatar_widget_ = loader.load(&file, this);
    if (!avatar_widget_)
        return;

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(avatar_widget_);
    layout->setContentsMargins(0, 0, 0, 0);
    setLayout(layout);

    // Connect signals.
    QPushButton *button = avatar_widget_->findChild<QPushButton *>("but_export");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(ExportAvatar()));

    button = avatar_widget_->findChild<QPushButton *>("but_exportlocal");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(ExportAvatarLocal()));

    button = avatar_widget_->findChild<QPushButton *>("but_load");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(LoadAvatar()));

    button = avatar_widget_->findChild<QPushButton *>("but_revert");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(RevertAvatar()));

    button = avatar_widget_->findChild<QPushButton *>("but_attachment");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(AddAttachment()));

    setWindowTitle(tr("Avatar Editor"));
    ui->AddWidgetToScene(this);
    ui->AddWidgetToMenu(this);
}
示例#4
0
plKey plAvatarMgr::LoadPlayerFromFile(const plString &name, const plString &account, const plFileName &clothingFile)
{
    return LoadAvatar(name, account, true, nullptr, nullptr, "", clothingFile);
}
示例#5
0
plKey plAvatarMgr::LoadPlayer(const plString &name, const plString &account)
{
    return LoadAvatar(name, account, true, nullptr, nullptr);
}