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

[SM64] Settings Rework #280

Merged
merged 121 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
1ccf49f
General settings rework, tools rework, level layout operator, etc
Lilaa3 Dec 12, 2023
8793dff
Undid a sin
Lilaa3 Jan 6, 2024
e0713b0
fixed a thing
Lilaa3 Jan 6, 2024
f455153
oops
Lilaa3 Jan 6, 2024
70d1a1a
Another oopsie
Lilaa3 Jan 6, 2024
ee0d63c
black
Lilaa3 Jan 7, 2024
4e833f6
register and unregister settings at the end
Lilaa3 Jan 7, 2024
5a5e2d1
Merge commit '70310474e4627ae3f0a3a43a81aced4aa1200cf3^' into setting…
Lilaa3 Jan 7, 2024
dd77415
Merge commit '70310474e4627ae3f0a3a43a81aced4aa1200cf3' into settings…
Lilaa3 Jan 7, 2024
033c992
Merge remote-tracking branch 'upstream/main' into settings_changes
Lilaa3 Jan 7, 2024
36d13e0
the black reformater errors are hard to read
Lilaa3 Jan 7, 2024
ee9cb1b
is it correct now?
Lilaa3 Jan 7, 2024
da2e667
suggested changes and seperate import panel bool
Lilaa3 Jan 7, 2024
d09cf59
no more f strings....
Lilaa3 Jan 8, 2024
7eb9d6d
remove dumb import
Lilaa3 Jan 8, 2024
c8a750c
me when im in a making bad comments competition and my opponent is my…
Lilaa3 Jan 8, 2024
e8f3445
false
Lilaa3 Jan 8, 2024
d4e77af
unnecessary traces are not a good thing
Lilaa3 Jan 8, 2024
ce265d6
removed the export part of goals (all of them for consistency)
Lilaa3 Jan 8, 2024
a65c5bc
black formatting my nemesis
Lilaa3 Jan 8, 2024
b4ce8c6
AAAAAAAAAAAAAA
Lilaa3 Jan 8, 2024
135bc06
updated read me
Lilaa3 Jan 8, 2024
2266656
suggested
Lilaa3 Jan 8, 2024
5489fd7
force extended ram toggle (to free the 4 mb people of this bull)
Lilaa3 Jan 8, 2024
785820c
Matstack complient export toggle
Lilaa3 Jan 8, 2024
d1b28f3
ok ok fine i will turn on format on save
Lilaa3 Jan 8, 2024
d3c754e
new lines :))))))))))))))))))
Lilaa3 Jan 8, 2024
3b4dbf3
small spelling mistake
Lilaa3 Jan 8, 2024
7b619ec
lighting engine presets
Lilaa3 Jan 8, 2024
7214167
Moved tools and settings into their own folders
Lilaa3 Jan 22, 2024
dcd1c84
remove more imports
Lilaa3 Jan 22, 2024
5849c00
forgot to move this
Lilaa3 Apr 6, 2024
e2d882b
format
Lilaa3 Apr 6, 2024
25f83fa
Merge branch 'main' into move_for_settings_rework
Lilaa3 Apr 6, 2024
50f4630
small mistakes
Lilaa3 Apr 7, 2024
0190158
General settings rework, tools rework, level layout operator, etc
Lilaa3 Dec 12, 2023
b46507a
Undid a sin
Lilaa3 Jan 6, 2024
2d5052e
fixed a thing
Lilaa3 Jan 6, 2024
2c4eb0e
oops
Lilaa3 Jan 6, 2024
5b2aeb7
Another oopsie
Lilaa3 Jan 6, 2024
4b43898
register and unregister settings at the end
Lilaa3 Jan 7, 2024
e4484e0
is it correct now?
Lilaa3 Jan 7, 2024
9b26660
suggested changes and seperate import panel bool
Lilaa3 Jan 7, 2024
6369175
no more f strings....
Lilaa3 Jan 8, 2024
5c1d767
remove dumb import
Lilaa3 Jan 8, 2024
cce6823
me when im in a making bad comments competition and my opponent is my…
Lilaa3 Jan 8, 2024
c6d7a85
false
Lilaa3 Jan 8, 2024
cbf751d
unnecessary traces are not a good thing
Lilaa3 Jan 8, 2024
372c876
removed the export part of goals (all of them for consistency)
Lilaa3 Jan 8, 2024
5a59cb3
black formatting my nemesis
Lilaa3 Jan 8, 2024
1b63d24
AAAAAAAAAAAAAA
Lilaa3 Jan 8, 2024
321dbc9
updated read me
Lilaa3 Jan 8, 2024
bc5e9f9
suggested
Lilaa3 Jan 8, 2024
bc5263a
force extended ram toggle (to free the 4 mb people of this bull)
Lilaa3 Jan 8, 2024
c159e64
Matstack complient export toggle
Lilaa3 Jan 8, 2024
5b6a243
ok ok fine i will turn on format on save
Lilaa3 Jan 8, 2024
d443b41
new lines :))))))))))))))))))
Lilaa3 Jan 8, 2024
39ec2fb
small spelling mistake
Lilaa3 Jan 8, 2024
eb6d841
lighting engine presets
Lilaa3 Jan 8, 2024
64c132d
small mistakes
Lilaa3 Apr 7, 2024
a902183
finish rebase
Lilaa3 May 10, 2024
3e8bd21
fix conflicts?
Lilaa3 May 10, 2024
6800bfc
Merge branch 'main' into settings_changes
Lilaa3 May 10, 2024
5cf0f92
format
Lilaa3 May 10, 2024
9482d96
Undo new presets to reduce pr size
Lilaa3 May 10, 2024
9816ff2
clean changes
Lilaa3 May 10, 2024
67c7037
[SM64] - Settings Rework
Lilaa3 May 10, 2024
33402a1
Merge branch 'settings_changes' of https://github.com/Lilaa3/fast64 i…
Lilaa3 May 10, 2024
b1177e8
Add OperatorBase
Lilaa3 May 12, 2024
5191308
Some more clean up
Lilaa3 May 12, 2024
f0ab73e
More clean up
Lilaa3 May 12, 2024
737b21c
More UI improvements being worked on
Lilaa3 May 12, 2024
14a8efb
draw_props in operator base
Lilaa3 May 12, 2024
97eedc9
Use split, expect 0x for hex values
Lilaa3 May 12, 2024
dddf2ec
Less reduncancy
Lilaa3 May 12, 2024
16fc730
New warning function
Lilaa3 May 12, 2024
bf95a6e
ui warnings to not rely on exceptions in the middle of ui code
Lilaa3 May 12, 2024
386348a
More
Lilaa3 May 12, 2024
89d57db
Use @property
Lilaa3 May 12, 2024
c905dd7
Memory icon
Lilaa3 May 12, 2024
5b13d43
Move into sm64_utility
Lilaa3 May 13, 2024
600f57c
Comma
Lilaa3 May 13, 2024
fdda9ac
make this look cleaner
Lilaa3 May 17, 2024
249fa23
Seperate draw_props from just the operator draw logic
Lilaa3 May 17, 2024
c28980d
revert the seperation as its not really necessary
Lilaa3 May 17, 2024
f37be54
string_int_prop
Lilaa3 May 21, 2024
142e7ae
check existing context mode
Lilaa3 May 21, 2024
cb69c13
remove old repo properties dict
Lilaa3 May 21, 2024
bbeffea
Some more patterns ive been following
Lilaa3 May 21, 2024
34832af
icons and stuff
Lilaa3 May 21, 2024
dc1ec58
Just general stuff, im out of names
Lilaa3 May 21, 2024
5d924f9
show rdp defaults in the repo settings tab
Lilaa3 May 21, 2024
3d03100
Remove boxing
Lilaa3 May 21, 2024
9c995f3
check if auto pick is on
Lilaa3 May 21, 2024
1badb41
black
Lilaa3 May 22, 2024
82aefb1
custom int_from_str
Lilaa3 May 24, 2024
ae81d6f
Address converter into its own property class
Lilaa3 May 24, 2024
229e17e
split, improve string int prop
Lilaa3 May 24, 2024
a7b844e
put into col
Lilaa3 May 24, 2024
f203cda
Add support for objects to use SM64_Panel
Lilaa3 May 25, 2024
d03a0e1
Fix bug, make goal behavior more explicit
Lilaa3 May 25, 2024
ec2085a
Merge branch 'main' into settings_changes
Lilaa3 May 25, 2024
94f1b9f
Remove extra new line
Lilaa3 May 25, 2024
1a3cda9
Improve path checks, improve expanded error
Lilaa3 May 25, 2024
9447f8d
add back useless comment for this pr, use context to make line shorter
Lilaa3 May 25, 2024
a58bf49
fixed an issue i caused when rebasing
Lilaa3 May 25, 2024
d66c500
?
Lilaa3 May 25, 2024
60c41b1
And don´t forget to black format
Lilaa3 May 25, 2024
88725bb
no longer silently fail
Lilaa3 May 25, 2024
a63e8a6
Let me inspect my todo first before trying to solve so dependicie stuff
Lilaa3 May 25, 2024
1e864da
Implemented suggestions except for OperatorBase which has a new method
Lilaa3 May 28, 2024
627ca0a
upgrade to version 1
Lilaa3 Jun 17, 2024
28a2b7d
Merge branch 'main' into settings_changes
Lilaa3 Jun 17, 2024
f3c62f3
ported over rdp settings to json from glTF2
Lilaa3 Jun 29, 2024
7d34882
Fix importing
Lilaa3 Jun 29, 2024
44dfbb6
use cameCase for repo settings
Lilaa3 Jun 29, 2024
0f2312b
static method
Lilaa3 Jun 30, 2024
66696ef
Also upgrade conversion proprety group
Lilaa3 Jun 30, 2024
8c3f0c7
Fix int_from_str prefix check
Lilaa3 Jun 30, 2024
2e2586c
Undo accidental rename
Lilaa3 Jun 30, 2024
943c4ef
Important fix
Lilaa3 Jul 2, 2024
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
179 changes: 74 additions & 105 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import bpy
from bpy.utils import register_class, unregister_class
from bpy.path import abspath

from . import addon_updater_ops
from .fast64_internal.operators import AddWaterBox
from .fast64_internal.panels import SM64_Panel
from .fast64_internal.utility import PluginError, raisePluginError, attemptModifierApply, prop_split, multilineLabel

from .fast64_internal.sm64 import SM64_Properties, sm64_register, sm64_unregister
from .fast64_internal.utility import filepath_ui_warnings, prop_split, multilineLabel

from .fast64_internal.repo_settings import (
SM64_LoadRepoSettings,
SM64_SaveRepoSettings,
load_repo_settings,
repo_settings_operators_register,
repo_settings_operators_unregister,
)

from .fast64_internal.sm64.settings.properties import SM64_Properties
from .fast64_internal.sm64 import sm64_register, sm64_unregister
from .fast64_internal.sm64.sm64_geolayout_bone import SM64_BoneProperties
from .fast64_internal.sm64.sm64_objects import SM64_ObjectProperties
from .fast64_internal.sm64.sm64_geolayout_utility import createBoneGroups
from .fast64_internal.sm64.sm64_geolayout_parser import generateMetarig

from .fast64_internal.oot import OOT_Properties, oot_register, oot_unregister
from .fast64_internal.oot.props_panel_main import OOT_ObjectProperties
Expand Down Expand Up @@ -54,97 +62,6 @@
)


