Skip to content

Commit 04c2913

Browse files
Merge pull request #6903 from MjnMixael/lab_misc_fixes
Misc Lab Fixes
2 parents 75a7fc5 + 3f0c330 commit 04c2913

6 files changed

Lines changed: 42 additions & 38 deletions

File tree

code/ai/aicode.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12125,9 +12125,11 @@ void ai_process_subobjects(int objnum)
1212512125

1212612126
bool in_lab = gameseq_get_state() == GS_STATE_LAB;
1212712127

12128-
// non-player ships that are playing dead do not process subsystems or turrets
12129-
if ((!(objp->flags[Object::Object_Flags::Player_ship]) || Player_use_ai) && aip->mode == AIM_PLAY_DEAD)
12130-
return;
12128+
// non-player ships that are playing dead do not process subsystems or turrets unless we're in the lab
12129+
if (gameseq_get_state() != GS_STATE_LAB) {
12130+
if ((!(objp->flags[Object::Object_Flags::Player_ship]) || Player_use_ai) && aip->mode == AIM_PLAY_DEAD)
12131+
return;
12132+
}
1213112133

1213212134
polymodel_instance *pmi = model_get_instance(shipp->model_instance_num);
1213312135
polymodel *pm = model_get(pmi->model_num);

code/ai/aigoals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ enum ai_goal_mode : uint8_t
8080
AI_GOAL_FLY_TO_SHIP,
8181
AI_GOAL_IGNORE_NEW,
8282
AI_GOAL_CHASE_SHIP_CLASS,
83-
AI_GOAL_PLAY_DEAD_PERSISTENT, // Disables subsystem rotation/translation among other things but there is a carveout for that in the lab only in ship_move_subsystems()
83+
AI_GOAL_PLAY_DEAD_PERSISTENT, // Disables subsystem rotation/translation among other things but there is a carveout for that in the lab in ship_move_subsystems() and ai_process_subobjects()
8484
AI_GOAL_LUA,
8585
AI_GOAL_DISARM_SHIP_TACTICAL,
8686
AI_GOAL_DISABLE_SHIP_TACTICAL,

code/lab/dialogs/lab_ui.cpp

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,37 +1029,10 @@ void LabUi::build_secondary_weapon_combobox(SCP_string& text, weapon_info* wip,
10291029
}
10301030
}
10311031

1032-
void LabUi::reset_animations(ship* shipp, ship_info* sip) const
1032+
void LabUi::reset_animations()
10331033
{
1034-
polymodel_instance* shipp_pmi = model_get_instance(shipp->model_instance_num);
1035-
1036-
for (auto i = 0; i < MAX_SHIP_PRIMARY_BANKS; ++i) {
1037-
if (triggered_primary_banks[i]) {
1038-
sip->animations.getAll(shipp_pmi, animation::ModelAnimationTriggerType::PrimaryBank, i)
1039-
.start(animation::ModelAnimationDirection::RWD);
1040-
triggered_primary_banks[i] = false;
1041-
}
1042-
}
1043-
1044-
for (auto i = 0; i < MAX_SHIP_SECONDARY_BANKS; ++i) {
1045-
if (triggered_secondary_banks[i]) {
1046-
sip->animations.getAll(shipp_pmi, animation::ModelAnimationTriggerType::SecondaryBank, i)
1047-
.start(animation::ModelAnimationDirection::RWD);
1048-
triggered_secondary_banks[i] = false;
1049-
}
1050-
}
1051-
1052-
for (auto& entry : manual_animations) {
1053-
if (entry.second) {
1054-
sip->animations.getAll(shipp_pmi, entry.first).start(animation::ModelAnimationDirection::RWD);
1055-
entry.second = false;
1056-
}
1057-
}
1058-
1059-
for (const auto& entry : manual_animation_triggers) {
1060-
auto animation_type = entry.first;
1061-
sip->animations.getAll(shipp_pmi, animation_type).start(animation::ModelAnimationDirection::RWD);
1062-
}
1034+
// With full animation support for docking stages and fighter bays it's honestly just easier to reload the current object
1035+
getLabManager()->changeDisplayedObject(getLabManager()->CurrentMode, getLabManager()->CurrentClass, getLabManager()->CurrentSubtype);
10631036
}
10641037

