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.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Textures have 2 different methods for obtaining sizes. One obtains the original size of the actual image, and the other contains the (possibly) increased size to the nearest power of 2 if the texture was required to be a power of 2.

Something like getDimensions and getOriginalDimensions ? I think the wording was slightly different though... (Checks API)
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
sp00n
Posts: 114
Joined: Wed Sep 13, 2006 9:39 am

Post by sp00n »

About darker colors - it's true, when i use same texture for skin's window and IGUIImage first looks darker:(
in function

Code: Select all

void CImageGUISkin::drawElementStyle( const SImageGUIElementStyle& elem, const core::rect<s32>& rect, const core::rect<s32>* clip, video::SColor* pcolor  )
we have those lines:

Code: Select all

video::SColor faceColor = getColor(EGDC_3D_FACE);
color.setRed( (u8)(color.getRed() * faceColor.getRed() / 255) );
color.setGreen( (u8)(color.getGreen() * faceColor.getGreen() / 255) );
color.setBlue( (u8)(color.getBlue() * faceColor.getBlue() / 255) );
color.setAlpha( (u8)(color.getAlpha() * faceColor.getAlpha() / 255 ) );
as i see here's a problem, but if we comment this piece we'll lose a transparency. Has somebody any ideas? :)
p.s. when we change to

Code: Select all

video::SColor faceColor = getColor(EGDC_3D_LIGHT);
it works nice for me, but i think there will be a problems not are?

p.p.s. oh, i understood this part of code :) for my goal it needs to make more switch-cases to draw different elements with right colors ... and parts of elements too like window's corners and caption etc :(
doqkhanh
Posts: 158
Joined: Sat Mar 01, 2008 3:14 am
Location: Tokyo, Japan
Contact:

Post by doqkhanh »

Is there anybody attempt to fix this error? I am using a Intel Q35 Express with Intel GMA 3100 and my system is well new...

Image
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

Try downloading it again. I resized two of the textures to have a power-of-two width. I still think it's a bug in Irrlicht, that it uses coordinates after resizing, instead of remembering its original size.
doqkhanh
Posts: 158
Joined: Sat Mar 01, 2008 3:14 am
Location: Tokyo, Japan
Contact:

Post by doqkhanh »

Klasker wrote:Try downloading it again. I resized two of the textures to have a power-of-two width. I still think it's a bug in Irrlicht, that it uses coordinates after resizing, instead of remembering its original size.
:shock: That's it!!! Everything is ok now!
maitrelame2
Posts: 26
Joined: Sun Jan 21, 2007 9:11 pm

Post by maitrelame2 »

How do you change the arrows for a list box ?

Thanks for the good work
Irrlicht 4ever.
kernelpanic
Posts: 2
Joined: Fri Aug 01, 2008 5:16 pm
Location: Guatemala

Very Nice

Post by kernelpanic »

Nice Skin... Remembers me the blender. :D
-[o].[o]-
Is3dpic
Posts: 16
Joined: Mon Aug 25, 2008 6:12 pm

Post by Is3dpic »

Klasker wrote: It's a nice looking skin, and works pretty well with the GUI editor too-
Image
hi,
how do you get this GUI Editor ? please :)
thanks!
instinct
Posts: 87
Joined: Sat May 10, 2008 3:42 pm

Post by instinct »

when i try to implement this in my project, i get these errors. Im using Irrlicht version 1.4, but somehow get these errors:

Code: Select all

Compiling...
UI.cpp
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(10) : error C2039: 'SImageGUISkinConfig' : is not a member of 'irr::gui'
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(10) : error C2065: 'SImageGUISkinConfig' : undeclared identifier
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(10) : error C2146: syntax error : missing ';' before identifier 'guicfg'
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(10) : error C2065: 'guicfg' : undeclared identifier
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(10) : error C3861: 'LoadGUISkinFromFile': identifier not found
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(11) : error C2039: 'CImageGUISkin' : is not a member of 'irr::gui'
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(11) : error C2065: 'CImageGUISkin' : undeclared identifier
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(11) : error C2065: 'skin' : undeclared identifier
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(11) : error C2039: 'CImageGUISkin' : is not a member of 'irr::gui'
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(11) : error C2061: syntax error : identifier 'CImageGUISkin'
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(12) : error C2227: left of '->loadConfig' must point to class/struct/union/generic type
        type is ''unknown-type''
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(18) : error C2227: left of '->setFont' must point to class/struct/union/generic type
        type is ''unknown-type''
..\..\..\..\..\Desktop\GAME\svn\Source\CPP en H files\Game\UI.cpp(21) : error C2227: left of '->drop' must point to class/struct/union/generic type
        type is ''unknown-type''
Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\game\game\Debug\BuildLog.htm"
game - 13 error(s), 0 warning(s)
Seems like it doesnt recognize CImageGUISkin and SImageGUISkinConfig, i have no clue where i should look to solve this so i figured i could ask you here :)

This is my UI class

Code: Select all

#include "UI.h"

// Player players[2];

UI::UI(IrrlichtDevice* device)
{
	this->device = device;
	this->env = device->getGUIEnvironment();

	gui::SImageGUISkinConfig guicfg = LoadGUISkinFromFile(device->getFileSystem(), device->getVideoDriver(), "media/ui/guiskin.cfg");
    gui::CImageGUISkin* skin = new gui::CImageGUISkin(driver, env->getSkin());
    skin->loadConfig(guicfg);

	//IGUISkin* skin = env->getSkin();

	gui::IGUIFont* font = env->getFont("media/ui/fontlucida.png");
    if (font != 0)
		skin->setFont(font, gui::EGDF_DEFAULT);

	env->setSkin(skin);
	skin->drop();
}