class AddBoneGroups(bpy.types.Operator):
# set bl_ properties
bl_description = (
"Add bone groups respresenting other node types in " + "SM64 geolayouts (ex. Shadow, Switch, Function)."
)
bl_idname = "object.add_bone_groups"
bl_label = "Add Bone Groups"
bl_options = {"REGISTER", "UNDO", "PRESET"}

# Called on demand (i.e. button press, menu item)
# Can also be called from operator search menu (Spacebar)
def execute(self, context):
try:
if context.mode != "OBJECT" and context.mode != "POSE":
raise PluginError("Operator can only be used in object or pose mode.")
elif context.mode == "POSE":
bpy.ops.object.mode_set(mode="OBJECT")

if len(context.selected_objects) == 0:
raise PluginError("Armature not selected.")
elif type(context.selected_objects[0].data) is not bpy.types.Armature:
raise PluginError("Armature not selected.")

armatureObj = context.selected_objects[0]
createBoneGroups(armatureObj)
except Exception as e:
raisePluginError(self, e)
return {"CANCELLED"}

self.report({"INFO"}, "Created bone groups.")
return {"FINISHED"} # must return a set


class CreateMetarig(bpy.types.Operator):
# set bl_ properties
bl_description = (
"SM64 imported armatures are usually not good for "
+ "rigging. There are often intermediate bones between deform bones "
+ "and they don't usually point to their children. This operator "
+ "creates a metarig on armature layer 4 useful for IK."
)
bl_idname = "object.create_metarig"
bl_label = "Create Animatable Metarig"
bl_options = {"REGISTER", "UNDO", "PRESET"}

