Commit 7685f5cf authored by Gerhard Stein's avatar Gerhard Stein Committed by Gerhard Stein

Thumb animation finally added.

parent 6612fd07
......@@ -89,7 +89,7 @@ bool CLevelPlay::loadLevel(const Uint16 level)
const std::string level_text = "LEVEL" + itoa(level) + "_LOAD_TEXT";
const std::string loading_text = gBehaviorEngine.getString(level_text);
showMsgWithBmp( loading_text, "KEENTHUMBSUP", LEFT );
showMsgWithBmp( loading_text, "KEENTHUMBSUPLOADING", LEFT, true );
mMap.drawAll();
......
......@@ -110,19 +110,25 @@ void CMapPlayGalaxy::pumpEvent(const CEvent *evPtr)
void CMapPlayGalaxy::ponderBase(const float deltaT)
{
const bool msgboxactive = mMsgBoxOpen;
bool pause = msgboxactive;
bool oneInvOpen = false;
// Check if the engine need to be paused
for( auto &inv : mInventoryVec)
pause |= inv.showStatus();
{
oneInvOpen |= inv.showStatus();
}
// Animate the tiles of the map
mMap.m_animation_enabled = !pause;
mMap.m_animation_enabled = !oneInvOpen;
if(mMsgBoxOpen)
{
mMap.m_animation_enabled = true;
}
mMap.animateAllTiles();
if(!pause)
if(!oneInvOpen && !mMsgBoxOpen)
{
for( auto obj = mObjectPtr.begin(); obj != mObjectPtr.end() ; obj++)
{
......@@ -183,7 +189,6 @@ void CMapPlayGalaxy::ponderBase(const float deltaT)
}
}
}
void CMapPlayGalaxy::render()
......
......@@ -472,7 +472,7 @@ void CPlayGameGalaxy::pumpEvent(const CEvent *evPtr)
m_WorldMap.loadAndPlayMusic();
}
showMsgWithBmp( loading_text, "KEENTHUMBSUP", LEFT);
showMsgWithBmp( loading_text, "KEENTHUMBSUPLOADING", LEFT, true);
const EventExitLevel &evCopy = *ev;
......
......@@ -54,7 +54,7 @@ bool CWorldMap::init()
if(!gSaveGameController.busy())
{
showMsgWithBmp(loading_text, "KEENTHUMBSUP", LEFT);
showMsgWithBmp(loading_text, "KEENTHUMBSUPLOADING", LEFT, true);
}
mMap.drawAll();
......
......@@ -353,7 +353,8 @@ void CPlayerWM::processMoving()
else
{
// Tell the player he cannot climb yet
showMsgWithBmp(gBehaviorEngine.getString("KEEN_ROPE_REQUIRED"), "KEENTALKING", RIGHT);
showMsgWithBmp(gBehaviorEngine.getString("KEEN_ROPE_REQUIRED"),
"KEENTALKING", RIGHT, false);
moveYDir(-(climbDir<<CSF)/2);
}
}
......@@ -496,7 +497,8 @@ void CPlayerWM::processMoving()
if( !m_cantswim )
{
gSound.playSound( SOUND_CANT_DO, SoundPlayMode::PLAY_PAUSEALL );
showMsgWithBmp(gBehaviorEngine.getString("CANT_SWIM_TEXT"), 105, LEFT);
showMsgWithBmp(gBehaviorEngine.getString("CANT_SWIM_TEXT"),
105, LEFT, false);
m_cantswim = true;
}
......
......@@ -16,9 +16,10 @@ namespace galaxy
const int FONT_ID = 0;
CMessageBoxBitmapGalaxy::CMessageBoxBitmapGalaxy(const std::string& Text,
const GsBitmap &BitmapRef,
const direction_t alignment,
CEvent *closeEv) :
const GsBitmap &BitmapRef,
const direction_t alignment,
const bool animation,
CEvent *closeEv) :
CMessageBoxGalaxy(Text, closeEv),
mBitmap(BitmapRef),
mAlignment(alignment)
......@@ -33,6 +34,15 @@ mAlignment(alignment)
mMBSurface.createRGBSurface(mMBRect);
mMBSurface.makeBlitCompatible();
if(animation)
{
// After 240 time frames the dialog closes automatically
mShowtime = 240;
mMBAnimatedSurface.createRGBSurface(mMBRect);
mMBAnimatedSurface.makeBlitCompatible();
}
}
void CMessageBoxBitmapGalaxy::init()
......@@ -54,31 +64,78 @@ void CMessageBoxBitmapGalaxy::init()
initText(rect);
const Uint16 bmpX = ( mAlignment == LEFT ) ? 10 : mMBRect.w-(mBitmap.width()+32);
mBitmap._draw( bmpX, 10, mMBSurface.getSDLSurface() );
const int scaling = gVideoDriver.getOptimalScaling();
mMBRect.w *= scaling;
mMBRect.h *= scaling;
mMBSurface.scaleTo(mMBRect, filterOptionType(scaling) );
GsRect<Uint16> gameRes = gVideoDriver.getGameResolution();
mMBRect.x = (gameRes.w-mMBRect.w)/2;
mMBRect.y = (gameRes.h-mMBRect.h)/2;
mMBRect.y = (gameRes.h-mMBRect.h)/2;
}
void CMessageBoxBitmapGalaxy::ponder()
{
CMessageBoxGalaxy::ponder();
if(!mMBAnimatedSurface.empty() && mAnimFrame < 6)
{
mAnimtimer++;
void showMsgWithBmp( const std::string &text,
if(mAnimtimer >= 15)
{
mAnimtimer = 0;
std::string bmpStr = "KEENTHUMBSUPLOADING";
bmpStr += itoa(mAnimFrame);
const GsBitmap &bitmapRef = *gGraphics.getBitmapFromStr(bmpStr);
const Uint16 bmpX = 10+mBitmap.width()-bitmapRef.width();
const Uint16 bmpY = 10+mBitmap.height()-bitmapRef.height();
bitmapRef._draw( bmpX, bmpY, mMBSurface.getSDLSurface() );
mAnimFrame++;
}
}
if(mShowtime > 0)
{
mShowtime--;
if(mShowtime == 0)
{
std::shared_ptr<CEvent> ev(std::move(mCloseEv));
gEventManager.add( ev );
mMustClose = true;
}
}
}
void CMessageBoxBitmapGalaxy::render()
{
CMessageBoxGalaxy::render();
if(!mMBAnimatedSurface.empty())
{
BlitSurface(mMBAnimatedSurface.getSDLSurface(), nullptr,
gVideoDriver.getBlitSurface(), &mMBRect);
}
}
void showMsgWithBmp(const std::string &text,
const std::string &bmp,
const direction_t alignment,
const direction_t alignment, const bool animation,
CEvent *closeEv)
{
CMessageBoxBitmapGalaxy *pMsgBoxBmp =
new CMessageBoxBitmapGalaxy( text,
*gGraphics.getBitmapFromStr(bmp),
alignment, closeEv ) ;
alignment, animation, closeEv ) ;
pMsgBoxBmp->init();
......@@ -88,12 +145,13 @@ void showMsgWithBmp( const std::string &text,
void showMsgWithBmp( const std::string &text,
const unsigned int bmpID,
const direction_t alignment,
const bool animation,
CEvent *closeEv)
{
CMessageBoxBitmapGalaxy *pMsgBoxBmp =
new CMessageBoxBitmapGalaxy( text,
gGraphics.getBitmapFromId(bmpID),
alignment, closeEv ) ;
alignment, animation, closeEv ) ;
pMsgBoxBmp->init();
......
......@@ -27,26 +27,43 @@ public:
CMessageBoxBitmapGalaxy(const std::string& Text,
const GsBitmap &BitmapRef,
const direction_t alignment,
const bool animation,
CEvent *closeEv = nullptr);
virtual ~CMessageBoxBitmapGalaxy() {}
virtual void init();
virtual void init() override;
void ponder() override;
void render() override;
private:
const GsBitmap &mBitmap;
const direction_t mAlignment;
/**
* @brief mMBAnimatedSurface Some boxes have animation,
* like Billys hand forming a fist
*/
GsSurface mMBAnimatedSurface;
int mAnimtimer = 0;
int mAnimFrame = 1;
int mShowtime = -1;
};
void showMsgWithBmp(const std::string &text,
const std::string &bmp,
const direction_t alignment,
const bool animation,
CEvent *closeEv = nullptr);
void showMsgWithBmp(const std::string &text,
const unsigned int bmpID,
const direction_t alignment ,
const bool animation,
CEvent *closeEv = nullptr);
......
......@@ -136,7 +136,8 @@ void CMessageBoxGalaxy::ponder()
void CMessageBoxGalaxy::render()
{
// Just render the MessageBox
BlitSurface(mMBSurface.getSDLSurface(), nullptr, gVideoDriver.getBlitSurface(), &mMBRect);
BlitSurface(mMBSurface.getSDLSurface(), nullptr,
gVideoDriver.getBlitSurface(), &mMBRect);
}
......
......@@ -131,10 +131,14 @@ void CCouncilMember::performJanitorMode()
std::vector<CMessageBoxGalaxy*> msgs;
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[0], gGraphics.getBitmapFromId(104), LEFT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[1], *gGraphics.getBitmapFromStr("KEENTALKING"), RIGHT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[2], gGraphics.getBitmapFromId(104), LEFT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[3], *gGraphics.getBitmapFromStr("KEENTALKING"), RIGHT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[0],
gGraphics.getBitmapFromId(104), LEFT, false) );
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[1],
*gGraphics.getBitmapFromStr("KEENTALKING"), RIGHT, false) );
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[2],
gGraphics.getBitmapFromId(104), LEFT, false) );
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[3],
*gGraphics.getBitmapFromStr("KEENTALKING"), RIGHT, false) );
showMsgVec( msgs );
......@@ -201,7 +205,8 @@ void CCouncilMember::getTouchedBy(CSpriteObject &theObject)
std::vector<CMessageBoxGalaxy*> msgs;
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[0], gGraphics.getBitmapFromId(104), LEFT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[0],
gGraphics.getBitmapFromId(104), LEFT, false) );
rescuedelders++;
......@@ -209,11 +214,12 @@ void CCouncilMember::getTouchedBy(CSpriteObject &theObject)
{
msgs.push_back( new CMessageBoxBitmapGalaxy(elder_text[1],
*gGraphics.getBitmapFromStr("KEENTHUMBSUP"),
RIGHT) );
RIGHT, false) );
msgs.push_back( new CMessageBoxBitmapGalaxy(gBehaviorEngine.getString(answermap[8]),
*gGraphics.getBitmapFromStr("KEENTHUMBSUP"), RIGHT) );
*gGraphics.getBitmapFromStr("KEENTHUMBSUP"),
RIGHT,false) );
gEventManager.add(new OpenComputerWrist(4));
gEventManager.add(new EventEndGamePlay());
......
......@@ -106,14 +106,19 @@ void CLindsey::getTouchedBy(CSpriteObject &theObject)
if(!customDlgs)
{
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[0], gGraphics.getBitmapFromId(108), LEFT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[1], gGraphics.getBitmapFromId(108), LEFT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[2], *gGraphics.getBitmapFromStr("KEENTHUMBSUP"), RIGHT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[0],
gGraphics.getBitmapFromId(108), LEFT, false) );
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[1],
gGraphics.getBitmapFromId(108), LEFT, false) );
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[2],
*gGraphics.getBitmapFromStr("KEENTHUMBSUP"), RIGHT, false) );
}
else
{
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[0], gGraphics.getBitmapFromId(108), LEFT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[1], *gGraphics.getBitmapFromStr("KEENTHUMBSUP"), RIGHT) );
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[0],
gGraphics.getBitmapFromId(108), LEFT, false) );
msgs.push_back( new CMessageBoxBitmapGalaxy(lindsey_text[1],
*gGraphics.getBitmapFromStr("KEENTHUMBSUP"), RIGHT, false) );
}
showMsgVec( msgs );
......
......@@ -205,7 +205,8 @@ void CFuse::getTouchedBy(CSpriteObject &theObject)
msgs.push_back( new CMessageBoxBitmapGalaxy(
msg,
gGraphics.getBitmapFromId(mLevelTestBmp),
RIGHT) );
RIGHT,
true) );
showMsgVec( msgs );
mIsDead = true;
......
......@@ -145,23 +145,24 @@ void CRocket::getTouchedBy(CSpriteObject& theObject)
if(getActionNumber(A_ROCKET_FLY))
return;
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
if(player->m_Inventory.Item.m_special.rocketKeycard > 0)
{
setAction(A_ROCKET_FLY);
playSound(SOUND_ROCKET_LAUNCH);
mpCarriedPlayer = player;
mpCarriedPlayer->solid = false;
mpCarriedPlayer->dontdraw = true;
}
else
{
// Tell the player he cannot climb yet
showMsgWithBmp(gBehaviorEngine.getString("KEEN_KEYCARD_REQUIRED"), 29, RIGHT);
player->moveYDir((1<<CSF)/2);
}
}
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
if(player->m_Inventory.Item.m_special.rocketKeycard > 0)
{
setAction(A_ROCKET_FLY);
playSound(SOUND_ROCKET_LAUNCH);
mpCarriedPlayer = player;
mpCarriedPlayer->solid = false;
mpCarriedPlayer->dontdraw = true;
}
else
{
// Tell the player he cannot climb yet
showMsgWithBmp(gBehaviorEngine.getString("KEEN_KEYCARD_REQUIRED"),
29, RIGHT, false);
player->moveYDir((1<<CSF)/2);
}
}
}
void CRocket::process()
......
......@@ -27,8 +27,14 @@ void CEGAGraphicsGalaxy::createBitmapsIDs()
m_BitmapNameMap[0][102] = "STARWARS";
m_BitmapNameMap[0][103] = "TITLE";
m_BitmapNameMap[0][105] = "KEENTALKING";
m_BitmapNameMap[0][106] = "KEENTHUMBSUP";
m_SpriteNameMap[0][129] = "HUDBACKGROUND";
m_BitmapNameMap[0][106] = "KEENTHUMBSUP";
m_BitmapNameMap[0][109] = "KEENTHUMBSUPLOADING";
m_BitmapNameMap[0][110] = "KEENTHUMBSUPLOADING1";
m_BitmapNameMap[0][111] = "KEENTHUMBSUPLOADING2";
m_BitmapNameMap[0][112] = "KEENTHUMBSUPLOADING3";
m_BitmapNameMap[0][113] = "KEENTHUMBSUPLOADING4";
m_BitmapNameMap[0][114] = "KEENTHUMBSUPLOADING5";
m_SpriteNameMap[0][129] = "HUDBACKGROUND";
// Menu Labels
m_BitmapNameMap[0][82] = "MAINMENULABEL";
......@@ -58,6 +64,13 @@ void CEGAGraphicsGalaxy::createBitmapsIDs()
m_BitmapNameMap[1][82] = "TITLE";
m_BitmapNameMap[1][76] = "KEENSWATCH";
m_BitmapNameMap[1][85] = "KEENTHUMBSUP";
m_BitmapNameMap[1][86] = "KEENTHUMBSUPLOADING";
m_BitmapNameMap[1][87] = "KEENTHUMBSUPLOADING1";
m_BitmapNameMap[1][88] = "KEENTHUMBSUPLOADING2";
m_BitmapNameMap[1][89] = "KEENTHUMBSUPLOADING3";
m_BitmapNameMap[1][90] = "KEENTHUMBSUPLOADING4";
m_BitmapNameMap[1][91] = "KEENTHUMBSUPLOADING5";
// Sprites
m_SpriteNameMap[1][133] = "HUDBACKGROUND";
......@@ -69,6 +82,13 @@ void CEGAGraphicsGalaxy::createBitmapsIDs()
m_BitmapNameMap[2][20] = "KEENSWATCH";
m_BitmapNameMap[2][29] = "KEENTALKING";
m_BitmapNameMap[2][30] = "KEENTHUMBSUP";
m_BitmapNameMap[2][31] = "KEENTHUMBSUPLOADING";
m_BitmapNameMap[2][32] = "KEENTHUMBSUPLOADING1";
m_BitmapNameMap[2][33] = "KEENTHUMBSUPLOADING2";
m_BitmapNameMap[2][34] = "KEENTHUMBSUPLOADING3";
m_BitmapNameMap[2][35] = "KEENTHUMBSUPLOADING4";
m_BitmapNameMap[2][36] = "KEENTHUMBSUPLOADING5";
m_BitmapNameMap[2][0] = "HELPHAND";
// Sprites
......@@ -81,6 +101,13 @@ void CEGAGraphicsGalaxy::createBitmapsIDs()
m_BitmapNameMap[3][15] = "KEENSWATCH";
m_BitmapNameMap[3][24] = "KEENTALKING";
m_BitmapNameMap[3][25] = "KEENTHUMBSUP";
m_BitmapNameMap[3][26] = "KEENTHUMBSUPLOADING";
m_BitmapNameMap[3][27] = "KEENTHUMBSUPLOADING1";
m_BitmapNameMap[3][28] = "KEENTHUMBSUPLOADING2";
m_BitmapNameMap[3][29] = "KEENTHUMBSUPLOADING3";
m_BitmapNameMap[3][30] = "KEENTHUMBSUPLOADING4";
m_BitmapNameMap[3][31] = "KEENTHUMBSUPLOADING5";
// The following is not right for k6demo, but here as a placeholder:
m_BitmapNameMap[3][0] = "HELPHAND";
......
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