- 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

@ -520,7 +520,7 @@ class Menu(StructRNA, _GenericUI):
props.path = path
if operator == "script.execute_preset":
props.menu_idname = self.bl_idname
props.preset_name = preset_name
props.preset_name = preset_name
def draw_preset(self, context):
"""Define these on the subclass

@ -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

@ -109,7 +109,7 @@ def bake(frame_start, frame_end, step=1, only_selected=False):
#pbone.location = matrix.translation_part()
#pbone.rotation_quaternion = matrix.to_quat()
pbone.matrix_local = [f for v in matrix for f in v]
pbone.keyframe_insert("location", -1, f, name)
rotation_mode = pbone.rotation_mode

@ -26,8 +26,8 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
cursor = bpy.context.scene.cursor_location
Left_Up_Front_SEL = [[],[],[]]
Right_Down_Back_SEL = [[],[],[]]
Left_Up_Front_SEL = [[], [], []]
Right_Down_Back_SEL = [[], [], []]
flag_first = True
@ -43,13 +43,13 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
if obj == bpy.context.active_object:
center_active_x = ( Left_Up_Front[0] + Right_Down_Back[0] ) / 2
center_active_y = ( Left_Up_Front[1] + Right_Down_Back[1] ) / 2
center_active_z = ( Left_Up_Front[2] + Right_Down_Back[2] ) / 2
center_active_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2
center_active_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2
center_active_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2
size_active_x = ( Right_Down_Back[0] - Left_Up_Front[0] ) / 2
size_active_y = ( Right_Down_Back[1] - Left_Up_Front[1] ) / 2
size_active_z = ( Left_Up_Front[2] - Right_Down_Back[2] ) / 2
size_active_x = (Right_Down_Back[0] - Left_Up_Front[0]) / 2
size_active_y = (Right_Down_Back[1] - Left_Up_Front[1]) / 2
size_active_z = (Left_Up_Front[2] - Right_Down_Back[2]) / 2
# Selection Center
@ -85,9 +85,9 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
if Right_Down_Back[2] < Right_Down_Back_SEL[2]:
Right_Down_Back_SEL[2] = Right_Down_Back[2]
center_sel_x = ( Left_Up_Front_SEL[0] + Right_Down_Back_SEL[0] ) / 2
center_sel_y = ( Left_Up_Front_SEL[1] + Right_Down_Back_SEL[1] ) / 2
center_sel_z = ( Left_Up_Front_SEL[2] + Right_Down_Back_SEL[2] ) / 2
center_sel_x = (Left_Up_Front_SEL[0] + Right_Down_Back_SEL[0]) / 2
center_sel_y = (Left_Up_Front_SEL[1] + Right_Down_Back_SEL[1]) / 2
center_sel_z = (Left_Up_Front_SEL[2] + Right_Down_Back_SEL[2]) / 2
# Main Loop
@ -100,9 +100,9 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
Left_Up_Front = bb_world[1]
Right_Down_Back = bb_world[7]
center_x = ( Left_Up_Front[0] + Right_Down_Back[0] ) / 2
center_y = ( Left_Up_Front[1] + Right_Down_Back[1] ) / 2
center_z = ( Left_Up_Front[2] + Right_Down_Back[2] ) / 2
center_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2
center_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2
center_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2
positive_x = Right_Down_Back[0]
positive_y = Right_Down_Back[1]
@ -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')

@ -30,7 +30,7 @@ def randomize_selected(seed, loc, rot, scale, scale_even, scale_min):
random.seed(seed)
def rand_vec(vec_range):
return Vector([uniform(- val, val) for val in vec_range])
return Vector([uniform(-val, val) for val in vec_range])
for obj in bpy.context.selected_objects:

@ -87,7 +87,7 @@ class ExecutePreset(bpy.types.Operator):
# change the menu title to the most recently chosen option
preset_class = getattr(bpy.types, self.properties.menu_idname)
preset_class.bl_label = self.properties.preset_name
# execute the preset using script.python_file_run
bpy.ops.script.python_file_run(path=self.properties.path)
return {'FINISHED'}
@ -182,13 +182,14 @@ class AddPresetSunSky(AddPresetBase):
preset_subdir = "sunsky"
class AddPresetInteraction(AddPresetBase):
'''Add an Application Interaction Preset'''
bl_idname = "wm.interaction_preset_add"
bl_label = "Add Interaction Preset"
name = AddPresetBase.name
save_keyconfig = True
preset_values = [
"bpy.context.user_preferences.edit.drag_immediately",
"bpy.context.user_preferences.edit.insertkey_xyz_to_rgb",

@ -281,48 +281,48 @@ class DATA_PT_uv_texture(DataButtonsPanel):
lay = me.active_uv_texture
if lay:
layout.prop(lay, "name")
class DATA_PT_texface(DataButtonsPanel):
bl_label = "Texture Face"
def poll(self, context):
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
col = layout.column()
wide_ui = context.region.width > narrowui
wide_ui = context.region.width > narrowui
me = context.mesh
tf = me.faces.active_tface
if tf:
split = layout.split()
col = split.column()
col.prop(tf, "tex")
col.prop(tf, "light")
col.prop(tf, "invisible")
col.prop(tf, "collision")
col.prop(tf, "shared")
col.prop(tf, "twoside")
col.prop(tf, "object_color")
if wide_ui:
col = split.column()
col.prop(tf, "halo")
col.prop(tf, "billboard")
col.prop(tf, "shadow")
col.prop(tf, "text")
col.prop(tf, "alpha_sort")
col = layout.column()
col.prop(tf, "transp")
else:

@ -911,7 +911,8 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
col = split.column()
col.label()
col.prop(vol, "depth_cutoff")
class MATERIAL_PT_volume_options(VolumeButtonsPanel):
bl_label = "Options"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@ -929,7 +930,7 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel):
col.prop(mat, "traceable")
col.prop(mat, "full_oversampling")
col.prop(mat, "exclude_mist")
col = split.column()
col.label(text="Light Group:")
col.prop(mat, "light_group", text="")
@ -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,

@ -369,30 +369,30 @@ class RENDER_PT_output(RenderButtonsPanel):
col = split.column()
col.prop(rd, "quicktime_codec_type", text="Video Codec")
col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
#Audio
col.prop(rd,"quicktime_audiocodec_type", text="Audio Codec")
# Audio
col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
if rd.quicktime_audiocodec_type != 'No audio':
split = layout.split()
col = split.column()
if rd.quicktime_audiocodec_type == 'LPCM':
col.prop(rd,"quicktime_audio_bitdepth", text="")
col.prop(rd, "quicktime_audio_bitdepth", text="")
if wide_ui:
col = split.column()
col.prop(rd,"quicktime_audio_samplerate", text="")
col.prop(rd, "quicktime_audio_samplerate", text="")
split = layout.split()
col = split.column()
if rd.quicktime_audiocodec_type == 'AAC':
col.prop(rd,"quicktime_audio_bitrate")
col.prop(rd, "quicktime_audio_bitrate")
if wide_ui:
subsplit = split.split()
col = subsplit.column()
if rd.quicktime_audiocodec_type == 'AAC':
col.prop(rd,"quicktime_audio_codec_isvbr")
col.prop(rd, "quicktime_audio_codec_isvbr")
if wide_ui:
col = subsplit.column()
col.prop(rd,"quicktime_audio_resampling_hq")
col.prop(rd, "quicktime_audio_resampling_hq")
class RENDER_PT_encoding(RenderButtonsPanel):

@ -250,7 +250,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel):
if type(idblock) == bpy.types.Brush:
if context.sculpt_object:
layout.prop(tex, "map_mode", expand=True)
row = layout.row()
row.active = tex.map_mode in ('FIXED', 'TILED')
row.prop(tex, "angle")

@ -126,7 +126,7 @@ class GRAPH_MT_select(bpy.types.Menu):
layout.separator()
layout.operator("graph.select_more")
layout.operator("graph.select_less")
layout.separator()
layout.operator("graph.select_linked")

@ -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'
@ -426,7 +427,7 @@ class IMAGE_PT_view_waveform(bpy.types.Panel):
sub = layout.row().split(percentage=0.75)
sub.prop(sima.scopes, "waveform_alpha")
sub.prop(sima.scopes, "waveform_mode", text="", icon_only=True)
class IMAGE_PT_view_vectorscope(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
@ -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'

@ -245,7 +245,7 @@ class SEQUENCER_MT_strip(bpy.types.Menu):
if strip:
stype = strip.type
# XXX note strip.type is never equal to 'EFFECT', look at seq_type_items within rna_sequencer.c
if stype == 'EFFECT':
pass
@ -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'
@ -110,8 +112,8 @@ class USERPREF_MT_interaction_presets(bpy.types.Menu):
preset_subdir = "interaction"
preset_operator = "script.execute_preset"
draw = bpy.types.Menu.draw_preset
class USERPREF_MT_splash(bpy.types.Menu):
bl_label = "Splash"
@ -123,7 +125,7 @@ class USERPREF_MT_splash(bpy.types.Menu):
row = split.row()
row.label("Interaction:")
row.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label)
class USERPREF_PT_interface(bpy.types.Panel):
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"
@ -1027,7 +1030,7 @@ class USERPREF_PT_input(InputKeyMapPanel):
subrow.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label)
subrow.operator("wm.interaction_preset_add", text="", icon="ZOOMIN")
sub.separator()
sub.label(text="Mouse:")
sub1 = sub.column()
sub1.enabled = (inputs.select_mouse == 'RIGHT')
@ -1409,7 +1412,6 @@ class WM_OT_addon_links(bpy.types.Operator):
return {'FINISHED'}
classes = [
USERPREF_HT_header,
USERPREF_PT_tabs,
@ -1428,7 +1430,7 @@ classes = [
WM_OT_addon_disable,
WM_OT_addon_install,
WM_OT_addon_expand,
WM_OT_addon_links ]
WM_OT_addon_links]
def register():

@ -27,12 +27,12 @@ KM_HIERARCHY = [
('Screen', 'EMPTY', 'WINDOW', [ # full screen, undo, screenshot
('Screen Editing', 'EMPTY', 'WINDOW', []), # resizing, action corners
]),
('View2D', 'EMPTY', 'WINDOW', []), # view 2d navigation (per region)
('View2D Buttons List', 'EMPTY', 'WINDOW', []), # view 2d with buttons navigation
('Header', 'EMPTY', 'WINDOW', []), # header stuff (per region)
('Grease Pencil', 'EMPTY', 'WINDOW', []), # grease pencil stuff (per region)
('3D View', 'VIEW_3D', 'WINDOW', [ # view 3d navigation and generic stuff (select, transform)
('Object Mode', 'EMPTY', 'WINDOW', []),
('Mesh', 'EMPTY', 'WINDOW', []),
@ -41,23 +41,23 @@ KM_HIERARCHY = [
('Metaball', 'EMPTY', 'WINDOW', []),
('Lattice', 'EMPTY', 'WINDOW', []),
('Font', 'EMPTY', 'WINDOW', []),
('Pose', 'EMPTY', 'WINDOW', []),
('Vertex Paint', 'EMPTY', 'WINDOW', []),
('Weight Paint', 'EMPTY', 'WINDOW', []),
('Face Mask', 'EMPTY', 'WINDOW', []),
('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
('Sculpt', 'EMPTY', 'WINDOW', []),
('Armature Sketch', 'EMPTY', 'WINDOW', []),
('Particle', 'EMPTY', 'WINDOW', []),
('Object Non-modal', 'EMPTY', 'WINDOW', []), # mode change
('3D View Generic', 'VIEW_3D', 'WINDOW', []) # toolbar and properties
]),
('Frames', 'EMPTY', 'WINDOW', []), # frame navigation (per region)
('Markers', 'EMPTY', 'WINDOW', []), # markers (per region)
('Animation', 'EMPTY', 'WINDOW', []), # frame change on click, preview range (per region)
@ -70,33 +70,33 @@ KM_HIERARCHY = [
('NLA Channels', 'NLA_EDITOR', 'WINDOW', []),
('NLA Generic', 'NLA_EDITOR', 'WINDOW', [])
]),
('Image', 'IMAGE_EDITOR', 'WINDOW', [
('UV Editor', 'EMPTY', 'WINDOW', []), # image (reverse order, UVEdit before Image
('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
('Image Generic', 'IMAGE_EDITOR', 'WINDOW', [])
]),
('Timeline', 'TIMELINE', 'WINDOW', []),
('Outliner', 'OUTLINER', 'WINDOW', []),
('Node Editor', 'NODE_EDITOR', 'WINDOW', [
('Node Generic', 'NODE_EDITOR', 'WINDOW', [])
]),
('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', []),
('Logic Editor', 'LOGIC_EDITOR', 'WINDOW', []),
('File Browser', 'FILE_BROWSER', 'WINDOW', [
('File Browser Main', 'FILE_BROWSER', 'WINDOW', []),
('File Browser Buttons', 'FILE_BROWSER', 'WINDOW', [])
]),
('Property Editor', 'PROPERTIES', 'WINDOW', []), # align context menu
('Script', 'SCRIPTS_WINDOW', 'WINDOW', []),
('Text', 'TEXT_EDITOR', 'WINDOW', []),
('Console', 'CONSOLE', 'WINDOW', []),
('View3D Gesture Circle', 'EMPTY', 'WINDOW', []),
('Gesture Border', 'EMPTY', 'WINDOW', []),
('Standard Modal Map', 'EMPTY', 'WINDOW', []),
@ -112,7 +112,7 @@ def _km_exists_in(km, export_keymaps):
if km2.name == km.name:
return True
return False
# kc1 takes priority over kc2
def _merge_keymaps(kc1, kc2):
merged_keymaps = [(km, kc1) for km in kc1.keymaps]
@ -121,25 +121,26 @@ def _merge_keymaps(kc1, kc2):
return merged_keymaps
class InputKeyMapPanel(bpy.types.Panel):
bl_space_type = 'USER_PREFERENCES'
bl_label = "Input"
bl_region_type = 'WINDOW'
bl_show_header = False
def draw_entry(self, display_keymaps, entry, col, level=0):
idname, spaceid, regionid, children = entry
for km, kc in display_keymaps:
if km.name == idname and km.space_type == spaceid and km.region_type == regionid:
self.draw_km(display_keymaps, kc, km, children, col, level)
'''
km = kc.find_keymap(idname, space_type=spaceid, region_type=regionid)
if not km:
kc = defkc
km = kc.find_keymap(idname, space_type=spaceid, region_type=regionid)
if km:
self.draw_km(kc, km, children, col, level)
'''
@ -314,8 +315,7 @@ class InputKeyMapPanel(bpy.types.Panel):
if kmm:
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()
@ -354,13 +354,13 @@ class InputKeyMapPanel(bpy.types.Panel):
wm = context.manager
kc = wm.active_keyconfig
defkc = wm.default_keyconfig
col = layout.column()
col = layout.column()
sub = col.column()
subsplit = sub.split()
subcol = subsplit.column()
row = subcol.row()
row.prop_object(wm, "active_keyconfig", wm, "keyconfigs", text="Key Config:")
layout.set_context_pointer("keyconfig", wm.active_keyconfig)
@ -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"
@ -597,25 +599,26 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
f.write("kc = wm.add_keyconfig('%s')\n\n" % name)
# Generate a list of keymaps to export:
#
#
# First add all user_defined keymaps (found in inputs.edited_keymaps list),
# then add all remaining keymaps from the currently active custom keyconfig.
#
# 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()
edited_kc.keymaps.extend(context.user_preferences.inputs.edited_keymaps)
edited_kc.keymaps.extend(context.user_preferences.inputs.edited_keymaps)
# merge edited keymaps with non-default keyconfig, if it exists
if kc != wm.default_keyconfig:
export_keymaps = _merge_keymaps(edited_kc, kc)
else:
export_keymaps = _merge_keymaps(edited_kc, edited_kc)
for km, kc_x in export_keymaps:
km = km.active()
f.write("# Map %s\n" % km.name)

@ -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()));
PyList_SET_ITEM(resultlist, 1, PyFloat_FromDouble(float(yevent.m_eventval)/self->m_canvas->GetHeight()));
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()));
return resultlist;
return ret;
}
int SCA_PythonMouse::pyattr_set_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)