Skip to content

Commit c7553d4

Browse files
committed
feat(config): unfiy style configuration files into one
1 parent d0f541d commit c7553d4

File tree

15 files changed

+86
-211
lines changed

15 files changed

+86
-211
lines changed

include/config.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,7 @@ typedef struct {
233233
int opacity_step_fast;
234234
int scale_step_normal;
235235
int scale_step_fast;
236-
BOOL glow_effect;
237-
BOOL glass_effect;
238-
BOOL neon_effect;
239-
BOOL holographic_effect;
240-
BOOL liquid_effect;
236+
int text_effect; /* TextEffectType enum value */
241237
} DisplayConfig;
242238

243239
/**

include/config/config_loader.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ typedef struct {
4949
int opacityStepFast;
5050
int scaleStepNormal;
5151
int scaleStepFast;
52-
BOOL glowEffect;
53-
BOOL glassEffect;
54-
BOOL neonEffect;
55-
BOOL holographicEffect;
56-
BOOL liquidEffect;
52+
int textEffect; /* TextEffectType enum value */
5753

5854
/* Timer */
5955
int defaultStartTime;

include/window.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313
#ifndef WINDOW_H
1414
#define WINDOW_H
1515

16-
/* Global effect flags */
17-
extern BOOL CLOCK_GLOW_EFFECT;
18-
extern BOOL CLOCK_GLASS_EFFECT;
19-
extern BOOL CLOCK_NEON_EFFECT;
20-
extern BOOL CLOCK_HOLOGRAPHIC_EFFECT;
21-
extern BOOL CLOCK_LIQUID_EFFECT;
22-
23-
/* Global configuration variables */
24-
2516
/* Include all window module headers */
2617
#include "window/window_core.h"
2718
#include "window/window_visual_effects.h"

include/window/window_core.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,25 @@ extern BOOL CLOCK_TEXT_RECT_VALID;
3030
extern float CLOCK_FONT_SCALE_FACTOR;
3131
extern float PLUGIN_FONT_SCALE_FACTOR;
3232
extern int CLOCK_BASE_FONT_SIZE;
33-
extern BOOL CLOCK_GLOW_EFFECT;
34-
extern BOOL CLOCK_GLASS_EFFECT;
35-
extern BOOL CLOCK_NEON_EFFECT;
33+
34+
/* Text effect type enumeration */
35+
typedef enum {
36+
TEXT_EFFECT_NONE = 0,
37+
TEXT_EFFECT_GLOW,
38+
TEXT_EFFECT_GLASS,
39+
TEXT_EFFECT_NEON,
40+
TEXT_EFFECT_HOLOGRAPHIC,
41+
TEXT_EFFECT_LIQUID
42+
} TextEffectType;
43+
44+
extern TextEffectType CLOCK_TEXT_EFFECT;
45+
46+
/* Legacy compatibility macros - map old BOOL checks to new enum */
47+
#define CLOCK_GLOW_EFFECT (CLOCK_TEXT_EFFECT == TEXT_EFFECT_GLOW)
48+
#define CLOCK_GLASS_EFFECT (CLOCK_TEXT_EFFECT == TEXT_EFFECT_GLASS)
49+
#define CLOCK_NEON_EFFECT (CLOCK_TEXT_EFFECT == TEXT_EFFECT_NEON)
50+
#define CLOCK_HOLOGRAPHIC_EFFECT (CLOCK_TEXT_EFFECT == TEXT_EFFECT_HOLOGRAPHIC)
51+
#define CLOCK_LIQUID_EFFECT (CLOCK_TEXT_EFFECT == TEXT_EFFECT_LIQUID)
3652

3753
/* ============================================================================
3854
* Public API

src/config/config_applier.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
#include <time.h>
2020
#include <math.h>
2121

22-
/* Global effect flags */
23-
extern BOOL CLOCK_GLOW_EFFECT;
24-
extern BOOL CLOCK_GLASS_EFFECT;
25-
extern BOOL CLOCK_NEON_EFFECT;
26-
extern BOOL CLOCK_HOLOGRAPHIC_EFFECT;
22+
/* Global text effect */
23+
extern TextEffectType CLOCK_TEXT_EFFECT;
2724

