Skip to content

Commit

Permalink
Merge branch 'Amulet-Team:0.10' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
toka7290 authored Mar 3, 2023
2 parents 8911004 + 3ba1c7e commit f70b0d9
Show file tree
Hide file tree
Showing 27 changed files with 340 additions and 40 deletions.
1 change: 0 additions & 1 deletion amulet_map_editor/api/framework/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class AmuletApp(wx.App):

_amulet_ui: amulet_ui.AmuletUI

def OnInit(self):
Expand Down
1 change: 1 addition & 0 deletions amulet_map_editor/api/framework/update_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def goto_download_page(new_version, _):

def _is_compatible(current_version: Version, release_version: Version) -> bool:
"""The release version is only compatible with the current version if it is newer and more stable."""

# release > beta > beta.dev > alpha.dev
# > alpha > alpha.dev
def get_release_stage(version: Version) -> int:
Expand Down
12 changes: 7 additions & 5 deletions amulet_map_editor/api/opengl/canvas/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,19 @@ def __init__(self, parent: wx.Window):
size=parent.GetClientSize(),
style=wx.WANTS_CHARS,
)

if sys.platform == "linux":
# setup the OpenGL context. This apparently fixes Amulet-Team/Amulet-Map-Editor#84
self._context = glcanvas.GLContext(self)
else:
if sys.platform == "darwin":
# This is required for MacOS. Amulet-Team/Amulet-Map-Editor#597
context_attributes = wx.glcanvas.GLContextAttrs()
context_attributes.CoreProfile().Robust().ResetIsolation().EndList()
self._context = glcanvas.GLContext(
self, ctxAttrs=context_attributes
) # setup the OpenGL context
else:
# This is required for linux and windows.
# Amulet-Team/Amulet-Map-Editor#84
# Amulet-Team/Amulet-Map-Editor#856
self._context = glcanvas.GLContext(self)

if not self._context.IsOK():
raise Exception(f"Failed setting up context")

Expand Down
6 changes: 4 additions & 2 deletions amulet_map_editor/api/opengl/canvas/event_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ def __init__(self, parent: wx.Window):

def reset_bound_events(self):
"""Unbind all events and re-bind the default events.
We are allowing users to bind custom events so we should have a way to reset what is bound."""
We are allowing users to bind custom events so we should have a way to reset what is bound.
"""
self.tear_down_events()
self.bind_events()

def tear_down_events(self):
"""Unbind all events.
We are allowing users to bind custom events so we should have a way to reset what is bound."""
We are allowing users to bind custom events so we should have a way to reset what is bound.
"""
for event, handler, source in self._bound_events:
if source is None:
while super().Unbind(event):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def offset(self) -> numpy.ndarray:
@staticmethod
def _get_block_data(blocks: numpy.ndarray) -> Tuple[numpy.ndarray, numpy.ndarray]:
"""Given a Chunk object will return the chunk arrays needed to generate geometry
:returns: block array of the chunk, block array one block larger than the chunk, array of unique blocks"""
:returns: block array of the chunk, block array one block larger than the chunk, array of unique blocks
"""
larger_blocks = numpy.zeros(blocks.shape + numpy.array((2, 2, 2)), blocks.dtype)
larger_blocks[1:-1, 1:-1, 1:-1] = blocks
unique_blocks = numpy.unique(larger_blocks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ def point2_colour(self) -> RGBColour:
@property
def locked(self) -> bool:
"""Is the selection locked or not.
If locked (True) the highlight colour will be used, if unlocked (False) the moving colour will be used."""
If locked (True) the highlight colour will be used, if unlocked (False) the moving colour will be used.
"""
return self._locked

@locked.setter
def locked(self, lock: bool):
"""Set if the selection locked or not.
If locked (True) the highlight colour will be used, if unlocked (False) the moving colour will be used."""
If locked (True) the highlight colour will be used, if unlocked (False) the moving colour will be used.
"""
self._locked = bool(lock)

def _create_geometry_(self):
Expand Down
3 changes: 2 additions & 1 deletion amulet_map_editor/api/opengl/resource_pack/resource_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def get_atlas_id(self, context_id: str) -> int:

def get_texture_path(self, namespace: Optional[str], relative_path: str):
"""Get the absolute path of the image from the relative components.
Useful for getting the id of textures for hard coded textures not connected to a resource pack."""
Useful for getting the id of textures for hard coded textures not connected to a resource pack.
"""
return self._resource_pack.get_texture_path(namespace, relative_path)

