diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 1164de541..25f02e9b1 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -71,7 +71,8 @@ GameController::GameController(): renderOptions(NULL), loginWindow(NULL), ssave(NULL), - console(NULL) + console(NULL), + tagsWindow(NULL) { gameView = new GameView(); gameModel = new GameModel(); @@ -99,6 +100,10 @@ GameController::~GameController() { delete loginWindow; } + if(tagsWindow) + { + delete tagsWindow; + } if(console) { delete console; @@ -333,7 +338,8 @@ void GameController::OpenLogin() void GameController::OpenTags() { - //TODO: Implement + tagsWindow = new TagsController(NULL); + ui::Engine::Ref().ShowWindow(tagsWindow->GetView()); } void GameController::OpenDisplayOptions() diff --git a/src/game/GameController.h b/src/game/GameController.h index 8480aeb31..7944dc717 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -10,6 +10,7 @@ #include "render/RenderController.h" #include "login/LoginController.h" #include "ssave/SSaveController.h" +#include "tags/TagsController.h" #include "console/ConsoleController.h" //#include "cat/TPTScriptInterface.h" #include "cat/LuaScriptInterface.h" @@ -32,6 +33,7 @@ private: LoginController * loginWindow; SSaveController * ssave; ConsoleController * console; + TagsController * tagsWindow; CommandInterface * commandInterface; public: class LoginCallback; diff --git a/src/tags/TagsController.cpp b/src/tags/TagsController.cpp new file mode 100644 index 000000000..88356c7d3 --- /dev/null +++ b/src/tags/TagsController.cpp @@ -0,0 +1,37 @@ +/* + * TagsController.cpp + * + * Created on: Mar 5, 2012 + * Author: Simon + */ + +#include "TagsController.h" +#include "interface/Engine.h" + +#include "TagsModel.h" +#include "TagsView.h" + +TagsController::TagsController(ControllerCallback * callback): + HasDone(false) +{ + tagsModel = new TagsModel(); + tagsView = new TagsView(); + tagsView->AttachController(this); + tagsModel->AddObserver(tagsView); + + this->callback = callback; +} + +void TagsController::Exit() +{ + if(ui::Engine::Ref().GetWindow() == tagsView) + ui::Engine::Ref().CloseWindow(); + if(callback) + callback->ControllerExit(); + HasDone = true; +} + +TagsController::~TagsController() { + // TODO Auto-generated destructor stub +} + diff --git a/src/tags/TagsController.h b/src/tags/TagsController.h new file mode 100644 index 000000000..5c613f0a6 --- /dev/null +++ b/src/tags/TagsController.h @@ -0,0 +1,28 @@ +/* + * TagsController.h + * + * Created on: Mar 5, 2012 + * Author: Simon + */ + +#ifndef TAGSCONTROLLER_H_ +#define TAGSCONTROLLER_H_ + +#include "Controller.h" +#include "TagsView.h" + +class TagsView; +class TagsModel; +class TagsController { + ControllerCallback * callback; + TagsView * tagsView; + TagsModel * tagsModel; +public: + bool HasDone; + TagsController(ControllerCallback * callback); + TagsView * GetView() {return tagsView;} + void Exit(); + virtual ~TagsController(); +}; + +#endif /* TAGSCONTROLLER_H_ */ diff --git a/src/tags/TagsModel.cpp b/src/tags/TagsModel.cpp new file mode 100644 index 000000000..cfff37120 --- /dev/null +++ b/src/tags/TagsModel.cpp @@ -0,0 +1,23 @@ +/* + * TagsModel.cpp + * + * Created on: Mar 5, 2012 + * Author: Simon + */ + +#include "TagsModel.h" + +TagsModel::TagsModel() { + // TODO Auto-generated constructor stub + +} + +void TagsModel::AddObserver(TagsView * observer) +{ + observers.push_back(observer); +} + +TagsModel::~TagsModel() { + // TODO Auto-generated destructor stub +} + diff --git a/src/tags/TagsModel.h b/src/tags/TagsModel.h new file mode 100644 index 000000000..fe7c0579c --- /dev/null +++ b/src/tags/TagsModel.h @@ -0,0 +1,22 @@ +/* + * TagsModel.h + * + * Created on: Mar 5, 2012 + * Author: Simon + */ + +#ifndef TAGSMODEL_H_ +#define TAGSMODEL_H_ + +#include + +class TagsView; +class TagsModel { + std::vector observers; +public: + TagsModel(); + void AddObserver(TagsView * observer); + virtual ~TagsModel(); +}; + +#endif /* TAGSMODEL_H_ */ diff --git a/src/tags/TagsView.cpp b/src/tags/TagsView.cpp new file mode 100644 index 000000000..f9eafbc00 --- /dev/null +++ b/src/tags/TagsView.cpp @@ -0,0 +1,29 @@ +/* + * TagsView.cpp + * + * Created on: Mar 5, 2012 + * Author: Simon + */ + +#include "TagsView.h" + +#include "TagsController.h" +#include "TagsModel.h" + +TagsView::TagsView(): + ui::Window(ui::Point(-1, -1), ui::Point(200, 300)){ + // TODO Auto-generated constructor stub + +} + +void TagsView::OnDraw() +{ + Graphics * g = ui::Engine::Ref().g; + g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3); + g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); +} + +TagsView::~TagsView() { + // TODO Auto-generated destructor stub +} + diff --git a/src/tags/TagsView.h b/src/tags/TagsView.h new file mode 100644 index 000000000..3126e5a6b --- /dev/null +++ b/src/tags/TagsView.h @@ -0,0 +1,24 @@ +/* + * TagsView.h + * + * Created on: Mar 5, 2012 + * Author: Simon + */ + +#ifndef TAGSVIEW_H_ +#define TAGSVIEW_H_ + +#include "interface/Window.h" + +class TagsController; +class TagsModel; +class TagsView: public ui::Window { + TagsController * c; +public: + TagsView(); + virtual void OnDraw(); + void AttachController(TagsController * c_) { c = c_; }; + virtual ~TagsView(); +}; + +#endif /* TAGSVIEW_H_ */