Exemplo n.º 1
0
void TaskBarIcon::onItemChanged(UserCore::Item::ItemInfoI::ItemInfo_s& info)
{
	if (!GetUserCore())
		return;

	if (info.changeFlags & UserCore::Item::ItemInfoI::CHANGED_STATUS)
	{
		UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo(info.id);
	
		if (!item)
			return;

		if (item->getStatus() & UserCore::Item::ItemInfoI::STATUS_UPDATEAVAL)
		{
			if (!findUpdateItem(item))
				m_vNextUpdateList.push_back(item);
		}
		else
		{
			removeUpdateItem(item);
		}
	}

	updateIcon();
}
Exemplo n.º 2
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));
}
Exemplo n.º 3
0
void UpdateInfoForm::onButtonPressed(wxCommandEvent& event)
{
	Close();

	UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( m_uiInternId );

	if (!item)
		return;

	if (m_bLaunch)
	{
		if (item)
		{
			if (m_cbReminder->IsChecked())
				item->addOFlag(UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE);
			else
				item->delOFlag(UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE);
		}
	}

	if (event.GetId() == m_butUpdate->GetId())
	{
		g_pMainApp->handleInternalLink(m_uiInternId, ACTION_UPDATE, FormatArgs("show=true"));
	}
	else if (event.GetId() == m_butLaunch->GetId())
	{
		g_pMainApp->handleInternalLink(m_uiInternId, ACTION_LAUNCH, FormatArgs("noupdate"));
	}
}
Exemplo n.º 4
0
void InternalLink::onUploadTrigger(ut& info)
{
	FINDFORM(info.id, UploadMCFForm);

	UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( info.id );
	if (!item && !GetUserCore()->isAdmin())
	{
		//cant upload show prompt
		gcMessageBox(g_pMainApp->getMainWindow(), Managers::GetString(L"#MF_NONDEV_ERROR"), Managers::GetString(L"#MF_PERMISSION_ERRTITLE"));
		return;
	}

	if (item && !HasAllFlags(item->getStatus(), UserCore::Item::ItemInfoI::STATUS_DEVELOPER) && !GetUserCore()->isAdmin())
	{
		//cant upload show prompt
		gcMessageBox(g_pMainApp->getMainWindow(), Managers::GetString(L"#MF_UPERMISSION_ERROR"), Managers::GetString(L"#MF_PERMISSION_ERRTITLE"));
		return;
	}

	//create new create from
	UploadMCFForm* form = new UploadMCFForm(m_pParent);
	form->setInfo_path(info.id, info.path.c_str());

	if (info.caller)
	{
		wxPoint pos = info.caller->GetScreenPosition();
		form->SetPosition(pos);
	}

	form->Show(true);	
	form->Raise();
	form->run();

	m_vSubForms.push_back(form);
}
Exemplo n.º 5
0
	PreloadButtonHelper(DesuraId id)
	{
		m_Id = id;

		UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo(id);

		if (!item)
			return;

		for (size_t x=0; x<item->getBranchCount(); x++)
		{
			uint32 flags = item->getBranch(x)->getFlags();
			
			if (HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_NORELEASES))
				continue;

			if (item->getBranch(x)->isPreOrder())
				continue;

			bool isDemo = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_DEMO|UserCore::Item::BranchInfoI::BF_TEST);
			bool onAccount = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_FREE|UserCore::Item::BranchInfoI::BF_ONACCOUNT);
			bool isLocked = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_REGIONLOCK|UserCore::Item::BranchInfoI::BF_MEMBERLOCK);

			if (isDemo)
				m_DemoBranch = item->getBranch(x)->getBranchId();
			else if (onAccount && !isLocked)
				m_bOtherBranches = true;
		}
	}
Exemplo n.º 6
0
void CreateMCFOverview::setInfo(DesuraId itemId, const char* szPath)
{
	UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(itemId);
	
	if (!item && !GetUserCore()->isAdmin())
	{	
		GetParent()->Close();
		return;
	}

	BasePage::setInfo(itemId);
	
	if (item)
		m_labInfo->SetLabel(gcWString(Managers::GetString(L"#CF_COMPLETE"), item->getName()));

	UTIL::FS::Path path(szPath, "", true);
	uint64 filesize = UTIL::FS::getFileSize(path);

	m_szFolderPath = path.getFolderPath();
	m_szPath = path.getFullPath();
	m_pItem = item;

	m_labName->SetLabel(path.getFile().getFile());
	m_labSize->SetLabel(UTIL::MISC::niceSizeStr(filesize));
	m_labPath->SetLabel(path.getShortPath(45, true));
	m_labPath->SetToolTip(path.getFullPath());

	Layout();
}
Exemplo n.º 7
0
bool UpdateThreadOld::pollUpdates()
{
	if (!m_pWebCore || !m_pUser)
		return false;

	updateBuildVer();

	std::map<std::string, std::string> post;

#ifdef DESURA_NONGPL_BUILD
	post["appid"] = gcString("{0}", m_iAppId);
	post["build"] = gcString("{0}", m_iAppVersion);
#endif

	for (uint32 x=0; x< m_pUser->getItemManager()->getCount(); x++)
	{
		UserCore::Item::ItemInfoI* item = m_pUser->getItemManager()->getItemInfo(x);

		if (!item)
			continue;

		if (!(item->getStatus() & UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER) || (item->getStatus()&UserCore::Item::ItemInfoI::STATUS_ONACCOUNT))
			continue;

		DesuraId id = item->getId();

		if (id.getType() == DesuraId::TYPE_LINK)
			continue;

		gcString key("updates[{0}][{1}]", id.getTypeString().c_str(), id.getItem());
		post[key] = "1";
	}

	TiXmlDocument doc;

	try
	{
		m_pWebCore->getUpdatePoll(doc, post);
	}
	catch (gcException &e)
	{
		Warning(gcString("Update poll failed: {0}\n", e));
		return false;
	}

	parseXML(doc);

#ifdef WIN32
	checkFreeSpace();
#endif

	m_hHttpHandle->cleanPostInfo();
	m_hHttpHandle->cleanUp();
	m_hHttpHandle->clearCookies();

	return true;
}
Exemplo n.º 8
0
void CDKInfo::onButtonClicked(wxCommandEvent& event)
{
	if (event.GetId() == m_butClose->GetId())
	{
		GetParent()->Close();
	}
	else if (event.GetId() == m_imgCopyAll->GetId() || (m_vSplitKey.size() == 0 && event.GetId() == m_imgCopyPart->GetId()))
	{
		if (wxTheClipboard->Open())
		{
			wxTheClipboard->SetData(new wxTextDataObject(m_tbCdKey->GetValue()));
			wxTheClipboard->Close();
		}	

		m_tbCdKey->SetSelection(-1,-1);
	}
	else if (event.GetId() == m_imgCopyPart->GetId())
	{
		SplitInfo *info = m_vSplitKey[m_uiCurIndex];

		m_uiCurIndex++;

		if (m_uiCurIndex >= m_vSplitKey.size())
			m_uiCurIndex = 0;
		
		if (wxTheClipboard->Open())
		{
			wxTheClipboard->SetData(new wxTextDataObject(info->text));
			wxTheClipboard->Close();
		}

		m_tbCdKey->SetSelection(info->start,info->end);

		gcString label(Managers::GetString("#CDK_COPYPART"));

		if (m_uiCurIndex != 0)
			label = gcString(Managers::GetString("#CDK_COPYPART_X"), m_uiCurIndex+1);

		m_imgCopyPart->SetToolTip(label);
	}
	else if (m_butLaunch && m_butLaunch->GetId() == event.GetId())
	{
		g_pMainApp->handleInternalLink(getItemId(), ACTION_LAUNCH, FormatArgs("cdkey", std::string("exe=") + m_szExe));
		GetParent()->Close();
	}
	else if (m_butActivate && m_butActivate->GetId() == event.GetId())
	{
		UserCore::Item::ItemInfoI* info = getItemInfo();

		if (info && info->isLaunchable())
			info->addSFlag(UserCore::Item::ItemInfoI::STATUS_LAUNCHED);

#ifdef WIN32
		UTIL::WIN::runAs("steam://open/activateproduct");
#endif
	}
}
Exemplo n.º 9
0
void InstallBranch::onButtonClick(wxCommandEvent &event)
{
	if (event.GetId() == m_butInfo->GetId())
	{
		if ((m_bIsMod || m_bIsExpansion) && !m_bSelectBranch)
			g_pMainApp->handleInternalLink(m_Item, ACTION_PROFILE, FormatArgs("?help=needgame"));
		else
			g_pMainApp->handleInternalLink(m_Item, ACTION_PROFILE, FormatArgs("?help=branches"));

		EndModal(wxID_CANCEL);
	}
	else if (event.GetId() == m_butInstall->GetId())
	{
		MCFBranch b = getBranch();

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

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

			pItemInfo->addSFlag(UserCore::Item::ItemInfoI::STATUS_LINK|UserCore::Item::ItemInfoI::STATUS_INSTALLED|UserCore::Item::ItemInfoI::STATUS_READY);
			EndModal(wxID_OK);
		}
		else if (b == (UINT_MAX - 1))
		{
			g_pMainApp->handleInternalLink(m_Item, ACTION_SHOWSETTINGS, FormatArgs("tab=cip"));
			EndModal(wxID_CANCEL);
		}
		else if (m_bBuy)
		{
			MCFBranch g = getGlobal();
			gcString args;

			if (g == 0 || !g.isGlobal())
				args = gcString("?help=buy&branch={0}", b);
			else
				args = gcString("?help=buy&branchglobal={0}", g);
			
			g_pMainApp->handleInternalLink(m_Item, ACTION_PROFILE, FormatArgs(args));
			EndModal(wxID_CANCEL);
		}
		else
		{
			EndModal(wxID_OK);
		}
	}
	else if (event.GetId() == m_butCancel->GetId())
	{
		EndModal(wxID_CANCEL);
	}
}
Exemplo n.º 10
0
void ComplexPrompt::setInfo(DesuraId id)
{
	UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(id);

	if (!item)
	{
		EndModal(wxID_CANCEL);
		return;
	}

	m_labInfo->SetLabel(gcWString(Managers::GetString(L"#IF_CONFLICT"), item->getName()));
	m_labInfo->Wrap( 350 );
}
Exemplo n.º 11
0
void InstallVerifyInfoPage::init()
{
	UserCore::Item::ItemInfoI *info = getItemInfo();

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

	m_labInfo->SetLabel(gcWString(Managers::GetString(L"#IF_VERIFYCONFIRM"), info->getName()));
	m_labInfo->Wrap( 360 );
}
Exemplo n.º 12
0
void CDKeyForm::setInfo(DesuraId id)
{
	m_ItemId = id;

	UserCore::Item::ItemInfoI *item = m_pItemManager->findItemInfo(id);

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

	this->SetTitle(gcString(Managers::GetString("#CDK_TITLE"), item->getName()));

	m_pPage->setInfo(m_ItemId);
	m_pPage->run();
}
Exemplo n.º 13
0
void CDKeyForm::setInfo(DesuraId id)
{
	m_ItemId = id;

	UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(id);

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

	this->SetTitle(gcString("{0}: CD Key", item->getName()));

	m_pPage->setInfo(m_ItemId);
	m_pPage->run();
}
Exemplo n.º 14
0
void UninstallForm::setInfo(DesuraId id)
{
	m_uiInternId = id;
	UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(id);

	if (!item)
	{
		Warning("Item was null for uninstall!");
		Close();
	}

	gcWString name(item->getName());

	gcWString title(255, L"{0} {0}", GETSTRING(L"#UNF_TITLE"), name.c_str());
	this->SetTitle(title.c_str());

	showInfo();
}
Exemplo n.º 15
0
void UploadInfoPage::resetAllValues()
{
	//m_dpFile->SetPath(wxT(""));
	m_butUpload->Enable( false );

	UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(getItemId());

	gcString filePath;
	gcString cachePath = GetUserCore()->getMcfCachePath();

	if (!item)
		filePath = gcString("{0}{1}temp{1}", cachePath, DIRS_STR);
	else
		filePath = gcString("{0}{2}{1}", cachePath, item->getId().getFolderPathExtension().c_str(), DIRS_STR);

	gcWString wfilePath(filePath);
	m_tbItemFile->SetValue(wfilePath.c_str());
}
Exemplo n.º 16
0
void ExeSelectForm::onButtonClick(wxCommandEvent& event)
{
	for (size_t x=0; x<m_vButtonList.size(); x++)
	{
		if (m_vButtonList[x]->GetId() == event.GetId())
		{
			UserCore::Item::ItemInfoI *item = m_pItemManager->findItemInfo(m_Id);

			std::vector<UserCore::Item::Misc::ExeInfoI*> vExeList;
			item->getExeList(vExeList);

			g_pMainApp->handleInternalLink(m_Id, ACTION_LAUNCH, FormatArgs(std::string("exe=") + vExeList[x]->getName(), m_bHasSeenCDKey?"cdkey":""));
			break;
		}
	}

	Close();
}
Exemplo n.º 17
0
void InternalLink::showUpdateForm(DesuraId id, Args args)
{
	UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( id );

	if (!item)
		return;

	if (!HasAllFlags(item->getStatus(), UserCore::Item::ItemInfoI::STATUS_UPDATEAVAL))
		return;
	
	std::string reminder = args.getArgValue("reminder");

	//create new gather info form from
	UpdateInfoForm* form = new UpdateInfoForm(m_pParent);
	regForm(id, form);

	form->setInfo(id, reminder == "true");
	form->Show(true);
}
Exemplo n.º 18
0
bool InternalLink::checkForPreorder(DesuraId id)
{
	UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( id );

	if (!item)
		return false;

	if (item->getCurrentBranch())
		return item->getCurrentBranch()->isPreOrderAndNotPreload();


	for (size_t x=0; x<item->getBranchCount(); x++)
	{
		if (item->getBranch(x)->isPreOrderAndNotPreload())
			return true;
	}		

	return false;
}
Exemplo n.º 19
0
bool VSDownloadMissing::checkComplex()
{
	if (HasAnyFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX))
	{
		UserCore::Item::ItemInfoI* par = getParentItemInfo();

		if (par && (!par->getInstalledModId().isOk() || par->getInstalledModId() != getItemId()))
		{		
			setResult(RES_COMPLETE);
		}
		else if (getItemInfo()->getInstalledModId().isOk())
		{
			setResult(RES_COMPLETE);
		}

		return false;
	}

	return true;
}
Exemplo n.º 20
0
void InstallPrompt::setInfo(DesuraId id, const char* path)
{
	UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(id);

	if (!item || !path)
	{
		Close();
		return;
	}

	m_szPath = gcWString(path);

	gcWString title(L"{0} {1}", Managers::GetString(L"#IF_INSTALL"), item->getName());
	gcWString quest(Managers::GetString(L"#IF_EXISTINGFILES"), item->getName());

	SetTitle(title);
	m_labQuestion->SetLabel(quest);


}
Exemplo n.º 21
0
void CDKInfo::setInfo(DesuraId id, const char* key)
{
	BasePage::setInfo(id);

	UserCore::Item::ItemInfoI *info = getItemInfo();

	if (!info)
	{
		GetParent()->Close();
		return;
	}

	m_butLaunch->Enable(info->isLaunchable());

	if (checkForArma(id, key))
		return;

	m_tbCdKey->ChangeValue(key);
	tokenizeKey(key);

	UserCore::Item::BranchInfoI* cb = info->getCurrentBranch();

	if (cb && cb->isSteamGame())
	{
		m_labInfo->SetLabel(gcWString(Managers::GetString(L"#CDK_INFO_STEAM"), info->getName()));
		m_labInfo->Wrap(360);

		m_butActivate = new gcButton(this, wxID_ANY, Managers::GetString(L"#CDK_ACTIVATE"));

		m_pButtonSizer->Clear(false);
		m_pButtonSizer->Add( 0, 0, 1, wxEXPAND, 5 );
		m_pButtonSizer->Add(m_butActivate, 0, wxTOP|wxBOTTOM|wxLEFT, 5);
		m_pButtonSizer->Add(m_butLaunch, 0, wxTOP|wxBOTTOM|wxLEFT, 5);
		m_pButtonSizer->Add(m_butClose, 0, wxALL, 5);

		Layout();
		Refresh(false);

		setParentSize(-1, 140);
	}
}
Exemplo n.º 22
0
bool VSCheckInstall::checkInstallComplex(bool completeMcf)
{
	if (HasAnyFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX) == false)
		return false;

	UserCore::Item::ItemInfoI* pItem = getItemInfo();
	UserCore::Item::ItemInfoI* pParent = getParentItemInfo();

	if (pParent)
	{		
		if (!pParent->getInstalledModId().isOk() || pParent->getInstalledModId() != pItem->getId())
		{
			if (completeMcf)
				setResult(RES_COMPLETE);
			else
				setResult(RES_DOWNLOADMISSING);

			return true;
		}
	}
	else if (pItem->getInstalledModId().isOk())
	{
		setResult(RES_COMPLETE);
		return true;
	}

	return false;
}
Exemplo n.º 23
0
void UpdateInfoForm::setInfo(DesuraId id, bool launch)
{
	m_bLaunch = launch;
	m_uiInternId = id;

	m_cbReminder->Enable(m_bLaunch);
	m_cbReminder->Show(m_bLaunch);

	

	UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( id );

	if (!item)
	{
		Warning("Cant find item for update form.\n");
		return;
	}

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

	m_cbReminder->SetValue(m_bLaunch && item->getOptions() & UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE);

	SetLabel(gcWString(L"{0} {1}", Managers::GetString(L"#UI_TITLE"), item->getName()));

	m_ieBrowser->loadUrl(gcWString(L"http://www.desura.com/{0}/{1}/changelog", id.getTypeString(), item->getShortName()));
}
Exemplo n.º 24
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 );
}
Exemplo n.º 25
0
void InternalLink::showPreorderPrompt(DesuraId id, bool isPreload)
{
	UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( id );

	if (!item)
		return;

	UserCore::Item::BranchInfoI* bi = item->getCurrentBranch();

	if (!bi)
	{
		for (size_t x=0; x<item->getBranchCount(); x++)
		{
			UserCore::Item::BranchInfoI *temp = item->getBranch(x);

			if (temp->isPreOrder())
			{
				bi = temp;
				break;
			}
		}
	}

	if (!bi)
		return;

	const char* str = bi->getPreOrderExpDate();

	uint32 days;
	uint32 hours;
	std::string time_available = UTIL::MISC::dateTimeToDisplay(str);

	UTIL::MISC::getTimeDiffFromNow(str, days, hours);

	gcString title(Managers::GetString("#IF_PRELOADLAUNCH_TITLE"), item->getName());
	gcString msg(Managers::GetString("#IF_PRELOADLAUNCH"), item->getName(), 
					days, 
						Managers::GetString(isPreload?"#IF_PRELOADLAUNCH_PRELOADED":"#IF_PRELOADLAUNCH_PREORDERED"), 
							time_available, 
								Managers::GetString(days == 1 ? "#IF_PRELOADLAUNCH_WORD_DAY":"#IF_PRELOADLAUNCH_WORD_DAYS"));

	PreloadButtonHelper pobh(id);

	if (pobh.m_bOtherBranches)
		msg += gcString(Managers::GetString("#IF_PRELOADLAUNCH_INSTALLOTHER_INFO"), item->getName());

	gcMessageBox(g_pMainApp->getMainWindow(), msg, title, wxICON_EXCLAMATION|wxCLOSE, &pobh);
}
Exemplo n.º 26
0
void ExeSelectForm::setInfo(DesuraId id)
{
	m_Id = id;

	UserCore::Item::ItemInfoI *item = m_pItemManager->findItemInfo(id);

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

	if (item->getIcon() && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(item->getIcon())))
	{
		setIcon(item->getIcon());
	}

	gcWString title(Managers::GetString(L"#ES_TITLE"), item->getName());
	SetTitle(title);

	gcWString text(Managers::GetString(L"#ES_LABEL"), item->getName());
	m_labInfo->SetLabel(text);
	m_labInfo->Wrap(350);

	std::vector<UserCore::Item::Misc::ExeInfoI*> vExeList;
	item->getExeList(vExeList);

	gcButton* def = nullptr;

	for (auto exe : vExeList)
	{
		gcWString name(exe->getName());
		gcButton* but = new gcButton(this, wxID_ANY, name, wxDefaultPosition, wxSize(150, -1));
		m_vButtonList.push_back(but);

		m_pButtonSizer->Add( but, 0, wxALL, 2 );

		if (name.find(L"Play") != std::wstring::npos)
			def = but;
	}

	this->Layout();

	if (def)
		def->SetDefault();
}
Exemplo n.º 27
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;
}
Exemplo n.º 28
0
uint32 GatherInfoTask::validate()
{
	UserCore::Item::ItemInfoI* pItemInfo = getItemHandle()->getItemInfo();
	uint32 isValid = 0;

	if (!pItemInfo)
		return UserCore::Item::Helper::V_BADINFO;

	DesuraId par = pItemInfo->getParentId();
	UserCore::Item::ItemInfoI *parInfo = nullptr;

	if (par.isOk())
	{
		parInfo = getUserCore()->getItemManager()->findItemInfo(par);

		if (!parInfo || !(parInfo->getStatus() & UserCore::Item::ItemInfoI::STATUS_INSTALLED))
			isValid |= UserCore::Item::Helper::V_PARENT;
	}

	const char* path = pItemInfo->getPath(getMcfBranch());

	if (!path)
	{
		isValid |= UserCore::Item::Helper::V_BADPATH;
	}
	else
	{
		const char *comAppPath = getUserCore()->getAppDataPath();

		uint64 inFreeSpace = UTIL::OS::getFreeSpace(path);
		uint64 dlFreeSpace = UTIL::OS::getFreeSpace(comAppPath);

		//if they are on the same drive:
		if (strncmp(comAppPath, path, 3) == 0)
		{
			if ((inFreeSpace+dlFreeSpace) < (pItemInfo->getDownloadSize()+pItemInfo->getInstallSize()))
			{
				isValid |= (UserCore::Item::Helper::V_FREESPACE|UserCore::Item::Helper::V_FREESPACE_DL|UserCore::Item::Helper::V_FREESPACE_INS);
			}
		}
		else
		{
			if (dlFreeSpace < pItemInfo->getDownloadSize())
				isValid |= UserCore::Item::Helper::V_FREESPACE|UserCore::Item::Helper::V_FREESPACE_DL;

			if (inFreeSpace < pItemInfo->getInstallSize())
				isValid |= UserCore::Item::Helper::V_FREESPACE|UserCore::Item::Helper::V_FREESPACE_INS;
		}

		if (pItemInfo->getStatus() & UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX)
		{
			const char* primPath = pItemInfo->getInsPrimary();

			if (primPath && strcmp(primPath, "") != 0 && UTIL::FS::isValidFolder(primPath) && !UTIL::FS::isFolderEmpty(primPath))
				isValid |= UserCore::Item::Helper::V_NONEMPTY;
		}
		else if (pItemInfo->getStatus() & UserCore::Item::ItemInfoI::STATUS_DLC)
		{
			if (!parInfo || gcString(path) != gcString(parInfo->getPath()))
			{
				if (!UTIL::FS::isFolderEmpty(path))
					isValid |= UserCore::Item::Helper::V_NONEMPTY;
			}
		}
		else if (!UTIL::FS::isFolderEmpty(path))
		{
			isValid |= UserCore::Item::Helper::V_NONEMPTY;
		}
	}

#ifdef NIX
	UserCore::Item::BranchInfoI* bi = pItemInfo->getBranchById(getMcfBranch());
	
	std::vector<DesuraId> toolList;
	bi->getToolList(toolList);

	uint32 res = getUserCore()->getToolManager()->hasNonInstallableTool(toolList);
	
	switch (res)
	{
	case 0:
		isValid |= UserCore::Item::Helper::V_JAVA_SUN;
		break;		
		
	case 1:
		isValid |= UserCore::Item::Helper::V_JAVA;
		break;		
	
	case 2:
		isValid |= UserCore::Item::Helper::V_MONO;
		break;
		
	case 3:
		isValid |= UserCore::Item::Helper::V_AIR;
		break;		
	};
#endif

	return isValid;
}
Exemplo n.º 29
0
void InternalLink::launchItem(DesuraId id, Args args)
{
	bool cdKeyArg = args.containsArg("cdkey");
	bool noUpdateArg = args.containsArg("noupdate");
	bool exeNumArg = args.containsArg("exe");
	std::string exe = args.getArgValue("exe");

	if (exe == "")
		exeNumArg = false;

	g_pMainApp->showPlay();

	if (checkForPreorder(id))
		return;

	UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo(id);
	bool delFlag=false;

	if (!item || !item->isLaunchable())
	{
		installItem(id, Args());
		return;
	}

	if (!item->hasAcceptedEula())
	{
		showPrompt(id, FormatArgs("prompt=eula"));
		return;
	}

	if (!exeNumArg && item->getExeCount(true) > 1)
	{
		showExeSelect(id, cdKeyArg);
		return;
	}
	else if (exe.size() > 0)
	{
		item->setActiveExe(exe.c_str());
	}

	bool hasCDKey = item->getCurrentBranch() && item->getCurrentBranch()->hasCDKey();
	bool hasDLCDKey = item->getCurrentBranch() && item->getCurrentBranch()->isCDKeyValid();

	if (!cdKeyArg && ((item->isFirstLaunch() && hasCDKey) || (hasCDKey && !hasDLCDKey)))
	{
		showCDKey(id, FormatArgs("launch=true", std::string("exe=") + exe));
		return;
	}

	bool shouldShowGameDisk = false;

	if (args.containsArg("gamedisk") == false && HasAnyFlags(item->getOptions(), UserCore::Item::ItemInfoI::OPTION_DONTPROMPTGAMEDISK) == false)
	{
		size_t x=0; 
		while (g_GameDiskList[x].isOk())
		{
			if (item->getId() == g_GameDiskList[x] || item->getParentId() == g_GameDiskList[x])
			{
				shouldShowGameDisk = true;
				break;
			}

			x++;
		}
	}

	if (shouldShowGameDisk)
	{
		showGameDisk(id, exe.c_str(), cdKeyArg);
		return;
	}

	if (noUpdateArg && !HasAnyFlags(item->getOptions(), UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE))
	{
		item->addOFlag(UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE);
		delFlag = true;
	}

	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_LAUNCH);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for launch [{0}].\n", id.toInt64()));

	if (item && delFlag)
		item->delOFlag(UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE);
}
Exemplo n.º 30
0
wxMenu* TBIModMenu::createMenu(uint32 &lastMenuId)
{
	gcMenu* menu = new gcMenu();
	m_IdMapList.clear();

	if (!m_pItemManager && GetUserCore())
		m_pItemManager = GetUserCore()->getItemManager();

	if (!m_pItemManager)
		return menu;

	std::vector<UserCore::Item::ItemInfoI*> gList;
	m_pItemManager->getGameList(gList);

	std::sort(gList.begin(), gList.end(), [](UserCore::Item::ItemInfoI* left, UserCore::Item::ItemInfoI* right){
		return strcmp(left->getName(), right->getName()) <= 0;
	});

	for (size_t x=0; x<gList.size(); x++)
	{
		UserCore::Item::ItemInfoI *game = gList[x];

		std::vector<UserCore::Item::ItemInfoI*> mList;
		m_pItemManager->getModList(game->getId(), mList);

		if (mList.size() == 0)
			continue;

		gcMenu* gameMenu = new gcMenu();
		
		std::sort(mList.begin(), mList.end(), [](UserCore::Item::ItemInfoI* left, UserCore::Item::ItemInfoI* right){
			return strcmp(left->getName(), right->getName()) <= 0;
		});

		for (size_t y=0; y<mList.size(); y++)
		{
			UserCore::Item::ItemInfoI *mod = mList[y];

			wxMenuItem* menuItem = new gcMenuItem(gameMenu, lastMenuId, mod->getName());
			gameMenu->Append(menuItem);

			m_IdMapList[lastMenuId] = mod->getId();
			loadIcon(menuItem, mod->getIcon());

			lastMenuId++;
		}

		wxMenuItem* gameItem = new gcMenuItem(gameMenu, wxID_ANY, game->getName(), "", wxITEM_NORMAL, gameMenu);
		loadIcon(gameItem, game->getIcon());

		menu->Append(gameItem);
	}

	if (menu->GetMenuItemCount() == 0)
	{
		wxMenuItem* noItems = new gcMenuItem(menu, lastMenuId, Managers::GetString(L"#TB_NOITEMS"));
		lastMenuId++;

		menu->Append(noItems);
		noItems->Enable(false);
	}

	return menu;
}