-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGVPlanet.cpp
More file actions
102 lines (81 loc) · 2.27 KB
/
Copy pathGVPlanet.cpp
File metadata and controls
102 lines (81 loc) · 2.27 KB
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
/// \file GVPlanet.cpp
/// \brief class file for planet object in GalaxyView
// GVPlanet.cpp -- class file for planet object in GalaxyView
//
// Copyright 2003, Quarterflash Design Group
//
// Licensed under GPL version 2 - see COPYING for details
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "GVPlanet.h"
enum _planet_radius {
PLANET_RADIUS = 3,
PLANET_RADIUS_HALF = (PLANET_RADIUS/2),
};
GVPlanet::GVPlanet (unsigned int id, unsigned int turn) :
GVGalaxyObject (id, turn)
{
}
GVPlanet::~GVPlanet ()
{
}
void
GVPlanet::Draw (wxDC* dc, long ox, long oy, double size, double zoom,
bool center)
{
int nX;
int nY;
if (center) {
nX = int (float (x + (size / 2)) * zoom - PLANET_RADIUS_HALF);
nY = int (float (y + (size / 2)) * zoom - PLANET_RADIUS_HALF);
}
else {
nX = int (float (x) * zoom - PLANET_RADIUS_HALF);
nY = int (float (y) * zoom - PLANET_RADIUS_HALF);
}
nX -= ox;
nY -= oy;
if (zoom < 1) {
float radius = float (PLANET_RADIUS) * zoom;
if (radius < 1.0f)
radius = 1.0f;
dc->DrawCircle (nX, nY, int (radius));
}
else {
dc->DrawCircle (nX, nY, PLANET_RADIUS);
}
}
GVPlanet*
GVPlanet::LoadFromResult (Row& row)
{
unsigned int id = atoi (row[0]);
long turn = 0;
// if we have turn data set turn
if(row[4]) {
turn = atol (row[4]);
}
GVPlanet *p = new GVPlanet (id, turn);
p->x = atof (row[1]);
p->y = atof (row[2]);
// row[3] is null if the join failed
if (row[3]!=NULL) {
p->m_turn = -1;
p->m_name = row[5];
// unsigned int raceid = atoi (row[6]);
// p->m_lastOwner = GVApp::GetGalaxy()->GetRaceByID(raceid);
p->m_size = atof (row[7]);
}
return p;
}