allow disabling time based tinting
This commit is contained in:
parent
5a1ea421f6
commit
617a4fbfb6
16
src/main.cpp
16
src/main.cpp
@ -88,6 +88,7 @@ static M4x4 inverse_projection_matrix;
|
||||
|
||||
static SDL_Time time;
|
||||
|
||||
static bool enable_time_tints = true;
|
||||
static bool use_actual_time = true;
|
||||
static SDL_DateTime calendar_time;
|
||||
|
||||
@ -1637,14 +1638,20 @@ int main(int argc, char **argv) {
|
||||
time_tints_settings_handler.TypeName = "TimeTints";
|
||||
time_tints_settings_handler.TypeHash = ImHashStr("TimeTints");
|
||||
time_tints_settings_handler.ReadOpenFn = [](ImGuiContext *context, ImGuiSettingsHandler *handler, const char *name) -> void * {
|
||||
if (strcmp(name, "num") == 0)
|
||||
if (strcmp(name, "Settings") == 0)
|
||||
return (void *)-1;
|
||||
int num = atoi(name) + 1;
|
||||
return (void *)(Sint64)num;
|
||||
};
|
||||
time_tints_settings_handler.ReadLineFn = [](ImGuiContext *context, ImGuiSettingsHandler *handler, void *entry, const char *line) {
|
||||
if (entry == (void *)-1) {
|
||||
SDL_sscanf(line, "num=%d", &num_used_tint_times);
|
||||
if (strncmp(line, "num", 3) == 0) {
|
||||
SDL_sscanf(line, "num=%d", &num_used_tint_times);
|
||||
} else if (strncmp(line, "enable", 6) == 0) {
|
||||
Uint32 enable = 0;
|
||||
SDL_sscanf(line, "enable=%d", &enable);
|
||||
enable_time_tints = !!enable;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1655,7 +1662,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
};
|
||||
time_tints_settings_handler.WriteAllFn = [](ImGuiContext *context, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buffer) {
|
||||
buffer->append("[TimeTints][num]\n");
|
||||
buffer->append("[TimeTints][Settings]\n");
|
||||
buffer->appendf("enable=%u\n", enable_time_tints ? 1 : 0);
|
||||
buffer->appendf("num=%d\n\n", num_used_tint_times);
|
||||
|
||||
for (int i = 0; i < num_used_tint_times; i++) {
|
||||
@ -1782,6 +1790,7 @@ int main(int argc, char **argv) {
|
||||
ImGui::DragScalarN("Time", ImGuiDataType_S32, &calendar_time.hour, 3);
|
||||
ImGui::EndDisabled();
|
||||
ImGui::Checkbox("use actual time", &use_actual_time);
|
||||
ImGui::Checkbox("enable time based tinting", &enable_time_tints);
|
||||
|
||||
ImGui::NewLine();
|
||||
for (int i = 0; i < num_used_tint_times; i++) {
|
||||
@ -2227,6 +2236,7 @@ int main(int argc, char **argv) {
|
||||
double t = v / (double)time_between;
|
||||
|
||||
V3 tint_color = lerp(time_tints[last_time_index], time_tints[(last_time_index + 1) % num_used_tint_times], t);
|
||||
if (!enable_time_tints) tint_color = V3_(1, 1, 1);
|
||||
update_buffer(tint_color_buffer, 0, sizeof(tint_color), &tint_color);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user