Example #1
0
/* TextureEditorPanel::replacePatch
 * Prompts the user to select a patch from the patch table to replace
 * selectes patch(es) with
 *******************************************************************/
void TextureEditorPanel::replacePatch()
{
	// Get selection
	wxArrayInt selection = list_patches->selectedItems();

	// Do nothing if no patches are selected
	if (selection.size() == 0)
		return;

	// Get first selected patch name (for browser)
	string pname = tex_canvas->getTexture()->getPatch(selection[0])->getName();

	// Browse for patch
	int patch = tx_editor->browsePatchTable(pname);
	if (patch >= 0)
	{
		// Go through selection and replace each patch
		for (size_t a = 0; a < selection.size(); a++)
			tex_current->replacePatch(selection[a], tx_editor->patchTable().patchName(patch));
	}

	// Repopulate patch list
	populatePatchList();

	// Restore selection
	for (size_t a = 0; a < selection.size(); a++)
		list_patches->selectItem(selection[a]);

	// Update UI
	updatePatchControls();

	tex_modified = true;
}
Example #2
0
/* TextureEditorPanel::duplicatePatch
 * Duplicates selected patch(es) in the current texture (each
 * duplication is placed 8 units right+down from its original patch)
 *******************************************************************/
void TextureEditorPanel::duplicatePatch(int xoff, int yoff)
{
	// Get selection
	wxArrayInt selection = list_patches->selectedItems();

	// Do nothing if no patches are selected
	if (selection.size() == 0)
		return;

	// Go through selection backwards
	for (int a = selection.size()-1; a >= 0; a--)
	{
		// Duplicate selected patch
		tex_current->duplicatePatch(selection[a], xoff, yoff);
	}

	// Repopulate patch list
	populatePatchList();

	// Update selection
	int offset = 1;
	for (size_t a = 0; a < selection.size(); a++)
	{
		list_patches->selectItem(selection[a] + offset);
		offset++;
	}

	// Update UI
	updatePatchControls();

	tex_modified = true;
}
Example #3
0
/* TextureEditorPanel::openTexture
 * Loads a TEXTUREX format texture into the editor
 *******************************************************************/
bool TextureEditorPanel::openTexture(CTexture* tex, TextureXList* list)
{
	// Check texture was given
	if (!tex)
	{
		clearTexture();
		return false;
	}

	// Set as current texture
	if (!tex_current)
		tex_current = new CTexture();
	tex_current->copyTexture(tex);
	tex_current->setList(list);

	// Open texture in canvas
	tex_canvas->openTexture(tex_current, tx_editor->getArchive());

	// Set control values
	updateTextureControls();
	populatePatchList();
	updatePatchControls();

	tex_modified = false;

	return true;
}
/* ZTextureEditorPanel::replacePatch
 * Prompts the user to select a patch any open resource to replace
 * selectes patch(es) with
 *******************************************************************/
void ZTextureEditorPanel::replacePatch()
{
	// Get selection
	wxArrayInt selection = list_patches->selectedItems();

	// Do nothing if no patches are selected
	if (selection.size() == 0)
		return;

	// Browse for patch
	string patch = tx_editor->browsePatchEntry();
	if (!patch.IsEmpty())
	{
		// Go through selection and replace each patch
		for (size_t a = 0; a < selection.size(); a++)
			tex_current->replacePatch(selection[a], patch);
	}

	// Repopulate patch list
	populatePatchList();

	// Restore selection
	for (size_t a = 0; a < selection.size(); a++)
		list_patches->selectItem(selection[a]);

	// Update UI
	updatePatchControls();

	tex_modified = true;
}
Example #5
0
/* TextureEditorPanel::clearTexture
 * Clears the current texture
 *******************************************************************/
void TextureEditorPanel::clearTexture()
{
	// Clear texture
	if (tex_current)
		delete tex_current;
	tex_canvas->clearTexture();

	// Update variables
	tex_current = NULL;
	tex_modified = false;

	// Set control values
	updateTextureControls();
	populatePatchList();
	updatePatchControls();
}
Example #6
0
/* TextureEditorPanel::addPatch
 * Prompts the user to select a patch from the patch table to be
 * added to the current texture
 *******************************************************************/
void TextureEditorPanel::addPatch()
{
	// Do nothing if patch list is empty
	if (tx_editor->patchTable().nPatches() == 0 || !tex_current)
		return;

	// Browse for patch
	int patch = tx_editor->browsePatchTable();
	if (patch >= 0)
	{
		// Add new patch
		tex_current->addPatch(tx_editor->patchTable().patchName(patch), 0, 0);

		// Update UI
		populatePatchList();
		updatePatchControls();
	}

	tex_modified = true;
}
/* ZTextureEditorPanel::addPatch
 * Prompts the user to select a patch from any open resources to be
 * added to the current texture
 *******************************************************************/
void ZTextureEditorPanel::addPatch()
{
	// Do nothing if no texture is open
	if (!tex_current)
		return;

	// Browse for patch
	string patch = tx_editor->browsePatchEntry();
	if (!patch.IsEmpty())
	{
		// Add new patch
		tex_current->addPatch(patch, 0, 0);

		// Update UI
		populatePatchList();
		updatePatchControls();
	}

	tex_modified = true;
}