Skip to content

Commit e5ebbf1

Browse files
committed
Sort props by category
1 parent 166e36b commit e5ebbf1

File tree

12 files changed

+201
-52
lines changed

12 files changed

+201
-52
lines changed

code/lab/dialogs/lab_ui.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,32 @@ void LabUi::build_weapon_subtype_list() const
9393
}
9494
}
9595

96+
void LabUi::build_prop_subtype_list() const
97+
{
98+
for (size_t i = 0; i < Prop_categories.size(); i++) {
99+
with_TreeNode(Prop_categories[i].name.c_str())
100+
{
101+
int prop_idx = 0;
102+
103+
for (auto const& class_def : Prop_info) {
104+
if (lcase_equal(class_def.category, Prop_categories[i].name)) {
105+
SCP_string node_label;
106+
sprintf(node_label, "##PropClassIndex%i", prop_idx);
107+
TreeNodeEx(node_label.c_str(),
108+
ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen,
109+
"%s",
110+
class_def.name.c_str());
111+
112+
if (IsItemClicked() && !IsItemToggledOpen()) {
113+
getLabManager()->changeDisplayedObject(LabMode::Prop, prop_idx);
114+
}
115+
}
116+
prop_idx++;
117+
}
118+
}
119+
}
120+
}
121+
96122
void LabUi::build_asteroid_list()
97123
{
98124
with_TreeNode("Asteroids")
@@ -178,24 +204,11 @@ void LabUi::build_object_list()
178204
}
179205
}
180206

181-
void LabUi::build_prop_list()
207+
void LabUi::build_prop_list() const
182208
{
183209
with_TreeNode("Prop Classes")
184210
{
185-
int prop_info_idx = 0;
186-
187-
for (auto const& class_def : Prop_info) {
188-
SCP_string node_label;
189-
sprintf(node_label, "##PropClassIndex%i", prop_info_idx);
190-
TreeNodeEx(node_label.c_str(),
191-
ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen,
192-
"%s",
193-
class_def.name);
194-
if (IsItemClicked() && !IsItemToggledOpen()) {
195-
getLabManager()->changeDisplayedObject(LabMode::Prop, prop_info_idx);
196-
}
197-
prop_info_idx++;
198-
}
211+
build_prop_subtype_list();
199212
}
200213
}
201214

@@ -300,9 +313,9 @@ void LabUi::show_object_selector() const
300313

301314
build_weapon_list();
302315

303-
build_object_list();
304-
305316
build_prop_list();
317+
318+
build_object_list();
306319
}
307320
}
308321
}

code/lab/dialogs/lab_ui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class LabUi {
2727
static void build_object_list();
2828
static void build_asteroid_list();
2929
static void build_debris_list();
30-
static void build_prop_list();
30+
void build_prop_list() const;
31+
void build_prop_subtype_list() const;
3132
void build_background_list() const;
3233
void show_render_options();
3334
void show_object_options() const;

code/lab/dialogs/lab_ui_helpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ SCP_string get_prop_table_text(const prop_info* pip)
436436
while (line2[i] == ' ' || line2[i] == '\t' || line2[i] == '@')
437437
i++;
438438

439-
if (!stricmp(line2 + i, pip->name)) {
439+
if (!stricmp(line2 + i, pip->name.c_str())) {
440440
result += "-- props.tbl -------------------------------\r\n";
441441
found = 1;
442442
}
@@ -494,7 +494,7 @@ SCP_string get_prop_table_text(const prop_info* pip)
494494
while (line2[i] == ' ' || line2[i] == '\t' || line2[i] == '@')
495495
i++;
496496

497-
if (!stricmp(line2 + i, pip->name)) {
497+
if (!stricmp(line2 + i, pip->name.c_str())) {
498498
memset(file_text, 0, sizeof(file_text));
499499
snprintf(file_text,
500500
sizeof(file_text) - 1,

code/mission/missionparse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5081,7 +5081,7 @@ void post_process_path_stuff()
50815081
}
50825082

50835083
// MjnMixael
5084-
void post_process_props()
5084+
void post_process_mission_props()
50855085
{
50865086
for (int i = 0; i < static_cast<int>(Parse_props.size()); i++) {
50875087
parsed_prop* propp = &Parse_props[i];
@@ -6457,7 +6457,7 @@ bool post_process_mission(mission *pm)
64576457
ship_weapon *swp;
64586458
ship_obj *so;
64596459

6460-
post_process_props();
6460+
post_process_mission_props();
64616461

64626462
// Goober5000 - this must be done even before post_process_ships_wings because it is a prerequisite
64636463
ship_clear_ship_type_counts();

code/model/modelrender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ bool render_tech_model(tech_render_type model_type, int x1, int y1, int x2, int
30553055
}
30563056

30573057
// Make sure model is loaded
3058-
model_num = model_load(pip->pof_file);
3058+
model_num = model_load(pip->pof_file.c_str());
30593059

30603060
break;
30613061

code/parse/sexp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4454,7 +4454,7 @@ void preload_change_prop_class(const char* text)
44544454
// preload the model, just in case there is no other prop of this class in the mission
44554455
// (this eliminates the slight pause during a mission when changing to a previously unloaded model)
44564456
pip = &Prop_info[idx];
4457-
pip->model_num = model_load(pip->pof_file);
4457+
pip->model_num = model_load(pip->pof_file.c_str());
44584458

44594459
if (pip->model_num >= 0)
44604460
model_page_in_textures(pip->model_num, idx);

0 commit comments

Comments
 (0)