-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
335 lines (307 loc) · 15.4 KB
/
index.html
File metadata and controls
335 lines (307 loc) · 15.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TacticalGrid - Battlecode Planner by Tariq Tayebi</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script
defer
src="https://cloud.umami.is/script.js"
data-website-id="cf737a12-1727-4214-8c3b-0a91f596eb1d">
</script>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
<!-- Markdown -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<!-- PeerJS for P2P collaboration -->
<script src="https://cdn.jsdelivr.net/npm/peerjs@1.5.2/dist/peerjs.min.js"></script>
<link rel="stylesheet" href="src/style/style.css">
</head>
<body>
<header>
<div class="logo">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 2L2 7L12 12L22 7L12 2Z"/>
<path d="M2 17L12 22L22 17"/>
<path d="M2 12L12 17L22 12"/>
</svg>
<h1>Tactical<span>Grid</span> - Battlecode Planner</h1>
</div>
<div class="header-controls">
<button class="btn-collab" onclick="toggleCollabPanel()" id="collab-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
<circle cx="9" cy="7" r="4"/>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
</svg>
<span id="collab-count">Solo</span>
</button>
<button class="btn-primary" onclick="uploadMap()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15"/>
</svg>
Upload Map
</button>
<button class="btn-secondary" onclick="saveSnapshot()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
<circle cx="8.5" cy="8.5" r="1.5"/>
<polyline points="21 15 16 10 5 21"/>
</svg>
Export
</button>
</div>
</header>
<!-- Collaboration Panel -->
<div id="collab-panel" class="collab-panel">
<div class="collab-header">
<h3>
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
<circle cx="9" cy="7" r="4"/>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
</svg>
Collaboration
</h3>
<button class="close-btn" onclick="toggleCollabPanel()">×</button>
</div>
<div class="collab-content">
<div class="collab-section">
<label>Your Session ID:</label>
<div class="session-id-box">
<input type="text" id="my-session-id" readonly>
<button class="copy-btn" onclick="copySessionId()">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
</svg>
</button>
</div>
<p class="hint">Share this ID with others to collaborate</p>
</div>
<div class="collab-section">
<label>Join Session:</label>
<div class="join-session-box">
<input type="text" id="peer-session-id" placeholder="Enter session ID">
<button class="join-btn" onclick="connectToPeer()">Connect</button>
</div>
</div>
<div class="collab-section">
<label>Connected Users (<span id="peer-count">0</span>):</label>
<div id="connected-peers" class="connected-peers">
<div class="no-peers">No one connected yet</div>
</div>
</div>
<div class="collab-status">
<div class="status-indicator" id="status-indicator"></div>
<span id="status-text">Ready to connect</span>
</div>
</div>
</div>
<main>
<!-- Map Viewport -->
<div class="map-container">
<div class="map-toolbar">
<div class="toolbar-group">
<button class="tool-btn active" onclick="setTool('draw')" data-tool="draw" title="Draw (Shift+D)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 19l7-7 3 3-7 7-3-3z"/>
<path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/>
<path d="M2 2l7.586 7.586"/>
<circle cx="11" cy="11" r="2"/>
</svg>
</button>
<button class="tool-btn" onclick="setTool('erase')" data-tool="erase" title="Erase (Shift+E)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 20H7L3 16L12 7L21 16V20Z"/>
<path d="M12 7L7 12"/>
</svg>
</button>
<button class="tool-btn" onclick="setTool('line')" data-tool="line" title="Line (Shift+L)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="5" y1="19" x2="19" y2="5"/>
</svg>
</button>
<button class="tool-btn" onclick="setTool('arrow')" data-tool="arrow" title="Arrow (Shift+A)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="5" y1="12" x2="19" y2="12"/>
<polyline points="12 5 19 12 12 19"/>
</svg>
</button>
<div class="divider"></div>
<div class="color-picker-wrapper">
<input type="color" id="colorPicker" value="#4fd1c5">
<label for="colorPicker" class="color-label">Color</label>
</div>
<div class="divider"></div>
<button class="tool-btn" onclick="clearDraw()" title="Clear All Drawing">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="3 6 5 6 21 6"/>
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
</svg>
</button>
</div>
<div class="toolbar-group">
<button class="tool-btn" onclick="zoom(1.2)" title="Zoom In (+)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<line x1="8" y1="11" x2="14" y2="11"/>
<line x1="11" y1="8" x2="11" y2="14"/>
<line x1="21" y1="21" x2="16.65" y2="16.65"/>
</svg>
</button>
<button class="tool-btn" onclick="zoom(0.8)" title="Zoom Out (-)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<line x1="8" y1="11" x2="14" y2="11"/>
<line x1="21" y1="21" x2="16.65" y2="16.65"/>
</svg>
</button>
<button class="tool-btn" onclick="resetView()" title="Reset View (R)">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="23 4 23 10 17 10"/>
<path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>
</svg>
</button>
<div class="zoom-display">
<span id="zoom-level">100%</span>
</div>
</div>
</div>
<div id="map-viewport">
<div id="map-world">
<img id="map-image">
<canvas id="draw-layer"></canvas>
</div>
</div>
<div class="minimap" id="minimap">
<canvas id="minimap-canvas"></canvas>
<div id="minimap-viewport"></div>
</div>
</div>
<!-- Sidebar -->
<div id="sidebar">
<div class="sidebar-section">
<h2>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
<line x1="16" y1="13" x2="8" y2="13"/>
<line x1="16" y1="17" x2="8" y2="17"/>
<polyline points="10 9 9 9 8 9"/>
</svg>
Strategy Notes
</h2>
<div class="panel strategy-panel">
<div class="tabs">
<button class="tab-btn active" onclick="setMarkdownMode('edit')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
</svg>
Edit
</button>
<button class="tab-btn" onclick="setMarkdownMode('preview')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
<circle cx="12" cy="12" r="3"/>
</svg>
Preview
</button>
</div>
<textarea id="markdown-input" placeholder="# Opening Strategy
- Early expansion towards resources
- Defensive positioning on high ground
- Scout enemy movements
## Mid Game
- Control key chokepoints
- Maintain unit production
- Coordinate flanking maneuvers"></textarea>
<div id="markdown-preview"></div>
</div>
</div>
<div class="sidebar-section">
<h2>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"/>
<rect x="14" y="3" width="7" height="7"/>
<rect x="14" y="14" width="7" height="7"/>
<rect x="3" y="14" width="7" height="7"/>
</svg>
Map Elements
</h2>
<div class="panel">
<button class="action-btn" onclick="addUnit()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="12" y1="8" x2="12" y2="16"/>
<line x1="8" y1="12" x2="16" y2="12"/>
</svg>
Add Unit Icon
</button>
<button class="action-btn" onclick="addMapText()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
</svg>
Add Text Label
</button>
<button class="action-btn" onclick="addMarker()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/>
<circle cx="12" cy="10" r="3"/>
</svg>
Add Marker
</button>
<div class="unit-upload">
<label for="unit-file-input" class="file-label">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15"/>
</svg>
Upload Unit PNG
</label>
<input type="file" id="unit-file-input" accept="image/png" onchange="loadUnitImage(event)">
<span class="hint" id="unit-filename">No file selected</span>
</div>
</div>
</div>
<div class="sidebar-section">
<h2>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"/>
<path d="M12 1v6m0 6v6M5.64 5.64l4.24 4.24m4.24 4.24l4.24 4.24M1 12h6m6 0h6M5.64 18.36l4.24-4.24m4.24-4.24l4.24-4.24"/>
</svg>
Layers
</h2>
<div class="panel layers-panel">
<div class="layer-item">
<input type="checkbox" id="layer-grid" checked onchange="toggleGrid()">
<label for="layer-grid">Grid Overlay</label>
</div>
<div class="layer-item">
<input type="checkbox" id="layer-units" checked onchange="toggleUnits()">
<label for="layer-units">Units</label>
</div>
<div class="layer-item">
<input type="checkbox" id="layer-drawings" checked onchange="toggleDrawings()">
<label for="layer-drawings">Drawings</label>
</div>
</div>
</div>
<footer>
<div class="shortcuts">
<strong>Shortcuts:</strong> WASD/Arrows Pan • Scroll/+/- Zoom • Shift+D/E/L/A Tools • Ctrl+Z Undo • R Reset
</div>
<div class="credits">
Real-Time Collaborative Planning Tool
</div>
</footer>
</div>
</main>
<script type="module" src="src/javascript/planner.js"></script></body>
</html>