예제 #1
0
void InstallBranch::onChoice(wxCommandEvent& event)
{
	MCFBranch b = getBranch();

	if (b == UINT_MAX || b == (UINT_MAX - 1))
	{
		if (b == UINT_MAX)
			m_butInstall->SetLabel(Managers::GetString(L"#PLAY"));
		else
			m_butInstall->SetLabel(Managers::GetString(L"#FIND"));

		m_butInstall->Enable(true);
		return;
	}

	UserCore::Item::ItemInfoI* pItemInfo = GetUserCore()->getItemManager()->findItemInfo(m_Item);

	if ((m_bIsMod || m_bIsExpansion) && !m_bSelectBranch)
		pItemInfo = GetUserCore()->getItemManager()->findItemInfo(pItemInfo->getParentId());

	UserCore::Item::BranchInfoI* bi = pItemInfo->getBranchById(b);

	m_bBuy = (!(bi->getFlags()&UserCore::Item::BranchInfoI::BF_ONACCOUNT) && !(bi->getFlags()&UserCore::Item::BranchInfoI::BF_FREE));

	if (m_bBuy)
		m_butInstall->SetLabel(Managers::GetString(L"#PURCHASE"));
	else
		m_butInstall->SetLabel(Managers::GetString(L"#INSTALL"));

	bool noRelease = HasAllFlags(bi->getFlags(), UserCore::Item::BranchInfoI::BF_NORELEASES);
	bool isPreorder = bi->isPreOrder();
	bool onAccount = HasAllFlags(bi->getFlags(), UserCore::Item::BranchInfoI::BF_ONACCOUNT);

	m_butInstall->Enable(!(noRelease && isPreorder && onAccount));
}
예제 #2
0
bool UninstallAllThread::hasPaidBranch(UserCore::Item::ItemInfoI* item)
{
	for (size_t z=0; z<item->getBranchCount(); z++)
	{
		UserCore::Item::BranchInfoI* bi = item->getBranch(z);

		if (HasAllFlags(bi->getFlags(), UserCore::Item::BranchInfoI::BF_ONACCOUNT) && !HasAnyFlags(bi->getFlags(), UserCore::Item::BranchInfoI::BF_FREE|UserCore::Item::BranchInfoI::BF_DEMO|UserCore::Item::BranchInfoI::BF_TEST))
			return true;
	}
	return false;
}
예제 #3
0
void UninstallInfoPage::init()
{
	UserCore::Item::ItemInfoI *info = getItemInfo();

	if (!info)
	{
		Close();
		return;
	}


	bool hasPaidBranch = false;

	for (size_t x=0; x<info->getBranchCount(); x++)
	{
		UserCore::Item::BranchInfoI* b = info->getBranch(x);

		if (b && HasAnyFlags(b->getFlags(), UserCore::Item::BranchInfoI::BF_ONACCOUNT) && !HasAnyFlags(b->getFlags(), UserCore::Item::BranchInfoI::BF_DEMO|UserCore::Item::BranchInfoI::BF_FREE|UserCore::Item::BranchInfoI::BF_TEST))
			hasPaidBranch = true;
	}

	if (hasPaidBranch)
	{
		m_cbAccount->Enable(false);
		m_cbAccount->SetValue(false);
	}

	if (info->getId().getType() == DesuraId::TYPE_LINK)
	{
		m_cbAccount->Enable(false);
		m_cbAccount->SetValue(true);

		m_cbComplete->Enable(false);
		m_cbComplete->SetValue(true);
	}


	m_labInfo->SetLabel(gcWString(Managers::GetString(L"#UNF_CONFIRM"), info->getName()));
	m_labInfo->Wrap( 360 );
}
예제 #4
0
int InstallBranch::setInfo(DesuraId id, bool selectBranch)
{
	m_bSelectBranch = selectBranch;
	UserCore::Item::ItemInfoI* pItemInfo = GetUserCore()->getItemManager()->findItemInfo(id);

	if (!pItemInfo)
		return 1;

	m_bIsMod = id.getType() == DesuraId::TYPE_MOD;
	m_bIsExpansion = m_bIsMod == false && pItemInfo->getParentId().getType() == DesuraId::TYPE_GAME;

	m_Item = id;

	gcWString parName;
	gcWString itemName = pItemInfo->getName();
	
	DesuraId par = pItemInfo->getParentId();
	UserCore::Item::ItemInfoI *parInfo = NULL;
	if (par.isOk())
	{
		parInfo = GetUserCore()->getItemManager()->findItemInfo(par);

		if (parInfo)
			parName = gcWString(parInfo->getName());
	}

	fixName(parName);
	fixName(itemName);

	if (selectBranch == false && m_bIsMod)
	{
		m_labInfo->SetLabel(gcWString(Managers::GetString(L"#IF_NOTFOUND"), itemName, parName));
		m_labInfo->Wrap( 350 );
	}
	else if (selectBranch == false && m_bIsExpansion)
	{
		m_labInfo->SetLabel(gcWString(Managers::GetString(L"#IF_NOTFOUND_GAME"), itemName, parName));
		m_labInfo->Wrap( 350 );
	}
	else
	{
		m_labInfo->SetLabel(gcWString(Managers::GetString(L"#IF_BRANCHINFO"), itemName));
		m_labInfo->Wrap( 350 );
	}

	uint32 count = 0;
	int32 full = -1;
	uint32 fullReadyCount = 0;
	m_bBuy = true;

	UserCore::Item::ItemInfoI *i = pItemInfo;

	bool isCheckingParent = (m_bIsMod || m_bIsExpansion) && !selectBranch;

	if (isCheckingParent)
	{
		if (!parInfo)
		{
			gcMessageBox(GetParent(), Managers::GetString(L"#IF_IIPARENT"), Managers::GetString(L"#IF_IIERRTITLE"));
			return 1;
		}

		i = parInfo;
	}

	std::vector<UserCore::Item::BranchInfoI*> bList;

	for (uint32 x=0; x<i->getBranchCount(); x++)
	{
		UserCore::Item::BranchInfoI* bi = i->getBranch(x);

		if (!bi)
			continue;

		uint32 flags = bi->getFlags();

		bool noRelease = HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_NORELEASES);
		bool isPreorder = bi->isPreOrder();
		bool isDemo = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_DEMO);
		bool onAccount = HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_ONACCOUNT);
		bool locked = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_MEMBERLOCK|UserCore::Item::BranchInfoI::BF_REGIONLOCK);
		bool test = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_TEST);
		bool free = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_FREE);

		if (noRelease && !isPreorder)
			continue;

		if (!onAccount && locked)
			continue;
		
		if (!selectBranch && (isDemo || test))
			continue;

		if ((free || onAccount) && isPreorder && !selectBranch)
			continue;

		bool globalFound = false;

		for (size_t x=0; x<bList.size(); x++)
		{
			if (bList[x]->getGlobalId() == bi->getGlobalId())
			{
				globalFound = true;
				break;
			}
		}

		if (globalFound)
			continue;

		if (isDemo || test)
		{
		}
		else if (full == -1 || ((!m_bBuy || onAccount) && !free))
		{
			if (full == -1 || m_bBuy)
			{
				//if this is the first full game or this is the first full game that you dont have to buy
				m_bBuy = (!onAccount && !free);
				full = count;
			}
			
			if (onAccount || free)
				fullReadyCount++;
		}

		bList.push_back(bi);
		count++;
	}

	for (size_t x=0; x<bList.size(); x++)
	{
		UserCore::Item::BranchInfoI* bi = bList[x];
		gcString name = bi->getName();
		gcWString title;
		
		uint32 flags = bi->getFlags();

		bool noRelease = HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_NORELEASES);
		bool isPreorder = bi->isPreOrder();
		bool onAccount = HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_ONACCOUNT);
		bool free = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_FREE);

		if (!free)
			title = gcString("{0} - {1}", name, Managers::GetString("#IF_BROUGHT"));
		else
			title = gcString("{0} - {1}", name, Managers::GetString("#IF_FREE"));
		
		if (!free && !onAccount)
		{
			gcWString cost(bi->getCost());

			if (cost == "")
				cost = gcString(Managers::GetString("#TBA"));

			title = gcString("{0} - {1}", name, cost.c_str());
		}
		else if (isPreorder)
		{
			if (noRelease)
				title = gcString("{0} - {1}", name, Managers::GetString("#IF_PREORDERED_NORELEASE"));
			else
				title = gcString("{0} - {1}", name, Managers::GetString("#IF_PREORDERED"));
		}

		m_cbBranchList->Append(title, new BranchData(bi->getBranchId(), bi->getGlobalId()));
	}

	count = bList.size();

	if (full == -1)
		full = 0;

