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;
|
handle Result = SelectedBlockHandle;
|
||||||
|
|
||||||
// TODO(pjs): Animation Selection
|
// TODO(pjs): Animation Selection
|
||||||
animation CurrAnimation = AnimationSystem->Animations.Values[0];
|
animation CurrAnimation = *AnimationSystem_GetActiveAnimation(AnimationSystem);
|
||||||
|
|
||||||
rect2 LayerMenuBounds, TimelineBounds;
|
rect2 LayerMenuBounds, TimelineBounds;
|
||||||
RectVSplitAtDistanceFromLeft(PanelBounds, 256, &LayerMenuBounds, &TimelineBounds);
|
RectVSplitAtDistanceFromLeft(PanelBounds, 256, &LayerMenuBounds, &TimelineBounds);
|
||||||
|
@ -579,6 +579,13 @@ PANEL_MODAL_OVERRIDE_CALLBACK(LoadAnimationFileCallback)
|
||||||
Assert(ReturningFrom->TypeIndex == PanelType_FileView);
|
Assert(ReturningFrom->TypeIndex == PanelType_FileView);
|
||||||
file_view_state* FileViewState = Panel_GetStateStruct(ReturningFrom, file_view_state);
|
file_view_state* FileViewState = Panel_GetStateStruct(ReturningFrom, file_view_state);
|
||||||
gs_file_info FileInfo = FileViewState->SelectedFile;
|
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
|
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_entry* FileBrowser = PanelSystem_PushPanel(&State->PanelSystem, PanelType_FileView, State, Context);
|
||||||
Panel_PushModalOverride(Panel, FileBrowser, LoadAnimationFileCallback);
|
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);
|
ui_EndRow(&TitleBarLayout);
|
||||||
|
|
|
@ -14,7 +14,19 @@ struct file_view_state
|
||||||
gs_file_info SelectedFile;
|
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;
|
s32 FileView_CommandsCount = 0;
|
||||||
|
|
||||||
internal void
|
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);
|
file_view_state* FileViewState = Panel_GetStateStruct(Panel, file_view_state);
|
||||||
ui_layout Layout = ui_CreateLayout(State->Interface, PanelBounds);
|
ui_layout Layout = ui_CreateLayout(State->Interface, PanelBounds);
|
||||||
|
|
||||||
|
if (ui_LayoutButton(&State->Interface, &Layout, MakeString("Exit")))
|
||||||
|
{
|
||||||
|
FileView_Exit_(Panel, State, Context);
|
||||||
|
}
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
ui_LayoutDrawString(&State->Interface, &Layout, FileViewState->WorkingDirectory, v4{0, 1, 0, 1});
|
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
|
else
|
||||||
{
|
{
|
||||||
FileViewState->SelectedFile = File;
|
FileViewState->SelectedFile = File;
|
||||||
|
FileView_Exit_(Panel, State, Context);
|
||||||
Assert(Panel->IsModalOverrideFor != 0);
|
|
||||||
panel* ReturnTo = Panel->IsModalOverrideFor;
|
|
||||||
if (ReturnTo->ModalOverrideCB)
|
|
||||||
{
|
|
||||||
ReturnTo->ModalOverrideCB(Panel, State, Context);
|
|
||||||
}
|
|
||||||
Panel_PopModalOverride(ReturnTo, &State->PanelSystem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ struct animation_system
|
||||||
// NOTE(Peter): The frame currently being displayed/processed. you
|
// 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
|
// can see which frame you're on by looking at the time slider on the timeline
|
||||||
// panel
|
// panel
|
||||||
|
u32 ActiveAnimationIndex;
|
||||||
s32 CurrentFrame;
|
s32 CurrentFrame;
|
||||||
s32 LastUpdatedFrame;
|
s32 LastUpdatedFrame;
|
||||||
r32 SecondsPerFrame;
|
r32 SecondsPerFrame;
|
||||||
|
@ -401,7 +402,7 @@ internal animation*
|
||||||
AnimationSystem_GetActiveAnimation(animation_system* System)
|
AnimationSystem_GetActiveAnimation(animation_system* System)
|
||||||
{
|
{
|
||||||
// TODO(pjs): need a way to specify the active animation
|
// TODO(pjs): need a way to specify the active animation
|
||||||
return System->Animations.Values + 0;
|
return System->Animations.Values + System->ActiveAnimationIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal animation_frame
|
internal animation_frame
|
||||||
|
|
|
@ -70,7 +70,7 @@ AnimSerializer_Serialize(animation Anim, animation_clip* GlobalClips, gs_memory_
|
||||||
}
|
}
|
||||||
|
|
||||||
internal animation
|
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};
|
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.CountMax = Parser_ReadU32Value(&Parser, AnimField_LayersCount);
|
||||||
Result.Layers.Values = PushArray(Arena, anim_layer, Result.Layers.CountMax);
|
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,
|
Result.Blocks_.CountMax = Parser_ReadU32Value(&Parser, AnimField_BlocksCount);
|
||||||
// but I want to replace that eventually, so this is here to preallocate the blocks we need
|
Result.Blocks_.Generations = PushArray(Arena, u32, Result.Blocks_.CountMax);
|
||||||
u32 BlocksCount = Parser_ReadU32Value(&Parser, AnimField_BlocksCount);
|
Result.Blocks_.Values = PushArray(Arena, animation_block, Result.Blocks_.CountMax);
|
||||||
|
|
||||||
if (Parser_ReadOpenStruct(&Parser, AnimField_PlayableRange))
|
if (Parser_ReadOpenStruct(&Parser, AnimField_PlayableRange))
|
||||||
{
|
{
|
||||||
Result.PlayableRange.Min = Parser_ReadU32Value(&Parser, AnimField_PlayableRangeMin);
|
Result.PlayableRange.Min = Parser_ReadU32Value(&Parser, AnimField_PlayableRangeMin);
|
||||||
Result.PlayableRange.Max = Parser_ReadU32Value(&Parser, AnimField_PlayableRangeMax);
|
Result.PlayableRange.Max = Parser_ReadU32Value(&Parser, AnimField_PlayableRangeMax);
|
||||||
|
|
||||||
|
if (Parser_ReadCloseStruct(&Parser))
|
||||||
|
{
|
||||||
|
// TODO(pjs): Error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -155,7 +155,6 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
Animation_AddBlock(&Anim, 22, 123, 2, 0);
|
Animation_AddBlock(&Anim, 22, 123, 2, 0);
|
||||||
|
|
||||||
AnimationArray_Push(&State->AnimationSystem.Animations, Anim);
|
AnimationArray_Push(&State->AnimationSystem.Animations, Anim);
|
||||||
|
|
||||||
} // End Animation Playground
|
} // End Animation Playground
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue