checklist stuff
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "Util.h"
|
||||
#include "Settings.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
extern bool justDocked;
|
||||
extern DrawData* gDrawData;
|
||||
extern ApplicationData* gAppData;
|
||||
@@ -10,8 +12,8 @@ extern ApplicationData* gAppData;
|
||||
void initSettings(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "ApplicationSettings";
|
||||
ini_handler.TypeHash = ImHashStr("ApplicationSettings");
|
||||
ini_handler.TypeName = APPLICATION_SETTINGS_GROUP;
|
||||
ini_handler.TypeHash = ImHashStr(APPLICATION_SETTINGS_GROUP);
|
||||
ini_handler.ReadOpenFn = settingsReadOpen;
|
||||
ini_handler.ReadLineFn = settingsReadLine;
|
||||
ini_handler.WriteAllFn = settingsWriteAll;
|
||||
@@ -29,6 +31,8 @@ void* settingsReadOpen(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const c
|
||||
|
||||
void settingsReadLine(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line)
|
||||
{
|
||||
if (strlen(line) == 0) return;
|
||||
|
||||
ApplicationSettings* settings = (ApplicationSettings*)entry;
|
||||
|
||||
int docked;
|
||||
@@ -36,19 +40,54 @@ void settingsReadLine(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* en
|
||||
{
|
||||
settings->docked = (bool)docked;
|
||||
}
|
||||
|
||||
int autostart;
|
||||
if (sscanf_s(line, "autostart=%i", &autostart))
|
||||
{
|
||||
settings->autostart = (bool)autostart;
|
||||
}
|
||||
|
||||
std::string taskName{};
|
||||
taskName.resize(MAX_TASK_NAME_LENGTH);
|
||||
if (sscanf_s(line, "taskname=%s", &taskName[0], MAX_TASK_NAME_LENGTH))
|
||||
{
|
||||
settings->taskNames.push_back(taskName);
|
||||
}
|
||||
|
||||
std::string task{};
|
||||
task.resize(MAX_TASK_NAME_LENGTH);
|
||||
time_t dayTimestamp;
|
||||
if (sscanf_s(line, "task=%lld %s", &dayTimestamp, &task[0], MAX_TASK_NAME_LENGTH))
|
||||
{
|
||||
if (settings->tasks.contains(task))
|
||||
{
|
||||
settings->tasks[task].push_back(dayTimestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings->tasks.insert({ task, std::vector{ dayTimestamp } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void settingsWriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* outBuf)
|
||||
{
|
||||
outBuf->appendf("[%s][%s]\n", "ApplicationSettings", "ApplicationSettings");
|
||||
outBuf->appendf("[%s][%s]\n", APPLICATION_SETTINGS_GROUP, APPLICATION_SETTINGS_GROUP);
|
||||
outBuf->appendf("docked=%i\n", (int)gAppData->settings.docked);
|
||||
outBuf->appendf("autostart=%i\n", (int)gAppData->settings.autostart);
|
||||
outBuf->append("\n");
|
||||
|
||||
for (std::string& taskName : gAppData->settings.taskNames)
|
||||
{
|
||||
outBuf->appendf("taskname=%s\n", taskName.c_str());
|
||||
}
|
||||
|
||||
for (auto& task : gAppData->settings.tasks)
|
||||
{
|
||||
for (auto& date : task.second)
|
||||
{
|
||||
outBuf->appendf("task=%lld %s\n", date, task.first.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void applySettings(DrawData& drawData, ApplicationData& appData)
|
||||
|
||||
Reference in New Issue
Block a user