Hi all!
I've just completed putting together a rough version of the options menu.
I couldn't have done it without consulting this forum's vast knowledge archive.
At who, here's a pic of the main options screen:
http://i11.photobucket.com/albums/a175/ ... een_v1.jpg
Here's a sub-window once you click an option (I know in the original NES DW 1, you move up and down with gamepad then use button on gamepad to select the option; but I haven't got gamepad support in yet, so only mouse is supported -- that's why they're GUI buttons):
http://i11.photobucket.com/albums/a175/ ... window.jpg
It looks better in motion.
Here's a video demo of options screen in action (only 445,680 bytes; used to be 33,899,328 bytes before I encoded with Windows Movie Maker):
http://rapidshare.de/files/12148056/DW1 ... o.wmv.html
But that's not all, here's the heavily modified irrlicht example 5 that I used to test out the options screen:
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
IrrlichtDevice *device = 0;
video::IVideoDriver* driver = 0;
// globals for CHANGE MESSAGE SPEED menu option
s32 window_102_closeButtonId = 0;
IGUIWindow* window102;
IGUIButton* button106;
// Event Receiver
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* env = device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
// decide what to do when a button is clicked
case EGET_BUTTON_CLICKED:
// CONTINUE A QUEST menu option
if (id == 101)
{
// TODO
return true;
}
// CHANGE MESSAGE SPEED menu option
if (id == 102)
{
// create window
window102 = env->addWindow(rect<s32>(280,370,835,400),
true,
L"Select Saved Game"); // unable to see text
//// add bitmap background to window
IGUISkin* window102Skin = env->getSkin();
// define black color and fully transparent
SColor window102BlackColor(255,0,0,0);
// draw 3D window, set background to transparent
window102Skin->draw3DWindowBackground(window102,
false,
window102BlackColor,
rect<s32>(280,370,835,400));
// load window background top image of the frame)
IGUIImage* window102BackGroundTop = env->addImage(driver->getTexture("media/single_adventure_window_border_top.bmp"),
position2d<int>(400,360));
// load window background bottom image of the frame)
IGUIImage* window102BackGroundBottom = env->addImage(driver->getTexture("media/single_adventure_window_border_bottom.bmp"),
position2d<int>(400,415));
// load window background left image of the frame)
IGUIImage* window102BackGroundLeft = env->addImage(driver->getTexture("media/single_adventure_window_border_left.bmp"),
position2d<int>(400,365));
// load window background right image of the frame)
IGUIImage* window102BackGroundRight = env->addImage(driver->getTexture("media/single_adventure_window_border_right.bmp"),
position2d<int>(775,365));
// add button to represent saved game
button106 = env->addButton(rect<s32>(280,370,820,400),
0,
106,
L"ADVENTURE LOG 1: Jcln");
// assign button to this window (so that it can be removed when window is closed)
window102->addChild(button106);
window102->addChild(window102BackGroundTop);
window102->addChild(window102BackGroundLeft);
window102->addChild(window102BackGroundRight);
window102->addChild(window102BackGroundBottom);
return true;
}
// BEGIN A NEW QUEST menu option
if (id == 103)
{
// TODO
return true;
}
// COPY A QUEST menu option
if (id == 104)
{
// TODO
return true;
}
// ERASE A QUEST menu option
if (id == 105)
{
// TODO
return true;
}
break;
}
}
return false;
}
};
int main()
{
// create device and exit if creation failed
device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(1024, 768));
// could not create selected driver.
if (device == 0) return 1;
// setup the event receiver
MyEventReceiver receiver;
device->setEventReceiver(&receiver);
// set windows caption
device->setWindowCaption(L"DW 1 3D -- Options Menu Test");
// setup video driver
driver = device->getVideoDriver();
// setup and gui environment
IGUIEnvironment* env = device->getGUIEnvironment();
// define white color
SColor color(255,255,255,255);
// change button text to white color
env->getSkin()->setColor(EGDC_BUTTON_TEXT,color);
// define black color
SColor black_color(255,0,0,0);
// set all GUI colors for buttons to black up to button text
for (s32 i=0; i<8; ++i)
{
env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i,black_color);
}
// set all GUI colors for buttons to black after button text
for (s32 i=9; i<EGDC_COUNT; ++i)
{
env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i,black_color);
}
// add buttons to represent options choices
env->addButton(rect<s32>(250,210,790,240), 0, 101, L"CONTINUE A QUEST");
env->addButton(rect<s32>(280,250,820,280), 0, 102, L"CHANGE MESSAGE SPEED");
env->addButton(rect<s32>(255,290,795,320), 0, 103, L"BEGIN A NEW QUEST");
env->addButton(rect<s32>(220,330,760,360), 0, 104, L"COPY A QUEST");
env->addButton(rect<s32>(227,370,767,400), 0, 105, L"ERASE A QUEST");
// set button text to "cleaned" DW 1 font
IGUISkin* skin = env->getSkin();
IGUIFont* font = env->getFont("media/dw1_font_256_normal_20_pts_cleaned.bmp");
if (font) skin->setFont(font);
// execute game loop
while(device->run() && driver)
if (device->isWindowActive())
{
// set scene background to black
driver->beginScene(true, true, SColor(0,0,0,0));
env->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
As you can see, I had to think of something clever to work around not being able to make the inner part of the background image transparent. I ended up cutting up the image into four pieces. Then moving each to the correct coordinates.
Also, I added the button and background image to the sub-window "node" as children so that when the sub-window closes, it removes the buttons and background images. Pretty neat, huh?
...going to bed now -- good night everyone.
