//---------------------------------------------------------------------------- UIFrame *LP_Manager::CreateHeadFrame() { UIFrame *headFrame = new0 UIFrame(); headFrame->SetPivot(0.0f, 0.5f); headFrame->SetAnchorHor(0.0f, 0.0f); headFrame->SetAnchorVer(0.0f, 1.0f); headFrame->SetSize(200.0f, 0.0f); UIButton *headBut = new0 UIButton(); headFrame->AttachChild(headBut); headBut->SetAnchorHor(0.0f, 0.0f); headBut->SetAnchorVer(0.5f, 0.5f); headBut->SetSize(60.0f, 60.0f); headBut->SetAnchorParamHor(40.0f, 0.f); headBut->GetPicBoxAtState(UIButtonBase::BS_NORMAL)->SetTexture( "DataLauncher/images/icons/h_brid_72.png"); headBut->SetStateColor(UIButtonBase::BS_NORMAL, Float3::WHITE); headBut->SetStateColor(UIButtonBase::BS_HOVERED, Float3::WHITE); headBut->SetStateColor(UIButtonBase::BS_PRESSED, Float3::WHITE); headBut->SetStateBrightness(UIButtonBase::BS_NORMAL, 1.0f); headBut->SetStateBrightness(UIButtonBase::BS_HOVERED, 1.0f); headBut->SetStateBrightness(UIButtonBase::BS_PRESSED, 1.05f); UIFText *nameText = new0 UIFText(); headBut->AttachChild(nameText); nameText->LocalTransform.SetTranslateY(-2.0f); nameText->SetAnchorHor(0.5f, 0.5f); nameText->SetAnchorVer(0.0f, 0.0f); nameText->SetAnchorParamVer(7.0f, 0.0f); nameText->GetText()->SetFont("DataLauncher/fonts/msyh.ttc", 24, 24); nameText->GetText()->SetFontScale(0.5f); nameText->GetText()->SetFontColor(Float3::WHITE); nameText->GetText()->SetDrawStyle(FD_BORDER); nameText->GetText()->SetBorderShadowAlpha(0.5f); nameText->GetText()->SetText(PX2_LMVAL("mrtime")); return headFrame; }
DAVA::UIControl *UIControlFactory::CreateButton(DAVA::UIControl *prototype, UIStyle *style) { UIButton *button = NULL; if (prototype) button = dynamic_cast<UIButton*>(prototype->Clone()); if (!button) button = new UIButton(); ApplyAttributes(button, style); const int32 states[] = {UIControl::STATE_NORMAL, UIControl::STATE_PRESSED_INSIDE, UIControl::STATE_PRESSED_OUTSIDE, UIControl::STATE_DISABLED, UIControl::STATE_SELECTED, UIControl::STATE_HOVER}; const String stateNames[] = {"Normal", "PressedInside", "PressedOutside", "Disabled", "Selected", "Hover"}; for (int i = 0; i < UIControl::STATE_COUNT; i++) { const UIStyle *stateStyle = style->GetSubstyle(stateNames[i]); if (stateStyle == NULL) stateStyle = style; const UIStyleAttribute *attr = NULL; if ((attr = stateStyle->GetAttribute("sprite", style)) != NULL) button->SetStateSprite(states[i], attr->AsString()); if ((attr = stateStyle->GetAttribute("spriteFrame", style)) != NULL) button->SetStateFrame(states[i], attr->AsInt()); if ((attr = stateStyle->GetAttribute("color", style)) != NULL) button->SetStateColor(states[i], attr->AsColor()); if ((attr = stateStyle->GetAttribute("text", style)) != NULL) button->SetStateText(states[i], StringToWString(attr->AsString())); if ((attr = stateStyle->GetAttribute("font", style)) != NULL) { String fontName = attr->AsString(); int fontSize = 20; if ((attr = stateStyle->GetAttribute("fontSize", style)) != NULL) fontSize = attr->AsInt(); Font *font = FTFont::Create(fontName); font->SetSize(fontSize); button->SetStateFont(states[i], font); SafeRelease(font); } } return button; }
//---------------------------------------------------------------------------- UIFrame *LP_Manager::CreateEngineFrame() { UIFrame *engineFrame = new0 UIFrame(); engineFrame->LocalTransform.SetTranslateY(-1.0f); engineFrame->SetAnchorHor(0.0f, 1.0f); engineFrame->SetAnchorVer(0.0f, 1.0f); float leftWidth = 200.0f; float engineButWidth = leftWidth - 10.0f; float engineButHeight = 50.0f; UIFrame *leftFrame = new0 UIFrame(); engineFrame->AttachChild(leftFrame); leftFrame->SetAnchorHor(0.0f, 0.0f); leftFrame->SetAnchorVer(0.0f, 1.0f); leftFrame->SetAnchorParamHor(leftWidth / 2.0f, 0.0f); leftFrame->SetSize(leftWidth, 0.0f); UIPicBox *picBox = leftFrame->CreateAddBackgroundPicBox(); picBox->SetColor(Float3::MakeColor(64, 64, 64)); float height = -80.0f; // engine UIButton *butEngine = new0 UIButton(); leftFrame->AttachChild(butEngine); butEngine->SetAnchorHor(0.5f, 0.5f); butEngine->SetAnchorVer(1.0f, 1.0f); butEngine->SetAnchorParamVer(height, 0.0f); butEngine->LocalTransform.SetTranslateY(-1.0f); butEngine->SetSize(engineButWidth, engineButHeight); // news height -= 100.0f; UIButton *butNews = new0 UIButton(); butNews->SetStateColor(UIButtonBase::BS_NORMAL, Float3::MakeColor(80, 80, 80)); butNews->SetStateColor(UIButtonBase::BS_HOVERED, Float3::MakeColor(100, 100, 100)); butNews->SetStateColor(UIButtonBase::BS_PRESSED, Float3::MakeColor(60, 60, 60)); leftFrame->AttachChild(butNews); butNews->SetAnchorHor(0.5f, 0.5f); butNews->SetAnchorVer(1.0f, 1.0f); butNews->SetAnchorParamVer(height, 0.0f); butNews->LocalTransform.SetTranslateY(-1.0f); butNews->SetSize(leftWidth, engineButHeight); // learn height -= 55.0f; UIButton *butLearn = new0 UIButton(); leftFrame->AttachChild(butLearn); butLearn->SetAnchorHor(0.5f, 0.5f); butLearn->SetAnchorVer(1.0f, 1.0f); butLearn->SetAnchorParamVer(height, 0.0f); butLearn->LocalTransform.SetTranslateY(-1.0f); butLearn->SetSize(leftWidth, engineButHeight); // res height -= 55.0f; UIButton *butRes = new0 UIButton(); leftFrame->AttachChild(butRes); butRes->SetAnchorHor(0.5f, 0.5f); butRes->SetAnchorVer(1.0f, 1.0f); butRes->SetAnchorParamVer(height, 0.0f); butRes->LocalTransform.SetTranslateY(-1.0f); butRes->SetSize(leftWidth, engineButHeight); UIFrame *rightFrame = new0 UIFrame(); engineFrame->AttachChild(rightFrame); rightFrame->SetAnchorHor(0.0f, 1.0f); rightFrame->SetAnchorVer(0.0f, 1.0f); rightFrame->SetAnchorParamHor(leftWidth, 0.0f); AweUIFrame *aweFrame = new0 AweUIFrame(); rightFrame->AttachChild(aweFrame); aweFrame->SetAnchorHor(0.0f, 1.0f); aweFrame->SetAnchorVer(0.0f, 1.0f); aweFrame->OpenURL("http://www.google.com/"); return engineFrame; }
//---------------------------------------------------------------------------- UIFrame *LP_Manager::AddTabFrame(const std::string &name, const std::string &title) { UIFrame *uiFrame = new0 UIFrame(); uiFrame->SetAnchorHor(0.0f, 1.0f); uiFrame->SetAnchorVer(0.0f, 1.0f); uiFrame->SetActivateSelfCtrled(true); UIFPicBox *fpicBox = new0 UIFPicBox(); uiFrame->AttachChild(fpicBox); fpicBox->LocalTransform.SetTranslateY(-10.0f); fpicBox->SetAnchorHor(0.0f, 1.0f); fpicBox->SetAnchorVer(1.0f, 1.0f); fpicBox->SetPivot(0.5f, 1.0f); fpicBox->SetSize(0.0f, 3.0f); UIPicBox *picBox = fpicBox->GetUIPicBox(); picBox->SetTexture("Data/engine/white.png"); picBox->SetColor(Float3::YELLOW); mTableFrame->AddTab(name, title, uiFrame); UIText *text = mTableFrame->GetTabButton(name)->GetText(); text->SetColorSelfCtrled(true); text->SetBrightnessSelfCtrled(true); text->SetFontScale(0.65f); text->SetFontColor(Float3::WHITE); text->SetColor(Float3::WHITE); text->SetDrawStyle(FD_SHADOW); text->SetBorderShadowAlpha(0.8f); if ("ManyKit" == name) { text->SetFont("DataLauncher/fonts/msyh.ttc", 24, 24); } else { text->SetFont("DataLauncher/fonts/msyhl.ttc", 24, 24); } UIButton *tabBut = mTableFrame->GetTabButton(name); Float3 color = Float3::MakeColor(237, 28, 36); if ("ManyKit" == name) { color = Float3::MakeColor(237, 28, 36); } else if ("Edu" == name) { color = Float3::MakeColor(0, 162, 233); } else if ("Toys" == name) { color = Float3::MakeColor(255, 127, 39); } else if ("Games" == name) { color = Float3::MakeColor(24, 177, 76); } picBox->SetColor(color); tabBut->SetStateColor(UIButtonBase::BS_NORMAL, color); tabBut->SetStateColor(UIButtonBase::BS_HOVERED, color); tabBut->SetStateBrightness(UIButtonBase::BS_HOVERED, 1.2f); tabBut->SetStateColor(UIButtonBase::BS_PRESSED, color); tabBut->SetStateBrightness(UIButtonBase::BS_PRESSED, 1.0f); tabBut->SetActivateColor(color); return uiFrame; }