@@ -295,7 +295,36 @@ void Module::removeKeybind()
295295
296296void Module::onKeybindActivated (KeyState state)
297297{
298- this ->setUserEnabled (!getUserEnabled ());
298+ bool en = getUserEnabled ();
299+
300+ switch (keyConfig.type )
301+ {
302+ case KeybindType::Toggle:
303+ en = !getUserEnabled ();
304+
305+ if (!state.isDown && !state.isRepeat )
306+ return ;
307+ break ;
308+
309+ case KeybindType::Hold:
310+ en = state.isDown ;
311+
312+ if (state.isRepeat )
313+ return ;
314+ break ;
315+
316+ case KeybindType::HoldInverted:
317+ en = !state.isDown ;
318+
319+ if (state.isRepeat )
320+ return ;
321+ break ;
322+ }
323+
324+ if (getUserEnabled () == en)
325+ return ;
326+
327+ this ->setUserEnabled (en);
299328
300329 onToggle ();
301330 ModuleNode::updateAllNodes (nullptr );
@@ -346,6 +375,7 @@ void Module::saveShortcutConfig()
346375 conf[" colour_opacity" ] = shortcutConf.colour .opacity ;
347376 conf[" colour_chromaspeed" ] = shortcutConf.colour .chromaSpeed ;
348377 conf[" colour_type" ] = (int )shortcutConf.colour .type ;
378+ conf[" animation" ] = (int )shortcutConf.animation ;
349379
350380 Mod::get ()->setSavedValue <matjson::Value>(fmt::format (" {}_shortcutconf" , getID ()), conf);
351381}
@@ -375,6 +405,7 @@ void Module::loadShortcutConfig()
375405 conf.colour .opacity = json[" colour_opacity" ].asDouble ().unwrapOr (1 );
376406 conf.colour .chromaSpeed = json[" colour_chromaspeed" ].asDouble ().unwrapOr (1 );
377407 conf.colour .type = (ColourConfigType)json[" colour_type" ].asInt ().unwrapOr (0 );
408+ conf.animation = (FloatingButtonAnimationType)json[" animation" ].asInt ().unwrapOr (0 );
378409
379410 setShortcutConfig (Mod::get ()->getSavedValue <bool >(fmt::format (" {}_shortcutenabled" , getID ()), false ), conf);
380411}
@@ -399,6 +430,7 @@ void Module::setShortcutConfig(bool enabled, ModuleShortcutConfig conf)
399430 btn->setMovable (shortcutConf.isMovable );
400431 btn->setBaseScale (shortcutConf.scale );
401432 btn->setBaseOpacity (shortcutConf.opacity );
433+ btn->setAnimation (shortcutConf.animation );
402434
403435 shortcutNode = btn;
404436 }
0 commit comments