2825
/* ============================================================================
2926
* Helper: Language enum mapping
@@ -118,16 +115,8 @@ void ApplyDisplaySettings(const ConfigSnapshot* snapshot) {
118115
g_AppConfig.display.opacity_step_fast = snapshot->opacityStepFast;
119116
g_AppConfig.display.scale_step_normal = snapshot->scaleStepNormal;
120117
g_AppConfig.display.scale_step_fast = snapshot->scaleStepFast;
121-
CLOCK_GLOW_EFFECT = snapshot->glowEffect;
122-
CLOCK_GLASS_EFFECT = snapshot->glassEffect;
123-
CLOCK_NEON_EFFECT = snapshot->neonEffect;
124-
CLOCK_HOLOGRAPHIC_EFFECT = snapshot->holographicEffect;
125-
CLOCK_LIQUID_EFFECT = snapshot->liquidEffect;
126-
g_AppConfig.display.glow_effect = snapshot->glowEffect;
127-
g_AppConfig.display.glass_effect = snapshot->glassEffect;
128-
g_AppConfig.display.neon_effect = snapshot->neonEffect;
129-
g_AppConfig.display.holographic_effect = snapshot->holographicEffect;
130-
g_AppConfig.display.liquid_effect = snapshot->liquidEffect;
118+
CLOCK_TEXT_EFFECT = (TextEffectType)snapshot->textEffect;
119+
g_AppConfig.display.text_effect = snapshot->textEffect;
131120

132121
HWND hwnd = FindWindowW(L"CatimeWindowClass", L"Catime");
133122
if (hwnd) {

src/config/config_defaults.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ static const ConfigItemMeta CONFIG_METADATA[] = {
4949
{INI_SECTION_DISPLAY, "OPACITY_STEP_FAST", "5", CONFIG_TYPE_INT, "Opacity Ctrl+scroll step (1-100)"},
5050
{INI_SECTION_DISPLAY, "SCALE_STEP_NORMAL", "10", CONFIG_TYPE_INT, "Scale scroll step (1-100)"},
5151
{INI_SECTION_DISPLAY, "SCALE_STEP_FAST", "15", CONFIG_TYPE_INT, "Scale Ctrl+scroll step (1-100)"},
52-
{INI_SECTION_DISPLAY, "TEXT_GLOW_EFFECT", "FALSE", CONFIG_TYPE_BOOL, "Enable neon glow effect"},
53-
{INI_SECTION_DISPLAY, "TEXT_GLASS_EFFECT", "FALSE", CONFIG_TYPE_BOOL, "Enable optical prism effect"},
54-
{INI_SECTION_DISPLAY, "TEXT_NEON_EFFECT", "FALSE", CONFIG_TYPE_BOOL, "Enable Hong Kong neon tube effect"},
55-
{INI_SECTION_DISPLAY, "TEXT_HOLOGRAPHIC_EFFECT", "FALSE", CONFIG_TYPE_BOOL, "Enable holographic dispersion effect"},
56-
{INI_SECTION_DISPLAY, "TEXT_LIQUID_EFFECT", "FALSE", CONFIG_TYPE_BOOL, "Enable liquid flow/caustics effect"},
52+
{INI_SECTION_DISPLAY, "TEXT_EFFECT", "NONE", CONFIG_TYPE_ENUM, "Text effect style (NONE/GLOW/GLASS/NEON/HOLOGRAPHIC/LIQUID)"},
5753

5854
/* Timer settings */
5955
{INI_SECTION_TIMER, "CLOCK_DEFAULT_START_TIME", "1500", CONFIG_TYPE_INT, "Default timer duration (seconds)"},

