Skip to content

Commit 0d0ea9a

Browse files
authored
Merge pull request #32 from RivinHD/dev
Version 2.3.0
2 parents dc568e0 + bfd48c5 commit 0d0ea9a

File tree

10 files changed

+171
-296
lines changed

10 files changed

+171
-296
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
__pycache__/__init__.cpython-37.pyc
33
Storage/
44
*.pyc
5+
*.zip

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"--max-line-length",
88
"120",
99
"--experimental"
10-
]
10+
],
11+
"python.analysis.diagnosticSeverityOverrides": {
12+
"reportInvalidTypeForm": "none",
13+
}
1114
}

__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import bpy
22
from bpy.app.handlers import persistent
3-
from . import properties, preferences, update, operators, functions, panels, dynamic_panels, menus
3+
from . import properties, preferences, operators, functions, panels, dynamic_panels, menus
44

55
bl_info = {
66
"name": "Script To Button",
77
"author": "RivinHD",
8-
"blender": (3, 3, 10),
9-
"version": (2, 2, 3),
8+
"blender": (3, 6, 0),
9+
"version": (2, 3, 0),
1010
"location": "View3D",
1111
"category": "System",
1212
"doc_url": "https://github.com/RivinHD/ScriptToButton/wiki",
@@ -38,7 +38,6 @@ def register():
3838
preferences.register()
3939
properties.register()
4040
operators.register()
41-
update.register()
4241
panels.register()
4342
menus.register()
4443
bpy.app.handlers.load_post.append(load_saves)
@@ -56,7 +55,6 @@ def unregister():
5655
preferences.unregister()
5756
properties.unregister()
5857
operators.unregister()
59-
update.unregister()
6058
panels.unregister()
6159
dynamic_panels.unregister()
6260
menus.unregister()

blender_manifest.toml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
schema_version = "1.0.0"
2+
3+
# Example of manifest file for a Blender extension
4+
# Change the values according to your extension
5+
id = "script_to_button"
6+
version = "2.3.0"
7+
name = "Script To Button"
8+
tagline = "Converts scripts to buttons"
9+
maintainer = "RivinHD"
10+
# Supported types: "add-on", "theme"
11+
type = "add-on"
12+
13+
# # Optional: link to documentation, support, source files, etc
14+
website = "https://github.com/RivinHD/ScriptToButton/wiki"
15+
16+
# # Optional: tag list defined by Blender and server, see:
17+
# # https://docs.blender.org/manual/en/dev/advanced/extensions/tags.html
18+
tags = ["System"]
19+
20+
blender_version_min = "4.2.0"
21+
# # Optional: Blender version that the extension does not support, earlier versions are supported.
22+
# # This can be omitted and defined later on the extensions platform if an issue is found.
23+
# blender_version_max = "5.1.0"
24+
25+
# License conforming to https://spdx.org/licenses/ (use "SPDX: prefix)
26+
# https://docs.blender.org/manual/en/dev/advanced/extensions/licenses.html
27+
license = [
28+
"SPDX:GPL-3.0-or-later",
29+
]
30+
# # Optional: required by some licenses.
31+
# copyright = [
32+
# "2002-2024 Developer Name",
33+
# "1998 Company Name",
34+
# ]
35+
36+
# # Optional: list of supported platforms. If omitted, the extension will be available in all operating systems.
37+
# platforms = ["windows-x64", "macos-arm64", "linux-x64"]
38+
# # Other supported platforms: "windows-arm64", "macos-x64"
39+
40+
# # Optional: bundle 3rd party Python modules.
41+
# # https://docs.blender.org/manual/en/dev/advanced/extensions/python_wheels.html
42+
# wheels = [
43+
# "./wheels/hexdump-3.3-py3-none-any.whl",
44+
# "./wheels/jsmin-3.0.1-py3-none-any.whl",
45+
# ]
46+
47+
# # Optional: add-ons can list which resources they will require:
48+
# # * files (for access of any filesystem operations)
49+
# # * network (for internet access)
50+
# # * clipboard (to read and/or write the system clipboard)
51+
# # * camera (to capture photos and videos)
52+
# # * microphone (to capture audio)
53+
# #
54+
# # If using network, remember to also check `bpy.app.online_access`
55+
# # https://docs.blender.org/manual/en/dev/advanced/extensions/addons.html#internet-access
56+
# #
57+
# # For each permission it is important to also specify the reason why it is required.
58+
# # Keep this a single short sentence without a period (.) at the end.
59+
# # For longer explanations use the documentation or detail page.
60+
61+
[permissions]
62+
files = "Save the user defined scripts"
63+
64+
# # Optional: advanced build settings.
65+
# # https://docs.blender.org/manual/en/dev/advanced/extensions/command_line_arguments.html#command-line-args-extension-build
66+
[build]
67+
# These are the default build excluded patterns.
68+
# You only need to edit them if you want different options.
69+
paths_exclude_pattern = [
70+
"__pycache__/",
71+
"/.git/",
72+
"/*.zip",
73+
"/.vscode/",
74+
"/.github/",
75+
".gitignore",
76+
".gitattributes"
77+
]

dynamic_panels.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,19 @@ def draw(self, context: Context):
104104
STB_MT_Buttons.__name__ = "STB_MT_Buttons_%s" % index
105105

106106
if register:
107+
button_classes[STB_MT_Buttons.__name__] = STB_MT_Buttons
107108
bpy.utils.register_class(STB_MT_Buttons)
108109
panel_names.append(name)
109110
panel_names.sort()
110111
else:
111-
bpy.utils.register_class(getattr(bpy.types, STB_MT_Buttons.__name__))
112+
bpy.utils.unregister_class(getattr(bpy.types, STB_MT_Buttons.__name__))
113+
del button_classes[STB_MT_Buttons.__name__]
112114
panel_names.remove(name)
113115
panel_names.sort()
114116

115117

116118
def unregister():
117119
for cls in button_classes.values():
118120
bpy.utils.unregister_class(cls)
121+
button_classes.clear()
119122
panel_names.clear()

operators.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ class STB_OT_RemoveButton(Operator):
178178
default=True
179179
)
180180

181+
@classmethod
182+
def poll(cls, context: Context):
183+
STB_pref = get_preferences(context)
184+
return STB_pref.selected_button != ""
185+
181186
def draw(self, context: Context):
182187
STB_pref = get_preferences(context)
183188
layout = self.layout
@@ -221,6 +226,11 @@ class STB_OT_Load(Operator):
221226
name="Texts in Texteditor"
222227
)
223228

229+
@classmethod
230+
def poll(cls, context: Context):
231+
STB_pref = get_preferences(context)
232+
return STB_pref.selected_button != ""
233+
224234
def draw(self, context: Context):
225235
layout = self.layout
226236
layout.prop(self, 'mode', expand=True)
@@ -277,6 +287,11 @@ class STB_OT_Reload(Operator):
277287
bl_description = "Reload the linked Text in the Texteditor of the selected Button"
278288
bl_options = {"REGISTER"}
279289

290+
@classmethod
291+
def poll(cls, context: Context):
292+
STB_pref = get_preferences(context)
293+
return STB_pref.selected_button != ""
294+
280295
def execute(self, context: Context):
281296
STB_pref = get_preferences(context)
282297
stb = context.scene.stb
@@ -315,6 +330,11 @@ class STB_OT_Save(Operator):
315330
bl_label = "Save"
316331
bl_description = "Save all buttons to the Storage"
317332

333+
@classmethod
334+
def poll(cls, context: Context):
335+
STB_pref = get_preferences(context)
336+
return STB_pref.selected_button != ""
337+
318338
def execute(self, context):
319339
Fails = []
320340
for button in context.scene.stb:
@@ -395,6 +415,11 @@ def get_use_filter_folder(self):
395415
filepath: StringProperty(name="File Path", maxlen=1024, default="")
396416
directory: StringProperty(name="Folder Path", maxlen=1024, default="")
397417

418+
@classmethod
419+
def poll(cls, context: Context):
420+
STB_pref = get_preferences(context)
421+
return STB_pref.selected_button != ""
422+
398423
def draw(self, context: Context):
399424
layout = self.layout
400425
layout.prop(self, 'mode', expand=True)
@@ -441,6 +466,11 @@ class STB_OT_Import(Operator, ImportHelper):
441466
)
442467
files: CollectionProperty(type=PropertyGroup)
443468

469+
@classmethod
470+
def poll(cls, context: Context):
471+
STB_pref = get_preferences(context)
472+
return STB_pref.selected_button != ""
473+
444474
def execute(self, context: Context):
445475
not_added_file = []
446476
button_fails = ([], [])
@@ -519,6 +549,11 @@ class STB_OT_Edit(Operator):
519549
name: StringProperty(name="Name")
520550
stb_properties: CollectionProperty(type=properties.STB_edit_property_item)
521551

552+
@classmethod
553+
def poll(cls, context: Context):
554+
STB_pref = get_preferences(context)
555+
return STB_pref.selected_button != ""
556+
522557
def items_stb_select_area(self, context: Context):
523558
for item in self.stb_areas:
524559
if item.delete:
@@ -679,6 +714,11 @@ class STB_OT_LoadSingleButton(Operator):
679714
bl_label = "Load Button"
680715
bl_description = "Load the script of the selected Button into the Texteditor"
681716

717+
@classmethod
718+
def poll(cls, context: Context):
719+
STB_pref = get_preferences(context)
720+
return STB_pref.selected_button != ""
721+
682722
def execute(self, context: Context):
683723
STB_pref = get_preferences(context)
684724
stb = context.scene.stb
@@ -717,6 +757,11 @@ def text_properties_items(self, context):
717757
options={'HIDDEN'}
718758
)
719759

760+
@classmethod
761+
def poll(cls, context: Context):
762+
STB_pref = get_preferences(context)
763+
return STB_pref.selected_button != ""
764+
720765
def invoke(self, context: Context, event: Event):
721766
STB_pref = get_preferences(context)
722767
text_index = bpy.data.texts.find(STB_pref.selected_button)
@@ -754,7 +799,9 @@ def execute(self, context: Context):
754799
item = self.text_variables[index]
755800
lines = [line.body for line in text.lines]
756801
if self.space == "PanelDialog":
757-
insert_comment = f"#STB-Input-Panel-{item.type} /// #STB-Input-Dialog-{item.type} /// #STB-InitValue-{item.value}-END"
802+
insert_comment = (
803+
f"#STB-Input-Panel-{item.type} /// #STB-Input-Dialog-{item.type} /// #STB-InitValue-"
804+
+ f"{item.value}-END")
758805
else:
759806
insert_comment = f"#STB-Input-{self.space}-{item.type} /// #STB-InitValue-{item.value}-END"
760807
lines.insert(item.position, insert_comment)

panels.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ class STB_PT_ScriptToButton(Panel):
2222
def draw(self, context: Context):
2323
layout = self.layout
2424
STB_pref = get_preferences(context)
25-
if STB_pref.auto_update and STB_pref.update:
26-
box = layout.box()
27-
box.label(
28-
text="A new Version is available (" + STB_pref.version + ")")
29-
box.operator("stb.update", text="Update")
3025
col = layout.column()
3126
row = col.row(align=True)
3227
row.operator("stb.add_button", text="Add", icon='ADD')
@@ -65,7 +60,7 @@ class STB_PT_Properties(Panel):
6560
bl_category = "Script To Button"
6661
bl_parent_id = "STB_PT_ScriptToButton_%s" % space_type
6762
bl_order = 2147483647 # max size
68-
63+
6964
def draw_header(self, context: Context):
7065
layout = self.layout
7166
layout.alignment = 'RIGHT'

preferences.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,45 +44,14 @@ def get_selected_button(self):
4444
return bpy.context.scene.get("stb_button.selected_name", "")
4545
selected_button: StringProperty(get=get_selected_button, name="INTERNAL")
4646

47-
update: BoolProperty()
48-
version: StringProperty()
49-
restart: BoolProperty()
50-
auto_update: BoolProperty(
51-
default=True,
52-
name="Auto Update",
53-
description="automatically search for a new update"
54-
)
55-
5647
def draw(self, context: Context) -> None:
57-
STB_pref = get_preferences(context)
5848
layout = self.layout
5949
row = layout.row()
6050
row.prop(self, 'autosave')
6151
row.prop(self, 'autoload')
6252
row.prop(self, 'delete_script_after_run')
6353
layout.separator(factor=0.8)
6454
col = layout.column()
65-
col.prop(STB_pref, 'auto_update')
66-
row = col.row()
67-
if STB_pref.update:
68-
row.operator("stb.update", text="Update")
69-
row.operator("stb.release_notes", text="Release Notes")
70-
else:
71-
row.operator("stb.check_update", text="Check For Updates")
72-
if STB_pref.restart:
73-
row.operator("stb.show_restart_menu", text="Restart to Finish")
74-
if STB_pref.version == '':
75-
return
76-
if STB_pref.update:
77-
col.label(
78-
text="A new Version is available (%s)" % STB_pref.version
79-
)
80-
else:
81-
col.label(
82-
text="You are using the latest Version (%s)" % STB_pref.version
83-
)
84-
layout.separator(factor=0.8)
85-
col = layout.column()
8655
kc = bpy.context.window_manager.keyconfigs.user
8756
for addon_keymap in keymaps.values():
8857
km = kc.keymaps[addon_keymap.name].active()

0 commit comments

Comments
 (0)