Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilém Duha <vilda.novak@gmail.com>2020-12-27 23:26:55 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-12-27 23:26:55 +0300
commit317934f41738179fbd18acda57cc3ff85eb3ac27 (patch)
treecc489c3d9232ea9eadc060de6285755fddf69856 /blenderkit
parent5a6b7e99c1297d60022117ad596d5614892340ed (diff)
BlenderKit: several improvements to rating
Try to make rating more prominent in the interface by adding some messages to tooltips (by now only for validators), reorder rating in the menu Fix texture resolution in tooltips.
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/__init__.py2
-rw-r--r--blenderkit/ratings.py4
-rw-r--r--blenderkit/search.py30
-rw-r--r--blenderkit/ui.py15
-rw-r--r--blenderkit/ui_panels.py13
5 files changed, 42 insertions, 22 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index fa7ec290..dd04c506 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -717,7 +717,7 @@ class BlenderKitRatingProps(PropertyGroup):
rating_work_hours: FloatProperty(name="Work Hours",
description="How many hours did this work take?",
default=0.00,
- min=0.0, max=1000, update=ratings.update_ratings_work_hours
+ min=0.0, max=150, update=ratings.update_ratings_work_hours
)
# rating_complexity: IntProperty(name="Complexity",
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py
index 2ec1f462..d2c91412 100644
--- a/blenderkit/ratings.py
+++ b/blenderkit/ratings.py
@@ -342,7 +342,7 @@ class FastRateMenu(Operator):
rating_work_hours: FloatProperty(name="Work Hours",
description="How many hours did this work take?",
default=0.00,
- min=0.0, max=1000, update=update_ratings_work_hours
+ min=0.0, max=150, update=update_ratings_work_hours
)
rating_work_hours_ui: EnumProperty(name="Work Hours",
@@ -443,7 +443,7 @@ class FastRateMenu(Operator):
self.message = f"Rate asset {self.asset_name}"
wm = context.window_manager
- if utils.profile_is_validator():
+ if utils.profile_is_validator() and self.asset_type == 'model':
#spawn a wider one for validators for the enum buttons
return wm.invoke_props_dialog(self, width = 500)
else:
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 26fcef0e..84254434 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -249,10 +249,9 @@ def parse_result(r):
if f['fileType'].find('resolution') > -1:
r['available_resolutions'].append(resolutions.resolutions[f['fileType']])
r['max_resolution'] = 0
- if r['available_resolutions']:#should check only for non-empty sequences
+ if r['available_resolutions']: # should check only for non-empty sequences
r['max_resolution'] = max(r['available_resolutions'])
-
tooltip = generate_tooltip(r)
# for some reason, the id was still int on some occurances. investigate this.
r['author']['id'] = str(r['author']['id'])
@@ -462,7 +461,7 @@ def load_previews():
img.filepath = tpath
img.reload()
if r['assetType'] == 'hdr':
- #to display hdr thumbnails correctly, we use non-color, otherwise looks shifted
+ # to display hdr thumbnails correctly, we use non-color, otherwise looks shifted
img.colorspace_settings.name = 'Non-Color'
else:
img.colorspace_settings.name = 'sRGB'
@@ -617,9 +616,9 @@ def generate_tooltip(mdata):
t += 'texture size: %s\n' % fmt_length(mparams['textureSizeMeters'])
if has(mparams, 'textureResolutionMax') and mparams['textureResolutionMax'] > 0:
- if not mparams.get('textureResolutionMin'):#for HDR's
+ if not mparams.get('textureResolutionMin'): # for HDR's
t = writeblockm(t, mparams, key='textureResolutionMax', pretext='Resolution', width=col_w)
- elif mparams.get('textureResolutionMin') == mparams['textureResolutionMax']:
+ elif mparams.get('textureResolutionMin') == mparams['textureResolutionMax']:
t = writeblockm(t, mparams, key='textureResolutionMin', pretext='texture resolution', width=col_w)
else:
t += 'tex resolution: %i - %i\n' % (mparams.get('textureResolutionMin'), mparams['textureResolutionMax'])
@@ -646,8 +645,8 @@ def generate_tooltip(mdata):
else:
if fs:
for f in fs:
- if f['fileType'].find('resolution')>-1:
- t+= 'Asset has lower resolutions available\n'
+ if f['fileType'].find('resolution') > -1:
+ t += 'Asset has lower resolutions available\n'
break;
# generator is for both upload preview and search, this is only after search
# if mdata.get('versionNumber'):
@@ -659,6 +658,20 @@ def generate_tooltip(mdata):
# t += generate_author_textblock(adata)
# t += '\n'
+ if utils.profile_is_validator():
+ rc = mdata.get('ratingsCount')
+ if rc:
+ rcount = min(rc['quality'], rc['workingHours'])
+ else:
+ rcount = 0
+ if rcount < 10:
+ t += f"Please rate this asset, \nit doesn't have enough ratings.\n"
+ else:
+ t += f"Quality rating: {int(mdata['ratingsAverage']['quality']) * '*'}\n"
+ t += f"Hours saved rating: {int(mdata['ratingsAverage']['workingHours'])}\n"
+ if utils.profile_is_validator():
+ t += f"Ratings count {rc['quality']}*/{rc['workingHours']}wh value " \
+ f"{int(mdata['ratingsAverage']['quality'])}*/{int(mdata['ratingsAverage']['workingHours'])}wh\n"
if len(t.split('\n')) < 11:
t += '\n'
t += get_random_tip(mdata)
@@ -1109,7 +1122,6 @@ def build_query_model():
if props.free_only:
query["is_free"] = True
-
# if props.search_advanced:
if props.search_condition != 'UNSPECIFIED':
query["condition"] = props.search_condition
@@ -1426,7 +1438,7 @@ def search_update(self, context):
# this complex behaviour is here for the case where the user needs to paste manually into blender?
sprops = utils.get_search_props()
sprops.search_keywords = kwds[:ati].rstrip()
- #return here since writing into search keywords triggers this update function once more.
+ # return here since writing into search keywords triggers this update function once more.
return
search()
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 02e3ef71..ba98f0cd 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -346,7 +346,8 @@ def draw_tooltip(x, y, text='', author='', img=None, gravatar=None):
textcol = bpy.context.preferences.themes[0].user_interface.wcol_tooltip.text
textcol = (textcol[0], textcol[1], textcol[2], 1)
textcol_mild = (textcol[0] * .8, textcol[1] * .8, textcol[2] * .8, 1)
- textcol_strong = (textcol[0] * 1.3, textcol[1] * 1.3, textcol[2] * 1.3, 1)
+ textcol_strong = (textcol[0] * 1.3, textcol[1] * 2.3, textcol[2] * 1.3, 1)
+ textcol_strong = (0.4, 1, 0.3, 1)
white = (1, 1, 1, .1)
# background
@@ -387,9 +388,11 @@ def draw_tooltip(x, y, text='', author='', img=None, gravatar=None):
tcol = textcol
tsize = font_height
else:
- if l[:4] == 'Tip:':
- tcol = textcol_strong
fsize = font_height
+ if l[:4] == 'Tip:' or l[:11] == 'Please rate':
+ tcol = textcol_strong
+ fsize = font_height + 1
+
i += 1
column_lines += 1
ui_bgl.draw_text(l, xtext, ytext, fsize, tcol)
@@ -411,9 +414,11 @@ def draw_tooltip(x, y, text='', author='', img=None, gravatar=None):
tcol = textcol
tsize = font_height
else:
- if l[:4] == 'Tip:':
- tcol = textcol_strong
fsize = font_height
+ if l[:4] == 'Tip:' or l[:11] == 'Please rate':
+ tcol = textcol_strong
+ fsize = font_height + 1
+
i += 1
column_lines += 1
ui_bgl.draw_text(l, xtext, ytext, fsize, tcol)
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 9d8d6460..daa88f82 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -1134,6 +1134,14 @@ def draw_asset_context_menu(self, context, asset_data, from_panel=False):
author_id = str(asset_data['author'].get('id'))
wm = bpy.context.window_manager
+
+ layout.operator_context = 'INVOKE_DEFAULT'
+
+ op = layout.operator('wm.blenderkit_menu_rating_upload', text='Rate')
+ op.asset_name = asset_data['name']
+ op.asset_id = asset_data['id']
+ op.asset_type = asset_data['assetType']
+
if wm.get('bkit authors') is not None and author_id is not None:
a = bpy.context.window_manager['bkit authors'].get(author_id)
if a is not None:
@@ -1181,12 +1189,7 @@ def draw_asset_context_menu(self, context, asset_data, from_panel=False):
# if asset_data['downloaded'] == 100: # only show for downloaded/used assets
# if ui_props.asset_type in ('MODEL', 'MATERIAL'):
# layout.menu(OBJECT_MT_blenderkit_resolution_menu.bl_idname)
- layout.operator_context = 'INVOKE_DEFAULT'
- op = layout.operator('wm.blenderkit_menu_rating_upload', text='Rate')
- op.asset_name = asset_data['name']
- op.asset_id = asset_data['id']
- op.asset_type = asset_data['assetType']
if ui_props.asset_type in ('MODEL', 'MATERIAL', 'HDR') and \
utils.get_param(asset_data, 'textureResolutionMax') is not None and \