Ejemplo n.º 1
0
void CMessageBox::Show(const wchar_t *pString, MBCreate* pCreate, uint32 nFontSize, bool bDefaultReturn)
{
	if (m_bVisible || !pCreate)
		return;

	m_eType = pCreate->eType;

	m_bGameWasPaused = g_pGameClientShell->IsGamePaused();
	if (!m_bGameWasPaused)
        g_pGameClientShell->PauseGame(true,true);

	uint32 nSize;
	if (nFontSize)
		nSize = nFontSize;
	else
		nSize = g_pLayoutDB->GetDialogFontSize();

	m_Dlg.SetScale(g_pInterfaceResMgr->GetScreenScale());

	m_pText->SetSize( LTVector2n(kBaseWidth-2*kIndent,nSize) );
	m_pText->SetString(pString);
	m_pText->SetFont(CFontInfo(m_Font.m_szTypeface,nSize));

	if (m_eType == LTMB_EDIT)
	{
		m_pEdit->SetText(pCreate->pString);
		m_pEdit->SetInputMode(pCreate->eInput);
		m_pEdit->SetInputFilter(pCreate->pFilterFn);
		m_pEdit->SetMaxLength(pCreate->nMaxChars);
		m_pEdit->SetPreventEmptyString(pCreate->bPreventEmptyString);

		m_pEdit->Show(true);
		m_pEdit->SetFont(CFontInfo(m_Font.m_szTypeface,nSize));
	}
	else
		m_pEdit->Show(false);


	//build the texture so we can find out how big it is
	m_pText->RecreateTextureStrings();
	LTRect2n rExtents;
	m_pText->GetExtents(rExtents);

	//if the wordwrapped text height is more than half it's width, go to a larger box
	if (rExtents.GetHeight() > (rExtents.GetWidth() / 2))
	{
		m_pText->SetSize(LTVector2n(kBigWidth-2*kIndent,nSize));
		m_pText->GetExtents(rExtents);

	}

	LTVector2n dlgSz;
	dlgSz.x = 2*kIndent + (int32)((float)rExtents.GetWidth()/ g_pInterfaceResMgr->GetXRatio());
	if (dlgSz.x < kMinWidth)
		dlgSz.x = kMinWidth;
	dlgSz.y = (uint32)((float)rExtents.GetHeight()/g_pInterfaceResMgr->GetYRatio());
	dlgSz.y += 3*kIndent + m_pOK->GetBaseHeight();

	if (m_eType == LTMB_EDIT)
	{
		dlgSz.y += (kIndent + m_pEdit->GetBaseHeight());
		if (dlgSz.x < kBaseWidth)
			dlgSz.x = kBaseWidth;
//		m_pEdit->SetFixedWidth(dlgSz.x-2*kIndent,true);
	}

	LTVector2n offset;

	uint32 textWidth = (uint32)( (float)rExtents.GetWidth() / g_pInterfaceResMgr->GetXRatio() );

	m_Dlg.SetSize(dlgSz);
	offset.x = (dlgSz.x - textWidth) / 2;
	offset.y = kIndent;
	m_Dlg.SetControlOffset(m_pText,offset);

	m_bIgnoreEsc = !!( pCreate->nFlags & eMBFlag_IgnoreESC );
	m_bPreventEmptyString = pCreate->bPreventEmptyString;

	switch (m_eType)
	{
	case LTMB_YESNO:
		{
			m_pOK->SetAlignment( kLeft );
			m_pOK->SetString(szYes);
			m_pOK->SetSize(LTVector2n(dlgSz.x/3,m_pOK->GetBaseHeight()));
			offset.x = 4*kIndent;
			offset.y = (dlgSz.y - kIndent) - m_pOK->GetBaseHeight();
			m_Dlg.SetControlOffset(m_pOK,offset);
			m_pOK->Show(true);

			m_pCancel->SetString(szNo);
			m_pCancel->SetSize(LTVector2n(dlgSz.x/3,m_pCancel->GetBaseHeight()));
			offset.x = (dlgSz.x) - 4*kIndent - m_pCancel->GetBaseWidth();
			offset.y = (dlgSz.y - kIndent) - m_pCancel->GetBaseHeight();
			m_Dlg.SetControlOffset(m_pCancel,offset);
			m_pCancel->Show(true);
		}	break;
	case LTMB_OK:
		{
			m_pOK->SetAlignment( kCenter );
			m_pOK->SetString(szOK);
			m_pOK->SetSize(LTVector2n(dlgSz.x/3,m_pOK->GetBaseHeight()));
			offset.x = (dlgSz.x - m_pOK->GetBaseWidth()) / 2;
			offset.y = (dlgSz.y - kIndent) - m_pOK->GetBaseHeight();
			m_Dlg.SetControlOffset(m_pOK,offset);
			m_pOK->Show(true);
			m_pCancel->Show(false);
		} break;
	case LTMB_EDIT:
		{
			offset.x = kIndent;
			offset.y = 2* kIndent + m_pText->GetBaseHeight();
			m_Dlg.SetControlOffset(m_pEdit,offset);

			m_pOK->SetAlignment( kLeft );
			m_pOK->SetString(szOK);
			m_pOK->SetSize(LTVector2n(dlgSz.x/3,m_pOK->GetBaseHeight()));
			offset.x = 4*kIndent;
			offset.y = (dlgSz.y - kIndent) - m_pOK->GetBaseHeight();
			m_Dlg.SetControlOffset(m_pOK,offset);

			UpdateEditOK();

			m_pCancel->SetString(szCancel);
			m_pCancel->SetSize(LTVector2n(dlgSz.x/3,m_pCancel->GetBaseHeight()));
			offset.x = (dlgSz.x) - 4*kIndent - m_pCancel->GetBaseWidth();
			offset.y = (dlgSz.y - kIndent) - m_pCancel->GetBaseHeight();
			m_Dlg.SetControlOffset(m_pCancel,offset);
			m_pCancel->Show(true);
		} break;
	};


	m_pCallback = pCreate->pFn;
	m_pUserData = pCreate->pUserData;
	m_pData = pCreate->pData;

	if (bDefaultReturn)
	{
		m_Dlg.SetSelection(m_Dlg.GetIndex(m_pOK));
	}
	else
	{
		m_Dlg.SetSelection(m_Dlg.GetIndex(m_pCancel));
	}

	offset.x =  (640 - dlgSz.x) / 2;
	offset.y = (480 - dlgSz.y) / 2;
	m_Dlg.SetBasePos(offset);

	m_Dlg.Show(true);
    m_bVisible = true;

    // Set the cursor to the appropriate state
	g_pInterfaceMgr->UpdateCursorState();

	m_nHotKey = pCreate->nHotKey;
}
Ejemplo n.º 2
0
void CScreenHostLevels::AddMissionToList(int nMissionId, bool bVerifySize, bool bForce)
{
	// Sanity checks...

	if (!m_pSelMissions) return;
	if (m_pSelMissions->GetNumControls() == MAX_GAME_LEVELS) return;


	// Add the level to the list...

	CLTGUICtrl_create cs;
	cs.rnBaseRect.m_vMin.Init();
	cs.rnBaseRect.m_vMax = LTVector2n(nSelWidth,nListFontSize);
	cs.nCommandID = CMD_REMOVE_LEVEL;
	cs.pCommandHandler = this;

	HRECORD hMission = g_pMissionDB->GetMission(nMissionId);
	HRECORD	hLevel = g_pMissionDB->GetLevel(hMission,0);
	if (hMission && hLevel)
	{
		if (!g_pMissionDB->CheckMPLevelRequirements(hMission,m_setRequiredMapFeatures))
		{
			return;
		}

		if (!bForce)
		{
			uint32 nMapMin = g_pMissionDB->GetInt32(hLevel,MDB_MinPlayers,0,0);
			uint32 nMapMax = g_pMissionDB->GetInt32(hLevel,MDB_MaxPlayers,0,0);
			uint32 nGameMax = GameModeMgr::Instance( ).m_grnMaxPlayers.GetValue();
			if (nMapMax > 0 && nGameMax > nMapMax)
			{
				if (bVerifySize)
				{

					MBCreate mb;
					mb.eType = LTMB_YESNO;
					mb.pFn = AddCallBack;
					mb.pData = (void *)nMissionId;
					mb.pUserData = this;
					g_pInterfaceMgr->ShowMessageBox("Screen_Host_LevelTooSmall",&mb);

				}
				return;
			}
			if (nMapMin > 0 && nGameMax < nMapMin)
			{
				if (bVerifySize)
				{

					MBCreate mb;
					mb.eType = LTMB_YESNO;
					mb.pFn = AddCallBack;
					mb.pData = (void *)nMissionId;
					mb.pUserData = this;
					g_pInterfaceMgr->ShowMessageBox("Screen_Host_LevelTooLarge",&mb);

				}
				return;
			}
		}

		
		const char* szNameId = g_pMissionDB->GetString(hMission,MDB_Name);
		std::wstring sName;
		if( szNameId[0] != '\0' )
		{
			sName = LoadString(szNameId);
		}
		else
		{
			sName = g_pMissionDB->GetWString(hMission,MDB_NameStr);
			if (!sName.length())
			{
				sName = MPA2W(g_pMissionDB->GetWorldName(hLevel,false)).c_str();
			}
		}
		wchar_t wszPlayers[64] = L"";
		uint32 nMin = g_pMissionDB->GetInt32(hLevel,MDB_MinPlayers,0,0);
		uint32 nMax = g_pMissionDB->GetInt32(hLevel,MDB_MaxPlayers,0,0);
		if (nMin >= 2 && nMax >= nMin)
		{
			FormatString("MP_Players",wszPlayers,LTARRAYSIZE(wszPlayers),nMin,nMax);
			sName += L" ";
			sName += wszPlayers;
		}

		cs.szHelpID = "";

		CLTGUIColumnCtrlEx* pColumnCtrl = debug_new(CLTGUIColumnCtrlEx);
		pColumnCtrl->Create(cs);
		pColumnCtrl->SetScale(g_pInterfaceResMgr->GetScreenScale());
		pColumnCtrl->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor);
		pColumnCtrl->SetParam1( nMissionId );

		char const* pszListFont = g_pLayoutDB->GetListFont(m_hLayout,0);
		const uint32 nListFontSize = g_pLayoutDB->GetListSize(m_hLayout,0);

		pColumnCtrl->SetFont( CFontInfo(pszListFont, nListFontSize) );
		pColumnCtrl->AddTextColumn( sName.c_str(), nSelWidth, true );

		m_pSelMissions->AddControl( pColumnCtrl );
	
	}
	else
	{
		ASSERT(!"Invalid mission id");
	}

}
Ejemplo n.º 3
0
CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store)
{
    u32 magic;
    in.readBytesToBuf(&magic, 4);
    if (magic != SBIG('FONT'))
        return;

    u32 version = in.readUint32Big();
    x4_monoWidth = in.readUint32Big();
    x8_monoHeight = in.readUint32Big();

    if (version >= 1)
        x8c_baseline = in.readUint32Big();
    else
        x8c_baseline = x8_monoHeight;

    if (version >= 2)
        x90_lineMargin = in.readUint32Big();

    bool tmp1 = in.readBool();
    bool tmp2 = in.readBool();

    u32 tmp3 = in.readUint32Big();
    u32 tmp4 = in.readUint32Big();
    std::string name= in.readString();
    u32 txtrId = in.readUint32Big();
    x30_fontInfo = CFontInfo(tmp1, tmp2, tmp3, tmp4, name.c_str());
    x80_texture = store.GetObj({'TXTR', txtrId});
    EColorType mode = EColorType(in.readUint32Big());
    /* TODO: Make an enum */
    if (mode == EColorType::One)
        x2c_mode = EColorType::One;
    else if (mode == EColorType::Zero)
        x2c_mode = EColorType::Zero;

    u32 glyphCount = in.readUint32Big();
    xc_glyphs.reserve(glyphCount);

    for (u32 i = 0 ; i < glyphCount ; ++i)
    {
        wchar_t chr = in.readUint16Big();
        float startU = in.readFloatBig();
        float startV = in.readFloatBig();
        float endU = in.readFloatBig();
        float endV = in.readFloatBig();
        s32 a = in.readInt32Big();
        s32 b = in.readInt32Big();
        s32 c = in.readInt32Big();
        s32 cellWidth = in.readInt32Big();
        s32 cellHeight = in.readInt32Big();
        s32 baseline = in.readInt32Big();
        s32 kernStart = in.readInt32Big();
        xc_glyphs[i] = std::make_pair(chr, CGlyph(a, b, c, startU, startV, endU, endV,
                                                  cellWidth, cellHeight, baseline, kernStart));
    }

    std::sort(xc_glyphs.begin(), xc_glyphs.end(), [=](auto& a, auto& b) -> bool{
        return a.first < b.first;
    });

    u32 kernCount = in.readUint32Big();
    x1c_kerning.reserve(kernCount);

    for (u32 i = 0 ; i < kernCount ; ++i)
    {
        wchar_t first = in.readUint16Big();
        wchar_t second = in.readUint16Big();
        s32 howMuch = in.readUint32Big();
        x1c_kerning[i] = CKernPair(first, second, howMuch);
    }
}
Ejemplo n.º 4
0
bool CScreenHostLevels::FillAvailList()
{
	// Sanity checks...

    if (!m_pAvailMissions) return(false);

	CLTGUICtrl_create cs;
	cs.rnBaseRect.m_vMin.Init();
	cs.rnBaseRect.m_vMax = LTVector2n(nAvailWidth,nListFontSize);
	cs.nCommandID = CMD_ADD_LEVEL;
	cs.pCommandHandler = this;


	for (uint32 nMission = 0; nMission < g_pMissionDB->GetNumMissions(); nMission++)
	{
		HRECORD hMission = g_pMissionDB->GetMission(nMission);
		HRECORD	hLevel = g_pMissionDB->GetLevel(hMission,0);
		bool bValidForGameMode = true;
		if (hMission && hLevel)
		{
			if (!g_pMissionDB->CheckMPLevelRequirements(hMission,m_setRequiredMapFeatures))
			{
				continue;
			}

			const char* szNameId = g_pMissionDB->GetString(hMission,MDB_Name);
			std::wstring sName;
			if( szNameId[0] != '\0' )
			{
				sName = LoadString(szNameId);
			}
			else
			{
				sName = g_pMissionDB->GetWString(hMission,MDB_NameStr);
				if (!sName.length())
				{
					sName = MPA2W(g_pMissionDB->GetWorldName(hLevel,false)).c_str();
				}
			}
			wchar_t wszPlayers[64] = L"";
			uint32 nMin = g_pMissionDB->GetInt32(hLevel,MDB_MinPlayers,0,0);
			uint32 nMax = g_pMissionDB->GetInt32(hLevel,MDB_MaxPlayers,0,0);
			if (nMin >= 2 && nMax >= nMin)
			{
				FormatString("MP_Players",wszPlayers,LTARRAYSIZE(wszPlayers),nMin,nMax);
				sName += L" ";
				sName += wszPlayers;
			}

			char szWorldTitle[MAX_PATH] = "";
			LTStrCpy(szWorldTitle,g_pMissionDB->GetWorldName(hLevel,false),LTARRAYSIZE(szWorldTitle));

			CLTGUIColumnCtrlEx* pColumnCtrl = debug_new(CLTGUIColumnCtrlEx);
			pColumnCtrl->Create(cs);
			pColumnCtrl->SetScale(g_pInterfaceResMgr->GetScreenScale());
			pColumnCtrl->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor);
			pColumnCtrl->SetParam1(nMission);

			char const* pszListFont = g_pLayoutDB->GetListFont(m_hLayout,0);
			const uint32 nListFontSize = g_pLayoutDB->GetListSize(m_hLayout,0);

			pColumnCtrl->SetFont( CFontInfo(pszListFont, nListFontSize) );
			pColumnCtrl->AddTextColumn( sName.c_str(), nAvailWidth, true );

			m_pAvailMissions->AddControl( pColumnCtrl );
		}
	}


    return (true);
}