Skip to content

Commit

Permalink
various improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sky-is-winning committed Jun 4, 2024
1 parent 85b4ba8 commit 7be1397
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 24 deletions.
2 changes: 1 addition & 1 deletion client/media/crumbs/en.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/media/crumbs/en/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@
"replace-igloo": "This will replace your current igloo. Please copy the data for your current igloo if you want to keep it!",
"copyclipboard": "Copy to clipboard",
"copied": "Copied!",
"search": "Search:",
"entername": "Enter name",
"errors": {
"0": "You need more coins",
"1": "You already have this item",
Expand Down
Binary file modified client/media/interface/game/iglooedit/iglooedit-new-0.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion src/scenes/components/InputText.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class InputText extends EventComponent {
this.firstTrueX = this.trueX
this.firstTrueY = this.trueY

this.update = this.updateRect
this.gameObject.scene.events.on('update', this.updateRect, this)
}

updateRect() {
Expand Down
9 changes: 8 additions & 1 deletion src/scenes/igloos/IglooScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ export default class IglooScene extends RoomScene {

let mask = this.createMask()
this.flooring.setMask(mask)

this.children.list.forEach((f) => {
if (f.frame && f.frame.name == 'floor') {
f.setDepth(-2)
}
})
}

addLocation() {
Expand Down Expand Up @@ -187,6 +193,7 @@ export default class IglooScene extends RoomScene {

loadAllFurniture() {
for (let f of this.args.furniture) {
console.log('loadAllFurniture', f)
this.updateQuantity(f.furnitureId)
this.loader.loadFurniture(f.furnitureId, null, f.x, f.y, f.rotation, f.frame, this)
}
Expand Down Expand Up @@ -305,7 +312,7 @@ export default class IglooScene extends RoomScene {
onPointerMove(pointer) {
if (this.editing && this.selected) {
this.selected.drag(pointer)
if (this.selected.y < 200) {
if (pointer.y < 200) {
this.interface.iglooEdit.showMirror(this.selected.id, this.selected.x, this.selected.y)
} else {
this.interface.iglooEdit.hideMirror()
Expand Down
155 changes: 135 additions & 20 deletions src/scenes/interface/game/iglooedit/IglooEdit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BaseScene from '@scenes/base/BaseScene'

import {Button, Interactive, ShowHint, SimpleButton, LocalisedString} from '@components/components'
import {Button, Interactive, ShowHint, SimpleButton, LocalisedString, InputText} from '@components/components'

import IglooFactory from '@engine/world/room/IglooFactory'

Expand All @@ -24,6 +24,12 @@ export default class IglooEdit extends BaseScene {
this.hide;
/** @type {Phaser.GameObjects.Container} */
this.lower;
/** @type {Phaser.GameObjects.Text} */
this.search;
/** @type {Phaser.GameObjects.Text} */
this.search_input;
/** @type {Phaser.GameObjects.Container} */
this.searchBox;
/** @type {Phaser.GameObjects.Container} */
this.itemContainer;
/** @type {NinePatchContainer} */
Expand Down Expand Up @@ -66,7 +72,6 @@ export default class IglooEdit extends BaseScene {

// controls
const controls = this.add.container(0, 0);
controls.visible = false;

// button_box
const button_box = this.add.image(1424.9985859979595, 883.0016987305266, "iglooedit-new", "cardboardbox");
Expand Down Expand Up @@ -117,6 +122,29 @@ export default class IglooEdit extends BaseScene {
const upper = this.add.container(0, 0);
controls.add(upper);

// searchBox
const searchBox = this.add.container(0, 0);
searchBox.visible = false;
upper.add(searchBox);

// music_panel_1
const music_panel_1 = this.add.image(410, -101, "iglooedit-new", "music-panel");
searchBox.add(music_panel_1);

// search
const search = this.add.text(271, 205, "", {});
search.setOrigin(0, 0.5);
search.text = "Search:";
search.setStyle({ "color": "#3e83c5ff", "fixedWidth":150,"fontFamily": "cpBurbankSmall", "fontSize": "22px", "fontStyle": "bold" });
searchBox.add(search);

// search_input
const search_input = this.add.text(271, 241, "", {});
search_input.setOrigin(0, 0.5);
search_input.text = "Enter Name";
search_input.setStyle({ "color": "#3e83c5ff", "fixedWidth":270,"fontFamily": "cpBurbankSmall", "fontSize": "22px", "fontStyle": "bold" });
searchBox.add(search_input);

// all
const all = this.add.image(659.9985859459266, 215.00169858592562, "iglooedit-new", "all-selected");
upper.add(all);
Expand Down Expand Up @@ -167,6 +195,7 @@ export default class IglooEdit extends BaseScene {

// scrollBarContainer
const scrollBarContainer = this.add.container(-0.00001392595368088223, 0.0015205401127835472);
scrollBarContainer.visible = false;
upper.add(scrollBarContainer);

// rounded_rect
Expand Down Expand Up @@ -333,7 +362,7 @@ export default class IglooEdit extends BaseScene {
// title_3
const title_3 = this.add.text(1180, 397, "", {});
title_3.setOrigin(0.5, 0.5);
title_3.text = "Replace with data from clipboard";
title_3.text = "Replace with JSON from clipboard";
title_3.setStyle({ "align": "center", "color": "#3e83c5ff", "fixedWidth":300,"fontFamily": "cpBurbankSmall", "fontSize": "18px", "fontStyle": "bold" });
title_3.setWordWrapWidth(300);
chooseIgloo.add(title_3);
Expand Down Expand Up @@ -398,6 +427,21 @@ export default class IglooEdit extends BaseScene {
const hideLocalisedString = new LocalisedString(hide);
hideLocalisedString.id = "hide";

// music_panel_1 (components)
new Interactive(music_panel_1);

// search (components)
const searchLocalisedString = new LocalisedString(search);
searchLocalisedString.id = "search";

// search_input (components)
const search_inputLocalisedString = new LocalisedString(search_input);
search_inputLocalisedString.id = "entername";
const search_inputInputText = new InputText(search_input);
search_inputInputText.charlimit = 96;
search_inputInputText.entercallback = () => this.searchForItems();
search_inputInputText.extends = false;

// all (components)
const allSimpleButton = new SimpleButton(all);
allSimpleButton.callback = () => this.selectCategory(0);
Expand Down Expand Up @@ -480,6 +524,9 @@ export default class IglooEdit extends BaseScene {
this.music = music;
this.hide = hide;
this.lower = lower;
this.search = search;
this.search_input = search_input;
this.searchBox = searchBox;
this.itemContainer = itemContainer;
this.scrollbar = scrollbar;
this.scroller = scroller;
Expand All @@ -498,24 +545,23 @@ export default class IglooEdit extends BaseScene {


/* START-USER-CODE */

get clientEmu() {
return {
furnitureInventory: Object.keys(this.shell.crumbs.furniture) .map((id) => {return {id: parseInt(id), type: 'furniture', quantity: 99}}),
locationInventory: Object.keys(this.shell.crumbs.locations) .map((id) => {return {id: parseInt(id), type: 'location', quantity: 1}}),
iglooInventory: Object.keys(this.shell.crumbs.igloos) .map((id) => {return {id: parseInt(id), type: 'igloo', quantity: 1}}),
floorInventory: Object.keys(this.shell.crumbs.flooring) .map((id) => {return {id: parseInt(id), type: 'flooring', quantity: 1}}),

}
}

get currentIgloo() {
let iglooData = JSON.parse(localStorage.iglooData)
return iglooData.currentIgloo
}

create() {
this._create()

this.clientEmu = {
furnitureInventory: Object.keys(this.shell.crumbs.furniture) .map((id) => {return {id: parseInt(id), type: 'furniture', quantity: 99}}) .sort((a, b) => this.crumbs.furniture[a.id].name.localeCompare(this.crumbs.furniture[b.id].name)),
locationInventory: Object.keys(this.shell.crumbs.locations) .map((id) => {return {id: parseInt(id), type: 'location', quantity: 1}}) .sort((a, b) => this.crumbs.locations[a.id].name.localeCompare(this.crumbs.locations[b.id].name)),
iglooInventory: Object.keys(this.shell.crumbs.igloos) .map((id) => {return {id: parseInt(id), type: 'igloo', quantity: 1}}) .sort((a, b) => this.crumbs.igloos[a.id].name.localeCompare(this.crumbs.igloos[b.id].name)),
floorInventory: Object.keys(this.shell.crumbs.flooring) .map((id) => {return {id: parseInt(id), type: 'flooring', quantity: 1}}) .sort((a, b) => this.crumbs.flooring[a.id].name.localeCompare(this.crumbs.flooring[b.id].name)),
}



for (let s of this.spinners) {
s.anims.play('blue-spinner')
}
Expand Down Expand Up @@ -759,7 +805,7 @@ export default class IglooEdit extends BaseScene {
}

let furniture = this.shell.room.furnitureSprites.map((f, i) => {
return `${i}|${f.id}|${f.x}|${f.y}|${parseInt(f.currentFrame[0])}|${parseInt(f.currentFrame[1])}`
return `${i}|${f.id}|${f.x}|${f.y}|${parseInt(f.currentFrame[1])}|${parseInt(f.currentFrame[0])}`
})

// this.airtower.sendXt('g#ur', furniture.join(','))
Expand Down Expand Up @@ -788,11 +834,83 @@ export default class IglooEdit extends BaseScene {
this.categories[id].setFrame(this.categories[id].frame.name + '-selected')
this.loadItems(id)

if (id == 6) {
this.searchBox.visible = true
this.search_input.__InputText.clickZone.visible = true
} else {
this.searchBox.visible = false
this.search_input.__InputText.clickZone.visible = false
this.search_input.__InputText.clearText()
}

if (this.controls.state == 'minimised') {
this.tweenControls()
}
}

searchForItems() {
let search = this.search_input.textContent
let items = []
let exactMatch;

let searchLower = search.toLowerCase()

for (let item of this.clientEmu.furnitureInventory) {
let name = this.crumbs.furniture[item.id].name
if (name.toLowerCase() == searchLower) {
exactMatch = item
continue
}

if (name.toLowerCase().includes(searchLower)) {
items.push(item)
}
}

for (let item of this.clientEmu.locationInventory) {
let name = this.crumbs.locations[item.id].name
if (name.toLowerCase() == searchLower) {
exactMatch = item
continue
}

if (name.toLowerCase().includes(searchLower)) {
items.push(item)
}
}

for (let item of this.clientEmu.iglooInventory) {
let name = this.crumbs.igloos[item.id].name
if (name.toLowerCase() == searchLower) {
exactMatch = item
continue
}

if (name.toLowerCase().includes(searchLower)) {
items.push(item)
}
}

for (let item of this.clientEmu.floorInventory) {
let name = this.crumbs.flooring[item.id].name
if (name.toLowerCase() == searchLower) {
exactMatch = item
continue
}

if (name.toLowerCase().includes(searchLower)) {
items.push(item)
}
}

if (exactMatch) {
items.filter((item) => item != exactMatch)
items.unshift(exactMatch)
}

this.loadItems(items)
}

loadItems(category) {
for (let i = 0; i < this.items.length; i++) {
this.items[i].destroy()
Expand Down Expand Up @@ -829,12 +947,9 @@ export default class IglooEdit extends BaseScene {
})
break
case 6:
this.clientEmu.furnitureInventory.forEach((item) => {
if (this.crumbs.furniture[item.id].type == 4) {
items.push(item)
}
})
break
default:
items = category
}

this.loadIglooItems(items, xcoord)
Expand Down
67 changes: 66 additions & 1 deletion src/scenes/interface/game/iglooedit/IglooEdit.scene
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"id": "5aebe2f5-2ecf-43e9-a438-fdaa0213fb02",
"label": "controls",
"scope": "CLASS",
"visible": false,
"list": [
{
"type": "Image",
Expand Down Expand Up @@ -190,6 +189,71 @@
"label": "upper",
"scope": "CLASS",
"list": [
{
"type": "Container",
"id": "273ce45b-df27-4593-b51f-cb07f1060bbe",
"label": "searchBox",
"scope": "CLASS",
"visible": false,
"list": [
{
"type": "Image",
"id": "92c63c7a-3cbb-46d4-894b-a40dbd6a419e",
"label": "music_panel_1",
"components": [
"Interactive"
],
"texture": {
"key": "iglooedit-new",
"frame": "music-panel"
},
"x": 410,
"y": -101
},
{
"type": "Text",
"id": "75b9062b-ac72-4607-8e6e-466127613664",
"label": "search",
"scope": "CLASS",
"components": [
"LocalisedString"
],
"LocalisedString.id": "search",
"x": 271,
"y": 205,
"originY": 0.5,
"text": "Search:",
"fixedWidth": 150,
"fontFamily": "cpBurbankSmall",
"fontSize": "22px",
"fontStyle": "bold",
"color": "#3e83c5ff"
},
{
"type": "Text",
"id": "648776ea-6a63-442e-b17a-9dd6f8b56c8a",
"label": "search_input",
"scope": "CLASS",
"components": [
"LocalisedString",
"InputText"
],
"LocalisedString.id": "entername",
"InputText.charlimit": 96,
"InputText.entercallback": "() => this.searchForItems()",
"InputText.extends": false,
"x": 271,
"y": 241,
"originY": 0.5,
"text": "Enter Name",
"fixedWidth": 270,
"fontFamily": "cpBurbankSmall",
"fontSize": "22px",
"fontStyle": "bold",
"color": "#3e83c5ff"
}
]
},
{
"type": "Image",
"id": "aa0e11f4-f6b6-4c5d-b2aa-b3b0ce255d00",
Expand Down Expand Up @@ -360,6 +424,7 @@
"scope": "CLASS",
"x": -0.00001392595368088223,
"y": 0.0015205401127835472,
"visible": false,
"list": [
{
"type": "NinePatchContainer",
Expand Down
2 changes: 2 additions & 0 deletions src/scenes/interface/game/iglooedit/IglooItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export default class IglooItem extends Phaser.GameObjects.Container {
}

onClick() {
if (this.scene.shell.room.selected) return

let pointer = this.scene.input.activePointer

if (this.item.type == 'furniture') {
Expand Down

0 comments on commit 7be1397

Please sign in to comment.