+
+ //
+ // Create each instrument.
+ //
+ SG_LOG( SG_COCKPIT, SG_INFO, "Reading panel instruments" );
+ const SGPropertyNode * instrument_group = root->getChild("instruments");
+ if (instrument_group != 0) {
+ int nInstruments = instrument_group->nChildren();
+ for (int i = 0; i < nInstruments; i++) {
+ const SGPropertyNode * node = instrument_group->getChild(i);
+ if (!strcmp(node->getName(), "instrument")) {
+ FGPanelInstrument * instrument = readInstrument(node);
+ if (instrument != 0)
+ panel->addInstrument(instrument);
+ } else if (!strcmp(node->getName(), "special-instrument")) {
+ //cout << "Special instrument found in instruments section!\n";
+ const string name = node->getStringValue("name");
+ if (name == "KLN89 GPS") {
+ //cout << "Special instrument is KLN89\n";
+
+ int x = node->getIntValue("x", -1);
+ int y = node->getIntValue("y", -1);
+ int real_w = node->getIntValue("w", -1);
+ int real_h = node->getIntValue("h", -1);
+ int w = node->getIntValue("w-base", -1);
+ int h = node->getIntValue("h-base", -1);
+
+ if (x == -1 || y == -1) {
+ SG_LOG( SG_COCKPIT, SG_ALERT,
+ "x and y positions must be specified and > 0" );
+ return 0;
+ }
+
+ float w_scale = 1.0;
+ float h_scale = 1.0;
+ if (real_w != -1) {
+ w_scale = float(real_w) / float(w);
+ w = real_w;
+ }
+ if (real_h != -1) {
+ h_scale = float(real_h) / float(h);
+ h = real_h;
+ }
+
+ SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading instrument " << name );
+
+ // Warning - hardwired size!!!
+ RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y);
+ KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+ if (gps == NULL) {
+ gps = new KLN89(instrument);
+ globals->add_subsystem("kln89", gps);
+ }
+ //gps->init(); // init seems to get called automagically.
+ FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps);
+ panel->addInstrument(gpsinst);
+ } else {
+ SG_LOG( SG_COCKPIT, SG_WARN, "Unknown special instrument found" );
+ }
+ } else {
+ SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
+ << " in instruments section" );
+ }