We got a metric ton of “bug reports” that users couldn’t click “Disable VR” when using the 3-d mouse. ![]() A few notes on usability: Have Your Mouse Cake and Eat It In_out_lbrt = in_out_lbrt + (1.We’re starting internal and private testing of VR preview 4 – if it goes well, we’ll release it early next week. In_out_lbrt = in_out_lbrt + XPLMMeasureString( xplmFont_Proportional, text, strlen(text)) // *just* wide enough to fit the button text We draw our rudimentary button boxes based on the height of the button text Void draw_button(const char * text, float in_out_lbrt /* you set the left and bottom, we'll set the right and top */) XPLMDrawString(col_white, l, t - 4 * char_height, line2, NULL, xplmFont_Proportional) XPLMDrawString(col_white, l, t - 2 * char_height, line1, NULL, xplmFont_Proportional) G_size_button_lbrt = g_vr_button_lbrt ĭraw_button("Toggle Size", g_size_button_lbrt) Įlse // Draw some text to say VR isn't availableĬhar * line1 = "VR must be enabled before you" Ĭhar * line2 = "can toggle this window into VR." G_size_button_lbrt = g_vr_button_lbrt + 10 G_vr_button_lbrt = t - char_height * 1.5 ĭraw_button("Toggle VR", g_vr_button_lbrt) Position the button in the upper left of the window (sized to fit the button text) XPLMGetFontDimensions( xplmFont_Proportional, NULL, &char_height, NULL) XPLMGetWindowGeometry(in_window_id, &l, &t, &r, &b) Void draw( XPLMWindowID in_window_id, void * in_refcon) Position_lbrt = global_desktop_bounds + 450 ![]() Position_lbrt = global_desktop_bounds + 350 Position_lbrt = global_desktop_bounds + 150 Position_lbrt = global_desktop_bounds + 50 XPLMGetScreenBoundsGlobal(&global_desktop_bounds, &global_desktop_bounds, &global_desktop_bounds, &global_desktop_bounds) Int global_desktop_bounds // left, bottom, right, top we'll need to query for the global desktop bounds! We're not guaranteed that the main monitor's lower left is at (0, 0). Void get_default_window_pos(int position_lbrt) XPLMSetWindowTitle(g_window, "Sample VR Window") XPLMSetWindowResizingLimits(g_window, 200, 200, 500, 500) // Limit resizing our window: maintain a minimum width/height of 200 boxels and a max width/height of 500 ![]() XPLMSetWindowPositioningMode(g_window, vr_is_enabled ? xplm_WindowVR : xplm_WindowPositionFree, -1) corateAsFloatingWindow = xplm_WindowDecorationRoundRectangle Ĭonst int vr_is_enabled = XPLMGetDatai(g_vr_dref) Params.layer = xplm_WindowLayerFloatingWindows Params.handleCursorFunc = dummy_cursor_status_handler Params.handleKeyFunc = dummy_key_handler Params.handleMouseWheelFunc = dummy_wheel_handler Params.handleRightClickFunc = dummy_mouse_handler Params.handleMouseClickFunc = handle_mouse XPLMSetWindowPositioningMode(g_window, xplm_WindowVR, -1) Įlse if(inFrom = XPLM_PLUGIN_XPLANE & inMsg = XPLM_MSG_EXITING_VR & XPLMWindowIsInVR(g_window)) If(inFrom = XPLM_PLUGIN_XPLANE & inMsg = XPLM_MSG_ENTERED_VR) PLUGIN_API void XPluginReceiveMessage( XPLMPluginID inFrom, int inMsg, void * inParam) Int dummy_mouse_handler( XPLMWindowID in_window_id, int x, int y, int is_down, void * in_refcon) Void handle_menu(void * mRef, void * iRef) Int handle_mouse( XPLMWindowID in_window_id, int x, int y, int is_down, void * in_refcon) #error This is made to be compiled against the XPLM301 SDK #include " XPLMPlugin.h" // for XPLM_MSG_ENTERED_VR and XPLM_MSG_EXITING_VR message #include " XPLMDataAccess.h" // for the VR dataref #include " XPLMGraphics.h" // for window drawing #include " XPLMDisplay.h" // for window creation and manipulation Download as a project for GCC 4.x/Linux (64-bit).Download as a project for Microsoft Visual Studio 2017 (64-bit requires Windows 8.1 SDK).Download as a project for Xcode 14 or newer (64-bit Intel).Note that some of the APIs used here are new to X-Plane 11.20b5-if you get a runtime error, ensure you’re on the latest release. Note that as of X‑Plane 11.20, control over windows in VR is quite limited-you can move a window in and out of VR and change the window’s size, but that’s about it. The following sample code, modeled after the X‑Plane 11 Window API sample, will create a “modern”-style window.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |