Skip to content

Commit

Permalink
🔊Enhanced some logs
Browse files Browse the repository at this point in the history
carefree0910 committed Nov 12, 2024
1 parent 483d034 commit d0b272c
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cfb-web/src/plugins/shortcuts.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ export class WebShortcutsPlugin implements IPlugin {
if (checkKeys(e, ["control", "z"])) {
const executer = e.world.getPlugin(ExecuterPlugin);
if (!executer) {
Logger.warn("`undo` failed: `ExecuterPlugin` is not found in the world");
Logger.error("`undo` failed: `ExecuterPlugin` is not found in the world");
} else {
if (executer.canUndo()) {
executer.undo();
@@ -23,7 +23,7 @@ export class WebShortcutsPlugin implements IPlugin {
} else if (checkKeys(e, ["control", "shift", "z"])) {
const executer = e.world.getPlugin(ExecuterPlugin);
if (!executer) {
Logger.warn("`redo` failed: `ExecuterPlugin` is not found in the world");
Logger.error("`redo` failed: `ExecuterPlugin` is not found in the world");
} else {
if (executer.canRedo()) {
executer.redo();
6 changes: 4 additions & 2 deletions cfb-web/src/plugins/zoom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IPlugin } from "@carefree0910/cfb-core";
import type { WebWorld } from "../world.ts";

import { Point, wheelEvent } from "@carefree0910/cfb-core";
import { Logger, Point, wheelEvent } from "@carefree0910/cfb-core";
import { getNormalizedWheelDelta } from "./utils.ts";
import { WebKeyboardPlugin } from "./keyboard.ts";

@@ -10,7 +10,9 @@ export class WebZoomPlugin implements IPlugin {
wheelEvent.on((e) => {
const world = e.world as WebWorld;
const keyboard = world.getPlugin(WebKeyboardPlugin);
if (keyboard) {
if (!keyboard) {
Logger.error("cannot find `keyboard` plugin, `zoom` plugin will not work");
} else {
const status = keyboard.getStatus();
if (status.ctrlKey || status.metaKey) {
const deltaY = getNormalizedWheelDelta(e.e, 25).y;

0 comments on commit d0b272c

Please sign in to comment.