1
0
Fork 0

- make function table and lookup function

- make unnamed elements explicitly "[unnamed]"
This commit is contained in:
mfranz 2006-06-15 18:09:15 +00:00
parent ed7ee6b534
commit d336553d75
8 changed files with 79 additions and 157 deletions

View file

@ -729,3 +729,66 @@ void fgCockpitUpdate( void ) {
glViewport( 0, 0, iwidth, iheight );
}
struct FuncTable {
char *name;
FLTFNPTR func;
} fn_table[] = {
{ "agl", get_agl },
{ "aileronval", get_aileronval },
{ "altitude", get_altitude },
{ "anzg", get_anzg },
{ "aoa", get_aoa },
{ "ax", get_Ax },
{ "climb", get_climb_rate },
{ "elevatortrimval", get_elev_trimval },
{ "elevatorval", get_elevatorval },
{ "fov", get_fov },
{ "framerate", get_frame_rate },
{ "heading", get_heading },
{ "latitude", get_latitude },
{ "longitude", get_longitude },
{ "mach", get_mach },
{ "rudderval", get_rudderval },
{ "speed", get_speed },
{ "throttleval", get_throttleval },
{ "view_direction", get_view_direction },
{ "vfc_tris_culled", get_vfc_tris_culled },
{ "vfc_tris_drawn", get_vfc_tris_drawn },
#ifdef ENABLE_SP_FMDS
{ "aux1", get_aux1 },
{ "aux2", get_aux2 },
{ "aux3", get_aux3 },
{ "aux4", get_aux4 },
{ "aux5", get_aux5 },
{ "aux6", get_aux6 },
{ "aux7", get_aux7 },
{ "aux8", get_aux8 },
{ "aux9", get_aux9 },
{ "aux10", get_aux10 },
{ "aux11", get_aux11 },
{ "aux12", get_aux12 },
{ "aux13", get_aux13 },
{ "aux14", get_aux14 },
{ "aux15", get_aux15 },
{ "aux16", get_aux16 },
{ "aux17", get_aux17 },
{ "aux18", get_aux18 },
#endif
{ 0, 0 },
};
FLTFNPTR get_func(const char *name)
{
for (int i = 0; fn_table[i].name; i++)
if (!strcmp(fn_table[i].name, name))
return fn_table[i].func;
return 0;
}

View file

@ -16,6 +16,7 @@
#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif
FLTFNPTR get_func(const char *name); // FIXME
hud_card::hud_card(const SGPropertyNode *node) :
instr_scale(
@ -32,7 +33,7 @@ hud_card::hud_card(const SGPropertyNode *node) :
node->getIntValue("major_divs"),
node->getIntValue("minor_divs"),
node->getIntValue("modulator"),
node->getBoolValue("working")),
node->getBoolValue("working", true)),
val_span(node->getFloatValue("value_span")), // FIXME
type(node->getStringValue("type")),
draw_tick_bottom(node->getBoolValue("tick_bottom", false)),
@ -59,39 +60,7 @@ hud_card::hud_card(const SGPropertyNode *node) :
SG_LOG(SG_INPUT, SG_INFO, "Done reading dial/tape instrument "
<< node->getStringValue("name", "[unnamed]"));
string loadfn = node->getStringValue("loadfn");
float (*load_fn)(void);
if (loadfn == "anzg")
load_fn = get_anzg;
else if (loadfn == "heading")
load_fn = get_heading;
else if (loadfn == "aoa")
load_fn = get_aoa;
else if (loadfn == "climb")
load_fn = get_climb_rate;
else if (loadfn == "altitude")
load_fn = get_altitude;
else if (loadfn == "agl")
load_fn = get_agl;
else if (loadfn == "speed")
load_fn = get_speed;
else if (loadfn == "view_direction")
load_fn = get_view_direction;
else if (loadfn == "aileronval")
load_fn = get_aileronval;
else if (loadfn == "elevatorval")
load_fn = get_elevatorval;
else if (loadfn == "elevatortrimval")
load_fn = get_elev_trimval;
else if (loadfn == "rudderval")
load_fn = get_rudderval;
else if (loadfn == "throttleval")
load_fn = get_throttleval;
else
load_fn = 0;
set_data_source(load_fn);
set_data_source(get_func(node->getStringValue("loadfn")));
half_width_units = range_to_show() / 2.0;
}

