Skip to content

Commit

Permalink
feat: Changed negative number frame meanings
Browse files Browse the repository at this point in the history
BREAKING CHANGE: For state frame ranges, -1 now means the last frame, -2 means the onchange frame.
  • Loading branch information
christides11 committed Jul 21, 2022
1 parent c942453 commit 3eaf910
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 36 deletions.
24 changes: 13 additions & 11 deletions Assets/HnSF/Editor/StateEditor/StateTimelineEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,15 @@ public virtual void DataBarsDrawParentAndChildren(List<VisualElement> dbs, int d
{
for (int j = 0; j < stateTimeline.data[index].FrameRanges.Length; j++)
{
int framebarStart = stateTimeline.data[index].FrameRanges[j].x < 0
? 1
: (int)stateTimeline.data[index].FrameRanges[j].x;
int framebarWidth = stateTimeline.data[index].FrameRanges[j].x < 0
? this.stateTimeline.totalFrames-1
: (int)stateTimeline.data[index].FrameRanges[j].y -
(int)stateTimeline.data[index].FrameRanges[j].x;
int frx = ConvertFrameNumber((int)stateTimeline.data[index].FrameRanges[j].x);
int fry = ConvertFrameNumber((int)stateTimeline.data[index].FrameRanges[j].y);
int framebarStart = frx;
int framebarWidth = fry - frx;
mainFrameBarLabel.CloneTree(dbs[incr]);
var thisMainFrameBarLabel = dbs[incr].Query(name: mainFrameBarLabel.name).Build().Last();
thisMainFrameBarLabel.style.left = GetFrameWidth() * framebarStart;
thisMainFrameBarLabel.style.width = new StyleLength(GetFrameWidth() *
(framebarWidth + 1));
thisMainFrameBarLabel.Q<Label>().text = (stateTimeline.data[index].FrameRanges[j].y + 1 -
stateTimeline.data[index].FrameRanges[j].x).ToString();
thisMainFrameBarLabel.style.width = new StyleLength(GetFrameWidth() * (framebarWidth + 1));
thisMainFrameBarLabel.Q<Label>().text = (fry + 1 - frx).ToString();
}
}

Expand All @@ -394,6 +389,13 @@ public virtual void DataBarsDrawParentAndChildren(List<VisualElement> dbs, int d
}
}

public virtual int ConvertFrameNumber(int number)
{
if (number == -1) return stateTimeline.totalFrames;
if (number == -2) return stateTimeline.totalFrames+1;
return number;
}

