Skip to content

Commit 18936a8

Browse files
committed
Reverse the local resource logic
1 parent 08bfe0f commit 18936a8

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

demosys/effect_templates/cube_simple/effect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class SimpleCubeEffect(effect.Effect):
88
"""Generated default effect"""
99
def __init__(self):
10-
self.shader = self.get_shader("cube_plain.glsl")
10+
self.shader = self.get_shader("cube_plain.glsl", local=True)
1111
self.cube = geometry.cube(4.0, 4.0, 4.0)
1212

1313
@effect.bind_target

demosys/effect_templates/sphere_textured/effect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
class TexturedSphere(effect.Effect):
88
"""Generated default effect"""
99
def __init__(self):
10-
self.shader = self.get_shader("default.glsl")
10+
self.shader = self.get_shader("default.glsl", local=True)
1111
self.sphere = geometry.sphere(4.0, sectors=32, rings=16)
12-
self.texture = self.get_texture("wood.jpg")
12+
self.texture = self.get_texture("wood.jpg", local=True)
1313

1414
@effect.bind_target
1515
def draw(self, time, frametime, target):

demosys/effects/effect.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ def local_path(func):
2929
def local_wrapper(*args, **kwargs):
3030
use_local = kwargs.get('local')
3131

32-
# If use_local is True or None we assume local loading
33-
if use_local is not False:
34-
# Don't mess with the path if path starts with local dir
35-
if not args[1].startswith("{}/".format(args[0].effect_name)):
32+
# If use_local is True prepend the package name to the path
33+
if use_local is True:
3634
path = args[1]
3735
path = os.path.join(args[0].effect_name, path)
3836

@@ -87,7 +85,7 @@ def draw(self, time, frametime, target):
8785
# Methods for getting resources
8886

8987
@local_path
90-
def get_shader(self, path, local=True):
88+
def get_shader(self, path, local=False):
9189
"""
9290
Get a shader or schedule the shader for loading.
9391
If the resource is not loaded yet, an empty shader object
@@ -100,7 +98,7 @@ def get_shader(self, path, local=True):
10098
return resources.shaders.get(path, create=True)
10199

102100
@local_path
103-
def get_texture(self, path, local=True, **kwargs):
101+
def get_texture(self, path, local=False, **kwargs):
104102
"""
105103
Get a shader or schedule the texture for loading.
106104
If the resource is not loaded yet, an empty texture object
@@ -113,7 +111,7 @@ def get_texture(self, path, local=True, **kwargs):
113111
return resources.textures.get(path, create=True, **kwargs)
114112

115113
@local_path
116-
def get_track(self, name, local=True):
114+
def get_track(self, name, local=False):
117115
"""
118116
Get or create a rocket track. This only makes sense when using rocket timers.
119117
If the resource is not loaded yet, an empty track object
@@ -126,7 +124,7 @@ def get_track(self, name, local=True):
126124
return resources.tracks.get(name)
127125

128126
@local_path
129-
def get_scene(self, path, local=True, **kwargs):
127+
def get_scene(self, path, local=False, **kwargs):
130128
"""
131129
Get or create a scene.
132130
:param path: Path to the scene

0 commit comments

Comments
 (0)