X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCockpit%2Fpanel_io.cxx;h=64641b5f74c8f4db7aa569848e63216fe1644f74;hb=c0b4531d04215f76f9cf65afbdaed6b7c0b32634;hp=f3922b8dac9db8d56b247f3eb40f41298f44ab0e;hpb=5aee96c481e99a4b17fc9df4b7959ae2fa89ac2c;p=flightgear.git diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index f3922b8da..64641b5f7 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -29,11 +29,10 @@ #include // for strcmp() #include -#include - -#include +#include #include -#include +#include +#include #include STL_IOSTREAM #include STL_FSTREAM @@ -44,16 +43,14 @@ #include -#include "panel.hxx" +// #include "panel.hxx" #include "panel_io.hxx" //built-in layers #include "built_in/FGMagRibbon.hxx" -#if !defined (SG_HAVE_NATIVE_SGI_COMPILERS) SG_USING_STD(istream); SG_USING_STD(ifstream); -#endif SG_USING_STD(string); @@ -134,12 +131,13 @@ readTexture (const SGPropertyNode * node) //////////////////////////////////////////////////////////////////////// static void -readConditions (FGConditional * component, const SGPropertyNode * node) +readConditions (SGConditional *component, const SGPropertyNode *node) { const SGPropertyNode * conditionNode = node->getChild("condition"); if (conditionNode != 0) // The top level is implicitly AND - component->setCondition(fgReadCondition(conditionNode)); + component->setCondition(sgReadCondition(globals->get_props(), + conditionNode) ); } @@ -179,14 +177,24 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale) int y = int(node->getIntValue("y") * h_scale); int w = int(node->getIntValue("w") * w_scale); int h = int(node->getIntValue("h") * h_scale); + bool repeatable = node->getBoolValue("repeatable", true); - FGPanelAction * action = new FGPanelAction(button, x, y, w, h); + FGPanelAction * action = new FGPanelAction(button, x, y, w, h, repeatable); vectorbindings = node->getChildren("binding"); - for (unsigned int i = 0; i < bindings.size(); i++) { + + unsigned int i; + for (i = 0; i < bindings.size(); i++) { SG_LOG(SG_INPUT, SG_INFO, "Reading binding " << bindings[i]->getStringValue("command")); - action->addBinding(new FGBinding(bindings[i])); // TODO: allow modifiers + action->addBinding(new FGBinding(bindings[i]), 0); + } + + if (node->hasChild("mod-up")) { + bindings = node->getChild("mod-up")->getChildren("binding"); + for (i = 0; i < bindings.size(); i++) { + action->addBinding(new FGBinding(bindings[i]), 1); + } } readConditions(action, node); @@ -230,7 +238,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale) SGPropertyNode * target = 0; if (type.empty()) { - SG_LOG( SG_COCKPIT, SG_ALERT, + SG_LOG( SG_COCKPIT, SG_INFO, "No type supplied for transformation " << name << " assuming \"rotation\"" ); type = "rotation"; @@ -243,6 +251,9 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale) t->node = target; t->min = node->getFloatValue("min", -9999999); t->max = node->getFloatValue("max", 99999999); + t->has_mod = node->hasChild("modulator"); + if (t->has_mod) + t->mod = node->getFloatValue("modulator"); t->factor = node->getFloatValue("scale", 1.0); t->offset = node->getFloatValue("offset", 0.0); @@ -354,9 +365,11 @@ readTextChunk (const SGPropertyNode * node) else if (type == "number-value") { string propName = node->getStringValue("property"); float scale = node->getFloatValue("scale", 1.0); + float offset = node->getFloatValue("offset", 0.0); + bool truncation = node->getBoolValue("truncate", false); SGPropertyNode * target = fgGetNode(propName.c_str(), true); chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target, - format, scale); + format, scale, offset, truncation); } // Unknown type. @@ -407,7 +420,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale) if (type.empty()) { - SG_LOG( SG_COCKPIT, SG_ALERT, + SG_LOG( SG_COCKPIT, SG_INFO, "No type supplied for layer " << name << " assuming \"texture\"" ); type = "texture"; @@ -425,11 +438,8 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale) layer = new FGGroupLayer(); for (int i = 0; i < node->nChildren(); i++) { const SGPropertyNode * child = node->getChild(i); - cerr << "Trying child " << child->getName() << endl; - if (!strcmp(child->getName(), "layer")) { - cerr << "succeeded!" << endl; + if (!strcmp(child->getName(), "layer")) ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale)); - } } } @@ -472,13 +482,12 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale) // A switch instrument layer. else if (type == "switch") { - SGPropertyNode * target = - fgGetNode(node->getStringValue("property"), true); - FGInstrumentLayer * layer1 = - readLayer(node->getNode("layer[0]"), w_scale, h_scale); - FGInstrumentLayer * layer2 = - readLayer(node->getNode("layer[1]"), w_scale, h_scale); - layer = new FGSwitchLayer(w, h, target, layer1, layer2); + layer = new FGSwitchLayer(); + for (int i = 0; i < node->nChildren(); i++) { + const SGPropertyNode * child = node->getChild(i); + if (!strcmp(child->getName(), "layer")) + ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale)); + } } // A built-in instrument layer.