#ifdef WIN32
	if (HasAnyFlags(i->getStatus(), UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER))
		m_cbBranchList->Append(Managers::GetString("#IF_ONCOMPUTER"), new BranchData(MCFBranch::BranchFromInt(-1), MCFBranch::BranchFromInt(-1)));
	else
		m_cbBranchList->Append(Managers::GetString("#IF_FINDONCOMPUTER"), new BranchData(MCFBranch::BranchFromInt(-2), MCFBranch::BranchFromInt(-2)));
#endif

	m_cbBranchList->SetSelection(full);

	if (pItemInfo->getIcon() && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(pItemInfo->getIcon())))
		setIcon(pItemInfo->getIcon());

	SetTitle(gcWString(Managers::GetString(L"#IF_BRANCHTITLE"), itemName));


	uint32 ret = 0;

	if (count == 0)
	{
		if (!isCheckingParent)
			gcMessageBox(GetParent(), Managers::GetString(L"#IF_IINOBRANCHES"), Managers::GetString(L"#IF_IIERRTITLE"));
		else if (selectBranch)
			ret = 1;
	}
	else if ((count == 1 || fullReadyCount == 1) && !m_bBuy)
	{	
		ret =  1;
	}
	else
	{
		wxCommandEvent e;
		onChoice(e);
	}

	return ret;
}