Skip to content

Commit

Permalink
Spell name field
Browse files Browse the repository at this point in the history
  • Loading branch information
gdavid04 committed Mar 12, 2024
1 parent af4df19 commit 27fc0ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/grid.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { setPiece } from './piece.mjs';
import { removePiece, createEditor, exportPiece, importPiece } from './piece.mjs';
import './util.mjs';
import { spellData } from './main.mjs';
import { nameField, spellData } from './main.mjs';

export function createGrid(grid, width, height, editor = null, selected = null) {
let cells = [];
Expand Down Expand Up @@ -77,6 +77,7 @@ export function importGrid(from, cells) {
// TODO validation and error messages
spellData.modsRequired = from.modsRequired;
spellData.spellName = from.spellName;
nameField.value = from.spellName;
for (let pieceData of from.spellList) {
setPiece(cells[pieceData.x][pieceData.y], importPiece(pieceData.data));
}
Expand Down
8 changes: 7 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
<div data-piece-name></div>
<div data-piece-desc></div>
</div>
<div class="grid" id="spell-grid"></div>
<div class="vertical">
<div class="grid" id="spell-grid"></div>
<div class="horizontal hjustify">
<div>Name:</div>
<input type="text" id="spell-name" style="width: 80%;">
</div>
</div>
<div class="vertical catalog-container">
<div class="horizontal">
<i class="fa-solid fa-magnifying-glass"></i>
Expand Down
4 changes: 3 additions & 1 deletion src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ await init(wasmUrl);
const size = 9;
export const width = size, height = size;
const grid = document.querySelector('#spell-grid');
export const nameField = document.querySelector('#spell-name');
const search = document.querySelector('#search');
const exportButton = document.querySelector('#export');
const importButton = document.querySelector('#import');
const deleteButton = document.querySelector('#delete');
export let selected = {};
export let editor = { element: document.querySelector('#piece-config'), controls: [], params: [], comment: null };
export let cells = createGrid(grid, width, height, editor, selected);
export let spellData = { spellName: 'PsiEdit', modsRequired: [] };
export let spellData = { spellName: '', modsRequired: [] };
selectCell(cells, selected, 4, 4);

const pieceList = document.querySelector('#piece-catalog');
Expand Down Expand Up @@ -73,6 +74,7 @@ function deletePiece() {
createEditor(editor, selected);
}

nameField.addEventListener('input', () => spellData.spellName = nameField.value);
search.addEventListener('input', filterCatalog);
exportButton.addEventListener('click', exportSpell);
importButton.addEventListener('click', importSpell);
Expand Down

0 comments on commit 27fc0ef

Please sign in to comment.