Debian Codegraph @

src/Model/validateSharedModels.cxx

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2025 James Turner
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include "config.h"
5
6 #include <Model/validateSharedModels.hxx>
7
8 // SimGear
9 #include <simgear/misc/ResourceManager.hxx>
10
11 #include <GUI/MessageBox.hxx>
12 #include <Main/fg_props.hxx>
13 #include <Main/globals.hxx>
14 #include <Main/locale.hxx>
15
16 namespace flightgear {
17
18 static bool static_haveShownError = false;
19
20 bool validateSharedModels()
21 {
22 string_list paths = {
23 "Models/Airport/marker.ac",
24 "Models/Airport/beacon.xml",
25 "Models/Airport/localizer.xml",
26 "Models/Airport/windsock_lit.xml",
27 "Models/Misc/trigpoint.ac",
28 "Models/Industrial/generic_chimney_01.xml",
29 "Models/Airport/Vehicle/Cobus_3000.xml",
30 "Models/Industrial/GenericStorageTank40m.ac",
31 "Models/Boundaries/Fence_50m.ac",
32 "Models/Residential/french_house_s.xml",
33 "Models/Power/generic_pylon_50m.ac"};
34
35 bool missing = false;
36 for (const auto& p : paths) {
37 SGPath ex = simgear::ResourceManager::instance()->findPath(p);
38 if (!ex.exists()) {
39 missing = true;
40 break;
41 }
42 }
43
44 // exit here if all the test paths were found correctly
45 if (!missing) {
46 return true; // validate succeeded
47 }
48
49 if (static_haveShownError) {
50 return false; // still return the status, but no need to show again (eg, re-init)
51 }
52
53 const auto usingTerraSync = fgGetBool("/sim/terrasync/enabled");
54 const auto title = globals->get_locale()->getLocalizedString("shared-models-missing-title", "sys");
55 const auto msg = globals->get_locale()->getLocalizedString(usingTerraSync ? "shared-models-missing-terrasync" : "shared-models-missing", "sys");
56 modalMessageBox(title, msg);
57 static_haveShownError = true;
58 return false; // validate failed
59 }
60
61 bool haveShownSharedModelsError()
62 {
63 return static_haveShownError;
64 }
65
66 } // namespace flightgear