void LandscapeEditorHeightmap::TextureWillChanged(const String &forKey) { if("property.landscape.texture.heightmap" == forKey) { if(savedPath.length()) { SaveTextureAction(savedPath); StoreOriginalHeightmap(); } } else if("property.landscape.texture.tilemask" == forKey) { if(tilemaskImage && tilemaskWasChanged) { tilemaskWasChanged = false; ImageLoader::Save(tilemaskImage, tilemaskPathname); } } }
void HeightmapEditorSystem::ProcessUIEvent(DAVA::UIEvent *event) { if (!IsLandscapeEditingEnabled()) { return; } UpdateCursorPosition(); if (event->tid == UIEvent::BUTTON_1) { Vector3 point; switch(event->phase) { case UIEvent::PHASE_BEGAN: if (drawingType == HEIGHTMAP_DRAW_ABSOLUTE_DROPPER || drawingType == HEIGHTMAP_DROPPER) { curHeight = drawSystem->GetHeightAtPoint(cursorPosition); SceneSignals::Instance()->EmitDropperHeightChanged(dynamic_cast<SceneEditor2*>(GetScene()), curHeight); } if (isIntersectsLandscape) { if (drawingType == HEIGHTMAP_COPY_PASTE) { int32 curKeyModifiers = QApplication::keyboardModifiers(); if (curKeyModifiers & Qt::AltModifier) { copyPasteFrom = cursorPosition; copyPasteTo = Vector2(-1.f, -1.f); return; } else { if (copyPasteFrom == Vector2(-1.f, -1.f)) { return; } copyPasteTo = cursorPosition; StoreOriginalHeightmap(); } } else { if (drawingType != HEIGHTMAP_DROPPER) { StoreOriginalHeightmap(); } } UpdateToolImage(); editingIsEnabled = true; } activeDrawingType = drawingType; break; case UIEvent::PHASE_DRAG: break; case UIEvent::PHASE_ENDED: FinishEditing(); break; } } }
void LandscapeEditorHeightmap::InputAction(int32 phase, bool intersects) { bool dropper = IsKeyModificatorPressed(DVKEY_CTRL); if(dropper) { switch(phase) { case UIEvent::PHASE_BEGAN: case UIEvent::PHASE_DRAG: case UIEvent::PHASE_ENDED: { currentTool->height = GetDropperHeight(); break; } default: break; } } else { switch(phase) { case UIEvent::PHASE_BEGAN: { if(currentTool->absoluteDropperDrawing) { currentTool->height = GetDropperHeight(); } bool skipUndoPointCreation = false; if(LandscapeTool::TOOL_COPYPASTE == currentTool->type) { //CopyPasteBegin returns true when copyFrom point is set //no need to create undo point in this case skipUndoPointCreation = CopyPasteBegin(); if (!skipUndoPointCreation) { DVASSERT(oldTilemap == NULL); workingLandscape->UpdateFullTiledTexture(); oldTilemap = tilemaskTexture->CreateImageFromMemory(); } } if (!skipUndoPointCreation) { StoreOriginalHeightmap(); } editingIsEnabled = true; UpdateToolImage(); break; } case UIEvent::PHASE_DRAG: { if(editingIsEnabled && !intersects) { editingIsEnabled = false; CreateUndoPoint(); } else if(!editingIsEnabled && intersects) { editingIsEnabled = true; UpdateToolImage(); StoreOriginalHeightmap(); if(LandscapeTool::TOOL_COPYPASTE == currentTool->type) { DVASSERT(oldTilemap == NULL); workingLandscape->UpdateFullTiledTexture(); oldTilemap = tilemaskTexture->CreateImageFromMemory(); } } break; } case UIEvent::PHASE_ENDED: { editingIsEnabled = false; CreateUndoPoint(); break; } default: break; } } }