def texture_bounds(self, texture_path: str) -> Tuple[float, float, float, float]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

class OpenGLResourcePackManagerStatic:
"""A class to hold an opengl resource pack.
All classes wanting to access block geometry or textures should subclass this class."""
All classes wanting to access block geometry or textures should subclass this class.
"""

def __init__(
self,
Expand All @@ -18,7 +19,8 @@ def resource_pack(self) -> OpenGLResourcePack:

class OpenGLResourcePackManager(OpenGLResourcePackManagerStatic):
"""A class to hold and enable switching of an opengl resource pack.
All classes wanting to access block geometry or textures should subclass this class."""
All classes wanting to access block geometry or textures should subclass this class.
"""

@property
def resource_pack(self) -> OpenGLResourcePack:
Expand Down
4 changes: 3 additions & 1 deletion amulet_map_editor/api/opengl/shaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def compile_shader():

try:
shader = compile_shader()
except OpenGL.GL.shaders.ShaderValidationError: # on Mac the above fails if there is no VBO bound
except (
OpenGL.GL.shaders.ShaderValidationError
): # on Mac the above fails if there is no VBO bound
glBindVertexArray(glGenVertexArrays(1))
shader = compile_shader()
glBindVertexArray(0)
Expand Down
3 changes: 2 additions & 1 deletion amulet_map_editor/api/wx/ui/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def SetItems(
):
"""Set items. Does not have to be strings.
If items is a dictionary the string of the values are show to the user and the key is returned from GetAny
If it is just an iterable the string of the values are shown and the raw equivalent input is returned."""
If it is just an iterable the string of the values are shown and the raw equivalent input is returned.
"""
if not items:
return
if isinstance(items, dict):
Expand Down
3 changes: 2 additions & 1 deletion amulet_map_editor/api/wx/util/button_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def is_key_pressed(self, key: KeyType):

def unpress_all(self):
"""Unpress all keys.
This is useful if the window focus is lost because key release events will not be detected."""
This is useful if the window focus is lost because key release events will not be detected.
"""
self._pressed_keys.clear()
self._clean_up_actions()

Expand Down
2 changes: 0 additions & 2 deletions amulet_map_editor/api/wx/util/key_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@
def serialise_modifier(
evt: Union[wx.KeyEvent, wx.MouseEvent], key: int
) -> ModifierType:

modifier = []
if evt.ControlDown():
if key not in (wx.WXK_SHIFT, wx.WXK_ALT):
Expand Down Expand Up @@ -275,7 +274,6 @@ def serialise_key_event(
evt: Union[wx.KeyEvent, wx.MouseEvent]
) -> Optional[SerialisedKeyType]:
if isinstance(evt, wx.KeyEvent):

key = evt.GetUnicodeKey() or evt.GetKeyCode()
if key == wx.WXK_CONTROL:
return
Expand Down
9 changes: 6 additions & 3 deletions amulet_map_editor/api/wx/util/mouse_movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,22 @@ def reset_delta(self):
@property
def delta_x(self) -> int:
"""The x pixel distance between the current location and the location when reset_delta was called.
If the pointer was warped the offset before it was warped will be added to this."""
If the pointer was warped the offset before it was warped will be added to this.
"""
return self.delta_xy[0]

@property
def delta_y(self) -> int:
"""The y pixel distance between the current location and the location when reset_delta was called.
If the pointer was warped the offset before it was warped will be added to this."""
If the pointer was warped the offset before it was warped will be added to this.
"""
return self.delta_xy[1]

@property
def delta_xy(self) -> Tuple[int, int]:
"""The x and y pixel distance between the current location and the location when reset_delta was called.
If the pointer was warped the offset before it was warped will be added to this."""
If the pointer was warped the offset before it was warped will be added to this.
"""
return self._to_absolute(
self._x - self._start_x + self._delta_x,
self._y - self._start_y + self._delta_y,
Expand Down
Loading

0 comments on commit f70b0d9

Please sign in to comment.