Skip to content

Commit

Permalink
hide sim, no hex download
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Apr 26, 2024
1 parent 7e06704 commit a1485bc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/targets/pxtarget.md
Expand Up @@ -216,6 +216,7 @@ Each target has one board (plus optional parts).
autoRun?: boolean; // automatically run program after a change to its code
stopOnChange?: boolean; // stop execution when user changes code
headless?: boolean; // whether simulator should still run while collapsed
hideSim?: boolean; // whether the simulator should be rendered
// buttons and parts
hideRestart?: boolean; // hide the restart button
Expand Down
1 change: 1 addition & 0 deletions localtypings/pxtarget.d.ts
Expand Up @@ -261,6 +261,7 @@ declare namespace pxt {
// instructions?: boolean;
partsAspectRatio?: number; // aspect ratio of the simulator when parts are displayed
headless?: boolean; // whether simulator should still run while collapsed
hideSim?: boolean; // whether simulator should be rendered
trustedUrls?: string[]; // URLs that are allowed in simulator modal messages
invalidatedClass?: string; // CSS class to be applied to the sim iFrame when it needs to be updated (defaults to sepia filter)
stoppedClass?: string; // CSS class to be applied to the sim iFrame when it isn't running (defaults to grayscale filter)
Expand Down
6 changes: 6 additions & 0 deletions webapp/src/editortoolbar.tsx
Expand Up @@ -186,6 +186,9 @@ export class EditorToolbar extends data.Component<ISettingsProps, EditorToolbarS

protected onDownloadButtonClick = async () => {
pxt.tickEvent("editortools.downloadbutton", { collapsed: this.getCollapsedState() }, { interactiveConsent: true });
if (!pxt.appTarget.compile.hasHex) {
return this.saveFile();
}
if (this.shouldShowPairingDialogOnDownload()
&& !pxt.packetio.isConnected()
&& !pxt.packetio.isConnecting()
Expand All @@ -199,6 +202,9 @@ export class EditorToolbar extends data.Component<ISettingsProps, EditorToolbarS
// Matching the tick in the call to compile() above for historical reasons
pxt.tickEvent("editortools.download", { collapsed: this.getCollapsedState() }, { interactiveConsent: true });
pxt.tickEvent("editortools.downloadasfile", { collapsed: this.getCollapsedState() }, { interactiveConsent: true });
if (!pxt.appTarget.compile.hasHex) {
return this.saveFile();
}
(this.props.parent as ProjectView).compile(true);
}

Expand Down
21 changes: 11 additions & 10 deletions webapp/src/sidepanel.tsx
Expand Up @@ -150,6 +150,7 @@ export class Sidepanel extends data.Component<SidepanelProps, SidepanelState> {
handleHardwareDebugClick, onTutorialStepChange, onTutorialComplete } = this.props;

const hasSimulator = !pxt.appTarget.simulator?.headless;
const hideSimulator = pxt.appTarget.simulator?.hideSim;
const showOpenInVscodeButton = parent.isJavaScriptActive() && pxt.appTarget?.appTheme?.showOpenInVscode;

const simContainerClassName = `simulator-container ${this.props.tutorialSimSidebar ? "" : " hidden"}`;
Expand All @@ -162,22 +163,22 @@ export class Sidepanel extends data.Component<SidepanelProps, SidepanelState> {
<div id="editorSidebar" className="editor-sidebar" style={!this.props.tutorialSimSidebar ? { height: editorSidebarHeight } : undefined}>
<div className={simContainerClassName}>
<div className={`ui items simPanel ${showHostMultiplayerGameButton ? "multiplayer-preview" : ""}`} ref={this.handleSimPanelRef}>
<div id="boardview" className="ui vertical editorFloat" role="region" aria-label={lf("Simulator")} tabIndex={inHome ? -1 : 0} />
{showHostMultiplayerGameButton && <div className="ui item grid centered portrait multiplayer-presence">
{!hideSimulator && <div id="boardview" className="ui vertical editorFloat" role="region" aria-label={lf("Simulator")} tabIndex={inHome ? -1 : 0} />}
{!hideSimulator && showHostMultiplayerGameButton && <div className="ui item grid centered portrait multiplayer-presence">
<SimulatorPresenceBar />
</div>}
<simtoolbar.SimulatorToolbar parent={parent} collapsed={collapseEditorTools} simSerialActive={simSerialActive} devSerialActive={deviceSerialActive} showSimulatorSidebar={this.tryShowSimulator} />
{showKeymap && <keymap.Keymap parent={parent} />}
<div className="ui item portrait hide hidefullscreen">
{!hideSimulator && showKeymap && <keymap.Keymap parent={parent} />}
{!hideSimulator && <div className="ui item portrait hide hidefullscreen">
{pxt.options.debug && <Button key="hwdebugbtn" className="teal" icon="xicon chip" text={"Dev Debug"} onClick={handleHardwareDebugClick} />}
</div>
<div className="ui item grid centered portrait hide hidefullscreen">
</div>}
{!hideSimulator && <div className="ui item grid centered portrait hide hidefullscreen">
{showOpenInVscodeButton && <Button className={"teal hostmultiplayergame-button"} icon={"icon share"} text={lf("Open in VS Code")} ariaLabel={lf("Open in Visual Studio Code for Web")} onClick={this.onOpenInVSCodeClick} />}
</div>
<div className="ui item grid centered portrait hide hidefullscreen">
</div>}
{!hideSimulator && <div className="ui item grid centered portrait hide hidefullscreen">
{showHostMultiplayerGameButton && <Button className={"teal hostmultiplayergame-button"} icon={"xicon multiplayer"} text={lf("Host multiplayer game")} ariaLabel={lf("Host multiplayer game")} onClick={this.onHostMultiplayerGameClick} />}
</div>
{showSerialButtons && <div id="serialPreview" className="ui editorFloat portrait hide hidefullscreen">
</div>}
{!hideSimulator && showSerialButtons && <div id="serialPreview" className="ui editorFloat portrait hide hidefullscreen">
<serialindicator.SerialIndicator ref="simIndicator" isSim={true} onClick={this.handleSimSerialClick} parent={parent} />
<serialindicator.SerialIndicator ref="devIndicator" isSim={false} onClick={this.handleDeviceSerialClick} parent={parent} />
</div>}
Expand Down
9 changes: 5 additions & 4 deletions webapp/src/simtoolbar.tsx
Expand Up @@ -119,6 +119,7 @@ export class SimulatorToolbar extends data.Component<SimulatorProps, {}> {
const fullscreen = run && !simOpts.hideFullscreen && !sandbox;
const audio = run && targetTheme.hasAudio;
const isHeadless = simOpts.headless;
const hideSim = simOpts.hideSim;
const screenshot = !!targetTheme.simScreenshot;
const screenshotClass = !!parentState.screenshoting ? "loading" : "";
const debugBtnEnabled = !isStarting && !isSimulatorPending && inCodeEditor;
Expand All @@ -138,7 +139,7 @@ export class SimulatorToolbar extends data.Component<SimulatorProps, {}> {
const showSerialEditorSection = isFullscreen && (simSerialActive || devSerialActive);

return <aside className={"ui item grid centered simtoolbar" + (sandbox ? "" : " portrait ")} role="complementary" aria-label={lf("Simulator toolbar")}>
<div className={`ui icon tiny buttons`} style={{ padding: "0" }}>
{!hideSim && <div className={`ui icon tiny buttons`} style={{ padding: "0" }}>
{make && <sui.Button disabled={debugging} icon='configure' className="secondary" title={makeTooltip} onClick={this.openInstructions} />}
{run && !targetTheme.bigRunButton && <PlayButton parent={parent} simState={parentState.simState} debugging={parentState.debugging} />}
{fullscreen && <sui.Button key='fullscreenbtn' className="fullscreen-button tablet only hidefullscreen" icon="xicon fullscreen" title={fullscreenTooltip} onClick={this.toggleSimulatorFullscreen} />}
Expand All @@ -150,8 +151,8 @@ export class SimulatorToolbar extends data.Component<SimulatorProps, {}> {
icon={`${collapsed ? 'play' : 'stop'}`}
title={collapseIconTooltip} onClick={this.toggleSimulatorCollapse}
/>}
</div>
{!isHeadless && <div className={`ui icon tiny buttons computer only`} style={{ padding: "0" }}>
</div>}
{!isHeadless && !hideSim && <div className={`ui icon tiny buttons computer only`} style={{ padding: "0" }}>
{audio && <MuteButton onClick={this.toggleMute} state={parent.state.mute} />}
{simOpts.keymap && <sui.Button key='keymap' className="keymap-button" icon="keyboard" title={keymapTooltip} onClick={parent.toggleKeymap} />}
</div>}
Expand All @@ -169,7 +170,7 @@ export class SimulatorToolbar extends data.Component<SimulatorProps, {}> {
onClick={this.openDeviceSerial}
/>}
</div>}
{!isHeadless && <div className={`ui icon tiny buttons computer only`} style={{ padding: "0" }}>
{!isHeadless && !hideSim && <div className={`ui icon tiny buttons computer only`} style={{ padding: "0" }}>
{screenshot && <sui.Button disabled={!isRunning} key='screenshotbtn' className={`screenshot-button ${screenshotClass}`} icon={`icon camera left`} title={screenshotTooltip} onClick={this.takeScreenshot} />}
{fullscreen && <sui.Button key='fullscreenbtn' className={`fullscreen-button`} icon={`xicon ${isFullscreen ? 'fullscreencollapse' : 'fullscreen'}`} title={fullscreenTooltip} onClick={this.toggleSimulatorFullscreen} />}
</div>}
Expand Down

0 comments on commit a1485bc

Please sign in to comment.