//static
LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) 
{
	LLFloater* res = findInstance(name, key);
	if (!res)
	{
		const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc;
//		const std::string& xui_file = sBuildMap[name].mFile;
// [SL:KB] - Patch: UI-Base | Checked: 2010-12-01 (Catznip-3.0.0a) | Added: Catznip-2.5.0a
		const std::string& xui_file = (!sBuildMap[name].mFileFunc) ? sBuildMap[name].mFile : sBuildMap[name].mFileFunc();
// [/SL:KB]
		if (build_func)
		{
			const std::string& groupname = sGroupMap[name];
			if (!groupname.empty())
			{
				instance_list_t& list = sInstanceMap[groupname];

				res = build_func(key);
				if (!res)
				{
					LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL;
					return NULL;
				}
				bool success = res->buildFromFile(xui_file);
				if (!success)
				{
					LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL;
					return NULL;
				}

				// Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
				if (res->mKey.isUndefined()) 
				{
					res->mKey = key;
				}
				res->setInstanceName(name);
				
				LLFloater *last_floater = (list.empty() ? NULL : list.back());

				res->applyControlsAndPosition(last_floater);

				gFloaterView->adjustToFitScreen(res, false);

				list.push_back(res);
			}
		}
		if (!res)
		{
			LL_WARNS() << "Floater type: '" << name << "' not registered." << LL_ENDL;
		}
	}
	return res;
}