Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
57ab7bca76
@ -67,7 +67,7 @@ int main(int argc, char * argv[])
|
|||||||
ui::Engine::Ref().g->AttachSDLSurface(SDLOpen());
|
ui::Engine::Ref().g->AttachSDLSurface(SDLOpen());
|
||||||
|
|
||||||
ui::Engine * engine = &ui::Engine::Ref();
|
ui::Engine * engine = &ui::Engine::Ref();
|
||||||
engine->Begin(XRES, YRES);
|
engine->Begin(XRES+BARSIZE, YRES+MENUSIZE);
|
||||||
|
|
||||||
GameController * gameController = new GameController();
|
GameController * gameController = new GameController();
|
||||||
engine->ShowWindow(gameController->GetView());
|
engine->ShowWindow(gameController->GetView());
|
||||||
|
@ -19,7 +19,9 @@ Engine::Engine():
|
|||||||
mousexp_(0),
|
mousexp_(0),
|
||||||
mouseyp_(0),
|
mouseyp_(0),
|
||||||
FpsLimit(60.0f),
|
FpsLimit(60.0f),
|
||||||
windows(stack<Window*>())
|
windows(stack<Window*>()),
|
||||||
|
lastBuffer(NULL),
|
||||||
|
prevBuffers(stack<pixel*>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,17 +53,44 @@ void Engine::Exit()
|
|||||||
|
|
||||||
void Engine::ShowWindow(Window * window)
|
void Engine::ShowWindow(Window * window)
|
||||||
{
|
{
|
||||||
|
if(window->Position.X==-1)
|
||||||
|
{
|
||||||
|
window->Position.X = (width_-window->Size.X)/2;
|
||||||
|
}
|
||||||
|
if(window->Position.Y==-1)
|
||||||
|
{
|
||||||
|
window->Position.Y = (height_-window->Size.Y)/2;
|
||||||
|
}
|
||||||
if(state_)
|
if(state_)
|
||||||
{
|
{
|
||||||
|
if(lastBuffer)
|
||||||
|
{
|
||||||
|
prevBuffers.push(lastBuffer);
|
||||||
|
}
|
||||||
|
lastBuffer = (pixel*)malloc((width_ * height_) * PIXELSIZE);
|
||||||
|
g->fillrect(0, 0, width_, height_, 0, 0, 0, 100);
|
||||||
|
memcpy(lastBuffer, g->vid, (width_ * height_) * PIXELSIZE);
|
||||||
|
|
||||||
windows.push(state_);
|
windows.push(state_);
|
||||||
}
|
}
|
||||||
state_ = window;
|
state_ = window;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::CloseWindow()
|
void Engine::CloseWindow()
|
||||||
{
|
{
|
||||||
if(!windows.empty())
|
if(!windows.empty())
|
||||||
{
|
{
|
||||||
|
if(!prevBuffers.empty())
|
||||||
|
{
|
||||||
|
lastBuffer = prevBuffers.top();
|
||||||
|
prevBuffers.pop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(lastBuffer);
|
||||||
|
lastBuffer = NULL;
|
||||||
|
}
|
||||||
state_ = windows.top();
|
state_ = windows.top();
|
||||||
windows.pop();
|
windows.pop();
|
||||||
}
|
}
|
||||||
@ -112,10 +141,17 @@ void Engine::Tick(float dt)
|
|||||||
|
|
||||||
void Engine::Draw()
|
void Engine::Draw()
|
||||||
{
|
{
|
||||||
|
if(lastBuffer && !(state_->Position.X == 0 && state_->Position.Y == 0 && state_->Size.X == width_ && state_->Size.Y == height_))
|
||||||
|
{
|
||||||
|
memcpy(g->vid, lastBuffer, (width_ * height_) * PIXELSIZE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g->Clear();
|
||||||
|
}
|
||||||
if(state_)
|
if(state_)
|
||||||
state_->DoDraw();
|
state_->DoDraw();
|
||||||
g->Blit();
|
g->Blit();
|
||||||
g->Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::onKeyPress(int key, bool shift, bool ctrl, bool alt)
|
void Engine::onKeyPress(int key, bool shift, bool ctrl, bool alt)
|
||||||
|
@ -54,6 +54,8 @@ namespace ui
|
|||||||
float FpsLimit;
|
float FpsLimit;
|
||||||
Graphics * g;
|
Graphics * g;
|
||||||
private:
|
private:
|
||||||
|
pixel * lastBuffer;
|
||||||
|
std::stack<pixel*> prevBuffers;
|
||||||
std::stack<Window*> windows;
|
std::stack<Window*> windows;
|
||||||
//Window* statequeued_;
|
//Window* statequeued_;
|
||||||
Window* state_;
|
Window* state_;
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
virtual void Draw(const Point& screenPos);
|
virtual void Draw(const Point& screenPos);
|
||||||
virtual void Tick(float dt);
|
virtual void Tick(float dt);
|
||||||
|
|
||||||
|
Save * GetSave() { return save; }
|
||||||
inline bool GetState() { return state; }
|
inline bool GetState() { return state; }
|
||||||
virtual void DoAction();
|
virtual void DoAction();
|
||||||
void SetActionCallback(SaveButtonAction * action);
|
void SetActionCallback(SaveButtonAction * action);
|
||||||
|
@ -23,6 +23,9 @@ enum ChromeStyle
|
|||||||
class Window
|
class Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Point Position;
|
||||||
|
Point Size;
|
||||||
|
|
||||||
Window(Point _position, Point _size);
|
Window(Point _position, Point _size);
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
@ -74,9 +77,6 @@ enum ChromeStyle
|
|||||||
virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt) {}
|
virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt) {}
|
||||||
std::vector<Component*> Components;
|
std::vector<Component*> Components;
|
||||||
Component* focusedComponent_;
|
Component* focusedComponent_;
|
||||||
|
|
||||||
Point Position;
|
|
||||||
Point Size;
|
|
||||||
ChromeStyle chrome;
|
ChromeStyle chrome;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
26
src/preview/PreviewController.cpp
Normal file
26
src/preview/PreviewController.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* PreviewController.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jan 21, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "PreviewController.h"
|
||||||
|
#include "PreviewView.h"
|
||||||
|
#include "PreviewModel.h"
|
||||||
|
|
||||||
|
PreviewController::PreviewController(int saveID) {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
previewModel = new PreviewModel();
|
||||||
|
previewView = new PreviewView();
|
||||||
|
previewModel->AddObserver(previewView);
|
||||||
|
previewView->AttachController(this);
|
||||||
|
|
||||||
|
previewModel->UpdateSave(saveID);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreviewController::~PreviewController() {
|
||||||
|
delete previewView;
|
||||||
|
delete previewModel;
|
||||||
|
}
|
||||||
|
|
25
src/preview/PreviewController.h
Normal file
25
src/preview/PreviewController.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* PreviewController.h
|
||||||
|
*
|
||||||
|
* Created on: Jan 21, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PREVIEWCONTROLLER_H_
|
||||||
|
#define PREVIEWCONTROLLER_H_
|
||||||
|
|
||||||
|
#include "preview/PreviewModel.h"
|
||||||
|
#include "preview/PreviewView.h"
|
||||||
|
|
||||||
|
class PreviewModel;
|
||||||
|
class PreviewView;
|
||||||
|
class PreviewController {
|
||||||
|
PreviewModel * previewModel;
|
||||||
|
PreviewView * previewView;
|
||||||
|
public:
|
||||||
|
PreviewController(int saveID);
|
||||||
|
PreviewView * GetView() { return previewView; }
|
||||||
|
virtual ~PreviewController();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PREVIEWCONTROLLER_H_ */
|
29
src/preview/PreviewModel.cpp
Normal file
29
src/preview/PreviewModel.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* PreviewModel.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jan 21, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "PreviewModel.h"
|
||||||
|
|
||||||
|
PreviewModel::PreviewModel():
|
||||||
|
save(NULL)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewModel::UpdateSave(int saveID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewModel::AddObserver(PreviewView * observer) {
|
||||||
|
observers.push_back(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreviewModel::~PreviewModel() {
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
28
src/preview/PreviewModel.h
Normal file
28
src/preview/PreviewModel.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* PreviewModel.h
|
||||||
|
*
|
||||||
|
* Created on: Jan 21, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PREVIEWMODEL_H_
|
||||||
|
#define PREVIEWMODEL_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "PreviewView.h"
|
||||||
|
#include "search/Save.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class PreviewView;
|
||||||
|
class PreviewModel {
|
||||||
|
vector<PreviewView*> observers;
|
||||||
|
Save * save;
|
||||||
|
public:
|
||||||
|
PreviewModel();
|
||||||
|
void AddObserver(PreviewView * observer);
|
||||||
|
void UpdateSave(int saveID);
|
||||||
|
virtual ~PreviewModel();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PREVIEWMODEL_H_ */
|
29
src/preview/PreviewView.cpp
Normal file
29
src/preview/PreviewView.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* PreviewView.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jan 21, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "PreviewView.h"
|
||||||
|
#include "interface/Point.h"
|
||||||
|
#include "interface/Window.h"
|
||||||
|
|
||||||
|
PreviewView::PreviewView():
|
||||||
|
ui::Window(ui::Point(-1, -1), ui::Point(200, 200))
|
||||||
|
{
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewView::OnDraw()
|
||||||
|
{
|
||||||
|
Graphics * g = ui::Engine::Ref().g;
|
||||||
|
g->clearrect(Position.X-2, Position.Y-2, Size.X+4, Size.Y+4);
|
||||||
|
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreviewView::~PreviewView() {
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
23
src/preview/PreviewView.h
Normal file
23
src/preview/PreviewView.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* PreviewView.h
|
||||||
|
*
|
||||||
|
* Created on: Jan 21, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PREVIEWVIEW_H_
|
||||||
|
#define PREVIEWVIEW_H_
|
||||||
|
#include "interface/Window.h"
|
||||||
|
#include "preview/PreviewController.h"
|
||||||
|
|
||||||
|
class PreviewController;
|
||||||
|
class PreviewView: public ui::Window {
|
||||||
|
PreviewController * c;
|
||||||
|
public:
|
||||||
|
void AttachController(PreviewController * controller) { c = controller;}
|
||||||
|
PreviewView();
|
||||||
|
virtual void OnDraw();
|
||||||
|
virtual ~PreviewView();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PREVIEWVIEW_H_ */
|
@ -3,8 +3,10 @@
|
|||||||
#include "SearchModel.h"
|
#include "SearchModel.h"
|
||||||
#include "SearchView.h"
|
#include "SearchView.h"
|
||||||
#include "interface/Panel.h"
|
#include "interface/Panel.h"
|
||||||
|
#include "preview/PreviewController.h"
|
||||||
|
|
||||||
SearchController::SearchController()
|
SearchController::SearchController():
|
||||||
|
activePreview(NULL)
|
||||||
{
|
{
|
||||||
searchModel = new SearchModel();
|
searchModel = new SearchModel();
|
||||||
searchView = new SearchView();
|
searchView = new SearchView();
|
||||||
@ -19,6 +21,11 @@ SearchController::SearchController()
|
|||||||
|
|
||||||
SearchController::~SearchController()
|
SearchController::~SearchController()
|
||||||
{
|
{
|
||||||
|
if(activePreview)
|
||||||
|
{
|
||||||
|
ui::Engine::Ref().CloseWindow();
|
||||||
|
delete activePreview;
|
||||||
|
}
|
||||||
delete searchModel;
|
delete searchModel;
|
||||||
delete searchView;
|
delete searchView;
|
||||||
}
|
}
|
||||||
@ -54,5 +61,11 @@ void SearchController::ChangeSort()
|
|||||||
|
|
||||||
void SearchController::ShowOwn(bool show)
|
void SearchController::ShowOwn(bool show)
|
||||||
{
|
{
|
||||||
|
//TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchController::OpenSave(int saveID)
|
||||||
|
{
|
||||||
|
activePreview = new PreviewController(saveID);
|
||||||
|
ui::Engine::Ref().ShowWindow(activePreview->GetView());
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "interface/Panel.h"
|
#include "interface/Panel.h"
|
||||||
#include "SearchModel.h"
|
#include "SearchModel.h"
|
||||||
#include "SearchView.h"
|
#include "SearchView.h"
|
||||||
|
#include "preview/PreviewController.h"
|
||||||
class SearchView;
|
class SearchView;
|
||||||
class SearchModel;
|
class SearchModel;
|
||||||
class SearchController
|
class SearchController
|
||||||
@ -11,6 +12,7 @@ class SearchController
|
|||||||
private:
|
private:
|
||||||
SearchModel * searchModel;
|
SearchModel * searchModel;
|
||||||
SearchView * searchView;
|
SearchView * searchView;
|
||||||
|
PreviewController * activePreview;
|
||||||
public:
|
public:
|
||||||
SearchController();
|
SearchController();
|
||||||
~SearchController();
|
~SearchController();
|
||||||
@ -20,6 +22,7 @@ public:
|
|||||||
void PrevPage();
|
void PrevPage();
|
||||||
void ChangeSort();
|
void ChangeSort();
|
||||||
void ShowOwn(bool show);
|
void ShowOwn(bool show);
|
||||||
|
void OpenSave(int saveID);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SEARCHCONTROLLER_H
|
#endif // SEARCHCONTROLLER_H
|
||||||
|
@ -178,6 +178,16 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
|
|||||||
buttonAreaHeight = Size.Y - buttonYOffset - 18;
|
buttonAreaHeight = Size.Y - buttonYOffset - 18;
|
||||||
buttonWidth = (buttonAreaWidth/savesX) - buttonPadding*2;
|
buttonWidth = (buttonAreaWidth/savesX) - buttonPadding*2;
|
||||||
buttonHeight = (buttonAreaHeight/savesY) - buttonPadding*2;
|
buttonHeight = (buttonAreaHeight/savesY) - buttonPadding*2;
|
||||||
|
class SaveOpenAction: public ui::SaveButtonAction
|
||||||
|
{
|
||||||
|
SearchView * v;
|
||||||
|
public:
|
||||||
|
SaveOpenAction(SearchView * _v) { v = _v; }
|
||||||
|
virtual void ActionCallback(ui::SaveButton * sender)
|
||||||
|
{
|
||||||
|
v->c->OpenSave(sender->GetSave()->GetID());
|
||||||
|
}
|
||||||
|
};
|
||||||
for(i = 0; i < saves.size(); i++)
|
for(i = 0; i < saves.size(); i++)
|
||||||
{
|
{
|
||||||
if(saveX == savesX)
|
if(saveX == savesX)
|
||||||
@ -195,6 +205,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
|
|||||||
),
|
),
|
||||||
ui::Point(buttonWidth, buttonHeight),
|
ui::Point(buttonWidth, buttonHeight),
|
||||||
saves[i]);
|
saves[i]);
|
||||||
|
saveButton->SetActionCallback(new SaveOpenAction(this));
|
||||||
saveButtons.push_back(saveButton);
|
saveButtons.push_back(saveButton);
|
||||||
AddComponent(saveButton);
|
AddComponent(saveButton);
|
||||||
saveX++;
|
saveX++;
|
||||||
|
Loading…
Reference in New Issue
Block a user