Game Development Community

dev|Pro Game Development Curriculum

Cloning textures with operations in Terrain Texture Editor

by Thomas Huehn · 11/13/2006 (4:42 pm) · 0 comments

If you want to move a Project into another Mod-Directory the .ter file still have the
old path in the textures. After i got mad manual cloning the textures/operations i added
a clone function to creator/editor/EditorGui.cs . This also helps if you want to replace a
texture. I know a rename of the texture-filename would be easier but this also works fine.


1.) Add the clone Button after the delete button in creator/editor/EditorGui.gui at about line 3085

----
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "90 3";
extent = "53 20";
minExtent = "8 8";
visible = "1";
command = "Texture::CloneMaterialTexture();";
helpTag = "0";
text = "Clone";
groupNum = "-1";
buttonType = "PushButton";
};

----

2.) Adding the source to creator/editor/EditorGui.cs

----

function Texture::CloneMaterialTexture()
{
%root = filePath(terrain.terrainFile);
getLoadFilename("*.png\t*.jpg", cloneLoadedMaterial);
}

function cloneLoadedMaterial(%file)
{
%data = Texture_material.getRowTextById($selectedMaterial);
Texture::saveMaterial();
Texture::hideTab();
%text = filePath(%file) @ "/" @ fileBase(%file);
%id = Texture::addMaterial(%text @ "\t" @ $nextTextureRegister++);
if (%id != -1)
{
Texture_material.setSelectedById(%id);
%recordCount = getRecordCount(%data);
for (%record=1; %record<%recordCount; %record++)
{
%entry = getRecord(%data, %record);
Texture_operation.addRow($nextTextureId++, %entry);
}
}
Texture::save();
}

----

After cloning just click on the cloned line and the preview appears correctly.