VST DLL Folder and Skins File


#1

I’m using this code to check for the current VST DLL Folder and load a skin file, and open a directory inside it. Where I keep my DATA files. Just sharing. I don’t know if there’s an easier / cleaner way to do this. So if my code is dirty, please, let me know, I’m here to learn too. :oops:

[code] // Read Skin File Positions //
File xFile(File::getSpecialLocation(File::currentExecutableFile));
xFile = xFile.getParentDirectory();
String dPath(xFile.getFullPathName());
dPath.append(T("\Wusik Red Fuse\Skins\Default\Positions.xml"),99);
XmlDocument myDocument = new XmlDocument ( File(dPath) );
if (myDocument != 0)
{
XmlElement
myParentXml = myDocument->getDocumentElement();
forEachXmlChildElement (*myParentXml, child)
{
int Pos[4] = {0,0,0,0};

		Pos[0] = child->getIntAttribute(T("PosX"), Pos[0] );
		Pos[1] = child->getIntAttribute(T("PosY"), Pos[1] );
		Pos[2] = child->getIntAttribute(T("Width"), Pos[2] );
		Pos[3] = child->getIntAttribute(T("Height"), Pos[3] );

		if (child->hasTagName (T("TreeView"))) cTreeView->setBounds (Pos[0],Pos[1],Pos[2],Pos[3]);
		if (child->hasTagName (T("TreeV_Indent"))) cTreeView->setIndentSize(Pos[2]);
		if (child->hasTagName (T("Keyboard"))) midiKeyboard->setBounds (Pos[0],Pos[1],Pos[2],Pos[3]);
		if (child->hasTagName (T("Keyboard_Key"))) midiKeyboard->setKeyWidth(float(Pos[2]));
	}
	
	delete myDocument;
}

// Read Skin File Colours //
String dPath2(xFile.getFullPathName());
dPath2.append(T("\\Wusik Red Fuse\\Skins\\Default\\Colours.xml"),99);
myDocument = new XmlDocument ( File(dPath2) );
if (myDocument != 0)
{
	XmlElement* myParentXml = myDocument->getDocumentElement();
	forEachXmlChildElement (*myParentXml, child)
	{
		if (child->hasTagName (T("Keyboard")))
		{
			midiKeyboard->setColour(MidiKeyboardComponent::whiteNoteColourId, Colour::fromString( child->getStringAttribute(T("whiteNote"),T("000000")) ));
			midiKeyboard->setColour(MidiKeyboardComponent::blackNoteColourId, Colour::fromString( child->getStringAttribute(T("blackNote"),T("000000")) ));
			midiKeyboard->setColour(MidiKeyboardComponent::keySeparatorLineColourId, Colour::fromString( child->getStringAttribute(T("keySeparatorLine"),T("000000")) ));
			midiKeyboard->setColour(MidiKeyboardComponent::mouseOverKeyOverlayColourId, Colour::fromString( child->getStringAttribute(T("mouseOverKeyOverlay"),T("000000")) ));
			midiKeyboard->setColour(MidiKeyboardComponent::keyDownOverlayColourId, Colour::fromString( child->getStringAttribute(T("keyDownOverlay"),T("000000")) ));
			midiKeyboard->setColour(MidiKeyboardComponent::textLabelColourId, Colour::fromString( child->getStringAttribute(T("textLabel"),T("000000")) ));
			midiKeyboard->setColour(MidiKeyboardComponent::upDownButtonBackgroundColourId, Colour::fromString( child->getStringAttribute(T("upDownButtonBack"),T("000000")) ));
			midiKeyboard->setColour(MidiKeyboardComponent::upDownButtonArrowColourId, Colour::fromString( child->getStringAttribute(T("upDownButtonArrow"),T("000000")) ));
		}

		if (child->hasTagName (T("TreeView")))
		{
			cTreeView->setColour(TreeView::backgroundColourId, Colour::fromString( child->getStringAttribute(T("background"),T("000000")) ));
			cTreeView->setColour(TreeView::linesColourId, Colour::fromString( child->getStringAttribute(T("lines"),T("000000")) ));
			cTreeView->setColour(DirectoryContentsDisplayComponent::highlightColourId, Colour::fromString( child->getStringAttribute(T("highlight"),T("000000")) ));
			cTreeView->setColour(DirectoryContentsDisplayComponent::textColourId, Colour::fromString( child->getStringAttribute(T("text"),T("000000")) ));
		}
	}
	
	delete myDocument;
}

[/code]

Wk


#2

Here’s the Positions.xml file: (so far)

[code]<?xml version="1.0" encoding="UTF-8"?>

Wusik Red Fuse Skin

[/code]


#3

And the Colours.xml file: (so far)

[code]<?xml version="1.0" encoding="UTF-8"?>

Wusik Red Fuse Skin - Colours In Hex AARRGGBB Format (Alpha, Red, Green and Blue)

Overlay colours will be overlaid on top of the normal note colour>

[/code]


#4

BTW: this is for the person who is in charge of this board. When using the option, to me, I think at least, it should show with a fixed / preformat font instead of the current one. Unless I’m wrong, if so, just ignore me. :wink:


#5

Maybe it’s just me, but I’d define the schema differently. Here’s a quick example of the direction I would go:

[code]

<?xml version="1.0" encoding="UTF-8"?>

Wusik Red Fuse Skin

500>/X> 20 290 450" ffffffff ff000000 [/code][/code]