# Called on demand (i.e. button press, menu item)
# Can also be called from operator search menu (Spacebar)
def execute(self, context):
try:
if context.mode != "OBJECT":
bpy.ops.object.mode_set(mode="OBJECT")

if len(context.selected_objects) == 0:
raise PluginError("Armature not selected.")
elif type(context.selected_objects[0].data) is not bpy.types.Armature:
raise PluginError("Armature not selected.")

armatureObj = context.selected_objects[0]
generateMetarig(armatureObj)
except Exception as e:
raisePluginError(self, e)
return {"CANCELLED"}

self.report({"INFO"}, "Created metarig.")
return {"FINISHED"} # must return a set


class SM64_AddWaterBox(AddWaterBox):
bl_idname = "object.sm64_add_water_box"

scale: bpy.props.FloatProperty(default=10)
preset: bpy.props.StringProperty(default="Shaded Solid")
matName: bpy.props.StringProperty(default="sm64_water_mat")

def setEmptyType(self, emptyObj):
emptyObj.sm64_obj_type = "Water Box"


class SM64_ArmatureToolsPanel(SM64_Panel):
bl_idname = "SM64_PT_armature_tools"
bl_label = "SM64 Tools"

# called every frame
def draw(self, context):
col = self.layout.column()
col.operator(ArmatureApplyWithMeshOperator.bl_idname)
col.operator(AddBoneGroups.bl_idname)
col.operator(CreateMetarig.bl_idname)
col.operator(SM64_AddWaterBox.bl_idname)


class F3D_GlobalSettingsPanel(bpy.types.Panel):
bl_idname = "F3D_PT_global_settings"
bl_label = "F3D Global Settings"
Expand Down Expand Up @@ -201,14 +118,52 @@ class Fast64_GlobalSettingsPanel(bpy.types.Panel):
def poll(cls, context):
return True

def draw_repo_settings(self, layout, context):
col = layout.column()

scene = context.scene
fast64_settings = scene.fast64.settings

col.prop(
fast64_settings,
"repo_settings_tab",
text="Repo Settings",
icon="TRIA_DOWN" if fast64_settings.repo_settings_tab else "TRIA_RIGHT",
)
if not fast64_settings.repo_settings_tab:
return

col.box().label(text="World defaults will be saved and loaded.")

prop_split(col, fast64_settings, "repo_settings_path", "Repo Settings Path")

path = abspath(fast64_settings.repo_settings_path)
if filepath_ui_warnings(col, path):
load_op = col.operator(SM64_LoadRepoSettings.bl_idname)
load_op.path = fast64_settings.repo_settings_path

save_op = col.operator(SM64_SaveRepoSettings.bl_idname)
save_op.path = fast64_settings.repo_settings_path

prop_split(col, scene, "f3d_type", "F3D Microcode")
col.prop(scene, "saveTextures")
col.prop(fast64_settings, "auto_repo_load_settings")

