Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_init_exit.c')
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c137
1 files changed, 118 insertions, 19 deletions
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 862255d7cd5..4d4e399a1c7 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -49,6 +49,7 @@
#include "BKE_font.h"
#include "BKE_global.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_mball.h"
#include "BKE_report.h"
#include "BKE_utildefines.h"
@@ -88,12 +89,13 @@
#include "UI_interface.h"
#include "BLF_api.h"
-#include "gpu_buffers.h"
+#include "GPU_buffers.h"
#include "GPU_extensions.h"
#include "GPU_draw.h"
#include "BKE_depsgraph.h"
#include "BKE_sound.h"
+#include "GHOST_C-api.h"
static void wm_init_reports(bContext *C)
{
@@ -163,7 +165,11 @@ void WM_init(bContext *C, int argc, char **argv)
G.ndofdevice = -1; /* XXX bad initializer, needs set otherwise buttons show! */
- read_Blog();
+ read_history();
+
+ if(G.sce[0] == 0)
+ BLI_make_file_string("/", G.sce, BLI_getDefaultDocumentFolder(), "untitled.blend");
+
BLI_strncpy(G.lib, G.sce, FILE_MAX);
}
@@ -182,18 +188,115 @@ void WM_init_splash(bContext *C)
}
}
-void WM_init_game(bContext *C)
+static ScrArea *biggest_view3d(bContext *C)
+{
+ bScreen *sc= CTX_wm_screen(C);
+ ScrArea *sa, *big= NULL;
+ int size, maxsize= 0;
+
+ for(sa= sc->areabase.first; sa; sa= sa->next) {
+ if(sa->spacetype==SPACE_VIEW3D) {
+ size= sa->winx * sa->winy;
+ if(size > maxsize) {
+ maxsize= size;
+ big= sa;
+ }
+ }
+ }
+ return big;
+}
+
+int WM_init_game(bContext *C)
{
- //XXX copied from WM_init_splash we may not even need those "window" related code
- //XXX not working yet, it fails at the game_start_operator pool (it needs an area)
wmWindowManager *wm= CTX_wm_manager(C);
- wmWindow *prevwin= CTX_wm_window(C);
-
- if(wm->windows.first) {
- CTX_wm_window_set(C, wm->windows.first);
+ wmWindow* win;
+
+ ScrArea *sa;
+ ARegion *ar;
+
+ Scene *scene= CTX_data_scene(C);
+
+ if (!scene) {
+ // XXX, this should not be needed.
+ Main *bmain = CTX_data_main(C);
+ scene= bmain->scene.first;
+ }
+
+ win = wm->windows.first;
+
+ //first to get a valid window
+ if(win)
+ CTX_wm_window_set(C, win);
+
+ sa = biggest_view3d(C);
+
+ if(sa)
+ {
+ for(ar=sa->regionbase.first; ar; ar=ar->next) {
+ if(ar->regiontype == RGN_TYPE_WINDOW) {
+ break;
+ }
+ }
+ }
+
+ // if we have a valid 3D view
+ if (sa && ar) {
+ ARegion *arhide;
+
+ CTX_wm_area_set(C, sa);
+ CTX_wm_region_set(C, ar);
+
+ /* disable quad view */
+ if(ar->alignment == RGN_ALIGN_QSPLIT)
+ WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL);
+
+ /* toolbox, properties panel and header are hidden */
+ for(arhide=sa->regionbase.first; arhide; arhide=arhide->next) {
+ if(arhide->regiontype != RGN_TYPE_WINDOW) {
+ if(!(arhide->flag & RGN_FLAG_HIDDEN)) {
+ ED_region_toggle_hidden(C, arhide);
+ }
+ }
+ }
+
+ /* full screen the area */
+ if(!sa->full) {
+ ED_screen_full_toggle(C, wm->windows.first, sa);
+ }
+
+ /* Fullscreen */
+ if(scene->gm.fullscreen) {
+ WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL);
+ wm_get_screensize(&ar->winrct.xmax, &ar->winrct.ymax);
+ }
+ else
+ {
+ GHOST_RectangleHandle rect = GHOST_GetClientBounds(win->ghostwin);
+ ar->winrct.ymax = GHOST_GetHeightRectangle(rect);
+ ar->winrct.xmax = GHOST_GetWidthRectangle(rect);
+ GHOST_DisposeRectangle(rect);
+ }
+
WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL);
- CTX_wm_window_set(C, prevwin);
+
+ return 1;
+ }
+ else
+ {
+ ReportTimerInfo *rti;
+
+ BKE_report(&wm->reports, RPT_ERROR, "No valid 3D View found. Game auto start is not possible.");
+
+ /* After adding the report to the global list, reset the report timer. */
+ WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
+
+ /* Records time since last report was added */
+ wm->reports.reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.02);
+
+ rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
+ wm->reports.reporttimer->customdata = rti;
}
+ return 0;
}
/* free strings of open recent files */
@@ -202,7 +305,7 @@ static void free_openrecent(void)
struct RecentFile *recent;
for(recent = G.recent_files.first; recent; recent=recent->next)
- MEM_freeN(recent->filename);
+ MEM_freeN(recent->filepath);
BLI_freelistN(&(G.recent_files));
}
@@ -301,23 +404,19 @@ void WM_exit(bContext *C)
BPY_end_python();
#endif
- libtiff_exit();
-
-#ifdef WITH_QUICKTIME
- quicktime_exit();
-#endif
-
if (!G.background) {
// XXX UI_filelist_free_icons();
}
GPU_buffer_pool_free(0);
+ GPU_free_unused_buffers();
GPU_extensions_exit();
// if (copybuf) MEM_freeN(copybuf);
// if (copybufinfo) MEM_freeN(copybufinfo);
-
- BKE_undo_save_quit(); // saves quit.blend if global undo is on
+ if (!G.background) {
+ BKE_undo_save_quit(); // saves quit.blend if global undo is on
+ }
BKE_reset_undo();
ED_file_exit(); /* for fsmenu */