git repos / blockattack-game

blame: source/code/editor/editorMain.hpp

normal view · raw

89c4a3a6 sago007 2008-08-29 14:32 1
/*
c53e6443 sago007 2012-04-17 11:04 2
===========================================================================
c53e6443 sago007 2012-04-17 11:04 3
blockattack - Block Attack - Rise of the Blocks
c53e6443 sago007 2012-04-17 11:04 4
Copyright (C) 2005-2012 Poul Sander
c53e6443 sago007 2012-04-17 11:04 5
c53e6443 sago007 2012-04-17 11:04 6
This program is free software: you can redistribute it and/or modify
c53e6443 sago007 2012-04-17 11:04 7
it under the terms of the GNU General Public License as published by
c53e6443 sago007 2012-04-17 11:04 8
the Free Software Foundation, either version 2 of the License, or
c53e6443 sago007 2012-04-17 11:04 9
(at your option) any later version.
c53e6443 sago007 2012-04-17 11:04 10
c53e6443 sago007 2012-04-17 11:04 11
This program is distributed in the hope that it will be useful,
c53e6443 sago007 2012-04-17 11:04 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
c53e6443 sago007 2012-04-17 11:04 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c53e6443 sago007 2012-04-17 11:04 14
GNU General Public License for more details.
c53e6443 sago007 2012-04-17 11:04 15
c53e6443 sago007 2012-04-17 11:04 16
You should have received a copy of the GNU General Public License
c53e6443 sago007 2012-04-17 11:04 17
along with this program.  If not, see http://www.gnu.org/licenses/
c53e6443 sago007 2012-04-17 11:04 18
c53e6443 sago007 2012-04-17 11:04 19
Source information and contacts persons can be found at
c53e6443 sago007 2012-04-17 11:04 20
http://blockattack.sf.net
c53e6443 sago007 2012-04-17 11:04 21
===========================================================================
89c4a3a6 sago007 2008-08-29 14:32 22
*/
89c4a3a6 sago007 2008-08-29 14:32 23
c53e6443 sago007 2012-04-17 11:04 24
#include "SDL.h"
89c4a3a6 sago007 2008-08-29 14:32 25
#include "EditorInterface.hpp"
89c4a3a6 sago007 2008-08-29 14:32 26
#include <vector>
89c4a3a6 sago007 2008-08-29 14:32 27
89c4a3a6 sago007 2008-08-29 14:32 28
//Do to stability reasons we load everything in the main and just refer to it here:
89c4a3a6 sago007 2008-08-29 14:32 29
extern SDL_Surface *bCreateFile;
89c4a3a6 sago007 2008-08-29 14:32 30
extern SDL_Surface *bDeletePuzzle;
89c4a3a6 sago007 2008-08-29 14:32 31
extern SDL_Surface *bLoadFile;
89c4a3a6 sago007 2008-08-29 14:32 32
extern SDL_Surface *bMoveBack;
89c4a3a6 sago007 2008-08-29 14:32 33
extern SDL_Surface *bMoveDown;
89c4a3a6 sago007 2008-08-29 14:32 34
extern SDL_Surface *bMoveForward;
89c4a3a6 sago007 2008-08-29 14:32 35
extern SDL_Surface *bMoveLeft;
89c4a3a6 sago007 2008-08-29 14:32 36
extern SDL_Surface *bMoveRight;
89c4a3a6 sago007 2008-08-29 14:32 37
extern SDL_Surface *bMoveUp;
89c4a3a6 sago007 2008-08-29 14:32 38
extern SDL_Surface *bNewPuzzle;
89c4a3a6 sago007 2008-08-29 14:32 39
extern SDL_Surface *bSaveFileAs;
89c4a3a6 sago007 2008-08-29 14:32 40
extern SDL_Surface *bSavePuzzle;
89c4a3a6 sago007 2008-08-29 14:32 41
extern SDL_Surface *bSaveToFile;
89c4a3a6 sago007 2008-08-29 14:32 42
extern SDL_Surface *bTestPuzzle;
89c4a3a6 sago007 2008-08-29 14:32 43
89c4a3a6 sago007 2008-08-29 14:32 44
//The screen we draw on:
89c4a3a6 sago007 2008-08-29 14:32 45
extern SDL_Surface *screen;
89c4a3a6 sago007 2008-08-29 14:32 46
89c4a3a6 sago007 2008-08-29 14:32 47
extern EditorInterface ei;
89c4a3a6 sago007 2008-08-29 14:32 48
89c4a3a6 sago007 2008-08-29 14:32 49
class aButton
89c4a3a6 sago007 2008-08-29 14:32 50
{
c53e6443 sago007 2012-04-17 11:04 51
public:
c53e6443 sago007 2012-04-17 11:04 52
	int x,y,width,height;
c53e6443 sago007 2012-04-17 11:04 53
	SDL_Surface *label;
c53e6443 sago007 2012-04-17 11:04 54
c53e6443 sago007 2012-04-17 11:04 55
	aButton()
c53e6443 sago007 2012-04-17 11:04 56
	{
c53e6443 sago007 2012-04-17 11:04 57
	}
c53e6443 sago007 2012-04-17 11:04 58
c53e6443 sago007 2012-04-17 11:04 59
	aButton(int x,int y,SDL_Surface *ss)
c53e6443 sago007 2012-04-17 11:04 60
	{
c53e6443 sago007 2012-04-17 11:04 61
		this->x = x;
c53e6443 sago007 2012-04-17 11:04 62
		this->y = y;
c53e6443 sago007 2012-04-17 11:04 63
		this->label = ss;
c53e6443 sago007 2012-04-17 11:04 64
		width = this->label->w;
c53e6443 sago007 2012-04-17 11:04 65
		height = this->label->h;
c53e6443 sago007 2012-04-17 11:04 66
	}
c53e6443 sago007 2012-04-17 11:04 67
c53e6443 sago007 2012-04-17 11:04 68
	void draw();
c53e6443 sago007 2012-04-17 11:04 69
c53e6443 sago007 2012-04-17 11:04 70
	//Function to check if the button is clicked.
c53e6443 sago007 2012-04-17 11:04 71
	bool clicked(int x, int y)
c53e6443 sago007 2012-04-17 11:04 72
	{
c53e6443 sago007 2012-04-17 11:04 73
		if((x>=this->x)&&(x<=this->x+width)&&(y>=this->y)&&(y<=this->y+height))
c53e6443 sago007 2012-04-17 11:04 74
			return true;
c53e6443 sago007 2012-04-17 11:04 75
		else
c53e6443 sago007 2012-04-17 11:04 76
			return false;
c53e6443 sago007 2012-04-17 11:04 77
	}
c53e6443 sago007 2012-04-17 11:04 78
c53e6443 sago007 2012-04-17 11:04 79
	void click(int x, int y);
89c4a3a6 sago007 2008-08-29 14:32 80
};
89c4a3a6 sago007 2008-08-29 14:32 81
89c4a3a6 sago007 2008-08-29 14:32 82
const int numberOfButtons = 14;
89c4a3a6 sago007 2008-08-29 14:32 83
89c4a3a6 sago007 2008-08-29 14:32 84
//The editor itself...
89c4a3a6 sago007 2008-08-29 14:32 85
class theEditor
89c4a3a6 sago007 2008-08-29 14:32 86
{
c53e6443 sago007 2012-04-17 11:04 87
private:
c53e6443 sago007 2012-04-17 11:04 88
	vector<aButton> buttons;
c53e6443 sago007 2012-04-17 11:04 89
c53e6443 sago007 2012-04-17 11:04 90
c53e6443 sago007 2012-04-17 11:04 91
public:
c53e6443 sago007 2012-04-17 11:04 92
c53e6443 sago007 2012-04-17 11:04 93
	theEditor();
c53e6443 sago007 2012-04-17 11:04 94
c53e6443 sago007 2012-04-17 11:04 95
	virtual void drawButtons();
c53e6443 sago007 2012-04-17 11:04 96
c53e6443 sago007 2012-04-17 11:04 97
	virtual void click(int x, int y);
c53e6443 sago007 2012-04-17 11:04 98
89c4a3a6 sago007 2008-08-29 14:32 99
};
1970-01-01 00:00 100