Beispiel #1
0
CommandCopyPasteHeightmap::CommandCopyPasteHeightmap(bool copyHeightmap, bool copyTilemap, Heightmap* originalHeightmap, Heightmap* newHeightmap, Image* originalTilemap, Image* newTilemap, const String& tilemapSavedPath)
:	HeightmapModificationCommand(COMMAND_UNDO_REDO)
,	heightmap(copyHeightmap)
,	tilemap(copyTilemap)
{
	commandName = "Heightmap Copy/Paste";

	heightmapUndoFilename = "";
	heightmapRedoFilename = "";
	tilemapUndoImage = NULL;
	tilemapRedoImage = NULL;

	if (copyHeightmap && originalHeightmap && newHeightmap)
	{
		heightmapUndoFilename = SaveHeightmap(originalHeightmap);
		heightmapRedoFilename = SaveHeightmap(newHeightmap);

		updatedRect = GetDifferenceRect(originalHeightmap, newHeightmap);
	}

	if (copyTilemap && originalTilemap && newTilemap)
	{
		tilemapSavedPathname = FileSystem::Instance()->ReplaceExtension(tilemapSavedPath, ".png");;
		tilemapUndoImage = SafeRetain(originalTilemap);
		tilemapRedoImage = SafeRetain(newTilemap);
	}
}
Beispiel #2
0
void Scene::SetCurrentCamera(Camera * _camera)
{
    SafeRelease(currentCamera);
    currentCamera = SafeRetain(_camera);
    SafeRelease(clipCamera);
    clipCamera = SafeRetain(_camera);
}
void HierarchyTreeControlNode::RemoveTreeNodeFromScene()
{
	if (!this->GetParent() || !uiObject->GetParent())
	{
		return;
	}
	
	this->parentUIObject = uiObject->GetParent();
	SafeRetain(this->parentUIObject);

	// Determine the "child above" to return node to scene to the correct position.
	this->childUIObjectAbove = NULL;
	for (List<UIControl*>::const_iterator iter = parentUIObject->GetChildren().begin();
		 iter != parentUIObject->GetChildren().end(); iter ++)
	{
		if (((*iter) == uiObject) && (iter != parentUIObject->GetChildren().begin()))
		{
			iter --;
			this->childUIObjectAbove = (*iter);
			break;
		}
	}

	SafeRetain(uiObject);
	this->parentUIObject->RemoveControl(uiObject);
	
	// We added an additional reference to uiObject and parentUIObject - don't forget
	// to release them in destructor.
	this->needReleaseUIObjects = true;
}
void ResourcePackerScreen::LoadResources()
{
	inputGfxDirectory = FileSystem::RealPath("/Sources/dava.framework/Tools/ResourceEditor/DataSource/Gfx/");
    Logger::Debug("%s", inputGfxDirectory.c_str());
	outputGfxDirectory = FileSystem::RealPath(inputGfxDirectory + "/../../Data/Gfx");
	excludeDirectory = FileSystem::RealPath(inputGfxDirectory + "/../");
	
	// PackResources();
	
	UIYamlLoader::Load(this, "~res:/Screens/ResourcePackerScreen.yaml");
	
	resourceTree = SafeRetain(dynamic_cast<UIFileTree*>(FindByName("resourceTree")));
	resourceTree->SetDelegate(this);
	resourceTree->SetFolderNavigation(true);
	resourceTree->SetPath(outputGfxDirectory, ".txt");
	
	// Resource Tree Setup
//	resourceTree = new UIFileTree(Rect(0, 0, 200, 600));
//	resourceTree->SetPath(outputGfxDirectory, ".txt");
//	AddControl(resourceTree);
//	resourceTree->SetDelegate(this);

	//resourceTree->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
	//resourceTree->GetBackground()->SetColor(Color(0.3, 0.3, 0.3, 1.0f));
	
	// SpriteEditor setup
	spriteEditor = SafeRetain(dynamic_cast<UISpriteEditor*> (FindByName("spriteEditor")));
//	spriteEditor = new UISpriteEditor(Rect(220, 0, GetScreenWidth() - 230, 500));
//	spriteEditor->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
//	spriteEditor->GetBackground()->SetColor(Color(0.5, 0.5, 0.5, 1.0f));
//	spriteEditor->
}
Beispiel #5
0
void Scene::SetCurrentCamera(Camera * _camera)
{
    SafeRelease(mainCamera);
    mainCamera = SafeRetain(_camera);
    SafeRelease(drawCamera);
    drawCamera = SafeRetain(_camera);
}
CommandDrawCustomColors::CommandDrawCustomColors(Image* originalImage, Image* newImage)
:	Command(COMMAND_UNDO_REDO, CommandList::ID_COMMAND_DRAW_CUSTOM_COLORS)
{
	commandName = "Custom Color Draw";

	undoImage = SafeRetain(originalImage);
	redoImage = SafeRetain(newImage);
}
Beispiel #7
0
CommandDrawTilemap::CommandDrawTilemap(Image* originalImage, Image* newImage, const FilePath & pathname, Landscape* landscape)
:	Command(COMMAND_UNDO_REDO, CommandList::ID_COMMAND_DRAW_TILEMAP)
,	landscape(landscape)
{
	commandName = "Tilemap Draw";

	savedPathname = pathname;
    savedPathname.ReplaceExtension(".png");

	undoImage = SafeRetain(originalImage);
	redoImage = SafeRetain(newImage);
}
ActionSetVisibilityPoint::ActionSetVisibilityPoint(Image* originalImage,
												   Sprite* cursorSprite,
												   VisibilityToolProxy* visibilityToolProxy,
												   const Vector2& visibilityPoint)
:	CommandAction(CMDID_VISIBILITY_TOOL_SET_POINT, "Set Visibility Point")
{
//	this->undoImage = SafeRetain(originalImage);
	this->cursorSprite = SafeRetain(cursorSprite);
	this->visibilityToolProxy = SafeRetain(visibilityToolProxy);
//	this->undoVisibilityPoint = visibilityToolProxy->GetVisibilityPoint();
	this->redoVisibilityPoint = visibilityPoint;
//	this->undoVisibilityPointSet = visibilityToolProxy->IsVisibilityPointSet();
}
Beispiel #9
0
Font * GraphicsFont::Clone()
{
    GraphicsFont * cloneFont = new GraphicsFont();

    cloneFont->fdef = SafeRetain(this->fdef);
    cloneFont->fontSprite = SafeRetain(this->fontSprite);

    cloneFont->SetColor(this->GetColor());
    cloneFont->SetVerticalSpacing(this->GetVerticalSpacing());
    cloneFont->SetHorizontalSpacing(this->GetHorizontalSpacing());
    cloneFont->SetSize(this->GetSize());
    cloneFont->fontDefinitionName = this->GetFontDefinitionName();

    return cloneFont;
}
CommandSetVisibilityPoint::CommandSetVisibilityPoint(Image* originalImage,
													 Sprite* cursorSprite,
													 VisibilityToolProxy* visibilityToolProxy,
													 const Vector2& visibilityPoint)
:	Command(COMMAND_WITHOUT_UNDO_EFFECT, CommandList::ID_COMMAND_PLACE_POINT_VISIBILITY_TOOL)
{
	commandName = "Place Visibility Point";

	this->undoImage = SafeRetain(originalImage);
	this->cursorSprite = SafeRetain(cursorSprite);
	this->visibilityToolProxy = SafeRetain(visibilityToolProxy);
	this->undoVisibilityPoint = visibilityToolProxy->GetVisibilityPoint();
	this->redoVisibilityPoint = visibilityPoint;
	this->undoVisibilityPointSet = visibilityToolProxy->IsVisibilityPointSet();
}
void LandscapeEditorCustomColors::ShowAction()
{
    landscapeSize = GetLandscape()->GetTexture(Landscape::TEXTURE_TILE_FULL)->GetWidth();

	workingLandscape->CursorEnable();
	//save fog status and disable it for more convenience
	isFogEnabled = workingLandscape->IsFogEnabled();
	workingLandscape->SetFog(false);
	texSurf = SafeRetain( workingLandscape->GetTexture(Landscape::TEXTURE_TILE_FULL));

	FilePath loadFileName = GetCurrentSaveFileName();
	if(!loadFileName.IsEmpty())
		LoadTextureAction(loadFileName);

	if(NULL == colorSprite)
	{
		Texture* tex =  workingLandscape->GetTexture(Landscape::TEXTURE_TILE_FULL);
		colorSprite = Sprite::CreateAsRenderTarget(tex->width, tex->height, FORMAT_RGBA8888);
		RenderManager::Instance()->SetRenderTarget(colorSprite);
		const Vector<Color> & colors = EditorConfig::Instance()->GetColorPropertyValues("LandscapeCustomColors");
		if(!colors.empty())
		{
			RenderManager::Instance()->ClearWithColor(colors[0].r, colors[0].g, colors[0].b, colors[0].a);
		}
		RenderManager::Instance()->RestoreRenderTarget();
	}

	PerformLandscapeDraw();

	// TODO: mainwindow
	//QtMainWindowHandler::Instance()->SetCustomColorsWidgetsState(true);
}
void LandscapeEditorDrawSystem::SetCursorTexture(Texture* cursorTexture)
{
	SafeRelease(this->cursorTexture);
	this->cursorTexture = SafeRetain(cursorTexture);
	
	landscapeProxy->SetCursorTexture(cursorTexture);
}
ChangeFontPropertyCommandData& ChangeFontPropertyCommandData::operator =(const ChangeFontPropertyCommandData& data)
{
    font = SafeRetain(data.font);
    isApplyToAll = data.isApplyToAll;
    fontPresetOriginalName = data.fontPresetOriginalName;
    fontPresetName = data.fontPresetName;
    
    Map<String, Font*>::const_iterator it = data.localizedFonts.begin();
    Map<String, Font*>::const_iterator endIt = data.localizedFonts.end();
    for(; it != endIt; ++it)
    {
        localizedFonts[it->first] = SafeRetain(it->second);
    }
    
    return *this;
}
	void SkyboxSystem::AddEntity(Entity * entity)
	{
		if((NULL == skyboxEntity) && GetSkybox(entity))
		{
            skyboxEntity = SafeRetain(entity);
		}
	}
