[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30417] branches/soc-2010-nexyon/source: Enabling game engine autoplay again based on a patch by Dalai:
Joerg Mueller
nexyon at gmail.com
Fri Jul 16 19:25:23 CEST 2010
Revision: 30417
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30417
Author: nexyon
Date: 2010-07-16 19:25:23 +0200 (Fri, 16 Jul 2010)
Log Message:
-----------
Enabling game engine autoplay again based on a patch by Dalai:
* The biggest 3D view in the open scene is used, if there is none, blender opens the file normally and raises an error.
* The 3D view are is made fullscreen.
* Quad view, header, properties and toolbox panel are all hidden to get the maximum view.
* If the game engine full screen setting is set, the game starts in fullscreen.
With this abilities we maybe don't need the game player anymore?!
Modified Paths:
--------------
branches/soc-2010-nexyon/source/blender/windowmanager/WM_api.h
branches/soc-2010-nexyon/source/blender/windowmanager/intern/wm_init_exit.c
branches/soc-2010-nexyon/source/creator/creator.c
Modified: branches/soc-2010-nexyon/source/blender/windowmanager/WM_api.h
===================================================================
--- branches/soc-2010-nexyon/source/blender/windowmanager/WM_api.h 2010-07-16 16:54:39 UTC (rev 30416)
+++ branches/soc-2010-nexyon/source/blender/windowmanager/WM_api.h 2010-07-16 17:25:23 UTC (rev 30417)
@@ -57,7 +57,7 @@
void WM_exit (struct bContext *C);
void WM_main (struct bContext *C);
-void WM_init_game (struct bContext *C);
+int WM_init_game (struct bContext *C);
void WM_init_splash (struct bContext *C);
Modified: branches/soc-2010-nexyon/source/blender/windowmanager/intern/wm_init_exit.c
===================================================================
--- branches/soc-2010-nexyon/source/blender/windowmanager/intern/wm_init_exit.c 2010-07-16 16:54:39 UTC (rev 30416)
+++ branches/soc-2010-nexyon/source/blender/windowmanager/intern/wm_init_exit.c 2010-07-16 17:25:23 UTC (rev 30417)
@@ -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"
@@ -182,18 +183,107 @@
}
}
-void WM_init_game(bContext *C)
+static ScrArea *biggest_view3d(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)
+ 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)
+{
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;
+
+ Main *main = CTX_data_main(C);
+ Scene *scene= CTX_data_scene(C);
+
+ if (!scene)
+ scene= main->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);
+ ar->winrct.ymax = win->sizey;
+ ar->winrct.xmax = win->sizex;
+ }
+
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 */
Modified: branches/soc-2010-nexyon/source/creator/creator.c
===================================================================
--- branches/soc-2010-nexyon/source/creator/creator.c 2010-07-16 16:54:39 UTC (rev 30416)
+++ branches/soc-2010-nexyon/source/creator/creator.c 2010-07-16 17:25:23 UTC (rev 30417)
@@ -1150,7 +1150,8 @@
else {
if((G.fileflags & G_FILE_AUTOPLAY) && (G.f & G_SCRIPT_AUTOEXEC))
- WM_init_game(C);
+ if(WM_init_game(C))
+ return 0;
else if(!G.file_loaded)
WM_init_splash(C);
More information about the Bf-blender-cvs
mailing list