Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ obj~/

# SSH credentials, DO NOT COMMIT
/scripts/credentials

# For the Blender addon
__pycache__
31 changes: 31 additions & 0 deletions Blender/Blender.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!--
Will copy files to $(BlenderAddonsDir) so you can quickly iterate in Blender.

In Blender use "Reload Scripts" command. Blender>System>Reload Scripts or hit F3
and search for "Reload Scripts"
-->

<Import Condition="Exists('$(MSBuildProjectDirectory)/../Directory.Build.props')" Project="$(MSBuildProjectDirectory)/../Directory.Build.props" />
<Import Condition="Exists('$(MSBuildProjectDirectory)/../Directory.Build.props.user')" Project="$(MSBuildProjectDirectory)/../Directory.Build.props.user" />
<Import Condition="Exists('$(MSBuildProjectFile).user')" Project="$(MSBuildProjectFile).user" />

<PropertyGroup>
<BuildDir>$(MSBuildProjectDirectory)/../Build/MapStation_Blender_Addon</BuildDir>
<BuildZip>$(MSBuildProjectDirectory)/../Build/MapStation_Blender_Addon.zip</BuildZip>
</PropertyGroup>

<Target Name="Build">
<MakeDir Directories="$(BuildDir)" />
<ItemGroup>
<_Assets Include="$(MSBuildProjectDirectory)/mapstation/**/*" Exclude="__pycache__" />
</ItemGroup>
<!-- Copy to /Build -->
<Copy SourceFiles="@(_Assets)" DestinationFolder="$(BuildDir)/mapstation/%(RecursiveDir)" />
<!-- Copy to Blender addons dir -->
<Copy Condition="'' != '$(BlenderAddonsDir)'" SourceFiles="@(_Assets)" DestinationFolder="$(BlenderAddonsDir)/mapstation/%(RecursiveDir)" />
<!-- Zip for publication -->
<ZipDirectory Overwrite="true" DestinationFile="$(MSBuildProjectDirectory)/../Build/MapStation_Blender_Addon.zip" SourceDirectory="$(BuildDir)" />
</Target>
</Project>
32 changes: 32 additions & 0 deletions Blender/mapstation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import importlib

# To support auto-reload of local imports: https://blenderartists.org/t/is-reload-scripts-not-working-for-anyone-else-for-addon-development/1146804
if "bpy" in locals():
importlib.reload(mapstation.auto_assign_guids)
importlib.reload(mapstation.hint_ui)
else:
import mapstation.auto_assign_guids
import mapstation.hint_ui

import bpy

bl_info = {
"name": "MapStation",
"description": "Mapping tools for Bomb Rush Cyberfunk",
"author": "cspotcode",
"version": (1, 0),
"blender": (4, 0, 0),
"location": "",
"category": "Object"
}

def register():
print("Register")
mapstation.auto_assign_guids.register()

def unregister():
print("Unregister")
mapstation.auto_assign_guids.unregister()

if __name__ == "__main__":
register()
33 changes: 33 additions & 0 deletions Blender/mapstation/auto_assign_guids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import bpy
import uuid
guid_prop = "guid"

def gen_guid():
return str(uuid.uuid4())

def assign_guids():
guids = set()
for obj in bpy.data.objects:
if guid_prop in obj:
guid = obj[guid_prop]
if guid in guids:
guid = gen_guid()
obj[guid_prop] = guid
else:
guid = gen_guid()
obj[guid_prop] = guid
guids.add(guid)

# return delay so timer calls us again
return 1

def register():
print("register auto_assign_guids: " + __file__)
print("hi there")
bpy.app.timers.register(assign_guids)

def unregister():
bpy.app.timers.unregister(assign_guids)

if __name__ == "__main__":
register()
72 changes: 72 additions & 0 deletions Blender/mapstation/hint_ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import bpy

# Define the hints array
hints = ["_Grind", "_NonStableSurface", "_Spawn"]

class ObjectHintPanel(bpy.types.Panel):
bl_label = "BRC MapStation Hints"
bl_idname = "OBJECT_PT_hint_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Object'

def draw(self, context):
layout = self.layout

obj = context.active_object

if obj:
layout.label(text="Selected Object: " + obj.name)
layout.separator()

for hint in hints:
# Check if the hint is present in the object name
has_hint = hint in obj.name

# Toggle hint button
if has_hint:
layout.operator("object.remove_hint_operator", text="Remove " + hint).hint = hint
else:
layout.operator("object.add_hint_operator", text="Add " + hint).hint = hint
else:
layout.label(text="No object selected")


class AddHintOperator(bpy.types.Operator):
bl_idname = "object.add_hint_operator"
bl_label = "Add Hint"

hint: bpy.props.StringProperty()

def execute(self, context):
obj = context.active_object
obj.name += self.hint
return {'FINISHED'}


class RemoveHintOperator(bpy.types.Operator):
bl_idname = "object.remove_hint_operator"
bl_label = "Remove Hint"

hint: bpy.props.StringProperty()

def execute(self, context):
obj = context.active_object
obj.name = obj.name.replace(self.hint, "")
return {'FINISHED'}


def register():
bpy.utils.register_class(ObjectHintPanel)
bpy.utils.register_class(AddHintOperator)
bpy.utils.register_class(RemoveHintOperator)


def unregister():
bpy.utils.unregister_class(ObjectHintPanel)
bpy.utils.unregister_class(AddHintOperator)
bpy.utils.unregister_class(RemoveHintOperator)


if __name__ == "__main__":
register()
Binary file not shown.
106 changes: 106 additions & 0 deletions MapStation.Editor/Assets/Maps/cspotcode.demo/VertexandCurve.blend.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
106 changes: 106 additions & 0 deletions MapStation.Editor/Assets/Maps/cspotcode.demo/newblend.blend.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading