1
+ #include " empire_city.h"
2
+
3
+ #include " widget/debug_console.h"
4
+ #include " imgui/imgui.h"
5
+ #include " imgui/imgui_internal.h"
6
+ #include " empire/empire_map.h"
7
+ #include " empire/empire.h"
8
+
9
+ ANK_REGISTER_PROPS_ITERATOR (config_load_selected_empire_city_properties);
10
+ ANK_REGISTER_PROPS_ITERATOR (config_load_all_empire_city_properties);
11
+
12
+ void game_debug_show_properties_object (pcstr prefix, empire_city *c) {
13
+ ImGui::PushID (0x80000000 | c->name_id );
14
+
15
+ ImGui::TableNextRow ();
16
+ ImGui::TableSetColumnIndex (0 );
17
+ ImGui::AlignTextToFramePadding ();
18
+ pcstr city_name = ui::str (195 , c->name_id );
19
+ bool common_open = ImGui::TreeNodeEx (city_name, ImGuiTreeNodeFlags_DefaultOpen, city_name);
20
+ ImGui::TableSetColumnIndex (1 );
21
+
22
+ int i = 0 ;
23
+ if (common_open) {
24
+ game_debug_show_property (i, " in_use" , c->in_use );
25
+ bstring256 type_name; type_name.printf (" %s [%d]" , token::find_name (e_empire_city_tokens, c->type ), c->type );
26
+ game_debug_show_property (i, " type<name>" , type_name);
27
+ game_debug_show_property (i, " type" , c->type );
28
+ game_debug_show_property (i, " name_id" , c->name_id );
29
+ game_debug_show_property (i, " name" , ui::str (195 , c->name_id ));
30
+ game_debug_show_property (i, " route_id" , c->route_id );
31
+ game_debug_show_property (i, " is_open" , c->is_open );
32
+ game_debug_show_property (i, " cost_to_open" , c->cost_to_open );
33
+ game_debug_show_property (i, " ph_unk01" , c->ph_unk01 );
34
+ game_debug_show_property (i, " ph_unk02" , c->ph_unk02 );
35
+ game_debug_show_property (i, " trader_entry_delay" , c->trader_entry_delay );
36
+ game_debug_show_property (i, " empire_object_id" , c->empire_object_id );
37
+ game_debug_show_property (i, " is_sea_trade" , c->is_sea_trade );
38
+ game_debug_show_property (i, " trader_figure_ids[0]" , c->trader_figure_ids [0 ], true );
39
+ game_debug_show_property (i, " trader_figure_ids[1]" , c->trader_figure_ids [1 ], true );
40
+ game_debug_show_property (i, " trader_figure_ids[2]" , c->trader_figure_ids [2 ], true );
41
+
42
+ {
43
+ ImGui::PushID (0x81000000 | c->name_id );
44
+
45
+ ImGui::TableNextRow ();
46
+ ImGui::TableSetColumnIndex (0 );
47
+ ImGui::AlignTextToFramePadding ();
48
+ const bool buy_res_open = ImGui::TreeNodeEx (" Buy Resources" , ImGuiTreeNodeFlags_DefaultOpen, " Buy Resources" );
49
+ ImGui::TableSetColumnIndex (1 );
50
+
51
+ if (buy_res_open) {
52
+ for (const auto r : resource_list::all) {
53
+ game_debug_show_property (i, ui::resource_name (r.type ), c->buys_resource [r.type ]);
54
+ }
55
+
56
+ ImGui::TreePop ();
57
+ }
58
+ ImGui::PopID ();
59
+ }
60
+
61
+ {
62
+ ImGui::PushID (0x41000000 | c->name_id );
63
+
64
+ ImGui::TableNextRow ();
65
+ ImGui::TableSetColumnIndex (0 );
66
+ ImGui::AlignTextToFramePadding ();
67
+ const bool sell_res_open = ImGui::TreeNodeEx (" Sells Resources" , ImGuiTreeNodeFlags_DefaultOpen, " Sells Resource" );
68
+ ImGui::TableSetColumnIndex (1 );
69
+
70
+ if (sell_res_open) {
71
+ for (const auto r : resource_list::all) {
72
+ game_debug_show_property (i, ui::resource_name (r.type ), c->sells_resource [r.type ]);
73
+ }
74
+
75
+ ImGui::TreePop ();
76
+ }
77
+ ImGui::PopID ();
78
+ }
79
+
80
+ ImGui::TreePop ();
81
+ }
82
+ ImGui::PopID ();
83
+ }
84
+
85
+ void config_load_selected_empire_city_properties (bool header) {
86
+ static bool _debug_city_open = true ;
87
+
88
+ if (header) {
89
+ ImGui::Checkbox (" Selected Empire City" , &_debug_city_open);
90
+ return ;
91
+ }
92
+
93
+ int selected_object = g_empire_map.selected_object ();
94
+ int selected_city = selected_object ? g_empire.get_city_for_object (selected_object - 1 ) : 0 ;
95
+
96
+ if (_debug_city_open && selected_city > 0 && ImGui::BeginTable (" split" , 2 , ImGuiTableFlags_BordersOuter | ImGuiTableFlags_Resizable)) {
97
+ empire_city *c = g_empire.city (selected_city);
98
+ game_debug_show_properties_object (" City" , c);
99
+ ImGui::EndTable ();
100
+ }
101
+ }
102
+
103
+ void config_load_all_empire_city_properties (bool header) {
104
+ static bool _debug_city_open = false ;
105
+
106
+ if (header) {
107
+ ImGui::Checkbox (" Empire Cities" , &_debug_city_open);
108
+ return ;
109
+ }
110
+
111
+ if (_debug_city_open && ImGui::BeginTable (" split" , 2 , ImGuiTableFlags_BordersOuter | ImGuiTableFlags_Resizable)) {
112
+ for (auto &city : g_empire.get_cities ()) {
113
+ game_debug_show_properties_object (" City" , &city);
114
+ }
115
+ ImGui::EndTable ();
116
+ }
117
+ }
0 commit comments