New GUI skin [update: new skins, support for 1.5/1.6]

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

good job on this one. i like it.
madoc
Posts: 32
Joined: Fri Feb 11, 2005 10:43 am

Post by madoc »

No engine patch is required, theres 2 ways to fix the problem with the checkboxes.
One is the right way, by fixing the file in irrlicht and recompile, and then submit patch so it can be fixed forever and ever.
I didn't do it that way, the way I did it was overload the function that was causing the problem and fix it that way :)
So no patch required :)
madoc
Posts: 32
Joined: Fri Feb 11, 2005 10:43 am

Checkbox fix

Post by madoc »

Code: Select all


void CImageGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
    const core::position2di position, u32 starttime, u32 currenttime, 
    bool loop, const core::rect<s32>* clip)
{
	
	// Patch to make checkbox and radio color come from gui::EGDC_WINDOW_SYMBOL -- Madoc
	if(icon == gui::EGDI_CHECK_BOX_CHECKED || icon == gui::EGDI_RADIO_BUTTON_CHECKED) {
		FallbackSkin->getSpriteBank()->draw2DSprite( FallbackSkin->getIcon(icon),
			position,
			clip,
			getColor(gui::EGDC_WINDOW_SYMBOL),
			starttime,
			currenttime,
			loop,
			true);
		
	}
    else FallbackSkin->drawIcon(element,icon,position,starttime,currenttime,loop,clip);
}

Heres just the checkbox fix, if your using my stuff you don't need this.
If your using pure fuzzyspoon, you can replace this function if yours and checkboxes and radio buttons (their broken too, just dosnt show in demo) will then have their color come off of EGDC_WINDOW_SYMBOL
bayofxyz
Posts: 5
Joined: Sun Sep 28, 2008 5:58 pm

I wanna delete that line.

Post by bayofxyz »

Image
From my picture, I want to delete that white line. how to do that :?
Mloren
Posts: 114
Joined: Mon Aug 07, 2006 2:30 am
Location: Australia
Contact:

Post by Mloren »

Thanks so much to madoc and Fuzzyspoon for creating this, its exactly what I needed for my project.
I've made quite a few updates to it:

New version can be downloaded here:
Download

New Features
Can now separately specify the appearance of the following elements:
Disabled buttons
The active Tab button
Context menus
Checkboxes
Disabled Checkboxes
Comboboxes
Disabled Comboboxes

Can also specify the color of the tick in the checkbox

Bug Fixes
Fixed the Fallback skin setting which wasn't working correctly (it was always using EGST_WINDOWS_METALLIC regardless of what was specified in the .xml)
Fixed bug where getValueAsColor() would return 0 if any channel of the color was 0, so colors like 0xFFFF0000 (red) were coming out as transparent black.

For my own project, I also created a Windows XP skin which is included in the above download, it uses all of the new features so you can look at it for an example:

Image
I don't need the progress bar so I haven't changed its texture.

There is also a bug in irrlicht which prevents Comboboxes from looking correct when disabled: their button component doesn't get disabled so it looks weird. I've added a magic function to fix this called SetComboBoxEnabled(). You just call that and pass in the pointer to the combobox instead of using the normal combobox setEnabled() function and it makes it look correct. This new function is in the CMain.cpp file in the above download but here's the code as well:

Code: Select all

static void SetComboBoxEnabled(gui::IGUISkin* pSkin, gui::IGUIComboBox* pComboBox, bool bEnabled)
{
	pComboBox->setEnabled(bEnabled);
		
	core::list<gui::IGUIElement*> aChildren = pComboBox->getChildren();
	for(core::list<gui::IGUIElement*>::Iterator itter = aChildren.begin(); itter != aChildren.end(); ++itter)
	{
		if((*itter)->getType() == gui::EGUIET_BUTTON)
		{
			(*itter)->setEnabled(bEnabled);

			if(bEnabled)
				((gui::IGUIButton*)(*itter))->setSprite(gui::EGBS_BUTTON_UP, pSkin->getIcon(gui::EGDI_CURSOR_DOWN), pSkin->getColor(gui::EGDC_WINDOW_SYMBOL));
			else
				((gui::IGUIButton*)(*itter))->setSprite(gui::EGBS_BUTTON_UP, pSkin->getIcon(gui::EGDI_CURSOR_DOWN), pSkin->getColor(gui::EGDC_GRAY_TEXT));
		}
	}
}
I hope people find this useful :)
Amaroker
Posts: 5
Joined: Sat Nov 15, 2008 11:46 am

Post by Amaroker »

Thanks Mloren.

I got some memory leaks, so just had to modify code to delete CXMLRegistry
and CXMLNodes. Also, CGUISkinSystem::applySkin and populateTreeView can return if load fails and in this case will not delete. Anyway, easy to fix.

Any idea how to get the reflection effect seen in Fuzzyspoon's screenshot? (http://img27.imageshack.us/img27/3359/previewmoa.jpg)
Mloren
Posts: 114
Joined: Mon Aug 07, 2006 2:30 am
Location: Australia
Contact:

Post by Mloren »

Sorry didn't see this until now, can you be more specific about these memory leaks, I didn't notice any and I have a memory leak tracker that didn't pick anything up.

I'm not sure where that reflection comes from, it is not a part of the skin system as far as I am aware, it must be something else he has going.
lostgdi
Posts: 5
Joined: Wed Jan 05, 2011 12:28 pm

Post by lostgdi »

:D that is cool
Post Reply