Page 1 of 2

(C++) icon/slot drag/drop rpg style gui

Posted: Mon Jul 09, 2007 6:57 pm
by JonLT
I gui thing intented to be like a rpg gui. Move around icons in slots.

Image

Included in the zip:
- CGUIIcon: The icon that can be moved between slots
- CGUIIconSlot: The slot to put the icon in
- CGUISlotWindow: A window with slots
- CGUIBringUpSlotWindowButton: A button to show/hide the slot window.

The button and the window is almost just copies of the original irrlicht gui, but with a few changes.

Slots can also just be added as children of a normal gui window.

How to use:

Code: Select all

//create a slot window
CGUISlotWindow* window = new CGUISlotWindow(device, gui->getRootGUIElement(), -1, rect<s32>(25, 25, 300, 200));
window->drop();

//create a button to show/hide the window
IGUIButton* button = window->createBringUpButton(rect<s32>(10,210,110,242));
button->drop();

//load some very beautiful textures
ITexture* slotTex = driver->getTexture("slot.png");
ITexture* iconTex2 = driver->getTexture("icon.png");
ITexture* iconTex2 = driver->getTexture("icon2.png");

//create an array of slots in the window
core::array<IGUIElement*> slotArray = window->addSlotArray(core::rect<s32>(0,0,32,32), slotTex, 0, -1,
core::position2d<s32>(10,30),core::dimension2d<s32>(6,3),core::dimension2d<s32>(10,10));

//create an icon
CGUIIcon *icon = new CGUIIcon(gui, gui->getRootGUIElement(), -1, rect<s32>(0,0,32,32));
icon->drop();
icon->setImage(iconTex);

//create another icon
CGUIIcon *icon2 = new CGUIIcon(gui, gui->getRootGUIElement(), -1, rect<s32>(0,0,32,32));
icon2->drop();
icon2->setImage(iconTex2);

//let the icons know about the slots
icon->setUsableSlotArray(&slotArray);
icon2->setUsableSlotArray(&slotArray);
--Slots.zip--

Enjoy!

Posted: Mon Jul 09, 2007 10:13 pm
by dawasw
Babe, I love you.

Posted: Mon Jul 09, 2007 11:29 pm
by Midnight
dawasw wrote:Babe, I love you.
wtf :shock: :?

Posted: Tue Jul 10, 2007 12:02 am
by iZigoo
Cool !

Looks very useful ...

I will try it !

:D

Posted: Tue Jul 10, 2007 1:06 pm
by JonLT
Thanks!
You have to be carfull with assigning the array returned by the window to a icon though. If the array runs out of scope, the icon will have a dangeling pointer. Maybe the window should return something else, I will look in to this when i get the time!

Posted: Tue Jul 10, 2007 1:16 pm
by bitplane
argh! I just started an icon the other day!
well, mine's more like a desktop icon, for future tree and list elements.. It's the main reason I made the edit box support multiple lines and text alignment.
Perhaps we could merge them, if at all possible?

edit: oh yes, i can feel a merge coming on :)
I've started a factory for all kinds of icon-based elements, which means listviews, treeviews, these slots and windows, and anything else we can think of!
I'll commit it to the plugins svn as soon as I've got it working, but it probably means butchering a lot of your code.. i apologise in advance for that ;)

here's the generic icon in action..
Image
i'll steal your drag/drop code and make it event based. i'll add a thumbnail style texture-based layout (it's currently animated sprite based) with no text to emulate your icons, and make it resize to fit in a slot.

Posted: Thu Jul 12, 2007 2:37 am
by BlindSide
Whoa nice, both of you.

Posted: Wed Aug 01, 2007 10:41 pm
by MolokoTheMole
Hey,
Could you repost the download, it isn't available anymore.

Posted: Mon Aug 13, 2007 11:49 am
by JonLT
sorry.. my computer is in pieces at the moment, and for some reason the files has been deleted from the server? I'll put it back in as soon as i have my computer in one piece.

Posted: Mon Aug 13, 2007 12:56 pm
by dawasw
An alternative host to download slots ;) :

http://filebeam.com/402b9a1fc3d69d510f2ac2510e728e75

Posted: Fri Aug 17, 2007 4:32 pm
by JonLT
thanks!
the link in the initial post should also work now

Posted: Fri Jun 20, 2008 6:52 am
by doqkhanh
:shock: so cool !

Posted: Fri Jun 20, 2008 7:48 am
by B@z
hi.
could you repost the image too? xD
wanna see before download it :D

Updated new link

Posted: Sat Jun 21, 2008 5:46 am
by doqkhanh
I am using 1.4.1

New edition compile well with Irrlicht 1.4.1: http://doqkhanh.googlepages.com/CGUIBri ... Button.zip

I have const SEvent& event instead of event now.

Code: Select all

//! called if an event happened.
		virtual bool OnEvent(const SEvent& event);

Code: Select all

1>CGUISlotWindow.cpp
1>c:\documents and settings\quockhanh\デスクトップ\cguiicon\cguislotwindow.cpp(233) : error C2259: 'irr::gui::CGUIBringUpSlotWindowButton' : cannot instantiate abstract class
1>        due to following members:
1>        'bool irr::gui::IGUIButton::isPressed(void) const' : is abstract
1>        d:\engine\irrlicht-1.4\include\iguibutton.h(113) : see declaration of 'irr::gui::IGUIButton::isPressed'
1>        'bool irr::gui::IGUIButton::isAlphaChannelUsed(void) const' : is abstract
1>        d:\engine\irrlicht-1.4\include\iguibutton.h(119) : see declaration of 'irr::gui::IGUIButton::isAlphaChannelUsed'
1>        'bool irr::gui::IGUIButton::isPushButton(void) const' : is abstract
1>        d:\engine\irrlicht-1.4\include\iguibutton.h(122) : see declaration of 'irr::gui::IGUIButton::isPushButton'
1>        'bool irr::gui::IGUIButton::isDrawingBorder(void) const' : is abstract
1>        d:\engine\irrlicht-1.4\include\iguibutton.h(128) : see declaration of 'irr::gui::IGUIButton::isDrawingBorder'
Solution

Code: Select all

//! Returns if the alpha channel should be used for drawing images on the button
		virtual bool isAlphaChannelUsed() const;

AND 

//! Returns if the alpha channel should be used for drawing images on the button
bool CGUIBringUpSlotWindowButton::isAlphaChannelUsed() const
{
	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
	return UseAlphaChannel;
}
instead of

Code: Select all

//! Returns if the alpha channel should be used for drawing images on the button
		virtual bool isAlphaChannelUsed();


//! Returns if the alpha channel should be used for drawing images on the button
bool CGUIBringUpSlotWindowButton::isAlphaChannelUsed() 
{
	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
	return UseAlphaChannel;
}
The same with 4 error method.

Edit: New link has been updated

Posted: Sat Jun 21, 2008 8:34 am
by B@z
HTTP1.1 STATUS 403 Remote Access to this object forbidden

Direct Access Forbidden
This file cannot be directly accessed from a remote site, but must be linked through the Brinkster Member's site.