# called every frame
def draw(self, context):
col = self.layout.column()
col.scale_y = 1.1 # extra padding
prop_split(col, context.scene, "gameEditorMode", "Game")
col.prop(context.scene, "exportHiddenGeometry")
col.prop(context.scene, "fullTraceback")
prop_split(col, context.scene.fast64.settings, "anim_range_choice", "Anim Range")

scene = context.scene
fast64_settings = scene.fast64.settings

prop_split(col, scene, "gameEditorMode", "Game")
col.prop(scene, "exportHiddenGeometry")
col.prop(scene, "fullTraceback")

prop_split(col, fast64_settings, "anim_range_choice", "Anim Range")

self.draw_repo_settings(col.box(), context)


class Fast64_GlobalToolsPanel(bpy.types.Panel):
Expand All @@ -231,6 +186,10 @@ def draw(self, context):
addon_updater_ops.update_notice_box_ui(self, context)


def repo_path_update(self, context):
load_repo_settings(context.scene, abspath(self.repo_settings_path), True)


class Fast64Settings_Properties(bpy.types.PropertyGroup):
"""Settings affecting exports for all games found in scene.fast64.settings"""

Expand Down Expand Up @@ -264,6 +223,16 @@ class Fast64Settings_Properties(bpy.types.PropertyGroup):
default="intersect_action_and_scene",
)

repo_settings_tab: bpy.props.BoolProperty(default=True)
repo_settings_path: bpy.props.StringProperty(
name="Repo Settings Path", subtype="FILE_PATH", update=repo_path_update
)
auto_repo_load_settings: bpy.props.BoolProperty(
name="Auto Load Repo's Settings",
description="When enabled, this will make fast64 automatically load repo settings if they are found after picking a decomp path",
default=True,
)


