Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blender 2.9] Search menu fixes #2086

Merged
merged 3 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blender/arm/logicnode/arm_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def execute(self, context):
class ArmNodeSearch(bpy.types.Operator):
bl_idname = "arm.node_search"
bl_label = "Search..."
bl_options = {"REGISTER"}
bl_options = {"REGISTER", "INTERNAL"}
bl_property = "item"

def get_search_items(self, context):
Expand Down
95 changes: 50 additions & 45 deletions blender/arm/props_tilesheet.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
import shutil
import bpy
import os
import json
from bpy.types import Menu, Panel, UIList
from bpy.props import *

class ArmTilesheetActionListItem(bpy.types.PropertyGroup):
name: StringProperty(
name="Name",
description="A name for this item",
default="Untitled")
name="Name",
description="A name for this item",
default="Untitled")

start_prop: IntProperty(
name="Start",
description="A name for this item",
default=0)
name="Start",
description="A name for this item",
default=0)

end_prop: IntProperty(
name="End",
description="A name for this item",
default=0)
name="End",
description="A name for this item",
default=0)

loop_prop: BoolProperty(
name="Loop",
description="A name for this item",
default=True)
name="Loop",
description="A name for this item",
default=True)

class ARM_UL_TilesheetActionList(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
Expand Down Expand Up @@ -52,14 +48,16 @@ def execute(self, context):
return{'FINISHED'}

class ArmTilesheetActionListDeleteItem(bpy.types.Operator):
# Delete the selected item from the list
"""Delete the selected item from the list"""
bl_idname = "arm_tilesheetactionlist.delete_item"
bl_label = "Deletes an item"

@classmethod
def poll(self, context):
""" Enable if there's something in the list """
"""Enable if there's something in the list"""
wrd = bpy.data.worlds['Arm']
if len(wrd.arm_tilesheetlist) == 0:
return False
trait = wrd.arm_tilesheetlist[wrd.arm_tilesheetlist_index]
return len(trait.arm_tilesheetactionlist) > 0

Expand All @@ -78,18 +76,23 @@ def execute(self, context):
return{'FINISHED'}

class ArmTilesheetActionListMoveItem(bpy.types.Operator):
# Move an item in the list
"""Move an item in the list"""
bl_idname = "arm_tilesheetactionlist.move_item"
bl_label = "Move an item in the list"
bl_options = {'INTERNAL'}

direction: EnumProperty(
items=(
('UP', 'Up', ""),
('DOWN', 'Down', ""),))
items=(
('UP', 'Up', ""),
('DOWN', 'Down', "")
))

@classmethod
def poll(self, context):
""" Enable if there's something in the list. """
"""Enable if there's something in the list"""
wrd = bpy.data.worlds['Arm']
if len(wrd.arm_tilesheetlist) == 0:
return False
trait = wrd.arm_tilesheetlist[wrd.arm_tilesheetlist_index]
return len(trait.arm_tilesheetactionlist) > 0

Expand Down Expand Up @@ -129,27 +132,27 @@ def execute(self, context):

class ArmTilesheetListItem(bpy.types.PropertyGroup):
name: StringProperty(
name="Name",
description="A name for this item",
default="Untitled")
name="Name",
description="A name for this item",
default="Untitled")

tilesx_prop: IntProperty(
name="Tiles X",
description="A name for this item",
default=0)
name="Tiles X",
description="A name for this item",
default=0)

tilesy_prop: IntProperty(
name="Tiles Y",
description="A name for this item",
default=0)
name="Tiles Y",
description="A name for this item",
default=0)

framerate_prop: FloatProperty(
name="Frame Rate",
description="A name for this item",
default=4.0)
name="Frame Rate",
description="A name for this item",
default=4.0)

arm_tilesheetactionlist: CollectionProperty(type=ArmTilesheetActionListItem)
arm_tilesheetactionlist_index: IntProperty(name="Index for my_list", default=0)
arm_tilesheetactionlist_index: IntProperty(name="Index for arm_tilesheetactionlist", default=0)

class ARM_UL_TilesheetList(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
Expand All @@ -162,10 +165,10 @@ def draw_item(self, context, layout, data, item, icon, active_data, active_propn

elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon = custom_icon)
layout.label(text="", icon=custom_icon)

class ArmTilesheetListNewItem(bpy.types.Operator):
# Add a new item to the list
"""Add a new item to the list"""
bl_idname = "arm_tilesheetlist.new_item"
bl_label = "Add a new item"

Expand All @@ -176,7 +179,7 @@ def execute(self, context):
return{'FINISHED'}

class ArmTilesheetListDeleteItem(bpy.types.Operator):
# Delete the selected item from the list
"""Delete the selected item from the list"""
bl_idname = "arm_tilesheetlist.delete_item"
bl_label = "Deletes an item"

Expand All @@ -200,13 +203,16 @@ def execute(self, context):
return{'FINISHED'}

class ArmTilesheetListMoveItem(bpy.types.Operator):
# Move an item in the list
"""Move an item in the list"""
bl_idname = "arm_tilesheetlist.move_item"
bl_label = "Move an item in the list"
bl_options = {'INTERNAL'}

direction: EnumProperty(
items=(
('UP', 'Up', ""),
('DOWN', 'Down', ""),))
items=(
('UP', 'Up', ""),
('DOWN', 'Down', "")
))

@classmethod
def poll(self, context):
Expand Down Expand Up @@ -247,7 +253,6 @@ def execute(self, context):
return{'FINISHED'}

def register():

bpy.utils.register_class(ArmTilesheetActionListItem)
bpy.utils.register_class(ARM_UL_TilesheetActionList)
bpy.utils.register_class(ArmTilesheetActionListNewItem)
Expand All @@ -261,7 +266,7 @@ def register():
bpy.utils.register_class(ArmTilesheetListMoveItem)

bpy.types.World.arm_tilesheetlist = CollectionProperty(type=ArmTilesheetListItem)
bpy.types.World.arm_tilesheetlist_index = IntProperty(name="Index for my_list", default=0)
bpy.types.World.arm_tilesheetlist_index = IntProperty(name="Index for arm_tilesheetlist", default=0)

def unregister():
bpy.utils.unregister_class(ArmTilesheetListItem)
Expand Down