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:
authorJoerg Mueller <nexyon@gmail.com>2010-08-16 16:14:09 +0400
committerJoerg Mueller <nexyon@gmail.com>2010-08-16 16:14:09 +0400
commit0be08725adec7659ca612e2d068e62d4d7a926c6 (patch)
tree3b2c827a67432387148dc9b3c7def927e9116cfd /source/blender
parent25fec1592efade86233c0ba71212dc973b618ad1 (diff)
Py API (GSoC): Second merging commit
Rough summary of fixes/changes: - Blender Py API: GameLogic -> bge.logic - Blender Py API: Implemented missing KX_PYATTRIBUTE_TODOs and -DUMMYs. - Fix for [#22924] KX_PolygonMaterial.diffuse does not return expected list[r,g,b] - Py API: Renaming _owner attribute of mathutils classes to owner. - Fix some minor errors in mathutils and blf. - 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. - Fix for ipo conversion on file transition in the game engine.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_logic/logic_window.c2
-rw-r--r--source/blender/makesrna/intern/rna_actuator.c4
-rw-r--r--source/blender/python/generic/blf_api.c4
-rw-r--r--source/blender/python/generic/mathutils_color.c2
-rw-r--r--source/blender/python/generic/mathutils_euler.c2
-rw-r--r--source/blender/python/generic/mathutils_matrix.c2
-rw-r--r--source/blender/python/generic/mathutils_quat.c4
-rw-r--r--source/blender/python/generic/mathutils_vector.c8
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c113
-rw-r--r--source/blender/windowmanager/intern/wm_window.c2
-rw-r--r--source/blender/windowmanager/wm_window.h2
12 files changed, 124 insertions, 23 deletions
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 511ca99ff82..d7f8803b3bf 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -2529,7 +2529,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo
}
//str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3";
- str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save GameLogic.globalDict %x4|Load GameLogic.globalDict %x5";
+ str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save bge.logic.globalDict %x4|Load bge.logic.globalDict %x5";
uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &gma->type, 0.0, 0.0, 0, 0, "");
yco -= ysize;
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c
index f5145d86270..63e09c1b6c2 100644
--- a/source/blender/makesrna/intern/rna_actuator.c
+++ b/source/blender/makesrna/intern/rna_actuator.c
@@ -1557,8 +1557,8 @@ static void rna_def_game_actuator(BlenderRNA *brna)
{ACT_GAME_LOAD, "START", 0, "Start new game", ""},
{ACT_GAME_RESTART, "RESTART", 0, "Restart this game", ""},
{ACT_GAME_QUIT, "QUIT", 0, "Quit this game", ""},
- {ACT_GAME_SAVECFG, "SAVECFG", 0, "Save GameLogic.globalDict", ""},
- {ACT_GAME_LOADCFG, "LOADCFG", 0, "Load GameLogic.globalDict", ""},
+ {ACT_GAME_SAVECFG, "SAVECFG", 0, "Save bge.logic.globalDict", ""},
+ {ACT_GAME_LOADCFG, "LOADCFG", 0, "Load bge.logic.globalDict", ""},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "GameActuator", "Actuator");
diff --git a/source/blender/python/generic/blf_api.c b/source/blender/python/generic/blf_api.c
index 762153b8349..a5f5f8815c7 100644
--- a/source/blender/python/generic/blf_api.c
+++ b/source/blender/python/generic/blf_api.c
@@ -39,7 +39,7 @@ static char py_blf_position_doc[] =
" :arg y: Y axis position to draw the text.\n"
" :type y: float\n"
" :arg z: Z axis position to draw the text.\n"
-" :type x: float\n";
+" :type z: float\n";
static PyObject *py_blf_position(PyObject *self, PyObject *args)
{
@@ -261,7 +261,7 @@ static char py_blf_rotation_doc[] =
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default font use 0.\n"
" :type fontid: int\n"
" :arg angle: The angle for text drawing to use.\n"
-" :type aspect: float\n";
+" :type angle: float\n";
static PyObject *py_blf_rotation(PyObject *self, PyObject *args)
{
diff --git a/source/blender/python/generic/mathutils_color.c b/source/blender/python/generic/mathutils_color.c
index d4ab64e13c5..57d2838238c 100644
--- a/source/blender/python/generic/mathutils_color.c
+++ b/source/blender/python/generic/mathutils_color.c
@@ -445,7 +445,7 @@ static PyGetSetDef Color_getseters[] = {
{"hsv", (getter)Color_getHSV, (setter)Color_setHSV, "HSV Values in [0, 1].\n\n:type: float triplet", (void *)0},
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
- {"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
+ {"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
diff --git a/source/blender/python/generic/mathutils_euler.c b/source/blender/python/generic/mathutils_euler.c
index 63a04918941..b36eb7803f1 100644
--- a/source/blender/python/generic/mathutils_euler.c
+++ b/source/blender/python/generic/mathutils_euler.c
@@ -621,7 +621,7 @@ static PyGetSetDef Euler_getseters[] = {
{"order", (getter)Euler_getOrder, (setter)Euler_setOrder, "Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']", (void *)NULL},
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
- {"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
+ {"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
diff --git a/source/blender/python/generic/mathutils_matrix.c b/source/blender/python/generic/mathutils_matrix.c
index 1ef834b7a3e..24239e1f541 100644
--- a/source/blender/python/generic/mathutils_matrix.c
+++ b/source/blender/python/generic/mathutils_matrix.c
@@ -1737,7 +1737,7 @@ static PyGetSetDef Matrix_getseters[] = {
{"median_scale", (getter)Matrix_getMedianScale, (setter)NULL, "The average scale applied to each axis (readonly).\n\n:type: float", NULL},
{"is_negative", (getter)Matrix_getIsNegative, (setter)NULL, "True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL},
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
- {"_owner",(getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
+ {"owner",(getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
diff --git a/source/blender/python/generic/mathutils_quat.c b/source/blender/python/generic/mathutils_quat.c
index 8d9fe54fa85..553844b6ee5 100644
--- a/source/blender/python/generic/mathutils_quat.c
+++ b/source/blender/python/generic/mathutils_quat.c
@@ -109,7 +109,7 @@ static PyObject *Quaternion_ToEuler(QuaternionObject * self, PyObject *args)
}
//----------------------------Quaternion.toMatrix()------------------
static char Quaternion_ToMatrix_doc[] =
-".. method:: to_matrix(other)\n"
+".. method:: to_matrix()\n"
"\n"
" Return a matrix representation of the quaternion.\n"
"\n"
@@ -930,7 +930,7 @@ static PyGetSetDef Quaternion_getseters[] = {
{"angle", (getter)Quaternion_getAngle, (setter)Quaternion_setAngle, "angle of the quaternion.\n\n:type: float", NULL},
{"axis",(getter)Quaternion_getAxisVec, (setter)Quaternion_setAxisVec, "quaternion axis as a vector.\n\n:type: :class:`Vector`", NULL},
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
- {"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
+ {"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
diff --git a/source/blender/python/generic/mathutils_vector.c b/source/blender/python/generic/mathutils_vector.c
index 9672878ec51..75a695526fc 100644
--- a/source/blender/python/generic/mathutils_vector.c
+++ b/source/blender/python/generic/mathutils_vector.c
@@ -508,7 +508,8 @@ static char Vector_angle_doc[] =
" :arg other: another vector to compare the angle with\n"
" :type other: :class:`Vector`\n"
" :arg fallback: return this value when the angle cant be calculated (zero length vector)\n"
-" :return angle: angle in radians or fallback when given\n"
+" :type fallback: any\n"
+" :return: angle in radians or fallback when given\n"
" :rtype: float\n"
"\n"
" .. note:: Zero length vectors raise an :exc:`AttributeError`.\n";
@@ -607,8 +608,9 @@ static char Vector_Project_doc[] =
"\n"
" Return the projection of this vector onto the *other*.\n"
"\n"
+" :arg other: second vector.\n"
" :type other: :class:`Vector`\n"
-" :return projection: the parallel projection vector\n"
+" :return: the parallel projection vector\n"
" :rtype: :class:`Vector`\n";
static PyObject *Vector_Project(VectorObject *self, VectorObject *value)
@@ -1601,7 +1603,7 @@ static PyGetSetDef Vector_getseters[] = {
{"length", (getter)Vector_getLength, (setter)Vector_setLength, "Vector Length.\n\n:type: float", NULL},
{"magnitude", (getter)Vector_getLength, (setter)Vector_setLength, "Vector Length.\n\n:type: float", NULL},
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
- {"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
+ {"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
/* autogenerated swizzle attrs, see python script below */
{"xx", (getter)Vector_getSwizzle, (setter)NULL, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, // 36
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index c562d7a0aeb..9fe09c0836c 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -57,7 +57,7 @@ void WM_init (struct bContext *C, int argc, char **argv);
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);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 558d20021ce..45c851a5598 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"
@@ -94,6 +95,7 @@
#include "BKE_depsgraph.h"
#include "BKE_sound.h"
+#include "GHOST_C-api.h"
static void wm_init_reports(bContext *C)
{
@@ -186,18 +188,113 @@ 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;
+
+ 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);
+ 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 */
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index e4bb5b797d3..45234464ef0 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -73,7 +73,7 @@ static int prefsizx= 0, prefsizy= 0, prefstax= 0, prefstay= 0;
/* XXX this one should correctly check for apple top header...
done for Cocoa : returns window contents (and not frame) max size*/
-static void wm_get_screensize(int *width_r, int *height_r)
+void wm_get_screensize(int *width_r, int *height_r)
{
unsigned int uiwidth;
unsigned int uiheight;
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index fa244036645..d57fd0e75d8 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -36,6 +36,8 @@ struct wmOperator;
void wm_ghost_init (bContext *C);
void wm_ghost_exit(void);
+void wm_get_screensize(int *width_r, int *height_r);
+
wmWindow *wm_window_new (bContext *C);
void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win);
void wm_window_close (bContext *C, wmWindowManager *wm, wmWindow *win);