104 lines
2.4 KiB
C++
104 lines
2.4 KiB
C++
#ifndef _VIEW_H
|
|
#define _VIEW_H
|
|
|
|
#include "ViewBase.h"
|
|
#include "OverlayBase.h"
|
|
#include "mathlib.h"
|
|
#include "Sprite.h"
|
|
#include "EntityBase.h"
|
|
#include "SimpleConsoleOverlay.h"
|
|
#include "AsteroidsEnums.h"
|
|
|
|
namespace asteroids {
|
|
|
|
struct ShipEntity;
|
|
struct AsteroidEntity;
|
|
struct RocketEntity;
|
|
|
|
struct BackgroundStar {
|
|
vector3d position;
|
|
};
|
|
|
|
/** \brief Performs the actual drawing based on Camera and Model
|
|
*/
|
|
class View : public Engine::ViewBase {
|
|
public:
|
|
virtual ~View() {};
|
|
|
|
protected:
|
|
/** \brief Initializes the system */
|
|
virtual int OnInit (int argc, char* argv[]);
|
|
virtual void OnDestroy ();
|
|
|
|
/** \brief Updates the camera for further drawing */
|
|
virtual void UpdateCamera ();
|
|
|
|
private:
|
|
void DrawUi();
|
|
|
|
void DrawPageTitle(const std::string &title);
|
|
|
|
void DrawUiMainMenu();
|
|
void DrawUiGameRunning();
|
|
void DrawUiGameOver();
|
|
void DrawUiLevelComplete();
|
|
void DrawUiGamePaused();
|
|
void DrawUiPlayerDied();
|
|
void DrawHighscoreEntry(float x, float y, float entry_width, const std::string &name, unsigned int points);
|
|
void DrawUiHighscore();
|
|
void DrawUiOptions();
|
|
void DrawUiEnterPlayername();
|
|
|
|
virtual void Draw ();
|
|
virtual void DrawWorld ();
|
|
void DrawStars ();
|
|
|
|
void DrawEntity (Engine::EntityBase *entity);
|
|
void DrawShip (ShipEntity *ship);
|
|
void DrawAsteroid (AsteroidEntity *asteroid);
|
|
void DrawRocket (RocketEntity *asteroid);
|
|
void DrawShipPart (Engine::EntityBase *entity);
|
|
|
|
// boost::shared_ptr<MenuOverlay> mMenuOverlay;
|
|
// boost::shared_ptr<Engine::SimpleConsoleOverlay> mConsoleOverlay;
|
|
|
|
std::vector<BackgroundStar> mBackgroundStars;
|
|
|
|
std::vector<unsigned int> mShipPartsEntityIds;
|
|
|
|
std::stack<ViewState> mViewStateStack;
|
|
|
|
void PushViewState (const ViewState state) {
|
|
Engine::LogDebug ("Pushing ViewState %s", GetStringViewState(state));
|
|
mViewStateStack.push(state);
|
|
}
|
|
ViewState GetViewState () {
|
|
return mViewStateStack.top();
|
|
}
|
|
void PopViewState () {
|
|
mViewStateStack.pop();
|
|
Engine::LogDebug ("Popped ViewState top is now:%s", GetStringViewState(mViewStateStack.top()));
|
|
}
|
|
|
|
// \todo [high] add Resource Manager!
|
|
Engine::Sprite mGUIShipSprite;
|
|
Engine::Sprite mAsteroidSprite;
|
|
Engine::Sprite mShipSprite;
|
|
Engine::Sprite mShipThrustSprite;
|
|
Engine::Sprite mShipPartsSprite;
|
|
|
|
float screen_left;
|
|
float screen_right;
|
|
float screen_top;
|
|
float screen_bottom;
|
|
|
|
int button_width;
|
|
int button_height;
|
|
|
|
virtual bool OnReceiveEvent (const Engine::EventBasePtr &event);
|
|
};
|
|
|
|
}
|
|
|
|
#endif // _VIEW_H
|