Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logic shape #130

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions dread_editor/bmsad_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,26 @@ def draw(self, current_scale: float):
imgui.next_column()

# Fields
if component.fields is not None and imgui_util.tree_node_with_column(
f"Fields ##{component_key}_fields", imgui.TREE_NODE_DEFAULT_OPEN):
if imgui_util.tree_node_with_column(f"Fields ##{component_key}_fields",
imgui.TREE_NODE_DEFAULT_OPEN):

if component.fields is not None:
fields = component.fields.fields
else:
fields = construct.Container()

changed, new_field = bmsad_tree_render.render_value_of_type(
component.fields.fields,
fields,
type_lib.get_type(find_charclass_for_type(component.type)),
f"{component_key}"
)
if changed:
if component.fields is None:
component.fields = construct.Container(
empty_string="",
root="Root",
fields=new_field,
)
component.fields.fields = new_field
imgui.tree_pop()

Expand Down
18 changes: 18 additions & 0 deletions dread_editor/level_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def lerp_y(y):
self.display_borders["bottom"] - self.display_borders["top"])
return ly * actual_scale + canvas_po.y

# Draw Camera/Rooms
for entry in self.bmscc.raw.layers[0].entries:
if not self.valid_cameras.get(entry.name):
continue
Expand Down Expand Up @@ -285,6 +286,23 @@ def lerp_y(y):
if (mouse.x - final_x) ** 2 + (mouse.y - final_y) ** 2 < 5 * 5:
self.highlighted_actors_in_canvas.append((layer_name, actor))

if ("LOGICSHAPE" in actor.pComponents
and actor.pComponents.LOGICSHAPE["@type"] == 'CLogicShapeComponent'):
shape = actor.pComponents.LOGICSHAPE.pLogicShape
if shape is not None and shape["@type"] == 'game::logic::collision::CPolygonCollectionShape':
for poly in shape.oPolyCollection.vPolys:
vertices = []
for p in poly.oSegmentData:
vertices.append(
(lerp_x(p.vPos[0] + actor.vPos[0]),
lerp_y(p.vPos[1] + actor.vPos[1]))
)
draw_list.add_polyline(
vertices, color,
closed=poly.bClosed,
thickness=3,
)

if self.highlighted_actors_in_canvas and imgui.is_window_hovered():
imgui.begin_tooltip()
for layer_name, actor in self.highlighted_actors_in_canvas:
Expand Down
5 changes: 5 additions & 0 deletions dread_editor/main_loop.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import time
import tkinter
import tkinter.filedialog
import typing
Expand Down Expand Up @@ -174,7 +175,10 @@ def loop():

def load_romfs(path: Path):
nonlocal pkg_editor, possible_brfld, file_browser
start_time = time.time()
pkg_editor = FileTreeEditor(path)
print("Time to create FileTreeEditor: {:.03f}s".format(time.time() - start_time))

possible_brfld = [
asset_name
for asset_name in pkg_editor.all_asset_names()
Expand All @@ -195,6 +199,7 @@ def load_romfs(path: Path):

global_preferences["last_romfs"] = str(path)
save_preferences()
print("Time for load_romfs: {:.03f}s".format(time.time() - start_time))

while not glfw.window_should_close(window):
glfw.poll_events()
Expand Down