View file

@ -6,6 +6,7 @@
#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif
FLTFNPTR get_func(const char *name); // FIXME
gauge_instr::gauge_instr(const SGPropertyNode *node) :
instr_scale(
@ -23,43 +24,12 @@ gauge_instr::gauge_instr(const SGPropertyNode *node) :
node->getIntValue("minor_divs"),
node->getIntValue("modulator"), // "rollover"
0, /* hud.cxx: static int dp_shoing = 0; */ // FIXME
node->getBoolValue("working"))
node->getBoolValue("working", true))
{
SG_LOG(SG_INPUT, SG_INFO, "Done reading gauge instrument "
<< node->getStringValue("name", "[unnamed]"));
string loadfn = node->getStringValue("loadfn"); // FIXME
float (*load_fn)(void);
if (loadfn=="anzg") {
load_fn = get_anzg;
} else if (loadfn=="heading") {
load_fn = get_heading;
} else if (loadfn=="aoa") {
load_fn = get_aoa;
} else if (loadfn=="climb") {
load_fn = get_climb_rate;
} else if (loadfn=="altitude") {
load_fn = get_altitude;
} else if (loadfn=="agl") {
load_fn = get_agl;
} else if (loadfn=="speed") {
load_fn = get_speed;
} else if (loadfn=="view_direction") {
load_fn = get_view_direction;
} else if (loadfn=="aileronval") {
load_fn = get_aileronval;
} else if (loadfn=="elevatorval") {
load_fn = get_elevatorval;
} else if (loadfn=="elevatortrimval") {
load_fn = get_elev_trimval;
} else if (loadfn=="rudderval") {
load_fn = get_rudderval;
} else if (loadfn=="throttleval") {
load_fn = get_throttleval;
} else
load_fn = 0;
set_data_source(load_fn);
set_data_source(get_func(node->getStringValue("loadfn")));
}

View file

@ -8,13 +8,7 @@
#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif
// FIXME
extern float get_aux1(), get_aux2(), get_aux3(), get_aux4(), get_aux5(), get_aux6();
extern float get_aux7(), get_aux8(), get_aux9(), get_aux10(), get_aux11(), get_aux12();
extern float get_aux13(), get_aux14(), get_aux15(), get_aux16(), get_aux17(), get_aux18();
extern float get_Ax(), get_speed(), get_mach(), get_altitude(), get_agl(), get_frame_rate();
extern float get_heading(), get_fov(), get_vfc_tris_culled(), get_vfc_tris_drawn(), get_aoa();
extern float get_latitude(), get_anzg(), get_longitude(), get_throttleval();
FLTFNPTR get_func(const char *name); // FIXME
instr_label::instr_label(const SGPropertyNode *node) :
instr_item(
@ -25,7 +19,7 @@ instr_label::instr_label(const SGPropertyNode *node) :
NULL /* node->getStringValue("data_source") */, // FIXME
node->getFloatValue("scale_data"),
node->getIntValue("options"),
node->getBoolValue("working"),
node->getBoolValue("working", true),
node->getIntValue("digits")),
pformat(node->getStringValue("label_format")),
pre_str(node->getStringValue("pre_label_string")),
@ -37,83 +31,9 @@ instr_label::instr_label(const SGPropertyNode *node) :
lbox(node->getBoolValue("label_box", false))
{
SG_LOG(SG_INPUT, SG_INFO, "Done reading instr_label instrument "
<< node->getStringValue("name", "[none]"));
<< node->getStringValue("name", "[unnamed]"));
string loadfn = node->getStringValue("data_source"); // FIXME
float (*load_fn)(void);
#ifdef ENABLE_SP_FMDS
if (loadfn == "aux1")
load_fn = get_aux1;
else if (loadfn == "aux2")
load_fn = get_aux2;
else if (loadfn == "aux3")
load_fn = get_aux3;
else if (loadfn == "aux4")
load_fn = get_aux4;
else if (loadfn == "aux5")
load_fn = get_aux5;
else if (loadfn == "aux6")
load_fn = get_aux6;
else if (loadfn == "aux7")
load_fn = get_aux7;
else if (loadfn == "aux8")
load_fn = get_aux8;
else if (loadfn == "aux9")
load_fn = get_aux9;
else if (loadfn == "aux10")
load_fn = get_aux10;
else if (loadfn == "aux11")
load_fn = get_aux11;
else if (loadfn == "aux12")
load_fn = get_aux12;
else if (loadfn == "aux13")
load_fn = get_aux13;
else if (loadfn == "aux14")
load_fn = get_aux14;
else if (loadfn == "aux15")
load_fn = get_aux15;
else if (loadfn == "aux16")
load_fn = get_aux16;
else if (loadfn == "aux17")
load_fn = get_aux17;
else if (loadfn == "aux18")
load_fn = get_aux18;
else
#endif
if (loadfn == "ax")
load_fn = get_Ax;
else if (loadfn == "speed")
load_fn = get_speed;
else if (loadfn == "mach")
load_fn = get_mach;
else if (loadfn == "altitude")
load_fn = get_altitude;
else if (loadfn == "agl")
load_fn = get_agl;
else if (loadfn == "framerate")
load_fn = get_frame_rate;
else if (loadfn == "heading")
load_fn = get_heading;
else if (loadfn == "fov")
load_fn = get_fov;
else if (loadfn == "vfc_tris_culled")
load_fn = get_vfc_tris_culled;
else if (loadfn == "vfc_tris_drawn")
load_fn = get_vfc_tris_drawn;
else if (loadfn == "aoa")
load_fn = get_aoa;
else if (loadfn == "latitude")
load_fn = get_latitude;
else if (loadfn == "anzg")
load_fn = get_anzg;
else if (loadfn == "longitude")
load_fn = get_longitude;
else if (loadfn =="throttleval")
load_fn = get_throttleval;
else
load_fn = 0;
set_data_source(load_fn);
set_data_source(get_func(node->getStringValue("data_source")));
int just = node->getIntValue("justification");
if (just == 0)

