- for BGE mouse and keyboard events use tuples rather then lists

- pep8 corrections
This commit is contained in:
Campbell Barton 2010-04-17 19:05:53 +00:00
parent 392e1da179
commit 4cf697de89
17 changed files with 107 additions and 97 deletions

@ -27,6 +27,7 @@ script_paths = bpy.utils.script_paths()
_FAKE_STRUCT_SUBCLASS = True
def _get_direct_attr(rna_type, attr):
props = getattr(rna_type, attr)
base = rna_type.base
@ -45,6 +46,7 @@ def get_direct_properties(rna_type):
def get_direct_functions(rna_type):
return _get_direct_attr(rna_type, "functions")
def rna_id_ignore(rna_id):
if rna_id == "rna_type":
return True
@ -61,6 +63,7 @@ def rna_id_ignore(rna_id):
return True
return False
def range_str(val):
if val < -10000000:
return '-inf'
@ -393,6 +396,7 @@ def GetInfoFunctionRNA(bl_rna, parent_id):
def GetInfoOperatorRNA(bl_rna):
return _GetInfoRNA(bl_rna, InfoOperatorRNA)
def BuildRNAInfo():
# Use for faster lookups
# use rna_struct.identifier as the key for each dict
@ -402,7 +406,6 @@ def BuildRNAInfo():
rna_references_dict = {} # store a list of rna path strings that reference this type
# rna_functions_dict = {} # store all functions directly in this type (not inherited)
def full_rna_struct_path(rna_struct):
'''
Needed when referencing one struct from another

@ -240,8 +240,7 @@ class AlignObjects(bpy.types.Operator):
align_mode = bpy.props.EnumProperty(items=(
('OPT_1', "Negative Sides", ""),
('OPT_2', "Centers", ""),
('OPT_3', "Positive Sides", "")
),
('OPT_3', "Positive Sides", "")),
name="Align Mode:",
description="",
default='OPT_2')
@ -250,8 +249,7 @@ class AlignObjects(bpy.types.Operator):
('OPT_1', "Scene Origin", ""),
('OPT_2', "3D Cursor", ""),
('OPT_3', "Selection", ""),
('OPT_4', "Active", "")
),
('OPT_4', "Active", "")),
name="Relative To:",
description="",
default='OPT_4')

@ -182,6 +182,7 @@ class AddPresetSunSky(AddPresetBase):
preset_subdir = "sunsky"
class AddPresetInteraction(AddPresetBase):
'''Add an Application Interaction Preset'''
bl_idname = "wm.interaction_preset_add"

@ -282,6 +282,7 @@ class DATA_PT_uv_texture(DataButtonsPanel):
if lay:
layout.prop(lay, "name")
class DATA_PT_texface(DataButtonsPanel):
bl_label = "Texture Face"
@ -289,8 +290,7 @@ class DATA_PT_texface(DataButtonsPanel):
ob = context.active_object
rd = context.scene.render
return (context.mode =='EDIT_MESH') and (rd.engine == 'BLENDER_GAME') \
and ob and ob.type in ('MESH')
return (context.mode =='EDIT_MESH') and (rd.engine == 'BLENDER_GAME') and ob and ob.type == 'MESH'
def draw(self, context):
layout = self.layout

@ -912,6 +912,7 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
col.label()
col.prop(vol, "depth_cutoff")
class MATERIAL_PT_volume_options(VolumeButtonsPanel):
bl_label = "Options"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@ -938,7 +939,6 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel):
row.prop(mat, "light_group_exclusive", text="Exclusive")
classes = [
MATERIAL_PT_context_material,
MATERIAL_PT_preview,

@ -409,6 +409,7 @@ class IMAGE_PT_view_histogram(bpy.types.Panel):
layout.template_histogram(sima.scopes, "histogram")
layout.prop(sima.scopes.histogram, "mode", icon_only=True)
class IMAGE_PT_view_waveform(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
@ -444,6 +445,7 @@ class IMAGE_PT_view_vectorscope(bpy.types.Panel):
layout.template_vectorscope(sima, "scopes")
layout.prop(sima.scopes, "vectorscope_alpha")
class IMAGE_PT_sample_line(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
@ -460,6 +462,7 @@ class IMAGE_PT_sample_line(bpy.types.Panel):
layout.template_histogram(sima, "sample_histogram")
layout.prop(sima.sample_histogram, "mode")
class IMAGE_PT_scope_sample(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
@ -479,6 +482,7 @@ class IMAGE_PT_scope_sample(bpy.types.Panel):
row.active = not sima.scopes.use_full_resolution
row.prop(sima.scopes, "accuracy")
class IMAGE_PT_view_properties(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'

@ -749,7 +749,7 @@ class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
col.prop(st, "draw_safe_margin")
if st.display_mode == 'WAVEFORM':
col.prop(st, "separate_color_preview")
col.prop(st, "proxy_render_size");
col.prop(st, "proxy_render_size")
classes = [
SEQUENCER_HT_header, # header/menu classes

@ -66,6 +66,7 @@ def opengl_lamp_buttons(column, lamp):
col.active = lamp.enabled
col.prop(lamp, "direction", text="")
class USERPREF_HT_header(bpy.types.Header):
bl_space_type = 'USER_PREFERENCES'
@ -91,6 +92,7 @@ class USERPREF_HT_header(bpy.types.Header):
elif userpref.active_section == 'THEMES':
op = layout.operator("ui.reset_default_theme")
class USERPREF_PT_tabs(bpy.types.Panel):
bl_label = ""
bl_space_type = 'USER_PREFERENCES'
@ -1008,6 +1010,7 @@ class USERPREF_PT_file(bpy.types.Panel):
from space_userpref_keymap import InputKeyMapPanel
class USERPREF_PT_input(InputKeyMapPanel):
bl_space_type = 'USER_PREFERENCES'
bl_label = "Input"
@ -1409,7 +1412,6 @@ class WM_OT_addon_links(bpy.types.Operator):
return {'FINISHED'}
classes = [
USERPREF_HT_header,
USERPREF_PT_tabs,

@ -121,6 +121,7 @@ def _merge_keymaps(kc1, kc2):
return merged_keymaps
class InputKeyMapPanel(bpy.types.Panel):
bl_space_type = 'USER_PREFERENCES'
bl_label = "Input"
@ -315,7 +316,6 @@ class InputKeyMapPanel(bpy.types.Panel):
self.draw_km(display_keymaps, kc, kmm, None, layout, level + 1)
layout.set_context_pointer("keymap", km)
def draw_filtered(self, display_keymaps, filter, layout):
for km, kc in display_keymaps:
km = km.active()
@ -559,6 +559,8 @@ class WM_OT_keyconfig_import(bpy.types.Operator):
return {'RUNNING_MODAL'}
# This operator is also used by interaction presets saving - AddPresetBase
class WM_OT_keyconfig_export(bpy.types.Operator):
"Export key configuration to a python script"
bl_idname = "wm.keyconfig_export"
@ -604,6 +606,7 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
# This will create a final list of keymaps that can be used as a 'diff' against
# the default blender keyconfig, recreating the current setup from a fresh blender
# without needing to export keymaps which haven't been edited.
class FakeKeyConfig():
keymaps = []
edited_kc = FakeKeyConfig()

@ -102,9 +102,9 @@ PyObject* SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBU
if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
{
PyObject* keypair = PyList_New(2);
PyList_SET_ITEM(keypair, 0, PyLong_FromSsize_t(i));
PyList_SET_ITEM(keypair, 1, PyLong_FromSsize_t(inevent.m_status));
PyObject* keypair = PyTuple_New(2);
PyTuple_SET_ITEM(keypair, 0, PyLong_FromSsize_t(i));
PyTuple_SET_ITEM(keypair, 1, PyLong_FromSsize_t(inevent.m_status));
PyList_Append(resultlist, keypair);
}
}

@ -107,9 +107,9 @@ PyObject* SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_
if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
{
PyObject* keypair = PyList_New(2);
PyList_SET_ITEM(keypair, 0, PyLong_FromSsize_t(i));
PyList_SET_ITEM(keypair, 1, PyLong_FromSsize_t(inevent.m_status));
PyObject* keypair = PyTuple_New(2);
PyTuple_SET_ITEM(keypair, 0, PyLong_FromSsize_t(i));
PyTuple_SET_ITEM(keypair, 1, PyLong_FromSsize_t(inevent.m_status));
PyList_Append(resultlist, keypair);
}
}
@ -123,13 +123,12 @@ PyObject* SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUT
const SCA_InputEvent & xevent = self->m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEX);
const SCA_InputEvent & yevent = self->m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEY);
PyObject* resultlist = PyList_New(2);
PyObject* ret = PyTuple_New(2);
PyList_SET_ITEM(resultlist, 0, PyFloat_FromDouble(float(xevent.m_eventval)/self->m_canvas->GetWidth()));
PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(float(xevent.m_eventval)/self->m_canvas->GetWidth()));
PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(float(yevent.m_eventval)/self->m_canvas->GetHeight()));
PyList_SET_ITEM(resultlist, 1, PyFloat_FromDouble(float(yevent.m_eventval)/self->m_canvas->GetHeight()));
return resultlist;
return ret;
}
int SCA_PythonMouse::pyattr_set_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)