Animation loading
This commit is contained in:
parent
5c183d9c5f
commit
85f7aab621
|
@ -494,7 +494,7 @@ DrawAnimationTimeline (animation_system* AnimationSystem, animation_timeline_sta
|
|||
handle Result = SelectedBlockHandle;
|
||||
|
||||
// TODO(pjs): Animation Selection
|
||||
animation CurrAnimation = AnimationSystem->Animations.Values[0];
|
||||
animation CurrAnimation = *AnimationSystem_GetActiveAnimation(AnimationSystem);
|
||||
|
||||
rect2 LayerMenuBounds, TimelineBounds;
|
||||
RectVSplitAtDistanceFromLeft(PanelBounds, 256, &LayerMenuBounds, &TimelineBounds);
|
||||
|
@ -579,6 +579,13 @@ PANEL_MODAL_OVERRIDE_CALLBACK(LoadAnimationFileCallback)
|
|||
Assert(ReturningFrom->TypeIndex == PanelType_FileView);
|
||||
file_view_state* FileViewState = Panel_GetStateStruct(ReturningFrom, file_view_state);
|
||||
gs_file_info FileInfo = FileViewState->SelectedFile;
|
||||
|
||||
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);
|
||||
|
||||
u32 NewAnimIndex = AnimationArray_Push(&State->AnimationSystem.Animations, NewAnim);
|
||||
State->AnimationSystem.ActiveAnimationIndex = NewAnimIndex;
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -637,9 +644,6 @@ AnimationTimeline_Render(panel* Panel, rect2 PanelBounds, render_command_buffer*
|
|||
{
|
||||
panel_entry* FileBrowser = PanelSystem_PushPanel(&State->PanelSystem, PanelType_FileView, State, Context);
|
||||
Panel_PushModalOverride(Panel, FileBrowser, LoadAnimationFileCallback);
|
||||
// TODO(pjs): I think we want to be able to specify a return command that gets called when the
|
||||
// pushed panel state returns to this one
|
||||
// something like: AnimPanel_HandleLoadedAnimationFile
|
||||
}
|
||||
}
|
||||
ui_EndRow(&TitleBarLayout);
|
||||
|
|
|
@ -14,7 +14,19 @@ struct file_view_state
|
|||
gs_file_info SelectedFile;
|
||||
};
|
||||
|
||||
input_command* FileView_Commands = 0;
|
||||
internal void
|
||||
FileView_Exit_(panel* FileViewPanel, app_state* State, context Context)
|
||||
{
|
||||
Assert(FileViewPanel->IsModalOverrideFor != 0);
|
||||
panel* ReturnTo = FileViewPanel->IsModalOverrideFor;
|
||||
if (ReturnTo->ModalOverrideCB)
|
||||
{
|
||||
ReturnTo->ModalOverrideCB(FileViewPanel, State, Context);
|
||||
}
|
||||
Panel_PopModalOverride(ReturnTo, &State->PanelSystem);
|
||||
}
|
||||
|
||||
global input_command* FileView_Commands = 0;
|
||||
s32 FileView_CommandsCount = 0;
|
||||
|
||||
internal void
|
||||
|
@ -78,6 +90,11 @@ FileView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBu
|
|||
file_view_state* FileViewState = Panel_GetStateStruct(Panel, file_view_state);
|
||||
ui_layout Layout = ui_CreateLayout(State->Interface, PanelBounds);
|
||||
|
||||
if (ui_LayoutButton(&State->Interface, &Layout, MakeString("Exit")))
|
||||
{
|
||||
FileView_Exit_(Panel, State, Context);
|
||||
}
|
||||
|
||||
// Header
|
||||
ui_LayoutDrawString(&State->Interface, &Layout, FileViewState->WorkingDirectory, v4{0, 1, 0, 1});
|
||||
|
||||
|
@ -99,14 +116,7 @@ FileView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBu
|
|||
else
|
||||
{
|
||||
FileViewState->SelectedFile = File;
|
||||
|
||||
Assert(Panel->IsModalOverrideFor != 0);
|
||||
panel* ReturnTo = Panel->IsModalOverrideFor;
|
||||
if (ReturnTo->ModalOverrideCB)
|
||||
{
|
||||
ReturnTo->ModalOverrideCB(Panel, State, Context);
|
||||
}
|
||||
Panel_PopModalOverride(ReturnTo, &State->PanelSystem);
|
||||
FileView_Exit_(Panel, State, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ struct animation_system
|
|||
// NOTE(Peter): The frame currently being displayed/processed. you
|
||||
// can see which frame you're on by looking at the time slider on the timeline
|
||||
// panel
|
||||
u32 ActiveAnimationIndex;
|
||||
s32 CurrentFrame;
|
||||
s32 LastUpdatedFrame;
|
||||
r32 SecondsPerFrame;
|
||||
|
@ -401,7 +402,7 @@ internal animation*
|
|||
AnimationSystem_GetActiveAnimation(animation_system* System)
|
||||
{
|
||||
// TODO(pjs): need a way to specify the active animation
|
||||
return System->Animations.Values + 0;
|
||||
return System->Animations.Values + System->ActiveAnimationIndex;
|
||||
}
|
||||
|
||||
internal animation_frame
|
||||
|
|
|
@ -70,7 +70,7 @@ AnimSerializer_Serialize(animation Anim, animation_clip* GlobalClips, gs_memory_
|
|||
}
|
||||
|
||||
internal animation
|
||||
AnimParser_Parse(gs_string File, animation_clip* GlobalClips, gs_memory_arena* Arena, u32 AnimClipsCount, animation_clip* AnimClips)
|
||||
AnimParser_Parse(gs_string File, gs_memory_arena* Arena, u32 AnimClipsCount, animation_clip* AnimClips)
|
||||
{
|
||||
animation Result = {0};
|
||||
|
||||
|
@ -88,14 +88,19 @@ AnimParser_Parse(gs_string File, animation_clip* GlobalClips, gs_memory_arena* A
|
|||
Result.Layers.CountMax = Parser_ReadU32Value(&Parser, AnimField_LayersCount);
|
||||
Result.Layers.Values = PushArray(Arena, anim_layer, Result.Layers.CountMax);
|
||||
|
||||
// TODO(pjs): We're not using this now because Blocks are built on gs_list or something,
|
||||
// but I want to replace that eventually, so this is here to preallocate the blocks we need
|
||||
u32 BlocksCount = Parser_ReadU32Value(&Parser, AnimField_BlocksCount);
|
||||
Result.Blocks_.CountMax = Parser_ReadU32Value(&Parser, AnimField_BlocksCount);
|
||||
Result.Blocks_.Generations = PushArray(Arena, u32, Result.Blocks_.CountMax);
|
||||
Result.Blocks_.Values = PushArray(Arena, animation_block, Result.Blocks_.CountMax);
|
||||
|
||||
if (Parser_ReadOpenStruct(&Parser, AnimField_PlayableRange))
|
||||
{
|
||||
Result.PlayableRange.Min = Parser_ReadU32Value(&Parser, AnimField_PlayableRangeMin);
|
||||
Result.PlayableRange.Max = Parser_ReadU32Value(&Parser, AnimField_PlayableRangeMax);
|
||||
|
||||
if (Parser_ReadCloseStruct(&Parser))
|
||||
{
|
||||
// TODO(pjs): Error
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -155,7 +155,6 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
|||
Animation_AddBlock(&Anim, 22, 123, 2, 0);
|
||||
|
||||
AnimationArray_Push(&State->AnimationSystem.Animations, Anim);
|
||||
|
||||
} // End Animation Playground
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue