forked from scp-fs2open/PCS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SPCL_editor.h
169 lines (147 loc) · 4.42 KB
/
SPCL_editor.h
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#pragma once
#include"model_editor_ctrl.h"
#include"array_ctrl.h"
#include"primitive_ctrl.h"
#include"pcs_file.h"
class spcl_point_ctrl :
public editor<pcs_special>
{
protected:
string_ctrl*name;
multi_string_ctrl*properties;
vector_ctrl*point;
float_ctrl*radius;
public:
spcl_point_ctrl(wxWindow*parent, wxString Title, int orient = wxVERTICAL)
:editor<pcs_special>(parent, orient, Title)
{
//add controls
std::vector<std::string> op;
op.push_back("$Engine");
op.push_back("$Weapons");
op.push_back("$Sensors");
op.push_back("$Communication");
op.push_back("$Navigation");
op.push_back("$Fighterbay");
op.push_back("$Bridge");
op.push_back("$Reactor");
add_control(name=new suggest_ctrl<std::string, string_ctrl>(this,_("Name"),op, SUGGEST_REPLACE),0,wxEXPAND);
add_control(radius=new float_ctrl(this,_("Radius")),0,wxEXPAND);
add_control(properties=new multi_string_ctrl(this,_("Properties")),0,wxEXPAND );
add_control(point=new vector_ctrl(this,_("Position")),0,wxEXPAND );
}
virtual ~spcl_point_ctrl(void){};
void set_value(const pcs_special&t){
point->set_value(t.point);
name->set_value(t.name);
properties->set_value(t.properties);
radius->set_value(t.radius);
}
//return's the control's value
pcs_special get_value(){
pcs_special t;
t.name = name->get_value();
t.radius = radius->get_value();
t.properties = properties->get_value();
t.point = point->get_value();
return t;
}
virtual void transform(const matrix& transform, const vector3d& translation) {
pcs_special special = get_value();
special.Transform(get_main_window()->get_model(), transform, translation);
set_value(special);
}
};
//control for an array of Special points
class spcl_point_array_ctrl :
public type_array_ctrl<pcs_special, spcl_point_ctrl>
{
public:
spcl_point_array_ctrl(wxWindow*parent, wxString Title, wxString subtitle, int orient = wxHORIZONTAL)
:type_array_ctrl<pcs_special, spcl_point_ctrl>(parent, subtitle, _(""), wxVERTICAL, wxEXPAND, ARRAY_ITEM)
{
}
virtual~spcl_point_array_ctrl(){}
};
std::string get_subsystem_name(int idx);
class SPCL_ctrl
:public editor_ctrl<std::vector<pcs_special> >
{
spcl_point_array_ctrl*points;
public:
static color selected_item;
static color selected_list;
static color unselected;
SPCL_ctrl(wxWindow*parent)
:editor_ctrl<std::vector<pcs_special> >(parent, _("Special Points"))
{
//add controls
add_control(points=new spcl_point_array_ctrl(this, _("Point"), _("")),0,wxEXPAND );
points->set_index_name_function(get_subsystem_name);
}
//do nothing, needed so the base destructor will get called
virtual~SPCL_ctrl(){}
//set's the control's value
void set_value(const std::vector<pcs_special>&t){
data=t;
points->set_value(t);
}
//return's the control's value
std::vector<pcs_special> get_value(){
return points->get_value();
}
//populates the control with data from the model
void set_data(PCS_Model &model){
set_value(model.get_special());
}
//applies the data in the control to the model
void apply_data(PCS_Model &model){
model.set_special(get_value());
}
void set_item(const std::vector<int>&coord){
if(coord[0]>-1 && coord[0]<(int)points->get_size())points->set_index(coord[0]);
}
std::vector<int> get_item(){
std::vector<int> ret;
ret.resize(1);
ret[0] = points->get_index();
return ret;
};
omnipoints get_omnipoints(){
omnipoints o;
o.point.resize(1);
std::vector<pcs_special> pnt = get_value();
o.point[0].resize(pnt.size());
for( unsigned int i = 0; i<pnt.size(); i++){
o.point[0][i].pos = pnt[i].point;
o.point[0][i].rad = pnt[i].radius;
}
o.flags = OMNIPOINT_RAD;
o.selected_item = selected_item;
o.selected_list = selected_list;
o.unselected = unselected;
return o;
}
void set_omnipoints(const omnipoints&points_){
std::vector<pcs_special> temp = get_value();
if(points_.point.size()!=1 || temp.size()!=points_.point[0].size())return;
for(unsigned int i = 0; i<points_.point[0].size(); i++){
temp[i].point = points_.point[0][i].pos;
temp[i].radius = points_.point[0][i].rad;
}
set_value(temp);
}
void get_omnipoint_coords(int&list, int&item){
list = 0;
item = points->get_index();
}
void set_omnipoint_coords(int&list, int&item){
points->set_index(item);
}
wxSizer* get_transform_options(wxWindow* parent) {
return NULL;
}
virtual void transform(const matrix& transform, const vector3d& translation) {
points->get_child_control()->transform(transform, translation);
}
};