void SceneEditorScreenMain::OnCreatePressed(BaseObject *, void *, void *) { menuPopup->InitControl(MENUID_CREATENODE, btnCreate->GetRect()); AddControl(menuPopup); }
bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* parent) { if ( !wxDialog::Create(parent, wxID_ANY, wxString::Format(_("About %s"), info.GetName()), wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE) ) return false; m_sizerText = new wxBoxSizer(wxVERTICAL); wxString nameAndVersion = info.GetName(); if ( info.HasVersion() ) nameAndVersion << wxT(' ') << info.GetVersion(); wxStaticText *label = new wxStaticText(this, wxID_ANY, nameAndVersion); wxFont fontBig(*wxNORMAL_FONT); fontBig.SetFractionalPointSize(fontBig.GetFractionalPointSize() + 2.0); fontBig.SetWeight(wxFONTWEIGHT_BOLD); label->SetFont(fontBig); m_sizerText->Add(label, wxSizerFlags().Centre().Border()); m_sizerText->AddSpacer(5); AddText(info.GetCopyrightToDisplay()); AddText(info.GetDescription()); if ( info.HasWebSite() ) { #if wxUSE_HYPERLINKCTRL AddControl(new wxHyperlinkCtrl(this, wxID_ANY, info.GetWebSiteDescription(), info.GetWebSiteURL())); #else AddText(info.GetWebSiteURL()); #endif // wxUSE_HYPERLINKCTRL/!wxUSE_HYPERLINKCTRL } #if wxUSE_COLLPANE if ( info.HasLicence() ) AddCollapsiblePane(_("License"), info.GetLicence()); if ( info.HasDevelopers() ) AddCollapsiblePane(_("Developers"), AllAsString(info.GetDevelopers())); if ( info.HasDocWriters() ) AddCollapsiblePane(_("Documentation writers"), AllAsString(info.GetDocWriters())); if ( info.HasArtists() ) AddCollapsiblePane(_("Artists"), AllAsString(info.GetArtists())); if ( info.HasTranslators() ) AddCollapsiblePane(_("Translators"), AllAsString(info.GetTranslators())); #endif // wxUSE_COLLPANE DoAddCustomControls(); wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL); #if wxUSE_STATBMP wxIcon icon = info.GetIcon(); if ( icon.IsOk() ) { sizerIconAndText->Add(new wxStaticBitmap(this, wxID_ANY, icon), wxSizerFlags().Border(wxRIGHT)); } #endif // wxUSE_STATBMP sizerIconAndText->Add(m_sizerText, wxSizerFlags(1).Expand()); wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border()); // Mac typically doesn't use OK buttons just for dismissing dialogs. #if !defined(__WXMAC__) wxSizer *sizerBtns = CreateButtonSizer(wxOK); if ( sizerBtns ) { sizerTop->Add(sizerBtns, wxSizerFlags().Expand().Border()); } #endif SetSizerAndFit(sizerTop); CentreOnParent(); #if !wxUSE_MODAL_ABOUT_DIALOG Bind(wxEVT_CLOSE_WINDOW, &wxGenericAboutDialog::OnCloseWindow, this); Bind(wxEVT_BUTTON, &wxGenericAboutDialog::OnOK, this, wxID_OK); #endif // !wxUSE_MODAL_ABOUT_DIALOG return true; }
void wxGenericAboutDialog::AddText(const wxString& text) { if ( !text.empty() ) AddControl(new wxStaticText(this, wxID_ANY, text)); }
TextureConverterDialog::TextureConverterDialog(const Rect &rect, bool rectInAbsoluteCoordinates) : UIControl(rect, rectInAbsoluteCoordinates) { selectedItem = -1; selectedTextureName = ""; workingScene = NULL; ControlsFactory::CustomizePanelControl(this); textureList = new UIList(Rect(0, 0, ControlsFactory::TEXTURE_PREVIEW_WIDTH, rect.dy), UIList::ORIENTATION_VERTICAL); ControlsFactory::SetScrollbar(textureList); textureList->SetDelegate(this); AddControl(textureList); float32 closeButtonSide = ControlsFactory::BUTTON_HEIGHT; closeButtonTop = ControlsFactory::CreateCloseWindowButton(Rect(rect.dx - closeButtonSide, 0, closeButtonSide, closeButtonSide)); closeButtonTop->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &TextureConverterDialog::OnCancel)); AddControl(closeButtonTop); UIStaticText *notification = new UIStaticText(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, 0, rect.dx - ControlsFactory::TEXTURE_PREVIEW_WIDTH - closeButtonSide, closeButtonSide)); notification->SetFont(ControlsFactory::GetFontError()); notification->SetAlign(ALIGN_VCENTER | ALIGN_HCENTER); notification->SetText(LocalizedString(L"textureconverter.notification")); AddControl(notification); SafeRelease(notification); int32 x = rect.dx - ControlsFactory::BUTTON_WIDTH; convertButton = ControlsFactory::CreateButton(Vector2(x, rect.dy - ControlsFactory::BUTTON_HEIGHT), LocalizedString(L"textureconverter.convert")); convertButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &TextureConverterDialog::OnConvert)); AddControl(convertButton); AddLine(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, 0, 1, rect.dy)); dstPreview = new UIControl(Rect(0, 0, 100, 100)); dstPreview->SetInputEnabled(false); dstPreview->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); srcPreview = new UIControl(Rect(0, 0, 100, 100)); srcPreview->SetInputEnabled(false); srcPreview->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); int32 width = rect.dx - ControlsFactory::TEXTURE_PREVIEW_WIDTH; int32 height = (rect.dy - ControlsFactory::BUTTON_HEIGHT*2); if(width < height) { width = Min(width, height/2); --width; Rect srcRect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, ControlsFactory::BUTTON_HEIGHT, width, width); Rect dstRect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, ControlsFactory::BUTTON_HEIGHT + width + 1, width, width); srcZoomPreview = new UIZoomControl(srcRect); dstZoomPreview = new UIZoomControl(dstRect); AddLine(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH+width, ControlsFactory::BUTTON_HEIGHT, 1, width * 2)); AddLine(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, ControlsFactory::BUTTON_HEIGHT + width, width, 1)); AddLine(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, ControlsFactory::BUTTON_HEIGHT + width*2, width, 1)); } else { height = Min(height, width/2); --height; Rect srcRect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, ControlsFactory::BUTTON_HEIGHT, height, height); Rect dstRect(ControlsFactory::TEXTURE_PREVIEW_WIDTH + height + 1, ControlsFactory::BUTTON_HEIGHT, height, height); srcZoomPreview = new UIZoomControl(srcRect); dstZoomPreview = new UIZoomControl(dstRect); AddLine(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, ControlsFactory::BUTTON_HEIGHT + height, height*2, 1)); AddLine(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH + height, ControlsFactory::BUTTON_HEIGHT, 1, height)); AddLine(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH + height*2, ControlsFactory::BUTTON_HEIGHT, 1, height)); } srcZoomPreview->AddControl(srcPreview); dstZoomPreview->AddControl(dstPreview); zoomSlider = new UISlider(Rect(ControlsFactory::TEXTURE_PREVIEW_WIDTH, rect.dy - ControlsFactory::BUTTON_HEIGHT, rect.dx - ControlsFactory::TEXTURE_PREVIEW_WIDTH - ControlsFactory::BUTTON_WIDTH, ControlsFactory::BUTTON_HEIGHT)); zoomSlider->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &TextureConverterDialog::OnZoomChanged)); zoomSlider->SetMinSprite("~res:/Gfx/LandscapeEditor/Tools/polzunok", 1); zoomSlider->SetMinDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL); zoomSlider->SetMinLeftRightStretchCap(5); zoomSlider->SetMaxSprite("~res:/Gfx/LandscapeEditor/Tools/polzunok", 0); zoomSlider->SetMaxDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL); zoomSlider->SetMaxLeftRightStretchCap(5); zoomSlider->SetThumbSprite("~res:/Gfx/LandscapeEditor/Tools/polzunokCenter", 0); AddControl(zoomSlider); formatDialog = new TextureFormatDialog(this); lastActiveZoomControl = NULL; }
// Build the screen LTBOOL CScreenProfile::Build() { // Set the title's text CreateTitle(IDS_TITLE_PROFILE); // Get edit controls position and create it. LTIntPt pos = g_pLayoutMgr->GetScreenCustomPoint((eScreenID)m_nScreenID,"ProfileNamePos"); m_pCurrent = AddTextItem(" ", LTNULL, LTNULL, pos, LTTRUE); AddTextItem(IDS_CREATE, CMD_CREATE, IDS_HELP_PROFILE_CREATE); AddTextItem(IDS_LOAD, CMD_LOAD, IDS_HELP_PROFILE_LOAD); //jrg - 8/18/02 removed as a quick and dirty to multiple issues caused by renaming profiles. // m_pRename = AddTextItem(IDS_RENAME, CMD_RENAME, IDS_HELP_PROFILE_RENAME); m_pDelete = AddTextItem(IDS_DELETE, CMD_DELETE, IDS_HELP_PROFILE_DELETE); LTIntPt dlgPos = g_pLayoutMgr->GetScreenCustomPoint((eScreenID)m_nScreenID,"DialogPos"); LTIntPt dlgSz = g_pLayoutMgr->GetScreenCustomPoint((eScreenID)m_nScreenID,"DialogSize"); kDlgHt = dlgSz.y; kDlgWd = dlgSz.x; uint8 nDlgFont = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"DialogFontFace"); uint8 nDlgFontSz = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"DialogFontSize"); nListFont = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"ListFontFace"); nListFontSz = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"ListFontSize"); char szBack[128] = ""; g_pLayoutMgr->GetScreenCustomString((eScreenID)m_nScreenID,"DialogFrame",szBack,sizeof(szBack)); m_pDlg = debug_new(CLTGUIWindow); m_pDlg->Create(g_pInterfaceResMgr->GetTexture(szBack),kDlgHt,kDlgWd); LTIntPt tmp(8,8); CUIFont *pFont = g_pInterfaceResMgr->GetFont(nDlgFont); CLTGUITextCtrl *pCtrl = CreateTextItem(IDS_PROFILE_LIST, LTNULL, LTNULL, kDefaultPos, LTTRUE); pCtrl->SetFont(pFont,nDlgFontSz); m_pDlg->AddControl(pCtrl, tmp); tmp.y += 24; // Make a list controller m_pListCtrl = debug_new(CLTGUIListCtrl); if (m_pListCtrl->Create(kDlgHt-64)) { HTEXTURE hUp = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowup.dtx"); HTEXTURE hUpH = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowup_h.dtx"); HTEXTURE hDown = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowdn.dtx"); HTEXTURE hDownH = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowdn_h.dtx"); m_pListCtrl->UseArrows(kDlgWd-48,1.0f,hUp,hUpH,hDown,hDownH); m_pListCtrl->SetIndent(LTIntPt(4,4)); m_pListCtrl->SetFrameWidth(2); m_pListCtrl->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor); m_pDlg->AddControl(m_pListCtrl, tmp); } pCtrl = CreateTextItem(IDS_CANCEL, CMD_CANCEL, LTNULL); pCtrl->SetFont(pFont,nDlgFontSz); tmp.x = (kDlgWd - pCtrl->GetBaseWidth()) / 2; tmp.y = (kDlgHt - pCtrl->GetBaseHeight()) - 8; m_pDlg->AddControl(pCtrl, tmp); AddControl(m_pDlg); m_pDlg->SetBasePos(dlgPos); m_pDlg->SetScale(g_pInterfaceResMgr->GetXRatio()); m_pDlg->Show(LTFALSE); m_pDlg->SetSelection(1); UseBack(LTTRUE); // Make sure to call the base class return CBaseScreen::Build(); }
// Build the screen bool CScreenProfile::Build() { // Set the title's text CreateTitle("IDS_TITLE_PROFILE"); CLTGUICtrl_create cs; cs.rnBaseRect.m_vMin.Init(); cs.rnBaseRect.m_vMax = LTVector2n(m_ScreenRect.GetWidth(),g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenFontSize)); m_pCurrent = AddTextItem(L" ", cs, true); cs.nCommandID = CMD_CREATE; cs.szHelpID = "IDS_HELP_PROFILE_CREATE"; AddTextItem("IDS_CREATE", cs ); cs.nCommandID = CMD_LOAD; cs.szHelpID = "IDS_HELP_PROFILE_LOAD"; AddTextItem("IDS_LOAD", cs); cs.nCommandID = CMD_DELETE; cs.szHelpID = "IDS_HELP_PROFILE_DELETE"; m_pDelete = AddTextItem("IDS_DELETE", cs); LTRect2n dlgRect = g_pLayoutDB->GetRect(m_hLayout,LDB_ScreenDialogRect); std::string sDlgFont = g_pLayoutDB->GetFont(m_hLayout,LDB_ScreenDialogFont); uint8 nDlgFontSz = ( uint8 )g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenDialogSize); sListFont = g_pLayoutDB->GetListFont(m_hLayout,0); nListFontSz = g_pLayoutDB->GetListSize(m_hLayout,0); CLTGUICtrl_create dcs; dcs.rnBaseRect = dlgRect; m_pDlg = debug_new(CLTGUIWindow); m_pDlg->Create(TextureReference(g_pLayoutDB->GetString(m_hLayout,LDB_ScreenDialogFrame)),dcs); LTVector2n tmp(8,8); cs.nCommandID = NULL; cs.szHelpID = ""; CLTGUITextCtrl *pCtrl = CreateTextItem("IDS_PROFILE_LIST", cs, true, sDlgFont.c_str(), nDlgFontSz); m_pDlg->AddControl(pCtrl, tmp); tmp.y += 24; CLTGUIListCtrl_create listCs; listCs.rnBaseRect.m_vMin.Init(); listCs.rnBaseRect.Right() = kDlgWd - 48; listCs.rnBaseRect.Bottom() = kDlgWd - 64; listCs.bArrows = true; listCs.vnArrowSz = g_pLayoutDB->GetListArrowSize(m_hLayout,0); m_pListCtrl = CreateList(listCs); if (m_pListCtrl) { m_pListCtrl->SetIndent(g_pLayoutDB->GetListIndent(m_hLayout,0)); TextureReference hFrame(g_pLayoutDB->GetListFrameTexture(m_hLayout,0,0)); TextureReference hSelFrame(g_pLayoutDB->GetListFrameTexture(m_hLayout,0,1)); m_pListCtrl->SetFrame(hFrame,hSelFrame,g_pLayoutDB->GetListFrameExpand(m_hLayout,0)); m_pListCtrl->Show(true); m_pDlg->AddControl(m_pListCtrl, tmp); } cs.nCommandID = CMD_CANCEL; cs.szHelpID = ""; cs.rnBaseRect.Bottom() = nDlgFontSz; cs.rnBaseRect.Right() = kDlgWd / 2; pCtrl = CreateTextItem("IDS_CANCEL", cs, false, sDlgFont.c_str(), nDlgFontSz); pCtrl->SetAlignment(kCenter); tmp.x = kDlgWd / 2; tmp.y = (kDlgHt - nDlgFontSz) - 8; m_pDlg->AddControl(pCtrl, tmp); AddControl(m_pDlg); m_pDlg->Show(false); m_pDlg->SetSelection(1); UseBack(true); // Make sure to call the base class return CBaseScreen::Build(); }
void MainScreen::SafeAddControl(UIControl *control) { if(!control->GetParent()) AddControl(control); }
ModificationsPanel::ModificationsPanel(ModificationsPanelDelegate *newDelegate, const Rect &rect, bool rectInAbsoluteCoordinates) : UIControl(rect, rectInAbsoluteCoordinates) , delegate(newDelegate) , workingScene(NULL) { SetInputEnabled(false, false); modState = MOD_MOVE; modAxis = AXIS_X; modificationPanel = ControlsFactory::CreatePanelControl(Rect(0.f, 5.f, 160.f, 45.f)); modificationPanel->GetBackground()->SetColor(Color(1.0f, 1.0f, 1.0f, 0.2f)); for (int32 i = 0; i < 3; ++i) { btnMod[i] = ControlsFactory::CreateButton(Rect((float32)(BUTTON_W + BUTTON_B) * i, 0.f, (float32)BUTTON_W, (float32)BUTTON_W), mods[i]); btnMod[i]->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ModificationsPanel::OnModificationPressed)); modificationPanel->AddControl(btnMod[i]); btnAxis[i] = ControlsFactory::CreateButton(Rect((float32)(BUTTON_W + BUTTON_B) * i, (float32)(BUTTON_W + BUTTON_B), (float32)BUTTON_W, (float32)BUTTON_W), axises[i]); btnAxis[i]->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ModificationsPanel::OnModificationPressed)); modificationPanel->AddControl(btnAxis[i]); } UIStaticText * st = new UIStaticText(Rect(55.f, 0, 70.f, (float32)BUTTON_W)); st->SetFont(ControlsFactory::GetFont12()); st->SetTextColor(ControlsFactory::GetColorLight()); st->SetText(L"w, e, r"); modificationPanel->AddControl(st); st = new UIStaticText(Rect(55.f, (float32)(BUTTON_W + BUTTON_B), 80.f, (float32)BUTTON_W)); st->SetFont(ControlsFactory::GetFont12()); st->SetTextColor(ControlsFactory::GetColorLight()); st->SetText(L"5, 6, 7, 8"); modificationPanel->AddControl(st); btnPlaceOn = ControlsFactory::CreateButton(Rect(115.f, 0, (float32)BUTTON_W, (float32)BUTTON_W), L"P"); btnPlaceOn->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ModificationsPanel::OnModificationPressed)); modificationPanel->AddControl(btnPlaceOn); btnLandscape = ControlsFactory::CreateButton(Rect(115, BUTTON_W + BUTTON_B, BUTTON_W, BUTTON_W), L"L"); btnLandscape->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ModificationsPanel::OnLandscapeRelative)); modificationPanel->AddControl(btnLandscape); btnPopUp = ControlsFactory::CreateButton(Rect(140.f, 0, (float32)BUTTON_W, (float32)BUTTON_W), L"#"); btnPopUp->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ModificationsPanel::OnModificationPopUpPressed)); modificationPanel->AddControl(btnPopUp); modificationPopUp = new ModificationPopUp(); btnModeSelection = ControlsFactory::CreateButton(Rect(170.f, 5.f, (float32)BUTTON_W, (float32)BUTTON_W), L"S"); btnModeSelection->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ModificationsPanel::OnModePressed)); AddControl(btnModeSelection); btnModeModification = ControlsFactory::CreateButton(Rect(195.f, 5.f, (float32)BUTTON_W, (float32)BUTTON_W), L"M"); btnModeModification->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ModificationsPanel::OnModePressed)); AddControl(btnModeModification); btnModeCollision = new ComboBox(Rect(220.f, 5.f, 80.0f, (float32)BUTTON_W), this, EditorConfig::Instance()->GetComboPropertyValues("CollisionType")); btnModeCollision->SetMaxVisibleItemsCount(20); AddControl(btnModeCollision); isLandscapeRelative = false; modeCollision = 0; UpdateModState(); OnModePressed(btnModeSelection, 0, 0); }
void CWndLayout::AddControlByIdM(int nId, DWORD dwLayout, int nLeft, int nTop, int nRight, int nBottom) { HWND hWnd = ::GetDlgItem(m_hWndParent, nId); RECT rcMargin = {nLeft, nTop, nRight, nBottom}; AddControl(hWnd, dwLayout, rcMargin); }
LodDistanceControl::LodDistanceControl(LodDistanceControlDelegate *newDelegate, const Rect &rect, bool rectInAbsoluteCoordinates) : UIControl(rect, rectInAbsoluteCoordinates) { count = 0; maxDistance = 0; zones = NULL; sliders = NULL; delegate = newDelegate; mainTouch = -1; oldPos = newPos = 0.f; activeSlider = NULL; leftZone = NULL; rightZone = NULL; activeLodIndex = -1; for(int32 iDist = 0; iDist < LodComponent::MAX_LOD_LAYERS; ++iDist) { distanceText[iDist] = new UIStaticText(Rect(0, (float32)((iDist+1) * ControlsFactory::BUTTON_HEIGHT), rect.dx / 2.f, (float32)ControlsFactory::BUTTON_HEIGHT)); distanceText[iDist]->SetAlign(ALIGN_LEFT | ALIGN_VCENTER); distanceText[iDist]->SetFont(ControlsFactory::GetFont12()); distanceText[iDist]->SetTextColor(ControlsFactory::GetColorLight()); distanceTextValues[iDist] = new UITextField(Rect(rect.dx / 2.f, (float32)((iDist+1) * ControlsFactory::BUTTON_HEIGHT), rect.dx / 2.f, (float32)(ControlsFactory::BUTTON_HEIGHT))); ControlsFactory::CustomizeEditablePropertyCell(distanceTextValues[iDist]); distanceTextValues[iDist]->SetFont(ControlsFactory::GetFont12()); distanceTextValues[iDist]->SetTextColor(ControlsFactory::GetColorLight()); distanceTextValues[iDist]->SetDelegate(this); distanceTextValues[iDist]->SetInputEnabled((0 != iDist), false); trianglesText[iDist] = new UIStaticText(Rect(0, 0, rect.dx / 2.f, (float32)ControlsFactory::BUTTON_HEIGHT)); trianglesText[iDist]->SetAlign(ALIGN_LEFT | ALIGN_VCENTER); trianglesText[iDist]->SetFont(ControlsFactory::GetFont12()); trianglesText[iDist]->SetTextColor(ControlsFactory::GetColorLight()); trianglesTextValues[iDist] = new UIStaticText(Rect(rect.dx / 2.f, 0, rect.dx / 2.f, (float32)ControlsFactory::BUTTON_HEIGHT)); trianglesTextValues[iDist]->SetAlign(ALIGN_LEFT | ALIGN_VCENTER); trianglesTextValues[iDist]->SetFont(ControlsFactory::GetFont12()); trianglesTextValues[iDist]->SetTextColor(ControlsFactory::GetColorLight()); } distanceToCameraText = new UIStaticText(Rect(0, 0, rect.dx / 2.f, (float32)ControlsFactory::BUTTON_HEIGHT)); distanceToCameraText->SetAlign(ALIGN_LEFT | ALIGN_VCENTER); distanceToCameraText->SetFont(ControlsFactory::GetFont12()); distanceToCameraText->SetTextColor(ControlsFactory::GetColorLight()); distanceToCameraText->SetText(WideString(L"From Camera:")); AddControl(distanceToCameraText); distanceToCameraValue = new UIStaticText(Rect(rect.dx / 2.f, 0, rect.dx / 2.f, (float32)ControlsFactory::BUTTON_HEIGHT)); distanceToCameraValue->SetAlign(ALIGN_LEFT | ALIGN_VCENTER); distanceToCameraValue->SetFont(ControlsFactory::GetFont12()); distanceToCameraValue->SetTextColor(ControlsFactory::GetColorLight()); AddControl(distanceToCameraValue); }
// Build the screen LTBOOL CScreenDisplay::Build() { CreateTitle(IDS_TITLE_DISPLAYOPTIONS); kGap = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_DISPLAY,"ColumnWidth"); kWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_DISPLAY,"SliderWidth"); //background frame LTRect frameRect = g_pLayoutMgr->GetScreenCustomRect(SCREEN_ID_DISPLAY,"FrameRect"); LTIntPt pos(frameRect.left,frameRect.top); int nHt = frameRect.bottom - frameRect.top; int nWd = frameRect.right - frameRect.left; char szFrame[128]; g_pLayoutMgr->GetScreenCustomString(SCREEN_ID_DISPLAY,"FrameTexture",szFrame,sizeof(szFrame)); HTEXTURE hFrame = g_pInterfaceResMgr->GetTexture(szFrame); CLTGUIFrame *pFrame = debug_new(CLTGUIFrame); pFrame->Create(hFrame,nWd,nHt+8,LTTRUE); pFrame->SetBasePos(pos); pFrame->SetBorder(2,m_SelectedColor); AddControl(pFrame); // Build the array of renderers GetRendererData(); // Add the "resolution" control m_pResolutionCtrl = AddCycle(IDS_DISPLAY_RESOLUTION,IDS_HELP_RESOLUTION,kGap); // Setup the resolution control based on the current renderer SetupResolutionCtrl(); m_pHardwareCursor = AddToggle(IDS_HARDWARE_CURSOR,IDS_HELP_HARDWARE_CURSOR,kGap,&m_bHardwareCursor); AddToggle(IDS_VSYNC,IDS_HELP_VSYNC,kGap,&m_bVSync); m_pGamma = AddSlider(IDS_GAMMA,IDS_HELP_GAMMA,kGap,kWidth,-1,&m_nGamma); m_pGamma->SetSliderRange(0,kNumSteps); m_pGamma->SetSliderIncrement(1); int nBaseGamma = ConvertToSlider(1.0f); float xoffset = (m_pGamma->CalculateSliderOffset(nBaseGamma) / m_pGamma->GetScale()); uint16 nHeight = m_pGamma->GetBarHeight(); float yoffset = ((( (float)m_pGamma->GetBaseHeight()) - (float)nHeight)) / 2.0f; pos = m_pGamma->GetBasePos(); pos.x += (int)(xoffset - 1.0f); pos.y += (int)(yoffset + 0.5f); CLTGUIFrame *pBar = debug_new(CLTGUIFrame); pBar->Create(0xBF000000,3,nHeight+1); pBar->SetBasePos(pos); pBar->SetScale(g_pInterfaceResMgr->GetXRatio()); AddControl(pBar); // Make sure to call the base class if (!CBaseScreen::Build()) return LTFALSE; UseBack(LTTRUE,LTTRUE); return LTTRUE; }
void LodDistanceControl::SetDistances(float32 *newDistances, int32 *newTriangles, int32 newCount) { Vector2 newSize = GetSize(); newSize.y = GetControlHeightForLodCount(newCount); SetSize(newSize); ReleaseControls(); if(1 < newCount) { count = newCount; Memcpy(distances, newDistances, count * sizeof(float32)); Memcpy(triangles, newTriangles, count * sizeof(int32)); zones = new UIControl*[count]; maxDistance = (distances[count - 1] < LodComponent::MAX_LOD_DISTANCE) ? LodComponent::MAX_LOD_DISTANCE : (LodComponent::MAX_LOD_DISTANCE * 1.1f); Rect fullRect = GetRect(); Color initialColor(0.8f, 0.5f, 0.1f, 1.0f); for(int32 iZone = 0; iZone < count; ++iZone) { float32 x = (iZone) ? distances[iZone] : 0.f; float32 dx = (iZone != count - 1) ? (distances[iZone + 1] - x) : (maxDistance - distances[iZone]); x = x * fullRect.dx / maxDistance; dx = dx * fullRect.dx / maxDistance; zones[iZone] = new UIControl(Rect(x, 0, dx, ControlsFactory::BUTTON_HEIGHT)); zones[iZone]->SetInputEnabled(false, false); zones[iZone]->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); float32 color = distances[iZone] / maxDistance; Color zoneColor; zoneColor.r = initialColor.r + color; zoneColor.g = initialColor.g + color; zoneColor.b = initialColor.b + color; zoneColor.a = 1.0f; if(1.0f < zoneColor.r) zoneColor.r -= (int32)zoneColor.r; if(1.0f < zoneColor.g) zoneColor.g -= (int32)zoneColor.g; if(1.0f < zoneColor.b) zoneColor.b -= (int32)zoneColor.b; zones[iZone]->GetBackground()->SetColor(zoneColor); AddControl(zones[iZone]); } sliders = new UIControl*[count - 1]; for(int32 iSlider = 0; iSlider < count - 1; ++iSlider) { float32 x = distances[iSlider + 1] / maxDistance * fullRect.dx; sliders[iSlider] = new UIControl(Rect(x - 1, 0, 3, ControlsFactory::BUTTON_HEIGHT)); sliders[iSlider]->SetInputEnabled(false, false); sliders[iSlider]->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); sliders[iSlider]->GetBackground()->SetColor(Color(1.0f, 0.0f, 0.0f, 1.0f)); AddControl(sliders[iSlider]); } } float32 x = GetRect().dx / 2.f; for(int32 iDist = 0; iDist < LodComponent::MAX_LOD_LAYERS; ++iDist) { RemoveControl(distanceText[iDist]); RemoveControl(distanceTextValues[iDist]); RemoveControl(trianglesText[iDist]); RemoveControl(trianglesTextValues[iDist]); if(iDist < count) { AddControl(distanceText[iDist]); distanceText[iDist]->SetText(Format(L"Distance_%d:", iDist)); AddControl(distanceTextValues[iDist]); distanceTextValues[iDist]->SetText(Format(L"%.0f", distances[iDist])); float32 y = (float32)(count + iDist + 1) * (float32)ControlsFactory::BUTTON_HEIGHT; trianglesText[iDist]->SetPosition(Vector2(0, y)); AddControl(trianglesText[iDist]); trianglesText[iDist]->SetText(Format(L"Triangles_%d:", iDist)); trianglesTextValues[iDist]->SetPosition(Vector2(x, y)); AddControl(trianglesTextValues[iDist]); trianglesTextValues[iDist]->SetText(Format(L"%d", triangles[iDist])); } } float32 distanceToCameraY = (count * 2.f + 1.f) * (float32)ControlsFactory::BUTTON_HEIGHT; distanceToCameraText->SetPosition(Vector2(0, distanceToCameraY)); distanceToCameraValue->SetPosition(Vector2(x, distanceToCameraY)); }
void CreateNodesDialog::CreateNode(ResourceEditor::eNodeType nodeType) { SafeRelease(sceneNode); SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive(); EditorScene * editorScene = activeScene->GetScene(); scene = editorScene; switch (nodeType) { case ResourceEditor::NODE_LANDSCAPE: SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_LANDSCAPE)); sceneNode = new Entity(); sceneNode->AddComponent(ScopedPtr<RenderComponent> (new RenderComponent(ScopedPtr<Landscape>(new Landscape())))); sceneNode->SetName(ResourceEditor::LANDSCAPE_NODE_NAME); break; case ResourceEditor::NODE_LIGHT: { SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_LIGHT)); //sceneNode = //EditorLightNode::CreateSceneAndEditorLight(); sceneNode = new Entity(); sceneNode->AddComponent(ScopedPtr<LightComponent> (new LightComponent(ScopedPtr<Light>(new Light)))); sceneNode->SetName(ResourceEditor::LIGHT_NODE_NAME); break; } case ResourceEditor::NODE_SERVICE_NODE: { SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_SERVICE)); sceneNode = new Entity(); KeyedArchive *customProperties = sceneNode->GetCustomProperties(); customProperties->SetBool(ResourceEditor::EDITOR_IS_LOCKED, true); sceneNode->SetName(ResourceEditor::SERVICE_NODE_NAME); break; } case ResourceEditor::NODE_CAMERA: { SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_CAMERA)); sceneNode = new Entity(); Camera * camera = new Camera(); camera->SetUp(Vector3(0.0f, 0.0f, 1.0f)); sceneNode->AddComponent(ScopedPtr<CameraComponent> (new CameraComponent(camera))); sceneNode->SetName(ResourceEditor::CAMERA_NODE_NAME); SafeRelease(camera); }break; case ResourceEditor::NODE_IMPOSTER: SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_IMPOSTER)); sceneNode = new ImposterNode(); sceneNode->SetName(ResourceEditor::IMPOSTER_NODE_NAME); break; case ResourceEditor::NODE_PARTICLE_EMITTER: { SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_PARTICLE_EMITTER)); sceneNode = new Entity(); sceneNode->SetName(ResourceEditor::PARTICLE_EMITTER_NODE_NAME); ParticleEmitter3D* newEmitter = new ParticleEmitter3D(); RenderComponent * renderComponent = new RenderComponent(); renderComponent->SetRenderObject(newEmitter); sceneNode->AddComponent(renderComponent); newEmitter->Release(); renderComponent->Release(); break; } case ResourceEditor::NODE_USER_NODE: { SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_USER)); sceneNode = new Entity(); sceneNode->SetName(ResourceEditor::USER_NODE_NAME); sceneNode->AddComponent(ScopedPtr<UserComponent> (new UserComponent())); break; } case ResourceEditor::NODE_SWITCH_NODE: { SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_SWITCH)); sceneNode = new Entity(); sceneNode->SetName(ResourceEditor::SWITCH_NODE_NAME); sceneNode->AddComponent(ScopedPtr<SwitchComponent> (new SwitchComponent())); KeyedArchive *customProperties = sceneNode->GetCustomProperties(); customProperties->SetBool(Entity::SCENE_NODE_IS_SOLID_PROPERTY_NAME, false); } break; case ResourceEditor::NODE_PARTICLE_EFFECT: { SetHeader(ResourceEditor::CREATE_NODE_PARTICLE_EFFECT); sceneNode = new Entity(); sceneNode->AddComponent(ScopedPtr<ParticleEffectComponent> (new ParticleEffectComponent())); sceneNode->SetName(ResourceEditor::PARTICLE_EFFECT_NODE_NAME); break; } case ResourceEditor::NODE_SKYBOX: { SetHeader(L"SkyBox"); //TODO: add skybox creation code here break; } default: break; } propertyList = PropertyControlCreator::Instance()->CreateControlForNode(sceneNode, propertyRect, true); SafeRetain(propertyList); AddControl(propertyList); SetScene(editorScene); propertyList->ReadFrom(sceneNode); }
void CMainDlg::OnPaint() { if (!bInit) { AddControl(IDC_IMAGE_CONTROL, CST_RESIZE, CST_RESIZE, CST_RESIZE, CST_RESIZE); AddControl(IDC_TAB_CONTROL, CST_NONE, CST_NONE, CST_RESIZE, CST_RESIZE); AddControl(IDC_STARTOVER, CST_NONE, CST_NONE, CST_REPOS, CST_REPOS); AddControl(IDC_UNDO, CST_NONE, CST_NONE, CST_REPOS, CST_REPOS); AddControl(IDC_REDO, CST_NONE, CST_NONE, CST_REPOS, CST_REPOS); AddControl(IDC_ZOOMIN, CST_NONE, CST_NONE, CST_REPOS, CST_REPOS); AddControl(IDC_ZOOMOUT, CST_NONE, CST_NONE, CST_REPOS, CST_REPOS); AddControl(IDC_ZOOMFULL, CST_NONE, CST_NONE, CST_REPOS, CST_REPOS); AddControl(IDC_UPDATE, CST_REPOS, CST_REPOS, CST_REPOS, CST_REPOS); AddControl(IDOK, CST_REPOS, CST_REPOS, CST_REPOS, CST_REPOS); AddControl(IDCANCEL, CST_REPOS, CST_REPOS, CST_REPOS, CST_REPOS); bInit = true; } CResizeDlg::OnPaint(); }
uint16 CBaseMenu::AddControl (int stringID, uint32 commandID, LTBOOL bStatic) { return AddControl(LoadTempString(stringID),commandID,bStatic); }
// Build the screen LTBOOL CScreenConfigure::Build() { CreateTitle(IDS_TITLE_CONFIGURE); m_nActionWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"ActionWidth"); m_nEqualsWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"EqualsWidth"); m_nCommandWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"CommandWidth"); m_ListRect = g_pLayoutMgr->GetScreenCustomRect(SCREEN_ID_CONFIGURE,"ListRect"); m_nListFontSize = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"ListFontSize"); int nWidth = GetPageRight() - GetPageLeft(); LTIntPt topPos = g_pLayoutMgr->GetScreenCustomPoint(SCREEN_ID_CONFIGURE,"MoveControlPos"); CLTGUITextCtrl *pCtrl = AddTextItem(IDS_MOVE_CONTROLS,CMD_MOVE_COM,LTNULL,topPos); pCtrl->SetFixedWidth(nWidth); pCtrl = AddTextItem(IDS_INV_CONTROLS,CMD_INV_COM,LTNULL); pCtrl->SetFixedWidth(nWidth); pCtrl = AddTextItem(IDS_VIEW_CONTROLS,CMD_VIEW_COM,LTNULL); pCtrl->SetFixedWidth(nWidth); pCtrl = AddTextItem(IDS_MISC_CONTROLS,CMD_MISC_COM,LTNULL); pCtrl->SetFixedWidth(nWidth); LTIntPt pos(m_ListRect.left,m_ListRect.top); int nHt = m_ListRect.bottom - m_ListRect.top; int nWd = m_nActionWidth + m_nEqualsWidth + m_nCommandWidth; char szFrame[128]; g_pLayoutMgr->GetScreenCustomString(SCREEN_ID_CONFIGURE,"FrameTexture",szFrame,sizeof(szFrame)); HTEXTURE hFrame = g_pInterfaceResMgr->GetTexture(szFrame); m_pFrame = debug_new(CLTGUIFrame); m_pFrame->Create(hFrame,nWd,nHt+8,LTTRUE); m_pFrame->SetBasePos(pos); AddControl(m_pFrame); for (int nType = 0; nType < kNumCommandTypes; nType++) { m_pList[nType] = AddList(pos,nHt); m_pList[nType]->SetFrameWidth(2); m_pList[nType]->SetIndent(LTIntPt(4,4)); m_pList[nType]->Show(LTFALSE); pCtrl = LTNULL; switch (nType) { case COM_MOVE: pCtrl = CreateTextItem(IDS_MOVE_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE); break; case COM_INV: pCtrl = CreateTextItem(IDS_INV_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE); break; case COM_VIEW: pCtrl = CreateTextItem(IDS_VIEW_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE); break; case COM_MISC: pCtrl = CreateTextItem(IDS_MISC_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE); break; } if (pCtrl) m_pList[nType]->AddControl(pCtrl); } InitControlList(); // Make sure to call the base class if (! CBaseScreen::Build()) return LTFALSE; UseBack(LTTRUE,LTTRUE); return LTTRUE; }
// Build the screen bool CScreenHostLevels::Build() { LTRect2n rcAvailRect = g_pLayoutDB->GetListRect(m_hLayout,0); LTRect2n rcSelRect = g_pLayoutDB->GetListRect(m_hLayout,1); uint32 nOffset = g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenFontSize) + 4; LTVector2n addPos = rcAvailRect.GetTopLeft(); addPos.y -= nOffset; LTVector2n removePos = rcSelRect.GetTopLeft(); removePos.y -= nOffset; LTVector2n commandPos = rcAvailRect.GetTopRight(); commandPos.x += nOffset; commandPos.x += g_pLayoutDB->GetScrollBarSize(); int32 nCommandWidth = rcSelRect.Left() - commandPos.x; nListFontSize = g_pLayoutDB->GetListSize(m_hLayout,0); CreateTitle("IDS_TITLE_HOST_MISSIONS"); //background frame CLTGUICtrl_create frameCs; TextureReference hFrame(g_pLayoutDB->GetString(m_hLayout,LDB_ScreenFrameTexture)); frameCs.rnBaseRect = g_pLayoutDB->GetRect(m_hLayout,LDB_ScreenFrameRect); CLTGUIFrame *pFrame = debug_new(CLTGUIFrame); pFrame->Create(hFrame, frameCs); AddControl(pFrame); CLTGUICtrl_create cs; cs.rnBaseRect.m_vMin.Init(); cs.rnBaseRect.m_vMax = LTVector2n(nCommandWidth,g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenFontSize)); cs.nCommandID = CMD_ADD_LEVEL; cs.szHelpID = "IDS_HELP_ADD_MISSION"; m_pAdd = AddTextItem("IDS_HOST_ADD_MISSION", cs, true); m_pAdd->SetBasePos(addPos); m_DefaultPos = commandPos; cs.nCommandID = CMD_ADD_ALL; cs.szHelpID = "IDS_HELP_ADD_ALL_LEVELS"; m_pAddAll = AddTextItem("IDS_HOST_ADD_ALL_LEVELS", cs); cs.nCommandID = CMD_REMOVE_ALL; cs.szHelpID = "IDS_HELP_REM_ALL_LEVELS"; m_pRemoveAll = AddTextItem("IDS_HOST_REMOVE_ALL_LEVELS", cs); cs.nCommandID = CMD_REMOVE_LEVEL; cs.szHelpID = "IDS_HELP_REM_MISSION"; m_pRemove = AddTextItem("IDS_HOST_REMOVE_MISSION", cs, true); m_pRemove->SetBasePos(removePos); { CLTGUIScrollBar_create csb; csb.rnBaseRect = g_pLayoutDB->GetListRect(m_hLayout,0); csb.rnBaseRect.Right() += g_pLayoutDB->GetScrollBarSize(); csb.rnBaseRect.Left() = csb.rnBaseRect.Right() - g_pLayoutDB->GetScrollBarSize(); m_pAvailMissionsScrollBar = CreateScrollBar( csb ); if( m_pAvailMissionsScrollBar ) { m_pAvailMissionsScrollBar->SetFrameWidth( 1 ); m_pAvailMissionsScrollBar->Enable( true ); m_pAvailMissionsScrollBar->Show( true ); } } { CLTGUIScrollBar_create csb; csb.rnBaseRect = g_pLayoutDB->GetListRect(m_hLayout,1); csb.rnBaseRect.Right() += g_pLayoutDB->GetScrollBarSize(); csb.rnBaseRect.Left() = csb.rnBaseRect.Right() - g_pLayoutDB->GetScrollBarSize(); m_pSelMissionsScrollBar = CreateScrollBar( csb ); if( m_pSelMissionsScrollBar ) { m_pSelMissionsScrollBar->SetFrameWidth( 1 ); m_pSelMissionsScrollBar->Enable( true ); m_pSelMissionsScrollBar->Show( true ); } } // int32 nListHeight = rcAvailRect.GetHeight(); nAvailWidth = rcAvailRect.GetWidth(); CLTGUIListCtrlEx_create listCs; listCs.rnBaseRect = rcAvailRect; listCs.nTextIdent = g_pLayoutDB->GetListIndent(m_hLayout,0).x; listCs.pScrollBar = m_pAvailMissionsScrollBar; m_pAvailMissions = AddListEx(listCs); m_pAvailMissions->SetFrameWidth( 1 ); m_pAvailMissions->SetIndent(g_pLayoutDB->GetListIndent(m_hLayout,0)); hFrame.Load(g_pLayoutDB->GetListFrameTexture(m_hLayout,0,0)); TextureReference hSelFrame(g_pLayoutDB->GetListFrameTexture(m_hLayout,0,1)); m_pAvailMissions->SetFrame(hFrame,hSelFrame,g_pLayoutDB->GetListFrameExpand(m_hLayout,0)); if( m_pAvailMissionsScrollBar ) AddControl( m_pAvailMissionsScrollBar ); nSelWidth = rcSelRect.GetWidth(); listCs.rnBaseRect = rcSelRect; listCs.pScrollBar = m_pSelMissionsScrollBar; m_pSelMissions = AddListEx(listCs); m_pSelMissions->SetFrameWidth( 1 ); m_pSelMissions->SetIndent(g_pLayoutDB->GetListIndent(m_hLayout,1)); hFrame.Load(g_pLayoutDB->GetListFrameTexture(m_hLayout,1,0)); hSelFrame.Load(g_pLayoutDB->GetListFrameTexture(m_hLayout,1,1)); m_pSelMissions->SetFrame(hFrame,hSelFrame,g_pLayoutDB->GetListFrameExpand(m_hLayout,1)); if( m_pSelMissionsScrollBar ) AddControl( m_pSelMissionsScrollBar ); // Make sure to call the base class if (!CBaseScreen::Build()) return false; UseBack(true,true); return true; }
MaterialEditor::MaterialEditor() : DraggableDialog(Rect(GetScreenWidth()/8, GetScreenHeight()/8, GetScreenWidth()/4*3, GetScreenHeight()/4*3)) {//todo: create draggable dealog ControlsFactory::CustomizeDialog(this); displayMode = EDM_ALL; workingMaterial = NULL; workingSceneNode = NULL; workingScene = NULL; float32 materialListWidth = size.x * materialListPart; btnAll = ControlsFactory::CreateButton(Rect(0, ControlsFactory::BUTTON_HEIGHT, materialListWidth/2, ControlsFactory::BUTTON_HEIGHT), LocalizedString(L"materialeditor.all")); btnAll->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MaterialEditor::OnAllPressed)); btnSelected = ControlsFactory::CreateButton(Rect(materialListWidth/2, ControlsFactory::BUTTON_HEIGHT, materialListWidth/2, ControlsFactory::BUTTON_HEIGHT), LocalizedString(L"materialeditor.selected")); btnSelected->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MaterialEditor::OnSelectedPressed)); Rect setupFogRect(GetRect().dx - ControlsFactory::BUTTON_WIDTH, ControlsFactory::BUTTON_HEIGHT, ControlsFactory::BUTTON_WIDTH, ControlsFactory::BUTTON_HEIGHT); btnSetupFog = ControlsFactory::CreateButton(setupFogRect, LocalizedString(L"materialeditor.setupfog")); btnSetupFog->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MaterialEditor::OnSetupFog)); AddControl(btnSetupFog); Rect setupColorRect(setupFogRect); setupColorRect.x -= ControlsFactory::BUTTON_WIDTH; btnSetupColor = ControlsFactory::CreateButton(setupColorRect, L"Setup Color"); btnSetupColor->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MaterialEditor::OnSetupColor)); AddControl(btnSetupColor); line = ControlsFactory::CreateLine(Rect(GetRect().dx - ControlsFactory::BUTTON_WIDTH*3, ControlsFactory::BUTTON_HEIGHT * 2, ControlsFactory::BUTTON_WIDTH*3, 1), Color::White()); AddControl(line); Rect fogRect(setupFogRect.x - ControlsFactory::BUTTON_WIDTH, setupFogRect.dy + setupFogRect.y, ControlsFactory::BUTTON_WIDTH * 2, ControlsFactory::BUTTON_HEIGHT * 5); fogControl = new FogControl(fogRect, this); Rect colorRect(setupColorRect.x - ControlsFactory::BUTTON_WIDTH, setupColorRect.dy + setupColorRect.y, ControlsFactory::BUTTON_WIDTH * 3, ControlsFactory::BUTTON_HEIGHT * 5); colorControl = new ColorControl(colorRect, this); materialsList = new UIList(Rect(0, ControlsFactory::BUTTON_HEIGHT * 2, materialListWidth, size.y - ControlsFactory::BUTTON_HEIGHT * 2), UIList::ORIENTATION_VERTICAL); materialsList->SetDelegate(this); ControlsFactory::SetScrollbar(materialsList); ControlsFactory::CusomizeListControl(materialsList); AddControl(materialsList); UIStaticText *text = new UIStaticText(Rect(0, 0, size.x * materialListPart, ControlsFactory::BUTTON_HEIGHT)); text->SetFont(ControlsFactory::GetFont12()); text->SetText(LocalizedString(L"materialeditor.materials")); text->SetTextColor(ControlsFactory::GetColorLight()); AddControl(text); SafeRelease(text); float32 textY = (GetRect().dy - ControlsFactory::BUTTON_HEIGHT ) / 2.f; noMaterials = new UIStaticText(Rect(materialListWidth, textY, GetRect().dx - materialListWidth, (float32)ControlsFactory::BUTTON_HEIGHT)); noMaterials->SetFont(ControlsFactory::GetFont12()); noMaterials->SetTextColor(ControlsFactory::GetColorLight()); noMaterials->SetText(LocalizedString(L"materialeditor.nomaterials")); selectedMaterial = -1; lastSelection = NULL; Vector<String> v; for (int i = 0; i < Material::MATERIAL_TYPES_COUNT; i++) { v.push_back(Material::GetTypeName((Material::eType)i)); } materialProps = new MaterialPropertyControl(Rect(size.x * materialListPart, size.y * previewHeightPart, size.x - size.x * materialListPart, size.y - size.y * previewHeightPart), false); materialProps->SetDelegate(this); AddControl(materialProps); }
// Build the screen LTBOOL CScreenMulti::Build() { CreateTitle(IDS_TITLE_MULTI); //basic controls AddTextItem(IDS_PLAYER_SETUP, CMD_PLAYER, IDS_HELP_PLAYER); m_pCDKeyCtrl = AddColumnCtrl(CMD_EDIT_CDKEY, IDS_HELP_CDKEY); m_pCDKeyCtrl->AddColumn(LoadTempString(IDS_CDKEY), 200); m_pCDKeyCtrl->AddColumn(" ", 320, LTTRUE); m_pJoin = AddTextItem(IDS_JOIN, CMD_JOIN, IDS_HELP_JOIN); m_pHost = AddTextItem(IDS_HOST, CMD_HOST, IDS_HELP_HOST); m_pUpdate = AddTextItem(IDS_LAUNCH_UPDATE, CMD_UPDATE, IDS_HELP_LAUNCH_UPDATE); HTEXTURE hUp = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowup.dtx"); HTEXTURE hUpH = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowup_h.dtx"); HTEXTURE hDown = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowdn.dtx"); HTEXTURE hDownH = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowdn_h.dtx"); char szFrame[128]; g_pLayoutMgr->GetScreenCustomString(SCREEN_ID_MULTI,"FrameTexture",szFrame,sizeof(szFrame)); HTEXTURE hFrame = g_pInterfaceResMgr->GetTexture(szFrame); LTRect rect = g_pLayoutMgr->GetScreenCustomRect(SCREEN_ID_MULTI,"SystemMOTDRect"); LTIntPt pos(rect.left,rect.top); LTIntPt size( (rect.right - rect.left),(rect.bottom - rect.top)); uint8 nMOTDSize = (uint8)g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_MULTI,"MessageFontSize"); uint8 nFont = g_pLayoutMgr->GetScreenFontFace((eScreenID)m_nScreenID); CUIFont* pFont = g_pInterfaceResMgr->GetFont(nFont); m_pSysFrame = debug_new(CLTGUIFrame); m_pSysFrame->Create(hFrame,size.x+16,size.y,LTTRUE); m_pSysFrame->SetBasePos(pos); AddControl(m_pSysFrame); m_pSysMOTD = debug_new(CLTGUILargeText); m_pSysMOTD->Create("",pFont,nMOTDSize,size); m_pSysMOTD->SetBasePos(pos); m_pSysMOTD->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor); m_pSysMOTD->Enable(LTTRUE); m_pSysMOTD->SetFrameWidth(1); m_pSysMOTD->SetIndent(2); m_pSysMOTD->UseArrows(1.0f,hUp,hUpH,hDown,hDownH); AddControl(m_pSysMOTD); rect = g_pLayoutMgr->GetScreenCustomRect(SCREEN_ID_MULTI,"GameMOTDRect"); pos.x = rect.left; pos.y = rect.top; size.x = (rect.right - rect.left); size.y = (rect.bottom - rect.top); m_pGameFrame = debug_new(CLTGUIFrame); m_pGameFrame->Create(hFrame,size.x+16,size.y,LTTRUE); m_pGameFrame->SetBasePos(pos); AddControl(m_pGameFrame); m_pGameMOTD = debug_new(CLTGUILargeText); m_pGameMOTD->Create("",pFont,nMOTDSize,size); m_pGameMOTD->SetBasePos(pos); m_pGameMOTD->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor); m_pGameMOTD->Enable(LTTRUE); m_pGameMOTD->SetFrameWidth(1); m_pGameMOTD->SetIndent(2); m_pGameMOTD->UseArrows(1.0f,hUp,hUpH,hDown,hDownH); AddControl(m_pGameMOTD); nFont = g_pLayoutMgr->GetDialogFontFace(); pFont = g_pInterfaceResMgr->GetFont(nFont); uint8 nFontSize = g_pLayoutMgr->GetDialogFontSize(); m_pWaitText = debug_new(CLTGUITextCtrl); if (!m_pWaitText->Create(LoadTempString(IDS_INTERNET), NULL, LTNULL, pFont, nFontSize, this)) { debug_delete(m_pWaitText); return LTFALSE; } m_pWaitText->SetColors(argbBlack, argbBlack, argbBlack); m_pWaitText->Enable(LTFALSE); uint16 w = 16+m_pWaitText->GetBaseWidth(); uint16 h = 16+m_pWaitText->GetBaseHeight(); m_pWait = debug_new(CLTGUIWindow); char szBack[128] = ""; g_pLayoutMgr->GetDialogFrame(szBack,sizeof(szBack)); m_pWait->Create(g_pInterfaceResMgr->GetTexture(szBack),w,h); uint16 x = (640-w)/2; uint16 y = (480-h)/2; m_pWait->SetBasePos(LTIntPt(x,y)); AddControl(m_pWait); m_pWait->AddControl(m_pWaitText,LTIntPt(8,8)); // status text ----------------------------------------------- pos = g_pLayoutMgr->GetScreenCustomPoint(SCREEN_ID_MULTI,"StatusPos"); char szTmp[256] = ""; LoadString(IDS_WAITING,szTmp,sizeof(szTmp)); m_pStatusCtrl = AddTextItem(FormatTempString(IDS_STATUS_STRING,szTmp), 0, 0, pos, LTTRUE); m_pStatusCtrl->SetFont(NULL, nMOTDSize); CreateDMMissionFile(); // CreateTDMMissionFile(); CreateDDMissionFile(); // Make sure to call the base class return CBaseScreen::Build(); }
// This is called when the screen gets or loses focus void CMenuMission::OnFocus(LTBOOL bFocus) { if (bFocus) { int mission = g_pMissionMgr->GetCurrentMission(); int level = g_pMissionMgr->GetCurrentLevel(); MISSION* pMission = g_pMissionButeMgr->GetMission(mission); if (pMission) { m_pNameCtrl->SetString(LoadTempString(pMission->nNameId)); LEVEL* pLevel = g_pMissionButeMgr->GetLevel(mission,level); if (pLevel) { m_pLevelCtrl->SetString(LoadTempString(pLevel->nNameId)); } else m_pLevelCtrl->SetString(" "); } else { m_pNameCtrl->SetString(LoadTempString(IDS_CUSTOM_LEVEL)); m_pLevelCtrl->SetString(" "); } uint16 nextItem = m_nFirstObj; uint16 numItems = 0; uint16 nWidth = s_Size.x - 2*m_Indent.x; g_pPlayerStats->SetObjectivesSeen(); // add required objectives IDList* pObj = g_pPlayerStats->GetObjectives(); //check to see if we need to add a label if (pObj->m_IDArray.size()) { // if we already have created a objectives label, use it if (m_pObjLabel) { m_List.AddControl(m_pObjLabel); } else { // otherwise create a label uint16 ndx = AddControl(IDS_OBJECTIVES,0,LTTRUE); m_pObjLabel = (CLTGUITextCtrl *)m_List.GetControl(ndx); } } for (int i = (int)(pObj->m_IDArray.size())-1; i >= 0 ; i--) { CObjectiveCtrl* pCtrl = LTNULL; uint32 objID = pObj->m_IDArray[i]; // if we don't have a cached objective control, create a new one if (numItems >= m_Objectives.size()) { uint16 ndx = AddObjectiveControl(objID); pCtrl = (CObjectiveCtrl*)m_List.GetControl(ndx); pCtrl->SetFixedWidth(nWidth); numItems++; } else { //otherwise, grab one from the cache pCtrl = (CObjectiveCtrl*)m_Objectives[numItems]; m_List.AddControl(pCtrl); pCtrl->SetString(LoadTempString(objID)); pCtrl->SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); pCtrl->SetTexture(m_BulletTex); numItems++; } } // add optional objectives pObj = g_pPlayerStats->GetOptionalObjectives(); //check to see if we need to add a label if (pObj->m_IDArray.size() && !numItems) { // if we already have created a objectives label, use it if (m_pObjLabel) { m_List.AddControl(m_pObjLabel); } else { // otherwise create a label uint16 ndx = AddControl(IDS_OBJECTIVES,0,LTTRUE); m_pObjLabel = (CLTGUITextCtrl *)m_List.GetControl(ndx); } } for (int i = (int)(pObj->m_IDArray.size())-1; i >= 0 ; i--) { CObjectiveCtrl* pCtrl = LTNULL; uint32 objID = pObj->m_IDArray[i]; // if we don't have a cached objective control, create a new one if (numItems >= m_Objectives.size()) { uint16 ndx = AddObjectiveControl(objID,LTFALSE,LTTRUE); pCtrl = (CObjectiveCtrl*)m_List.GetControl(ndx); pCtrl->SetFixedWidth(nWidth); numItems++; } else { //otherwise, grab one from the cache pCtrl = (CObjectiveCtrl*)m_Objectives[numItems]; m_List.AddControl(pCtrl); char szString[256] = ""; LoadString(objID,szString,sizeof(szString)); strcat(szString,szOptional); pCtrl->SetString(szString); pCtrl->SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); pCtrl->SetTexture(m_BulletTex); numItems++; } } // add completed objectives pObj = g_pPlayerStats->GetCompletedObjectives(); //check to see if we need to add a label if (pObj->m_IDArray.size() && !numItems) { // if we already have created a objectives label, use it if (m_pObjLabel) { m_List.AddControl(m_pObjLabel); } else { // otherwise create a label uint16 ndx = AddControl(IDS_OBJECTIVES,0,LTTRUE); m_pObjLabel = (CLTGUITextCtrl *)m_List.GetControl(ndx); } } for (int i = (int)(pObj->m_IDArray.size())-1; i >= 0 ; i--) { CObjectiveCtrl* pCtrl = LTNULL; uint32 objID = pObj->m_IDArray[i]; // if we don't have a cached objective control, create a new one if (numItems >= m_Objectives.size()) { uint16 ndx = AddObjectiveControl(objID,LTTRUE); pCtrl = (CObjectiveCtrl*)m_List.GetControl(ndx); pCtrl->SetFixedWidth(nWidth); numItems++; } else { //otherwise, grab one from the cache pCtrl = (CObjectiveCtrl*)m_Objectives[numItems]; m_List.AddControl(pCtrl); pCtrl->SetString(LoadTempString(objID)); pCtrl->SetColors(argbCompleted,argbCompleted,argbCompleted); pCtrl->SetTexture(m_CompletedTex); numItems++; } } // add mission parameters pObj = g_pPlayerStats->GetParameters(); //check to see if we need to add a label if (pObj->m_IDArray.size()) { // if we already have created a parameters label, use it if (m_pParameters) { m_List.AddControl(m_pParameters); } else { // otherwise create a label uint16 ndx = AddControl(IDS_PARAMETERS,0,LTTRUE); m_pParameters = (CLTGUITextCtrl *)m_List.GetControl(ndx); } } for (int i = (int)(pObj->m_IDArray.size())-1; i >= 0 ; i--) { CObjectiveCtrl* pCtrl = LTNULL; uint32 objID = pObj->m_IDArray[i]; // if we don't have a cached objective control, create a new one if (numItems >= m_Objectives.size()) { uint16 ndx = AddObjectiveControl(objID); pCtrl = (CObjectiveCtrl*)m_List.GetControl(ndx); pCtrl->SetFixedWidth(nWidth); numItems++; } else { //otherwise, grab one from the cache pCtrl = (CObjectiveCtrl*)m_Objectives[numItems]; m_List.AddControl(pCtrl); pCtrl->SetString(LoadTempString(objID)); pCtrl->SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); numItems++; } } m_List.SetStartIndex(0); } else { // take the objectives and parameters out of the list // (they are still cached for re-use) RemoveObjectives(); } CBaseMenu::OnFocus(bFocus); }
void MainScreen::LoadResources() { Vector2 screenSize(GetScreenWidth(), GetScreenHeight()); cellH = GetScreenHeight() / 25; buttonW = GetScreenWidth() / 10; float32 infoAreaWidth = screenSize.x - 960.0f; Vector2 previewSize(screenSize.x - infoAreaWidth, screenSize.y - cellH); //Vector2 previewScale(previewSize.x/screenSize.x, previewSize.y/screenSize.y); preview = new PreviewControl(Rect(0.0f, cellH, previewSize.x, previewSize.y)); //preview->SetScaledRect(Rect(0.0f, cellH, previewSize.x*0.9f, previewSize.y*0.9f)); //preview->SetDebugDraw(true); AddControl(preview); FTFont* font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf"); font->SetSize(20.0f); font->SetColor(0.8f, 0.8f, 0.8f, 1.0f); chooseProject = new UIButton(Rect(0.0f, 0.0f, buttonW, cellH)); chooseProject->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL); chooseProject->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f)); chooseProject->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL); chooseProject->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5, 0.5, 0.5, 0.5)); chooseProject->SetStateFont(UIControl::STATE_NORMAL, font); chooseProject->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Project")); chooseProject->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed)); AddControl(chooseProject); loadUI = new UIButton(Rect(2*buttonW, 0, buttonW, cellH)); loadUI->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL); loadUI->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f)); loadUI->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL); loadUI->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f)); loadUI->SetStateFont(UIControl::STATE_NORMAL, font); loadUI->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Load")); loadUI->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed)); AddControl(loadUI); loadUI->SetVisible(false); saveUI = new UIButton(Rect(buttonW*3, 0, buttonW, cellH)); saveUI->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL); saveUI->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f)); saveUI->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL); saveUI->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f)); saveUI->SetStateFont(UIControl::STATE_NORMAL, font); saveUI->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Save")); saveUI->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed)); //TODO: add saveUI when uiviewer becomes editor //AddControl(saveUI); selectHoverModeButton = new UIButton(Rect(buttonW*4, 0, 2*buttonW, cellH)); selectHoverModeButton->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL); selectHoverModeButton->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f)); selectHoverModeButton->SetStateFont(UIControl::STATE_NORMAL, font); selectHoverModeButton->SetStateText(UIControl::STATE_NORMAL, LocalizedString("selection.mode.click")); selectHoverModeButton->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL); selectHoverModeButton->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f)); selectHoverModeButton->SetStateDrawType(UIControl::STATE_SELECTED, UIControlBackground::DRAW_FILL); selectHoverModeButton->GetStateBackground(UIControl::STATE_SELECTED)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f)); selectHoverModeButton->SetStateFont(UIControl::STATE_SELECTED, font); selectHoverModeButton->SetStateText(UIControl::STATE_SELECTED, LocalizedString("selection.mode.hover")); selectHoverModeButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed)); AddControl(selectHoverModeButton); selectHoverModeButton->SetVisible(false); for (int32 i = 0; i < InfoControl::INFO_TYPES_COUNT; ++i) { keyTexts[i] = new UIStaticText(Rect(screenSize.x - infoAreaWidth, cellH*(2*i+1), infoAreaWidth, cellH)); keyTexts[i]->SetFont(font); keyTexts[i]->SetText(keyNames[i]); AddControl(keyTexts[i]); valueTexts[i] = new UIStaticText(Rect(screenSize.x - infoAreaWidth, cellH*(2*i+2), infoAreaWidth, cellH)); valueTexts[i]->SetFont(font); AddControl(valueTexts[i]); } additionalInfoList = new UIList(Rect(screenSize.x - infoAreaWidth, cellH*(2*InfoControl::INFO_TYPES_COUNT+2), infoAreaWidth, screenSize.y - cellH*(2*InfoControl::INFO_TYPES_COUNT+2) ), UIList::ORIENTATION_VERTICAL); additionalInfoList->SetDelegate(this); AddControl(additionalInfoList); fsDlg = new UIFileSystemDialog("~res:/Fonts/MyriadPro-Regular.otf"); fsDlg->SetDelegate(this); Vector<String> filter; filter.push_back(".yaml"); filter.push_back(".YAML"); fsDlg->SetExtensionFilter(filter); fsDlg->SetTitle(LocalizedString("Dlg.Load")); fsDlg->SetCurrentDir(FileSystem::Instance()->SystemPathForFrameworkPath("~res:/")); fsDlgProject = new UIFileSystemDialog("~res:/Fonts/MyriadPro-Regular.otf"); //default = GetCurrentWorkingDirectory fsDlgProject->SetDelegate(this); fsDlgProject->SetOperationType(UIFileSystemDialog::OPERATION_CHOOSE_DIR); fsDlgProject->SetTitle(LocalizedString("Dlg.ChoosePrj")); KeyedArchive* archive = new KeyedArchive(); if(archive->Load("~doc:/uiviewer.archive")) { if(archive->IsKeyExists("projectPath")) { projectPath = archive->GetString("projectPath"); //TODO: different path formats on different OS OnLoadProject(); fsDlgProject->SetCurrentDir(projectPath); } } SafeRelease(archive); SafeRelease(font); }
void UIScrollViewTest::LoadResources() { Font *font = FTFont::Create("~res:/Fonts/korinna.ttf"); DVASSERT(font); font->SetSize(14); font->SetColor(Color::White()); UIYamlLoader::Load( this, "~res:/UI/Test/ScrollScreen.yaml" ); scrollView = DynamicTypeCheck<UIScrollView *>( FindByName( "Scrollview" ) ); UIControl* innerControl = FindByName("UIControl1"); if (innerControl) { innerControl->SetSprite("~res:/Gfx/UI/HorizontalScroll", 0); innerControl->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT); } UIControl *control = FindByName("HorizontalScrollbar"); if( control ) { UIScrollBar *horizontalScrollbar = DynamicTypeCheck<UIScrollBar *>( control ); horizontalScrollbar->GetSlider()->SetSprite("~res:/Gfx/UI/HorizontalScroll", 0); horizontalScrollbar->GetSlider()->GetBackground()->SetDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL); horizontalScrollbar->GetSlider()->GetBackground()->SetLeftRightStretchCap(10); horizontalScrollbar->SetOrientation( UIScrollBar::ORIENTATION_HORIZONTAL ); horizontalScrollbar->SetDelegate(scrollView); } control = FindByName("VerticalScrollbar"); if( control ) { UIScrollBar *verticalScrollbar = DynamicTypeCheck<UIScrollBar *>( control ); verticalScrollbar->GetSlider()->SetSprite("~res:/Gfx/UI/VerticalScroll", 0); verticalScrollbar->GetSlider()->GetBackground()->SetDrawType(UIControlBackground::DRAW_STRETCH_VERTICAL); verticalScrollbar->GetSlider()->GetBackground()->SetTopBottomStretchCap(10); verticalScrollbar->SetOrientation( UIScrollBar::ORIENTATION_VERTICAL ); verticalScrollbar->SetDelegate(scrollView); } UIControl *testControl4 = new UIControl(Rect(1200, 1400, 250, 250)); testControl4->SetDebugDraw(true); testControl4->GetBackground()->SetColor(Color(0.3333, 0.3333, 0.5555, 1.0000)); testControl4->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); testControl4->SetName("CONTROL_4"); testControl4->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); scrollView->AddControlToContainer(testControl4); UIControl *testControlChild = new UIControl(Rect(100, 100, 150, 150)); testControlChild->SetDebugDraw(true); testControlChild->GetBackground()->SetColor(Color(0.3333, 0.3333, 0.5555, 1.0000)); testControlChild->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); testControlChild->SetName("CONTROL_3"); testControlChild->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); UIControl *testControl = new UIControl(Rect(50, 0, 150, 150)); testControl->SetDebugDraw(true); testControl->GetBackground()->SetColor(Color(0.3333, 0.6667, 0.4980, 1.0000)); testControl->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); testControl->SetName("CONTROL_2"); testControl->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); testControl->AddControl(testControlChild); UIButton *testButton = new UIButton(Rect(10, 50, 250, 100)); testButton->SetDebugDraw(true); testButton->SetStateFont(STATE_NORMAL, font); testButton->SetStateText(STATE_NORMAL, L"First button"); testButton->GetBackground()->SetColor(Color(0.6667, 0.6667, 0.4980, 1.0000)); testButton->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); testButton->SetName("CONTROL_1"); testButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); testButton->AddControl(testControl); scrollView->AddControlToContainer(testButton); testMessageText = new UIStaticText(Rect(10, 10, 300, 30)); testMessageText->SetFont(font); testMessageText->SetTextColor(Color(0.0, 1.0, 0.0, 1.0)); testMessageText->GetBackground()->SetColor(Color(0.5, 0.0, 0.25, 1.0)); testMessageText->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); AddControl(testMessageText); finishTestBtn = new UIButton(Rect(10, 310, 300, 30)); finishTestBtn->SetStateFont(0xFF, font); finishTestBtn->SetStateFontColor(0xFF, Color(1.0, 0.0, 0.0, 0.75)); finishTestBtn->SetStateText(0xFF, L"Finish test"); finishTestBtn->SetDebugDraw(true); finishTestBtn->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); AddControl(finishTestBtn); }
void TextureConverterDialog::AddLine(const DAVA::Rect &lineRect) { UIControl *line = ControlsFactory::CreateLine(lineRect, Color(0.2f, 0.2f, 0.2f, 0.8f)); AddControl(line); SafeRelease(line); }
void IPlugProcess::EffectInit() { TRACE; if (mPlug) { AddControl(new CPluginControl_OnOff('bypa', "Master Bypass\nMastrByp\nMByp\nByp", false, true)); // Default to off DefineMasterBypassControlIndex(1); int paramCount = mPlug->NParams(); for (int i=0; i<paramCount; i++) { IParam *p = mPlug->GetParam(i); switch (p->Type()) { case IParam::kTypeDouble: AddControl(new CPluginControl_Linear(' ld '+i, p->GetNameForHost(), p->GetMin(), p->GetMax(), p->GetStep(), p->GetDefault(), p->GetCanAutomate())); break; case IParam::kTypeInt: AddControl(new CPluginControl_Discrete(' ld '+i, p->GetNameForHost(), (long) p->GetMin(), (long) p->GetMax(), (long) p->GetDefault(), p->GetCanAutomate())); break; case IParam::kTypeEnum: case IParam::kTypeBool: { std::vector<std::string> displayTexts; for (int j=0; j<p->GetNDisplayTexts(); j++) { displayTexts.push_back(p->GetDisplayTextAtIdx(j)); } assert(displayTexts.size()); AddControl(new CPluginControl_List(' ld '+i, p->GetNameForHost(), displayTexts, (long) p->GetDefault(), p->GetCanAutomate())); break; } default: break; } } #if PLUG_DOES_MIDI if (!IsAS()) { ComponentResult result = noErr; Cmn_Int32 requestedVersion = 7; std::string midiNodeName(PLUG_NAME" Midi"); while (requestedVersion) { result = DirectMidi_RegisterClient(requestedVersion, this, reinterpret_cast<Cmn_UInt32>(this), (void **)&mDirectMidiInterface); if (result == noErr && mDirectMidiInterface != NULL) { mDirectMidiInterface->CreateRTASBufferedMidiNode(0, const_cast<char *>(midiNodeName.c_str()), 1); break; } requestedVersion--; } } #endif mPlug->SetIO(GetNumInputs(), GetNumOutputs()); mPlug->SetSampleRate(GetSampleRate()); mPlug->Reset(); } }
LTBOOL CMenuPlayer::Init() { m_MenuID = MENU_ID_PLAYER; s_pSklMenu = this; if (!CBaseMenu::Init()) return LTFALSE; int nNameWidth = g_pLayoutMgr->GetMenuCustomInt(m_MenuID,"NameWidth"); int nLevelWidth = g_pLayoutMgr->GetMenuCustomInt(m_MenuID,"LevelWidth"); int nUpgradeWidth = s_Size.x - ( (m_Indent.x * 2) + nNameWidth + nLevelWidth); LTVector vColor = g_pLayoutMgr->GetMenuCustomVector(m_MenuID,"HighlightColor"); uint8 nA = 255; uint8 nR = (uint8)vColor.x; uint8 nG = (uint8)vColor.y; uint8 nB = (uint8)vColor.z; skillHighlightColor= SET_ARGB(nA,nR,nG,nB); uint8 nSmallerFont = (uint8)g_pLayoutMgr->GetMenuCustomInt(m_MenuID,"SmallerFontSize"); SetTitle(IDS_TITLE_SUMMARY); LTIntPt popupSize = g_pLayoutMgr->GetMenuCustomPoint(m_MenuID,"PopupSize"); m_Popup.Init(s_Frame,s_FrameTip,popupSize); m_Popup.m_bWaitForUpdate = LTFALSE; LTIntPt offset = m_Indent; offset.y = 8; CUIFont* pFont = g_pInterfaceResMgr->GetFont(m_TitleFontFace); m_Name.Create("name",LTNULL,LTNULL,pFont,m_TitleFontSize,LTNULL); m_Name.SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); m_Name.Enable(LTFALSE); m_Popup.AddControl(&m_Name,offset); offset.y += (m_Name.GetHeight() + 4); pFont = g_pInterfaceResMgr->GetFont(m_FontFace); m_Level.Create("level",LTNULL,LTNULL,pFont,m_FontSize,LTNULL); m_Level.SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); m_Level.Enable(LTFALSE); m_Popup.AddControl(&m_Level,offset); offset.y += (m_Level.GetHeight() + 12); m_Header.Create(LTNULL,LTNULL,pFont,m_FontSize, LTNULL); m_Header.AddColumn(" ",nNameWidth); m_Header.AddColumn(LoadTempString(IDS_CURRENT),60); m_Header.AddColumn(LoadTempString(IDS_UPGRADE),60); m_Header.SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); m_Header.Enable(LTFALSE); m_Popup.AddControl(&m_Header,offset); offset.y += (m_Header.GetHeight() + 2); for (uint8 m = 0; m < kMaxModifiers; ++m) { m_Mods[m].Create(LTNULL,LTNULL,pFont,m_FontSize,LTNULL); m_Mods[m].AddColumn(" ",nNameWidth); m_Mods[m].AddColumn("100",60); m_Mods[m].AddColumn("100",60); m_Mods[m].SetColors(skillHighlightColor,m_NonSelectedColor,m_DisabledColor); m_Mods[m].Enable(LTTRUE); m_Popup.AddControl(&m_Mods[m],offset); offset.y += (m_Mods[m].GetHeight() + 2); } offset.y += 8; m_Upgrade.Create("Upgrade",MC_UPGRADE,IDS_HELP_UPGRADE,pFont,m_FontSize,this); m_Upgrade.SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor); m_Popup.AddControl(&m_Upgrade,offset); offset.y += (m_Upgrade.GetHeight() + 4); m_Points.Create("avail",LTNULL,LTNULL,pFont,m_FontSize,LTNULL); m_Points.SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); m_Points.SetFont(LTNULL,nSmallerFont); m_Points.Enable(LTFALSE); m_Popup.AddControl(&m_Points,offset); uint8 nHelpFont = (uint8)g_pLayoutMgr->GetMenuCustomInt(m_MenuID,"HelpFontSize"); offset = g_pLayoutMgr->GetMenuCustomPoint(m_MenuID,"HelpOffset"); uint16 nWidth = 600 - 2* offset.x; if (!nHelpFont) nHelpFont = m_FontSize; m_ModDesc.Create("description",LTNULL,LTNULL,pFont,nHelpFont,LTNULL); m_ModDesc.SetColors(m_SelectedColor,m_SelectedColor,m_SelectedColor); m_ModDesc.SetFixedWidth(nWidth); m_ModDesc.Enable(LTFALSE); m_Popup.AddControl(&m_ModDesc,offset); int nPopupPos = g_pLayoutMgr->GetMenuCustomInt(m_MenuID,"PopupPos"); m_Popup.SetBasePos(LTIntPt(0,nPopupPos)); g_pInterfaceMgr->GetMenuMgr()->RegisterCommand(COMMAND_ID_STATUS,MENU_ID_PLAYER); //Rank control m_pRank = AddColumnCtrl(); m_pRank->AddColumn(LoadTempString(IDS_RANK),nNameWidth); m_pRank->AddColumn("Novice",nNameWidth); //Total points control m_pTotal = AddColumnCtrl(); m_pTotal->AddColumn(LoadTempString(IDS_SCORE),nNameWidth); m_pTotal->AddColumn("0",nNameWidth); //Avail points control m_pAvail = AddColumnCtrl(); m_pAvail->AddColumn(LoadTempString(IDS_SKILL_PTS),nNameWidth); m_pAvail->AddColumn("0",nNameWidth); AddControl(" ",0,LTTRUE); // CUIFont* pFont = g_pInterfaceResMgr->GetFont(m_FontFace); for (uint8 i = 0; i < kNumSkills; i++) { eSkill skl = (eSkill)i; if (g_pSkillsButeMgr->IsAvailable(skl) ) { m_pSkills[i] = debug_new(CSkillCtrl); m_pSkills[i]->Create(skl,(MC_CUSTOM+i),pFont,m_FontSize,this,nNameWidth); m_List.AddControl(m_pSkills[i]); } } return LTTRUE; }
xpr_bool_t HistoryDlg::OnInitDialog(void) { super::OnInitDialog(); SetIcon(mIcon, XPR_TRUE); HICON sIconHandle; sIconHandle = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_NOT)); mTreeImgList.Create(16, 16, ILC_COLOR32 | ILC_MASK, -1, -1); mTreeImgList.Add(sIconHandle); ::DestroyIcon(sIconHandle); mTreeCtrl.SetImageList(&mTreeImgList, TVSIL_NORMAL); //----------------------------------------------------------------------------- if (mToolBar.Create(this) == XPR_FALSE) { XPR_TRACE(XPR_STRING_LITERAL("Failed to create toolbar\n")); return -1; } mToolBarImgList.Create(IDB_TB_DRIVEDLG, 16, 1, RGB(255,0,255)); mToolBar.GetToolBarCtrl().SetImageList(&mToolBarImgList); mToolBar.GetToolBarCtrl().SetBitmapSize(CSize(16,16)); mToolBar.ModifyStyle(0, TBSTYLE_LIST | TBSTYLE_FLAT); mToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS | TBSTYLE_EX_MIXEDBUTTONS); mToolBar.SetBorders(0, 0, 0, 0); DWORD sStyle = mToolBar.GetBarStyle(); sStyle &= ~CBRS_BORDER_TOP; sStyle |= CBRS_FLYBY; mToolBar.SetBarStyle(sStyle); //----------------------------------------------------------------------------- TBBUTTON sTbButton = {0}; sTbButton.idCommand = ID_HISTORY_REFRESH; sTbButton.iBitmap = 0; sTbButton.fsState = TBSTATE_ENABLED; sTbButton.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE | BTNS_SHOWTEXT; sTbButton.iString = mToolBar.GetToolBarCtrl().AddStrings(gApp.loadString(XPR_STRING_LITERAL("popup.history.toolbar.refresh"))); mToolBar.GetToolBarCtrl().AddButtons(1, &sTbButton); //----------------------------------------------------------------------------- // ControlBar Reposition CRect sClientStartRect; CRect sClientNowRect; GetClientRect(sClientStartRect); RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, sClientNowRect); CPoint sOffsetPoint(sClientNowRect.left - sClientStartRect.left, sClientNowRect.top - sClientStartRect.top); CRect sChildRect; CWnd *sChildWnd = GetWindow(GW_CHILD); while (XPR_IS_NOT_NULL(sChildWnd)) { sChildWnd->GetWindowRect(sChildRect); ScreenToClient(sChildRect); sChildRect.OffsetRect(sOffsetPoint); sChildWnd->MoveWindow(sChildRect, XPR_FALSE); sChildWnd = sChildWnd->GetNextWindow(); } CRect sWindowRect; GetWindowRect(sWindowRect); sWindowRect.right += sClientStartRect.Width() - sClientNowRect.Width(); sWindowRect.bottom += sClientStartRect.Height() - sClientNowRect.Height(); MoveWindow(sWindowRect, XPR_FALSE); RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); //---------------------------------------------------------------------- if (mHistoryDispDeque.size() == 1) { mTabCtrl.ShowWindow(SW_HIDE); CRect sTabRect; mTabCtrl.GetWindowRect(&sTabRect); ScreenToClient(&sTabRect); CRect sTreeRect; mTreeCtrl.GetWindowRect(&sTreeRect); ScreenToClient(&sTreeRect); sTreeRect.top = sTabRect.top; mTreeCtrl.MoveWindow(&sTreeRect); } // CResizingDialog ------------------------------------------- HideSizeIcon(); //sizeNone: Don't resize at all //sizeResize: The control will be stretched in the appropriate direction //sizeRepos: The control will be moved in the appropriate direction //sizeRelative: The control will be moved proportionally in the appropriate direction AddControl(IDC_HISTORY_TREE, sizeResize, sizeResize); AddControl(IDC_HISTORY_STATUS, sizeResize, sizeRepos); //------------------------------------------------------------ HistoryDisp *sHistoryDisp; HistoryDispDeque::iterator sIterator; sIterator = mHistoryDispDeque.begin(); for (; sIterator != mHistoryDispDeque.end(); ++sIterator) { sHistoryDisp = *sIterator; if (sHistoryDisp == XPR_NULL) continue; mTabCtrl.InsertItem(mTabCtrl.GetItemCount(), sHistoryDisp->mTabText); } mTabCtrl.SetCurSel((xpr_sint_t)mCurHistoryDisp); showTab(mCurHistoryDisp); mDlgState = DlgStateManager::instance().getDlgState(XPR_STRING_LITERAL("History")); if (XPR_IS_NOT_NULL(mDlgState)) { mDlgState->setDialog(this, XPR_TRUE); mDlgState->load(); } return XPR_TRUE; }
void wxGenericAboutDialog::AddControl(wxWindow *win) { AddControl(win, wxSizerFlags().Border(wxDOWN).Centre()); }
bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info) { // TODO: should we use main frame as parent by default here? if ( !wxDialog::Create(NULL, wxID_ANY, _("About ") + info.GetName(), wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE) ) return false; m_sizerText = new wxBoxSizer(wxVERTICAL); wxString nameAndVersion = info.GetName(); if ( info.HasVersion() ) nameAndVersion << _T(' ') << info.GetVersion(); wxStaticText *label = new wxStaticText(this, wxID_ANY, nameAndVersion); wxFont fontBig(*wxNORMAL_FONT); fontBig.SetPointSize(fontBig.GetPointSize() + 2); fontBig.SetWeight(wxFONTWEIGHT_BOLD); label->SetFont(fontBig); m_sizerText->Add(label, wxSizerFlags().Centre().Border()); m_sizerText->AddSpacer(5); AddText(info.GetCopyrightToDisplay()); AddText(info.GetDescription()); if ( info.HasWebSite() ) { #if wxUSE_HYPERLINKCTRL AddControl(new wxHyperlinkCtrl(this, wxID_ANY, info.GetWebSiteDescription(), info.GetWebSiteURL())); #else AddText(info.GetWebSiteURL()); #endif // wxUSE_HYPERLINKCTRL/!wxUSE_HYPERLINKCTRL } #if wxUSE_COLLPANE if ( info.HasLicence() ) AddCollapsiblePane(_("License"), info.GetLicence()); if ( info.HasDevelopers() ) AddCollapsiblePane(_("Developers"), AllAsString(info.GetDevelopers())); if ( info.HasDocWriters() ) AddCollapsiblePane(_("Documentation writers"), AllAsString(info.GetDocWriters())); if ( info.HasArtists() ) AddCollapsiblePane(_("Artists"), AllAsString(info.GetArtists())); if ( info.HasTranslators() ) AddCollapsiblePane(_("Translators"), AllAsString(info.GetTranslators())); #endif // wxUSE_COLLPANE DoAddCustomControls(); wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL); #if wxUSE_STATBMP wxIcon icon = info.GetIcon(); if ( icon.Ok() ) { sizerIconAndText->Add(new wxStaticBitmap(this, wxID_ANY, icon), wxSizerFlags().Border(wxRIGHT)); } #endif // wxUSE_STATBMP sizerIconAndText->Add(m_sizerText, wxSizerFlags(1).Expand()); wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border()); wxSizer *sizerBtns = CreateButtonSizer(wxOK); if ( sizerBtns ) { sizerTop->Add(sizerBtns, wxSizerFlags().Expand().Border()); } SetSizerAndFit(sizerTop); CentreOnScreen(); return true; }
void EDetailManager::CreateControls() { AddControl (xr_new<TUI_CustomControl>(estDefault, etaSelect, this)); // frame pFrame = xr_new<TfraDetailObject>((TComponent*)0,this); }
void SceneEditorScreenMain::AddLineControl(DAVA::Rect r) { UIControl *lineControl = ControlsFactory::CreateLine(r); AddControl(lineControl); SafeRelease(lineControl); }