src/config/config_loader.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "config/config_recovery.h"
88
#include "config/config_defaults.h"
99
#include "config.h"
10+
#include "window/window_core.h"
1011
#include "log.h"
1112
#include "../resource/resource.h"
1213
#include <stdio.h>
@@ -182,11 +183,7 @@ void InitializeDefaultSnapshot(ConfigSnapshot* snapshot) {
182183
snapshot->opacityStepFast = 5;
183184
snapshot->scaleStepNormal = DEFAULT_SCALE_STEP_NORMAL;
184185
snapshot->scaleStepFast = DEFAULT_SCALE_STEP_FAST;
185-
snapshot->glowEffect = FALSE;
186-
snapshot->glassEffect = FALSE;
187-
snapshot->neonEffect = FALSE;
188-
snapshot->holographicEffect = FALSE;
189-
snapshot->liquidEffect = FALSE;
186+
snapshot->textEffect = TEXT_EFFECT_NONE;
190187
snapshot->defaultStartTime = DEFAULT_START_TIME_SECONDS;
191188
snapshot->notificationTimeoutMs = DEFAULT_NOTIFICATION_TIMEOUT_MS;
192189
snapshot->notificationMaxOpacity = DEFAULT_NOTIFICATION_MAX_OPACITY;
@@ -260,17 +257,25 @@ BOOL LoadConfigFromFile(const char* config_path, ConfigSnapshot* snapshot) {
260257
DEFAULT_SCALE_STEP_NORMAL, config_path);
261258
snapshot->scaleStepFast = ReadIniInt(INI_SECTION_DISPLAY, "SCALE_STEP_FAST",
262259
DEFAULT_SCALE_STEP_FAST, config_path);
263-
snapshot->glowEffect = ReadIniBool(INI_SECTION_DISPLAY, "TEXT_GLOW_EFFECT",
264-
FALSE, config_path);
265-
snapshot->glassEffect = ReadIniBool(INI_SECTION_DISPLAY, "TEXT_GLASS_EFFECT",
266-
FALSE, config_path);
267-
snapshot->neonEffect = ReadIniBool(INI_SECTION_DISPLAY, "TEXT_NEON_EFFECT",
268-
FALSE, config_path);
269-
snapshot->holographicEffect = ReadIniBool(INI_SECTION_DISPLAY, "TEXT_HOLOGRAPHIC_EFFECT",
270-
FALSE, config_path);
271-
snapshot->liquidEffect = ReadIniBool(INI_SECTION_DISPLAY, "TEXT_LIQUID_EFFECT",
272-
FALSE, config_path);
273-
260+
261+
/* Read text effect as enum */
262+
char textEffectStr[32] = {0};
263+
ReadIniString(INI_SECTION_DISPLAY, "TEXT_EFFECT", "NONE",
264+
textEffectStr, sizeof(textEffectStr), config_path);
265+
if (_stricmp(textEffectStr, "GLOW") == 0) {
266+
snapshot->textEffect = TEXT_EFFECT_GLOW;
267+
} else if (_stricmp(textEffectStr, "GLASS") == 0) {
268+
snapshot->textEffect = TEXT_EFFECT_GLASS;
269+
} else if (_stricmp(textEffectStr, "NEON") == 0) {
270+
snapshot->textEffect = TEXT_EFFECT_NEON;
271+
} else if (_stricmp(textEffectStr, "HOLOGRAPHIC") == 0) {
272+
snapshot->textEffect = TEXT_EFFECT_HOLOGRAPHIC;
273+
} else if (_stricmp(textEffectStr, "LIQUID") == 0) {
274+
snapshot->textEffect = TEXT_EFFECT_LIQUID;
275+
} else {
276+
snapshot->textEffect = TEXT_EFFECT_NONE;
277+
}
278+
274279
/* Read Timer section */
275280
snapshot->defaultStartTime = ReadIniInt(INI_SECTION_TIMER, "CLOCK_DEFAULT_START_TIME",
276281
1500, config_path);

src/drawing/drawing_render.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "timer/timer.h"
1717
#include "config.h"
1818
#include "window_procedure/window_procedure.h"
19+
#include "window/window_core.h"
1920
#include "menu_preview.h"
2021
#include "font/font_path_manager.h"
2122
#include "log.h"
@@ -567,10 +568,7 @@ void HandleWindowPaint(HWND hwnd, PAINTSTRUCT* ps) {
567568

568569
/* Dynamic timer interval adjustment based on current window size */
569570
/* This ensures smooth animation for small windows, reduced lag for large windows */
570-
extern BOOL CLOCK_GLOW_EFFECT, CLOCK_GLASS_EFFECT, CLOCK_NEON_EFFECT;
571-
extern BOOL CLOCK_HOLOGRAPHIC_EFFECT, CLOCK_LIQUID_EFFECT;
572-
573-
if (CLOCK_LIQUID_EFFECT || CLOCK_HOLOGRAPHIC_EFFECT ||
571+
if (CLOCK_LIQUID_EFFECT || CLOCK_HOLOGRAPHIC_EFFECT ||
574572
CLOCK_NEON_EFFECT || CLOCK_GLOW_EFFECT || CLOCK_GLASS_EFFECT) {
575573
static UINT s_lastInterval = 0;
576574
int pixelCount = rect.right * rect.bottom;

src/menu_preview.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "color/color_parser.h"
1414
#include "timer/timer.h"
1515
#include "tray/tray_animation_core.h"
16+
#include "window/window_core.h"
1617
#include "log.h"
1718

1819
/* ============================================================================
@@ -29,13 +30,6 @@ extern BOOL IS_PREVIEWING;
2930
extern char PREVIEW_FONT_NAME[MAX_PATH];
3031
extern char PREVIEW_INTERNAL_NAME[MAX_PATH];
3132

32-
/* Effect global flags */
33-
extern BOOL CLOCK_GLOW_EFFECT;
34-
extern BOOL CLOCK_GLASS_EFFECT;
35-
extern BOOL CLOCK_NEON_EFFECT;
36-
extern BOOL CLOCK_HOLOGRAPHIC_EFFECT;
37-
extern BOOL CLOCK_LIQUID_EFFECT;
38-
3933
extern void ResetTimerWithInterval(HWND hwnd);
4034
extern void WriteConfigColor(const char* color);
4135
extern void WriteConfigFont(const char* fontName, BOOL isCustom);

src/timer/timer_events.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ static BOOL HandleMainTimer(HWND hwnd) {
506506
DWORD now = GetTickCount();
507507
BOOL shouldRender = TRUE;
508508

509-
extern BOOL CLOCK_HOLOGRAPHIC_EFFECT;
510509
if (CLOCK_HOLOGRAPHIC_EFFECT) {
511510
RECT rect;
512511
GetClientRect(hwnd, &rect);

0 commit comments

Comments
 (0)