class Fast64_Properties(bpy.types.PropertyGroup):
"""
Expand Down Expand Up @@ -384,13 +353,9 @@ def draw(self, context):
Fast64_Properties,
Fast64_BoneProperties,
Fast64_ObjectProperties,
AddBoneGroups,
CreateMetarig,
SM64_AddWaterBox,
# Fast64_GlobalObjectPanel,
F3D_GlobalSettingsPanel,
Fast64_GlobalSettingsPanel,
SM64_ArmatureToolsPanel,
Fast64_GlobalToolsPanel,
UpgradeF3DMaterialsDialog,
)
Expand Down Expand Up @@ -452,6 +417,8 @@ def register():
sm64_register(True)
oot_register(True)

repo_settings_operators_register()

for cls in classes:
register_class(cls)

Expand Down Expand Up @@ -515,6 +482,8 @@ def unregister():
del bpy.types.Bone.fast64
del bpy.types.Object.fast64

repo_settings_operators_unregister()

for cls in classes:
unregister_class(cls)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
Yanis42 marked this conversation as resolved.
Show resolved Hide resolved
"last_check": "",
"backup_date": "",
"update_ready": false,
"ignore": false,
"just_restored": false,
"just_updated": false,
"version_text": {}
}
30 changes: 15 additions & 15 deletions fast64_internal/f3d/f3d_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -2099,10 +2099,6 @@ def load_handler(dummy):

bpy.app.handlers.load_post.append(load_handler)

# bpy.context.mode returns the keys here, while the values are required by bpy.ops.object.mode_set
BLENDER_MODE_TO_MODE_SET = {"PAINT_VERTEX": "VERTEX_PAINT", "EDIT_MESH": "EDIT"}
get_mode_set_from_context_mode = lambda mode: BLENDER_MODE_TO_MODE_SET.get(mode, "OBJECT")
Dragorn421 marked this conversation as resolved.
Show resolved Hide resolved

SCENE_PROPERTIES_VERSION = 1


Expand Down Expand Up @@ -2288,6 +2284,20 @@ def addColorAttributesToModel(obj: Object):
bpy.ops.object.mode_set(mode=get_mode_set_from_context_mode(prevMode))


def add_f3d_mat_to_obj(obj: bpy.types.Object, material, index=None):
# add material to object
if obj is not None:
addColorAttributesToModel(obj)
if index is None:
obj.data.materials.append(material)
if bpy.context.object is not None:
bpy.context.object.active_material_index = len(obj.material_slots) - 1
else:
obj.material_slots[index].material = material
if bpy.context.object is not None:
bpy.context.object.active_material_index = index


def createF3DMat(obj: Object | None, preset="Shaded Solid", index=None):
# link all node_groups + material from addon's data .blend
link_f3d_material_library()
Expand All @@ -2302,17 +2312,7 @@ def createF3DMat(obj: Object | None, preset="Shaded Solid", index=None):

createScenePropertiesForMaterial(material)

# add material to object
if obj is not None:
addColorAttributesToModel(obj)
if index is None:
obj.data.materials.append(material)
if bpy.context.object is not None:
bpy.context.object.active_material_index = len(obj.material_slots) - 1
else:
obj.material_slots[index].material = material
if bpy.context.object is not None:
bpy.context.object.active_material_index = index
add_f3d_mat_to_obj(obj, material, index)

material.is_f3d = True
material.mat_ver = 5
Expand Down
6 changes: 3 additions & 3 deletions fast64_internal/f3d/f3d_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ def getPosition(vertexBuffer, index):
yBytes = vertexBuffer[yStart : yStart + 2]
zBytes = vertexBuffer[zStart : zStart + 2]

x = int.from_bytes(xBytes, "big", signed=True) / bpy.context.scene.blenderToSM64Scale
y = int.from_bytes(yBytes, "big", signed=True) / bpy.context.scene.blenderToSM64Scale
z = int.from_bytes(zBytes, "big", signed=True) / bpy.context.scene.blenderToSM64Scale
x = int.from_bytes(xBytes, "big", signed=True) / bpy.context.scene.fast64.sm64.blender_to_sm64_scale
y = int.from_bytes(yBytes, "big", signed=True) / bpy.context.scene.fast64.sm64.blender_to_sm64_scale
z = int.from_bytes(zBytes, "big", signed=True) / bpy.context.scene.fast64.sm64.blender_to_sm64_scale

return (x, y, z)

Expand Down
24 changes: 8 additions & 16 deletions fast64_internal/panels.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@

import bpy

sm64GoalImport = 'Import' # Not in enum, separate UI option
sm64GoalTypeEnum = [
('All', 'All', 'All'),
('Export Object/Actor/Anim', 'Export Object/Actor/Anim', 'Export Object/Actor/Anim'),
('Export Level', 'Export Level', 'Export Level'),
('Export Displaylist', 'Export Displaylist', 'Export Displaylist'),
('Export UI Image', 'Export UI Image', 'Export UI Image'),
]

class SM64_Panel(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'SM64'
bl_options = {'DEFAULT_CLOSED'}
# goal refers to the selected sm64GoalTypeEnum, a different selection than this goal will filter this panel out
# goal refers to the selected enum_sm64_goal_type, a different selection than this goal will filter this panel out
# "Import" is not in the enum, as it is a separate UI option
goal = None
Dragorn421 marked this conversation as resolved.
Show resolved Hide resolved
# if this is True, the panel is hidden whenever the scene's exportType is not 'C'
# if this is True, the panel is hidden whenever the scene's export_type is not 'C'
decomp_only = False

@classmethod
def poll(cls, context):
sm64Props = bpy.context.scene.fast64.sm64
sm64_props = context.scene.fast64.sm64
if context.scene.gameEditorMode != 'SM64':
return False
elif not cls.goal:
return True # Panel should always be shown
elif cls.goal == sm64GoalImport:
elif cls.goal == "Import":
# Only show if importing is enabled
return sm64Props.showImportingMenus
elif cls.decomp_only and sm64Props.exportType != 'C':
return sm64_props.show_importing_menus
elif cls.decomp_only and sm64_props.export_type != 'C':
return False

sceneGoal = sm64Props.goal
sceneGoal = sm64_props.goal
return sceneGoal == 'All' or sceneGoal == cls.goal

class OOT_Panel(bpy.types.Panel):
Expand Down
Loading