Skip to content

Commit

Permalink
Made the box around pasting structures green
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC committed Jun 12, 2020
1 parent 9bafdc5 commit d927982
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion amulet_map_editor/opengl/mesh/selection/render_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ def __init__(self,
self.draw_count = 36
self._draw_mode = GL_TRIANGLES

@property
def box_tint(self) -> Tuple[int, int, int]:
return 1, 1, 1

def _init_verts(self, texture_bounds: Dict[Any, Tuple[float, float, float, float]]):
missing_no = texture_bounds.get(('minecraft', 'missing_no'), (0, 0, 0, 0))
self.verts = numpy.zeros((6 * 2 * 3, self._vert_len), dtype=numpy.float32)
self.verts[:36, 5:9] = texture_bounds.get(('amulet', 'ui/selection'), missing_no)
self.verts[:, 9:12] = 1
self.verts[:, 9:12] = self.box_tint

def __contains__(self, position: Union[BlockCoordinatesAny, PointCoordinatesAny]) -> bool:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _init_verts(self, texture_bounds: Dict[Any, Tuple[float, float, float, float
self.verts[:36, 5:9] = texture_bounds.get(('amulet', 'ui/selection'), missing_no)
self.verts[36:72, 5:9] = texture_bounds.get(('amulet', 'ui/selection_green'), missing_no)
self.verts[72:, 5:9] = texture_bounds.get(('amulet', 'ui/selection_blue'), missing_no)
self.verts[:, 9:12] = 1
self.verts[:, 9:12] = self.box_tint

@property
def is_static(self) -> bool:
Expand Down
15 changes: 13 additions & 2 deletions amulet_map_editor/opengl/mesh/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@

from amulet_map_editor.opengl.mesh.base.chunk_builder import RenderChunkBuilder
from amulet_map_editor.opengl.resource_pack import ResourcePackManager
from amulet_map_editor.opengl.mesh.selection import RenderSelectionGroup
from amulet_map_editor.opengl.mesh.selection import RenderSelectionGroup, RenderSelection


class GreenRenderSelection(RenderSelection):
@property
def box_tint(self) -> Tuple[float, float, float]:
return 0.7, 1.0, 0.7


class GreenRenderSelectionGroup(RenderSelectionGroup):
def _new_render_selection(self):
return GreenRenderSelection(self._context_identifier, self._texture_bounds, self._texture)


class SubRenderStructure(RenderChunkBuilder):
Expand Down Expand Up @@ -69,7 +80,7 @@ def __init__(
super().__init__(context_identifier, resource_pack, texture, texture_bounds, translator)
self._structure = structure
self._sub_structures = []
self._selection = RenderSelectionGroup(context_identifier, texture_bounds, texture, structure.selection)
self._selection = GreenRenderSelectionGroup(context_identifier, texture_bounds, texture, structure.selection)
self._create_geometry() # TODO: move this to a different thread

@property
Expand Down

0 comments on commit d927982

Please sign in to comment.