From a52d8645e693030a4180f2ce42b8a991cdb48dc8 Mon Sep 17 00:00:00 2001 From: PS Date: Sat, 14 Nov 2020 11:43:20 -0800 Subject: [PATCH] refactored clips -> patterns --- .../foldhaus_panel_animation_timeline.h | 28 +++++++++---------- src/app/engine/animation/foldhaus_animation.h | 2 +- .../foldhaus_animation_serializer.cpp | 6 ++-- src/app/foldhaus_app.cpp | 2 +- src/app/foldhaus_app.h | 4 +-- src/app/platform_win32/win32_foldhaus.cpp | 2 -- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/app/editor/panels/foldhaus_panel_animation_timeline.h b/src/app/editor/panels/foldhaus_panel_animation_timeline.h index 6210cfa..9bedf30 100644 --- a/src/app/editor/panels/foldhaus_panel_animation_timeline.h +++ b/src/app/editor/panels/foldhaus_panel_animation_timeline.h @@ -109,7 +109,7 @@ StartDragTimeMarker(rect2 TimelineBounds, frame_range VisibleFrames, app_state* #define CLICK_ANIMATION_BLOCK_EDGE_MAX_SCREEN_DISTANCE 10 -OPERATION_STATE_DEF(drag_animation_clip_state) +OPERATION_STATE_DEF(drag_animation_block_state) { rect2 TimelineBounds; handle BlockHandle; @@ -129,9 +129,9 @@ AttemptToSnapPosition(u32 SnappingFrame, u32 SnapToFrame) return Result; } -OPERATION_RENDER_PROC(UpdateDragAnimationClip) +OPERATION_RENDER_PROC(UpdateDragAnimationBlock) { - drag_animation_clip_state* OpState = (drag_animation_clip_state*)Operation.OpStateMemory; + drag_animation_block_state* OpState = (drag_animation_block_state*)Operation.OpStateMemory; animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); @@ -228,7 +228,7 @@ OPERATION_RENDER_PROC(UpdateDragAnimationClip) AnimationBlock->Range.Max = (u32)Clamp(PlayableStartFrame, (s32)AnimationBlock->Range.Max, PlayableEndFrame); } -input_command DragAnimationClipCommands [] = { +input_command DragAnimationBlockCommands [] = { { KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, 0 }, }; @@ -238,11 +238,11 @@ SelectAndBeginDragAnimationBlock(animation_timeline_state* TimelineState, handle TimelineState->SelectedBlockHandle = BlockHandle; animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); - operation_mode* DragAnimationClipMode = ActivateOperationModeWithCommands(&State->Modes, DragAnimationClipCommands, UpdateDragAnimationClip); + operation_mode* DragAnimationBlockMode = ActivateOperationModeWithCommands(&State->Modes, DragAnimationBlockCommands, UpdateDragAnimationBlock); - drag_animation_clip_state* OpState = CreateOperationState(DragAnimationClipMode, - &State->Modes, - drag_animation_clip_state); + drag_animation_block_state* OpState = CreateOperationState(DragAnimationBlockMode, + &State->Modes, + drag_animation_block_state); OpState->TimelineBounds = TimelineBounds; OpState->BlockHandle = BlockHandle; OpState->VisibleRange = VisibleRange; @@ -580,7 +580,7 @@ PANEL_MODAL_OVERRIDE_CALLBACK(LoadAnimationFileCallback) { gs_file AnimFile = ReadEntireFile(Context.ThreadContext.FileHandler, FileInfo.Path); gs_string AnimFileString = MakeString((char*)AnimFile.Data.Memory, AnimFile.Data.Size); - animation NewAnim = AnimParser_Parse(AnimFileString, State->AnimationSystem.Storage, GlobalAnimationClipsCount, GlobalAnimationClips); + animation NewAnim = AnimParser_Parse(AnimFileString, State->AnimationSystem.Storage, GlobalAnimationPatternsCount, GlobalAnimationPatterns); u32 NewAnimIndex = AnimationArray_Push(&State->AnimationSystem.Animations, NewAnim); State->AnimationSystem.ActiveAnimationIndex = NewAnimIndex; @@ -588,15 +588,15 @@ PANEL_MODAL_OVERRIDE_CALLBACK(LoadAnimationFileCallback) } internal void -DrawAnimationClipsList(rect2 PanelBounds, ui_interface* Interface, u32 SelectedAnimationLayerHandle, animation_system* AnimationSystem) +DrawAnimationPatternList(rect2 PanelBounds, ui_interface* Interface, u32 SelectedAnimationLayerHandle, animation_system* AnimationSystem) { ui_layout Layout = ui_CreateLayout(Interface, PanelBounds); ui_PushLayout(Interface, Layout); - for (s32 i = 0; i < GlobalAnimationClipsCount; i++) + for (s32 i = 0; i < GlobalAnimationPatternsCount; i++) { - animation_clip Clip = GlobalAnimationClips[i]; - gs_string ClipName = MakeString(Clip.Name, Clip.NameLength); - if (ui_LayoutListEntry(Interface, &Layout, ClipName, i)) + animation_pattern Pattern = GlobalAnimationPatterns[i]; + gs_string PatternName = MakeString(Pattern.Name, Pattern.NameLength); + if (ui_LayoutListEntry(Interface, &Layout, PatternName, i)) { AddAnimationBlockAtCurrentTime(i + 1, SelectedAnimationLayerHandle, AnimationSystem); } diff --git a/src/app/engine/animation/foldhaus_animation.h b/src/app/engine/animation/foldhaus_animation.h index 81e2080..bbdb1a5 100644 --- a/src/app/engine/animation/foldhaus_animation.h +++ b/src/app/engine/animation/foldhaus_animation.h @@ -103,7 +103,7 @@ struct animation_system }; // TODO(pjs): Better name - something like animation_prototype -struct animation_clip +struct animation_pattern { char* Name; s32 NameLength; diff --git a/src/app/engine/animation/foldhaus_animation_serializer.cpp b/src/app/engine/animation/foldhaus_animation_serializer.cpp index ac9954e..8607b0f 100644 --- a/src/app/engine/animation/foldhaus_animation_serializer.cpp +++ b/src/app/engine/animation/foldhaus_animation_serializer.cpp @@ -6,7 +6,7 @@ #ifndef FOLDHAUS_ANIMATION_SERIALIZER_CPP internal gs_string -AnimSerializer_Serialize(animation Anim, animation_clip* GlobalClips, gs_memory_arena* Arena) +AnimSerializer_Serialize(animation Anim, animation_pattern* GlobalClips, gs_memory_arena* Arena) { serializer Serializer = {0}; Serializer.String = PushString(Arena, 4096); @@ -48,7 +48,7 @@ AnimSerializer_Serialize(animation Anim, animation_clip* GlobalClips, gs_memory_ // TODO(pjs): Systematize the AnimationProcHandle // :AnimProcHandle u32 AnimationProcIndex = AnimationBlockAt.AnimationProcHandle - 1; - animation_clip Animation = GlobalClips[AnimationProcIndex]; + animation_pattern Animation = GlobalClips[AnimationProcIndex]; Serializer_OpenStruct(&Serializer, AnimField_Block); { @@ -70,7 +70,7 @@ AnimSerializer_Serialize(animation Anim, animation_clip* GlobalClips, gs_memory_ } internal animation -AnimParser_Parse(gs_string File, gs_memory_arena* Arena, u32 AnimClipsCount, animation_clip* AnimClips) +AnimParser_Parse(gs_string File, gs_memory_arena* Arena, u32 AnimClipsCount, animation_pattern* AnimClips) { animation Result = {0}; diff --git a/src/app/foldhaus_app.cpp b/src/app/foldhaus_app.cpp index f3038f6..8eee729 100644 --- a/src/app/foldhaus_app.cpp +++ b/src/app/foldhaus_app.cpp @@ -211,7 +211,7 @@ UPDATE_AND_RENDER(UpdateAndRender) // :AnimProcHandle u32 AnimationProcIndex = Block.AnimationProcHandle - 1; - animation_proc* AnimationProc = GlobalAnimationClips[AnimationProcIndex].Proc; + animation_proc* AnimationProc = GlobalAnimationPatterns[AnimationProcIndex].Proc; AnimationProc(&LayerLEDBuffers[Layer], *Assembly, SecondsIntoBlock, State->Transient); } diff --git a/src/app/foldhaus_app.h b/src/app/foldhaus_app.h index 66755c6..83e1de1 100644 --- a/src/app/foldhaus_app.h +++ b/src/app/foldhaus_app.h @@ -209,8 +209,8 @@ EndCurrentOperationMode(app_state* State) DeactivateCurrentOperationMode(&State->Modes); } -s32 GlobalAnimationClipsCount = 3; -animation_clip GlobalAnimationClips[] = { +s32 GlobalAnimationPatternsCount = 3; +animation_pattern GlobalAnimationPatterns[] = { { "Test Pattern One", 16, TestPatternOne }, { "Test Pattern Two", 16, TestPatternTwo }, { "Test Pattern Three", 18, TestPatternThree }, diff --git a/src/app/platform_win32/win32_foldhaus.cpp b/src/app/platform_win32/win32_foldhaus.cpp index 7f9b24a..dda8da8 100644 --- a/src/app/platform_win32/win32_foldhaus.cpp +++ b/src/app/platform_win32/win32_foldhaus.cpp @@ -479,8 +479,6 @@ WinMain ( #endif - - MainWindow = Win32CreateWindow (HInstance, "Foldhaus", 1440, 768, HandleWindowEvents); Win32UpdateWindowDimension(&MainWindow);