|
3 | 3 |
|
4 | 4 | #include "lab_ui_helpers.h" |
5 | 5 |
|
| 6 | +#include "asteroid/asteroid.h" |
6 | 7 | #include "graphics/debug_sphere.h" |
7 | 8 | #include "graphics/matrix.h" |
8 | 9 | #include "lab/labv2_internal.h" |
@@ -91,16 +92,91 @@ void LabUi::build_weapon_subtype_list() const |
91 | 92 | } |
92 | 93 | } |
93 | 94 |
|
94 | | -void LabUi::build_weapon_list() const |
| 95 | +void LabUi::build_asteroid_list() |
| 96 | +{ |
| 97 | + with_TreeNode("Asteroids") |
| 98 | + { |
| 99 | + int asteroid_idx = 0; |
| 100 | + |
| 101 | + for (const auto& info : Asteroid_info) { |
| 102 | + if (info.type == ASTEROID_TYPE_DEBRIS) { |
| 103 | + asteroid_idx++; |
| 104 | + continue; |
| 105 | + } |
| 106 | + |
| 107 | + int subtype_idx = 0; |
| 108 | + for (const auto& subtype : info.subtypes) { |
| 109 | + SCP_string node_label; |
| 110 | + sprintf(node_label, "##AsteroidClassIndex%i_%i", asteroid_idx, subtype_idx); |
| 111 | + TreeNodeEx(node_label.c_str(), |
| 112 | + ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, |
| 113 | + "%s (%s)", |
| 114 | + info.name, |
| 115 | + subtype.type_name.c_str()); |
| 116 | + |
| 117 | + if (IsItemClicked() && !IsItemToggledOpen()) { |
| 118 | + getLabManager()->changeDisplayedObject(LabMode::Asteroid, asteroid_idx, subtype_idx); |
| 119 | + } |
| 120 | + |
| 121 | + subtype_idx++; |
| 122 | + } |
| 123 | + |
| 124 | + asteroid_idx++; |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +void LabUi::build_debris_list() |
95 | 130 | { |
96 | | - //weapon display needs to be rethought |
| 131 | + with_TreeNode("Debris") |
| 132 | + { |
| 133 | + int debris_idx = 0; |
| 134 | + |
| 135 | + for (const auto& info : Asteroid_info) { |
| 136 | + if (info.type != ASTEROID_TYPE_DEBRIS) { |
| 137 | + debris_idx++; |
| 138 | + continue; |
| 139 | + } |
97 | 140 |
|
| 141 | + int subtype_idx = 0; |
| 142 | + for (const auto& subtype : info.subtypes) { |
| 143 | + SCP_string node_label; |
| 144 | + sprintf(node_label, "##DebrisClassIndex%i_%i", debris_idx, subtype_idx); |
| 145 | + TreeNodeEx(node_label.c_str(), |
| 146 | + ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, |
| 147 | + "%s (%s)", |
| 148 | + info.name, |
| 149 | + subtype.type_name.c_str()); |
| 150 | + |
| 151 | + if (IsItemClicked() && !IsItemToggledOpen()) { |
| 152 | + getLabManager()->changeDisplayedObject(LabMode::Asteroid, debris_idx, subtype_idx); |
| 153 | + } |
| 154 | + |
| 155 | + subtype_idx++; |
| 156 | + } |
| 157 | + |
| 158 | + debris_idx++; |
| 159 | + } |
| 160 | + } |
| 161 | +} |
| 162 | + |
| 163 | +void LabUi::build_weapon_list() const |
| 164 | +{ |
98 | 165 | with_TreeNode("Weapon Classes") |
99 | 166 | { |
100 | 167 | build_weapon_subtype_list(); |
101 | 168 | } |
102 | 169 | } |
103 | 170 |
|
| 171 | +void LabUi::build_object_list() |
| 172 | +{ |
| 173 | + with_TreeNode("Asteroid/Debris Types") |
| 174 | + { |
| 175 | + build_asteroid_list(); |
| 176 | + build_debris_list(); |
| 177 | + } |
| 178 | +} |
| 179 | + |
104 | 180 | void LabUi::build_background_list() const |
105 | 181 | { |
106 | 182 | SCP_vector<SCP_string> t_missions; |
@@ -201,6 +277,8 @@ void LabUi::show_object_selector() const |
201 | 277 | build_ship_list(); |
202 | 278 |
|
203 | 279 | build_weapon_list(); |
| 280 | + |
| 281 | + build_object_list(); |
204 | 282 | } |
205 | 283 | } |
206 | 284 | } |
@@ -346,12 +424,14 @@ void LabUi::show_render_options() |
346 | 424 | Checkbox("Rotate/Translate Subsystems", &animate_subsystems); |
347 | 425 | } |
348 | 426 | Checkbox("Show full detail", &show_full_detail); |
349 | | - Checkbox("Show thrusters", &show_thrusters); |
350 | | - if (getLabManager()->CurrentMode == LabMode::Ship) { |
351 | | - Checkbox("Show afterburners", &show_afterburners); |
352 | | - Checkbox("Show weapons", &show_weapons); |
353 | | - Checkbox("Show Insignia", &show_insignia); |
354 | | - Checkbox("Show damage lightning", &show_damage_lightning); |
| 427 | + if (getLabManager()->CurrentMode != LabMode::Asteroid) { |
| 428 | + Checkbox("Show thrusters", &show_thrusters); |
| 429 | + if (getLabManager()->CurrentMode == LabMode::Ship) { |
| 430 | + Checkbox("Show afterburners", &show_afterburners); |
| 431 | + Checkbox("Show weapons", &show_weapons); |
| 432 | + Checkbox("Show Insignia", &show_insignia); |
| 433 | + Checkbox("Show damage lightning", &show_damage_lightning); |
| 434 | + } |
355 | 435 | } |
356 | 436 | Checkbox("No glowpoints", &no_glowpoints); |
357 | 437 | } |
@@ -1186,6 +1266,44 @@ void LabUi::show_object_options() const |
1186 | 1266 | } |
1187 | 1267 | } |
1188 | 1268 | } |
| 1269 | + } else if (getLabManager()->CurrentMode == LabMode::Asteroid && getLabManager()->CurrentClass >= 0) { |
| 1270 | + const auto& info = Asteroid_info[getLabManager()->CurrentClass]; |
| 1271 | + |
| 1272 | + with_CollapsingHeader("Object Info") |
| 1273 | + { |
| 1274 | + static SCP_string table_text; |
| 1275 | + static int old_class = -1; |
| 1276 | + |
| 1277 | + if (table_text.empty() || old_class != getLabManager()->CurrentClass) { |
| 1278 | + table_text = get_asteroid_table_text(&info); |
| 1279 | + old_class = getLabManager()->CurrentClass; |
| 1280 | + } |
| 1281 | + |
| 1282 | + InputTextMultiline("##asteroid_table_text", |
| 1283 | + const_cast<char*>(table_text.c_str()), |
| 1284 | + table_text.length(), |
| 1285 | + ImVec2(-FLT_MIN, GetTextLineHeight() * 16), |
| 1286 | + ImGuiInputTextFlags_ReadOnly); |
| 1287 | + } |
| 1288 | + |
| 1289 | + with_CollapsingHeader("Object actions") |
| 1290 | + { |
| 1291 | + if (getLabManager()->isSafeForAsteroids()) { |
| 1292 | + if (Button("Destroy object")) { |
| 1293 | + if (Objects[getLabManager()->CurrentObject].type == OBJ_ASTEROID) { |
| 1294 | + auto obj = &Objects[getLabManager()->CurrentObject]; |
| 1295 | + |
| 1296 | + if (obj->type == OBJ_ASTEROID) { |
| 1297 | + vec3d dummy_pos = obj->pos; |
| 1298 | + vec3d dummy_force = ZERO_VECTOR; |
| 1299 | + |
| 1300 | + // Apply full asteroid health to guarantee destruction |
| 1301 | + asteroid_hit(obj, nullptr, &dummy_pos, obj->hull_strength + 1.0f, &dummy_force); |
| 1302 | + } |
| 1303 | + } |
| 1304 | + } |
| 1305 | + } |
| 1306 | + } |
1189 | 1307 | } |
1190 | 1308 | } |
1191 | 1309 | } |
|
0 commit comments