From d58c31704b7984687f001ea617af4d3ff85fd591 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 23 Jan 2011 17:25:27 +0000 Subject: [PATCH] BGE: option in the UI to start with the mouse cursor visible. Patch by Vitor Balbio, changes by me. ---------------------------------- While we are more and more moving towards enabling features in the Python API, it's also important to have Logic Bricks working with no scripts. This option allows you to start the game with the mouse cursor on (it's on Render Buttons). The defalt is still off (no do_version needed here). --- release/scripts/ui/properties_game.py | 4 +++- source/blender/makesdna/DNA_scene_types.h | 1 + source/blender/makesrna/intern/rna_scene.c | 4 ++++ .../gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 9 ++++++++- source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 5 ++++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/release/scripts/ui/properties_game.py b/release/scripts/ui/properties_game.py index 856ae624566..cb0dbc03912 100644 --- a/release/scripts/ui/properties_game.py +++ b/release/scripts/ui/properties_game.py @@ -217,7 +217,9 @@ class RENDER_PT_game_player(RenderButtonsPanel, bpy.types.Panel): gs = context.scene.game_settings - layout.prop(gs, "show_fullscreen") + row = layout.row() + row.prop(gs, "show_fullscreen") + row.prop(gs, "show_mouse") split = layout.split() diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index f214598f605..f87d10b1f7d 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -492,6 +492,7 @@ typedef struct GameData { #define GAME_GLSL_NO_EXTRA_TEX (1 << 11) #define GAME_IGNORE_DEPRECATION_WARNINGS (1 << 12) #define GAME_ENABLE_ANIMATION_RECORD (1 << 13) +#define GAME_SHOW_MOUSE (1 << 14) /* GameData.matmode */ #define GAME_MAT_TEXFACE 0 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 720b1287989..d0c7bc3ca2b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1811,6 +1811,10 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_PHYSICS); RNA_def_property_ui_text(prop, "Show Physics Visualization", "Show a visualization of physics bounds and interactions"); + prop= RNA_def_property(srna, "show_mouse", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_MOUSE); + RNA_def_property_ui_text(prop, "Show Mouse", "Start player with a visible mouse cursor"); + prop= RNA_def_property(srna, "use_frame_rate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES); RNA_def_property_ui_text(prop, "Use Frame Rate", "Respect the frame rate rather than rendering as many frames as possible"); diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index e5179e8926f..f6e29fe0dbb 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -176,11 +176,18 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0); #endif bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0); + bool mouse_state = startscene->gm.flag & GAME_SHOW_MOUSE; + if(animation_record) usefixed= true; /* override since you's always want fixed time for sim recording */ // create the canvas, rasterizer and rendertools RAS_ICanvas* canvas = new KX_BlenderCanvas(win, area_rect, ar); - canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); + + // default mouse state set on render panel + if (mouse_state) + canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); + else + canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); RAS_IRenderTools* rendertools = new KX_BlenderRenderTools(); RAS_IRasterizer* rasterizer = NULL; diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index d1dee052173..060f2f6c3c4 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -546,7 +546,10 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (!m_canvas) return false; - m_canvas->Init(); + m_canvas->Init(); + if (gm->flag & GAME_SHOW_MOUSE) + m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); + m_rendertools = new GPC_RenderTools(); if (!m_rendertools) goto initFailed;