Commit 45bd6a77 authored by Gerstrong's avatar Gerstrong

Added more elements for the special selection box after Keen died

parent 020be55b
......@@ -31,6 +31,12 @@ struct EventExitLevel : CEvent {
EventExitLevel(const uint16_t l, const bool s) : levelObject(l), sucess(s){}
};
struct EventRestartLevel : CEvent {
const uint16_t levelObject;
EventRestartLevel(const uint16_t l) : levelObject(l) {}
};
struct EventPlayerEndLevel : CEvent {
const uint16_t levelObject;
const bool sucess;
......@@ -62,9 +68,18 @@ struct EventSendBitmapDialogMsg : CEvent {
{}
};
/**
* \description small structure which holds a matching selection text to an event.
* It is used
*/
struct TextEventMatchOption
{
std::string text;
SmartPointer<CEvent> event;
};
/**
* \description This event triggers a MessageBox where you can select multiple item
* \description This event triggers a MessageBox where you can select multiple items
*
* \param Message This Text will be shown when the Box is triggered
* \param OptionStrings The Text to the option which can be selected
......@@ -72,21 +87,15 @@ struct EventSendBitmapDialogMsg : CEvent {
*/
struct EventSendSelectionDialogMsg : CEvent {
struct Option
{
std::string text;
SmartPointer<CEvent> event;
};
const std::string Message;
std::list<Option> Options;
std::list<TextEventMatchOption> Options;
EventSendSelectionDialogMsg(const std::string& lMsg) :
Message(lMsg){}
void addOption(const std::string& ltext, CEvent *levent)
{
Option NewOption;
TextEventMatchOption NewOption;
NewOption.text = ltext;
NewOption.event = levent;
Options.push_back(NewOption);
......
......@@ -10,6 +10,7 @@
#include "graphics/CGfxEngine.h"
#include "dialog/CMessageBoxBitmapGalaxy.h"
#include "dialog/CMessageBoxSelection.h"
#include "sdl/CVideoDriver.h"
#include "sdl/CInput.h"
#include "sdl/sound/CSound.h"
......@@ -142,10 +143,16 @@ void CPlayGameGalaxy::process()
if( EventSendBitmapDialogMsg* ev = EventContainer.occurredEvent<EventSendBitmapDialogMsg>() )
{
MessageBoxQueue.push_back(new CMessageBoxBitmapGalaxy( ev->Msg, ev->BitmapID, ev->Direction ) );
MessageBoxQueue.push_back( new CMessageBoxBitmapGalaxy( ev->Msg, ev->BitmapID, ev->Direction ) );
EventContainer.pop_Event();
}
else if( EventSendSelectionDialogMsg* ev = EventContainer.occurredEvent<EventSendSelectionDialogMsg>() )
{
MessageBoxQueue.push_back( new CMessageBoxSelection( ev->Message, ev->Options ) );
EventContainer.pop_Event();
}
if(MessageBoxQueue.empty())
{
if( EventEnterLevel *ev = EventContainer.occurredEvent<EventEnterLevel>() )
......@@ -163,6 +170,17 @@ void CPlayGameGalaxy::process()
}
EventContainer.pop_Event();
}
else if( EventRestartLevel *ev = EventContainer.occurredEvent<EventEnterLevel>() )
{
// Start a new level!
if(ev->data > 0xC000)
{
const Uint16 NewLevel = ev->data - 0xC000;
g_pMusicPlayer->stop();
m_LevelPlay.loadLevel(NewLevel);
}
EventContainer.pop_Event();
}
else if( EventExitLevel *ev = EventContainer.occurredEvent<EventExitLevel>() )
{
g_pMusicPlayer->stop();
......@@ -194,18 +212,6 @@ void CPlayGameGalaxy::processInput()
}
}
/*
* This processes the rendering over all the other stuff. THis is used for extra messages normally
* blit scrollsurface happens with m_WorldMap or m_LevelPlay
*/
void CPlayGameGalaxy::processRendering()
{
}
void CPlayGameGalaxy::cleanup()
{}
CPlayGameGalaxy::~CPlayGameGalaxy()
{
......
......@@ -987,10 +987,12 @@ void CPlayerLevel::processDead()
m_Inventory.Item.m_lifes--;
setActionForce(A_KEEN_DIE);
// Create the Event Selection screen
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
EventContainer.add( new EventSendSelectionDialogMsg("Loser!") );
EventContainer.add( new EventExitLevel(mp_Map->getLevel(), false) );
EventSendSelectionDialogMsg *pdialogevent = new EventSendSelectionDialogMsg("Loser!");
pdialogevent->addOption("Exit Level", new EventExitLevel(mp_Map->getLevel(), false) );
pdialogevent->addOption("Restart Level", new EventRestartLevel(mp_Map->getLevel()) );
EventContainer.add( pdialogevent );
m_dying = false;
}
......
......@@ -12,8 +12,10 @@
const int FONT_ID = 0;
CMessageBoxSelection::CMessageBoxSelection(const std::string& Text) :
CMessageBoxGalaxy(Text)
CMessageBoxSelection::CMessageBoxSelection( const std::string& Text, const std::list<TextEventMatchOption> &Options ) :
CMessageBoxGalaxy(Text),
m_Options(Options),
m_selection(0)
{
// Center that dialog box
CFont &Font = g_pGfxEngine->getFont(FONT_ID);
......@@ -50,10 +52,33 @@ void CMessageBoxSelection::process()
SDL_Surface *sfc = g_pVideoDriver->mp_VideoEngine->getFGLayerSurface();
// Look, if somebody pressed a button, and close this dialog!
if(g_pInput->getPressedAnyCommand()) {
if(g_pInput->getPressedCommand(IC_JUMP))
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
for( int c=0 ; c<m_selection ; c++ )
m_Options.pop_front();
EventContainer.add( m_Options.front().event );
m_mustclose = true;
return;
}
else if(g_pInput->getPressedCommand(IC_DOWN))
{
if(m_selection >= (m_Options.size()-1) )
m_selection = 0;
else
m_selection++;
}
else if(g_pInput->getPressedCommand(IC_UP))
{
if(m_selection <= 0 )
m_selection = m_Options.size()-1;
else
m_selection--;
}
// Draw the empty Dialog Box
mp_DlgFrame->draw(sfc);
......@@ -65,4 +90,9 @@ void CMessageBoxSelection::process()
// Draw the Text on our surface
for( size_t i=0 ; i<m_Lines.size() ; i++)
g_pGfxEngine->getFont(FONT_ID).drawFont(sfc, m_Lines[i], m_boxrect.x+m_TextPos.x, m_boxrect.y+(i*m_text_height+m_TextPos.y) );
for( size_t i=0 ; i<m_Options.size() ; i++)
g_pGfxEngine->getFont(FONT_ID).drawFont(sfc, m_Options.back().text, m_boxrect.x+m_TextPos.x, m_boxrect.y+((m_Lines.size()+i+1)*m_text_height+m_TextPos.y) );
}
......@@ -9,17 +9,21 @@
#define CMESSAGEBOXSELECTION_H_
#include "CMessageBoxGalaxy.h"
#include "SmartPointer.h"
#include "engine/CEvent.h"
class CMessageBoxSelection : public CMessageBoxGalaxy {
public:
/**
* \brief This constructor creates a typical Keen 4 Message Box with some
* Options that can be selected
* \param Text Message to be shown
*/
CMessageBoxSelection(const std::string& Text);
CMessageBoxSelection( const std::string& Text, const std::list<TextEventMatchOption> &Options );
std::list<TextEventMatchOption> m_Options;
int m_selection;
void process();
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment