Skip to content

Commit

Permalink
Merge pull request #43 from olivierbutler/main
Browse files Browse the repository at this point in the history
Clear sky while in Planner / window setup autosize
  • Loading branch information
rwellinger authored Feb 21, 2024
2 parents 32534f4 + 990c552 commit c7ac196
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
45 changes: 34 additions & 11 deletions src/bp_cam.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#define MIN_BUTTON_SCALE 0.5

#define BP_PLANNER_VISIBILITY 40000 /* meters */
#define BP_PLANNER_VISIBILITY_SM 25 /* statut miles */

#define PREDICTION_DRAWING_PHASE xplm_Phase_Window
#define PREDICTION_DRAWING_PHASE_BEFORE 1
Expand All @@ -103,6 +104,7 @@ static vect2_t cursor_world_pos;
static bool_t force_root_win_focus = B_TRUE;
static float saved_visibility;
static int saved_cloud_types[3];
static float fsaved_cloud_types[3];
static bool_t saved_real_wx;
static XPLMObjectRef cam_lamp_obj = NULL;
static XPLMInstanceRef cam_lamp_inst = NULL;
Expand Down Expand Up @@ -1105,6 +1107,13 @@ find_drs(void) {
fdr_find(&drs.use_real_wx, "sim/weather/use_real_weather_bool");
}

if ( (bp_xp_ver >= 12000) && (bp_xp_ver < 13000) ) {
fdr_find(&drs.visibility, "sim/weather/region/visibility_reported_sm");
fdr_find(&drs.cloud_types[0], "sim/weather/region/cloud_type");
fdr_find(&drs.use_real_wx, "sim/weather/region/change_mode");
}


fdr_find(&drs.cam_x, "sim/graphics/view/view_x");
fdr_find(&drs.cam_y, "sim/graphics/view/view_y");
fdr_find(&drs.cam_z, "sim/graphics/view/view_z");
Expand Down Expand Up @@ -1216,25 +1225,34 @@ bp_cam_start(void) {
route_load(GEO_POS2(dr_getf(&drs.lat), dr_getf(&drs.lon)),
dr_getf(&drs.hdg), &bp.segs);
}

/*
* While the planner is active, we override the current
* visibility and real weather usage, so that the user can
* clearly see the path while planning. After we're done,
* we'll restore the settings.
*/
saved_visibility = dr_getf(&drs.visibility);
saved_real_wx = dr_geti(&drs.use_real_wx);

if (bp_xp_ver < 12000) {
/*
* While the planner is active, we override the current
* visibility and real weather usage, so that the user can
* clearly see the path while planning. After we're done,
* we'll restore the settings.
*/
saved_visibility = dr_getf(&drs.visibility);
saved_cloud_types[0] = dr_geti(&drs.cloud_types[0]);
saved_cloud_types[1] = dr_geti(&drs.cloud_types[1]);
saved_cloud_types[2] = dr_geti(&drs.cloud_types[2]);
saved_real_wx = dr_geti(&drs.use_real_wx);

dr_setf(&drs.visibility, BP_PLANNER_VISIBILITY);
dr_seti(&drs.cloud_types[0], 0);
dr_seti(&drs.cloud_types[1], 0);
dr_seti(&drs.cloud_types[2], 0);
dr_seti(&drs.use_real_wx, 0);
}
if ( (bp_xp_ver >= 12000) && (bp_xp_ver < 13000) ) {
float zero_cloud[3] = {0.0};
dr_getvf32(&drs.cloud_types[0], fsaved_cloud_types, 0, 3);
dr_setvf32(&drs.cloud_types[0], zero_cloud, 0, 3);
dr_setf(&drs.visibility, BP_PLANNER_VISIBILITY_SM);
dr_seti(&drs.use_real_wx, 3);
}

cam_inited = B_TRUE;

