Skip to content

Commit c7dac51

Browse files
committed
Sort props by category
1 parent bea30e3 commit c7dac51

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")
@@ -172,24 +198,11 @@ void LabUi::build_object_list()
172198
}
173199
}
174200

175-
void LabUi::build_prop_list()
201+
void LabUi::build_prop_list() const
176202
{
177203
with_TreeNode("Prop Classes")
178204
{
179-
int prop_info_idx = 0;
180-
181-
for (auto const& class_def : Prop_info) {
182-
SCP_string node_label;
183-
sprintf(node_label, "##PropClassIndex%i", prop_info_idx);
184-
TreeNodeEx(node_label.c_str(),
185-
ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen,
186-
"%s",
187-
class_def.name);
188-
if (IsItemClicked() && !IsItemToggledOpen()) {
189-
getLabManager()->changeDisplayedObject(LabMode::Prop, prop_info_idx);
190-
}
191-
prop_info_idx++;
192-
}
205+
build_prop_subtype_list();
193206
}
194207
}
195208

@@ -294,9 +307,9 @@ void LabUi::show_object_selector() const
294307

295308
build_weapon_list();
296309

297-
build_object_list();
298-
299310
build_prop_list();
311+
312+
build_object_list();
300313
}
301314
}
302315
}

code/lab/dialogs/lab_ui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class LabUi {
3232
static void build_object_list();
3333
static void build_asteroid_list();
3434
static void build_debris_list();
35-
static void build_prop_list();
35+
void build_prop_list() const;
36+
void build_prop_subtype_list() const;
3637
void build_background_list() const;
3738
void show_render_options();
3839
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
@@ -452,7 +452,7 @@ SCP_string get_prop_table_text(const prop_info* pip)
452452
while (line2[i] == ' ' || line2[i] == '\t' || line2[i] == '@')
453453
i++;
454454

455-
if (!stricmp(line2 + i, pip->name)) {
455+
if (!stricmp(line2 + i, pip->name.c_str())) {
456456
result += "-- props.tbl -------------------------------\r\n";
457457
found = 1;
458458
}
@@ -510,7 +510,7 @@ SCP_string get_prop_table_text(const prop_info* pip)
510510
while (line2[i] == ' ' || line2[i] == '\t' || line2[i] == '@')
511511
i++;
512512

513-
if (!stricmp(line2 + i, pip->name)) {
513+
if (!stricmp(line2 + i, pip->name.c_str())) {
514514
memset(file_text, 0, sizeof(file_text));
515515
snprintf(file_text,
516516
sizeof(file_text) - 1,

code/mission/missionparse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5256,7 +5256,7 @@ void post_process_path_stuff()
52565256
}
52575257

52585258
// MjnMixael
5259-
void post_process_props()
5259+
void post_process_mission_props()
52605260
{
52615261
for (int i = 0; i < static_cast<int>(Parse_props.size()); i++) {
52625262
parsed_prop* propp = &Parse_props[i];
@@ -6632,7 +6632,7 @@ bool post_process_mission(mission *pm)
66326632
ship_weapon *swp;
66336633
ship_obj *so;
66346634

6635-
post_process_props();
6635+
post_process_mission_props();
66366636

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

code/model/modelrender.cpp

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

30643064
// Make sure model is loaded
3065-
model_num = model_load(pip->pof_file);
3065+
model_num = model_load(pip->pof_file.c_str());
30663066

30673067
break;
30683068

code/parse/sexp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4480,7 +4480,7 @@ void preload_change_prop_class(const char* text)
44804480
return;
44814481

44824482
pip = &Prop_info[idx];
4483-
pip->model_num = model_load(pip->pof_file);
4483+
pip->model_num = model_load(pip->pof_file.c_str());
44844484

44854485
if (pip->model_num >= 0)
44864486
model_page_in_textures(pip->model_num, idx);

0 commit comments

Comments
 (0)