Improve edit screen
This commit is contained in:
parent
52770d7eb2
commit
826986cdbf
12 changed files with 235 additions and 40 deletions
|
@ -1,10 +1,12 @@
|
|||
import * as gui from './index.mjs';
|
||||
import {message as editMessage} from '../game/edit.mjs';
|
||||
import {images as assets} from '../assets.mjs';
|
||||
import {canvas} from '../graphics/index.mjs';
|
||||
import GuiFrame from './frame.mjs';
|
||||
import GuiImage from './image.mjs';
|
||||
import GuiButton from './button.mjs';
|
||||
import GuiEdit from './edit.mjs';
|
||||
import GuiText from './text.mjs';
|
||||
import GuiInventory from './inventory.mjs';
|
||||
import * as events from '../game/events.mjs';
|
||||
import {state} from '../game/index.mjs';
|
||||
|
@ -40,19 +42,52 @@ export function title() {
|
|||
export function game() {
|
||||
let shadow = root();
|
||||
|
||||
let editButton = new GuiButton('Edit rocket', events.editShip, 0, 0, 200);
|
||||
let editButton = new GuiButton('Edit rocket', events.toggleEdit, 0, 0, 200);
|
||||
shadow.append(editButton);
|
||||
editButton.posRelative({ x: 0.5, xc: 0.5, y: 1 });
|
||||
editButton.y -= 45;
|
||||
editButton.tick = () => {
|
||||
editButton.options.draw = state.landed && !state.editing;
|
||||
editButton.options.draw = state.landed;
|
||||
editButton.options.disabled = state.editing && editMessage !== '';
|
||||
if (state.editing) {
|
||||
editButton.text = 'Finish';
|
||||
} else {
|
||||
editButton.text = 'Edit rocket';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let editShadow = root();
|
||||
shadow.append(editShadow);
|
||||
editShadow.posRelative({x: 0.45, y: 0, w: 0.55, h: 0.6});
|
||||
editShadow.x -= 10;
|
||||
editShadow.y += 10;
|
||||
|
||||
let edit = new GuiEdit(0, 0, 0, 0);
|
||||
shadow.append(edit);
|
||||
edit.posRelative({x: 0.45, y: 0, w: 0.55, h: 0.6});
|
||||
edit.x -= 10;
|
||||
edit.y += 10;
|
||||
editShadow.append(edit);
|
||||
edit.posRelative({w: 1, h: 1});
|
||||
|
||||
let editInfoText = new GuiText('', 0, 0, 0, 0, {
|
||||
size: 10,
|
||||
align: 'center'
|
||||
});
|
||||
editShadow.append(editInfoText);
|
||||
editInfoText.posRelative({x: 0.5, y: 1});
|
||||
editInfoText.y += 5;
|
||||
|
||||
let editWarnText = new GuiText('', 0, 0, 0, 0, {
|
||||
size: 10,
|
||||
align: 'center'
|
||||
});
|
||||
editShadow.append(editWarnText);
|
||||
editWarnText.posRelative({x: 0.5, y: 1});
|
||||
editWarnText.y += 20;
|
||||
|
||||
edit.textElements = {
|
||||
info: editInfoText,
|
||||
warn: editWarnText
|
||||
};
|
||||
|
||||
|
||||
let inventory = new GuiInventory(0, 0, 0, 0);
|
||||
shadow.append(inventory);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue