-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
common.py
61 lines (41 loc) · 1.49 KB
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import bpy
ADDON_NAME = 'blender-uvcs'
def get_addon_preferences(context):
return context.preferences.addons[ADDON_NAME].preferences
def get_uvcs_context(context):
return context.window_manager.uvcs_context
def show_info_message(title, messages):
__show_message(title, messages, 'INFO')
def show_warning_message(title, messages):
__show_message(title, messages, 'ERROR')
def show_error_message(title, messages):
__show_message(title, messages, 'CANCEL')
def show_error_log(title, message, log):
messages = [message, ' ', 'Unity Version Control output:']
for log_line in log:
messages.append('> ' + log_line)
__show_message(title, messages, 'CANCEL')
def __show_message(title, messages, icon='INFO'):
def draw(self, context):
layout = self.layout
for message in messages:
for limited_line in __limit_line_chars(message):
layout.label(text=limited_line, translate=False)
bpy.context.window_manager.popup_menu(draw, title=title, icon=icon)
def __limit_line_chars(line_text):
max_chars = 100
limited_lines = []
line_words = line_text.split(' ')
i = 0
line_text = ''
while i < len(line_words):
if len(line_text) < max_chars:
line_text += (line_words[i] + ' ')
i += 1
else:
limited_lines.append(line_text)
line_text = ''
limited_lines.append(line_text)
return limited_lines
def quote(text):
return '"' + text + '"'