1 | import { useEffect, useState } from "react";
|
---|
2 | import { MapBuilder } from "../../scripts/main/MapBuilder.js";
|
---|
3 | import styles from "./Draw.module.css";
|
---|
4 | import RoomModal from "../../components/RoomModal/RoomModal.jsx";
|
---|
5 | import SideBar from "../../components/SideBar/SideBar.jsx";
|
---|
6 | import EntranceModal from "../../components/EntranceModal/EntranceModal.jsx";
|
---|
7 | import DrawGuide from "../../components/DrawGuide/DrawGuide.jsx";
|
---|
8 | import RoomTypeModal from "../../components/RoomTypeModal/RoomTypeModal.jsx";
|
---|
9 | import InfoPinModal from "../../components/InfoPinModal/InfoPinModal.jsx";
|
---|
10 | import HttpService from "../../scripts/net/HttpService.js";
|
---|
11 | import SaveMap from "../../components/SaveMap/SaveMap.jsx";
|
---|
12 | import logo from "../../assets/logo_icon.png";
|
---|
13 | import MapTemplateSelector from "../../components/MapTemplateSelector/LoadMap.jsx";
|
---|
14 | import KeymapPanel from "../../components/KeyMappingsGuidePanel/KeymapPanel.jsx";
|
---|
15 | import { Link } from "react-router-dom";
|
---|
16 |
|
---|
17 | function Draw() {
|
---|
18 | const [selectedFloor, setSelectedFloor] = useState(1);
|
---|
19 | const [app, setApp] = useState(null);
|
---|
20 | const [isPopupVisible, setIsPopupVisible] = useState(false);
|
---|
21 | useEffect(() => {
|
---|
22 | const app = new MapBuilder("container");
|
---|
23 | setApp(app);
|
---|
24 | // fpsCounterLoop();
|
---|
25 | }, []);
|
---|
26 |
|
---|
27 | const handleFloorChange = (event) => {
|
---|
28 | setSelectedFloor(event.target.value);
|
---|
29 | console.log(`Floor changed to: ${event.target.value}`);
|
---|
30 | };
|
---|
31 |
|
---|
32 | const handleRenderClick = () => {
|
---|
33 | setIsPopupVisible(true);
|
---|
34 |
|
---|
35 | setTimeout(() => {
|
---|
36 | setIsPopupVisible(false);
|
---|
37 | }, 3000);
|
---|
38 | };
|
---|
39 |
|
---|
40 | const handleSaveClick = async (mapName) => {
|
---|
41 | const resp = await app.saveMap(mapName);
|
---|
42 | };
|
---|
43 | const handleLoadMapClick = (data) => {
|
---|
44 | app.deserializeMap(data);
|
---|
45 | };
|
---|
46 |
|
---|
47 | return (
|
---|
48 | <div className={styles.wrapper} id="wrapper">
|
---|
49 | <SideBar></SideBar>
|
---|
50 | <div id="container" className={styles.cont}></div>
|
---|
51 | <div className={styles.panel}>
|
---|
52 | <Link to="/">
|
---|
53 | <img src={logo} alt="Finki Logo" className={styles.logo} />
|
---|
54 | </Link>
|
---|
55 | <h1 className={styles.title}>Map Builder</h1>
|
---|
56 | {/* <div id="fpscont" className={styles.fpscounter}>
|
---|
57 | <p id="fpsCounter"></p>
|
---|
58 | </div> */}
|
---|
59 | <div className={styles.guideWrapper}>
|
---|
60 | <DrawGuide />
|
---|
61 | </div>
|
---|
62 |
|
---|
63 | {/* <div className={styles.floorSelector}>
|
---|
64 | <label htmlFor="floorSelect">Select Floor:</label>
|
---|
65 | <select
|
---|
66 | id="floorSelect"
|
---|
67 | value={selectedFloor}
|
---|
68 | onChange={handleFloorChange}
|
---|
69 | className={styles.floorDropdown}
|
---|
70 | >
|
---|
71 | <option value={1}>1st Floor</option>
|
---|
72 | <option value={2}>2nd Floor</option>
|
---|
73 | <option value={3}>3rd Floor</option>
|
---|
74 | <option value={4}>4th Floor</option>
|
---|
75 | </select>
|
---|
76 | </div> */}
|
---|
77 | {/* <h2 className={styles.paragraph}>Objects:</h2> */}
|
---|
78 | <ul className={styles.shapeOptions} id="shapeOptions">
|
---|
79 | <li data-info="Entrance" className={`${styles.shapeOption} ${styles.entrance}`}></li>
|
---|
80 | <li data-info="Wall" className={`${styles.shapeOption} ${styles.wall}`} id="wall"></li>
|
---|
81 | <li data-info="Room" className={`${styles.shapeOption} ${styles.room}`} id="room"></li>
|
---|
82 | </ul>
|
---|
83 | <br />
|
---|
84 | <RoomTypeModal map={app}></RoomTypeModal>
|
---|
85 |
|
---|
86 | <div id="render" className={styles.buttonContainer}>
|
---|
87 | <button
|
---|
88 | id="render-button"
|
---|
89 | type="button"
|
---|
90 | className={styles.renderButton}
|
---|
91 | onClick={handleRenderClick}
|
---|
92 | >
|
---|
93 | Render
|
---|
94 | </button>
|
---|
95 | </div>
|
---|
96 | <div className={styles.templateCont}>
|
---|
97 | <SaveMap submitHandler={handleSaveClick}></SaveMap>
|
---|
98 | <MapTemplateSelector loadHandler={handleLoadMapClick}></MapTemplateSelector>
|
---|
99 | </div>
|
---|
100 |
|
---|
101 | <div className={styles.hide}>
|
---|
102 | <RoomModal map={app}></RoomModal>
|
---|
103 | <EntranceModal map={app}></EntranceModal>
|
---|
104 | <InfoPinModal map={app}></InfoPinModal>
|
---|
105 | </div>
|
---|
106 | </div>
|
---|
107 |
|
---|
108 | {isPopupVisible && (
|
---|
109 | <div className={styles.popup}>
|
---|
110 | <div className={styles.popupContent}>
|
---|
111 | <h2>Map Rendered!</h2>
|
---|
112 | <p>Your map has been successfully rendered.</p>
|
---|
113 | </div>
|
---|
114 | </div>
|
---|
115 | )}
|
---|
116 | </div>
|
---|
117 | );
|
---|
118 | }
|
---|
119 |
|
---|
120 | export default Draw;
|
---|