10651038
void LabUi::maybe_show_animation_category(const SCP_vector<animation::ModelAnimationSet::RegisteredTrigger>& anim_triggers,
@@ -1070,10 +1043,35 @@ void LabUi::maybe_show_animation_category(const SCP_vector<animation::ModelAnima
10701043
})) {
10711044
with_TreeNode(label.c_str())
10721045
{
1046+
int count = 1;
10731047
for (const auto& anim_trigger : anim_triggers) {
10741048
if (anim_trigger.type == trigger_type) {
10751049

1076-
if (Button(anim_trigger.name.c_str())) {
1050+
SCP_string button_label = anim_trigger.name;
1051+
switch (trigger_type) {
1052+
case animation::ModelAnimationTriggerType::DockBayDoor:
1053+
button_label += "Trigger Bay Door Animation " + std::to_string(count++);
1054+
break;
1055+
case animation::ModelAnimationTriggerType::Docking_Stage1:
1056+
button_label += "Trigger Docking Stage 1 Animation " + std::to_string(count++);
1057+
break;
1058+
case animation::ModelAnimationTriggerType::Docking_Stage2:
1059+
button_label += "Trigger Docking Stage 2 Animation " + std::to_string(count++);
1060+
break;
1061+
case animation::ModelAnimationTriggerType::Docking_Stage3:
1062+
button_label += "Trigger Docking Stage 3 Animation " + std::to_string(count++);
1063+
break;
1064+
case animation::ModelAnimationTriggerType::Docked:
1065+
button_label += "Trigger Docked Animation " + std::to_string(count++);
1066+
break;
1067+
default:
1068+
// We really shouldn't be here, but just in case
1069+
Assertion(false, "Unexpected animation trigger type %d", static_cast<int>(trigger_type));
1070+
button_label += "Trigger Animation " + std::to_string(count++);
1071+
break;
1072+
}
1073+
1074+
if (Button(button_label.c_str())) {
10771075
auto& scripted_triggers = manual_animation_triggers[trigger_type];
10781076
auto direction = scripted_triggers[anim_trigger.name];
10791077
do_triggered_anim(trigger_type,
@@ -1095,7 +1093,7 @@ void LabUi::build_animation_options(ship* shipp, ship_info* sip) const
10951093
const auto& anim_triggers = sip->animations.getRegisteredTriggers();
10961094

10971095
if (Button("Reset animations")) {
1098-
reset_animations(shipp, sip);
1096+
reset_animations();
10991097
}
11001098

11011099
if (shipp->weapons.num_primary_banks > 0) {
@@ -1135,6 +1133,9 @@ void LabUi::build_animation_options(ship* shipp, ship_info* sip) const
11351133
maybe_show_animation_category(anim_triggers,
11361134
animation::ModelAnimationTriggerType::Docking_Stage3,
11371135
"Docking stage 3##anims");
1136+
maybe_show_animation_category(anim_triggers,
1137+
animation::ModelAnimationTriggerType::Docked,
1138+
"Docked animations##anims");
11381139
}
11391140
}
11401141

code/lab/dialogs/lab_ui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class LabUi {
6060
ship_info* sip) const;
6161
void build_model_info_box_actual(ship_info* sip, polymodel* pm) const;
6262
void build_team_color_combobox() const;
63-
void reset_animations(ship* shipp, ship_info* sip) const;
63+
static void reset_animations();
6464
void do_triggered_anim(animation::ModelAnimationTriggerType type,
6565
const SCP_string& name,
6666
bool direction,

code/lab/manager/lab_manager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ void LabManager::cleanup() {
421421
Player_ship = nullptr;
422422
}
423423

424-
Cmdline_dis_collisions = Saved_cmdline_collisions_value;
425424
}
426425

427426
void LabManager::deleteDockerObject() {

code/lab/manager/lab_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class LabManager {
5353

5454
cleanup();
5555

56+
Cmdline_dis_collisions = Saved_cmdline_collisions_value;
57+
5658
LabRenderer::close();
5759

5860
// Unload any asteroids that were loaded

0 commit comments

Comments
 (0)