Skip to content

Commit

Permalink
fix(projects): Remove unused items
Browse files Browse the repository at this point in the history
- Remove directory picker on platforms that don't support it
- Make command versions a recommendation, not an error
  • Loading branch information
mammerla committed Sep 3, 2024
1 parent c16eeae commit b7a8e38
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 169 deletions.
6 changes: 3 additions & 3 deletions app/public/data/gallery.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@
"description": "The cow can be found mooing about in grassy areas. It is very resourceful and makes for a great cattle companion.",
"gitHubOwner": "mojang",
"gitHubRepoName": "bedrock-samples",
"id": "Cat",
"id": "cat",
"type": 4,
"localLogo": "entity/cat/calico.png",
"logoLocation": { "x": 5, "y": 3, "width": 5, "height": 6, "imageWidth": 64 },
Expand Down Expand Up @@ -587,7 +587,7 @@
"description": "The cow can be found mooing about in grassy areas. It is very resourceful and makes for a great cattle companion.",
"gitHubOwner": "mojang",
"gitHubRepoName": "bedrock-samples",
"id": "Cow",
"id": "cow",
"type": 4,
"localLogo": "entity/cow/cow.png",
"logoLocation": { "x": 6, "y": 6, "width": 8, "height": 8, "imageWidth": 64 },
Expand All @@ -608,7 +608,7 @@
"description": "The creeper is a mob that can sneak up on you when you least expect it and trigger a devastating attack by blowing up.",
"gitHubOwner": "mojang",
"gitHubRepoName": "bedrock-samples",
"id": "Creeper",
"id": "creeper",
"type": 4,
"localLogo": "entity/creeper/creeper.png",
"logoLocation": { "x": 8, "y": 8, "width": 8, "height": 8, "imageWidth": 64 },
Expand Down
2 changes: 1 addition & 1 deletion app/src/UX/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ export default class Home extends Component<IHomeProps, IHomeState> {
onClick: this._handleConnectClick,
title: "Connect",
});
} else {
} else if (window.showDirectoryPicker !== undefined) {
actionsToolbar.push({
icon: <LocalFolderLabel isCompact={false} />,
key: "openFolderA",
Expand Down
50 changes: 26 additions & 24 deletions app/src/UX/ProjectActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,35 +133,37 @@ export default class ProjectActions extends Component<IProjectActionsProps, IPro
</Button>
);

exportBin.push(
<Button
className="pact-toolTile"
key="pact-exportLocalFolder"
style={{
borderColor: this.props.theme.siteVariables?.colorScheme.brand.background1,
}}
onClick={this._exportLocal}
onMouseDown={this._handleToolTileMouseDown}
onMouseUp={this._handleToolTileMouseUp}
>
<div
className="pact-toolTileInner"
if (window.showDirectoryPicker !== undefined) {
exportBin.push(
<Button
className="pact-toolTile"
key="pact-exportLocalFolder"
style={{
borderColor: this.props.theme.siteVariables?.colorScheme.brand.background2,
backgroundColor: this.props.theme.siteVariables?.colorScheme.brand.background3,
color: this.props.theme.siteVariables?.colorScheme.brand.foreground2,
borderColor: this.props.theme.siteVariables?.colorScheme.brand.background1,
}}
onClick={this._exportLocal}
onMouseDown={this._handleToolTileMouseDown}
onMouseUp={this._handleToolTileMouseUp}
>
<div className="pact-toolTile-label">
<div className="pact-faIconWrap">
<FontAwesomeIcon icon={faFolder} className="fa-xl" />
<div
className="pact-toolTileInner"
style={{
borderColor: this.props.theme.siteVariables?.colorScheme.brand.background2,
backgroundColor: this.props.theme.siteVariables?.colorScheme.brand.background3,
color: this.props.theme.siteVariables?.colorScheme.brand.foreground2,
}}
>
<div className="pact-toolTile-label">
<div className="pact-faIconWrap">
<FontAwesomeIcon icon={faFolder} className="fa-xl" />
</div>
<div className="pact-label">Export to folder on your device</div>
</div>
<div className="pact-label">Export to folder on your device</div>
<div className="pact-toolTile-instruction">Exports this project to a folder on your local device</div>
</div>
<div className="pact-toolTile-instruction">Exports this project to a folder on your local device</div>
</div>
</Button>
);
</Button>
);
}

packageBin.push(
<Button
Expand Down
132 changes: 35 additions & 97 deletions app/src/UX/ProjectEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
this._handleConvertToClick = this._handleConvertToClick.bind(this);
this._handleDialogDataUpdated = this._handleDialogDataUpdated.bind(this);
this._handleGetShareableLinkClick = this._handleGetShareableLinkClick.bind(this);
this._handleWebLocalDeployClick = this._handleWebLocalDeployClick.bind(this);
this._handleChangeWorldSettingsClick = this._handleChangeWorldSettingsClick.bind(this);
this._handleDownloadMCWorldWithPacks = this._handleDownloadMCWorldWithPacks.bind(this);
this._handleDeployDownloadWorldWithPacks = this._handleDeployDownloadWorldWithPacks.bind(this);
Expand Down Expand Up @@ -222,7 +221,6 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
this._handleExportMenuOpen = this._handleExportMenuOpen.bind(this);
this._handleDeployMenuOpen = this._handleDeployMenuOpen.bind(this);
this._handleViewMenuOpen = this._handleViewMenuOpen.bind(this);
this._handleWebLocalDeployOK = this._handleWebLocalDeployOK.bind(this);
this._handleConvertOK = this._handleConvertOK.bind(this);
this._handleIntegrateItemOK = this._handleIntegrateItemOK.bind(this);
this._handleDeployWorldAndTestAssetsPackClick = this._handleDeployWorldAndTestAssetsPackClick.bind(this);
Expand Down Expand Up @@ -677,20 +675,6 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
}
}

private async _handleWebLocalDeployOK() {
this._handleDialogDone();

if (this.props.carto.activeMinecraft) {
const operId = await this.props.carto.notifyOperationStarted(
"Deploying project '" + this.props.project.name + "'..."
);

await this.props.carto.activeMinecraft.syncWithDeployment();

await this.props.carto.notifyOperationEnded(operId, "Deployed '" + this.props.project.name + "'.");
}
}

private async _handleIntegrateItemOK() {
this._handleDialogDone();

Expand Down Expand Up @@ -1592,43 +1576,6 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
});
}, 2);
}

