Pattern builder in debug menu
This commit is contained in:
parent
6cb0749f2c
commit
5d321d6f54
|
@ -376,6 +376,8 @@ BlumenLumen_CustomInit(app_state* State, context Context)
|
||||||
|
|
||||||
gs_file_handler FileHandler = Context.ThreadContext.FileHandler;
|
gs_file_handler FileHandler = Context.ThreadContext.FileHandler;
|
||||||
gs_file ColorPhraseCSVFile = ReadEntireFile(FileHandler, PhraseMapCSVPath);
|
gs_file ColorPhraseCSVFile = ReadEntireFile(FileHandler, PhraseMapCSVPath);
|
||||||
|
if (ColorPhraseCSVFile.Memory != 0)
|
||||||
|
{
|
||||||
gs_const_string ColorPhraseMapStr = DataToString(ColorPhraseCSVFile.Data);
|
gs_const_string ColorPhraseMapStr = DataToString(ColorPhraseCSVFile.Data);
|
||||||
gscsv_sheet ColorPhraseSheet = CSV_Parse(ColorPhraseMapStr,
|
gscsv_sheet ColorPhraseSheet = CSV_Parse(ColorPhraseMapStr,
|
||||||
{ PhraseMapCSVSeparator },
|
{ PhraseMapCSVSeparator },
|
||||||
|
@ -383,6 +385,7 @@ BlumenLumen_CustomInit(app_state* State, context Context)
|
||||||
|
|
||||||
BLState->PhraseHueMap = PhraseHueMap_GenFromCSV(ColorPhraseSheet,
|
BLState->PhraseHueMap = PhraseHueMap_GenFromCSV(ColorPhraseSheet,
|
||||||
&State->Permanent);
|
&State->Permanent);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
animation_handle DemoPatternsAnim = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem,
|
animation_handle DemoPatternsAnim = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem,
|
||||||
|
@ -391,6 +394,7 @@ BlumenLumen_CustomInit(app_state* State, context Context)
|
||||||
ConstString("data/demo_patterns.foldanim"));
|
ConstString("data/demo_patterns.foldanim"));
|
||||||
State->AnimationSystem.ActiveFadeGroup.From = DemoPatternsAnim;
|
State->AnimationSystem.ActiveFadeGroup.From = DemoPatternsAnim;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
BLState->ModeAnimations[BlumenPattern_Standard] = LoadAllAnimationsInDir(AmbientPatternFolder, BLState, State, Context);
|
BLState->ModeAnimations[BlumenPattern_Standard] = LoadAllAnimationsInDir(AmbientPatternFolder, BLState, State, Context);
|
||||||
BLState->ModeAnimations[BlumenPattern_VoiceCommand] = LoadAllAnimationsInDir(VoicePatternFolder, BLState, State, Context);
|
BLState->ModeAnimations[BlumenPattern_VoiceCommand] = LoadAllAnimationsInDir(VoicePatternFolder, BLState, State, Context);
|
||||||
AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, State->Patterns, Context, ConstString("data/blumen_animations/anim_demo.foldanim"));
|
AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, State->Patterns, Context, ConstString("data/blumen_animations/anim_demo.foldanim"));
|
||||||
|
@ -405,6 +409,7 @@ BlumenLumen_CustomInit(app_state* State, context Context)
|
||||||
State->Patterns,
|
State->Patterns,
|
||||||
Context,
|
Context,
|
||||||
ConstString("data/blumen_animations/off_anim.foldanim"));
|
ConstString("data/blumen_animations/off_anim.foldanim"));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
State->AnimationSystem.TimelineShouldAdvance = true;
|
State->AnimationSystem.TimelineShouldAdvance = true;
|
||||||
|
|
||||||
|
@ -565,6 +570,8 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
||||||
BlumenLumen_AdvanceHueFade(BLState, *Context);
|
BlumenLumen_AdvanceHueFade(BLState, *Context);
|
||||||
|
|
||||||
// Update next frames Hues
|
// Update next frames Hues
|
||||||
|
if (!BLState->DebugOverrideHue)
|
||||||
|
{
|
||||||
r32 AnimTime = AnimationSystem_GetCurrentTime(State->AnimationSystem);
|
r32 AnimTime = AnimationSystem_GetCurrentTime(State->AnimationSystem);
|
||||||
AnimTime = (r32)Context->TotalTime;
|
AnimTime = (r32)Context->TotalTime;
|
||||||
r32 BaseTime = AnimTime * BLState->PatternSpeed;
|
r32 BaseTime = AnimTime * BLState->PatternSpeed;
|
||||||
|
@ -597,6 +604,14 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BLState->StandardPatternHues = BLState->DebugHue;
|
||||||
|
AnimationSystem_FadeToPlaylist(&State->AnimationSystem, BLState->ModeAnimations[BlumenPattern_VoiceCommand]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Open / Close the Motor
|
// Open / Close the Motor
|
||||||
if (MessageQueue_CanWrite(BLState->OutgoingMsgQueue) &&
|
if (MessageQueue_CanWrite(BLState->OutgoingMsgQueue) &&
|
||||||
!BLState->IgnoreTimeOfDay_MotorState)
|
!BLState->IgnoreTimeOfDay_MotorState)
|
||||||
|
@ -928,6 +943,56 @@ US_CUSTOM_DEBUG_UI(BlumenLumen_DebugUI)
|
||||||
BlumenLumen_ApplyNextHotHue(BLState, Context, &DebugStr, State);
|
BlumenLumen_ApplyNextHotHue(BLState, Context, &DebugStr, State);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui_Label(I, MakeString("Phrase Constructor"));
|
||||||
|
BLState->DebugOverrideHue = ui_ToggleText(I, MakeString("Override Hue"), BLState->DebugOverrideHue);
|
||||||
|
if (BLState->DebugOverrideHue)
|
||||||
|
{
|
||||||
|
phrase_hue PHue = BLState->DebugHue;
|
||||||
|
PHue.Hue0.Hue = (r64)ui_LabeledRangeSlider(I, MakeString("Hue0"), (r32)PHue.Hue0.Hue, 0, 360);
|
||||||
|
PHue.Hue1.Hue = (r64)ui_LabeledRangeSlider(I, MakeString("Hue1"), (r32)PHue.Hue1.Hue, 0, 360);
|
||||||
|
PHue.Hue2.Hue = (r64)ui_LabeledRangeSlider(I, MakeString("Hue2"), (r32)PHue.Hue2.Hue, 0, 360);
|
||||||
|
PHue.Granularity = (u32)ui_LabeledRangeSlider(I, MakeString("Granularity"), (r32)PHue.Granularity, 0, 5);
|
||||||
|
PHue.Speed = ui_LabeledRangeSlider(I, MakeString("Speed"), PHue.Speed, 0, 4);
|
||||||
|
|
||||||
|
gs_string PatternOptions[HuePattern_Count] = {};
|
||||||
|
PatternOptions[HuePattern_Patchy] = MakeString("patchy");
|
||||||
|
PatternOptions[HuePattern_Wavy] = MakeString("wavy");
|
||||||
|
|
||||||
|
gs_string CPattern = PatternOptions[PHue.Pattern];
|
||||||
|
if (ui_BeginLabeledDropdown(I, MakeString("Pattern"), CPattern))
|
||||||
|
{
|
||||||
|
for (u32 i = 0; i < HuePattern_Count; i++)
|
||||||
|
{
|
||||||
|
if (ui_Button(I, PatternOptions[i]))
|
||||||
|
{
|
||||||
|
PHue.Pattern = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui_EndLabeledDropdown(I);
|
||||||
|
|
||||||
|
|
||||||
|
gs_string AddInOptions[AddIn_Count] = {};
|
||||||
|
AddInOptions[AddIn_None] = MakeString("NA");
|
||||||
|
AddInOptions[AddIn_Waves] = MakeString("waves");
|
||||||
|
AddInOptions[AddIn_Rotary] = MakeString("rotary");
|
||||||
|
|
||||||
|
gs_string CAddIn = AddInOptions[PHue.AddIn];
|
||||||
|
if (ui_BeginLabeledDropdown(I, MakeString("Add In"), CAddIn))
|
||||||
|
{
|
||||||
|
for (u32 i = 0; i < AddIn_Count; i++)
|
||||||
|
{
|
||||||
|
if (ui_Button(I, AddInOptions[i]))
|
||||||
|
{
|
||||||
|
PHue.AddIn = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui_EndLabeledDropdown(I);
|
||||||
|
BLState->DebugHue = PHue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InterfaceAssert(I->PerFrameMemory);
|
InterfaceAssert(I->PerFrameMemory);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,9 @@ struct blumen_lumen_state
|
||||||
bool IgnoreTimeOfDay_MotorState;
|
bool IgnoreTimeOfDay_MotorState;
|
||||||
|
|
||||||
phrase_hue PendingPhrase;
|
phrase_hue PendingPhrase;
|
||||||
|
|
||||||
|
bool DebugOverrideHue;
|
||||||
|
phrase_hue DebugHue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "message_queue.cpp"
|
#include "message_queue.cpp"
|
||||||
|
|
|
@ -14,6 +14,8 @@ enum p_hue_pattern
|
||||||
{
|
{
|
||||||
HuePattern_Patchy,
|
HuePattern_Patchy,
|
||||||
HuePattern_Wavy,
|
HuePattern_Wavy,
|
||||||
|
|
||||||
|
HuePattern_Count,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum p_hue_add_in
|
enum p_hue_add_in
|
||||||
|
@ -21,6 +23,8 @@ enum p_hue_add_in
|
||||||
AddIn_None,
|
AddIn_None,
|
||||||
AddIn_Waves,
|
AddIn_Waves,
|
||||||
AddIn_Rotary,
|
AddIn_Rotary,
|
||||||
|
|
||||||
|
AddIn_Count,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct p_hue
|
typedef struct p_hue
|
||||||
|
@ -147,6 +151,8 @@ internal phrase_hue_map
|
||||||
PhraseHueMap_GenFromCSV(gscsv_sheet Sheet, gs_memory_arena* Arena)
|
PhraseHueMap_GenFromCSV(gscsv_sheet Sheet, gs_memory_arena* Arena)
|
||||||
{
|
{
|
||||||
phrase_hue_map Result = {};
|
phrase_hue_map Result = {};
|
||||||
|
if (Sheet.RowCount == 0) return Result;
|
||||||
|
|
||||||
Result.CountMax = Sheet.RowCount - 1; // we don't include the header row
|
Result.CountMax = Sheet.RowCount - 1; // we don't include the header row
|
||||||
Result.Phrases = PushArray(Arena, gs_const_string, Result.CountMax);
|
Result.Phrases = PushArray(Arena, gs_const_string, Result.CountMax);
|
||||||
Result.PhraseHashes = PushArray(Arena, u64, Result.CountMax);
|
Result.PhraseHashes = PushArray(Arena, u64, Result.CountMax);
|
||||||
|
@ -158,6 +164,8 @@ PhraseHueMap_GenFromCSV(gscsv_sheet Sheet, gs_memory_arena* Arena)
|
||||||
Result.Speed = PushArray(Arena, r32, Result.CountMax);
|
Result.Speed = PushArray(Arena, r32, Result.CountMax);
|
||||||
Result.AddIn = PushArray(Arena, u8, Result.CountMax);
|
Result.AddIn = PushArray(Arena, u8, Result.CountMax);
|
||||||
|
|
||||||
|
// this lets us tightly pack phrase_hues even if there is a
|
||||||
|
// row in the csv that is empty or invalid
|
||||||
s32 DestOffset = 0;
|
s32 DestOffset = 0;
|
||||||
for (u32 Row = 1; Row < Sheet.RowCount; Row++)
|
for (u32 Row = 1; Row < Sheet.RowCount; Row++)
|
||||||
{
|
{
|
||||||
|
@ -166,7 +174,6 @@ PhraseHueMap_GenFromCSV(gscsv_sheet Sheet, gs_memory_arena* Arena)
|
||||||
|
|
||||||
gs_const_string Phrase = CSVSheet_GetCell(Sheet,
|
gs_const_string Phrase = CSVSheet_GetCell(Sheet,
|
||||||
0, Row);
|
0, Row);
|
||||||
|
|
||||||
gs_const_string Hue0Str = CSVSheet_GetCell(Sheet, 1, Row);
|
gs_const_string Hue0Str = CSVSheet_GetCell(Sheet, 1, Row);
|
||||||
gs_const_string Hue1Str = CSVSheet_GetCell(Sheet, 2, Row);
|
gs_const_string Hue1Str = CSVSheet_GetCell(Sheet, 2, Row);
|
||||||
gs_const_string Hue2Str = CSVSheet_GetCell(Sheet, 3, Row);
|
gs_const_string Hue2Str = CSVSheet_GetCell(Sheet, 3, Row);
|
||||||
|
@ -176,6 +183,7 @@ PhraseHueMap_GenFromCSV(gscsv_sheet Sheet, gs_memory_arena* Arena)
|
||||||
gs_const_string Pattern = CSVSheet_GetCell(Sheet, 7, Row);
|
gs_const_string Pattern = CSVSheet_GetCell(Sheet, 7, Row);
|
||||||
gs_const_string AddIn = CSVSheet_GetCell(Sheet, 8, Row);
|
gs_const_string AddIn = CSVSheet_GetCell(Sheet, 8, Row);
|
||||||
|
|
||||||
|
// essential parameters
|
||||||
if (Phrase.Length == 0 ||
|
if (Phrase.Length == 0 ||
|
||||||
Hue0Str.Length == 0 ||
|
Hue0Str.Length == 0 ||
|
||||||
Hue1Str.Length == 0 ||
|
Hue1Str.Length == 0 ||
|
||||||
|
|
|
@ -201,7 +201,7 @@ CSVSheet_GetCell(gscsv_sheet Sheet, u64 Column, u64 Row)
|
||||||
{
|
{
|
||||||
gs_const_string Result = {};
|
gs_const_string Result = {};
|
||||||
|
|
||||||
if (Sheet.RowCount > Row && Sheet.ColumnCount > Column)
|
if (Row < Sheet.RowCount && Column < Sheet.ColumnCount)
|
||||||
{
|
{
|
||||||
u64 CellIndex = (Row * Sheet.ColumnCount) + Column;
|
u64 CellIndex = (Row * Sheet.ColumnCount) + Column;
|
||||||
Result = Sheet.Cells[CellIndex].Value;
|
Result = Sheet.Cells[CellIndex].Value;
|
||||||
|
|
Loading…
Reference in New Issue