Merge remote-tracking branch 'origin/blender-v2.83-release'
This commit is contained in:
commit
6ee2350a9e
|
@ -17,12 +17,12 @@
|
|||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
bl_info = {
|
||||
"name": "BlenderKit Asset Library",
|
||||
"name": "BlenderKit Online Asset Library",
|
||||
"author": "Vilem Duha, Petr Dlouhy",
|
||||
"version": (1, 0, 30),
|
||||
"blender": (2, 82, 0),
|
||||
"location": "View3D > Properties > BlenderKit",
|
||||
"description": "Online BlenderKit library (materials, models, brushes and more)",
|
||||
"description": "Online BlenderKit library (materials, models, brushes and more). Connects to the internet.",
|
||||
"warning": "",
|
||||
"doc_url": "{BLENDER_MANUAL_URL}/addons/add_mesh/blenderkit.html",
|
||||
"category": "3D View",
|
||||
|
@ -122,8 +122,8 @@ model_styles = (
|
|||
('PAINTERLY', 'Painterly', 'hand painted with visible strokes, mostly for games'),
|
||||
('LOWPOLY', 'Lowpoly', "Lowpoly art -don't mix up with polycount!"),
|
||||
('ANIME', 'Anime', 'Anime style'),
|
||||
('2D_VECTOR', '2d Vector', '2d vector'),
|
||||
('3D_GRAPHICS', '3d Graphics', '3d graphics'),
|
||||
('2D_VECTOR', '2D Vector', '2D vector'),
|
||||
('3D_GRAPHICS', '3D Graphics', '3D graphics'),
|
||||
('OTHER', 'Other', 'Other style'),
|
||||
)
|
||||
search_model_styles = (
|
||||
|
@ -131,8 +131,8 @@ search_model_styles = (
|
|||
('PAINTERLY', 'Painterly', 'hand painted with visible strokes, mostly for games'),
|
||||
('LOWPOLY', 'Lowpoly', "Lowpoly art -don't mix up with polycount!"),
|
||||
('ANIME', 'Anime', 'Anime style'),
|
||||
('2D_VECTOR', '2d Vector', '2d vector'),
|
||||
('3D_GRAPHICS', '3d Graphics', '3d graphics'),
|
||||
('2D_VECTOR', '2D Vector', '2D vector'),
|
||||
('3D_GRAPHICS', '3D Graphics', '3D graphics'),
|
||||
('OTHER', 'Other', 'Other Style'),
|
||||
('ANY', 'Any', 'Any Style'),
|
||||
)
|
||||
|
@ -155,7 +155,7 @@ engines = (
|
|||
('UNREAL', 'Unreal', 'Unreal engine'),
|
||||
('UNITY', 'Unity', 'Unity engine'),
|
||||
('GODOT', 'Godot', 'Godot engine'),
|
||||
('3D-PRINT', '3d printer', 'object can be 3d printed'),
|
||||
('3D-PRINT', '3D printer', 'object can be 3D printed'),
|
||||
('OTHER', 'Other', 'any other engine'),
|
||||
('NONE', 'None', 'no more engine block'),
|
||||
)
|
||||
|
@ -264,7 +264,7 @@ def asset_type_callback(self, context):
|
|||
items = (
|
||||
('MODEL', 'Upload Model', 'Upload a model to BlenderKit', 'OBJECT_DATAMODE', 0),
|
||||
# ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
|
||||
('MATERIAL', 'Uplaod Material', 'Upload a material to BlenderKit', 'MATERIAL', 2),
|
||||
('MATERIAL', 'Upload Material', 'Upload a material to BlenderKit', 'MATERIAL', 2),
|
||||
# ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
|
||||
('BRUSH', 'Upload Brush', 'Upload a brush to BlenderKit', 'BRUSH_DATA', 3)
|
||||
)
|
||||
|
@ -1502,7 +1502,7 @@ class BlenderKitAddonPreferences(AddonPreferences):
|
|||
items=(
|
||||
('BOTH', 'Both Types',
|
||||
''),
|
||||
('UNIFIED', 'Unified 3d View Panel',
|
||||
('UNIFIED', 'Unified 3D View Panel',
|
||||
""),
|
||||
('LOCAL', 'Relative to Data',
|
||||
'')
|
||||
|
@ -1513,7 +1513,7 @@ class BlenderKitAddonPreferences(AddonPreferences):
|
|||
)
|
||||
|
||||
max_assetbar_rows: IntProperty(name="Max Assetbar Rows",
|
||||
description="max rows of assetbar in the 3d view",
|
||||
description="max rows of assetbar in the 3D view",
|
||||
default=1,
|
||||
min=0,
|
||||
max=20)
|
||||
|
|
|
@ -139,6 +139,7 @@ class Logout(bpy.types.Operator):
|
|||
preferences.login_attempt = False
|
||||
preferences.api_key_refresh = ''
|
||||
preferences.api_key = ''
|
||||
del (bpy.context.window_manager['bkit profile'])
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
|
|
@ -770,6 +770,8 @@ def get_download_url(asset_data, scene_id, api_key, tcom=None):
|
|||
data = {
|
||||
'scene_uuid': scene_id
|
||||
}
|
||||
r = None
|
||||
|
||||
try:
|
||||
r = rerequests.get(asset_data['download_url'], params=data, headers=headers)
|
||||
except Exception as e:
|
||||
|
|
|
@ -55,7 +55,7 @@ def pretty_print_POST(req):
|
|||
))
|
||||
|
||||
|
||||
def uplaod_rating_thread(url, ratings, headers):
|
||||
def upload_rating_thread(url, ratings, headers):
|
||||
''' Upload rating thread function / disconnected from blender data.'''
|
||||
utils.p('upload rating', url, ratings)
|
||||
for rating_name, score in ratings:
|
||||
|
@ -75,17 +75,17 @@ def uplaod_rating_thread(url, ratings, headers):
|
|||
def send_rating_to_thread_quality(url, ratings, headers):
|
||||
'''Sens rating into thread rating, main purpose is for tasks_queue.
|
||||
One function per property to avoid lost data due to stashing.'''
|
||||
thread = threading.Thread(target=uplaod_rating_thread, args=(url, ratings, headers))
|
||||
thread = threading.Thread(target=upload_rating_thread, args=(url, ratings, headers))
|
||||
thread.start()
|
||||
|
||||
def send_rating_to_thread_work_hours(url, ratings, headers):
|
||||
'''Sens rating into thread rating, main purpose is for tasks_queue.
|
||||
One function per property to avoid lost data due to stashing.'''
|
||||
thread = threading.Thread(target=uplaod_rating_thread, args=(url, ratings, headers))
|
||||
thread = threading.Thread(target=upload_rating_thread, args=(url, ratings, headers))
|
||||
thread.start()
|
||||
|
||||
|
||||
def uplaod_review_thread(url, reviews, headers):
|
||||
def upload_review_thread(url, reviews, headers):
|
||||
r = rerequests.put(url, data=reviews, verify=True, headers=headers)
|
||||
|
||||
# except requests.exceptions.RequestException as e:
|
||||
|
@ -109,6 +109,7 @@ def get_rating(asset_id):
|
|||
def update_ratings_quality(self, context):
|
||||
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
|
||||
api_key = user_preferences.api_key
|
||||
|
||||
headers = utils.get_headers(api_key)
|
||||
asset = self.id_data
|
||||
bkit_ratings = asset.bkit_ratings
|
||||
|
@ -150,7 +151,7 @@ def upload_rating(asset):
|
|||
if bkit_ratings.rating_work_hours > 0.1:
|
||||
ratings.append(('working_hours', round(bkit_ratings.rating_work_hours, 1)))
|
||||
|
||||
thread = threading.Thread(target=uplaod_rating_thread, args=(url, ratings, headers))
|
||||
thread = threading.Thread(target=upload_rating_thread, args=(url, ratings, headers))
|
||||
thread.start()
|
||||
|
||||
url = paths.get_api_url() + 'assets/' + asset['asset_data']['id'] + '/review'
|
||||
|
@ -160,7 +161,7 @@ def upload_rating(asset):
|
|||
'reviewTextProblems': bkit_ratings.rating_problems,
|
||||
}
|
||||
if not (bkit_ratings.rating_compliments == '' and bkit_ratings.rating_compliments == ''):
|
||||
thread = threading.Thread(target=uplaod_review_thread, args=(url, reviews, headers))
|
||||
thread = threading.Thread(target=upload_review_thread, args=(url, reviews, headers))
|
||||
thread.start()
|
||||
|
||||
# the info that the user rated an item is stored in the scene
|
||||
|
|
|
@ -156,7 +156,7 @@ def timer_update():
|
|||
preferences = bpy.context.preferences.addons['blenderkit'].preferences
|
||||
if first_time: # first time
|
||||
first_time = False
|
||||
if preferences.show_on_start or preferences.first_run:
|
||||
if preferences.show_on_start:
|
||||
# TODO here it should check if there are some results, and only open assetbar if this is the case, not search.
|
||||
# if bpy.context.scene.get('search results') is None:
|
||||
search()
|
||||
|
@ -167,7 +167,11 @@ def timer_update():
|
|||
ui.add_report(text='BlenderKit Tip: ' + random.choice(rtips), timeout=12, color=colors.GREEN)
|
||||
return 3.0
|
||||
|
||||
check_clipboard()
|
||||
if preferences.first_run:
|
||||
search()
|
||||
preferences.first_run = False
|
||||
|
||||
#check_clipboard()
|
||||
|
||||
global search_threads
|
||||
if len(search_threads) == 0:
|
||||
|
@ -765,7 +769,11 @@ class Searcher(threading.Thread):
|
|||
if query.get('query') is None and query.get('category_subtree') == None:
|
||||
# assumes no keywords and no category, thus an empty search that is triggered on start.
|
||||
# orders by last core file upload
|
||||
requeststring += '+order:-last_upload'
|
||||
if query.get('verification_status') == 'uploaded':
|
||||
#for validators, sort uploaded from oldest
|
||||
requeststring += '+order:created'
|
||||
else:
|
||||
requeststring += '+order:-last_upload'
|
||||
elif query.get('author_id') is not None and utils.profile_is_validator():
|
||||
|
||||
requeststring += '+order:-created'
|
||||
|
|
|
@ -73,6 +73,11 @@ def draw_ratings(layout, context):
|
|||
# this function should run only when asset was already checked to be existing
|
||||
if asset == None:
|
||||
return;
|
||||
|
||||
if not utils.user_logged_in():
|
||||
label_multiline(layout, text='Please login or sign up '
|
||||
'to rate assets.')
|
||||
return
|
||||
bkit_ratings = asset.bkit_ratings
|
||||
|
||||
ratings.draw_rating(layout, bkit_ratings, 'rating_quality', 'Quality')
|
||||
|
@ -89,6 +94,14 @@ def draw_ratings(layout, context):
|
|||
# op = row.operator("object.blenderkit_rating_upload", text="Send rating", icon='URL')
|
||||
# return op
|
||||
|
||||
def draw_not_logged_in(source):
|
||||
title = "User not logged in"
|
||||
def draw_message(source, context):
|
||||
layout = source.layout
|
||||
label_multiline(layout, text='Please login or sign up '
|
||||
'to upload files.')
|
||||
draw_login_buttons(layout)
|
||||
bpy.context.window_manager.popup_menu(draw_message, title=title, icon='INFO')
|
||||
|
||||
def draw_upload_common(layout, props, asset_type, context):
|
||||
op = layout.operator("wm.url_open", text="Read upload instructions",
|
||||
|
@ -919,8 +932,10 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu):
|
|||
op = layout.operator('view3d.blenderkit_search', text='Search Similar')
|
||||
op.keywords = asset_data['name'] + ' ' + asset_data['description'] + ' ' + ' '.join(asset_data['tags'])
|
||||
if asset_data.get('canDownload') != 0:
|
||||
if bpy.context.view_layer.objects.active is not None and ui_props.asset_type == 'MODEL':
|
||||
if len(bpy.context.selected_objects)>0 and ui_props.asset_type == 'MODEL':
|
||||
aob = bpy.context.active_object
|
||||
if aob is None:
|
||||
aob = bpy.context.selected_objects[0]
|
||||
op = layout.operator('scene.blenderkit_download', text='Replace Active Models')
|
||||
op.asset_type = ui_props.asset_type
|
||||
op.asset_index = ui_props.active_index
|
||||
|
@ -1124,7 +1139,7 @@ class VIEW3D_PT_blenderkit_downloads(Panel):
|
|||
|
||||
|
||||
def header_search_draw(self, context):
|
||||
'''Top bar menu in 3d view'''
|
||||
'''Top bar menu in 3D view'''
|
||||
|
||||
if not utils.guard_from_crash():
|
||||
return;
|
||||
|
|
|
@ -750,6 +750,8 @@ class UploadOperator(Operator):
|
|||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
def draw(self, context):
|
||||
props = utils.get_upload_props()
|
||||
layout = self.layout
|
||||
|
@ -774,6 +776,10 @@ class UploadOperator(Operator):
|
|||
def invoke(self, context, event):
|
||||
props = utils.get_upload_props()
|
||||
|
||||
if not utils.user_logged_in():
|
||||
ui_panels.draw_not_logged_in(self)
|
||||
return {'CANCELLED'}
|
||||
|
||||
if props.is_private == 'PUBLIC':
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
else:
|
||||
|
|
|
@ -546,6 +546,13 @@ def dict_to_params(inputs, parameters=None):
|
|||
return parameters
|
||||
|
||||
|
||||
def user_logged_in():
|
||||
a = bpy.context.window_manager.get('bkit profile')
|
||||
if a is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def profile_is_validator():
|
||||
a = bpy.context.window_manager.get('bkit profile')
|
||||
if a is not None and a['user'].get('exmenu'):
|
||||
|
|
Loading…
Reference in New Issue