LTBOOL CBaseMenu::Init() { if (!s_Frame) { char szTmp[128] = ""; g_pLayoutMgr->GetMenuFrame(szTmp,sizeof(szTmp)); s_Frame = g_pInterfaceResMgr->GetTexture(szTmp); g_pLayoutMgr->GetMenuFrameTip(szTmp,sizeof(szTmp)); s_FrameTip = g_pInterfaceResMgr->GetTexture(szTmp); s_Size = g_pLayoutMgr->GetMenuSize(); s_Pos = g_pLayoutMgr->GetMenuPosition(); g_pLayoutMgr->GetMenuUpArrow(szTmp,sizeof(szTmp)); s_Up = g_pInterfaceResMgr->GetTexture(szTmp); g_pLayoutMgr->GetMenuUpArrowHighlight(szTmp,sizeof(szTmp)); s_UpH = g_pInterfaceResMgr->GetTexture(szTmp); g_pLayoutMgr->GetMenuDownArrow(szTmp,sizeof(szTmp)); s_Down = g_pInterfaceResMgr->GetTexture(szTmp); g_pLayoutMgr->GetMenuDownArrowHighlight(szTmp,sizeof(szTmp)); s_DownH = g_pInterfaceResMgr->GetTexture(szTmp); } m_FontFace = g_pLayoutMgr->GetMenuFontFace(m_MenuID); m_FontSize = g_pLayoutMgr->GetMenuFontSize(m_MenuID); m_TitleFontFace = g_pLayoutMgr->GetMenuTitleFontFace(m_MenuID); m_TitleFontSize = g_pLayoutMgr->GetMenuTitleFontSize(m_MenuID); m_Indent = g_pLayoutMgr->GetMenuIndent(m_MenuID); m_SelectedColor = g_pLayoutMgr->GetMenuSelectedColor(m_MenuID); m_NonSelectedColor = g_pLayoutMgr->GetMenuNonSelectedColor(m_MenuID); m_DisabledColor = g_pLayoutMgr->GetMenuDisabledColor(m_MenuID); if (!Create(NULL,s_Size.x,s_Size.y)) return LTFALSE; SetupQuadUVs(m_Poly[0], s_Frame, 0.0f,0.0f,1.0f,1.0f); SetupQuadUVs(m_Poly[1], s_FrameTip, 0.0f,0.0f,1.0f,1.0f); g_pDrawPrim->SetRGBA(&m_Poly[0],argbWhite); g_pDrawPrim->SetRGBA(&m_Poly[1],argbWhite); LTIntPt pos = m_Indent; CUIFont* pFont = g_pInterfaceResMgr->GetFont(m_TitleFontFace); if (!pFont) return LTFALSE; if (!m_Title.Create("X", LTNULL, LTNULL, pFont, m_TitleFontSize, this)) { return LTFALSE; } m_Title.SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); m_Title.Enable(LTFALSE); pos.x = m_Indent.x + 24; CLTGUIWindow::AddControl(&m_Title,pos); m_Title.SetScale(1.0f); pos.x = m_Indent.x; pos.y += (m_Title.GetHeight() + 4); m_Title.SetScale(g_pInterfaceResMgr->GetXRatio()); m_List.Create(s_Size.y - pos.y); uint16 nOffset = (s_Size.x-m_Indent.x*2)-16; m_List.UseArrows(nOffset ,1.0f,s_Up,s_UpH,s_Down,s_DownH); CLTGUIWindow::AddControl(&m_List,pos); m_Resume.Create(LoadTempString(IDS_RESUME),MC_CLOSE,NULL,pFont,m_TitleFontSize,this); pos.x = s_Size.x - m_Indent.x - m_Resume.GetWidth(); pos.y = 12; CLTGUIWindow::AddControl(&m_Resume,pos); pos.x = s_Pos; pos.y = 0; SetBasePos(pos); return LTTRUE; }
LTBOOL CHUDMessage::Create(MsgCreate &mc) { if (!mc.pFont) return LTFALSE; if (kMinDuration < 0.0f) kMinDuration = g_pLayoutMgr->GetMessageMinTime(); if (kMinFade < 0.0f) kMinFade = g_pLayoutMgr->GetMessageMinFade(); m_pFont = mc.pFont; if (!m_pText) { m_pText = g_pFontManager->CreateFormattedPolyString(m_pFont,"",0.0f,0.0f); if (!m_pText) return LTFALSE; } m_pText->SetText(mc.sString.c_str()); m_nFontSize = mc.nFontSize; m_nBaseFontSize = mc.nFontSize; m_nTextColor = mc.nTextColor; m_nFixedWidth = mc.nWidth; m_bDropShadow = mc.bDropShadow; m_pText->SetColor(m_nTextColor); m_fInitTime = -1.0f; m_eJustify = mc.eJustify; m_fDuration = mc.fDuration * GetConsoleFloat("MessageDuration",1.0f); if (m_fDuration < kMinDuration) m_fDuration = kMinDuration; m_fFadeDur = mc.fFadeDur * GetConsoleFloat("MessageDuration",1.0f);; if (m_fFadeDur < kMinFade) m_fFadeDur = kMinFade; m_hImage = mc.hImage; m_nBaseImageSize = mc.nImageSize; switch (m_eJustify) { case kMsgLeft: m_pText->SetAlignmentH(CUI_HALIGN_LEFT); break; case kMsgRight: m_pText->SetAlignmentH(CUI_HALIGN_RIGHT); break; case kMsgCenter: m_pText->SetAlignmentH(CUI_HALIGN_CENTER); break; }; InitPoly(); SetBasePos(LTIntPt(0,0)); SetScale(g_pInterfaceResMgr->GetXRatio()); m_bVisible = LTTRUE; return LTTRUE; }