diff --git a/code/vn.cpp b/code/vn.cpp index 8d892f2..571e113 100644 --- a/code/vn.cpp +++ b/code/vn.cpp @@ -1,6 +1,7 @@ #include "vn_platform.h" #include "vn_platform.cpp" +#include "vn_config.h" #include "vn_font.h" #include "vn_text_op.h" #include "vn_ui.h" @@ -8,6 +9,7 @@ #include "vn_theme_dark.h" #include "vn_animation_curve.h" +#include "vn_config.cpp" #include "vn_render.cpp" #include "vn_font.cpp" #include "vn_ui.cpp" @@ -20,6 +22,8 @@ struct vn_state memory_arena Arena; glyph_atlas *GlyphAtlas; + config *Config; + ui UI; workspace Workspace; animation_curve_state AnimationCurveState; @@ -37,8 +41,9 @@ VN_UPDATE_AND_RENDER(VN_UpdateAndRender) State = Memory->State = BootstrapPushStruct(vn_state, Arena); State->GlyphAtlas = CreateGlyphAtlas(RenderCommands); + State->Config = BootstrapPushStruct(config, Arena); - //Config_AddS64(&State->Config, StrLit("Platform/RefreshRate"), &Input->RefreshRate); + Config_BindEntry(State->Config, StrLit("Platform/RefreshRate"), Config_Entry_S32, &Input->RefreshRate); Workspace_Init(&State->Workspace); } @@ -47,8 +52,7 @@ VN_UPDATE_AND_RENDER(VN_UpdateAndRender) UI_NewFrame(&State->UI, Input->EventList, Input->MouseP); Workspace_Update(&State->Workspace, RenderCommands, Input, State->GlyphAtlas); - // sixten(NOTE): This allows us to check for - UI_SignalFromBox(UI_GetState()->ContainerNode); + UI_SignalFromBox(UI_GetState()->ContainerNode); // sixten(TODO): Move elsewhere. for(platform_event *Event = Input->EventList->First; Event != 0; diff --git a/code/vn_config.cpp b/code/vn_config.cpp index e69de29..9f86a17 100644 --- a/code/vn_config.cpp +++ b/code/vn_config.cpp @@ -0,0 +1,48 @@ +static config_entry *Config_FindEntryByName(config *Config, string Name) +{ + config_entry *Result = 0; + + u32 BucketSlot = HashString(Name) % ArrayCount(Config->EntryBuckets); + config_entry_bucket *Bucket = Config->EntryBuckets + BucketSlot; + + for(config_entry *Entry = Bucket->First; + Entry != 0; + Entry = Entry->Next) + { + if(AreEqual(Entry->Name, Name)) + { + Result = Entry; + break; + } + } + + return(Result); +} + +static void Config_ReadFile(config *Config, string Path) +{ + +} + +static void Config_WriteFile(config *Config) +{ +} + +static void Config_BindEntry(config *Config, string Name, config_entry_type Type, void *Target) +{ + config_entry *Entry = Config_FindEntryByName(Config, Name); + if(!Entry) + { + Entry = PushStruct(&Config->Arena, config_entry); + Entry->Name = Name; + Entry->Type = Type; + + u32 BucketSlot = HashString(Name) % ArrayCount(Config->EntryBuckets); + config_entry_bucket *Bucket = Config->EntryBuckets + BucketSlot; + + DLLInsertLast(Bucket->First, Bucket->Last, Entry); + } + + Assert(Entry->Type == Type); + Entry->Target = Target; +} \ No newline at end of file diff --git a/code/vn_config.h b/code/vn_config.h index f8a98d8..9c1dc73 100644 --- a/code/vn_config.h +++ b/code/vn_config.h @@ -3,27 +3,40 @@ #ifndef VN_CONFIG_H #define VN_CONFIG_H +enum config_entry_type +{ + Config_Entry_S32, + Config_Entry_S64, + Config_Entry_B32, +}; + struct config_entry { string Name; - buffer Target; + void *Target; + config_entry_type Type; config_entry *Next; config_entry *Prev; }; -struct config +struct config_entry_bucket { - memory_arena Arena; - config_entry *First; config_entry *Last; }; +struct config +{ + memory_arena Arena; + config_entry_bucket EntryBuckets[32]; +}; + +static config_entry *Config_FindEntryByName(config *Config, string Name); + static void Config_ReadFile(config *Config, string Path); static void Config_WriteFile(config *Config); -static void Config_AddEntry(config *Config, string Name, buffer Target); -static void Config_AddS64(config *Config, string Name, s64 *Target); +static void Config_BindEntry(config *Config, string Name, config_entry_type, void *Target); #endif //VN_CONFIG_H diff --git a/code/vn_platform.h b/code/vn_platform.h index 86981fa..af6722f 100644 --- a/code/vn_platform.h +++ b/code/vn_platform.h @@ -200,7 +200,7 @@ struct vn_input r32 dtForFrame; // sixten: Application to platform - s32 TargetRefreshRate; + s32 RefreshRate; }; struct vn_memory diff --git a/code/vn_workspace_view.cpp b/code/vn_workspace_view.cpp index d9eb635..73732af 100644 --- a/code/vn_workspace_view.cpp +++ b/code/vn_workspace_view.cpp @@ -240,7 +240,7 @@ static void Workspace_BuildSettingsTabButton(workspace_view_settings *Settings, { Platform.SetCursor(PlatformCursor_Hand); } - if(Signal.Clicked) + if(Signal.Pressed) { Settings->Category = Category; } @@ -420,6 +420,7 @@ static void Workspace_BuildView(workspace *Workspace, workspace_view *View) r32 ViewHighlightTransition = AnimationCurve_AnimateValueF(Workspace_ViewIsCurrent(Workspace, View), 0, 0.25, "Workspace View Highlight %p", View); UI_SetNextBorderColor(LinearBlend(Theme_BorderColor, Theme_HighlightBorderColor, ViewHighlightTransition)); + UI_SetNextBackgroundColor(Theme_BackgroundColor); UI_SetNextCornerRadius(3); ui_box *ViewBox = UI_MakeBoxF(UI_BoxFlag_Clickable | diff --git a/code/win32_main.cpp b/code/win32_main.cpp index b612852..aefbc63 100644 --- a/code/win32_main.cpp +++ b/code/win32_main.cpp @@ -658,17 +658,17 @@ int WinMain(HINSTANCE Instance, HINSTANCE PreviousInstance, LPSTR CommandLine, i LoadedCode.UpdateAndRender(&ThreadContext, &Memory, &Input, &RenderCommands); } - b32 UseVSync = (Input.TargetRefreshRate == 0); + b32 UseVSync = (Input.RefreshRate == 0); wglSwapIntervalEXT(UseVSync); OpenGL_EndFrame(&OpenGLContext, &RenderCommands); wglSwapLayerBuffers(DeviceContext, WGL_SWAP_MAIN_PLANE); } - b32 ShouldLimitFrameRate = (Input.TargetRefreshRate > 0); + b32 ShouldLimitFrameRate = (Input.RefreshRate > 0); if(ShouldLimitFrameRate) { - Win32_EnforceFrameRate(CurrentTime, Input.TargetRefreshRate); + Win32_EnforceFrameRate(CurrentTime, Input.RefreshRate); } } }