summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE13
-rw-r--r--docs/README.rst3
-rw-r--r--include/administration.hpp17
-rw-r--r--include/administration_reader.hpp17
-rw-r--r--include/administration_writer.hpp16
-rw-r--r--include/config.hpp16
-rw-r--r--include/file_templates.hpp16
-rw-r--r--include/locales.hpp17
-rw-r--r--include/log.hpp16
-rw-r--r--include/strops.hpp17
-rw-r--r--include/ui.hpp19
-rw-r--r--run.bat7
-rw-r--r--src/administration.cpp21
-rw-r--r--src/administration_reader.cpp30
-rw-r--r--src/administration_writer.cpp34
-rw-r--r--src/locales.cpp21
-rw-r--r--src/locales/en.cpp16
-rw-r--r--src/log.cpp16
-rw-r--r--src/main.cpp51
-rw-r--r--src/strops.cpp16
-rw-r--r--src/ui/helpers.cpp17
-rw-r--r--src/ui/ui_contacts.cpp16
-rw-r--r--src/ui/ui_earnings.cpp16
-rw-r--r--src/ui/ui_expenses.cpp16
-rw-r--r--src/ui/ui_invoices.cpp16
-rw-r--r--src/ui/ui_log.cpp16
-rw-r--r--src/ui/ui_main.cpp94
-rw-r--r--src/ui/ui_projects.cpp16
-rw-r--r--src/ui/ui_settings.cpp16
-rw-r--r--src/ui/ui_start.cpp31
30 files changed, 548 insertions, 85 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..0d6fec2
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file
diff --git a/docs/README.rst b/docs/README.rst
index e8aab29..c92bb7a 100644
--- a/docs/README.rst
+++ b/docs/README.rst
@@ -44,4 +44,5 @@ This section lists all supported countries. If the country you operate from is n
- tinyfiledialogs (https://sourceforge.net/projects/tinyfiledialogs/)
- xml.c (https://github.com/ooxi/xml.c)
- zip (https://github.com/kuba--/zip)
-- timer_lib (https://github.com/mjansson/timer_lib) \ No newline at end of file
+- timer_lib (https://github.com/mjansson/timer_lib)
+- greatest (https://github.com/silentbicycle/greatest) \ No newline at end of file
diff --git a/include/administration.hpp b/include/administration.hpp
index 2d8908d..cfdb293 100644
--- a/include/administration.hpp
+++ b/include/administration.hpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#pragma once
#include "config.hpp"
@@ -383,6 +399,7 @@ s32 administration_get_next_sequence_number();
char* administration_get_currency_symbol_for_currency(char* code);
char* administration_get_default_currency();
+void administration_set_file_path(char* path);
void administration_set_next_id(s32 nr);
void administration_set_next_sequence_number(s32 nr);
diff --git a/include/administration_reader.hpp b/include/administration_reader.hpp
index d94947e..cbd69ba 100644
--- a/include/administration_reader.hpp
+++ b/include/administration_reader.hpp
@@ -1,7 +1,24 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#pragma once
bool administration_reader_open_new();
bool administration_reader_open_existing(char* file_path);
+bool administration_reader_save_new();
bool administration_reader_import_administration_info(char* buffer, size_t buffer_size);
bool administration_reader_import_tax_rate(char* buffer, size_t buffer_size);
diff --git a/include/administration_writer.hpp b/include/administration_writer.hpp
index 08fe301..7ac0645 100644
--- a/include/administration_writer.hpp
+++ b/include/administration_writer.hpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#pragma once
#include "administration.hpp"
diff --git a/include/config.hpp b/include/config.hpp
index a0f11c0..2284c8a 100644
--- a/include/config.hpp
+++ b/include/config.hpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#pragma once
// major.minor.patch
diff --git a/include/file_templates.hpp b/include/file_templates.hpp
index d6f9b7d..58b777f 100644
--- a/include/file_templates.hpp
+++ b/include/file_templates.hpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
const char* project_save_template =
"<Project>\n"
" <Id>{{PROJECT_ID}}</Id>\n"
diff --git a/include/locales.hpp b/include/locales.hpp
index ff116d5..d361f1e 100644
--- a/include/locales.hpp
+++ b/include/locales.hpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#pragma once
typedef struct {
@@ -14,5 +30,6 @@ typedef struct {
extern locale_entry en_locales[];
extern const int en_locale_count;
+const char* get_locale();
void set_locale(const char key[2]);
const char* localize(const char* key); \ No newline at end of file
diff --git a/include/log.hpp b/include/log.hpp
index f34cc27..5efad6e 100644
--- a/include/log.hpp
+++ b/include/log.hpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#pragma once
#include "timer.h"
diff --git a/include/strops.hpp b/include/strops.hpp
index 412becc..68a927e 100644
--- a/include/strops.hpp
+++ b/include/strops.hpp
@@ -1,4 +1,21 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#pragma once
+
#include <stdint.h>
size_t strops_copy(char *dst, const char *src, size_t size);
diff --git a/include/ui.hpp b/include/ui.hpp
index 6364c55..cdffa58 100644
--- a/include/ui.hpp
+++ b/include/ui.hpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#pragma once
#include "imgui.h"
@@ -20,7 +36,6 @@ typedef enum
UI_PROJECTS = 5,
UI_SETTINGS = 6,
UI_LOG = 7,
- UI_START = 8,
UI_END
} main_state;
@@ -44,6 +59,7 @@ typedef struct
} ui_status;
extern ImFont* fontBold;
+extern ImFont* fontBig;
void ui_helper_draw_required_tag();
@@ -64,7 +80,6 @@ void ui_draw_settings();
void ui_draw_expenses();
void ui_draw_earnings();
void ui_draw_log();
-void ui_draw_start();
void ui_setup_invoices();
void ui_setup_contacts();
diff --git a/run.bat b/run.bat
index ae6e08d..7ad0316 100644
--- a/run.bat
+++ b/run.bat
@@ -14,6 +14,8 @@ if not exist "%VCVARSALL%" (
exit /b 1
)
+for /f "delims=" %%i in ('git rev-parse --short HEAD') do set COMMIT_ID=%%i
+
call "%VCVARSALL%" x64
@set OUT_DIR=build\\
@set OUT_EXE=accounting
@@ -30,11 +32,12 @@ set LIB_SOURCES=libs\imgui-1.92.1\backends\imgui_impl_dx11.cpp^
@set LIBS=opengl32.lib Advapi32.lib Shell32.lib Ole32.lib User32.lib Pathcch.lib D3D11.lib Comdlg32.lib Kernel32.lib
@set FLAGS=/nologo /Ob0 /MD /Oy- /Zi /FS /W4 /EHsc /utf-8
@set INCLUDE_DIRS=/I"libs/imgui-1.92.1" /I"libs/imgui-1.92.1/backends" /I"/" /I"libs/timer_lib" /I"libs/greatest" /I"libs/simclist-1.5" /I"libs/tinyfiledialogs" /I"libs/zip/src" /I"libs/xml.c/src" /I"libs/" /Iinclude
+@set DEFINITIONS=/D_BUILD_DATE_=\"%date%\" /D_COMMIT_=\"%COMMIT_ID%\" /D_PLATFORM_=\"win64\"
-if "%1"=="-t" @set SOURCES= tests\main.cpp src\administration.cpp src\administration_writer.cpp src\administration_reader.cpp src\strops.cpp src\log.cpp src\locales.cpp src\locales\*.cpp
+if "%1"=="-t" @set SOURCES= tests\main.cpp src\administration.cpp src\administration_writer.cpp src\administration_reader.cpp src\strops.cpp src\log.cpp src\locales.cpp src\locales\*.cpp src\ui\helpers.cpp
if "%1"=="-t" @set OUT_EXE=accounting_tests
-cl %FLAGS% %INCLUDE_DIRS% %SOURCES% %LIB_SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fd%OUT_DIR%/vc140.pdb /Fo%OUT_DIR%/ /link %LIBS%
+cl %FLAGS% %INCLUDE_DIRS% %DEFINITIONS% %SOURCES% %LIB_SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fd%OUT_DIR%/vc140.pdb /Fo%OUT_DIR%/ /link %LIBS%
if "%1"=="-r" call "%OUT_DIR%/%OUT_EXE%.exe"
if "%1"=="-t" call "%OUT_DIR%/%OUT_EXE%.exe" -v
if "%1"=="-d" call devenv "%OUT_DIR%/%OUT_EXE%.exe"
diff --git a/src/administration.cpp b/src/administration.cpp
index 404bd1e..f8d53f9 100644
--- a/src/administration.cpp
+++ b/src/administration.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
@@ -811,6 +827,11 @@ void administration_create_income_statement(income_statement* statement)
log_add("Created income statement in %.3fms.", STOPWATCH_TIME);
}
+void administration_set_file_path(char* path)
+{
+ strops_copy(g_administration.path, path, MAX_LEN_PATH);
+}
+
char* administration_get_file_path()
{
return strlen(g_administration.path) == 0 ? NULL : g_administration.path;
diff --git a/src/administration_reader.cpp b/src/administration_reader.cpp
index 529d8c0..8c6bf89 100644
--- a/src/administration_reader.cpp
+++ b/src/administration_reader.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -23,6 +39,20 @@ bool administration_reader_open_new()
return true;
}
+bool administration_reader_save_new()
+{
+ // @localize
+ char const * lFilterPatterns[1] = { "*.openbook" };
+ char* save_path = tinyfd_saveFileDialog("Select destination", NULL, 1, lFilterPatterns, NULL);
+
+ if (!save_path) return false;
+
+ administration_set_file_path(save_path);
+ administration_writer_save_all_async();
+
+ return true;
+}
+
bool administration_reader_open_existing(char* file_path)
{
if (file_path == NULL) {
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp
index 119f4b4..26e26c8 100644
--- a/src/administration_writer.cpp
+++ b/src/administration_writer.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#define _CRT_SECURE_NO_WARNINGS
#include <zip.h>
@@ -6,6 +22,8 @@
#include <threads.h>
#include "log.hpp"
+#include "ui.hpp"
+#include "locales.hpp"
#include "strops.hpp"
#include "administration_reader.hpp"
#include "administration_writer.hpp"
@@ -16,7 +34,12 @@ mtx_t _save_file_mutex;
static void on_administration_data_changed()
{
- administration_writer_save_all_administration_info_blocking();
+ if (administration_writer_save_all_administration_info_blocking()) {
+ ui_set_status(localize("status.saved"));
+ }
+ else {
+ ui_set_status(localize("status.saveFailed"));
+ }
}
static void on_administration_data_deleted(char id[MAX_LEN_ID])
@@ -682,10 +705,11 @@ static int administration_writer_write_all_t(void *arg) {
bool administration_writer_save_all_async()
{
- thrd_t thr;
- if (thrd_create(&thr, administration_writer_write_all_t, 0) != thrd_success) {
- return false;
- }
+ administration_writer_write_all_t(0);
+ //thrd_t thr;
+ //if (thrd_create(&thr, administration_writer_write_all_t, 0) != thrd_success) {
+ // return false;
+ //}
return true;
} \ No newline at end of file
diff --git a/src/locales.cpp b/src/locales.cpp
index 89c8499..62bf6fb 100644
--- a/src/locales.cpp
+++ b/src/locales.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <stdio.h>
#include <string.h>
@@ -12,6 +28,11 @@ const int locale_map_count = sizeof(locales) / sizeof(locales[0]);
locale_map g_locale = locales[0]; // Default to english.
+const char* get_locale()
+{
+ return g_locale.lang_code;
+}
+
void set_locale(const char* key)
{
for (int i = 0; i < locale_map_count; ++i) {
diff --git a/src/locales/en.cpp b/src/locales/en.cpp
index cbb1d13..36b9876 100644
--- a/src/locales/en.cpp
+++ b/src/locales/en.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include "locales.hpp"
locale_entry en_locales[] = {
diff --git a/src/log.cpp b/src/log.cpp
index 058b594..270a636 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
diff --git a/src/main.cpp b/src/main.cpp
index ba7a2e5..2e3d215 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include "imgui.h"
#include "imgui_impl_win32.h"
#include "imgui_impl_dx11.h"
@@ -9,6 +25,7 @@
#include "administration_writer.hpp"
// Data
+static HWND hwnd;
static ID3D11Device* g_pd3dDevice = nullptr;
static ID3D11DeviceContext* g_pd3dDeviceContext = nullptr;
static IDXGISwapChain* g_pSwapChain = nullptr;
@@ -23,10 +40,29 @@ void CreateRenderTarget();
void CleanupRenderTarget();
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+void platorm_maximize_window()
+{
+ LONG style = GetWindowLong(hwnd, GWL_STYLE);
+
+ // allow resizing + maximize
+ style |= (WS_THICKFRAME | WS_MAXIMIZEBOX);
+
+ SetWindowLong(hwnd, GWL_STYLE, style);
+
+ // Apply style changes
+ SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+
+ ShowWindow(hwnd, SW_MAXIMIZE);
+}
+
// Main code
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
int main()
{
+ int start_width = 1280;
+ int start_height = 800;
+
// Make process DPI aware and obtain main monitor scale
ImGui_ImplWin32_EnableDpiAwareness();
float main_scale = ImGui_ImplWin32_GetDpiScaleForMonitor(::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY));
@@ -34,7 +70,17 @@ int main()
// Create application window
WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
::RegisterClassExW(&wc);
- HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"OpenBooks", WS_OVERLAPPEDWINDOW, 100, 100, (int)(1280 * main_scale), (int)(800 * main_scale), nullptr, nullptr, wc.hInstance, nullptr);
+
+ // Get screen size
+ int screenW = GetSystemMetrics(SM_CXSCREEN);
+ int screenH = GetSystemMetrics(SM_CYSCREEN);
+
+ // Calculate top-left so window is centered
+ int x = (screenW - start_width) / 2;
+ int y = (screenH - start_height) / 2;
+
+ hwnd = ::CreateWindowW(wc.lpszClassName, L"OpenBooks", WS_OVERLAPPEDWINDOW,
+ x, y, (int)(start_width * main_scale), (int)(start_height * main_scale), nullptr, nullptr, wc.hInstance, nullptr);
// Initialize Direct3D
if (!CreateDeviceD3D(hwnd))
@@ -80,7 +126,9 @@ int main()
style.FontSizeBase = 18.0f;
//io.Fonts->AddFontDefault();
io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
+ //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\seguisym.ttf");
fontBold = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeuib.ttf");
+ fontBig = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeuib.ttf", 36);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf");
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf");
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf");
@@ -91,6 +139,7 @@ int main()
timer_lib_initialize();
administration_writer_create();
+ administration_create_default("");
// Main loop
bool done = false;
diff --git a/src/strops.cpp b/src/strops.cpp
index 6179f82..2c5f0b9 100644
--- a/src/strops.cpp
+++ b/src/strops.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <string.h>
#include <ctype.h>
#include <stdio.h>
diff --git a/src/ui/helpers.cpp b/src/ui/helpers.cpp
index 0a93cf7..07302b7 100644
--- a/src/ui/helpers.cpp
+++ b/src/ui/helpers.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <tinyfiledialogs.h>
#include "ui.hpp"
@@ -6,6 +22,7 @@
#include "strops.hpp"
ImFont* fontBold;
+ImFont* fontBig;
static ui_status current_status;
diff --git a/src/ui/ui_contacts.cpp b/src/ui/ui_contacts.cpp
index cfeb08d..92dd21a 100644
--- a/src/ui/ui_contacts.cpp
+++ b/src/ui/ui_contacts.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/ui/ui_earnings.cpp b/src/ui/ui_earnings.cpp
index 002b2bc..82fe1af 100644
--- a/src/ui/ui_earnings.cpp
+++ b/src/ui/ui_earnings.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/ui/ui_expenses.cpp b/src/ui/ui_expenses.cpp
index d1259a8..b195442 100644
--- a/src/ui/ui_expenses.cpp
+++ b/src/ui/ui_expenses.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <time.h>
diff --git a/src/ui/ui_invoices.cpp b/src/ui/ui_invoices.cpp
index 5ec9297..c3c6b8c 100644
--- a/src/ui/ui_invoices.cpp
+++ b/src/ui/ui_invoices.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <time.h>
diff --git a/src/ui/ui_log.cpp b/src/ui/ui_log.cpp
index 4943548..da0d29d 100644
--- a/src/ui/ui_log.cpp
+++ b/src/ui/ui_log.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <stdio.h>
#include "ui.hpp"
diff --git a/src/ui/ui_main.cpp b/src/ui/ui_main.cpp
index 3405a7e..45b787b 100644
--- a/src/ui/ui_main.cpp
+++ b/src/ui/ui_main.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include "ui.hpp"
#include "imgui.h"
#include "administration.hpp"
@@ -16,7 +32,6 @@ void (*drawcalls[main_state::UI_END])(void) = {
ui_draw_projects,
ui_draw_settings,
ui_draw_log,
- ui_draw_start,
};
void (*setupcalls[main_state::UI_END])(void) = {
@@ -28,7 +43,6 @@ void (*setupcalls[main_state::UI_END])(void) = {
ui_setup_projects,
ui_setup_settings,
0,
- 0,
};
void (*destroycalls[main_state::UI_END])(void) = {
@@ -40,7 +54,6 @@ void (*destroycalls[main_state::UI_END])(void) = {
0,
ui_destroy_settings,
0,
- 0,
};
void ui_set_state(main_state state)
@@ -52,7 +65,7 @@ void ui_set_state(main_state state)
void ui_draw_main()
{
- if (ui_state == main_state::UI_END) ui_set_state(main_state::UI_START);
+ if (ui_state == main_state::UI_END) ui_set_state(main_state::UI_INVOICES);
// @localize
if (ImGui::BeginMainMenuBar())
@@ -61,6 +74,7 @@ void ui_draw_main()
{
if (ImGui::MenuItem("New")) { administration_reader_open_new(); }
if (ImGui::MenuItem("Open")) { administration_reader_open_existing(NULL); }
+ if (ImGui::MenuItem("Save")) { administration_reader_save_new(); }
ImGui::EndMenu();
}
@@ -81,49 +95,43 @@ void ui_draw_main()
ImGui::SetNextWindowPos(ImVec2(0, menuBarHeight));
ImGui::SetNextWindowSize(ImVec2(sidePanelWidth, io.DisplaySize.y - menuBarHeight - statusBarHeight));
- if (ui_state != main_state::UI_START) {
- // Side panel
- ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
- ImGui::Begin("SidePanel", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse);
+ // Side panel
+ ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
+ ImGui::Begin("SidePanel", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse);
+ {
+ // Navigation buttons with custom styling
+ ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); // Transparent background
+ ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f));
+ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); // Reduce spacing between buttons
+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 0.0f));
+
+ float buttonWidth = sidePanelWidth;
+
+ if (ImGui::Button(localize("nav.invoices"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_INVOICES);
+ if (ImGui::Button(localize("nav.expenses"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_EXPENSES);
+ if (ImGui::Button(localize("nav.contacts"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_CONTACTS);
+
+ static bool reports_opened = true;
+ if (ImGui::Button(localize("nav.reports"), ImVec2(buttonWidth, 24))) reports_opened = !reports_opened;
+ if (reports_opened)
{
- // Navigation buttons with custom styling
- ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); // Transparent background
- ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f));
- ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); // Reduce spacing between buttons
- ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 0.0f));
-
- float buttonWidth = sidePanelWidth;
-
- if (ImGui::Button(localize("nav.invoices"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_INVOICES);
- if (ImGui::Button(localize("nav.expenses"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_EXPENSES);
- if (ImGui::Button(localize("nav.contacts"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_CONTACTS);
-
- static bool reports_opened = true;
- if (ImGui::Button(localize("nav.reports"), ImVec2(buttonWidth, 24))) reports_opened = !reports_opened;
- if (reports_opened)
- {
- ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(20.0f, 0.0f));
- if (ImGui::Button(localize("nav.reports.results"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_REPORT_RESULTS);
- if (ImGui::Button(localize("nav.reports.tax"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_REPORT_TAX);
- ImGui::PopStyleVar();
- }
-
- if (ImGui::Button(localize("nav.projects"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_PROJECTS);
- if (ImGui::Button(localize("nav.settings"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_SETTINGS);
-
- ImGui::PopStyleColor(1);
- ImGui::PopStyleVar(3);
+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(20.0f, 0.0f));
+ if (ImGui::Button(localize("nav.reports.results"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_REPORT_RESULTS);
+ if (ImGui::Button(localize("nav.reports.tax"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_REPORT_TAX);
+ ImGui::PopStyleVar();
}
- ImGui::End();
- ImGui::PopStyleVar();
- ImGui::SetNextWindowPos(ImVec2(sidePanelWidth, menuBarHeight));
- ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x - sidePanelWidth, io.DisplaySize.y - menuBarHeight - statusBarHeight));
- }
- else {
- ImGui::SetNextWindowPos(ImVec2(0, 0));
- ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x, io.DisplaySize.y - statusBarHeight));
+ if (ImGui::Button(localize("nav.projects"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_PROJECTS);
+ if (ImGui::Button(localize("nav.settings"), ImVec2(buttonWidth, 24))) ui_set_state(main_state::UI_SETTINGS);
+
+ ImGui::PopStyleColor(1);
+ ImGui::PopStyleVar(3);
}
+ ImGui::End();
+ ImGui::PopStyleVar();
+
+ ImGui::SetNextWindowPos(ImVec2(sidePanelWidth, menuBarHeight));
+ ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x - sidePanelWidth, io.DisplaySize.y - menuBarHeight - statusBarHeight));
// Main content
ImGui::Begin("AccountingMainWindow", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse);
diff --git a/src/ui/ui_projects.cpp b/src/ui/ui_projects.cpp
index 16d04b1..dddf881 100644
--- a/src/ui/ui_projects.cpp
+++ b/src/ui/ui_projects.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <stdio.h>
#include "ui.hpp"
diff --git a/src/ui/ui_settings.cpp b/src/ui/ui_settings.cpp
index 4812502..892e580 100644
--- a/src/ui/ui_settings.cpp
+++ b/src/ui/ui_settings.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/ui/ui_start.cpp b/src/ui/ui_start.cpp
deleted file mode 100644
index 90326f5..0000000
--- a/src/ui/ui_start.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "ui.hpp"
-#include "imgui.h"
-#include "administration.hpp"
-#include "locales.hpp"
-#include "tinyfiledialogs.h"
-#include "administration_writer.hpp"
-#include "administration_reader.hpp"
-
-void ui_draw_start()
-{
- ImVec2 windowSize = ImGui::GetContentRegionAvail();
- ImVec2 buttonSize(windowSize.x * 0.5f, windowSize.y);
-
- ImGui::Columns(2, nullptr, false);
- if (ImGui::Button("Create", buttonSize))
- {
- if (administration_reader_open_new()) {
- ui_set_state(main_state::UI_SETTINGS);
- }
- }
-
- ImGui::NextColumn();
- if (ImGui::Button("Load", buttonSize))
- {
- if (administration_reader_open_existing(NULL)) {
- ui_set_state(main_state::UI_INVOICES);
- }
- }
-
- ImGui::Columns(1);
-} \ No newline at end of file