File: program.cpp

package info (click to toggle)
glest 3.2.2-2
  • links: PTS, VCS
  • area: contrib
  • in suites: squeeze
  • size: 2,800 kB
  • ctags: 6,581
  • sloc: cpp: 32,575; sh: 8,341; makefile: 63
file content (132 lines) | stat: -rw-r--r-- 2,937 bytes parent folder | download
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include "program.h"

#include "util.h" 

using namespace Shared::Util;

namespace Glest{ namespace MapEditor{

// ===============================================
//	class Program
// ===============================================

Program::Program(int w, int h){
     cellSize=6;
     ofsetX= 0;
     ofsetY= 0;
     map= new Map();
     renderer.init(w, h);
}

Program::~Program(){
     delete map;
}

void Program::changeMapHeight(int x, int y, int Height, int radius){
     map->changeHeight((x-ofsetX)/cellSize, (y+ofsetY)/cellSize, Height, radius);
}

void Program::changeMapSurface(int x, int y, int surface, int radius){
     map->changeSurface((x-ofsetX)/cellSize, (y+ofsetY)/cellSize, surface, radius);
}

void Program::changeMapObject(int x, int y, int object, int radius){
     map->changeObject((x-ofsetX)/cellSize, (y+ofsetY)/cellSize, object, radius);
}

void Program::changeMapResource(int x, int y, int resource, int radius){
     map->changeResource((x-ofsetX)/cellSize, (y+ofsetY)/cellSize, resource, radius);
}

void Program::changeStartLocation(int x, int y, int player){    
     map->changeStartLocation((x-ofsetX)/cellSize, (y+ofsetY)/cellSize, player);
}

void Program::renderMap(int w, int h){
     renderer.renderMap(map, ofsetX, ofsetY, w, h, cellSize);
}

void Program::setRefAlt(int x, int y){
	map->setRefAlt((x-ofsetX)/cellSize, (y+ofsetY)/cellSize);
}

void Program::flipX(){
	map->flipX();
}

void Program::flipY(){
	map->flipY();
}

void Program::randomizeMapHeights(){
	map->randomizeHeights();
}

void Program::randomizeMap(){
	map->randomize();
}

void Program::switchMapSurfaces(int surf1, int surf2){
	map->switchSurfaces(surf1, surf2);
}

void Program::reset(int w, int h, int alt, int surf){
     map->reset(w, h, (float) alt, surf);
}

void Program::resize(int w, int h, int alt, int surf){
     map->resize(w, h, (float) alt, surf);
}

void Program::resetPlayers(int maxPlayers){
     map->resetPlayers(maxPlayers);
}

void Program::setMapTitle(const string &title){
     map->setTitle(title);
}
 
void Program::setMapDesc(const string &desc){
     map->setDesc(desc);
}

void Program::setMapAuthor(const string &author){
     map->setAuthor(author);
}

void Program::setOfset(int x, int y){
     ofsetX+= x;
     ofsetY-= y;
}

void Program::incCellSize(int i){
    
	int minInc= 2-cellSize;

	if(i<minInc){
		i= minInc;
	}
	cellSize+= i;
	ofsetX-= (map->getW()*i)/2;
	ofsetY+= (map->getH()*i)/2;
}

void Program::resetOfset(){
     ofsetX= 0;
     ofsetY= 0;
     cellSize= 6;
}

void Program::setMapAdvanced(int altFactor, int waterLevel){
     map->setAdvanced(altFactor, waterLevel);
}

void Program::loadMap(const string &path){
     map->loadFromFile(path);
}

void Program::saveMap(const string &path){
     map->saveToFile(path);
}

}}// end namespace