vn/code/vn_workspace_character_edit...

100 lines
3.7 KiB
C++

////////////////////////////////
//~ sixten: Workspace Character Editor Functions
static character_editor_entry_data *W_AllocateCharacterEntryData(workspace_view_character_editor *Editor, memory_arena *Arena)
{
character_editor_entry_data *Result = Editor->FreeList.First;
if(!Result)
{
Result = PushStructNoClear(Arena, character_editor_entry_data);
}
*Result = {};
return(Result);
}
static void W_BuildCharacterEditorView(workspace_view *View)
{
workspace_view_character_editor *Editor = (workspace_view_character_editor *)View->Data;
//- sixten: check that the entry list is filled out
if(DLLIsEmpty(Editor->List.First))
{
character_list Characters = CR_GetCharacters();
for(character_entry *Character = Characters.First; Character != 0; Character = Character->Next)
{
character_editor_entry_data *Data = W_AllocateCharacterEntryData(Editor, View->Arena);
Data->Entry = Character;
DLLInsertLast(Editor->List.First, Editor->List.Last, Data);
}
}
UI_WidthFill UI_HeightFill UI_Row() UI_Padding(UI_Em(5, 1)) UI_Column()
{
UI_Spacer(UI_Em(2, 1));
// sixten: build character lister
{
UI_SetNextWidth(UI_Percent(1, 1));
UI_SetNextHeight(UI_Percent(1, 0));
UI_Scroll(0, &Editor->ScrollT)
{
UI_Height(UI_Em(2.0f, 1)) UI_CornerRadius(4.0f)
for(character_editor_entry_data *Data = Editor->List.First; Data != 0; Data = Data->Next)
{
character_entry *Entry = Data->Entry;
if(UI_ButtonF("%S", Entry->Name).Clicked)
{
Data->IsOpen = !Data->IsOpen;
}
AC_AnimateValueDirect(Data->IsOpen, 0.3f, &Data->OpenTransition);
if(Data->OpenTransition > 0.1f)
{
UI_SetNextHeight(UI_ChildrenSum(Data->OpenTransition, 1));
UI_Parent(UI_MakeBox(UI_BoxFlag_DrawBorder |
UI_BoxFlag_DrawDropShadow |
UI_BoxFlag_Clip,
StrLit("")))
{
UI_LabelF("hello");
UI_LabelF("line");
UI_LabelF("paint");
UI_LabelF("color");
UI_LabelF("design");
UI_LabelF("address");
UI_LabelF("brightness");
}
}
}
}
}
// sixten: build bottom controls
UI_Spacer(UI_Em(1.5, 1));
UI_Height(UI_Em(2, 1)) UI_Row()
{
UI_Width(UI_TextContent(15, 1)) UI_CornerRadius(4)
{
UI_SetNextFont(Font_Icons);
ui_signal AddSignal = UI_ButtonF("%U", FontIcon_UserPlus);
if(AddSignal.Hovering)
{
UI_TooltipLabel(StrLit("Add new character"), UI_MouseP());
}
UI_Spacer(UI_Em(0.5, 1));
UI_SetNextFont(Font_Icons);
ui_signal RemoveSignal = UI_ButtonF("%U", FontIcon_UserTimes);
if(RemoveSignal.Hovering)
{
UI_TooltipLabel(StrLit("Delete selected character"), UI_MouseP());
}
}
}
UI_Spacer(UI_Em(1.5, 1));
}
}