设置开关bug+关于本机(agent-104: SET_INT开关get_switch/set_switch修复+落盘确认+关于本机弹窗) + Hello通知/全屏按钮(agent-105)
This commit is contained in:
1 parent
a2673d5922
commit
9b3842534c
6 files changed
+303
-11
No files matched your search
@@ -501,6 +501,40 @@ int meow_settings_set_bool(const char *key, int v)
|
||||
return MEOW_OK;
|
||||
}
|
||||
|
||||
/* ---- 开关型(M2.5x)----
|
||||
* 开关 = SET_BOOL,或 SET_INT 且取值域恰为 {0,1}(如 display.multi_font / font.load_full,
|
||||
* 见 SYSTEM_SETTINGS §1「int 0/1」)。实体设置页 SC_SWITCH 与字体逻辑用通用读写,
|
||||
* 避免对 SET_INT 开关误用 get_bool/set_bool(类型不符必失败 → 点不动/恒 OFF/6 类行恒隐藏)。 */
|
||||
static int is_switch_like(meow_setting *s)
|
||||
{
|
||||
if (!s) return 0;
|
||||
if (s->type == SET_BOOL) return 1;
|
||||
if (s->type == SET_INT && s->min == 0 && s->max == 1) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int meow_settings_get_switch(const char *key, int *out)
|
||||
{
|
||||
meow_setting *s = find_set(key);
|
||||
if (!s) return MEOW_ERR_NOENT;
|
||||
if (!g_inited) return MEOW_ERR_NOTINIT;
|
||||
if (!out) return MEOW_ERR_INVAL;
|
||||
if (!is_switch_like(s)) return MEOW_ERR_INVAL;
|
||||
if (s->type == SET_BOOL) *out = (s->cur[0] == '1');
|
||||
else *out = (atoi(s->cur) != 0);
|
||||
return MEOW_OK;
|
||||
}
|
||||
|
||||
int meow_settings_set_switch(const char *key, int v)
|
||||
{
|
||||
meow_setting *s = find_set(key);
|
||||
if (!s) return MEOW_ERR_NOENT;
|
||||
if (!g_inited) return MEOW_ERR_NOTINIT;
|
||||
if (!is_switch_like(s)) return MEOW_ERR_INVAL;
|
||||
if (s->type == SET_BOOL) return meow_settings_set_bool(key, v);
|
||||
return meow_settings_set_int(key, v ? 1 : 0); /* SET_INT 0/1:写 0/1(clamp 到 {0,1}) */
|
||||
}
|
||||
|
||||
/* ---- listener ---- */
|
||||
int meow_settings_add_listener(meow_settings_listener cb)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user