public virtual float GetFrameWidth()
{
return 20.0f * zoomMultiplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MonoBehaviour:
stateName:
useBaseState: 1
baseState: {fileID: 11400000, guid: 65f5e055426eb834a95aa16b8f725063, type: 2}
totalFrames: 10
totalFrames: 24
autoIncrement: 1
autoLoop: 1
autoLoopFrame: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ MonoBehaviour:
data:
name:
id: 10
frameRanges: []
frameRanges:
- {x: -1, y: -2}
condition:
rid: -2
value: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ MonoBehaviour:
data:
- rid: 2193520583769325568
- rid: 2193520583769325569
- rid: 2193520692439547904
references:
version: 2
RefIds:
Expand All @@ -33,7 +34,7 @@ MonoBehaviour:
name: Set Fall Speed
id: 0
frameRanges:
- {x: -1, y: -1}
- {x: 1, y: -1}
condition:
rid: -2
value: 10
Expand All @@ -45,7 +46,7 @@ MonoBehaviour:
name: Apply Grravity
id: 1
frameRanges:
- {x: -1, y: -1}
- {x: 1, y: -1}
condition:
rid: -2
useMaxFallSpeedStat: 1
Expand All @@ -54,3 +55,17 @@ MonoBehaviour:
gravity: 0
parent: -1
children:
- rid: 2193520692439547904
type: {class: VarApplyTraction, ns: HnSF.Sample.TDAction.State, asm: HnSF.TDAction}
data:
name:
id: 2
frameRanges:
- {x: -2, y: -2}
condition:
rid: -2
useTractionStat: 0
aerialTraction: 0
traction: 0
parent: -1
children:
4 changes: 2 additions & 2 deletions HnSF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@
<Compile Include="Assets\HnSF\Combat\Boxes\Hurtbox\HurtboxState.cs" />
<Compile Include="Assets\HnSF\State\StateConditionMapperBase.cs" />
<Compile Include="Assets\HnSF\Fighter\IFighterCombatManager.cs" />
<Compile Include="Assets\HnSF\Helpers\UndoUtility.cs" />
<Compile Include="Assets\HnSF\Combat\Boxes\Hitbox\HitboxGroup.cs" />
<Compile Include="Assets\HnSF\Combat\Info\HurtInfoBase.cs" />
<Compile Include="Assets\HnSF\Fighter\IFighterStateManager.cs" />
<Compile Include="Assets\HnSF\Combat\Boxes\BoxDefinitionBase.cs" />
<Compile Include="Assets\HnSF\Combat\ForceType.cs" />
<Compile Include="Assets\HnSF\Combat\ITeamable.cs" />
<Compile Include="Assets\HnSF\Helpers\UnityObjectUtility.cs" />
<Compile Include="Assets\HnSF\Combat\Boxes\Hitbox\HitboxForceType.cs" />
<Compile Include="Assets\HnSF\Combat\Info\HurtInfo3D.cs" />
<Compile Include="Assets\HnSF\Fighter\IFighterPhysicsManager.cs" />
Expand All @@ -83,8 +85,6 @@
<Compile Include="Assets\HnSF\State\FighterStateReferenceBase.cs" />
<Compile Include="Assets\HnSF\Combat\MovesetDefinition.cs" />
<Compile Include="Assets\HnSF\Input\InputDefinition.cs" />
<Compile Include="Assets\HnSF\Helpers\UnityObjectUtility.cs" />
<Compile Include="Assets\HnSF\Helpers\UndoUtility.cs" />
<None Include="Assets\HnSF\HnSF.asmdef" />
<None Include="Assets\HnSF\package.json" />
<Reference Include="UnityEngine">
Expand Down
38 changes: 19 additions & 19 deletions UserSettings/Layouts/default-2021.dwlt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
width: 2560
height: 1349
m_ShowMode: 4
m_Title: Project
m_Title: Hierarchy
m_RootView: {fileID: 6}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
Expand Down Expand Up @@ -48,7 +48,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 133
controlID: 136
--- !u!114 &3
MonoBehaviour:
m_ObjectHideFlags: 52
Expand Down Expand Up @@ -224,7 +224,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 16192, y: 16192}
vertical: 1
controlID: 26
controlID: 23
--- !u!114 &10
MonoBehaviour:
m_ObjectHideFlags: 52
Expand All @@ -249,7 +249,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 8096}
vertical: 0
controlID: 27
controlID: 24
--- !u!114 &11
MonoBehaviour:
m_ObjectHideFlags: 52
Expand All @@ -269,8 +269,8 @@ MonoBehaviour:
y: 0
width: 1546
height: 792
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 18}
m_Panes:
- {fileID: 17}
Expand Down Expand Up @@ -385,22 +385,22 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/HnSF/Editor/StateEditor
- Assets
m_Globs: []
m_OriginalText:
m_ViewMode: 1
m_StartGridSize: 16
m_LastFolders:
- Assets/HnSF/Editor/StateEditor
- Assets
m_LastFoldersGridSize: 16
m_LastProjectPath: C:\Projects\Unity\hack-and-slash-framework
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 130}
m_SelectedIDs: 46620000
m_LastClickedID: 25158
m_ExpandedIDs: 0000000020620000226200002462000026620000286200002a6200002c6200002e620000306200003262000000ca9a3b
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 24620000
m_LastClickedID: 25124
m_ExpandedIDs: 0000000024620000266200002a6200002c6200002e62000032620000346200003662000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand Down Expand Up @@ -428,7 +428,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 0000000020620000226200002462000026620000286200002a6200002c6200002e6200003062000032620000
m_ExpandedIDs: 000000002462000026620000286200002a6200002c6200002e62000030620000326200003462000036620000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand All @@ -455,22 +455,22 @@ MonoBehaviour:
m_ListAreaState:
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 1
m_HadKeyboardFocusLastEvent: 0
m_ExpandedInstanceIDs: c6230000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: UndoUtility
m_OriginalName: UndoUtility
m_Name:
m_OriginalName:
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 26152
m_UserData: 0
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 0
m_OriginalEventType: 11
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 5}
m_CreateAssetUtility:
Expand Down Expand Up @@ -998,7 +998,7 @@ MonoBehaviour:
width: 4446.72
height: 2160
m_MinimalGUI: 1
m_defaultScale: 0.3472222
m_defaultScale: 0.35694444
m_LastWindowPixelSize: {x: 1544, y: 771}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
Expand Down

0 comments on commit 3eaf910

Please sign in to comment.