updateAvailable = getPluginUpdateStatus();
Expand Down Expand Up @@ -1278,13 +1296,18 @@ bp_cam_stop(void) {
cockpit_view_cmd = XPLMFindCommand("sim/view/3d_cockpit_cmnd_look");
ASSERT(cockpit_view_cmd != NULL);
XPLMCommandOnce(cockpit_view_cmd);

dr_setf(&drs.visibility, saved_visibility);
dr_seti(&drs.use_real_wx, saved_real_wx);
if (bp_xp_ver < 12000) {
dr_setf(&drs.visibility, saved_visibility);
dr_seti(&drs.cloud_types[0], saved_cloud_types[0]);
dr_seti(&drs.cloud_types[1], saved_cloud_types[1]);
dr_seti(&drs.cloud_types[2], saved_cloud_types[2]);
dr_seti(&drs.use_real_wx, saved_real_wx);
}
if ( (bp_xp_ver >= 12000) && (bp_xp_ver < 13000) ) {
dr_setvf32(&drs.cloud_types[0], fsaved_cloud_types, 0, 3);
}

cam_inited = B_FALSE;

pop_fov_values();
Expand Down
17 changes: 10 additions & 7 deletions src/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ create_main_window(void) {
int col1_width, col2_width, col3_width, col4_width;
int main_window_width, l;
char *prefs_title;
size_t main_window_height = MAIN_WINDOW_HEIGHT ;

checkbox_t col1[] = {
{_("User interface"), NULL, NULL},
Expand Down Expand Up @@ -490,12 +491,14 @@ create_main_window(void) {
col3_width = measure_checkboxes_width(radio_out);
col4_width = measure_checkboxes_width(sound_out);
main_window_width = 4 * MARGIN + col1_width + col2_width + MAX(col3_width, col4_width);

if ((buttons.num_radio_boxes + buttons.num_sound_boxes) > 6) {
main_window_height += (buttons.num_radio_boxes + buttons.num_sound_boxes) * BUTTON_HEIGHT ;
}
l = snprintf(NULL, 0, "%s", _("BetterPushback Preferences"));
prefs_title = safe_malloc(l + 1);
snprintf(prefs_title, l + 1, "%s", _("BetterPushback Preferences"));
main_win = create_widget_rel(100, 100, B_FALSE, main_window_width,
MAIN_WINDOW_HEIGHT, 0, prefs_title, 1, NULL,
main_window_height, 0, prefs_title, 1, NULL,
xpWidgetClass_MainWindow);
XPSetWidgetProperty(main_win, xpProperty_MainWindowHasCloseBoxes, 1);
XPAddWidgetCallback(main_win, main_window_cb);
Expand All @@ -521,29 +524,29 @@ create_main_window(void) {
} while (0)

LAYOUT_PUSH_BUTTON(save_cfg, (main_window_width - BUTTON_WIDTH) / 2,
MAIN_WINDOW_HEIGHT - MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT,
main_window_height - MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT,
_("Save preferences"), save_prefs_tooltip);

const int MAIN_WINDOW_SPACE = 25;

create_widget_rel(MARGIN,
MAIN_WINDOW_HEIGHT - 101 - (MAIN_WINDOW_SPACE + 10), B_FALSE,
main_window_height - 101 - (MAIN_WINDOW_SPACE + 10), B_FALSE,
main_window_width - 4 * MARGIN,
BUTTON_HEIGHT, 1, _("** Settings related to the current aircraft"), 0, main_win,
xpWidgetClass_Caption);

create_widget_rel(MARGIN,
MAIN_WINDOW_HEIGHT - 75 - MAIN_WINDOW_SPACE, B_FALSE,
main_window_height - 75 - MAIN_WINDOW_SPACE, B_FALSE,
main_window_width - 4 * MARGIN,
BUTTON_HEIGHT, 1, COPYRIGHT1, 0, main_win,
xpWidgetClass_Caption);
create_widget_rel(MARGIN,
MAIN_WINDOW_HEIGHT - 62 - MAIN_WINDOW_SPACE, B_FALSE,
main_window_height - 62 - MAIN_WINDOW_SPACE, B_FALSE,
main_window_width - 4 * MARGIN,
BUTTON_HEIGHT, 1, COPYRIGHT2, 0, main_win,
xpWidgetClass_Caption);
create_widget_rel(MARGIN,
MAIN_WINDOW_HEIGHT - 49 - (MAIN_WINDOW_SPACE - 10), B_FALSE,
main_window_height - 49 - (MAIN_WINDOW_SPACE - 10), B_FALSE,
main_window_width - 4 * MARGIN,
BUTTON_HEIGHT, 1, _(TOOLTIP_HINT), 0, main_win,
xpWidgetClass_Caption);
Expand Down

0 comments on commit c7ac196

Please sign in to comment.