Commit 2c23cec5 authored by Gerstrong's avatar Gerstrong

New Dialog Class which displays pictures now. Loading Dialog or speaking to...

New Dialog Class which displays pictures now. Loading Dialog or speaking to elders is used for those dialogs.
parent 4d054ef7
......@@ -264,7 +264,7 @@ bool CMap::gotoPos(int x, int y)
// scrolls the map one pixel right
bool CMap::scrollRight(const bool force)
{
if(m_scrollx < (m_width<<4) - g_pVideoDriver->getGameResolution().w)
if(m_scrollx < ((m_width-2)<<4) - g_pVideoDriver->getGameResolution().w)
{
m_scrollx++;
m_scrollx_buf = m_scrollx&511;
......@@ -316,7 +316,7 @@ bool CMap::scrollDown(const bool force)
if( !force && findScrollHorizontalScrollBlocker((m_scrolly+res_height)<<STC) )
return false;
if(m_scrolly < (m_height<<4) - res_height )
if(m_scrolly < ((m_height-2)<<4) - res_height )
{
m_scrolly++;
m_scrolly_buf = m_scrolly&511;
......
......@@ -55,7 +55,7 @@ m_Font_ID((theme==DLG_THEME_GALAXY) ? 1 : 0)
if(m_y + m_h > 200)
m_h = 200-m_y;
mp_Frame = new CDlgFrame(m_x, m_y, m_w, m_h, theme);
mp_Frame = new CDlgFrame(m_x, m_y, m_w*8, m_h*8, theme);
}
m_twirl.posy = m_y;
......
......@@ -8,6 +8,8 @@
#include "CDlgFrame.h"
#include "graphics/CGfxEngine.h"
CDlgFrame::CDlgFrame(int x, int y, int w, int h, Uint8 theme, int tilewidth, int tileheight) {
m_8x8tileheight = tilewidth;
......@@ -15,12 +17,14 @@ CDlgFrame::CDlgFrame(int x, int y, int w, int h, Uint8 theme, int tilewidth, int
m_x = x;
m_y = y;
m_w = w*m_8x8tilewidth;
m_h = h*m_8x8tileheight;
resize(w, h);
m_theme = theme;
}
void CDlgFrame::draw(SDL_Surface *dst)
{
if( m_theme == DLG_THEME_VORTICON )
......@@ -37,6 +41,16 @@ void CDlgFrame::draw(SDL_Surface *dst)
}
}
void CDlgFrame::resize(const Uint32 width, const Uint32 height)
{
m_w = width; m_h = height;
}
void CDlgFrame::drawOldSchoolFrame(SDL_Surface *dst)
{
CFont &Font = g_pGfxEngine->getFont(0);
......@@ -153,7 +167,3 @@ void CDlgFrame::drawRedFrame(SDL_Surface *dst)
Font.drawCharacter(dst, 28, m_x, m_y + m_h - m_8x8tileheight ); // Lower-Left corner
Font.drawCharacter(dst, 30, m_x + m_w - m_8x8tilewidth, m_y + m_h - m_8x8tileheight ); // Lower-Right corner
}
CDlgFrame::~CDlgFrame() {
// TODO Auto-generated destructor stub
}
......@@ -20,10 +20,16 @@ enum themes{
class CDlgFrame {
public:
CDlgFrame(int x, int y, int w, int h, Uint8 theme = DLG_THEME_VORTICON, int tilewidth = 8, int tileheight = 8);
virtual ~CDlgFrame();
void draw(SDL_Surface *dst);
/**
* \brief Resizes the dialog box to new dimensions
* \param width New width of the box
* \param width New height of the box
*/
void resize(const Uint32 width, const Uint32 height);
int m_x;
int m_y;
int m_w;
......@@ -39,6 +45,7 @@ private:
void drawOldSchoolFrame(SDL_Surface *dst);
void drawGalaxyFrame(SDL_Surface *dst);
void drawRedFrame(SDL_Surface *dst);
};
#endif /* CDLGFRAME_H_ */
......@@ -44,11 +44,11 @@ public:
protected:
bool m_mustclose;
bool m_keymsg;
int m_text_width;
int m_text_height;
Uint32 m_text_width;
Uint32 m_text_height;
std::vector<std::string> m_Lines;
SmartPointer<CDlgFrame> mp_DlgFrame;
SDL_Rect m_gamerect;
SDL_Rect m_boxrect;
};
#endif /* CMESSAGEBOX_H_ */
......@@ -10,6 +10,7 @@
#include "sdl/CInput.h"
#include "sdl/CVideoDriver.h"
#include "sdl/music/CMusic.h"
#include "dialog/CMessageBoxBitmapGalaxy.h"
#include "CLogFile.h"
#include "CMapPlayGalaxy.h"
......@@ -37,6 +38,9 @@ bool CLevelPlay::loadLevel(const Uint16 level)
else
g_pMusicPlayer->play();
// Add the load message
m_MessageBoxes.push_back(new CMessageBoxBitmapGalaxy("Level " + itoa(level) + " has been loaded...", 106 ) );
m_Map.drawAll();
return true;
}
......
......@@ -9,6 +9,7 @@
#include "CMapLoaderGalaxy.h"
#include "graphics/CGfxEngine.h"
#include "dialog/CMessageBoxBitmapGalaxy.h"
#include "sdl/CVideoDriver.h"
#include "sdl/CInput.h"
#include "sdl/sound/CSound.h"
......@@ -111,11 +112,15 @@ void CPlayGameGalaxy::process()
// process World Map if active. At the start it's enabled
if(m_WorldMap.isActive())
{
m_WorldMap.process();
}
// process World Map if active. At the start it's enabled
if(m_LevelPlay.isActive())
{
m_LevelPlay.process();
}
// We have to show the status screen, do so...
if( m_Inventory.showStatus() )
......@@ -136,9 +141,10 @@ void CPlayGameGalaxy::process()
// Start a new level!
if(ev->data > 0xC000)
{
const Uint16 NewLevel = ev->data - 0xC000;
g_pMusicPlayer->stop();
m_WorldMap.setActive(false);
m_LevelPlay.loadLevel(ev->data - 0xC000);
m_LevelPlay.loadLevel(NewLevel);
m_LevelName = m_LevelPlay.getLevelName();
g_pSound->playSound( SOUND_ENTER_LEVEL );
m_LevelPlay.setActive(true);
......
......@@ -10,6 +10,7 @@
#include "engine/playgame/CPlayGame.h"
#include "engine/galaxy/CInventory.h"
#include "dialog/CMessageBoxGalaxy.h"
#include "common/CMap.h"
#include "CWorldMap.h"
#include "CLevelPlay.h"
......
......@@ -59,7 +59,7 @@ m_Cheatmode(Cheatmode)
processActionRoutine();
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
moveUp(rSprite.m_bboxY2-rSprite.m_bboxY1+(1<<CSF));
processMove(0, (14<<STC)-(rSprite.m_bboxY2-rSprite.m_bboxY1));
performCollisions();
m_camera.setPosition(m_Pos);
}
......
/*
* CMessageBoxBitmapGalaxy.cpp
*
* Created on: 04.05.2011
* Author: gerstrong
*/
#include "CMessageBoxBitmapGalaxy.h"
#include "sdl/CVideoDriver.h"
CMessageBoxBitmapGalaxy::CMessageBoxBitmapGalaxy( const std::string& Text, const Uint16 BitmapId ) :
CMessageBoxGalaxy(Text),
m_Bitmap(g_pGfxEngine->getBitmap(BitmapId))
{
SDL_Rect gamerect = g_pVideoDriver->getGameResolution();
// Looking if the Bitmap is too big for the Message box. In that case enlarge it!
if( m_Bitmap.getHeight() > m_boxrect.h )
{
const int new_height = m_Bitmap.getHeight();
m_TextPos.x = 10+m_Bitmap.getWidth();
m_TextPos.y = ((new_height+16)/2) - 8*m_Lines.size();
// Resize
mp_DlgFrame->resize(m_boxrect.w+m_Bitmap.getWidth()+2, new_height+16);
// Now calculate new coordinates and remove the box
m_boxrect.x = (gamerect.w - m_boxrect.w)/2;
m_boxrect.y = (gamerect.h - m_boxrect.h)/2;
}
}
void CMessageBoxBitmapGalaxy::process()
{
CMessageBoxGalaxy::process();
SDL_Surface *sfc = g_pVideoDriver->mp_VideoEngine->getFGLayerSurface();
m_Bitmap.draw(sfc,m_boxrect.x+8, m_boxrect.y+8);
}
/*
* CMessageBoxBitmapGalaxy.h
*
* Created on: 04.05.2011
* Author: gerstrong
*/
#ifndef CMESSAGEBOXBITMAPGALAXY_H_
#define CMESSAGEBOXBITMAPGALAXY_H_
#include "CMessageBoxGalaxy.h"
#include "graphics/CGfxEngine.h"
class CMessageBoxBitmapGalaxy : public CMessageBoxGalaxy {
public:
/**
* \brief This constructor creates a typical Keen 4 Message Box
* \param Text Message to be shown
* \param BitmapId Bitmap that will be shown to the left side in the box
*/
CMessageBoxBitmapGalaxy(const std::string& Text, const Uint16 BitmapId );
/**
* \brief the cycle to be processed for rendering the Message-Box
*/
virtual void process();
private:
CBitmap &m_Bitmap;
};
#endif /* CMESSAGEBOXBITMAPGALAXY_H_ */
......@@ -19,10 +19,10 @@ CMessageBox(Text, false, false, false)
{
// Center that dialog box
CFont &Font = g_pGfxEngine->getFont(FONT_ID);
m_gamerect = g_pVideoDriver->getGameResolution();
m_boxrect = g_pVideoDriver->getGameResolution();
m_gamerect.x = m_gamerect.w/2;
m_gamerect.y = m_gamerect.h/2;
m_boxrect.x = m_boxrect.w/2;
m_boxrect.y = m_boxrect.h/2;
int width = 0;
for( size_t i=0 ; i<m_Lines.size() ; i++)
......@@ -34,17 +34,17 @@ CMessageBox(Text, false, false, false)
// TODO: Those hardcoded are only temporary. They need to be removed.
m_text_height = Font.getPixelTextHeight();
m_gamerect.h = (m_text_height+2)*m_Lines.size()+16;
m_gamerect.w = width;
m_boxrect.h = (m_text_height+2)*m_Lines.size()+16;
m_boxrect.w = width;
m_gamerect.x -= m_gamerect.w/2;
m_gamerect.y -= m_gamerect.h/2;
m_boxrect.x -= m_boxrect.w/2;
m_boxrect.y -= m_boxrect.h/2;
m_gamerect.h /= 8;
m_gamerect.w /= 8;
mp_DlgFrame = new CDlgFrame(m_boxrect.x, m_boxrect.y,
m_boxrect.w, m_boxrect.h, DLG_THEME_GALAXY);
mp_DlgFrame = new CDlgFrame(m_gamerect.x, m_gamerect.y,
m_gamerect.w, m_gamerect.h, DLG_THEME_GALAXY);
m_TextPos.x = 8;
m_TextPos.y = 8;
}
void CMessageBoxGalaxy::process()
......@@ -66,5 +66,5 @@ void CMessageBoxGalaxy::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_gamerect.x+8, m_gamerect.y+(i*m_text_height+8) );
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) );
}
......@@ -9,12 +9,21 @@
#define CMESSAGEBOXGALAXY_H_
#include "dialog/CMessageBox.h"
#include "CVec.h"
class CMessageBoxGalaxy : public CMessageBox {
public:
/**
* \brief This constructor creates a typical Keen 4 Message Box
* \param Text Message to be shown
*/
CMessageBoxGalaxy(const std::string& Text);
void process();
protected:
SDL_Rect m_TextPos;
};
#endif /* CMESSAGEBOXGALAXY_H_ */
......@@ -31,30 +31,30 @@ m_twirlframe(0)
}
// try to center that dialog box
m_gamerect = g_pVideoDriver->getGameResolution();
m_boxrect = g_pVideoDriver->getGameResolution();
int h = m_gamerect.h;
m_gamerect.x = m_gamerect.w/2;
m_gamerect.y = m_gamerect.h/2;
int h = m_boxrect.h;
m_boxrect.x = m_boxrect.w/2;
m_boxrect.y = m_boxrect.h/2;
m_gamerect.h = (m_Lines.size()+2)*8;
m_gamerect.w = (m_text_width+2)*8;
m_boxrect.h = (m_Lines.size()+2)*8;
m_boxrect.w = (m_text_width+2)*8;
m_gamerect.x -= m_gamerect.w/2;
m_boxrect.x -= m_boxrect.w/2;
if(!lower)
m_gamerect.y -= m_gamerect.h/2;
m_boxrect.y -= m_boxrect.h/2;
else
m_gamerect.y = h-m_gamerect.h;
m_boxrect.y = h-m_boxrect.h;
if(leftbound) m_gamerect.x = 0;
if(leftbound) m_boxrect.x = 0;
m_gamerect.h /= 8;
m_gamerect.w /= 8;
m_boxrect.h /= 8;
m_boxrect.w /= 8;
mp_DlgFrame = new CDlgFrame(m_gamerect.x, m_gamerect.y,
m_gamerect.w, m_gamerect.h, DLG_THEME_VORTICON);
mp_DlgFrame = new CDlgFrame(m_boxrect.x, m_boxrect.y,
m_boxrect.w*8, m_boxrect.h*8, DLG_THEME_VORTICON);
}
// This function is used in your Ship need those parts.
......@@ -86,12 +86,12 @@ void CMessageBoxVort::process()
// Draw the Text on our surface
for( size_t i=0 ; i<m_Lines.size() ; i++)
g_pGfxEngine->getFont(0).drawFont(sfc, m_Lines[i], m_gamerect.x+8, m_gamerect.y+((i+1)*8) );
g_pGfxEngine->getFont(0).drawFont(sfc, m_Lines[i], m_boxrect.x+8, m_boxrect.y+((i+1)*8) );
// Draw additional tiles on the surface if any where defined
for(size_t i=0 ; i<m_Tiles.size() ; i++) {
g_pGfxEngine->getTileMap(1).drawTile(sfc, m_gamerect.x+m_Tiles[i].x,
m_gamerect.y+m_Tiles[i].y, m_Tiles[i].tile);
g_pGfxEngine->getTileMap(1).drawTile(sfc, m_boxrect.x+m_Tiles[i].x,
m_boxrect.y+m_Tiles[i].y, m_Tiles[i].tile);
}
if(m_keymsg)
......
......@@ -7,7 +7,7 @@
#include "CBitmap.h"
#include "CPalette.h"
#include "../FindFile.h"
#include "FindFile.h"
CBitmap::CBitmap() {
m_BitmapSurface = NULL;
......
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