// type	getPlayers()
// {
// }

void UI::showHighScores()
{
}

void UI::showPlayerCreationScreen()
{
}

void UI::showMultiPlayerSelectionScreen()
{
}

void UI::showSinglePlayerSelectionScreen()
{
	env->addStaticText(L"Quick SinglePlayer Select", rect<s32>(300,260,400,269), false);
	IGUIListBox* playerlistbox = env->addListBox(rect<s32>(250, 270, 550, 370), 0, 5, true);
	playerlistbox->addItem(L"Yannick");
	playerlistbox->addItem(L"Rutger");
}

void UI::showStartScreen()
{
	device->setWindowCaption(L"user interface van de game");
	IVideoDriver *driver = device->getVideoDriver();
	IGUIEnvironment *env = device->getGUIEnvironment();

	env->addStaticText(L"Onze naamloze game", rect<s32>(50,20,200,40), false);

	env->addButton(rect<s32>(10,110,200,140), 0, 1, L"Single player");
	env->addButton(rect<s32>(10,160,200,190), 0, 2, L"Multi player");
	env->addButton(rect<s32>(10,210,200,240), 0, 3, L"Highscores");
	env->addButton(rect<s32>(10,260,200,290), 0, 4, L"Select player");		

	env->addImage(driver->getTexture("UI testplaatje.jpg"), position2d<int>(300,100));

}
kingdutch
Posts: 76
Joined: Tue Sep 02, 2008 7:01 am

Post by kingdutch »

stodge wrote:
Dances wrote::roll: Maybe you need to turn up the brightness/contrast on your monitor. If you've already done that, then its time to buy a new one.
:roll:
:roll:
Nuf said
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

hey,

i just tried this snipped with 1.4.2 and find it great? What would be needed to get it into irrlicht?

I thought about maybe rewriting the config file to xml and zipping everything to a .skin folder.
But then again i don't know if there is any possiblity to have something like this inside irrlicht.

Instead of containing a FallbackSkin it maybe should inheirt from one of Irrlichts skins and only override certain functions?

greetings,
Halan
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

Hey,

i started working on simplyfing the whole class.

I would like to request spereate draw calls for the background of progress bars and check boxes.
Also the ablility of the xml read to read Colors or Positions.

This is how the config file looks now (imo much cleaner)

Code: Select all

<!-- Config file for the GUI Skin
 Source border is the border width (in pixels) on the texture.
 Dest border is the border width on the screen (also in pixels).
-->

<?xml version="1.0"?>

<guiskin>
	<element name="Button">
		<texture>button.png</texture>
		<srcBorder top="10" left="10" bottom="10" right="10">
		<dstBorder top="10" left="10" bottom="10" right="10">
	</element>

	<element name="ButtonPressed">
		<texture>button.png</texture>
		<srcBorder top="10" left="10" bottom="10" right="10">
		<dstBorder top="10" left="10" bottom="10" right="10">
		<color alpha="255" red="196" green="196" blue="196">
	</element>

	<element name="SunkenPane">
		<texture>sunkenpane.png</texture>
		<srcBorder top="32" left="32" bottom="32" right="32">
		<dstBorder top="10" left="10" bottom="10" right="10">
	</element>

	<element name="Window">
		<texture>windowbg.png</texture>
		<srcBorder top="25" left="10" bottom="10" right="10">
		<dstBorder top="25" left="10" bottom="10" right="10">
	</element>

	<element name="ProgressBar">
		<texture>gauge.png</texture>
		<srcBorder top="16" left="16" bottom="16" right="16">
		<dstBorder top="16" left="16" bottom="16" right="16">
	</element>

	<element name="ProgressBarFilled">
		<texture>gauge.png</texture>
		<srcBorder top="16" left="16" bottom="16" right="16">
		<dstBorder top="16" left="16" bottom="16" right="16">
	</element>
</guiskin>
nice?

greets,
Halan

edit: also I'm wondering if the bug that he fixed with clipRects.h is still there.
Leomond
Posts: 2
Joined: Wed Dec 17, 2008 5:45 pm
Contact:

Irrlicht 1.5

Post by Leomond »

Hello : )

I just updated to irrlicht 1.5 and got the error related to the abstract class.

Here are the litle changes I made to make it compile:

Add this to the CImageGUISkin.h

Code: Select all

virtual void draw3DTabButton(IGUIElement* element, bool active,
			const core::rect<s32>& rect, const core::rect<s32>* clip=0, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT);

virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
			const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT );
Added this to the CImageGUISkin.cpp

Code: Select all

void CImageGUISkin::draw3DTabButton(IGUIElement* element, bool active,
	const core::rect<s32>& rect, const core::rect<s32>* clip, gui::EGUI_ALIGNMENT alignment)
{
	FallbackSkin->draw3DTabButton(element, active, rect, clip, alignment);
}

void CImageGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background,
			const core::rect<s32>& rect, const core::rect<s32>* clip, s32 tabHeight, gui::EGUI_ALIGNMENT alignment)
{
	FallbackSkin->draw3DTabBody(element, border, background, rect, clip, tabHeight, alignment);
}
It was simple like that.
I hope this is useful to someone.
GameDude
Posts: 498
Joined: Thu May 24, 2007 12:24 am

Post by GameDude »

That looks pretty cool, I'll have to look into it sometime
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

GameDude wrote:That looks pretty cool, I'll have to look into it sometime
You can also look into my improved version ;)

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=30912
Post Reply