summaryrefslogtreecommitdiff
path: root/src/stamps/StampsController.cpp
blob: 07c1efd437ad342e26a84502761c7aed39d2fe65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * StampsController.cpp
 *
 *  Created on: Mar 29, 2012
 *      Author: Simon
 */

#include "StampsController.h"
#include "interface/Engine.h"

#include "StampsModel.h"
#include "StampsView.h"

StampsController::StampsController(ControllerCallback * callback):
	HasDone(false)
{
	stampsModel = new StampsModel();
	stampsView = new StampsView();
	stampsView->AttachController(this);
	stampsModel->AddObserver(stampsView);

	this->callback = callback;

	stampsModel->UpdateStampsList(1);
}

void StampsController::OpenStamp(Save * stamp)
{
	stampsModel->SetStamp(stamp);
}

Save * StampsController::GetStamp()
{
	return stampsModel->GetStamp();
}

void StampsController::NextPage()
{
	if(stampsModel->GetPageNum()>1)
		stampsModel->UpdateStampsList(stampsModel->GetPageNum()-1);
}

void StampsController::PrevPage()
{
	if(stampsModel->GetPageNum() <= stampsModel->GetPageCount())
		stampsModel->UpdateStampsList(stampsModel->GetPageNum()+1);
}

void StampsController::Update()
{
	if(stampsModel->GetStamp())
	{
		Exit();
	}
}

void StampsController::Exit()
{
	if(ui::Engine::Ref().GetWindow() == stampsView)
		ui::Engine::Ref().CloseWindow();
	if(callback)
		callback->ControllerExit();
	HasDone = true;
}

StampsController::~StampsController() {
	// TODO Auto-generated destructor stub
}