LandscapeToolsPanel::LandscapeToolsPanel(LandscapeToolsPanelDelegate *newDelegate, const Rect & rect) : UIControl(rect) , delegate(newDelegate) , selectedTool(NULL) , selectedBrushTool(NULL) { ControlsFactory::CustomizeDialogFreeSpace(this); selectionPanel = NULL; brushIcon = new UIControl(Rect(0, 0, ControlsFactory::TOOLS_HEIGHT, ControlsFactory::TOOLS_HEIGHT)); brushIcon->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &LandscapeToolsPanel::OnBrushTool)); brushIcon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); AddControl(brushIcon); sizeSlider = CreateSlider(Rect(rect.dx - SLIDER_WIDTH - TEXTFIELD_WIDTH, 0, SLIDER_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2)); sizeSlider->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &LandscapeToolsPanel::OnSizeChanged)); AddControl(sizeSlider); strengthSlider = CreateSlider(Rect(rect.dx - SLIDER_WIDTH - TEXTFIELD_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2, SLIDER_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2)); strengthSlider->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &LandscapeToolsPanel::OnStrengthChanged)); AddControl(strengthSlider); AddSliderHeader(sizeSlider, LocalizedString(L"landscapeeditor.size")); AddSliderHeader(strengthSlider, LocalizedString(L"landscapeeditor.strength")); }
LandscapeToolsPanelHeightmap::LandscapeToolsPanelHeightmap(LandscapeToolsPanelDelegate *newDelegate, const Rect & rect) : LandscapeToolsPanel(newDelegate, rect) { Rect sizeRect(rect.dx - TEXTFIELD_WIDTH, 0, TEXTFIELD_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2); sizeValue = CreateTextField(sizeRect); AddControl(sizeValue); Rect strengthRect(sizeRect); strengthRect.y = sizeRect.y + sizeRect.dy; strengthValue = CreateTextField(strengthRect); AddControl(strengthValue); Rect lineRect; lineRect.x = strengthSlider->GetRect().x + strengthSlider->GetRect().dx/2; lineRect.dx = 2; lineRect.y = strengthSlider->GetRect().y - 2; lineRect.dy = strengthSlider->GetRect().dy + 4; line = ControlsFactory::CreateLine(lineRect); AddControl(line); showGrid = CreateCkeckbox(Rect(0, ControlsFactory::TOOLS_HEIGHT, ControlsFactory::TOOLS_HEIGHT/2, ControlsFactory::TOOLS_HEIGHT/2), LocalizedString(L"landscapeeditor.showgrid")); float32 x = 0; float32 y = ControlsFactory::TOOLS_HEIGHT + ControlsFactory::TOOLS_HEIGHT/2.f; relative = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), LocalizedString(L"landscapeeditor.relative")); x += (ControlsFactory::TOOLS_HEIGHT/2.f + OFFSET + TEXT_WIDTH); average = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), LocalizedString(L"landscapeeditor.average")); x += (ControlsFactory::TOOLS_HEIGHT/2.f + OFFSET + TEXT_WIDTH); absoluteDropper = CreateCkeckbox(Rect(x, y, ControlsFactory::TOOLS_HEIGHT/2.f, ControlsFactory::TOOLS_HEIGHT/2.f), LocalizedString(L"landscapeeditor.absolutedropper")); Rect heightRect; heightRect.x = showGrid->GetRect().x + showGrid->GetRect().dx + TEXT_WIDTH + OFFSET; heightRect.y = ControlsFactory::TOOLS_HEIGHT; heightRect.dx = TEXTFIELD_WIDTH; heightRect.dy = average->GetRect().dy; heightValue = CreateTextField(Rect(heightRect)); heightValue->SetText(L"0"); AddControl(heightValue); heightRect.x = heightRect.x + heightRect.dx + ControlsFactory::OFFSET/2.f; heightRect.dx = TEXT_WIDTH; UIStaticText *textControl = new UIStaticText(heightRect); textControl->SetText(LocalizedString(L"landscapeeditor.height")); textControl->SetFont(ControlsFactory::GetFontLight()); textControl->SetAlign(ALIGN_VCENTER | ALIGN_LEFT); AddControl(textControl); SafeRelease(textControl); averageStrength = CreateSlider(Rect(rect.dx - SLIDER_WIDTH, heightRect.y, SLIDER_WIDTH, ControlsFactory::TOOLS_HEIGHT / 2)); averageStrength->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &LandscapeToolsPanelHeightmap::OnAverageSizeChanged)); AddControl(averageStrength); AddSliderHeader(averageStrength, LocalizedString(L"landscapeeditor.averagestrength")); dropperTool = new LandscapeTool(-1, LandscapeTool::TOOL_DROPPER, "~res:/LandscapeEditor/SpecialTools/dropper.png"); dropperTool->size = 1.0f; dropperTool->height = prevHeightValue = 0.f; Rect dropperRect = brushIcon->GetRect(); dropperRect.x = (dropperRect.x + dropperRect.dx + ControlsFactory::OFFSET); dropperIcon = new UIControl(dropperRect); dropperIcon->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &LandscapeToolsPanelHeightmap::OnDropperTool)); dropperIcon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); dropperIcon->SetSprite(dropperTool->sprite, 0); AddControl(dropperIcon); copypasteTool = new LandscapeTool(-1, LandscapeTool::TOOL_COPYPASTE, "~res:/LandscapeEditor/SpecialTools/copypaste.png"); Rect copypasteRect = dropperRect; copypasteRect.x = (copypasteRect.x + copypasteRect.dx + ControlsFactory::OFFSET); copypasteIcon = new UIControl(copypasteRect); copypasteIcon->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &LandscapeToolsPanelHeightmap::OnCopypasteTool)); copypasteIcon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); copypasteIcon->SetSprite(copypasteTool->sprite, 0); AddControl(copypasteIcon); copypasteRect.x = (copypasteRect.x + copypasteRect.dx + ControlsFactory::OFFSET); copypasteRect.dx = copypasteRect.dy = ControlsFactory::TOOLS_HEIGHT / 2; copyHeightmap = CreateCkeckbox(copypasteRect, L"Height"); copypasteRect.y += copypasteRect.dy; copyTilemask = CreateCkeckbox(copypasteRect, L"Tilemask"); sizeValue->SetText(Format(L"%.3f", LandscapeTool::SizeHeightMax())); strengthValue->SetText(Format(L"%.3f", LandscapeTool::StrengthHeightMax())); relative->SetChecked(true, false); average->SetChecked(false, false); absoluteDropper->SetChecked(false, false); sizeSlider->SetMinMaxValue(0.f, LandscapeTool::SizeHeightMax()); sizeSlider->SetValue(LandscapeTool::DefaultSizeHeight()); strengthSlider->SetMinMaxValue(-LandscapeTool::StrengthHeightMax(), LandscapeTool::StrengthHeightMax()); strengthSlider->SetValue(LandscapeTool::DefaultStrengthHeight()); averageStrength->SetMinMaxValue(0.f, 1.f); averageStrength->SetValue(0.5f); copyHeightmap->SetChecked(true, false); copyTilemask->SetChecked(true, false); }