Beispiel #15
0
Shader * Shader::RecompileNewInstance(const String & combination)
{
    Shader * shader = new Shader();
    shader->vertexShaderData = SafeRetain(vertexShaderData);
    shader->fragmentShaderData = SafeRetain(fragmentShaderData);
    shader->SetDefineList(combination);
    
	//TODO: return "invalid shader" on error;
	shader->Recompile();
	/*if (!shader->Recompile())
    {
        SafeRelease(shader);
        return 0;
    }*/
    return shader;
}
void TextureListModel::setScene(DAVA::Scene *scene)
{
	beginResetModel();

	clear();

    activeScene = scene;
    
	DAVA::TexturesMap texturesInNode;
	SceneHelper::EnumerateSceneTextures(scene, texturesInNode, SceneHelper::EXCLUDE_NULL);

	for(DAVA::TexturesMap::iterator t = texturesInNode.begin(); t != texturesInNode.end(); ++t)
	{
		DAVA::TextureDescriptor * descriptor = t->second->texDescriptor;
		if(NULL != descriptor && descriptor->pathname.Exists())
		{
			textureDescriptorsAll.push_back(descriptor);
			texturesAll[descriptor] = SafeRetain(t->second);
		}
	}

	applyFilterAndSort();

	endResetModel();
}
void RenderManager::SetCursor(Cursor * _cursor)
{
#if defined(__DAVAENGINE_MACOS__) || (defined(__DAVAENGINE_WIN32__) && defined(__DAVAENGINE_DIRECTX9__))
	SafeRelease(cursor);
	cursor = SafeRetain(_cursor);
	if (cursor)cursor->HardwareSet();
#endif
}
Beispiel #18
0
void ShadowVolumeNode::Load(KeyedArchive * archive, SceneFileV2 * sceneFileV2)
{
	Entity::Load(archive, sceneFileV2);

	uint64 ptr = archive->GetByteArrayAsType("pg", (uint64)0);
	shadowPolygonGroup = dynamic_cast<PolygonGroup*>(sceneFileV2->GetNodeByPointer(ptr));
	SafeRetain(shadowPolygonGroup);
}
void UITextField::SetFont(Font * font)
{
#ifndef __DAVAENGINE_IPHONE__
    SafeRelease(textFont);
    textFont = SafeRetain(font);
    staticText->SetFont(textFont);
#endif
}
RemoveComponentCommand::RemoveComponentCommand(DAVA::Entity* _entity, DAVA::int32 componentType)
	: Command2(CMDID_COMPONENT_REMOVE, "Remove Component")
    , entity(_entity)
{
	DVASSERT(entity);

	oldComponent = SafeRetain(entity->GetComponent(componentType));
}
Beispiel #21
0
bool LandscapeEditorBase::SetScene(EditorScene *newScene)
{
    SafeRelease(workingScene);
    
    workingLandscape = SafeRetain(newScene->GetLandScape(newScene));
    if(!workingLandscape)
    {
        ErrorNotifier::Instance()->ShowError("No landscape at level.");
        return false;
    }
    
    savedShaderMode = workingLandscape->GetTiledShaderMode();
    workingLandscape->SetTiledShaderMode(LandscapeNode::TILED_MODE_TILEMASK);
    
    workingScene = SafeRetain(newScene);
    return true;
}
SoundInstance::SoundInstance(Sound * parent)
:	state(STATE_PLAYING),
    animatedVolume(-1.f),
    parentSound(NULL)
{
	SoundSystem::Instance()->AddSoundInstance(this);
    parentSound = SafeRetain(parent);
}
void UIScrollBar::LoadFromYamlNodeCompleted()
{
	slider = SafeRetain(FindByName(UISCROLLBAR_SLIDER_NAME));
	if (!slider)
	{
		InitControls();
	}
}
InfoControl::InfoControl(UIControl* watched) : UIControl(Rect(0.0f, 0.0f, watched->GetSize().x, watched->GetSize().y), false)
, watchedControl(SafeRetain(watched))
{
    //TODO: remember input enabled
    ParseSpecificInfo();
    watchedControl->SetInputEnabled(false, false);
    
    emptyString = L"";
}
void HierarchyTreeControlNode::RemoveTreeNodeFromScene()
{
    if (!this->GetParent() || !uiObject->GetParent())
    {
        return;
    }

    // Don't touch the subcontrol nodes - they are controlled by the parent control itself.
    List<UIControl*> subControlNodes = uiObject->GetSubcontrols();
    for (HIERARCHYTREENODESLIST::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
    {
        HierarchyTreeControlNode* control = dynamic_cast<HierarchyTreeControlNode*>(*iter);
        if (!control || std::find(subControlNodes.begin(), subControlNodes.end(), control->GetUIObject())
                != subControlNodes.end())
        {
            continue;
        }

        control->RemoveTreeNodeFromScene();
    }

    this->parentUIObject = uiObject->GetParent();
    SafeRetain(this->parentUIObject);

    // Determine the "child above" to return node to scene to the correct position.
    this->childUIObjectAbove = NULL;
    for (List<UIControl*>::const_iterator iter = parentUIObject->GetChildren().begin();
            iter != parentUIObject->GetChildren().end(); iter ++)
    {
        if (((*iter) == uiObject) && (iter != parentUIObject->GetChildren().begin()))
        {
            iter --;
            this->childUIObjectAbove = (*iter);
            break;
        }
    }

    SafeRetain(uiObject);
    this->parentUIObject->RemoveControl(uiObject);

    // We added an additional reference to uiObject and parentUIObject - don't forget
    // to release them in destructor.
    this->needReleaseUIObjects = true;
}
CommandPlacePointVisibilityTool::CommandPlacePointVisibilityTool(const Vector2& newVisibilityPoint, const Vector2& oldVisibilityPoint, bool oldPointIsSet, Image* oldImage)
:	Command(COMMAND_WITHOUT_UNDO_EFFECT, CommandList::ID_COMMAND_PLACE_POINT_VISIBILITY_TOOL)
,	point(newVisibilityPoint)
,	oldPoint(oldVisibilityPoint)
,	oldPointIsSet(oldPointIsSet)
{
	commandName = "Place Visibility Point";

	this->oldImage = SafeRetain(oldImage);
}
CommandPlacePointVisibilityTool::CommandPlacePointVisibilityTool(const Vector2& newVisibilityPoint, const Vector2& oldVisibilityPoint, bool oldPointIsSet, Image* oldImage)
:	Command(COMMAND_WITHOUT_UNDO_EFFECT)
,	point(newVisibilityPoint)
,	oldPoint(oldVisibilityPoint)
,	oldPointIsSet(oldPointIsSet)
{
	commandName = "Place Visibility Point";

	this->oldImage = SafeRetain(oldImage);
}
CommandPlaceAreaVisibilityTool::CommandPlaceAreaVisibilityTool(const Vector2& areaPoint, uint32 areaSize, Image* oldImage)
:	Command(COMMAND_WITHOUT_UNDO_EFFECT),
	point(areaPoint),
	size(areaSize),
	redoImage(NULL)
{
	commandName = "Place Visibility Area";

	this->oldImage = SafeRetain(oldImage);
}
bool LandscapeEditorBase::SetScene(EditorScene *newScene)
{
    SafeRelease(workingScene);
    
    workingLandscape = SafeRetain(newScene->GetLandscape(newScene));
	workingLandscapeEntity = SafeRetain(newScene->GetLandscapeNode(newScene));

    if(!workingLandscape)
    {
        ShowErrorDialog(String("No landscape at level."));
        return false;
    }
    
    savedShaderMode = workingLandscape->GetTiledShaderMode();
    workingLandscape->SetTiledShaderMode(Landscape::TILED_MODE_TILEMASK);
    
    workingScene = SafeRetain(newScene);
    return true;
}
Beispiel #30
0
void UISlider::AddControl(UIControl *control)
{
    // Synchronize the pointers to the thumb each time new control is added.
    UIControl::AddControl(control);

    if (control->GetName() == UISLIDER_THUMB_SPRITE_CONTROL_NAME && thumbButton != control)
    {
        SafeRelease(thumbButton);
        thumbButton = SafeRetain(control);
    }
}