View file

@ -21,7 +21,7 @@ HudLadder::HudLadder(const SGPropertyNode *node) :
node->getIntValue("height"),
get_roll,
get_pitch, // FIXME getter functions from cockpit.cxx
node->getBoolValue("working"),
node->getBoolValue("working", true),
HUDS_RIGHT),
width_units(int(node->getFloatValue("span_units"))),
div_units(int(fabs(node->getFloatValue("division_units")))),
@ -52,7 +52,7 @@ HudLadder::HudLadder(const SGPropertyNode *node) :
factor = 640.0 / 55.0;
SG_LOG(SG_INPUT, SG_INFO, "Done reading HudLadder instrument"
<< node->getStringValue("name", "[NONE]"));
<< node->getStringValue("name", "[unnamed]"));
if (!width_units)
width_units = 45;

View file

@ -62,7 +62,7 @@ runway_instr::runway_instr(const SGPropertyNode *node) :
drawIAAlways(arrowScale > 0 ? node->getBoolValue("arrow_always") : false)
{
SG_LOG(SG_INPUT, SG_INFO, "Done reading runway instrument "
<< node->getStringValue("name"));
<< node->getStringValue("name", "[unnamed]"));
view[0] = 0;
view[1] = 0;

View file

@ -23,7 +23,7 @@ fgTBI_instr::fgTBI_instr(const SGPropertyNode *node) :
node->getIntValue("height"),
get_roll, // FIXME
get_sideslip,
node->getBoolValue("working"),
node->getBoolValue("working", true),
HUDS_TOP),
BankLimit(int(node->getFloatValue("maxBankAngle"))),
SlewLimit(int(node->getFloatValue("maxSlipAngle"))),
@ -33,7 +33,7 @@ fgTBI_instr::fgTBI_instr(const SGPropertyNode *node) :
{
SG_LOG(SG_INPUT, SG_INFO, "Done reading TBI instrument"
<< node->getStringValue("name", "[NONE]"));
<< node->getStringValue("name", "[unnamed]"));
}

View file

@ -22,7 +22,7 @@
# include <config.h>
#endif
#ifdef HAVE_WINDOWS_H
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif