Skip to content

Commit 5c9d509

Browse files
authored
Merge pull request #1606 from glebmish/different-fixes
Different fixes
2 parents 093050e + ef17da1 commit 5c9d509

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

sandbox/studio/plugins/texture_processor/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
import os
88
import sys
99
import logging
10+
1011
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
1112

13+
1214
def register():
13-
menu = ui.find_or_create_menu("Utils")
15+
menu = ui.find_or_create_menu("Plugins")
1416

1517
act = QtWidgets.QAction("Convert textures", menu)
1618
act.triggered.connect(convert_all_textures_to_tx)
1719

1820
menu.addAction(act)
1921

22+
2023
def convert_all_textures_to_tx():
2124
def _find_maketx():
2225
root_path = studio.get_root_path()
@@ -28,6 +31,10 @@ def _find_maketx():
2831
raise Exception('maketx binary is not found')
2932

3033
project = studio.current_project()
34+
35+
if project is None:
36+
return
37+
3138
scene = project.get_scene()
3239
textures = get_textures(scene)
3340

@@ -56,8 +63,10 @@ def _find_maketx():
5663

5764
texture_parameters['filename'] = new_texture_path
5865
texture.set_parameters(texture_parameters)
66+
studio.set_project_dirty()
5967
logging.info('{} converted to {}'.format(texture_path, new_texture_path))
6068

69+
6170
def get_textures(container):
6271
assert isinstance(container, asr.BaseGroup)
6372

@@ -69,6 +78,7 @@ def get_textures(container):
6978

7079
return textures
7180

81+
7282
def get_full_path(texture_path, project):
7383
if os.path.isabs(texture_path):
7484
return texture_path

src/appleseed.python/studio/plugins.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
import imp
3131
import traceback
3232

33+
3334
def load_plugins(bundled_plugins_path):
3435
load_plugins_from_dir(bundled_plugins_path)
3536

3637
user_plugins_path = os.environ.get('APPLESEED_STUDIO_PLUGIN_PATH')
3738
if user_plugins_path is not None:
3839
load_plugins_from_dir(user_plugins_path)
3940

41+
4042
def load_plugins_from_dir(bundled_plugins_path):
4143
for plugin in os.listdir(bundled_plugins_path):
4244
plugin_path = os.path.join(bundled_plugins_path, plugin)
@@ -46,6 +48,7 @@ def load_plugins_from_dir(bundled_plugins_path):
4648

4749
load_plugin(plugin_path)
4850

51+
4952
def load_plugin(plugin_path):
5053
path, name = os.path.split(plugin_path)
5154
name, ext = os.path.splitext(name)

src/appleseed.python/studio/ui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import appleseed.studio as studio
3030
import Qt
3131

32+
3233
def wrapinstance(addr, type):
3334
if Qt.__binding__ == 'PyQt4':
3435
import sip
@@ -41,6 +42,7 @@ def wrapinstance(addr, type):
4142
else:
4243
raise Exception("No wrapinstance function defined for " + Qt.__binding__)
4344

45+
4446
def find_or_create_menu(menu_name):
4547
ptr = studio.main_window()
4648
main_window = wrapinstance(long(ptr), Qt.QtWidgets.QMainWindow)

src/appleseed.studio/python/module.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ bool is_project_dirty()
109109
return project_manager()->is_project_dirty();
110110
}
111111

112+
void set_project_dirty()
113+
{
114+
project_manager()->set_project_dirty_flag();
115+
}
116+
112117
bpy::long_ main_window_as_pylong()
113118
{
114119
const uintptr_t ptr = binary_cast<uintptr_t>(main_window());
@@ -135,6 +140,7 @@ BOOST_PYTHON_MODULE(_appleseedstudio)
135140
bpy::def("current_project", current_project,
136141
bpy::return_value_policy<bpy::reference_existing_object>());
137142
bpy::def("is_project_dirty", is_project_dirty);
143+
bpy::def("set_project_dirty", set_project_dirty);
138144

139145
bpy::def("main_window", main_window_as_pylong);
140146
bpy::def("create_dock_widget", create_dock_widget, bpy::args("dock_name"));

0 commit comments

Comments
 (0)