Files
Hommie_RPG_Game/editor.html
Maxim Dolgolyov fb5f09212b Initial commit: 3D Hommie RPG game
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 01:04:09 +03:00

525 lines
15 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Редактор карты — Бомж RPG</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', Tahoma, sans-serif;
background: #1a1a2e;
color: #ccc;
overflow: hidden;
height: 100vh;
display: flex;
flex-direction: column;
}
/* Toolbar */
#toolbar {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 12px;
background: #16213e;
border-bottom: 1px solid #333;
flex-shrink: 0;
flex-wrap: wrap;
}
#toolbar button {
padding: 5px 14px;
background: #0f3460;
color: #ddd;
border: 1px solid #1a4a8a;
border-radius: 4px;
cursor: pointer;
font-size: 0.8rem;
transition: background 0.2s;
}
#toolbar button:hover { background: #1a5a9a; }
#toolbar button.active { background: #e94560; border-color: #f06; }
.toolbar-sep {
width: 1px;
height: 24px;
background: #333;
margin: 0 4px;
}
#toolbar label {
font-size: 0.75rem;
color: #888;
display: flex;
align-items: center;
gap: 4px;
}
#toolbar input[type="checkbox"] { accent-color: #e94560; }
#toolbar input[type="number"] {
width: 50px;
padding: 2px 4px;
background: #0d1b3e;
color: #ddd;
border: 1px solid #333;
border-radius: 3px;
font-size: 0.75rem;
}
.toolbar-title {
font-size: 0.9rem;
font-weight: 700;
color: #e94560;
margin-right: 12px;
}
/* Main layout */
#main {
display: flex;
flex: 1;
min-height: 0;
}
/* Left panel - object list */
#list-panel {
width: 240px;
background: #16213e;
border-right: 1px solid #333;
overflow-y: auto;
flex-shrink: 0;
font-size: 0.75rem;
}
#list-panel::-webkit-scrollbar { width: 6px; }
#list-panel::-webkit-scrollbar-track { background: #111; }
#list-panel::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
.list-category {
border-bottom: 1px solid #222;
}
.list-category-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 10px;
background: #0f2847;
cursor: pointer;
user-select: none;
font-weight: 600;
font-size: 0.78rem;
}
.list-category-header:hover { background: #133058; }
.list-category-header .cat-icon { margin-right: 6px; }
.list-category-header .cat-count { color: #666; font-weight: 400; font-size: 0.7rem; }
.cat-add-btn {
padding: 1px 8px;
background: #1a5a2a;
color: #8f8;
border: none;
border-radius: 3px;
cursor: pointer;
font-size: 0.75rem;
}
.cat-add-btn:hover { background: #2a7a3a; }
.list-items { display: none; }
.list-items.open { display: block; }
.list-item {
padding: 4px 10px 4px 20px;
cursor: pointer;
display: flex;
align-items: center;
gap: 6px;
border-bottom: 1px solid rgba(255,255,255,0.03);
}
.list-item:hover { background: rgba(255,255,255,0.05); }
.list-item.selected { background: rgba(233,69,96,0.15); color: #fff; }
.list-item .item-icon {
width: 10px;
height: 10px;
border-radius: 2px;
flex-shrink: 0;
}
.list-item .item-coords {
color: #555;
font-size: 0.65rem;
margin-left: auto;
}
/* Canvas area */
#canvas-wrap {
flex: 1;
position: relative;
min-width: 0;
}
#editor-canvas {
display: block;
width: 100%;
height: 100%;
}
/* Right panel - properties */
#props-panel {
width: 240px;
background: #16213e;
border-left: 1px solid #333;
overflow-y: auto;
flex-shrink: 0;
padding: 10px;
font-size: 0.75rem;
}
#props-panel::-webkit-scrollbar { width: 6px; }
#props-panel::-webkit-scrollbar-track { background: #111; }
#props-panel::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
.props-title {
font-size: 0.85rem;
font-weight: 700;
color: #e94560;
margin-bottom: 10px;
padding-bottom: 6px;
border-bottom: 1px solid #333;
}
.props-empty {
color: #555;
text-align: center;
padding: 30px 10px;
font-size: 0.8rem;
}
.prop-group {
margin-bottom: 8px;
}
.prop-label {
color: #888;
font-size: 0.7rem;
margin-bottom: 2px;
}
.prop-input {
width: 100%;
padding: 4px 6px;
background: #0d1b3e;
color: #ddd;
border: 1px solid #333;
border-radius: 3px;
font-size: 0.75rem;
}
.prop-input:focus {
outline: none;
border-color: #e94560;
}
.prop-row {
display: flex;
gap: 6px;
}
.prop-row .prop-group { flex: 1; }
.prop-color {
width: 100%;
height: 28px;
padding: 0;
border: 1px solid #333;
border-radius: 3px;
cursor: pointer;
}
.btn-delete {
width: 100%;
padding: 6px;
background: #8a1a1a;
color: #faa;
border: 1px solid #a33;
border-radius: 4px;
cursor: pointer;
font-size: 0.75rem;
margin-top: 12px;
}
.btn-delete:hover { background: #a33; }
.patrol-list {
margin-top: 6px;
}
.patrol-point {
display: flex;
align-items: center;
gap: 4px;
margin-bottom: 3px;
}
.patrol-point input {
width: 55px;
padding: 2px 4px;
background: #0d1b3e;
color: #ddd;
border: 1px solid #333;
border-radius: 2px;
font-size: 0.7rem;
}
.patrol-remove {
background: none;
border: none;
color: #a55;
cursor: pointer;
font-size: 0.8rem;
padding: 0 4px;
}
.patrol-add {
padding: 2px 8px;
background: #1a3a1a;
color: #8f8;
border: none;
border-radius: 2px;
cursor: pointer;
font-size: 0.7rem;
margin-top: 4px;
}
/* Status bar */
#status-bar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 3px 12px;
background: #0f1a30;
border-top: 1px solid #333;
font-size: 0.7rem;
color: #666;
flex-shrink: 0;
}
/* Help overlay */
#help-overlay {
display: none;
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.7);
z-index: 100;
justify-content: center;
align-items: center;
}
#help-overlay.visible { display: flex; }
.help-box {
background: #1a1a2e;
border: 1px solid #444;
border-radius: 8px;
padding: 24px;
max-width: 500px;
width: 90%;
}
.help-box h2 {
color: #e94560;
margin-bottom: 16px;
font-size: 1.1rem;
}
.help-box table {
width: 100%;
border-collapse: collapse;
}
.help-box td {
padding: 4px 8px;
border-bottom: 1px solid #222;
font-size: 0.8rem;
}
.help-box td:first-child {
color: #f0a040;
font-weight: 600;
width: 140px;
}
.help-box button {
margin-top: 16px;
padding: 6px 20px;
background: #e94560;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<!-- Toolbar -->
<div id="toolbar">
<span class="toolbar-title">Редактор карты</span>
<button id="btn-save" title="Сохранить JSON (скачать)">Сохранить</button>
<button id="btn-load" title="Загрузить JSON из файла">Загрузить</button>
<div class="toolbar-sep"></div>
<label>
<input type="checkbox" id="chk-grid" checked> Сетка
</label>
<label>
Привязка: <input type="number" id="inp-snap" value="1" min="0" max="10" step="1">
</label>
<div class="toolbar-sep"></div>
<label>
<input type="checkbox" id="chk-labels" checked> Подписи
</label>
<label>
<input type="checkbox" id="chk-routes" checked> Маршруты
</label>
<div class="toolbar-sep"></div>
<button id="btn-center" title="Центрировать камеру">Центр</button>
<button id="btn-fit" title="Показать всю карту">Вся карта</button>
<button id="btn-help" title="Показать справку">?</button>
</div>
<!-- Main layout -->
<div id="main">
<div id="list-panel"></div>
<div id="canvas-wrap">
<canvas id="editor-canvas"></canvas>
</div>
<div id="props-panel">
<div class="props-empty">Выберите объект на карте<br>или в списке слева</div>
</div>
</div>
<!-- Status bar -->
<div id="status-bar">
<span id="status-coords">x: 0, z: 0</span>
<span id="status-zoom">Зум: 100%</span>
<span id="status-count">Объектов: 0</span>
</div>
<!-- Help overlay -->
<div id="help-overlay">
<div class="help-box">
<h2>Управление редактором</h2>
<table>
<tr><td>ЛКМ</td><td>Выбрать объект</td></tr>
<tr><td>ЛКМ + тянуть</td><td>Переместить объект</td></tr>
<tr><td>ПКМ + тянуть</td><td>Панорамирование</td></tr>
<tr><td>Колёсико</td><td>Зум (к курсору)</td></tr>
<tr><td>Delete</td><td>Удалить выбранный</td></tr>
<tr><td>Escape</td><td>Снять выделение</td></tr>
<tr><td>Панель слева</td><td>Список объектов, "+" — добавить</td></tr>
<tr><td>Панель справа</td><td>Свойства выбранного объекта</td></tr>
<tr><td>Сохранить</td><td>Скачать map-config.json</td></tr>
<tr><td>Загрузить</td><td>Загрузить JSON из файла</td></tr>
</table>
<button id="btn-close-help">Закрыть</button>
</div>
</div>
<input type="file" id="file-input" accept=".json" style="display:none">
<script type="module">
import { MapEditor } from './js/editor/MapEditor.js';
const canvas = document.getElementById('editor-canvas');
const listPanel = document.getElementById('list-panel');
const propsPanel = document.getElementById('props-panel');
const statusBar = {
coords: document.getElementById('status-coords'),
zoom: document.getElementById('status-zoom'),
count: document.getElementById('status-count')
};
const editor = new MapEditor(canvas, listPanel, propsPanel, statusBar);
// Load config
editor.loadConfigFromFile('data/map-config.json');
// Toolbar buttons
document.getElementById('btn-save').addEventListener('click', () => editor.saveToFile());
document.getElementById('btn-load').addEventListener('click', () => {
document.getElementById('file-input').click();
});
document.getElementById('file-input').addEventListener('change', (e) => {
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = () => {
try {
const json = JSON.parse(reader.result);
editor.loadConfig(json);
} catch (err) {
alert('Ошибка чтения файла: ' + err.message);
}
};
reader.readAsText(file);
e.target.value = '';
});
document.getElementById('chk-grid').addEventListener('change', (e) => {
editor.showGrid = e.target.checked;
});
document.getElementById('inp-snap').addEventListener('input', (e) => {
editor.snapStep = parseFloat(e.target.value) || 0;
});
document.getElementById('chk-labels').addEventListener('change', (e) => {
editor.showLabels = e.target.checked;
});
document.getElementById('chk-routes').addEventListener('change', (e) => {
editor.showRoutes = e.target.checked;
});
document.getElementById('btn-center').addEventListener('click', () => {
editor.camera.x = 0;
editor.camera.z = 0;
});
document.getElementById('btn-fit').addEventListener('click', () => {
editor.camera.x = 0;
editor.camera.z = 0;
editor.camera.zoom = 1.2;
});
// Help
document.getElementById('btn-help').addEventListener('click', () => {
document.getElementById('help-overlay').classList.add('visible');
});
document.getElementById('btn-close-help').addEventListener('click', () => {
document.getElementById('help-overlay').classList.remove('visible');
});
document.getElementById('help-overlay').addEventListener('click', (e) => {
if (e.target === e.currentTarget) {
e.currentTarget.classList.remove('visible');
}
});
</script>
</body>
</html>