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

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

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

Post 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!
Last edited by JonLT on Fri Aug 17, 2007 4:33 pm, edited 1 time in total.
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

Babe, I love you.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

dawasw wrote:Babe, I love you.
wtf :shock: :?
iZigoo
Posts: 53
Joined: Fri Feb 23, 2007 1:32 pm

Post by iZigoo »

Cool !

Looks very useful ...

I will try it !

:D
-------------------------------------------------------
iZigoo - The open 3D internet

iZigoo Homepage
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post 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!
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Whoa nice, both of you.
MolokoTheMole
Posts: 109
Joined: Tue Jan 09, 2007 1:18 pm

Post by MolokoTheMole »

Hey,
Could you repost the download, it isn't available anymore.
Crimson Glory full Irrlicht game source code!
What I Do - my blog & dev log
Currently developing Link-Dead
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post 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.
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

An alternative host to download slots ;) :

http://filebeam.com/402b9a1fc3d69d510f2ac2510e728e75
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post by JonLT »

thanks!
the link in the initial post should also work now
doqkhanh
Posts: 158
Joined: Sat Mar 01, 2008 3:14 am
Location: Tokyo, Japan
Contact:

Post by doqkhanh »

:shock: so cool !
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

hi.
could you repost the image too? xD
wanna see before download it :D
doqkhanh
Posts: 158
Joined: Sat Mar 01, 2008 3:14 am
Location: Tokyo, Japan
Contact:

Updated new link

Post 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
Last edited by doqkhanh on Sat Jun 21, 2008 9:16 am, edited 1 time in total.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post 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.
Post Reply