Skip to content

Commit

Permalink
✨ 增加逻辑节点面板
Browse files Browse the repository at this point in the history
  • Loading branch information
Littlefean committed Jan 23, 2025
1 parent 73a6ee6 commit 5b3db26
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/service/autoComputeEngine/mainTick.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ export function autoComputeEngineTick(tickNumber: number) {
return;
}
}

// 用于显示逻辑节点执行顺序标号
let i = 0;

let nodes = StageManager.getTextNodes().filter(
Expand Down
16 changes: 16 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ChevronDown,
ChevronLeft,
ChevronUp,
Cpu,
Diamond,
Menu,
RectangleEllipsis,
Expand Down Expand Up @@ -39,6 +40,7 @@ import ExportTreeTextPanel from "./_export_text_panel";
import RecentFilesPanel from "./_recent_files_panel";
import StartFilePanel from "./_start_file_panel";
import TagPanel from "./_tag_panel";
import LogicNodePanel from "./_logic_node_panel";

export default function App() {
const [maxmized, setMaxmized] = React.useState(false);
Expand All @@ -48,6 +50,7 @@ export default function App() {
const [isStartFilePanelOpen, setIsStartFilePanelOpen] = React.useState(false);
const [isAiPanelOpen, setIsAiPanelOpen] = React.useState(false);
const [isTagPanelOpen, setIsTagPanelOpen] = React.useState(false);
const [isLogicNodePanelOpen, setIsLogicNodePanelOpen] = React.useState(false);
const [ignoreMouse, setIgnoreMouse] = React.useState(false);

const navigate = useNavigate();
Expand Down Expand Up @@ -299,6 +302,17 @@ export default function App() {
className={cn("cursor-pointer", isTagPanelOpen ? "rotate-90" : "")}
/>
</IconButton>
{/* 逻辑节点按钮 */}
<IconButton
onClick={(e) => {
e.stopPropagation();
setIsLogicNodePanelOpen(!isLogicNodePanelOpen);
}}
>
<Cpu
className={cn("cursor-pointer", isAiPanelOpen ? "rotate-90" : "")}
/>
</IconButton>
{/* 中间标题 */}
{useNativeTitleBar || isWeb ? (
// h-0 才能完全摆脱划线时经过此区域的卡顿问题
Expand Down Expand Up @@ -331,6 +345,7 @@ export default function App() {
)}
</>
)}

{/* 右上角AI按钮 */}
<IconButton
onClick={(e) => {
Expand Down Expand Up @@ -387,6 +402,7 @@ export default function App() {
{/* 面板列表 */}
<AppMenu className="absolute left-4 top-16 z-20" open={isMenuOpen} />
<TagPanel open={isTagPanelOpen} className="z-10" />
<LogicNodePanel open={isLogicNodePanelOpen} className="z-10" />
<StartFilePanel open={isStartFilePanelOpen} />
<AiPanel open={isAiPanelOpen} />
<RecentFilesPanel />
Expand Down
55 changes: 55 additions & 0 deletions src/pages/_logic_node_panel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { v4 } from "uuid";
import Button from "../components/ui/Button";
import {
LogicNodeNameEnum,
LogicNodeNameToRenderNameMap,
} from "../core/service/autoComputeEngine/logicNodeNameEnum";
import { StageManager } from "../core/stage/stageManager/StageManager";
import { TextNode } from "../core/stage/stageObject/entity/TextNode";
import { cn } from "../utils/cn";
import { Camera } from "../core/stage/Camera";

/**
*
*/
export default function LogicNodePanel({
open = false,
className = "",
}: {
open: boolean;
className: string;
}) {
return (
<div
className={cn(
"fixed -left-64 top-16 flex h-96 w-64 flex-col overflow-auto rounded-md bg-neutral-900 p-2 transition-all",
{
"left-0": open,
},
className,
)}
>
<h2>逻辑节点</h2>
{Object.values(LogicNodeNameEnum).map((name) => {
return (
<Button
key={name}
className="m-1 text-xs"
onClick={() => {
StageManager.addTextNode(
new TextNode({
uuid: v4(),
location: [Camera.location.x, Camera.location.y],
text: name,
size: [10, 10],
}),
);
}}
>
{LogicNodeNameToRenderNameMap[name]}
</Button>
);
})}
</div>
);
}

0 comments on commit 5b3db26

Please sign in to comment.