private async _handleWebLocalDeployClick(e: SyntheticEvent | undefined, data: MenuItemProps | undefined) {
if (this.props.project == null || !data || !data.icon) {
return;
}

window.setTimeout(() => {
this.setState({
activeProjectItem: this.state.activeProjectItem,
tentativeProjectItem: this.state.tentativeProjectItem,
activeReference: this.state.activeReference,
menuState: this.state.menuState,
mode: this.state.mode,
viewMode: this.state.viewMode,
allInfoSet: this.props.project.infoSet,
allInfoSetGenerated: this.props.project.infoSet.completedGeneration,
displayFileView: this.state.displayFileView,
forceRawView: this.state.forceRawView,
filteredItems: this.state.filteredItems,
searchFilter: this.state.searchFilter,
effectMode: this.state.effectMode,
dragStyle: this.state.dragStyle,
visualSeed: this.state.visualSeed,
dialog: ProjectEditorDialog.webLocalDeploy,
dialogData: this.state.dialogData,
dialogActiveItem: this.state.dialogActiveItem,
statusAreaMode: this.state.statusAreaMode,
lastDeployKey: (data.icon as any).key,
lastExportKey: this.state.lastExportKey,
lastDeployFunction: this._handleWebLocalDeployClick,
lastExportFunction: this.state.lastExportFunction,
lastDeployData: data,
lastExportData: this.state.lastExportData,
});
}, 2);
}

private async _handleChangeWorldSettingsClick(e: SyntheticEvent | undefined, data: MenuItemProps | undefined) {
if (this.props.project == null || !data || !data.icon) {
return;
Expand Down Expand Up @@ -2967,7 +2914,7 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
};
exportMenu.push(exportKeys[nextExportKey]);

if (!AppServiceProxy.hasAppService) {
if (!AppServiceProxy.hasAppService && window.showDirectoryPicker !== undefined) {
exportMenu.push({
key: "dividerEXP",
kind: "divider",
Expand Down Expand Up @@ -3044,18 +2991,6 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje

const deployMenu: any = [];

if (CartoApp.isWeb) {
const deployWebLocalKey = "deployToLocalFolder";
deployKeys[deployWebLocalKey] = {
key: deployWebLocalKey + "A",
icon: <FontAwesomeIcon icon={faBox} key={deployWebLocalKey} className="fa-lg" />,
content: "Deploy to local Minecraft folder",
onClick: this._handleWebLocalDeployClick,
title: "Deploys this to a remote Dev Tools server",
};
deployMenu.push(deployKeys[deployWebLocalKey]);
}

for (let i = 0; i < this.props.project.items.length; i++) {
const pi = this.props.project.items[i];

Expand All @@ -3077,18 +3012,18 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
if (world) {
title = world.name;
}

/*
nextExportKey = "exportWorld|" + pi.name;
exportKeys = {
exportKeys[nextExportKey] = {
key: nextExportKey,
icon: <FontAwesomeIcon icon={faBox} className="fa-lg" />,
content: title + " world",
onClick: this._handleExportWorld,
title: "Download " + title,
};
exportMenu.push(exportKeys[nextExportKey]);
exportMenu.push(exportKeys[nextExportKey]);*/

if (AppServiceProxy.hasAppServiceOrSim) {
nextExportKey = "convertTo|" + pi.name;
Expand All @@ -3112,6 +3047,7 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
};
deployMenu.push(deployKeys[dlsKey]);

/*
const miKey = "deployWorldTestAssetsPack|" + pi.name;
deployKeys[miKey] = {
key: miKey + "A",
Expand All @@ -3121,18 +3057,7 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
title: "Deploys " + title + " and test assets in a zip",
};
deployMenu.push(deployKeys[miKey]);

if (AppServiceProxy.hasAppServiceOrDebug) {
const miKeyA = "deployWorldTestAssetsLocal|" + pi.name;
deployKeys[miKeyA] = {
key: miKeyA,
icon: <FontAwesomeIcon icon={faBox} key={miKeyA} className="fa-lg" />,
content: title + " and test assets to Minecraft",
onClick: this._handleDeployWorldAndTestAssetsLocalClick,
title: "Deploys " + title + " and test assets in a zip",
};
deployMenu.push(deployKeys[miKeyA]);
}
*/
}
}

Expand Down Expand Up @@ -3578,23 +3503,36 @@ export default class ProjectEditor extends Component<IProjectEditorProps, IProje
} else {
const exportItem = exportKeys[this.state.lastExportKey];

toolbarItems.push({
icon: <CustomLabel icon={exportItem.icon} text={exportItem.content} isCompact={isButtonCompact} />,
key: exportItem.key + "I",
onClick: exportItem.onClick,
active: true,
title: exportItem.title,
});
if (exportItem) {
toolbarItems.push({
icon: <CustomLabel icon={exportItem.icon} text={exportItem.content} isCompact={isButtonCompact} />,
key: exportItem.key + "I",
onClick: exportItem.onClick,
active: true,
title: exportItem.title,
});

toolbarItems.push({
icon: <DownArrowLabel />,
key: "export",
onMenuOpenChange: this._handleExportMenuOpen,
menuOpen: this.state.menuState === ProjectEditorMenuState.exportMenu,
menu: exportMenu,
active: true,
title: "Export Options",
});
toolbarItems.push({
icon: <DownArrowLabel />,
key: "export",
onMenuOpenChange: this._handleExportMenuOpen,
menuOpen: this.state.menuState === ProjectEditorMenuState.exportMenu,
menu: exportMenu,
active: true,
title: "Export Options",
});
} else {
toolbarItems.push({
key: "export",
icon: <MCPackLabel isCompact={isButtonCompact} />,
content: "Export",
title: isButtonCompact ? "" : "Export",
active: true,
menuOpen: this.state.menuState === ProjectEditorMenuState.exportMenu,
onMenuOpenChange: this._handleExportMenuOpen,
menu: exportMenu,
});
}
}

if (
Expand Down
2 changes: 1 addition & 1 deletion app/src/UX/ProjectGallery.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.pg-tabArea {
display: block;
position: relative;
top: 1px;
top: 0.75px;
padding-top: 10px;
padding-left: 10px;
padding-bottom: 0px;
Expand Down
2 changes: 1 addition & 1 deletion app/src/UX/ProjectItemEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default class ProjectItemEditor extends Component<IProjectItemEditorProps
{this.props.activeProjectItem
? ProjectItemUtilities.getDescriptionForType(this.props.activeProjectItem.itemType)
: ""}{" "}
- {this.props.activeProjectItem?.file?.isContentLoaded ? "loaded." : "loading..."}
- {this.props.activeProjectItem?.file?.isContentLoaded ? "loaded." : ""}
</div>
);
let readOnly = this.props.readOnly;
Expand Down
1 change: 1 addition & 0 deletions app/src/UX/ProjectItemList.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
width: 24px;
height: 25px;
background-color: green;
text-align: center;
}

.pil-cmbUnfocused button {
Expand Down
Loading

0 comments on commit b7a8e38

Please sign in to comment.